return Record(dict=record_dict)
def load_record_from_file(filename):
- f=codecs.open(filename, encoding="utf-8", mode="r")
- xml_string = f.read()
- f.close()
- return Record(xml=xml_string)
-
+ with codecs.open(filename, encoding="utf-8", mode="r") as f:
+ xml_str = f.read()
+ return Record(xml=xml_str)
import uuid
def unique_call_id(): return uuid.uuid4().urn
for (section, tuples) in flags:
print "[{}]".format(section)
try:
- for (external_name, internal_name) in tuples:
- print "{:-20} = {}".format(external_name, getattr(self, internal_name))
+ for external_name, internal_name in tuples:
+ print "{:<20} = {}".format(external_name, getattr(self, internal_name))
except:
- for name in tuples:
- varname = "{}_{}".format(section.upper(), name.upper())
+ print 'failed'
+ for external_name, internal_name in tuples:
+ varname = "{}_{}".format(section.upper(), external_name.upper())
value = getattr(self.config_instance,varname)
- print "{:-20} = {}".format(name, value)
+ print "{:<20} = {}".format(external_name, value)
# xxx should analyze result
return 0
try:
record_filepath = args[0]
rec_file = self.get_record_file(record_filepath)
- record_dict.update(load_record_from_file(rec_file).todict())
+ record_dict.update(load_record_from_file(rec_file).record_to_dict())
except:
print "Cannot load record file {}".format(record_filepath)
sys.exit(1)
if options:
- record_dict.update(load_record_from_opts(options).todict())
+ record_dict.update(load_record_from_opts(options).record_to_dict())
# we should have a type by now
if 'type' not in record_dict :
self.print_help()
if len(args) > 0:
record_filepath = args[0]
rec_file = self.get_record_file(record_filepath)
- record_dict.update(load_record_from_file(rec_file).todict())
+ record_dict.update(load_record_from_file(rec_file).record_to_dict())
if options:
- record_dict.update(load_record_from_opts(options).todict())
+ record_dict.update(load_record_from_opts(options).record_to_dict())
# at the very least we need 'type' here
if 'type' not in record_dict or record_dict['type'] is None:
self.print_help()