コード例 #1
0
def create_sample(file: str):
    logger.info('create the sample config XML file: ' + str(file))
    root = ET.Element(Tag.source)
    tree = ET.ElementTree(root)
    #tree._setroot(root)

    root.append(ET.Comment(' Supported version of "app_source" '))
    LMetree.create_subelem(root, Tag.version, __version__)

    apps = ET.SubElement(root, Tag.apps)
    append_eclipse(apps)
    append_java(apps)
    append_npp(apps)
    append_putty(apps)
    append_python(apps)
    append_git(apps)
    append_winmerge(apps)

    LMetree.indent(root)
    # NOTE: ElementTree.write() will use new line cgar CRLF but git repo has line ending LF
    #tree.write(file, encoding="UTF-8", xml_declaration=True)
    '''
    # NOTE: copied from ElementTree module _get_writer(...) -function
    #       This does not work -> byte writer is expected by ElementTree._get_writer()
    file_objects = open(file, "w", encoding="UTF-8", newline='\n',
                        errors="xmlcharrefreplace")
    '''
    file_objects = open(file, "wb")
    # TODO: ElementTree.write() -function should have parameter 'newline' and it should be passed to _get_writer() -function
    # TODO: Send request to ElementTree toolkit project. Python core project?
    #   https://docs.python.org/3/library/xml.etree.elementtree.html
    tree.write(file_objects, encoding="UTF-8", xml_declaration=True)
コード例 #2
0
def set_file(elem: Element, file: str = None):
    LMetree.create_subelem(elem, Tag.file, file)
コード例 #3
0
def set_sha256url(elem: Element,
                  sha256url: str = None,
                  sha256file: str = None):
    LMetree.create_subelem(elem, Tag.sha256url, sha256url)
    LMetree.create_subelem(elem, Tag.sha256file, sha256file)
コード例 #4
0
def set_md5sum(elem: Element, md5sum: str = None):
    LMetree.create_subelem(elem, Tag.md5sum, md5sum)
コード例 #5
0
def set_sha256sum(elem: Element, sha256sum: str = None):
    LMetree.create_subelem(elem, Tag.sha256sum, sha256sum)
コード例 #6
0
def set_md5url(elem: Element, md5url: str = None, md5file: str = None):
    LMetree.create_subelem(elem, Tag.md5url, md5url)
    LMetree.create_subelem(elem, Tag.md5file, md5file)
コード例 #7
0
def set_url(elem: Element, url: str = None):
    LMetree.create_subelem(elem, Tag.url, url)
コード例 #8
0
def append_lateset_element(elem: Element, text: str):
    LMetree.create_subelem(elem, Tag.latest, text)