attribute_re=re.compile(r'attribute=(\w+)')\r
value_re = re.compile(r'(//.*)')\r
part = []\r
+ part_without_comment = []\r
for x in section[1:]:\r
line=x.split('\n')[0]\r
comment_list = value_re.findall(line) # the string \\... in "Q...." line\r
if attribute[0] in ['0x3','0x7']:\r
offset = int(offset[0], 16)\r
#help = help_re.findall(x)\r
- text = offset, name[0], guid[0], value, attribute[0], comment\r
- part.append(text)\r
+ text_without_comment = offset, name[0], guid[0], value, attribute[0]\r
+ if text_without_comment in part_without_comment:\r
+ # check if exists same Pcd with different comments, add different comments in one line with "|".\r
+ dupl_index = part_without_comment.index(text_without_comment)\r
+ part[dupl_index] = list(part[dupl_index])\r
+ if comment not in part[dupl_index][-1]:\r
+ part[dupl_index][-1] += " | " + comment\r
+ part[dupl_index] = tuple(part[dupl_index])\r
+ else:\r
+ text = offset, name[0], guid[0], value, attribute[0], comment\r
+ part_without_comment.append(text_without_comment)\r
+ part.append(text)\r
return(part)\r
\r
def value_parser(self, list1):\r
i.sort()\r
return keys,title_all,info_list,header_list,inf_list\r
\r
+ def correct_sort(self, PcdString):\r
+ # sort the Pcd list with two rules:\r
+ # First sort through Pcd name;\r
+ # Second if the Pcd exists several elements, sort them through index value.\r
+ if ("]|") in PcdString:\r
+ Pcdname = PcdString.split("[")[0]\r
+ Pcdindex = int(PcdString.split("[")[1].split("]")[0])\r
+ else:\r
+ Pcdname = PcdString.split("|")[0]\r
+ Pcdindex = 0\r
+ return Pcdname, Pcdindex\r
+\r
def remove_bracket(self,List):\r
for i in List:\r
for j in i:\r
List[List.index(i)][i.index(j)] = j\r
for i in List:\r
if type(i) == type([0,0]):\r
- i.sort()\r
+ i.sort(key = lambda x:(self.correct_sort(x)[0], self.correct_sort(x)[1]))\r
return List\r
\r
def write_all(self):\r