aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSix <unknown>2011-05-03 21:02:33 -0400
committerSix <unknown>2011-05-03 21:02:33 -0400
commit9302855a3d4a8bfbd4b4e5e09857380a6012fe82 (patch)
tree2ea2fc86d7cff9c077cbd6c6c8aa11cbf273a8eb
parentbdde115451a7b1a9ad9746ca69b468420616e4cc (diff)
downloadd2-9302855a3d4a8bfbd4b4e5e09857380a6012fe82.tar.bz2
d2-9302855a3d4a8bfbd4b4e5e09857380a6012fe82.tar.xz
d2-9302855a3d4a8bfbd4b4e5e09857380a6012fe82.zip
fixed phone number format
-rw-r--r--lib/d2/bin/d2_data_merge.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/d2/bin/d2_data_merge.py b/lib/d2/bin/d2_data_merge.py
index 2270830..0af8e94 100644
--- a/lib/d2/bin/d2_data_merge.py
+++ b/lib/d2/bin/d2_data_merge.py
@@ -218,7 +218,7 @@ class DbOccupant(object):
218 218
219class BaseDb(object): 219class BaseDb(object):
220 220
221 NUMBER = '216-889' 221 NUMBER = '216889'
222 222
223 def __init__(self, config, static, detail_adapter): 223 def __init__(self, config, static, detail_adapter):
224 self._config = config 224 self._config = config
@@ -258,8 +258,22 @@ class BaseDb(object):
258 raise NotImplementedError() 258 raise NotImplementedError()
259 259
260 def _fix_phone_number(self, data): 260 def _fix_phone_number(self, data):
261 if len(data) == 4: 261 numbers = []
262 return u"{0}-{1}".format(self.NUMBER, data) 262 for c in data:
263 if c.isdigit():
264 numbers.append(c)
265 if len(numbers) < 5:
266 for x, n in enumerate(self.NUMBER):
267 numbers.insert(x, n)
268 return self._add_dashes(numbers)
269
270 def _add_dashes(self, numbers_list):
271 out = []
272 for x, number in enumerate(numbers_list):
273 if x in (3, 6):
274 out.append(u'-')
275 out.append(unicode(number))
276 return u''.join(out)
263 277
264 278
265class DbFirstName(BaseDb): 279class DbFirstName(BaseDb):