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:
93e3ae9
)
fix dump()
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Wed, 7 Mar 2012 19:28:58 +0000
(14:28 -0500)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Wed, 7 Mar 2012 19:28:58 +0000
(14:28 -0500)
sfa/storage/record.py
patch
|
blob
|
history
diff --git
a/sfa/storage/record.py
b/sfa/storage/record.py
index
fcde62c
..
0d03bc6
100644
(file)
--- a/
sfa/storage/record.py
+++ b/
sfa/storage/record.py
@@
-51,13
+51,13
@@
class Record:
# in addition we provide convenience for converting to and from xml records
# for this purpose only, we need the subclasses to define 'fields' as either
# a list or a dictionary
# in addition we provide convenience for converting to and from xml records
# for this purpose only, we need the subclasses to define 'fields' as either
# a list or a dictionary
- def
xml_
fields (self):
+ def fields (self):
fields = self.__dict__.keys()
return fields
def save_as_xml (self):
# xxx not sure about the scope here
fields = self.__dict__.keys()
return fields
def save_as_xml (self):
# xxx not sure about the scope here
- input_dict = dict( [ (key, getattr(self,key)) for key in self.
xml_
fields() if getattr(self,key,None) ] )
+ input_dict = dict( [ (key, getattr(self,key)) for key in self.fields() if getattr(self,key,None) ] )
xml_record=XML("<record />")
xml_record.parse_dict (input_dict)
return xml_record.toxml()
xml_record=XML("<record />")
xml_record.parse_dict (input_dict)
return xml_record.toxml()
@@
-77,29
+77,23
@@
class Record:
raise Exception, "Invalid format %s" % format
def dump_text(self, dump_parents=False):
raise Exception, "Invalid format %s" % format
def dump_text(self, dump_parents=False):
- # print core fields in this order
- core_fields = [ 'hrn', 'type', 'authority', 'date_created', 'created', 'last_updated', 'gid', ]
print "".join(['=' for i in range(40)])
print "RECORD"
print "".join(['=' for i in range(40)])
print "RECORD"
- print " hrn:", self.hrn
- print " type:", self.type
- print " authority:", self.authority
- print " date created:", self.date_repr( ['date_created','created'] )
- print " last updated:", self.date_repr('last_updated')
- print " gid:"
- if self.gid:
- print GID(self.gid).dump_string(8, dump_parents)
-
# print remaining fields
# print remaining fields
- for attrib_name in
dir(self
):
+ for attrib_name in
self.fields(
):
attrib = getattr(self, attrib_name)
# skip internals
if attrib_name.startswith('_'): continue
attrib = getattr(self, attrib_name)
# skip internals
if attrib_name.startswith('_'): continue
- # skip core fields
- if attrib_name in core_fields: continue
# skip callables
if callable (attrib): continue
# skip callables
if callable (attrib): continue
- print " %s: %s" % (attrib_name, attrib)
+ # handle gid
+ if attrib_name == 'gid':
+ print " gid:"
+ print GID(attrib).dump_string(8, dump_parents)
+ elif attrib_name in ['date created', 'last updated']:
+ print " %s: %s" % (attrib_name, self.date_repr(attrib_name))
+ else:
+ print " %s: %s" % (attrib_name, attrib)
def dump_simple(self):
return "%s"%self
def dump_simple(self):
return "%s"%self