Example #1
0
 def find_unused_resources_name_and_filepath(self):
     result = []
     for file_path in glob.glob(os.path.join(self.project_base_path, "*.*")):
         md5_resource_filename = common.md5_hash(file_path) + os.path.splitext(file_path)[1]
         if md5_resource_filename not in self.unique_resource_names:
             if os.path.basename(file_path) != _PROJECT_FILE_NAME:
                 result += [(md5_resource_filename, file_path)]
     return map(list, zip(*result))
Example #2
0
 def find_unused_resources_name_and_filepath(self):
     result = []
     for file_path in glob.glob(os.path.join(self.project_base_path,
                                             "*.*")):
         md5_resource_filename = common.md5_hash(
             file_path) + os.path.splitext(file_path)[1]
         if md5_resource_filename not in self.unique_resource_names:
             if os.path.basename(file_path) != _PROJECT_FILE_NAME:
                 result += [(md5_resource_filename, file_path)]
     return map(list, zip(*result))
Example #3
0
 def read_md5_to_resource_path_mapping():
     md5_to_resource_path_map = {}
     # TODO: clarify that only files with extension are covered
     for res_file_path in glob.glob(os.path.join(project_base_path, "*.*")):
         resource_name = common.md5_hash(res_file_path) + os.path.splitext(res_file_path)[1]
         md5_to_resource_path_map[resource_name] = res_file_path
     try:
         # penLayer is no regular resource file
         del md5_to_resource_path_map[self["penLayerMD5"]]
     except KeyError:
         # TODO: include penLayer download in webapi
         pass
     assert self["penLayerMD5"] not in md5_to_resource_path_map
     return md5_to_resource_path_map
Example #4
0
 def fixBadScratch3Hashes(self, projectFile, scratch_project_dir):
     import glob
     import os
     from scratchtocatrobat.tools import common
     file_content = projectFile.read()
     for file in glob.glob(scratch_project_dir + "/*.*"):
         if not file.endswith(".json"):
             file_hash = common.md5_hash(file)
             newname = scratch_project_dir+"/"+ file_hash +"." +file.split(".")[-1]
             os.rename(file, newname)
             oldfile = "".join(file.split('/')[-1].split('.')[0:-1])
             file_content = file_content.replace(oldfile ,file_hash)
     projectFile.flush()
     projectFile.write(file_content)
     return file_content
Example #5
0
 def read_md5_to_resource_path_mapping():
     md5_to_resource_path_map = {}
     # TODO: clarify that only files with extension are covered
     for res_file_path in glob.glob(
             os.path.join(project_base_path, "*.*")):
         resource_name = common.md5_hash(
             res_file_path) + os.path.splitext(res_file_path)[1]
         md5_to_resource_path_map[resource_name] = res_file_path
     try:
         # penLayer is no regular resource file
         del md5_to_resource_path_map[self['penLayerMD5']]
     except KeyError:
         # TODO: include penLayer download in webapi
         pass
     assert self['penLayerMD5'] not in md5_to_resource_path_map
     return md5_to_resource_path_map
Example #6
0
def _resource_name_for(file_path):
    return common.md5_hash(file_path) + os.path.splitext(file_path)[1]
def _resource_name_for(file_path):
    return common.md5_hash(file_path) + os.path.splitext(file_path)[1]