diff options
author | Filipp Lepalaan <f@230.to> | 2013-05-21 21:59:25 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-05-21 21:59:25 +0300 |
commit | 2b7085c439a7529f776bead711a38110ce6e2907 (patch) | |
tree | 6c3ec0f54783a47cc49389a99f8d137507f10653 /gsxws | |
parent | 6bcdd4ebaa0d04ff353602e3dbd8775c9ad76fdb (diff) | |
download | py-gsxws-2b7085c439a7529f776bead711a38110ce6e2907.tar.gz py-gsxws-2b7085c439a7529f776bead711a38110ce6e2907.tar.bz2 py-gsxws-2b7085c439a7529f776bead711a38110ce6e2907.zip |
Do date conversions last
Diffstat (limited to 'gsxws')
-rw-r--r-- | gsxws/core.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gsxws/core.py b/gsxws/core.py index d85c72a..4733001 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -394,6 +394,14 @@ class GsxObject(object): v = unicode(v) # "must be unicode, not str" + # strip currency prefix and munge into float + if re.search(r'Price$', k): + v = float(re.sub(r'[A-Z ,]', '', v)) + + # convert Y and N to boolean + if re.search(r'^[YN]$', k): + v = (v == 'Y') + # convert dates to native Python type ("mm/dd/yy") if re.search(r'^\d{2}/\d{2}/\d{2}$', v): m, d, y = v.split('/') @@ -404,19 +412,11 @@ class GsxObject(object): y, m, d = v.split('-') v = date(int(y), int(m), int(d)) - # strip currency prefix and munge into float - if re.search(r'Price$', k): - v = float(re.sub(r'[A-Z ,]', '', v)) - # Convert timestamps to native Python type # 18-Jan-13 14:38:04 if re.search(r'TimeStamp$', k): v = datetime.strptime(v, '%d-%b-%y %H:%M:%S') - # convert Y and N to boolean - if re.search(r'^[YN]$', k): - v = (v == 'Y') - setattr(obj, k, v) return obj |