コード例 #1
0
ファイル: test.py プロジェクト: MakerReduxCorp/grammar
def main(argv):
    inputfile = 'examples/bling.MARDS'
    sfile = 'compiled/V1/index.MARDS-schema'
    debug = False
    try:
        opts, args = getopt.getopt(argv, "hdi:s:",
                                   ["ifile=", "sfile=", "debug"])
    except getopt.GetoptError:
        print 'test.py -i <docfile> -s <schemafile>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'test.py -i <ifile> -s <sfile> (default = mr recipe.MARDS-schema> -d <debug>'
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-s", "--sfile"):
            sfile = arg
        elif opt in ("-d", "--debug"):
            debug = True

    print 'docfile is: ', inputfile
    print 'Schema file is: ', sfile
    with open(inputfile, 'r') as docfile:
        doc = docfile.read()
    with open(sfile, 'r') as schemafile:
        schema = schemafile.read()

    if debug == True:
        x, e = MARDS.ml.SCHEMA_to_rolne(schema)
    else:
        x, e = MARDS.string_to_rolne(doc, schema_file=sfile)

    print "FINAL:\n"
    print x._explicit()
    print "ERRORS:\n"
    for err in e:
        print repr(err)
コード例 #2
0
ファイル: test.py プロジェクト: MakerReduxCorp/grammar
def main(argv):
    inputfile = "examples/bling.MARDS"
    sfile = "compiled/V1/index.MARDS-schema"
    debug = False
    try:
        opts, args = getopt.getopt(argv, "hdi:s:", ["ifile=", "sfile=", "debug"])
    except getopt.GetoptError:
        print "test.py -i <docfile> -s <schemafile>"
        sys.exit(2)
    for opt, arg in opts:
        if opt == "-h":
            print "test.py -i <ifile> -s <sfile> (default = mr recipe.MARDS-schema> -d <debug>"
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-s", "--sfile"):
            sfile = arg
        elif opt in ("-d", "--debug"):
            debug = True

    print "docfile is: ", inputfile
    print "Schema file is: ", sfile
    with open(inputfile, "r") as docfile:
        doc = docfile.read()
    with open(sfile, "r") as schemafile:
        schema = schemafile.read()

    if debug == True:
        x, e = MARDS.ml.SCHEMA_to_rolne(schema)
    else:
        x, e = MARDS.string_to_rolne(doc, schema_file=sfile)

    print "FINAL:\n"
    print x._explicit()
    print "ERRORS:\n"
    for err in e:
        print repr(err)
コード例 #3
0
ファイル: export-test.py プロジェクト: MakerReduxCorp/MARDS
def main(argv):
   inputfile = ''
   sfile = 'mr recipe.MARDS-schema'
   debug = False
   warnings = False
   logs = False
   try:
      opts, args = getopt.getopt(argv,"hdwli:s:",["ifile=","sfile=","debug"])
   except getopt.GetoptError:
      print 'test.py -i <docfile> -s <schemafile>'
      sys.exit(2)
   for opt, arg in opts:
      if opt == '-h':
         print 'export-test.py -i <ifile> -s <sfile> (default = mr recipe.MARDS-schema> -d <debug> -w -l'
         sys.exit()
      elif opt in ("-i", "--ifile"):
         inputfile = arg
      elif opt in ("-s", "--sfile"):
         sfile = arg
      elif opt in ("-d", "--debug"):
         debug = True
      elif opt in ("-w", "--warnings"):
         warnings = True
      elif opt in ("-l", "--logs"):
         logs = True

   print 'docfile is: ', inputfile
   print 'Schema file is: ', sfile
   with open(inputfile, 'r') as docfile:
      doc = docfile.read()
   with open(sfile, 'r') as schemafile:
      schema = schemafile.read()

   if debug == True:
      x,e = MARDS.ml.SCHEMA_to_rolne(schema)
   else:
      x,e = MARDS.string_to_rolne(doc, schema)
   
   print "FINAL:\n"
   print x._explicit()
   print "ERRORS:\n\n"
   if warnings:
        print "* warnings shown\n"
   else:
        print "* warnings NOT shown\n"
   if logs:
        print "* logs shown\n\n"
   else:
        print "* logs NOT shown\n\n"
   print "{:<9} {:<6} {:<10} {}\n".format("level", "source", "seq", "message")
   for entry in e:
        show = False
        if entry[0]=='[error]':
            show = True
        if entry[0]=='[warning]' and warnings:
            show = True
        if entry[0]=='[logs]' and logs:
            show = True
        if show:
            print "{:<9} {:<6} {:<10} {}\n".format(entry[0], entry[1], entry[2], entry[3])

   print "EOL\n"
コード例 #4
0
ファイル: quick_test.py プロジェクト: MakerReduxCorp/MARDS
'''

breakdown_text = '''
root index
    title "blah blah"
    add_body_file intro.rst

    sub blinkb
        new_doc true
'''
    # sub item
        # new_doc true

schema_file = "temp/simple.MARDS-schema"
with open(schema_file, "r") as fh:
    schema = fh.read()
    schema_dir = os.path.dirname(os.path.realpath(schema_file))
x,e = MARDS.ml.SCHEMA_to_rolne(doc=schema, schema_dir=schema_dir)

breakdown, e = MARDS.string_to_rolne(breakdown_text)
MARDS.doc.generate_rst_files(x, breakdown, "tempdoc")

#x,e = MARDS.string_to_rolne(doc, schema_file="temp/simple.MARDS-schema")
#x,e = MARDS.string_to_rolne(doc)
#x,e = MARDS.compile(x, schema_rolne=r, renumber=True)

# print "FINAL:\n"
# print x._explicit()
# print "ERRORS:\n"
# print repr(e)
print "done."
コード例 #5
0
        print

        print "  Compiling Schema..."
        with open(schema_file, "r") as fh:
            schema_text = fh.read()
            schema_dir = os.path.dirname(os.path.realpath(schema_file))
        schema,e = MARDS.ml.SCHEMA_to_rolne(doc=schema_text, schema_dir=schema_dir)
        print "    compile errors:"
        print "     ",repr(e)
        print "    done."
        print

        print "  Compiling Breakdown..."
        with open(breakdown_file, "r") as fh:
            breakdown_text = fh.read()
        breakdown, e = MARDS.string_to_rolne(breakdown_text)
        print "    compile errors:"
        print "     ",repr(e)
        print "    done."
        print

        print "  Creating RST files..."
        MARDS.doc.generate_rst_files(schema, breakdown, dest_dir)
        print "    done."
        print

        print "  Copying other RST files..."
        for filename in glob.glob(os.path.join(schema_dir, '*.rst')):
            shutil.copy(filename, dest_dir)
        print "done."
コード例 #6
0
ファイル: recipe-test.py プロジェクト: MakerReduxCorp/MARDS
import sys, os
# the action below is a no-no in standard python, but it is done here for
# easy on-the-fly testing.

# this setup assumes that MARDS is NOT in the python library on the local
# machine, but is instead in a parrallel directory.
sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..'))
#print sys.path
import MARDS



with open("Bling.MARDS", 'r') as docfile:
    doc = docfile.read()
with open("mr recipe.MARDS-schema", 'r') as schemafile:
    schema = schemafile.read()

#x,e = MARDS.ml._SCHEMA_to_rolne(schema)
x,e = MARDS.string_to_rolne(doc, schema)
print "FINAL:\n"
print x._explicit()
print "ERRORS:\n"
print repr(e)
コード例 #7
0
    value
        type label
        required
    name size
        treatment one
    name color
        treatment unique
    name title
        required
        treatment concat
        value
            default "unknown"
    search color
        match 'blue'
            search size
                match 33
                    name blueness
                        value
                            required
        match 'yellow'
            name yellowness

'''

# x,e = MARDS._SCHEMA_to_rolne(schema)
x, e = MARDS.string_to_rolne(doc, schema)
print("FINAL:\n")
print(x._explicit())
print("ERRORS:\n")
print(repr(e))
コード例 #8
0
def main(argv):
    inputfile = ''
    sfile = 'mr recipe.MARDS-schema'
    debug = False
    warnings = False
    logs = False
    try:
        opts, args = getopt.getopt(argv, "hdwli:s:",
                                   ["ifile=", "sfile=", "debug"])
    except getopt.GetoptError:
        print('test.py -i <docfile> -s <schemafile>')
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print(
                'export-test.py -i <ifile> -s <sfile> (default = mr recipe.MARDS-schema> -d <debug> -w -l'
            )
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-s", "--sfile"):
            sfile = arg
        elif opt in ("-d", "--debug"):
            debug = True
        elif opt in ("-w", "--warnings"):
            warnings = True
        elif opt in ("-l", "--logs"):
            logs = True

    print('docfile is: ', inputfile)
    print('Schema file is: ', sfile)
    with open(inputfile, 'r') as docfile:
        doc = docfile.read()
    with open(sfile, 'r') as schemafile:
        schema = schemafile.read()

    if debug == True:
        x, e = MARDS.ml.SCHEMA_to_rolne(schema)
    else:
        x, e = MARDS.string_to_rolne(doc, schema)

    print("FINAL:\n")
    print(x._explicit())
    print("ERRORS:\n\n")
    if warnings:
        print("* warnings shown\n")
    else:
        print("* warnings NOT shown\n")
    if logs:
        print("* logs shown\n\n")
    else:
        print("* logs NOT shown\n\n")
    print("{:<9} {:<6} {:<10} {}\n".format("level", "source", "seq",
                                           "message"))
    for entry in e:
        show = False
        if entry[0] == '[error]':
            show = True
        if entry[0] == '[warning]' and warnings:
            show = True
        if entry[0] == '[logs]' and logs:
            show = True
        if show:
            print("{:<9} {:<6} {:<10} {}\n".format(entry[0], entry[1],
                                                   entry[2], entry[3]))

    print("EOL\n")