本文整理汇总了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',