6 ##############################################
7 def sort_by_archiModes( attrs_archiModes_dict
):
11 for a
in attrs_archiModes_dict
.keys():
12 attrs_archiModes
.append([a
] + attrs_archiModes_dict
[a
])
14 ac_byModes
= [] # ac as archiving configuration
17 attrs
= [ attrs_archiModes
[0][0] ]
18 ac_byModes
.append([ attrs_archiModes
[0][1:], attrs
] )
21 for i
in range (1, len(attrs_archiModes
)):
23 attr_archiMode_i
= attrs_archiModes
[i
]
25 curr_attr
= attr_archiMode_i
[0]
26 curr_mode
= attr_archiMode_i
[1:]
30 while j
in range (len(ac_byModes
)) and not seen_mode
:
32 if curr_mode
== ac_byModes
[j
][0]:
34 ac_byModes
[j
][1].append(curr_attr
)
39 ac_byModes
.append([curr_mode
, attrs
])
41 #print ac_byModes # debug
45 ##############################################
46 ##def sort_by_archiModes( attrs_archiModes ):
49 ## ac_byModes = [] # ac as archiving configuration
52 ## attrs = [ attrs_archiModes[0][0] ]
53 ## ac_byModes.append([ attrs_archiModes[0][1:], attrs ] )
56 ## for i in range (1, len(attrs_archiModes)):
58 ## attr_archiMode_i = attrs_archiModes[i]
60 ## curr_attr = attr_archiMode_i[0]
61 ## curr_mode = attr_archiMode_i[1:]
65 ## while j in range (len(ac_byModes)) and not seen_mode:
67 ## if curr_mode == ac_byModes[j][0]:
69 ## ac_byModes[j][1].append(curr_attr)
73 ## attrs = [curr_attr]
74 ## ac_byModes.append([curr_mode, attrs])
76 ## #print ac_byModes # debug
85 #################################################
86 def ac_byModes_fromDevFiles( devAC_filenames
):
90 for f
in range (len(devAC_filenames
)):
92 f_lines
= open(devAC_filenames
[f
]).readlines()
94 "The 1st line is supposed to contain the device name"
95 "Removing '\n' at the end of the string"
96 dev_name
= f_lines
[0].split()[0]
98 for i
in range (1, len(f_lines
)):
99 splitted_f_line
= f_lines
[i
].split()
101 "Skipping the empty lines"
102 if( len(splitted_f_line
) != 0 and f_lines
[i
][0] != "#"):
103 "Full attr name = device name + attr name"
104 splitted_f_line
[0] = dev_name
+ '/' + splitted_f_line
[0]
105 splitted_lines
.append(splitted_f_line
)
108 return splitted_lines
112 ############################
113 if __name__
== '__main__':
115 if len(sys
.argv
) != 2:
116 print "File name expected"
119 #print ac_byModes_fromDevList(sys.argv[1])
121 filenames
.append(sys
.argv
[1])
122 print ac_byModes_fromDevFiles(filenames
)