Python XmlVersionParser Example

说明

python xmlversionparser示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Python

命名空间/包名称: outwikercorexmlversionparser

示例#1

def _print_changelog(path_to_xml, lang):
    xml_content = readTextFile(path_to_xml)
    parser = XmlVersionParser([lang])
    appinfo = parser.parse(xml_content)
    generator = SiteChangelogGenerator(appinfo)
    changelog = generator.make()
    print(changelog)

示例#2

def plugins_list(lang):
    appinfo_list = []
    for plugin_name in PLUGINS_LIST:
        path_to_xml = os.path.join(PLUGINS_DIR,
                                   plugin_name,
                                   plugin_name,
                                   PLUGIN_VERSIONS_FILENAME)
        xml_content = readTextFile(path_to_xml)
        parser = XmlVersionParser([lang])
        appinfo = parser.parse(xml_content)
        appinfo_list.append(appinfo)

    generator = SitePluginsTableGenerator(appinfo_list)
    text = generator.make()
    print(text)

示例#3
文件: sitecontent.py项目: Jenyay/outwiker

    def _processSource(self, source: SiteContentSource) -> None:
        if not os.path.exists(os.path.join(self._templates_path, source.template_file)):
            print_error('Template file not found: {}'.format(source.template_file))
            return

        if not os.path.exists(source.xml_file):
            print_error('XML file not found: {}'.format(source.xml_file))
            return

        xml_content = readTextFile(source.xml_file)
        parser = XmlVersionParser([source.lang])
        appinfo = parser.parse(xml_content)

        # template_content = readTextFile(source.template_file)
        # template = Template(template_content)
        template_env = Environment(loader=FileSystemLoader(self._templates_path))
        template = template_env.get_template(source.template_file)

        current_version = appinfo.versionsList[0]
        version_full_str = str(current_version.version)
        version_main = '.'.join([str(n)
                                 for n
                                 in current_version.version[:-1]]
                                )
        version_build = current_version.version[-1]
        versions_list = appinfo.versionsList
        date = current_version.date_str

        result = template.render(
            version_full=version_full_str,
            version_main=version_main,
            version_build=version_build,
            versions_list=versions_list,
            date=date,
        )

        template_name = os.path.basename(source.template_file)
        result_fname = os.path.join(self.build_dir, template_name)
        writeTextFile(result_fname, result)

示例#4
文件: versions.py项目: Jenyay/outwiker

def downloadAppInfo(url):
    downloader = Downloader(DOWNLOAD_TIMEOUT)
    version_parser = XmlVersionParser(['en'])
    xml_content = downloader.download(url)
    appinfo = version_parser.parse(xml_content)
    return appinfo

展开阅读全文