Beispiel #1
0
    def prepare_file(filename):
        f = open(filename)
        data = f.read()
        f.close()

        e = chardet.detect(data)

        if (e['confidence'] == 0.99 and e['encoding'] == 'windows-1251'):
            data = data.decode('cp1251').encode('utf-8')
        elif (e['confidence'] == 1.0 and e['encoding'] == 'UTF-8'):
            data = data.decode('utf-8-sig').encode('utf-8')

        new_line = '\r\n\r\n'
        if not data.endswith(new_line):
            data += new_line

        f = open(filename, 'w')
        f.write(data)
        f.close()
Beispiel #2
0
     project_folder = sys.argv[1]
 else:
     project_folder = input("Enter Path to skin: ")
 INFOS.init_addon(project_folder)
 INFOS.check_xml_files()
 for path in INFOS.addon.get_xml_files():
     if Utils.check_bom(path):
         logging.info("found BOM. File: " + path)
     try:
         with codecs.open(path, "rb", encoding='utf-8', errors="strict") as f:
             text = f.read()
     except Exception:
         logging.info("Error when trying to read %s as UTF-8" % path)
         with codecs.open(path, "rb", errors="ignore") as f:
             rawdata = f.read()
         encoding = chardet.detect(rawdata)
         logging.info("detected encoding: %s" % encoding["encoding"])
         with codecs.open(path, "rb", encoding=encoding["encoding"]) as f:
             text = f.read()
 result = eol.eol_info_from_path_patterns([project_folder],
                                          recursive=True,
                                          includes=[],
                                          excludes=['.svn', '.git'])
 for item in result:
     if item[1] == '\n' or None:
         continue
     elif item[1] == '\r':
         logging.info("MAC Line Endings detected in " + item[0])
     else:
         logging.info("Windows Line Endings detected in " + item[0])
 logging.info("\n\nADDON DEPENDENCY CHECK\n\n")
Beispiel #3
0
 INFOS.update_builtin_labels()
 INFOS.init_addon(project_folder)
 INFOS.update_xml_files()
 INFOS.check_xml_files()
 for path in INFOS.file_list_generator():
     if check_bom(path):
         log("found BOM. File: " + path)
     try:
         with codecs.open(path, "rb", encoding='utf-8',
                          errors="strict") as f:
             text = f.read()
     except:
         log("Error when trying to read %s as UTF-8" % path)
         with codecs.open(path, "rb", errors="ignore") as f:
             rawdata = f.read()
         encoding = chardet.detect(rawdata)
         log("detected encoding: %s" % encoding["encoding"])
         with codecs.open(path, "rb", encoding=encoding["encoding"]) as f:
             text = f.read()
 result = eol.eol_info_from_path_patterns([project_folder],
                                          recursive=True,
                                          includes=[],
                                          excludes=['.svn', '.git'])
 for item in result:
     if item[1] == '\n' or None:
         continue
     elif item[1] == '\r':
         log("MAC Line Endings detected in " + item[0])
     else:
         log("Windows Line Endings detected in " + item[0])
 log("\n\nADDON DEPENDENCY CHECK\n\n")