3
# Copyright (C) 2010 ABINIT Group (Yann Pouillon)
5
# This file is part of the ABINIT software package. For license information,
6
# please see the COPYING file in the top-level directory of the ABINIT source
10
from ConfigParser import ConfigParser
11
from time import gmtime,strftime
18
class MyConfigParser(ConfigParser):
20
def optionxform(self,option):
23
# ---------------------------------------------------------------------------- #
30
my_name = "update-options-conf"
31
my_config = "config/specs/options.conf"
33
# Check if we are in the top of the ABINIT source tree
34
if ( not os.path.exists("configure.ac") or
35
not os.path.exists("src/98_main/abinit.F90") ):
36
print "%s: You must be in the top of an ABINIT source tree." % my_name
37
print "%s: Aborting now." % my_name
40
# Check config file(s)
41
if ( not os.path.exists(my_config) ):
42
print "%s: Could not find config file (%s)." % (my_name,cnf_file)
43
print "%s: Aborting now." % my_name
47
now = strftime("%Y/%m/%d %H:%M:%S +0000",gmtime())
50
re_sta = re.compile("^status.*(changed|new|removed|renamed)")
51
re_sec = re.compile("^\\[.*\\]$")
52
cnf = MyConfigParser()
54
opt_inp = file(my_config,"r").readlines()
63
for i in range(0,len(opt_inp)):
66
# Starting a new section
67
if ( re_sec.match(line) ):
73
sec_tit = re.sub("[\\[\\]]","",line).strip()
75
if ( sec_tit != "DEFAULT" ):
76
sec_sta = cnf.get(sec_tit,"status")
77
if ( sec_sta == "removed" ):
80
# Delete all status lines, but obsolete and unchanged
81
if ( not re_sta.match(line) ):
85
file(my_config,"w").write(opt_out)