当前位置: 首页>>代码示例>>Python>>正文


Python monad.Monad类代码示例

本文整理汇总了Python中net.sf.chellow.monad.Monad的典型用法代码示例。如果您正苦于以下问题:Python Monad类的具体用法?Python Monad怎么用?Python Monad使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Monad类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_start_up

def on_start_up(ctx):
    if sys.platform.startswith('java'):
        jython_start(ctx)
    else:
        cpython_start()

    Monad.getUtils()['impt'](globals(), *LIBS)

    for lib_name in LIBS:
        try:
            globals()[lib_name].startup()
        except AttributeError:
            pass
开发者ID:AndyDingley,项目名称:chellow,代码行数:13,代码来源:charge_script.py

示例2: make_fields

from net.sf.chellow.monad import Monad
import StringIO
import sys
import os
import db
import utils
import templater
import hh_importer
Monad.getUtils()['impt'](
    globals(), 'db', 'utils', 'templater', 'general_import', 'hh_importer')
Contract = db.Contract
UserException = utils.UserException
render = templater.render
inv, template = globals()['inv'], globals()['template']


def make_fields(sess, contract, message=None):
    messages = None if message is None else [str(message)]
    return {
        'contract': contract,
        'processes': hh_importer.get_hh_import_processes(contract.id),
        'messages': messages}

sess = None
contract = None
try:
    sess = db.session()
    hh_importer_contract = Contract.get_non_core_by_name(sess, 'hh_importer')

    if inv.getRequest().getMethod() == 'GET':
        hhdc_contract_id = inv.getLong('hhdc_contract_id')
开发者ID:AndyDingley,项目名称:chellow,代码行数:31,代码来源:script.py

示例3: get_lib

def get_lib(lib_name):
    return Monad.getContext().getAttribute("net.sf.chellow." + lib_name)
开发者ID:AndyDingley,项目名称:chellow,代码行数:2,代码来源:charge_script.py

示例4: set_colour

import sys
from net.sf.chellow.monad import Monad
import utils
import db
Monad.getUtils()['impt'](globals(), 'utils', 'db')
inv, template = globals()['inv'], globals()['template']
hh_format = utils.hh_format

if sys.platform.startswith('java'):
    from java.awt.image import BufferedImage
    from javax.imageio import ImageIO
    from java.awt import Color, Font
    from java.lang import System
    import math
    import datetime
    import pytz
    from dateutil.relativedelta import relativedelta

    HH = utils.HH
    Site = db.Site

    colour_list = [
        Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW, Color.MAGENTA,
        Color.CYAN, Color.PINK, Color.ORANGE]

    def set_colour(graphics, supplies, id):
        graphics.setColor(supplies[id][0])

    def add_colour(supplies, id, name, source_code):
        if id not in supplies:
            supplies[id] = [len(supplies), name, source_code]
开发者ID:AndyDingley,项目名称:chellow,代码行数:31,代码来源:script.py

示例5: on_shut_down

from net.sf.chellow.monad import Monad
import time
import traceback
import utils
import db
import hh_importer
import bsuos
import system_price
import bank_holidays
import rcrc
import tlms
import dloads
Monad.getUtils()['impt'](
    globals(), 'utils', 'hh_importer', 'bsuos', 'rcrc', 'tlms', 'db',
    'system_price', 'bank_holidays', 'dloads')

UserException = utils.UserException


def on_shut_down(ctx):
    messages = []
    sess = None
    try:
        sess = db.session()
        for md in (
                hh_importer, bsuos, system_price, rcrc, tlms, bank_holidays,
                dloads):
            try:
                md.shutdown()
            except UserException, e:
                time.sleep(2)
开发者ID:AndyDingley,项目名称:chellow,代码行数:31,代码来源:charge_script.py

示例6: globals

from net.sf.chellow.monad import Monad
import datetime
import os
import traceback
import threading
import pytz
from dateutil.relativedelta import relativedelta
from sqlalchemy import or_
from sqlalchemy.sql.expression import null
import db
import utils
import computer
import dloads
import sys

Monad.getUtils()['impt'](
    globals(), 'templater', 'db', 'utils', 'computer', 'dloads')
inv = globals()['inv']
Site, Era, Bill = db.Site, db.Era, db.Bill
HH, hh_after, hh_format = utils.HH, utils.hh_after, utils.hh_format
totalseconds = utils.totalseconds

caches = {}

year = inv.getInteger("finish_year")
month = inv.getInteger("finish_month")
months = inv.getInteger("months")

if inv.hasParameter('site_id'):
    st_id = inv.getLong('site_id')
else:
    st_id = None
开发者ID:AndyDingley,项目名称:chellow,代码行数:32,代码来源:script.py

示例7: content

from net.sf.chellow.monad import Monad
import datetime
import pytz
from dateutil.relativedelta import relativedelta
from sqlalchemy import or_, and_
import traceback
import utils
import db

Monad.getUtils()["impt"](globals(), "utils", "db")

HH, hh_format = utils.HH, utils.hh_format
RegisterRead, Bill, Supply, Era = db.RegisterRead, db.Bill, db.Supply, db.Era
inv = globals()["inv"]

year = inv.getInteger("end_year")
month = inv.getInteger("end_month")
months = inv.getInteger("months")
if inv.hasParameter("supply_id"):
    supply_id = inv.getLong("supply_id")
else:
    supply_id = None


def content():
    sess = None
    try:
        sess = db.session()

        finish_date = datetime.datetime(year, month, 1, tzinfo=pytz.utc) + relativedelta(months=1) - HH
开发者ID:chanoch,项目名称:chellow,代码行数:30,代码来源:script.py

示例8: sorted

from net.sf.chellow.monad import Monad
import traceback
import collections
import pytz
import threading
import sys
import os
import os.path
import time
import datetime
import utils

Monad.getUtils()['impt'](globals(), 'db', 'utils', 'templater')

UserException = utils.UserException

if sys.platform.startswith('java'):
    download_path = Monad.getContext().getRealPath("/downloads")
else:
    import chellow
    download_path = os.path.join(chellow.app.instance_path, 'downloads')

if not os.path.exists(download_path):
    os.makedirs(download_path)


download_id = 0

lock = threading.Lock()

files = sorted(os.listdir(download_path), reverse=True)
开发者ID:AndyDingley,项目名称:chellow,代码行数:31,代码来源:charge_script.py

示例9: globals

from net.sf.chellow.monad import Monad
import templater
import db
import hh_importer

Monad.getUtils()["impt"](globals(), "db", "utils", "templater", "hh_importer")
render = templater.render
inv, template = globals()["inv"], globals()["template"]

sess = None
try:
    sess = db.session()
    contract_id = inv.getLong("hhdc_contract_id")
    contract = db.Contract.get_hhdc_by_id(sess, contract_id)
    process_id = inv.getLong("process_id")
    process = hh_importer.get_hh_import_processes(contract_id)[process_id]

    render(inv, template, {"contract": contract, "process": process})
finally:
    if sess is not None:
        sess.close()
开发者ID:chanoch,项目名称:chellow,代码行数:21,代码来源:script.py

示例10: hh

from net.sf.chellow.monad import Monad
import scenario

Monad.getUtils()["impt"](globals(), "scenario")
db_id = globals()["db_id"]

create_future_func = scenario.make_create_future_func_simple("aahedc", ["aahedc_gbp_per_gsp_kwh"])


def hh(supply_source):
    bill = supply_source.supplier_bill
    rate_set = supply_source.supplier_rate_sets["aahedc-rate"]

    try:
        supply_source.caches["aahedc"]
    except KeyError:
        supply_source.caches["aahedc"] = {}

        try:
            future_funcs = supply_source.caches["future_funcs"]
        except KeyError:
            future_funcs = {}
            supply_source.caches["future_funcs"] = future_funcs

        try:
            future_funcs[db_id]
        except KeyError:
            future_funcs[db_id] = {"start_date": None, "func": create_future_func(1, 0)}

    for hh in supply_source.hh_data:
        bill["aahedc-msp-kwh"] += hh["msp-kwh"]
开发者ID:chanoch,项目名称:chellow,代码行数:31,代码来源:charge_script.py

示例11: __init__

from decimal import Decimal
from net.sf.chellow.monad import Monad
import utils
import edi_lib

Monad.getUtils()["impt"](globals(), "db", "utils", "templater", "bill_import", "edi_lib")
hh_after = utils.hh_after

read_type_map = {"00": "N", "01": "E", "02": "E", "04": "C", "06": "X", "07": "N"}


class Parser:
    def __init__(self, f):
        self.parser = edi_lib.EdiParser(f)
        self.line_number = None

    def make_raw_bills(self):
        raw_bills = []
        for self.line_number, code in enumerate(self.parser):
            if code == "CLO":
                cloc = self.parser.elements[0]
                account = cloc[1]
            elif code == "BCD":
                ivdt = self.parser.elements[0]
                invn = self.parser.elements[2]
                btcd = self.parser.elements[5]

                reference = invn[0]
                bill_type_code = btcd[0]
                issue_date = self.parser.to_date(ivdt[0])
            elif code == "MHD":
开发者ID:chanoch,项目名称:chellow,代码行数:31,代码来源:charge_script.py

示例12: hh

from net.sf.chellow.monad import Monad
import scenario
Monad.getUtils()['impt'](globals(), 'scenario')
db_id = globals()['db_id']

create_future_func = scenario.make_create_future_func_simple(
    'ro', ['gbp_per_msp_kwh'])


def hh(supply_source):
    bill = supply_source.supplier_bill
    rate_set = supply_source.supplier_rate_sets['ro-rate']

    try:
        supply_source.caches['ro']
    except KeyError:
        supply_source.caches['ro'] = {}

        try:
            future_funcs = supply_source.caches['future_funcs']
        except KeyError:
            future_funcs = {}
            supply_source.caches['future_funcs'] = future_funcs

        try:
            future_funcs[db_id]
        except KeyError:
            future_funcs[db_id] = {
                'start_date': None, 'func': create_future_func(1, 0)}

    for hh in supply_source.hh_data:
开发者ID:AndyDingley,项目名称:chellow,代码行数:31,代码来源:charge_script.py

示例13: content

from net.sf.chellow.monad import Monad
import datetime
import pytz
from sqlalchemy import or_
from sqlalchemy.sql.expression import null
from dateutil.relativedelta import relativedelta
import traceback
import utils
import db
import computer
Monad.getUtils()['impt'](globals(), 'computer', 'db', 'utils')
inv, template = globals()['inv'], globals()['template']

hh_before, HH, hh_format = utils.hh_before, utils.HH, utils.hh_format
form_int = utils.form_int
Contract, Era = db.Contract, db.Era

caches = {}
end_year = form_int(inv, "end_year")
end_month = form_int(inv, "end_month")
months = form_int(inv, "months")
contract_id = form_int(inv, 'hhdc_contract_id')


def content():
    sess = None
    try:
        sess = db.session()

        contract = Contract.get_hhdc_by_id(sess, contract_id)
开发者ID:AndyDingley,项目名称:chellow,代码行数:30,代码来源:script.py

示例14: triad_calc

from net.sf.chellow.monad import Monad
from dateutil.relativedelta import relativedelta
from sqlalchemy.sql.expression import null
from sqlalchemy import or_
import utils
import db
import triad_rates
import computer
import duos
Monad.getUtils()['impt'](
    globals(), 'db', 'utils', 'templater', 'computer', 'duos', 'triad_rates')
HH, hh_after = utils.HH, utils.hh_after
Contract, RateScript = db.Contract, db.RateScript
db_id = globals()['db_id']


def triad_calc(
        bill, prefix, triad_data, financial_year_start, financial_year_finish,
        data_source, month_begin):
    gsp_kw = 0
    for i, triad_hh in enumerate(triad_data):
        triad_prefix = prefix + '-' + str(i + 1)
        bill[triad_prefix + '-date'] = triad_hh['hist-start']
        bill[triad_prefix + '-msp-kw'] = triad_hh['msp-kw']
        bill[triad_prefix + '-status'] = triad_hh['status']
        bill[triad_prefix + '-laf'] = triad_hh['laf']
        bill[triad_prefix + '-gsp-kw'] = triad_hh['gsp-kw']
        gsp_kw += triad_hh['gsp-kw']

    bill[prefix + '-gsp-kw'] = gsp_kw / 3
开发者ID:AndyDingley,项目名称:chellow,代码行数:30,代码来源:charge_script.py

示例15: ccl

from net.sf.chellow.monad import Monad
import datetime
import pytz
import utils
import db
import computer
import scenario

Monad.getUtils()["impt"](globals(), "db", "utils", "computer", "scenario")
HH = utils.HH
Contract = db.Contract
db_id = globals()["db_id"]

create_future_func = scenario.make_create_future_func_simple("ccl", ["ccl_rate"])


def ccl(data_source):
    rate_set = data_source.supplier_rate_sets["ccl-rate"]

    if data_source.supply.find_era_at(data_source.sess, data_source.finish_date + HH) is None:
        sup_end = data_source.finish_date
    else:
        sup_end = None

    try:
        cache = data_source.caches["ccl"]
    except:
        data_source.caches["ccl"] = {}
        cache = data_source.caches["ccl"]

        try:
开发者ID:chanoch,项目名称:chellow,代码行数:31,代码来源:charge_script.py


注:本文中的net.sf.chellow.monad.Monad类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。