From 2f3a37a55c92500f50b22c06ec1aab64c1b71452 Mon Sep 17 00:00:00 2001 From: Sriram Karra Date: Fri, 28 Oct 2016 23:02:51 +0530 Subject: [PATCH] BBDB notes_map web_home_re / web_work_re were not being used This fixes #103, but it is only a hack. Need to rethink the original idea of allowing regexp in the notes_map, or at least make it a list of two values - a regexp to match at read time and a pattern string to generate a label to write out. At any rate the present hacky fix will work for those who are using a single website per contact. --- asynk/contact_bb.py | 19 +++++++++++++++++-- config/config_v8.json | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/asynk/contact_bb.py b/asynk/contact_bb.py index 8b73300..c8521b0 100644 --- a/asynk/contact_bb.py +++ b/asynk/contact_bb.py @@ -578,21 +578,36 @@ def _get_emails_as_string (self): def _get_websites_as_string (self): ## FIXME: What happens to the "get_web_prim()". + noted = self.get_notes_map() ret = [] + + home_label = noted['web_home_re'] for i, web in enumerate(self.get_web_home()): if not web: continue - label = 'Web-%02d-Home' % i + ## FIXME: Hack Alert. There is no easy way to regenerate proper + ## labels with the regex. Need to rethink this a bit. Perhaps + ## there needs to be a patter to match, and a python pattern to + ## generate them at the remote end. + if home_label == 'Web.*Home': + label = 'Web-%02d-Home' % i + else: + label = home_label value = unchompq(esc_str(web)) ret.append("(%s . %s)" % (label, value)) + work_label = noted['web_work_re'] for i, web in enumerate(self.get_web_work()): if not web: continue - label = 'Web-%02d-Work' % i + ## FIXME: Hack Alert. See above + if work_label == 'Web.*Work': + label = 'Web-%02d-Work' % i + else: + label = work_label value = unchompq(esc_str(web)) ret.append("(%s . %s)" % (label, value)) diff --git a/config/config_v8.json b/config/config_v8.json index eaa7c43..4a5a86d 100644 --- a/config/config_v8.json +++ b/config/config_v8.json @@ -283,8 +283,8 @@ 'birthday' : 'birthday', 'anniv' : 'anniversary', 'itemid' : 'bbdb-id', - 'web_home_re' : 'Web.*Home', // Regexp - 'web_work_re' : 'Web.*Work', // Regexp + 'web_home_re' : 'Web.*Home', // Regexp. FIXME. See Issue 103. + 'web_work_re' : 'Web.*Work', // Regexp. FIXME. See Issue 103. 'ims' : 'im-(.*)', // Regexp brackets are important. 'dept' : 'department', 'title' : 'title',