Changeset 326:46fe057f2605 for pdw/pd/__init__.py
- Timestamp:
- 03/10/10 12:32:00 (6 months ago)
- Branch:
- default
- Files:
-
- 1 modified
-
pdw/pd/__init__.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pdw/pd/__init__.py
r325 r326 58 58 59 59 now = datetime.datetime.now() 60 60 61 def float_date(year, month=0, day=0): 62 '''to convert a date in a float type''' 61 63 return swiss.date.FlexiDate(year, month, day).as_float() 62 64 … … 64 66 # now dispatch on jurisdiction (+ work type?) 65 67 # note two letter country codes based on ISO 3166 66 # 68 # need to add 'when' parameter here and deeper 67 69 if jurisdiction == 'us': 68 70 pd_calculator = CalculatorUnitedStates … … 80 82 To create a Work object and analize its pd status from a 81 83 python or json dict 84 @param params: json formatted string 85 @type params: string 82 86 ''' 83 84 87 params = json.loads(json_data) 85 88 jur = params['jurisdiction'] … … 108 111 return "date_pd=%s pd_prob=%s log=%s" % (self.date_pd, self.pd_prob, self.log) 109 112 113 @classmethod 114 def to_dict(cls, self): 115 '''Creates a dict result to give back as json in the api 116 ''' 117 out_dict = { 'confidence': 1-self.uncertainty, 118 'pd probability': self.pd_prob, 119 'date pd': self.date_pd, 120 'log': self.log, 121 } 122 return out_dict 123 #TODO 124 110 125 class CalculatorBase(object): 111 126 """A Public Domain Calculator … … 114 129 def __init__(self, when): 115 130 self.author_list = None 131 self.death_dates = [] 132 self.names = [] 116 133 if when: 117 self._now = when134 self._now = when 118 135 else: 119 136 self._now = float_date(datetime.date.today().year)
