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


Python Sync.getopts方法代码示例

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


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

示例1: Sync

# 需要导入模块: from sync import Sync [as 别名]
# 或者: from sync.Sync import getopts [as 别名]
    group = optparse.OptionGroup(parser, 'Operations', 'Type of sync to run, only supply one.')
    group.add_option('--watch', help='Watch the source folder for changes and sync them to the destination folder',
                       dest='watch', action='store_true', default=False)
    group.add_option('--run', help='Run sync with custom flags specified below',
                       dest='run', action='store_true', default=False)
    parser.add_option_group(group)

    help = {'update':'Update files that are changed in the source folder to the destination',
            'newer':'Only update if the source file is newer than the destination',
            'create':'Create files that don\'t currently exist in destination',
            'purge':'Delete files that don\'t currently exist in destination',
            'watch':'Keep the sync alive and monitor source folder for changes'}

    # Flags
    s = Sync()
    opts = s.getopts()
    group = optparse.OptionGroup(parser, 'Flags', 'Flags to adjust sync')
    for k in opts.keys():
        typ = 'string'
        kwargs = {}
        if isinstance(opts[k], bool):
            typ = 'choice'
            kwargs['choices'] = ['True', 'False']
        group.add_option('--{0}'.format(k), help=(help[k] + ' ' if help.has_key(k) else '') + 'Default: {0}'.format(opts[k]),
                          dest=k, action='store', default=None, type=typ, **kwargs)
    del s
    parser.add_option_group(group)

    # Watch folder customization
    group = optparse.OptionGroup(parser, 'Watch Folder Attributes')
    group.add_option('--watchTitle', help='Title to use for the watch folder display',
开发者ID:moonbot,项目名称:filesync,代码行数:33,代码来源:__main__.py


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