示例#1
0
def modify_channel(channel):
    path = '%s/AndroidManifest.xml' % (get_source_file_path(channel))
    tree = xml_helper.read_xml(path)
    nodes = xml_helper.find_nodes(tree, 'application/meta-data')
    result_nodes = xml_helper.get_node_by_keyvalue(nodes, {get_attrib_in_android_xml('name'): "CHANNEL"})
    xml_helper.change_node_properties(result_nodes, {get_attrib_in_android_xml('value'): channel})
    xml_helper.write_xml(tree, path)
示例#2
0
 def modify_xml_file(self, file_path, tag, node_name, value):
     tree = xml_helper.read_xml(file_path)
     nodes = xml_helper.find_nodes(tree, tag)
     result_nodes = xml_helper.get_node_by_keyvalue(nodes,
                                                    {"name": node_name})
     xml_helper.change_node_text(result_nodes, value)
     xml_helper.write_xml(tree, file_path)
     pass
示例#3
0
def modify_provider(channel, package):
    path = '%s/AndroidManifest.xml' % (get_source_file_path(channel))
    tree = xml_helper.read_xml(path)
    nodes = xml_helper.find_nodes(tree, 'application/provider')
    xml_helper.change_node_properties(
        nodes,
        {get_attrib_in_android_xml('authorities'): '%s.provider' % (package)})
    xml_helper.write_xml(tree, path)
示例#4
0
def guardar_noticia(medio, seccion):
    """
    :param medio:
    :param seccion:
    :return: guarda las noticias filtrandolas por lo requerido
    """
    path_xml = fm.get_path_xml(medio, seccion)
    url = cr.get_link(medio, seccion)
    noticias_get = get_noticias(url)

    tree = ET.ElementTree(ET.fromstring(noticias_get))
    root = tree.getroot()
    channel = root.find('channel')
    noticias = channel.findall('item')

    for noticia in noticias:
        if not xml.noticia_repetida(path_xml, noticia):
            root.remove(root.find('item'))
        xml.write_xml(path_xml, noticias)
示例#5
0
def modify_apk_package(channel, package):
    path = '%s/AndroidManifest.xml' % (get_source_file_path(channel))
    tree = xml_helper.read_xml(path)
    root = tree.getroot()
    root.attrib['package'] = package
    xml_helper.write_xml(tree, path)