예제 #1
0
def extract_descriptors(args):
    if os.path.exists(args.outfilename) and not args.force:
        sys.stderr.write(
            '\nFile %s exists.  Use -f/--force to overwrite.\n\n' %
            (args.outfilename, ))
        sys.exit(1)
    if sys.version_info.major == 3:
        outfile = open(args.outfilename, 'w', encoding='utf-8')
    else:
        outfile = open(args.outfilename, 'w')

    schema_file_name = os.path.join(os.path.abspath(os.path.curdir),
                                    args.infilename)
    infile = stringio()
    process_includes.process_include_files(args.infilename,
                                           infile,
                                           inpath=schema_file_name)
    infile.seek(0)

    doc = etree.parse(infile)
    root = doc.getroot()
    descriptors = {}
    extract(root, descriptors, outfile)
    for descriptor in list(descriptors.values()):
        descriptor.export(outfile)
    outfile.close()
def extract_descriptors(infile_name):

    schema_file_name = os.path.join(os.path.abspath(os.path.curdir), infile_name)
    infile = StringIO.StringIO()
    process_includes.process_include_files(infile_name, infile, inpath=schema_file_name)
    infile.seek(0)

    doc = etree.parse(infile)
    root = doc.getroot()

    return extract(root)
예제 #3
0
def extract_descriptors(infile_name):

    schema_file_name = os.path.join(os.path.abspath(os.path.curdir),
                                    infile_name)
    infile = StringIO.StringIO()
    process_includes.process_include_files(infile_name,
                                           infile,
                                           inpath=schema_file_name)
    infile.seek(0)

    doc = etree.parse(infile)
    root = doc.getroot()

    return extract(root)
예제 #4
0
파일: api.py 프로젝트: ajaniv/softwarebook
def _parse_file(file_name, parse_options):
     
    parser = make_parser()
 
    dh = XschemaHandler()

    parser.setContentHandler(dh)
    if file_name == '-':
        infile = sys.stdin
    else:
        infile = open(file_name, 'r')
    if parse_options.get('process_includes') is True:
        import process_includes
        outfile = StringIO.StringIO()
        process_includes.process_include_files(infile, outfile)
        outfile.seek(0)
        infile = outfile
    
    parser.parse(infile)
    root = dh.getRoot()
    root.annotate()
    return root
def extract_descriptors(args):
    if os.path.exists(args.outfilename) and not args.force:
        sys.stderr.write(
            '\nFile %s exists.  Use -f/--force to overwrite.\n\n' % (
            args.outfilename,))
        sys.exit(1)
    outfile = open(args.outfilename, 'w')

    schema_file_name = os.path.join(
        os.path.abspath(os.path.curdir),
        args.infilename)
    infile = StringIO.StringIO()
    process_includes.process_include_files(args.infilename, infile,
        inpath=schema_file_name)
    infile.seek(0)

    doc = etree.parse(infile)
    root = doc.getroot()
    descriptors = {}
    extract(root, descriptors, outfile)
    for descriptor in descriptors.itervalues():
        descriptor.export(outfile)
    outfile.close()
예제 #6
0
def extract_descriptors(args):
    if os.path.exists(args.outfilename) and not args.force:
        sys.stderr.write(
            '\nFile %s exists.  Use -f/--force to overwrite.\n\n' %
            (args.outfilename, ))
        sys.exit(1)
    outfile = open(args.outfilename, 'w')

    schema_file_name = os.path.join(os.path.abspath(os.path.curdir),
                                    args.infilename)
    infile = StringIO.StringIO()
    process_includes.process_include_files(args.infilename,
                                           infile,
                                           inpath=schema_file_name)
    infile.seek(0)

    doc = etree.parse(infile)
    root = doc.getroot()
    descriptors = {}
    extract(root, descriptors, outfile)
    for descriptor in descriptors.itervalues():
        descriptor.export(outfile)
    outfile.close()
예제 #7
0
        nml_attribute = node.attrib.pop(attribute)
        if nml_attribute[0].islower():
            renamed_attribute = to_lowercase_with_underscores(nml_attribute)
            if pluralize_flag:
                renamed_attribute = pluralize(renamed_attribute)
            NameTable[nml_attribute] = renamed_attribute


filename = variables['schema_name']

import StringIO
import process_includes
outfile = StringIO.StringIO()

infile = open(filename, 'r')
process_includes.process_include_files(infile, outfile, inpath=filename)
infile.close()
outfile.seek(0)
doc = objectify.parse(outfile)
root = doc.getroot()
queue = [root]

NameTable = {}

traverse_doc(queue, _node_to_python)

#filtering routine, need to get a better way to extract these, asked on Stack Overflow
import keyword
disallowed_keywords = keyword.kwlist
for keyword in disallowed_keywords:
    try:
예제 #8
0
        if nml_attribute[0].islower():
            renamed_attribute = to_lowercase_with_underscores(nml_attribute)
            if pluralize_flag:
                renamed_attribute = pluralize(renamed_attribute)
            NameTable[nml_attribute] = renamed_attribute


filename = variables["schema_name"]

import StringIO
import process_includes

outfile = StringIO.StringIO()
infile = open(filename, "r")

process_includes.process_include_files(infile, outfile, inpath=filename)
infile.close()
outfile.seek(0)
doc = objectify.parse(outfile)
root = doc.getroot()
queue = [root]

NameTable = {}

traverse_doc(queue, _node_to_python)

# filtering routine, need to get a better way to extract these, asked on Stack Overflow
import keyword

disallowed_keywords = keyword.kwlist
for keyword in disallowed_keywords: