@@ -0,0 +1,1837 @@
+import os%0Aimport sys%0Aimport inspect%0A%0Aimport annotator.model as model%0Aimport annotator.store as store%0A%0Aclass Command:%0A    def __init__(self, model):%0A        self.model = model%0A%0A    def create(self):%0A        %22%22%22%0A        Create a new consumer, returning the consumer key and secret.%0A        %22%22%22%0A        import os%0A        import hashlib%0A%0A        key    = hashlib.sha1(os.urandom(64)).hexdigest()%0A        secret = hashlib.sha256(os.urandom(512)).hexdigest()%0A%0A        c = self.model.Consumer(key=key, secret=secret)%0A        self.model.session.commit()%0A%0A        import json%0A        print json.dumps(c.to_dict(), indent=2)%0A%0A    def get(self, key):%0A        %22%22%22%0A        Get and print the details of the consumer key specified%0A        %22%22%22%0A%0A        c = self.model.Consumer.get(key)%0A%0A        if c:%0A            import json%0A            print json.dumps(c.to_dict(), indent=2)%0A        else:%0A            sys.exit(1)%0A%0Aif __name__ == '__main__':%0A    here = os.path.dirname(os.path.abspath( __file__ ))%0A%0A    if 'ANNOTATOR_CONFIG' in os.environ:%0A        store.app.config.from_envvar('ANNOTATOR_CONFIG')%0A    else:%0A        store.app.config.from_pyfile(here + '/annotator.cfg')%0A%0A    model.metadata.bind = store.app.config%5B'DB'%5D%0A%0A    # Create tables%0A    model.setup_all(True)%0A%0A    if len(sys.argv) %3E= 2:%0A        command = sys.argv%5B1%5D%0A        runner = Command(model)%0A%0A        if hasattr(runner, command):%0A            getattr(runner, command)(*sys.argv%5B2:%5D)%0A        else:%0A            print %22Command not known: %25s%22 %25 command%0A    else:%0A        print %22Usage: python %25s %3Ccommand%3E %5Bargs...%5D%22 %25 (__file__)%0A        print%0A        print %22Commands:%22%0A        for name, member in inspect.getmembers(Command):%0A            doc = inspect.getdoc(member)%0A            if inspect.ismethod(member) and doc:%0A                print %22    %25s %25s%22 %25 (name.ljust(10), inspect.getdoc(member))%0A

Add command line interface to create and fetch consumers