Esempio n. 1
0
                    i += 1
                icon.add_text(text.replace("\\\\", "\\"))
            log.debug("  text : %s", icon.text)
            log.debug(" importing image : %s", icon.image)
            try:
                image_content = read_function(target_path, icon.image)
                fout = open(os.path.join(config.temp_dir, icon.image),  "wb")
                fout.write(image_content)
                fout.close()          
                pack.add_icon(icon)
            except IOError, (errno, strerror):
                log.warn("error during loading image : " + strerror + " -> skipping")
        elif "Name=" in line:
            pack.name = line.partition("=")[2].strip()
        elif "Author=" in line:
            pack.author = line.partition("=")[2].strip()
        elif "[default]" in line:
            smile_part_started = True
    return pack

@timing
def import_qip_zip(target_file):
    log.debug("import from qip zip started...%s", target_file)
    # TODO add validation
    zip_file = ZipFile(target_file, "r")
    define_entry = filter(lambda item: item.endswith("_define.ini"), zip_file.namelist())[0]
    content = zip_file.read(define_entry)
    pack = Pack()
    pack.name = define_entry.partition("/")[0]
    log.debug(" pack name : %s", pack.name)
    images = filter(lambda item: item.endswith(".gif"), zip_file.namelist())