From cc1a4dcc8ab71ce8cd1a0bed24a9e7256e6e762b Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 5 Jun 2015 13:17:08 +0200 Subject: [PATCH] cosmetic --- sfa/managers/registry_manager.py | 4 ++-- sfa/storage/record.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sfa/managers/registry_manager.py b/sfa/managers/registry_manager.py index cc5654a6..8f65e068 100644 --- a/sfa/managers/registry_manager.py +++ b/sfa/managers/registry_manager.py @@ -42,7 +42,7 @@ from sqlalchemy.orm.collections import InstrumentedList # e.g. registry calls this 'reg-researchers' # while some drivers call this 'researcher' # we need to make sure that both keys appear and are the same -def _normalize_input (record, reg_key, driver_key): +def _normalize_input(record, reg_key, driver_key): # this looks right, use this for both keys if reg_key in record: # and issue a warning if they were both set and different @@ -229,7 +229,7 @@ class RegistryManager: # used to be in the driver code, sounds like a poorman thing though def solve_neighbour_url (record): if not record.type.startswith('authority'): return - hrn=record.hrn + hrn = record.hrn for neighbour_dict in [ api.aggregates, api.registries ]: if hrn in neighbour_dict: record.url=neighbour_dict[hrn].get_url() diff --git a/sfa/storage/record.py b/sfa/storage/record.py index 59317651..8600723a 100644 --- a/sfa/storage/record.py +++ b/sfa/storage/record.py @@ -16,7 +16,6 @@ class Record: xml_dict = xml.todict() self.load_from_dict(xml_dict) - def get_field(self, field): return self.__dict__.get(field, None) @@ -25,9 +24,10 @@ class Record: # (and 'last_updated' does not make it at all) # let's be flexible def date_repr (self,fields): - if not isinstance(fields,list): fields=[fields] + if not isinstance(fields,list): + fields = [fields] for field in fields: - value=getattr(self,field,None) + value = getattr(self,field,None) if isinstance (value,datetime): return datetime_to_string (value) elif isinstance (value,(int,float)): @@ -54,9 +54,11 @@ class Record: def load_from_dict (self, d): for (k,v) in d.iteritems(): # experimental - if isinstance(v, StringTypes) and v.lower() in ['true']: v=True - if isinstance(v, StringTypes) and v.lower() in ['false']: v=False - setattr(self,k,v) + if isinstance(v, StringTypes) and v.lower() in ['true']: + v = True + if isinstance(v, StringTypes) and v.lower() in ['false']: + v = False + setattr(self, k, v) # 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 @@ -68,8 +70,8 @@ class Record: def save_as_xml (self): # xxx not sure about the scope here input_dict = dict( [ (key, getattr(self,key)) for key in self.fields() if getattr(self,key,None) ] ) - xml_record=XML("") - xml_record.parse_dict (input_dict) + xml_record = XML("") + xml_record.parse_dict(input_dict) return xml_record.toxml() def dump(self, format=None, dump_parents=False, sort=False): @@ -90,7 +92,7 @@ class Record: print 40*'=' print "RECORD" # print remaining fields - fields=self.fields() + fields = self.fields() if sort: fields.sort() for attrib_name in fields: attrib = getattr(self, attrib_name) -- 2.43.0