configurationengine/source/plugins/common/ConeContentPlugin/contentplugin/contentmlparser.py
changeset 5 d2c80f5cab53
parent 3 e7e0ae78773e
equal deleted inserted replaced
4:0951727b8815 5:d2c80f5cab53
    58 
    58 
    59     def get_configuration(self, configuration):
    59     def get_configuration(self, configuration):
    60         self.configuration = configuration
    60         self.configuration = configuration
    61 
    61 
    62     def path_convert(self, path):
    62     def path_convert(self, path):
    63         match = re.match('([a-zA-Z]:)(.*)', path)
    63         if isinstance(path,list):
    64         if match:
    64             converted_paths = []
    65             path = match.group(2)
    65             for path_item in path:
    66         return path.lstrip('\\/')
    66                 converted_paths.append(self.path_convert(path_item))
       
    67             return converted_paths
       
    68         else:
       
    69             match = re.match('([a-zA-Z]:)(.*)', path)
       
    70             if match:
       
    71                 path = match.group(2)
       
    72             return path.lstrip('\\/')
    67 
    73 
    68     def get_dir(self):
    74     def get_dir(self):
    69         if self.configuration and ConfmlRefs.is_confml_ref(self._dir):
    75         if self.configuration and ConfmlRefs.is_confml_ref(self._dir):
    70             parts = self._dir.split(ConfmlRefs.ref_separator)
    76             parts = self._dir.split(ConfmlRefs.ref_separator)
    71             for (index, part) in enumerate(parts):
    77             for (index, part) in enumerate(parts):
    90                     ref = ConfmlRefs.get_confml_ref(part)
    96                     ref = ConfmlRefs.get_confml_ref(part)
    91                     parts[index] = self.configuration.get_default_view().get_feature(ref).value
    97                     parts[index] = self.configuration.get_default_view().get_feature(ref).value
    92                     parts[index] = self.path_convert(parts[index])
    98                     parts[index] = self.path_convert(parts[index])
    93                 else:
    99                 else:
    94                     parts[index] = part
   100                     parts[index] = part
       
   101             #sequence tester
       
   102             has_sequence = False
       
   103             seq_indexes = []
       
   104             for (index,single_part) in enumerate(parts):
       
   105                 if isinstance(single_part,list):
       
   106                     has_sequence= True
       
   107                     seq_indexes.append(index)
       
   108                     break
       
   109 
       
   110             if has_sequence:
       
   111                 final_list = []
       
   112                 list_index = 0
       
   113                 while len(parts[seq_indexes[0]]) > list_index:
       
   114                     tmp_list = []
       
   115                     for tmp_part in parts:
       
   116                         if isinstance(tmp_part,list):
       
   117                             tmp_list.append(tmp_part[list_index])
       
   118                         else:
       
   119                             tmp_list.append(tmp_part)
       
   120                     final_list.append((os.sep).join(tmp_list))
       
   121                     list_index = list_index + 1
       
   122                 return final_list
    95             return (os.sep).join(parts)
   123             return (os.sep).join(parts)
    96         else:
   124         else:
    97             return self._file
   125             return self._file
    98 
   126 
    99     def set_file(self, file):
   127     def set_file(self, file):