def _load_quantity_strings(self, language, xml_tree): quantity_string_nodes = xml_tree.findall( AndroidImporter.QUANTITY_STRINGS ) resources = {} for quantity_strings in quantity_string_nodes: key = quantity_strings.attrib['name'] resource = QuantityStrings(key, [language]) for item in quantity_strings.findall('item'): quantity = item.attrib['quantity'] if quantity in QuantityStrings.QUANTITIES: resource.add_quantity_string(language, quantity, item.text) resources[key] = resource return resources
def _load_quantity_strings(self, language, xml_tree): quantity_string_nodes = xml_tree.findall( AndroidImporter.QUANTITY_STRINGS) resources = {} for quantity_strings in quantity_string_nodes: key = quantity_strings.attrib['name'] resource = QuantityStrings(key, [language]) for item in quantity_strings.findall('item'): quantity = item.attrib['quantity'] if quantity in QuantityStrings.QUANTITIES: resource.add_quantity_string(language, quantity, item.text) resources[key] = resource return resources
from xml.etree import ElementTree as etree from mst.importer import AndroidImporter from mst import QuantityStrings xml = etree.parse(open('strings.xml')) quantity_string_nodes = xml.findall(AndroidImporter.QUANTITY_STRINGS) print("Loaded %s string arrays" % len(quantity_string_nodes)) language = 'en' resources = [] for quantity_strings in quantity_string_nodes: key = quantity_strings.attrib['name'] resource = QuantityStrings(key, [language]) for item in quantity_strings.findall('item'): quantity = item.attrib['quantity'] if quantity in QuantityStrings.QUANTITIES: resource.add_quantity_string(language, quantity, item.text) resources.append(resource)
from xml.etree import ElementTree as etree from mst.importer import AndroidImporter from mst import QuantityStrings xml = etree.parse( open('strings.xml') ) quantity_string_nodes = xml.findall( AndroidImporter.QUANTITY_STRINGS ) print("Loaded %s string arrays" % len(quantity_string_nodes) ) language = 'en' resources = [] for quantity_strings in quantity_string_nodes: key = quantity_strings.attrib['name'] resource = QuantityStrings(key, [language]) for item in quantity_strings.findall('item'): quantity = item.attrib['quantity'] if quantity in QuantityStrings.QUANTITIES: resource.add_quantity_string(language, quantity, item.text) resources.append( resource )