示例#1
0
def gen_admin(options, logger, args):
    """
    generate django admin from UML xml
       usage: gen_models <file_name>"""

    if len(args) != 1 or not os.path.isfile(args[0]):
        print "Please specify one correct file for parse"

    models = parse(options, logger, args[0])

    for model in models:
        print model.gen_admin()
示例#2
0
def gen_choices(options, logger, args):
    """
    generate django choices from UML xml
       usage: gen_choices <file_name>"""

    if len(args) != 1 or not os.path.isfile(args[0]):
        print "Please specify one correct file for parse"

    models = parse(options, logger, args[0])
    # print choices
    for model in models:
        for field in model.fields:
            if field.choices:
                print re.sub(r':', ' =', field.choices)