# HG changeset patch # User Jeff Hammel # Date 1487871311 28800 # Node ID 7d28efc8dfa1042bb2cf988664597a369e3e3b43 # Parent c9d222b85e636f9530e375c4d65c7da48eb524c8 fix + bump diff -r c9d222b85e63 -r 7d28efc8dfa1 setup.py --- a/setup.py Thu Feb 23 09:10:58 2017 -0800 +++ b/setup.py Thu Feb 23 09:35:11 2017 -0800 @@ -1,6 +1,6 @@ from setuptools import setup -version = '0.2.3' +version = '0.3' setup(name='silvermirror', version=version, diff -r c9d222b85e63 -r 7d28efc8dfa1 silvermirror/unify.py --- a/silvermirror/unify.py Thu Feb 23 09:10:58 2017 -0800 +++ b/silvermirror/unify.py Thu Feb 23 09:35:11 2017 -0800 @@ -6,6 +6,7 @@ import argparse import getpass +import json import os import socket import subprocess @@ -43,7 +44,7 @@ except KeyError: raise KeyError("password must be True or False (You gave: '%s')" % password) - ### resources + # resources for resource in config: # directory of resource @@ -62,15 +63,17 @@ ignore += config[resource]['ignore'].split() config[resource]['ignore'] = ignore - ### - config = { 'main': main, 'resources': config } - return config + # return configuration + return {'main': main, 'resources': config} + -def unify(conf, _resources, test=False, verbose=True, notification_prefix='\n*** SilverMirror; '): +def unify(conf, + _resources, + test=False, + verbose=True, + notification_prefix='\n*** SilverMirror; '): """unify virtual filesystems given configuration""" - # TODO: -> OO - # log function def log(message): if verbose: @@ -109,7 +112,7 @@ ### determine resources to sync cwd = os.path.realpath(os.getcwd()) resources = conf['resources'] - if 'all' not in _resources: + if (resources is None) or ('all' not in _resources): if _resources: resources = dict([(key, value) for key, value in resources.items() if key in _resources]) @@ -122,6 +125,7 @@ if test: log("Resources:\n") pprint(resources) + return # choose reflector backend reflectors = dict([(i.name, i.load()) for i in iter_entry_points('silvermirror.reflectors')]) @@ -141,6 +145,7 @@ finally: os.chdir(cwd) + def main(args=sys.argv[1:]): """CLI""" @@ -155,7 +160,7 @@ action='store_true', default=False) parser.add_argument('-v', '--verbose', action='store_true', default=False) - parser.add_argument('resources', nargs='*', + parser.add_argument('resources', nargs='*', default=None, help="resources to sync, or all if omitted") options = parser.parse_args(args) @@ -179,7 +184,7 @@ conf['main']['password'] = options.password and conf['main']['password'] # mirror all the things - unify(conf, args, options.test) + unify(conf, options.resources, test=options.test, verbose=options.verbose) if __name__ == '__main__': unify()