if keys: print tab * (counter) + "(children: %s)" % (",".join(keys))
+#
+# this code probably is obsolete
+# RSpec is not imported, it does not have a toDict() method anyway
+# plus, getNodes.py is not exposed in packaging
+#
def main():
parser = create_parser();
(options, args) = parser.parse_args()
if not options.infile:
print "RSpec file not specified"
return
-
+
rspec = RSpec()
try:
rspec.parseFile(options.infile)
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()
# xxx somehow here calling dict(record) issues a weird error
# however record.todict() seems to work fine
# records.extend( [ dict(record) for record in local_records ] )
- records.extend( [ record.todict(exclude_types=(InstrumentedList,)) for record in local_records ] )
+ records.extend( [ record.record_to_dict(exclude_types=(InstrumentedList,)) for record in local_records ] )
if not records:
raise RecordNotFound(str(hrns))
# record.todict() is the place where __dict__ is used
print "DO NOT REMOVE ME before augment_with_sfa_builtins, record=%s"%record
augment_with_sfa_builtins(record)
- record_dicts = [ record.todict(exclude_types=(InstrumentedList,)) for record in records ]
+ record_dicts = [ record.record_to_dict(exclude_types=(InstrumentedList,)) for record in records ]
return record_dicts
# register non-db attributes in an extensions field
return result
-def make_record_xml (xml):
- xml_record = XML(xml)
- xml_dict = xml_record.todict()
+def make_record_xml (xml_str):
+ xml = XML(xml_str)
+ xml_dict = xml.todict()
logger.info("load from xml, keys=%s"%xml_dict.keys())
return make_record_dict (xml_dict)
class Record:
- def __init__(self, dict=None, xml=None):
+ def __init__(self, dict=None, xml_str=None):
if dict:
self.load_from_dict(dict)
- elif xml:
- xml_record = XML(xml)
- xml_dict = xml_record.todict()
+ elif xml_str:
+ xml = XML(xml_str)
+ xml_dict = xml.todict()
self.load_from_dict(xml_dict)
# need to filter out results, esp. wrt relationships
# exclude_types must be a tuple so we can use isinstance
#
- def todict (self, exclude_types=None):
+ def record_to_dict (self, exclude_types=None):
if exclude_types is None:
exclude_types = ()
d = self.__dict__