本文整理匯總了Python中checker.Checker.to_file方法的典型用法代碼示例。如果您正苦於以下問題:Python Checker.to_file方法的具體用法?Python Checker.to_file怎麽用?Python Checker.to_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類checker.Checker
的用法示例。
在下文中一共展示了Checker.to_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from checker import Checker [as 別名]
# 或者: from checker.Checker import to_file [as 別名]
def __init__(self, help = False,
version = False,
rebuild = False,
update = False,
generate = False,
default = False,
md5 = False,
sha = False,
kill = False,
watch = False,
time = 10.0,
path = None,
config = None,
exclude = set(),
increase = set()):
try:
# Print version information
if version:
return jprint('version: 1.0.0.000 (20150621)')
# Print help information
if help:
# TODO: add version number to help text
_, width = (int(v) for v in
check_output('stty size',
shell=True).decode('utf-8').split())
return help_printer(_HELP, width, _INDENT)
# Set working-path
path = abspath(expanduser(expandvars(path or getcwd())))
chdir(path)
jprint('Sets work path:\n{}{}'.format(_INDENT, path))
# Create cache directory if does not exist
cache_dir = join(path, _CACHE_DIR)
makedirs(cache_dir, exist_ok=True)
jprint('Sets cache directory:\n{}{}'.format(_INDENT, cache_dir))
# Remove everything and return
if kill:
jprint('Removes every janitor data from work path')
rmtree(cache_dir, ignore_errors=True)
raise Janitor.FinishedWithoutError
# Create sample config file if specified
if generate:
configer = Configer.from_default(config_dir_path=path)
jprint('Generates configuration file:'
'\n{}{}'.format(_INDENT, configer.to_file()))
raise Janitor.FinishedWithoutError
# Set configuration
try:
if default:
configer = Configer.from_default()
jprint('Uses default configuration')
elif config:
config = expanduser(expandvars(config))
configer = Configer(config_file_path=config)
jprint('Uses manually specified configuration file:'
'\n{}{}'.format(_INDENT, config))
else:
configer = Configer(config_dir_path=path)
jprint('Uses configuration file:'
'\n{}{}'.format(_INDENT, join(path, Configer.FILE_NAME)))
except Configer.InvalidConfigFileFormat as e:
jerror('Invalid JSON format in the configuration file')
jerror(e)
exit(EX_CONFIG)
## If use the `versioner` module
#if configer['versioner']['use']:
# pass
## Check increase options
#for option in increase:
# if option not in _SPEC_VALID['increase']:
# return jerror("{!r} is invalid for 'increase'".format(option))
## Increase version number
#if increase:
# versioner = Versioner(path=cache_dir,
# options=increase,
# **configer['versioner'])
# versioner.to_file()
# return jprint('Current version is: {}'.format(versioner.version))
# Import hashing algorithm
if md5:
hash_id = 0
from hashlib import md5 as hasher
jprint('Uses MD5 hashing algorithm')
elif sha:
hash_id = 1
from hashlib import sha1 as hasher
jprint('Uses SHA1 hashing algorithm')
else:
hash_id = 2
try:
from pyhashxx import Hashxx as hasher
jprint('Uses xxHash hashing algorithm')
#.........這裏部分代碼省略.........