profile is now a dict, not a list
This commit is contained in:
parent
b0d84fff2a
commit
97fe89ab66
4 changed files with 14 additions and 11 deletions
|
|
@ -38,7 +38,7 @@ class ProfileFormatter(IFormatter):
|
||||||
result = u''
|
result = u''
|
||||||
if node.flags & node.SECTION:
|
if node.flags & node.SECTION:
|
||||||
result += u'\t' * level + node.label + '\n'
|
result += u'\t' * level + node.label + '\n'
|
||||||
for sub in node.value:
|
for sub in node.value.itervalues():
|
||||||
result += self.print_node(sub, level+1)
|
result += self.print_node(sub, level+1)
|
||||||
else:
|
else:
|
||||||
if isinstance(node.value, (tuple,list)):
|
if isinstance(node.value, (tuple,list)):
|
||||||
|
|
@ -63,7 +63,7 @@ class ProfileFormatter(IFormatter):
|
||||||
for name, photo in item['photos'].iteritems():
|
for name, photo in item['photos'].iteritems():
|
||||||
result += u'\t%s%s\n' % (photo, ' (hidden)' if photo.hidden else '')
|
result += u'\t%s%s\n' % (photo, ' (hidden)' if photo.hidden else '')
|
||||||
result += u'Profile:\n'
|
result += u'Profile:\n'
|
||||||
for head in item['profile']:
|
for head in item['profile'].itervalues():
|
||||||
result += self.print_node(head)
|
result += self.print_node(head)
|
||||||
result += u'Description:\n'
|
result += u'Description:\n'
|
||||||
for s in item['summary'].split('\n'):
|
for s in item['summary'].split('\n'):
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ class ContactProfile(QWidget):
|
||||||
missing_fields.add('profile')
|
missing_fields.add('profile')
|
||||||
elif not self.loaded_profile:
|
elif not self.loaded_profile:
|
||||||
self.loaded_profile = True
|
self.loaded_profile = True
|
||||||
for head in contact.profile:
|
for head in contact.profile.itervalues():
|
||||||
if head.flags & head.HEAD:
|
if head.flags & head.HEAD:
|
||||||
widget = self.ui.headWidget
|
widget = self.ui.headWidget
|
||||||
else:
|
else:
|
||||||
|
|
@ -265,7 +265,7 @@ class ContactProfile(QWidget):
|
||||||
if node.flags & node.SECTION:
|
if node.flags & node.SECTION:
|
||||||
value = QWidget()
|
value = QWidget()
|
||||||
value.setLayout(QFormLayout())
|
value.setLayout(QFormLayout())
|
||||||
for sub in node.value:
|
for sub in node.value.itervalues():
|
||||||
self.process_node(sub, value)
|
self.process_node(sub, value)
|
||||||
elif isinstance(node.value, list):
|
elif isinstance(node.value, list):
|
||||||
value = QLabel('<br />'.join(unicode(s) for s in node.value))
|
value = QLabel('<br />'.join(unicode(s) for s in node.value))
|
||||||
|
|
|
||||||
|
|
@ -208,20 +208,20 @@ class Contact(_Contact):
|
||||||
url=photo['url'],
|
url=photo['url'],
|
||||||
thumbnail_url=photo['url'].replace('image', 'thumb1_'),
|
thumbnail_url=photo['url'].replace('image', 'thumb1_'),
|
||||||
hidden=photo['hidden'])
|
hidden=photo['hidden'])
|
||||||
self.profile = []
|
self.profile = OrderedDict()
|
||||||
|
|
||||||
for section, d in self.TABLE.iteritems():
|
for section, d in self.TABLE.iteritems():
|
||||||
flags = ProfileNode.SECTION
|
flags = ProfileNode.SECTION
|
||||||
if section.startswith('_'):
|
if section.startswith('_'):
|
||||||
flags |= ProfileNode.HEAD
|
flags |= ProfileNode.HEAD
|
||||||
section = section.lstrip('_')
|
section = section.lstrip('_')
|
||||||
s = ProfileNode(section, section.capitalize(), [], flags=flags)
|
s = ProfileNode(section, section.capitalize(), OrderedDict(), flags=flags)
|
||||||
|
|
||||||
for key, builder in d.iteritems():
|
for key, builder in d.iteritems():
|
||||||
value = builder.get_value(profile, consts[int(profile['sex'])])
|
value = builder.get_value(profile, consts[int(profile['sex'])])
|
||||||
s.value.append(ProfileNode(key, key.capitalize().replace('_', ' '), value))
|
s.value[key] = ProfileNode(key, key.capitalize().replace('_', ' '), value)
|
||||||
|
|
||||||
self.profile.append(s)
|
self.profile[section] = s
|
||||||
|
|
||||||
self.aum_profile = profile
|
self.aum_profile = profile
|
||||||
|
|
||||||
|
|
@ -230,7 +230,7 @@ class Contact(_Contact):
|
||||||
result = u''
|
result = u''
|
||||||
if node.flags & node.SECTION:
|
if node.flags & node.SECTION:
|
||||||
result += u'\t' * level + node.label + '\n'
|
result += u'\t' * level + node.label + '\n'
|
||||||
for sub in node.value:
|
for sub in node.value.itervalues():
|
||||||
result += print_node(sub, level+1)
|
result += print_node(sub, level+1)
|
||||||
else:
|
else:
|
||||||
if isinstance(node.value, (tuple,list)):
|
if isinstance(node.value, (tuple,list)):
|
||||||
|
|
@ -257,7 +257,7 @@ class Contact(_Contact):
|
||||||
for name, photo in self.photos.iteritems():
|
for name, photo in self.photos.iteritems():
|
||||||
result += u'\t%s%s\n' % (photo, ' (hidden)' if photo.hidden else '')
|
result += u'\t%s%s\n' % (photo, ' (hidden)' if photo.hidden else '')
|
||||||
result += u'\nProfile:\n'
|
result += u'\nProfile:\n'
|
||||||
for head in self.profile:
|
for head in self.profile.itervalues():
|
||||||
result += print_node(head)
|
result += print_node(head)
|
||||||
result += u'Description:\n'
|
result += u'Description:\n'
|
||||||
for s in self.summary.split('\n'):
|
for s in self.summary.split('\n'):
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ class ProfileNode(object):
|
||||||
self.sufix = sufix
|
self.sufix = sufix
|
||||||
self.flags = flags
|
self.flags = flags
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return self.value[key]
|
||||||
|
|
||||||
class ContactPhoto(CapBaseObject):
|
class ContactPhoto(CapBaseObject):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
CapBaseObject.__init__(self, name)
|
CapBaseObject.__init__(self, name)
|
||||||
|
|
@ -70,7 +73,7 @@ class Contact(CapBaseObject):
|
||||||
self.add_field('status_msg', basestring)
|
self.add_field('status_msg', basestring)
|
||||||
self.add_field('summary', basestring)
|
self.add_field('summary', basestring)
|
||||||
self.add_field('photos', dict, OrderedDict())
|
self.add_field('photos', dict, OrderedDict())
|
||||||
self.add_field('profile', list)
|
self.add_field('profile', dict)
|
||||||
|
|
||||||
def set_photo(self, name, **kwargs):
|
def set_photo(self, name, **kwargs):
|
||||||
if not name in self.photos:
|
if not name in self.photos:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue