コード例 #1
0
ファイル: forge.py プロジェクト: nimbostratus/forger
class Forger(object):
    def __init__(self):
        self.sources = SourceRegistry()
        self.sources.add('tests/casts.json')
        self.sources.add('http://localhost:5000')
        self.sources.add('http://casts.nimbostratus.de')

    def run(self, args):
        if not args.verbose:
            logging.basicConfig(level=logging.ERROR)
        getattr(self, "do_" + args.subcommand)(args)

    def do_search(self, args):
        results = self.sources.search(args.expression)
        key_width = max([len(k) for k in results.keys()]) + 1
        format_str = "%-" + str(key_width) + "s %s"
        for k, v in results.items():
            print(format_str % (k, v['description']))

    def do_clone(self, args):
        cast = self.sources.get_cast(args.name)
        cast.clone(args.directory)

    def do_show(self, args):
        cast = self.sources.get_cast(args.name)
        print("Type:        ", cast.type)
        print("Name:        ", cast.name)
        print("Description: ", cast.description)
        print("Url:         ", cast.url)
コード例 #2
0
ファイル: forge.py プロジェクト: nimbostratus/forger
 def __init__(self):
     self.sources = SourceRegistry()
     self.sources.add('tests/casts.json')
     self.sources.add('http://localhost:5000')
     self.sources.add('http://casts.nimbostratus.de')