本文整理汇总了Python中utils.unchompq函数的典型用法代码示例。如果您正苦于以下问题:Python unchompq函数的具体用法?Python unchompq怎么用?Python unchompq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unchompq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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) + ')')
示例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
示例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 + ')'
示例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) + ')')
示例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
示例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
示例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 + ')'
示例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 + ')'
示例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 + ")"
示例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 + ')'
示例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()]])
示例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)
示例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)
示例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 + ')'