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)
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)
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)
def plugins_list(lang=None): ''' Print plugins list for th site ''' if lang is None: print_error(u'Error. No language specified') sys.exit(1) 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)
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)
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)
def _getPluginsUpdateUrls(self, plugins): ''' plugins - instance of the PluginsLoader Return dict which key is plugin name, value is updatesUrl ''' result = {} for plugin in plugins: xmlPath = os.path.join(plugin._pluginPath, PLUGIN_VERSION_FILE_NAME) try: xmlText = readTextFile(xmlPath) except IOError: logger.warning(u"Can't read {}".format(xmlPath)) continue versionParser = XmlVersionParser([_(u'__updateLang'), u'en']) try: result[plugin.name] = versionParser.parse(xmlText).updatesUrl except ValueError: logger.warning(u"Invalid format {}".format(xmlPath)) continue return result
def downloadAppInfo(url): downloader = Downloader(DOWNLOAD_TIMEOUT) version_parser = XmlVersionParser(['en']) xml_content = downloader.download(url) appinfo = version_parser.parse(xml_content) return appinfo
def downloadAppInfo(url): downloader = Downloader(DOWNLOAD_TIMEOUT) version_parser = XmlVersionParser(['en']) xml_content = downloader.download(url) appinfo = version_parser.parse(xml_content) return appinfo