• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.unchompq函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.unchompq函数的典型用法代码示例。如果您正苦于以下问题:Python unchompq函数的具体用法?Python unchompq怎么用?Python unchompq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了unchompq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _get_names_as_string

    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
开发者ID:brehm,项目名称:ASynK,代码行数:31,代码来源:contact_bb.py


示例2: _get_company_as_string

    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) + ')')
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:26,代码来源:contact_bb.py


示例3: _get_names_as_string

    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
开发者ID:Neil-Smithline,项目名称:ASynK,代码行数:33,代码来源:contact_bb.py


示例4: _get_emails_as_string

    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 + ')'
开发者ID:brehm,项目名称:ASynK,代码行数:11,代码来源:contact_bb.py


示例5: _get_company_as_string

    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) + ')')
开发者ID:brehm,项目名称:ASynK,代码行数:12,代码来源:contact_bb.py


示例6: _get_names_as_string

    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
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:49,代码来源:contact_bb.py


示例7: _get_sync_tags_as_str

    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
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:25,代码来源:contact_bb.py


示例8: _get_phones_as_string

    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 + ')'
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:16,代码来源:contact_bb.py


示例9: _get_postal_as_string

    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 + ')'
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:19,代码来源:contact_bb.py


示例10: _get_postal_as_string

    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 + ")"
开发者ID:khinsen,项目名称:ASynK,代码行数:19,代码来源:contact_bb.py


示例11: _get_emails_as_string

    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 + ')'
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:19,代码来源:contact_bb.py


示例12: _get_ver9_fields_as_string

    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()]])
开发者ID:barak,项目名称:ASynK,代码行数:13,代码来源:contact_bb.py


示例13: _get_websites_as_string

    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)
开发者ID:pontus,项目名称:ASynK,代码行数:38,代码来源:contact_bb.py


示例14: _get_websites_as_string

    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)
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:23,代码来源:contact_bb.py


示例15: _get_aka_as_string

    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 + ')'
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:15,代码来源:contact_bb.py


示例16: _get_aka_as_string

    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 + ")"
开发者ID:khinsen,项目名称:ASynK,代码行数:15,代码来源:contact_bb.py


示例17: _get_ims_as_string

    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
开发者ID:Sts0mrg0,项目名称:ASynK,代码行数:18,代码来源:contact_bb.py


示例18: _get_ims_as_string

    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
开发者ID:khinsen,项目名称:ASynK,代码行数:18,代码来源:contact_bb.py


示例19: _get_sync_tags_as_str

    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
开发者ID:Ekaptenn,项目名称:ASynK,代码行数:19,代码来源:contact_bb.py


示例20: _get_postal_as_string

    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 + ')'
开发者ID:jt74,项目名称:emacs,代码行数:22,代码来源:contact_bb.py



注:本文中的utils.unchompq函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.unescape函数代码示例发布时间:2022-05-26
下一篇:
Python utils.unParseTable函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap