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


Python writer.Writer类代码示例

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


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

示例1: run

def run(**kwargs):
    params = get_params(kwargs)
    configure_logging(params)

    if only_instance_running(params):
        logging.info('Starting execution.')
        write_pid_file(params)  # create lock to avoid concurrent executions

        current_exec_time = utcnow()
        last_exec_time = replace_exec_time(current_exec_time, params['history_path'])

        if 'config' in params:
            config = params['config']
        else:
            config = load_config(params['config_path'])
        config['current_exec_time'] = current_exec_time
        config['last_exec_time'] = last_exec_time
        config['query_folder'] = params['query_folder']
        config['output_folder'] = params['output_folder']
        config['wikis_path'] = params['wikis_path']

        reader = Reader(config)
        selector = Selector(reader, config)
        executor = Executor(selector, config)
        writer = Writer(executor, config)
        writer.run()

        delete_pid_file(params)  # free lock for other instances to execute
        logging.info('Execution complete.')
    else:
        logging.warning('Another instance is already running. Exiting.')
开发者ID:wikimedia,项目名称:analytics-limn-mobile-data,代码行数:31,代码来源:reportupdater.py

示例2: run

def run(**kwargs):
    params = get_params(kwargs)
    configure_logging(params)

    if only_instance_running(params):
        logging.info('Starting execution.')
        write_pid_file(params)  # create lock to avoid concurrent executions

        current_exec_time = utcnow()

        config = load_config(params['config_path'])
        config['current_exec_time'] = current_exec_time
        config['query_folder'] = params['query_folder']
        config['output_folder'] = params['output_folder']
        config['reruns'], rerun_files = read_reruns(params['query_folder'])

        reader = Reader(config)
        selector = Selector(reader, config)
        executor = Executor(selector, config)
        writer = Writer(executor, config, configure_graphite(config))
        writer.run()

        delete_reruns(rerun_files)  # delete rerun files that have been processed
        delete_pid_file(params)  # free lock for other instances to execute
        logging.info('Execution complete.')
    else:
        logging.warning('Another instance is already running. Exiting.')
开发者ID:wikimedia,项目名称:analytics-reportupdater,代码行数:27,代码来源:reportupdater.py

示例3: test

def test():
    log = lambda message: sys.stdout.write(message)
    writer = Writer('D:/exe/imod/IMOD_USER/pusair-output')

    try:
        log('Reading config... ')
        config.parse()
        if config.config['gradient'] > 1:
            raise ValueError('Maximum gradient is 1')
        log('Done\n')

        p, adj = slurp.prep(
            # fbore=str('D:/exe/imod/IMOD_USER/pusair-input/Boreholes_Dimas.ipf'),
            fbore=str('D:/exe/imod/IMOD_USER/pusair-input/Boreholes_Jakarta.ipf'),
            fscreen=str('data/well_M_z_all.ipf'),
            config=config,
            log=log)

        interpolator = Interpolator(p, adj, writer, log)
        interpolator.interpolate()

        log('\n[DONE]')
    except Exception as e:
        log('\n\n[ERROR] {}'.format(e))
        traceback.print_exc()

    writer.reset()
开发者ID:cilsat,项目名称:slurp,代码行数:27,代码来源:gui.py

示例4: dual

def dual(use_spi=False, soft=True):
    ssd0 = setup(False, soft)  # I2C display
    ssd1 = setup(True, False)  # SPI  instance
    Writer.set_textpos(ssd0, 0, 0)  # In case previous tests have altered it
    wri0 = Writer(ssd0, small, verbose=False)
    wri0.set_clip(False, False, False)
    Writer.set_textpos(ssd1, 0, 0)  # In case previous tests have altered it
    wri1 = Writer(ssd1, small, verbose=False)
    wri1.set_clip(False, False, False)

    nfields = []
    dy = small.height() + 6
    col = 15
    for n, wri in enumerate((wri0, wri1)):
        nfields.append([])
        y = 2
        for txt in ('X:', 'Y:', 'Z:'):
            Label(wri, y, 0, txt)
            nfields[n].append(Label(wri, y, col, wri.stringlen('99.99'), True))
            y += dy

    for _ in range(10):
        for n, wri in enumerate((wri0, wri1)):
            for field in nfields[n]:
                value = int.from_bytes(uos.urandom(3),'little')/167772
                field.value('{:5.2f}'.format(value))
            wri.device.show()
            utime.sleep(1)
    for wri in (wri0, wri1):
        Label(wri, 0, 64, ' DONE ', True)
        wri.device.show()
开发者ID:eztmondom,项目名称:test1,代码行数:31,代码来源:writer_tests.py

示例5: do_build

def do_build(args):
    #load config
    config_file = os.path.join(args.src_dir,"_config.py")
    try:
        config.init(config_file)
    except config.ConfigNotFoundException:
        print >>sys.stderr, ("No configuration found: %s" % config_file)
        parser.exit(1, "Want to make a new site? Try `blogofile init`\n")

    logger.info("Running user's pre_build() function..")
    writer = Writer(output_dir="_site")
    if config.blog_enabled == True:
        config.pre_build()
        posts = post.parse_posts("_posts")
        if args.include_drafts:
            drafts = post.parse_posts("_drafts", config)
            for p in drafts:
                p.draft = True
        else:
            drafts = None
        writer.write_blog(posts, drafts)
    else:
        #Build the site without a blog
        writer.write_site()
    logger.info("Running user's post_build() function..")
    config.post_build()
开发者ID:fj,项目名称:blogofile,代码行数:26,代码来源:main.py

示例6: handle_standard_io

def handle_standard_io(parser):
    parser.read_file(sys.stdin)
    #parser.print_file()  # what is this for?
    parser.build_structure() # build doc from actual file
    writer = Writer()
    writer.write(parser.node_file)
    for line in writer.buffer:
        print line.rstrip()
开发者ID:goossaert,项目名称:doge,代码行数:8,代码来源:main.py

示例7: do_build

def do_build(args, load_config=True):
    if load_config:
        config_init(args)
    writer = Writer(output_dir=util.path_join("_site",util.fs_site_path_helper()))
    logger.debug("Running user's pre_build() function..")
    config.pre_build()
    writer.write_site()
    logger.debug("Running user's post_build() function..")
    config.post_build()
开发者ID:jvc,项目名称:blogofile,代码行数:9,代码来源:main.py

示例8: render_html

def render_html(name, source, translator_class=None):
    writer = Writer()
    if translator_class is not None:
        writer.translator_class = translator_class

    settings = {"stylesheet_path": "/static/html4css1.css,/static/main.css",
                "embed_stylesheet": False,
                "file_insertion_enabled": False,
                "raw_enabled": False,
                "xml_declaration": False}

    return publish_string(source, writer_name="html", writer=writer,
                          settings_overrides=settings).decode()
开发者ID:B-Rich,项目名称:wiki,代码行数:13,代码来源:wiki.py

示例9: do_build

def do_build(args):
    #load config
    try:
        # Always load the _config.py from the current directory.
        # We already changed to the directory specified with --src-dir
        config.init("_config.py")
    except config.ConfigNotFoundException:
        print >>sys.stderr, ("No configuration found in source dir: %s" % args.src_dir)
        parser.exit(1, "Want to make a new site? Try `blogofile init`\n")

    writer = Writer(output_dir="_site")
    logger.debug("Running user's pre_build() function..")
    config.pre_build()
    writer.write_site()
    logger.debug("Running user's post_build() function..")
    config.post_build()
开发者ID:turian,项目名称:blogofile,代码行数:16,代码来源:main.py

示例10: test

def test(use_spi=False):
    ssd = setup(use_spi)  # Create a display instance
    rhs = WIDTH -1
    ssd.line(rhs - 20, 0, rhs, 20, 1)
    square_side = 10
    ssd.fill_rect(rhs - square_side, 0, square_side, square_side, 1)

    wri = Writer(ssd, freesans20)
    Writer.set_textpos(ssd, 0, 0)  # verbose = False to suppress console output
    wri.printstring('Sunday\n')
    wri.printstring('12 Aug 2018\n')
    wri.printstring('10.30am')
    ssd.show()
开发者ID:eztmondom,项目名称:test1,代码行数:13,代码来源:writer_demo.py

示例11: __init__

    def __init__(self, module):
        self.module = module
        self.buf = Writer() # modul-ebene

        self.function_buf = Writer() # funktionen kommen seperat
        self.label_count = 0

        self.jump_table = {} # offsets der funktionen
开发者ID:showstopper,项目名称:payne,代码行数:8,代码来源:compiler.py

示例12: main

def main():
    print "Welcome to draugiem.lv message downloader "
    sys.stdout.write("Email: ")
    sys.stdout.flush()
    email = raw_input()
    password = getpass.getpass()
    try:
        downloader = MessageDownloader(email, password)
    except DraugiemException:
        print "invalid username/password"
        sys.exit(1)
    def progress_show(current, total):
        sys.stdout.write("%3d of %d\r" % (current, total))
        sys.stdout.flush()
    print "[1/4] downloading inbox"
    downloader.get_messages(type = 'in', progress_callback = progress_show)
    print "[2/4] downloading outbox"
    downloader.get_messages(type = 'out', progress_callback = progress_show)
    print "[3/4] sorting messages"
    msgs =  downloader.get_all_messages()
    sys.stdout.write("Enter path: ")
    sys.stdout.flush()
    path = raw_input()
    if not os.path.exists(path):
        os.mkdir(path)
    print "[4/4] writing"
    for user in msgs:
        w = Writer(os.path.join(path, "%s.html" % (downloader.get_user_info(user).replace("/", ""))))

        w.start(downloader.users[user])
        for item in msgs[user]:
            w.write(item)
        w.end()
开发者ID:krikulis,项目名称:draugiem_backup,代码行数:33,代码来源:cli.py

示例13: inverse

def inverse(use_spi=False, soft=True):
    ssd = setup(use_spi, soft)  # Create a display instance
    rhs = WIDTH -1
    ssd.line(rhs - 20, 0, rhs, 20, 1)
    square_side = 10
    ssd.fill_rect(rhs - square_side, 0, square_side, square_side, 1)

    Writer.set_textpos(ssd, 0, 0)  # In case previous tests have altered it
    wri = Writer(ssd, freesans20, verbose=False)
    wri.set_clip(False, False, False)  # Char wrap
    wri.printstring('Sunday\n')
    wri.printstring('12 Aug 2018\n')
    wri.printstring('10.30am', True)  # Inverse text
    ssd.show()
开发者ID:eztmondom,项目名称:test1,代码行数:14,代码来源:writer_tests.py

示例14: wrap

def wrap(use_spi=False, soft=True):
    ssd = setup(use_spi, soft)  # Create a display instance
    Writer.set_textpos(ssd, 0, 0)  # In case previous tests have altered it
    wri = Writer(ssd, freesans20, verbose=False)
    wri.set_clip(False, False, True)  # Word wrap
    wri.printstring('the quick    brown fox jumps over')
    ssd.show()
开发者ID:eztmondom,项目名称:test1,代码行数:7,代码来源:writer_tests.py

示例15: main

def main(argv):
    try:
        opts, args = getopt.getopt(argv, "i:o:", ["input", "output"])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    for o, a in opts:
        if o in ("-i", "--input"):
            inputFile = a
        elif o in ("-o", "--output"):
            outputFile = a

    parser = Parser(inputFile)
    writer = Writer()
    writer.fromParser(parser)
    # TODO implement dumping to stdout
    writer.dumpToFile(outputFile)
开发者ID:RPOD,项目名称:ffe.pfarrerbuch,代码行数:18,代码来源:parser.py


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