Пример #1
0
def getArguments():
    sfdoc = sf.load_from_file("saves.json")
    sf.set_doc(sfdoc)
    result, problems = sf.validation.verify(sf.get_document())
    if result:
        print(" ,".join(problems))
        print(sf.prettyprint())
    else:
        print(sf.prettyprint())
    return None
Пример #2
0
def process(args):
    """
    Process arguments passed in from the command linke
    """
    print("ArgDB Command Line UI")
    print()
    if args.generate:
        print("Generating a configuration file for you...")
        config.generate_default()
        exit(1)

    if args.config:
        argdb.init(args.config)
        print(argdb.info())
        print()

        if args.add_datastore:
            print("Adding the following datastore: " + str(args.add_datastore))
            argdb.add_datastore(args.add_datastore)
            exit(1)

        if args.remove_datastore:
            print()
            db_name = args.remove_datastore
            if argdb.delete_datastore(db_name):
                print("Deleting the following datastore: " + db_name)
            else:
                print("There doesn't appear to be a datastore named: " +
                      db_name)
            print(argdb.info())
            exit(1)

        if args.datastore:
            print("Using the following datastore: " + args.datastore)
            if args.add_document:
                print("Adding a sadface document to: " + args.datastore)
                argdb.add_doc(args.datastore, args.add_document)
            elif args.remove_document:
                print("Deleting a sadface document from: " + args.datastore)
                argdb.delete_doc(args.datastore, args.remove_document)
            elif args.get_document:
                doc = argdb.get_doc(args.datastore, args.get_document)
                print(sadface.prettyprint(doc))

    else:
        print(
            "You didn't supply a configuration file. If you don't have one then perhaps you want to generate one?"
        )
Пример #3
0
 def do_prettyprint(self, line):
     print(sadface.prettyprint())
Пример #4
0
 def do_add_resource(self, line):
     sadface.add_resource("hello world")
     print(sadface.prettyprint())
Пример #5
0

    args = parser.parse_args()

    if args.config:
        config.set_config_location(args.config)

    if args.raw:
        sadface.sd = sadface.import_json(args.raw)
    elif args.load:
        sadface.sd = sadface.load_from_file(args.load)
    elif args.aml:
        aml.init(args.aml)
    else:
        sadface.sd = sadface.init()

    if args.save:
        sadface.save(args.save)

    if args.printdoc:
        print(sadface.print_doc())
    elif args.pretty:
        print(sadface.prettyprint())
    elif args.exportdot:
        print(sadface.export_dot())
    
    if args.interactive:
        REPL().cmdloop()
        
            
Пример #6
0
import sadface as sf
"""
A minimal script to demonstrate loading and verifying a SADFace document.
"""

sfdoc = sf.load_from_file("minimal.json")
sf.set_doc(sfdoc)

result, problems = sf.validation.verify(sf.get_document())
if result:
    print(", ".join(problems))
else:
    print(sf.prettyprint())