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


Python Checker.rebuild方法代码示例

本文整理汇总了Python中checker.Checker.rebuild方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.rebuild方法的具体用法?Python Checker.rebuild怎么用?Python Checker.rebuild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在checker.Checker的用法示例。


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

示例1: __init__

# 需要导入模块: from checker import Checker [as 别名]
# 或者: from checker.Checker import rebuild [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')
#.........这里部分代码省略.........
开发者ID:petervaro,项目名称:janitor,代码行数:103,代码来源:janitor.py


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