git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d07712a
)
added is_ini() and is_xml()
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Wed, 18 Jul 2012 02:42:47 +0000
(22:42 -0400)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Wed, 18 Jul 2012 02:42:47 +0000
(22:42 -0400)
sfa/util/config.py
patch
|
blob
|
history
diff --git
a/sfa/util/config.py
b/sfa/util/config.py
index
499ab1f
..
1ac9753
100644
(file)
--- a/
sfa/util/config.py
+++ b/
sfa/util/config.py
@@
-48,9
+48,11
@@
DO NOT EDIT. This file was automatically generated at
try:
self.config.read(filename)
except:
try:
self.config.read(filename)
except:
+ print "normal read failed"
if filename.endswith('.xml'):
self.load_xml(filename)
else:
if filename.endswith('.xml'):
self.load_xml(filename)
else:
+ print "loading shell"
self.load_shell(filename)
self._files.append(filename)
self.set_attributes()
self.load_shell(filename)
self._files.append(filename)
self.set_attributes()
@@
-117,6
+119,24
@@
DO NOT EDIT. This file was automatically generated at
def validate_type(self, var_type, value):
return True
def validate_type(self, var_type, value):
return True
+ @staticmethod
+ def is_xml(config_file):
+ try:
+ x = Xml(config_file)
+ return True
+ except:
+ return False
+
+ @staticmethod
+ def is_ini(config_file):
+ try:
+ c = ConfigParser.ConfigParser()
+ c.read(config_file)
+ return True
+ except:
+ return False
+
+
def dump(self, sections = []):
sys.stdout.write(output_python())
def dump(self, sections = []):
sys.stdout.write(output_python())