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


Python Checker.is_changed方法代码示例

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


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

示例1: __init__

# 需要导入模块: from checker import Checker [as 别名]
# 或者: from checker.Checker import is_changed [as 别名]

#.........这里部分代码省略.........

            # Go through each module and pass the necessary infos to them
            first_cycle = True
            while True:
                if first_cycle:
                    jprint('Walks through all files and folders in work path:')
                changed_files = []
                for root, dirs, files in walk(path):
                    # If skip this folder and all subfolders for every module
                    if root in all_exclude['folders']:
                        if first_cycle:
                            jskip(_INDENT, '<ALL>', join(root, '*'), sep='')
                        dirs.clear()
                        continue

                    # If skip subfolder
                    for dir in dirs:
                        if dir in all_exclude['folders']:
                            if first_cycle:
                                jskip(_INDENT, '<ALL>', join(root, dir, '*'))
                            dirs.remove(dir)

                    # Go through all files
                    for file in files:
                        _, ext = splitext(file)
                        # If extension or the filepath is on the black-list
                        if (ext in all_exclude['extensions']     or
                            ext[1:] in all_exclude['extensions'] or
                            file in all_exclude['names']):
                                if first_cycle:
                                    jskip(_INDENT, '<ALL>', join(root, file))
                                continue

                        # If file changed
                        file = join(root, file)
                        if checker.is_changed(file):
                            changed_files.append(file)
                            # If this is an update cycle only
                            if update:
                                continue
                            # Go through each module
                            for module in _MOD_USE_FILE:
                                mod_exclude = configer[module]['exclude']
                                # If file should be processed
                                try:
                                    # If this folder is excluded for module
                                    exclude = mod_exclude.get('folders', ())
                                    if (root in exclude or
                                        basename(root) in exclude):
                                            raise Janitor.Skip

                                    # If this extension is excluded for module
                                    exclude = mod_exclude.get('extensions', ())
                                    if (ext in exclude or
                                        ext[1:] in exclude):
                                            raise Janitor.Skip

                                    # If this file is excluded for module
                                    exclude = mod_exclude.get('names', ())
                                    if (file in exclude):
                                        raise Janitor.Skip

                                    # Use this file
                                    juse(_INDENT, module, file)
                                # If file should be skipped
                                except Janitor.Skip:
                                    jskip(_INDENT, module, file)
                                    continue

                # If any file changed since last
                # check, update and save cache
                if changed_files:
                    #for module in _MODULES:
                    #    module.done()
                    #    module.to_file()
                    if update:
                        jprint('Updates cache files')
                    checker.update(changed_files)
                    checker.to_file()
                    if (watch and
                        not first_cycle):
                        jprint('Watching for changes...')

                # If constantly watching
                if watch:
                    if first_cycle:
                        jprint('Watching for changes...')
                    first_cycle = False
                    update      = False
                    sleep(time)
                else:
                    break
        # If no error occured
        except KeyboardInterrupt:
            print()
        except Janitor.FinishedWithoutError:
            pass

        # Report to user
        return jprint('Finished')
开发者ID:petervaro,项目名称:janitor,代码行数:104,代码来源:janitor.py


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