Esempio n. 1
0
    def _get_names_as_string (self):
        ret = ''
        n = self.get_firstname()
        l = self.get_lastname()

        if bool(l) != bool(n):
            # A Logical xor to check if one and only one of the two strings is
            # valid. Inspired by: http://stackoverflow.com/a/433161/987738
            n = self.get_name()
            if n:
                ret = '"%s" nil ' % n
            else:
                ret = 'nil nil '
        else:
            if n:
                ret += unchompq(n) + ' '
            else:
                ret += 'nil '

            if l:
                ret += unchompq(l) + ' '
            else:
                ret += 'nil '

        a = self.get_suffix()
        if a:
            ret += ' ' + unchompq(a)
        else:
            ret += 'nil'

        return ret
Esempio n. 2
0
    def _get_company_as_string(self):
        comp1 = esc_str(self.get_company())
        if not comp1:
            return 'nil'

        comp = copy.deepcopy(self.get_custom('company'))
        ver = self.get_store().get_file_format()
        ## FIXME: This is an egregious design violation, as noted earlier. We
        ## should move all such version specific conversions to pimdb_bb.el
        if ver == '6':
            if comp and len(comp) > 0:
                comp = demjson.decode(comp)
                comp = [chompq(x) for x in comp]
            else:
                comp = []

            comp.insert(0, comp1)
            return unchompq('; '.join(comp))
        elif ver == '7':
            if comp and len(comp) > 0:
                comp = demjson.decode(comp)
                comp.insert(0, unchompq(comp1))
            else:
                comp = [unchompq(comp1)]

            return ('(' + ' '.join(comp) + ')')
Esempio n. 3
0
    def _get_company_as_string (self):
        comp1 = esc_str(self.get_company())
        if not comp1:
            return 'nil'

        comp = copy.deepcopy(self.get_custom('company'))
        ver = self.get_store().get_file_format()
        ## FIXME: This is an egregious design violation, as noted earlier. We
        ## should move all such version specific conversions to pimdb_bb.el
        if ver == '6':
            if comp and len(comp) > 0:
                comp = demjson.decode(comp)
                comp = [chompq(x) for x in comp]
            else:
                comp = []

            comp.insert(0, comp1)
            return unchompq('; '.join(comp))
        elif ver == '7':
            if comp and len(comp) > 0:
                comp = demjson.decode(comp)
                comp.insert(0, unchompq(comp1))
            else:
                comp = [unchompq(comp1)]

            return ('(' + ' '.join(comp) + ')')
Esempio n. 4
0
    def _get_names_as_string(self):
        ret = ''
        n = self.get_firstname()
        l = self.get_lastname()

        if bool(l) != bool(n):
            # A Logical xor to check if one and only one of the two strings is
            # valid. Inspired by: http://stackoverflow.com/a/433161/987738
            n = self.get_name()
            if n:
                ret = '"%s" nil ' % n
            else:
                ret = 'nil nil '
        else:
            if n:
                ret += unchompq(n) + ' '
            else:
                ret += 'nil '

            if l:
                ret += unchompq(l) + ' '
            else:
                ret += 'nil '

        a = self.get_suffix()
        if a:
            ret += ' ' + unchompq(a)
        else:
            ## FIXME: version hack. needs to be fixed as noted elsewhere
            if self.get_store().get_file_format() != '6':
                ret += 'nil'

        return ret
Esempio n. 5
0
    def _get_names_as_string (self):
        ret = ''
        n = self.get_firstname()
        l = self.get_lastname()

        if bool(l) != bool(n):
            # A Logical xor to check if one and only one of the two strings is
            # valid. Inspired by: http://stackoverflow.com/a/433161/987738
            n = self.get_name()
            if n:
                ret = '"%s" nil ' % n
            else:
                ret = 'nil nil '
        else:
            if n:
                ret += unchompq(n) + ' '
            else:
                ret += 'nil '

            if l:
                ret += unchompq(l) + ' '
            else:
                ret += 'nil '

        a = self.get_suffix()
        if a:
            ret += ' ' + unchompq(a)
        else:
            ## FIXME: version hack. needs to be fixed as noted elsewhere
            if self.get_store().get_file_format() != '6':
                ret += 'nil'

        return ret
Esempio n. 6
0
    def _get_emails_as_string(self):
        ems = [unchompq(e) for e in self.get_email_home()]
        ems.extend([unchompq(e) for e in self.get_email_work()])
        ems.extend([unchompq(e) for e in self.get_email_other()])

        ret = ' '.join(ems)

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 7
0
    def _get_emails_as_string (self):
        ems = [unchompq(e) for e in self.get_email_home()]
        ems.extend([unchompq(e) for e in self.get_email_work()])
        ems.extend([unchompq(e) for e in self.get_email_other()])

        ret = ' '.join(ems)

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 8
0
    def _get_company_as_string (self):
        comp1 = self.get_company()
        if not comp1:
            return 'nil'

        comp = copy.deepcopy(self.get_custom('company'))
        if comp and len(comp) > 0:
            comp = demjson.decode(comp)
            comp.insert(0, unchompq(comp1))
            return ('(' + ' '.join(comp) + ')')
        else:
            return ('(' + unchompq(comp1) + ')')
Esempio n. 9
0
    def _get_names_as_string(self):
        ret = ''
        n = esc_str(self.get_firstname())
        l = esc_str(self.get_lastname())

        if bool(l) != bool(n):
            # A Logical xor to check if one and only one of the two strings is
            # valid. Inspired by: http://stackoverflow.com/a/433161/987738
            n = self.get_name()
            if n:
                ret = '"%s" nil ' % n
            else:
                ret = 'nil nil '
        else:
            if n:
                ret += unchompq(n) + ' '
            else:
                ret += 'nil '

            if l:
                ret += unchompq(l) + ' '
            else:
                ret += 'nil '

        ## Handle the suffix - There is an "Affix" array field in file format
        ## 7+. So if we are in version 7 we should build up an array using the
        ## suffix field and any other stuf we stashed away in custom
        ## field. Othewrise we will just let all the stuff get handled in the
        ## custom handling routine - even the first suffix.

        a = esc_str(self.get_suffix())
        bbdb_ver = self.get_store().get_file_format()
        if not a:
            if bbdb_ver != '6':
                ret += ' nil'

        else:
            suffix = self.get_custom('affix')
            suffix = demjson.decode(suffix) if suffix else []

            if bbdb_ver == '6':
                suffix.insert(0, a)
                self.add_custom('affix', demjson.encode(suffix))
            else:
                suffix.insert(0, a)
                ret += ' (' + ' '.join([unchompq(x) for x in suffix]) + ')'
                self.del_custom('affix')

        return ret
Esempio n. 10
0
    def _get_names_as_string (self):
        ret = ''
        n = esc_str(self.get_firstname())
        l = esc_str(self.get_lastname())

        if bool(l) != bool(n):
            # A Logical xor to check if one and only one of the two strings is
            # valid. Inspired by: http://stackoverflow.com/a/433161/987738
            n = self.get_name()
            if n:
                ret = '"%s" nil ' % n
            else:
                ret = 'nil nil '
        else:
            if n:
                ret += unchompq(n) + ' '
            else:
                ret += 'nil '

            if l:
                ret += unchompq(l) + ' '
            else:
                ret += 'nil '

        ## Handle the suffix - There is an "Affix" array field in file format
        ## 7+. So if we are in version 7 we should build up an array using the
        ## suffix field and any other stuf we stashed away in custom
        ## field. Othewrise we will just let all the stuff get handled in the
        ## custom handling routine - even the first suffix.

        a = esc_str(self.get_suffix())
        bbdb_ver = self.get_store().get_file_format()
        if not a:
            if bbdb_ver != '6':
                ret += ' nil'

        else:
            suffix = self.get_custom('affix')
            suffix = demjson.decode(suffix) if suffix else []

            if bbdb_ver == '6':
                suffix.insert(0, a)
                self.add_custom('affix', demjson.encode(suffix))
            else:
                suffix.insert(0, a)
                ret += ' (' + ' '.join([unchompq(x) for x in suffix]) + ')'
                self.del_custom('affix')

        return ret
Esempio n. 11
0
    def _get_sync_tags_as_str (self):
        conf     = self.get_config()
        pname_re = conf.get_profile_name_re()
        label    = conf.make_sync_label(pname_re, self.get_dbid())

        ret = ''
        i = 0
        for key, val in self.get_sync_tags().iteritems():
            ## FIXME: This was put in here for a reason. I think it had
            ## something to do with "reproducing" sync labels containing the
            ## ID on the local end itself. This was the easiest fix,
            ## IIRC. This clearly conflicts with the present need. We need to
            ## solve this problem - and apply it for all the DBs.

            # # Skip any sync tag with BBDB IDs as values.
            # if re.search(label, key) or not val:
            #     continue

            if i > 0:
                ret += ' '
            i += 1

            ret += '(' + key + ' . ' + unchompq(val) + ')'

        return ret
Esempio n. 12
0
    def _get_sync_tags_as_str(self):
        conf = self.get_config()
        pname_re = conf.get_profile_name_re()
        label = conf.make_sync_label(pname_re, self.get_dbid())

        ret = ''
        i = 0
        for key, val in self.get_sync_tags().iteritems():
            ## FIXME: This was put in here for a reason. I think it had
            ## something to do with "reproducing" sync labels containing the
            ## ID on the local end itself. This was the easiest fix,
            ## IIRC. This clearly conflicts with the present need. We need to
            ## solve this problem - and apply it for all the DBs.

            # # Skip any sync tag with BBDB IDs as values.
            # if re.search(label, key) or not val:
            #     continue

            if i > 0:
                ret += ' '
            i += 1

            ret += '(' + key + ' . ' + unchompq(val) + ')'

        return ret
Esempio n. 13
0
    def _get_phones_as_string(self):
        ## Note that any BBDB phone number that was structured in the North
        ## Amerial format will be munged into an equivalent string notation
        ## for our convenience

        ph = copy.deepcopy(self.get_phone_home())
        ph.extend(self.get_phone_work())
        ph.extend(self.get_phone_mob())
        ph.extend(self.get_phone_other())

        phs = ['[%s %s]' % (unchompq(l), unchompq(n)) for l, n in ph]
        ret = ' '.join(phs)
        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 14
0
    def _get_phones_as_string (self):
        ## Note that any BBDB phone number that was structured in the North
        ## Amerial format will be munged into an equivalent string notation
        ## for our convenience

        ph  = copy.deepcopy(self.get_phone_home())
        ph.extend(self.get_phone_work())
        ph.extend(self.get_phone_mob())
        ph.extend(self.get_phone_other())

        phs = ['[%s %s]' % (unchompq(l), unchompq(n)) for l,n in ph]
        ret = ' '.join(phs)
        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 15
0
    def _get_postal_as_string(self):
        ret = ""
        for l, a in self.get_postal(as_array=True):
            ret += "[" + unchompq(l) + " "

            if "street" in a and a["street"]:
                s = a["street"].split("\n")
                ret += "(" + " ".join([unchompq(x) for x in map(esc_str, s)]) + ")"
            else:
                ret += "nil"

            arr = [a["city"], a["state"], a["zip"], a["country"]]
            ret += " " + " ".join([unchompq(x) for x in map(esc_str, arr)])
            ret += "]"

        if ret == "":
            return "nil"
        else:
            return "(" + ret + ")"
Esempio n. 16
0
    def _get_emails_as_string(self):
        ems = [unchompq(e) for e in self.get_email_home()]
        ems.extend([unchompq(e) for e in self.get_email_work()])
        ems.extend([unchompq(e) for e in self.get_email_other()])

        # The primary email address should be the first in the list.
        emp = self.get_email_prim()
        if emp:
            emp = unchompq(emp)
            if emp in ems:
                ems.remove(emp)
            ems.insert(0, emp)

        ret = ' '.join(ems)

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 17
0
    def _get_emails_as_string (self):
        ems = [unchompq(e) for e in self.get_email_home()]
        ems.extend([unchompq(e) for e in self.get_email_work()])
        ems.extend([unchompq(e) for e in self.get_email_other()])

        # The primary email address should be the first in the list.
        emp = self.get_email_prim()
        if emp:
            emp = unchompq(emp)
            if emp in ems:
                ems.remove(emp)
            ems.insert(0, emp)

        ret = ' '.join(ems)

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 18
0
    def _get_postal_as_string (self):
        ret = ''
        for l, a in self.get_postal(as_array=True):
            ret += '[' + unchompq(l) + ' '

            if 'street' in a and a['street']:
                s = a['street'].split('\n')
                ret += '(' + ' '.join([unchompq(x) for x in map(esc_str, s)]) + ')'
            else:
                ret += 'nil'

            arr = [a['city'], a['state'], a['zip'], a['country']]
            ret += ' ' + ' '.join([unchompq(x) for x in map(esc_str, arr)])
            ret += ']'

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 19
0
    def _get_postal_as_string (self):
        ret = ''
        for l, a in self.get_postal(as_array=True):
            ret += '[' + unchompq(l) + ' '

            if 'street' in a and a['street']:
                s = a['street'].split('\n')
                ret += '(' + ' '.join([unchompq(x) for x in map(esc_str, s)]) + ')'
            else:
                ret += 'nil'

            arr = [a['city'], a['state'], a['zip'], a['country']]
            ret += ' ' + ' '.join([unchompq(x) for x in map(esc_str, arr)])
            ret += ']'

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 20
0
    def _get_ver9_fields_as_string (self):
        """Prior to file format ver 9 these fields were embedded in the notes
           section. Ver 9 onwards they are first class citizens, so we
           need to handle them separately and make sure they are
           available in the record at the appropriate level."""

        bbdb_ver = int(self.get_store().get_file_format())
        if bbdb_ver < 9:
            return ' '           # Handled via the notes section

        return ' '.join([unchompq(x) for x in
                         [self.get_itemid(), self.get_created(),
                          self.get_updated()]])
Esempio n. 21
0
    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

            ## 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

            ## 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))

        return ' '.join(ret)
Esempio n. 22
0
    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

            ## 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

            ## 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))

        return ' '.join(ret)
Esempio n. 23
0
    def _get_websites_as_string (self):
        ## FIXME: What happens to the "get_web_prim()". 

        ret = []
        for i, web in enumerate(self.get_web_home()):
            if not web:
                continue

            label = 'Web-%02d-Home' % i
            value = unchompq(esc_str(web))

            ret.append("(%s . %s)" % (label, value))

        for i, web in enumerate(self.get_web_work()):
            if not web:
                continue

            label = 'Web-%02d-Work' % i
            value = unchompq(esc_str(web))

            ret.append("(%s . %s)" % (label, value))

        return ' '.join(ret)
Esempio n. 24
0
    def _get_websites_as_string(self):
        ## FIXME: What happens to the "get_web_prim()".

        ret = []
        for i, web in enumerate(self.get_web_home()):
            if not web:
                continue

            label = 'Web-%02d-Home' % i
            value = unchompq(esc_str(web))

            ret.append("(%s . %s)" % (label, value))

        for i, web in enumerate(self.get_web_work()):
            if not web:
                continue

            label = 'Web-%02d-Work' % i
            value = unchompq(esc_str(web))

            ret.append("(%s . %s)" % (label, value))

        return ' '.join(ret)
Esempio n. 25
0
    def _get_aka_as_string(self):
        nick = esc_str(self.get_nickname())
        if not nick:
            return 'nil'
        nick = unchompq(nick)

        aka = copy.deepcopy(self.get_custom('aka'))
        if aka:
            ## Note that we have inserted AKAs an json encoded array of
            ## strings.
            aka = demjson.decode(aka)
            aka.insert(0, nick)
            return ('(' + ' '.join(aka) + ')')
        else:
            return '(' + nick + ')'
Esempio n. 26
0
    def _get_aka_as_string(self):
        nick = esc_str(self.get_nickname())
        if not nick:
            return "nil"
        nick = unchompq(nick)

        aka = copy.deepcopy(self.get_custom("aka"))
        if aka:
            ## Note that we have inserted AKAs an json encoded array of
            ## strings.
            aka = demjson.decode(aka)
            aka.insert(0, nick)
            return "(" + " ".join(aka) + ")"
        else:
            return "(" + nick + ")"
Esempio n. 27
0
    def _get_aka_as_string (self):
        nick = esc_str(self.get_nickname())
        if not nick:
            return 'nil'
        nick = unchompq(nick)

        aka = copy.deepcopy(self.get_custom('aka'))
        if aka:
            ## Note that we have inserted AKAs an json encoded array of
            ## strings.
            aka = demjson.decode(aka)
            aka.insert(0, nick)
            return('(' + ' '.join(aka) + ')')
        else:
            return '(' + nick + ')'
Esempio n. 28
0
    def _get_ver9_fields_as_string(self):
        """Prior to file format ver 9 these fields were embedded in the notes
           section. Ver 9 onwards they are first class citizens, so we
           need to handle them separately and make sure they are
           available in the record at the appropriate level."""

        bbdb_ver = int(self.get_store().get_file_format())
        if bbdb_ver < 9:
            return ' '  # Handled via the notes section

        return ' '.join([
            unchompq(x) for x in
            [self.get_itemid(),
             self.get_created(),
             self.get_updated()]
        ])
Esempio n. 29
0
    def _get_ims_as_string (self, ims=None):
        if not ims:
            ims = self.get_im()

        # This is a trcky bit. If the IM label was a regular expression, then
        # we need to generate the correctly formatted IM notes field... Hm.

        im_label_re  = self.get_notes_map()['ims']
        if re.search(r'(.*)', im_label_re):
            im_label_fmt = string.replace(im_label_re, '(.*)', '%s')
        else:
            im_label_fmt = '%s'

        ret = ''
        for l, v in ims.iteritems():
            ret += ' ('+ (im_label_fmt % l) + ' . ' + unchompq(esc_str(v)) + ')'

        return ret
Esempio n. 30
0
    def _get_ims_as_string (self, ims=None):
        if not ims:
            ims = self.get_im()

        # This is a trcky bit. If the IM label was a regular expression, then
        # we need to generate the correctly formatted IM notes field... Hm.

        im_label_re  = self.get_notes_map()['ims']
        if re.search(r'(.*)', im_label_re):
            im_label_fmt = string.replace(im_label_re, '(.*)', '%s')
        else:
            im_label_fmt = '%s'

        ret = ''
        for l, v in ims.iteritems():
            ret += ' ('+ (im_label_fmt % l) + ' . ' + unchompq(esc_str(v)) + ')'

        return ret
Esempio n. 31
0
    def _get_ims_as_string(self, ims=None):
        if not ims:
            ims = self.get_im()

        # This is a trcky bit. If the IM label was a regular expression, then
        # we need to generate the correctly formatted IM notes field... Hm.

        im_label_re = self.get_notes_map()["ims"]
        if re.search(r"(.*)", im_label_re):
            im_label_fmt = string.replace(im_label_re, "(.*)", "%s")
        else:
            im_label_fmt = "%s"

        ret = ""
        for l, v in ims.iteritems():
            ret += " (" + (im_label_fmt % l) + " . " + unchompq(esc_str(v)) + ")"

        return ret
Esempio n. 32
0
    def _get_sync_tags_as_str (self):
        conf     = self.get_config()
        pname_re = conf.get_profile_name_re()
        label    = conf.make_sync_label(pname_re, self.get_dbid())

        ret = ''
        i = 0
        for key, val in self.get_sync_tags().iteritems():
            # Skip any sync tag with BBDB IDs as values.
            if re.search(label, key) or not val:
                continue

            if i > 0:
                ret += ' '
            i += 1

            ret += '(' + key + ' . ' + unchompq(val) + ')'

        return ret
Esempio n. 33
0
    def _get_sync_tags_as_str(self):
        conf = self.get_config()
        pname_re = conf.get_profile_name_re()
        label = conf.make_sync_label(pname_re, self.get_dbid())

        ret = ''
        i = 0
        for key, val in self.get_sync_tags().iteritems():
            # Skip any sync tag with BBDB IDs as values.
            if re.search(label, key) or not val:
                continue

            if i > 0:
                ret += ' '
            i += 1

            ret += '(' + key + ' . ' + unchompq(val) + ')'

        return ret
Esempio n. 34
0
    def _get_postal_as_string (self):
        ret = ''
        for l, a in self.get_postal(as_array=True):
            ret += '[' + unchompq(l) + ' '

            if 'street' in a and a['street']:
                strts = a['street'].split('\n')
                ret += '(' + ' '.join([unchompq(x) for x in strts]) + ')'
            else:
                ret += 'nil'

            ret += ' ' + (unchompq(a['city'])    if a['city']    else '""')
            ret += ' ' + (unchompq(a['state'])   if a['state']   else '""')
            ret += ' ' + (unchompq(a['zip'])     if a['zip']     else '""')
            ret += ' ' + (unchompq(a['country']) if a['country'] else '""')

            ret += ']'

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 35
0
    def _get_postal_as_string(self):
        ret = ''
        for l, a in self.get_postal(as_array=True):
            ret += '[' + unchompq(l) + ' '

            if 'street' in a and a['street']:
                strts = a['street'].split('\n')
                ret += '(' + ' '.join([unchompq(x) for x in strts]) + ')'
            else:
                ret += 'nil'

            ret += ' ' + (unchompq(a['city']) if a['city'] else '""')
            ret += ' ' + (unchompq(a['state']) if a['state'] else '""')
            ret += ' ' + (unchompq(a['zip']) if a['zip'] else '""')
            ret += ' ' + (unchompq(a['country']) if a['country'] else '""')

            ret += ']'

        if ret == '':
            return 'nil'
        else:
            return '(' + ret + ')'
Esempio n. 36
0
    def _get_notes_as_string (self):
        noted = self.get_notes_map()
        if not noted:
            logging.error('_ge(): Error in Config. No notes_map field for bb')
            return

        ret =  '(bbdb-id . %s) ' % unchompq(self.get_itemid())
        ret += '(%s . %s) ' % (noted['created'], unchompq(self.get_created()))
        ret += '(%s . %s) ' % (noted['updated'], unchompq(self.get_updated()))

        p = esc_str(self.get_prefix())
        g = esc_str(self.get_gender())
        t = esc_str(self.get_title())
        d = esc_str(self.get_dept())
        b = esc_str(self.get_birthday())
        a = esc_str(self.get_anniv())
        i = self.get_im()
        n = self.get_notes()
        m = esc_str(self.get_middlename())
        f = esc_str(self.get_bbdb_folder())

        if p:
            ret += '(%s . %s) ' % (noted['prefix'],  unchompq(p))
        if g:
            ret += '(%s . %s) ' % (noted['gender'],  unchompq(g))
        if t:
            ret += '(%s . %s) ' % (noted['title'],   unchompq(t))
        if d:
            ret += '(%s . %s) ' % (noted['dept'],    unchompq(d))
        if i and len(i) > 0:
            ret += self._get_ims_as_string(i)
        if b:
            ret += '(%s . %s) ' % (noted['birthday'], unchompq(b))
        if a:
            ret += '(%s . %s) ' % (noted['anniv'], unchompq(a))
        if n and len(n) > 0 and n[0]:
            ## BBDB cannot handle actual line breaks and double quotes. We
            ## need to quote them. And convert the dos line endings while we
            ## are at it...
            no = esc_str(n[0])
            ret += '(%s . %s) ' % (noted['notes'], unchompq(no))
        if m and m != '':
            ret += '(%s . %s) ' % (noted['middle_name'], unchompq(m))
        if f:
            ret += '(%s . %s) ' % (noted['folder'],  unchompq(f))

        ret += self._get_sync_tags_as_str() + ' '
        ret += self._get_websites_as_string() + ' '

        for label, note in self.get_custom().iteritems():
            if label in ['company', 'aka']:
                continue

            ret += '(%s . %s) ' % (label, unchompq(esc_str(note)))

        return '(' + ret + ')'
Esempio n. 37
0
    def _get_notes_as_string(self):
        noted = self.get_notes_map()
        if not noted:
            logging.error("_ge(): Error in Config. No notes_map field for bb")
            return

        ret = "(bbdb-id . %s) " % unchompq(self.get_itemid())
        ret += "(%s . %s) " % (noted["created"], unchompq(self.get_created()))
        ret += "(%s . %s) " % (noted["updated"], unchompq(self.get_updated()))

        p = esc_str(self.get_prefix())
        g = esc_str(self.get_gender())
        t = esc_str(self.get_title())
        d = esc_str(self.get_dept())
        b = esc_str(self.get_birthday())
        a = esc_str(self.get_anniv())
        i = self.get_im()
        n = self.get_notes()
        m = esc_str(self.get_middlename())
        f = esc_str(self.get_bbdb_folder())

        if p:
            ret += "(%s . %s) " % (noted["prefix"], unchompq(p))
        if g:
            ret += "(%s . %s) " % (noted["gender"], unchompq(g))
        if t:
            ret += "(%s . %s) " % (noted["title"], unchompq(t))
        if d:
            ret += "(%s . %s) " % (noted["dept"], unchompq(d))
        if i and len(i) > 0:
            ret += self._get_ims_as_string(i)
        if b:
            ret += "(%s . %s) " % (noted["birthday"], unchompq(b))
        if a:
            ret += "(%s . %s) " % (noted["anniv"], unchompq(a))
        if n and len(n) > 0 and n[0]:
            ## BBDB cannot handle actual line breaks and double quotes. We
            ## need to quote them. And convert the dos line endings while we
            ## are at it...
            no = esc_str(n[0])
            ret += "(%s . %s) " % (noted["notes"], unchompq(no))
        if m and m != "":
            ret += "(%s . %s) " % (noted["middle_name"], unchompq(m))
        if f:
            ret += "(%s . %s) " % (noted["folder"], unchompq(f))

        ret += self._get_sync_tags_as_str() + " "
        ret += self._get_websites_as_string() + " "

        for label, note in self.get_custom().iteritems():
            if label in ["company", "aka"]:
                continue

            ret += "(%s . %s) " % (label, unchompq(esc_str(note)))

        return "(" + ret + ")"
Esempio n. 38
0
    def _get_notes_as_string(self):
        noted = self.get_notes_map()
        if not noted:
            logging.error('_ge(): Error in Config. No notes_map field for bb')
            return

        ret = '(bbdb-id . %s) ' % unchompq(self.get_itemid())
        ret += '(%s . %s) ' % (noted['created'], unchompq(self.get_created()))
        ret += '(%s . %s) ' % (noted['updated'], unchompq(self.get_updated()))

        p = esc_str(self.get_prefix())
        g = esc_str(self.get_gender())
        t = esc_str(self.get_title())
        d = esc_str(self.get_dept())
        b = esc_str(self.get_birthday())
        a = esc_str(self.get_anniv())
        i = self.get_im()
        n = self.get_notes()
        m = esc_str(self.get_middlename())
        f = esc_str(self.get_bbdb_folder())

        if p:
            ret += '(%s . %s) ' % (noted['prefix'], unchompq(p))
        if g:
            ret += '(%s . %s) ' % (noted['gender'], unchompq(g))
        if t:
            ret += '(%s . %s) ' % (noted['title'], unchompq(t))
        if d:
            ret += '(%s . %s) ' % (noted['dept'], unchompq(d))
        if i and len(i) > 0:
            ret += self._get_ims_as_string(i)
        if b:
            ret += '(%s . %s) ' % (noted['birthday'], unchompq(b))
        if a:
            ret += '(%s . %s) ' % (noted['anniv'], unchompq(a))
        if n and len(n) > 0 and n[0]:
            ## BBDB cannot handle actual line breaks and double quotes. We
            ## need to quote them. And convert the dos line endings while we
            ## are at it...
            no = esc_str(n[0])
            ret += '(%s . %s) ' % (noted['notes'], unchompq(no))
        if m and m != '':
            ret += '(%s . %s) ' % (noted['middle_name'], unchompq(m))
        if f:
            ret += '(%s . %s) ' % (noted['folder'], unchompq(f))

        ret += self._get_sync_tags_as_str() + ' '
        ret += self._get_websites_as_string() + ' '

        for label, note in self.get_custom().iteritems():
            if label in ['company', 'aka']:
                continue

            ret += '(%s . %s) ' % (label, unchompq(esc_str(note)))

        return '(' + ret + ')'