Exemple #1
0
def main():
    parser = build_argparser()
    opts = parser.parse_args(sys.argv[1:])

    # Process all the files 
    xml_strs = []
    filespecs = opts.filespecs[:]
    for filespec in filespecs:
        # A concrete .info file:
        if isfile(filespec):
            f = InfoFile.from_info_file(filespec)
            f.location = opts.location
            xml_strs.append(f.to_xml_str())
        elif isdir(filespec):
            filespecs.extend(glob(os.path.join(filespec, "*.info")))
            if opts.recurse:
                # Also add all the subdirectories
                filespecs.extend(d for d in os.listdir(filespec) if isdir(d))

    # Output appropriately
    if getattr(opts, "append", None):
        raise NotImplementedError

    if opts.output is None:
        opts.output = "updates.xml"

    outfile = file(opts.output, "w")
    outfile.write("\n".join(xml_strs) + "\n")
    outfile.close()
Exemple #2
0
def main():
    parser = build_argparser()
    opts = parser.parse_args(sys.argv[1:])

    # Process all the files
    xml_strs = []
    filespecs = opts.filespecs[:]
    for filespec in filespecs:
        # A concrete .info file:
        if isfile(filespec):
            f = InfoFile.from_info_file(filespec)
            f.location = opts.location
            xml_strs.append(f.to_xml_str())
        elif isdir(filespec):
            filespecs.extend(glob(os.path.join(filespec, "*.info")))
            if opts.recurse:
                # Also add all the subdirectories
                filespecs.extend(d for d in os.listdir(filespec) if isdir(d))

    # Output appropriately
    if getattr(opts, "append", None):
        raise NotImplementedError

    if opts.output is None:
        opts.output = "updates.xml"

    outfile = file(opts.output, "w")
    outfile.write("\n".join(xml_strs) + "\n")
    outfile.close()
Exemple #3
0
def files2xml(filenames):
    """ Given a list of filenames, extracts the app version and log
    information from accompanying files produces an output xml string.

    There are no constraints or restrictions on the names or extensions
    of the input files.  They just need to be accompanied by a sidecar
    file named similarly, but with a ".info" extension, that can be 
    loaded by the InfoFile class.

    If there is no .info file for a filename or an error occurs while constructing it
    a warning message is printed. 
    """

    _xmlheader = """<?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- DO NOT EDIT MANUALLY -->
    <!-- Automatically generated file using enthought.util.updates -->
    """

    xmlparts = [_xmlheader]
    for file in filenames:
        #info_file_name = "{0}.info".format(file)
        info_file_name = "%s.info" % (file, )
        if not os.path.exists(info_file_name):
            #print "Warning: {0} was not found.".format(info_file_name)
            print "Warning: %s was not found." % (info_file_name, )
            continue
        try:
            info = InfoFile.from_info_file(info_file_name)
            xml_list = info.get_xml()
        except:
            #print "Warning: Failure in creating XML for {0}".format(info_file_name)
            print "Warning: Failure in creating XML for %s" % (
                info_file_name, )
            continue
        xmlparts.append('<update_file>')
        xmlparts.extend(xml_list)
        xmlparts.append('</update_file>')

    return "\n".join(xmlparts)
Exemple #4
0
def files2xml(filenames):
    """ Given a list of filenames, extracts the app version and log
    information from accompanying files produces an output xml string.

    There are no constraints or restrictions on the names or extensions
    of the input files.  They just need to be accompanied by a sidecar
    file named similarly, but with a ".info" extension, that can be 
    loaded by the InfoFile class.

    If there is no .info file for a filename or an error occurs while constructing it
    a warning message is printed. 
    """
    
    _xmlheader = """<?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- DO NOT EDIT MANUALLY -->
    <!-- Automatically generated file using enthought.util.updates -->
    """

    xmlparts = [_xmlheader]
    for file in filenames:
        #info_file_name = "{0}.info".format(file)
        info_file_name = "%s.info" % (file,)
        if not os.path.exists(info_file_name):
            #print "Warning: {0} was not found.".format(info_file_name)
            print "Warning: %s was not found." % (info_file_name,)
            continue
        try:
            info = InfoFile.from_info_file(info_file_name)
            xml_list = info.get_xml()
        except:
            #print "Warning: Failure in creating XML for {0}".format(info_file_name)
            print "Warning: Failure in creating XML for %s" % (info_file_name,)
            continue
        xmlparts.append('<update_file>') 
        xmlparts.extend(xml_list)
        xmlparts.append('</update_file>')

    return "\n".join(xmlparts)