Пример #1
0
 def _validate_headers(self):
     tpl_path = get_template_module_path(self.tpl.mod_type)
     if not os.path.isfile(tpl_path):
         self.no_tpl_file = True
         return
     if len(self.tpl.args) == 0:
         self.no_args = True
     else:
         for i, a in enumerate(self.tpl.args):
             if len(a) != 3:
                 self.not_3_args = True
         if len(self.tpl.args[0][0]) != len(self.tpl.maps):
             self.num_params_ne_num_maps = True
     for m in self.tpl.maps:
         if m[0] not in 'ds':
             self.unknown_map_types.add(m[0])
         offset = 2 if m[0] == 's' else 1
         for t in m[offset:]:
             if t not in self.data.value_maps:
                 self.unknown_map_tables.add(t)
     todos = [
         l[l.find(';'):].replace(';', '').replace(':',
                                                  '').replace('TODO',
                                                              '').strip()
         for l in self.tpl.lines if 'TODO' in l
     ]
     self.todos = [t for t in todos if t != '']
Пример #2
0
 def __init__(self, mod: Module):
     self.mod_type = mod.type
     self.mod_type_name = mod.type_name
     try:
         with open(get_template_module_path(mod.type), 'r') as f:
             self.lines = [l.strip() for l in f]
     except IOError:
         self.lines = []
     self.args_lines, self.args, self.maps = self._parse_headers()
Пример #3
0
def _all_modules_implemented(patch: Patch):
    not_implemented = [
        x.type_name for x in patch.modules
        if not os.path.isfile(get_template_module_path(x.type))
    ]
    if len(not_implemented) > 0:
        print(
            'The patch file contains some modules that has not been implemented yet:'
        )
        print(', '.join(not_implemented))
        print(
            'Please, consider contributing these modules, following our tutorial:'
        )
        print('https://github.com/gleb812/pch2csd/wiki/How-to-add-new-modules')
        return False
    return True