1 # http://stackoverflow.com/questions/15069127/python-configparser-module-\
3 def rename_section(cp
, section_from
, section_to
):
4 items
= cp
.items(section_from
)
5 cp
.add_section(section_to
)
7 cp
.set(section_to
, item
[0], item
[1])
8 cp
.remove_section(section_from
)
10 # Checkpoint version F renames an internal member of Process class.
13 for sec
in cpt
.sections():
16 if re
.match('.*\.%s.*' % fdm
, sec
):
17 rename
= re
.sub(fdm
, fde
, sec
)
18 split
= re
.split(fde
, rename
)
20 # rename the section and add the 'mode' field
21 rename_section(cpt
, sec
, rename
)
22 cpt
.set(rename
, 'mode', "0") # no proper value to set :(
24 # add in entries 257 to 1023
26 for x
in range(257, 1024):
27 seq
= (split
[0], fde
, "%s" % x
)
28 section
= "".join(seq
)
29 cpt
.add_section(section
)
30 cpt
.set(section
, 'fd', '-1')