本文整理汇总了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.')
示例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.')
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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
示例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()
示例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()
示例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()
示例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)