Example #1
0
def change_all_res_file(res_file_list, edited_res):
    """Search in all the resource XML files a resource reference"""
    for res_file in res_file_list:  # For each XML file
        if u.base_name(res_file) != 'public.xml':  # Do not edit the 'public.xml' file
            for res_line in u.open_file_input(res_file):  # For each line
                if re.search(r'@|name=|\:', res_line) is not None:  # If a resource reference is found
                    change_match_res_file(res_line, edited_res)
                else:  # Otherwise print back the line to file unchanged
                    print res_line,
Example #2
0
def change_all_res_file(res_file_list, edited_res):
    """Search in all the resource XML files a resource reference"""
    for res_file in res_file_list:  # For each XML file
        if u.base_name(
                res_file) != 'public.xml':  # Do not edit the 'public.xml' file
            for res_line in u.open_file_input(res_file):  # For each line
                if re.search(r'@|name=|\:', res_line
                             ) is not None:  # If a resource reference is found
                    change_match_res_file(res_line, edited_res)
                else:  # Otherwise print back the line to file unchanged
                    print res_line,
Example #3
0
def change_all_res_file(res_file_list):
    """Search in all the resource XML files a resource reference"""
    change_meta(u.load_manifest().getroot())
    for res_file in res_file_list:  # For each XML file
        if u.base_name(res_file) == 'strings.xml':  # Edit only the strings/colors resources
                ori_file_name = res_file
                purge_xml_tag_file(ori_file_name)
                res_file = res_file.replace(u.base_dir(), '')
                res_xml = u.load_xml(res_file)
                res_root = res_xml.getroot()
                change_match_res_string_file(res_root)
                u.save_xml(res_file, res_xml)
        if u.base_name(res_file) == 'arrays.xml' or u.base_name(res_file) == 'plurals.xml':  # Edit only the arrays/plurals resources
                ori_file_name = res_file
                purge_xml_tag_file(ori_file_name)
                res_file = res_file.replace(u.base_dir(), '')
                res_xml = u.load_xml(res_file)
                res_root = res_xml.getroot()
                change_match_res_array_file(res_root)
                u.save_xml(res_file, res_xml)
Example #4
0
def change_all_res_file(res_file_list):
    """Search in all the resource XML files a resource reference"""
    change_meta(u.load_manifest().getroot())
    for res_file in res_file_list:  # For each XML file
        if u.base_name(
                res_file
        ) == 'strings.xml':  # Edit only the strings/colors resources
            ori_file_name = res_file
            purge_xml_tag_file(ori_file_name)
            res_file = res_file.replace(u.base_dir(), '')
            res_xml = u.load_xml(res_file)
            res_root = res_xml.getroot()
            change_match_res_string_file(res_root)
            u.save_xml(res_file, res_xml)
        if u.base_name(res_file) == 'arrays.xml' or u.base_name(
                res_file
        ) == 'plurals.xml':  # Edit only the arrays/plurals resources
            ori_file_name = res_file
            purge_xml_tag_file(ori_file_name)
            res_file = res_file.replace(u.base_dir(), '')
            res_xml = u.load_xml(res_file)
            res_root = res_xml.getroot()
            change_match_res_array_file(res_root)
            u.save_xml(res_file, res_xml)
Example #5
0
    def create_thumbnail(self, absolut_file_name, destination_dir):
        """
        creates the thumbnail of absolut_file_name file into destination_dir
        Warning: be sure the create_thumbnail command is safe.
        """

        destination_dir = os.path.join(settings.SENDFILE_ROOT,
                destination_dir)
        try:
            os.mkdir(destination_dir)
        except:
            pass
        basename = base_name(absolut_file_name) + '.png'
        thumbnail_file_name = os.path.join(destination_dir, basename)
        if not os.path.exists(thumbnail_file_name):
            template = \
                string.Template(self.create_thumbnail_command.strip())
            cmd = template.safe_substitute(file_name=absolut_file_name,
                    thumbnail_file_name=thumbnail_file_name)
            LOGGER.debug('creating thumbnail:' + cmd)

            os.system(cmd)
        return thumbnail_file_name