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


Python FileUtils.get_filelist方法代码示例

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


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

示例1: main

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import get_filelist [as 别名]
def main(argv=None):
    """Usage: ./CfxCfg.py -p ./ctx """
    if argv is None:
        argv = sys.argv
    try:
        try:
            opts, args = getopt.getopt(argv[1:], "hp:", ["help", "path="])
        except getopt.error, msg:
            raise Usage(msg)

        path = None
        for opt, arg in opts :
            if opt in ("-h", "--help"):
                print __doc__
                sys.exit(0)
            elif opt in ("-p", "--path"):
                path = arg

        if not path :
            raise Usage("option -p is required.")

        print 'Begin.'

        print 'Check path', path

        filelist =  FileUtils.get_filelist(path, '.ini')

        [parse_file(filename) for filename in filelist]

        print 'End.'
开发者ID:hillscottc,项目名称:git-hill,代码行数:32,代码来源:CtxCfg.py

示例2: main

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import get_filelist [as 别名]
def main(argv=None):
    """Uses the ConFigMgr and related classes.
    
    Usage: ./main.py -p ./remote [-w]
    
    Args: (switches for running ConfigMgr.py main)
       -h: help
       -p: path to config files to be changed
       -w: write. Copies the files from targ dir to work dir and modifies them. 
           (Otherwise, it just reports on files in targ dir)
    """
    
    # set log file
    logpathname = os.path.join(os.getcwd(), 'logs', 'pydbutil.main.log')
    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s %(name)s %(levelname)-5s %(message)s',
                        datefmt='%m-%d %H:%M',
                        filename=logpathname,
                        filemode='w')
    
    print 'BEGIN.'
    
    if argv is None:
        argv = sys.argv
    try:
        try:
            opts, args = getopt.getopt(
                argv[1:], "hp:w", ["help", "path=", "write"])
        except getopt.error, msg:
            raise Usage(msg)
        
        # default value
        path = None
        DO_WRITE = False
        
        for opt, arg in opts :
            if opt in ("-h", "--help"):
                print __doc__
                sys.exit(0)
            elif opt in ("-p", "--path"):
                path = arg
            elif opt in ("-w", "--write"):
                DO_WRITE = True
        
        if not path :
            raise Usage("option -p is required.")
        
        
        if DO_WRITE:
            # copy remote to work. remove old work dir.
            if os.path.exists(ConfigMgr.WORK_DIR) :
                shutil.rmtree(ConfigMgr.WORK_DIR)
            shutil.copytree(path, ConfigMgr.WORK_DIR)
            print "Copied from {0} to {1}".format(path, ConfigMgr.WORK_DIR)
            
            workfiles = FileUtils.get_filelist(ConfigMgr.WORK_DIR, *Configure.FILE_EXTS)
        else:
            # not a write, so use the target path
            workfiles = FileUtils.get_filelist(path, *Configure.FILE_EXTS)
        
        cm = ConfigMgr(dbset=Configure.DBSET, filelist=workfiles, configs=Configure.CONFIGS)
        md = cm.go(write=DO_WRITE)
        
        if DO_WRITE :
            print
            print "{0} files written to dir '{1}'.".format(
                   FileUtils.filecount(ConfigMgr.OUTPUT_DIR), ConfigMgr.OUTPUT_DIR)
        print
        print 'END.'
开发者ID:hillscottc,项目名称:git-hill,代码行数:71,代码来源:main.py


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