Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0054.py @ 1075:7b4600ad73ad
misc: remove some pylints warnings
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 15 Jun 2014 18:18:36 +0200 |
parents | 301b342c697a |
children | 5d89fecdf667 |
comparison
equal
deleted
inserted
replaced
1074:a47995155e55 | 1075:7b4600ad73ad |
---|---|
124 if not name in cached or cached[name] != value: | 124 if not name in cached or cached[name] != value: |
125 self.host.memory.updateEntityData(jid, name, value, profile) | 125 self.host.memory.updateEntityData(jid, name, value, profile) |
126 if name == "avatar": | 126 if name == "avatar": |
127 self.avatars_cache[jid.userhost()] = value | 127 self.avatars_cache[jid.userhost()] = value |
128 | 128 |
129 def get_cache(self, jid, name, profile): | 129 def get_cache(self, entity_jid, name, profile): |
130 """return cached value for jid | 130 """return cached value for jid |
131 @param jid: target contact | 131 @param entity_jid: target contact |
132 @param name: name of the value ('nick' or 'avatar') | 132 @param name: name of the value ('nick' or 'avatar') |
133 @param profile: %(doc_profile)s | 133 @param profile: %(doc_profile)s |
134 @return: wanted value or None""" | 134 @return: wanted value or None""" |
135 try: | 135 try: |
136 data = self.host.memory.getEntityData(jid, [name], profile) | 136 data = self.host.memory.getEntityData(entity_jid, [name], profile) |
137 except exceptions.UnknownEntityError: | 137 except exceptions.UnknownEntityError: |
138 return None | 138 return None |
139 return data.get(name) | 139 return data.get(name) |
140 | 140 |
141 def save_photo(self, photo_xml): | 141 def save_photo(self, photo_xml): |
147 log.debug(_('Decoding binary')) | 147 log.debug(_('Decoding binary')) |
148 decoded = b64decode(str(elem)) | 148 decoded = b64decode(str(elem)) |
149 image_hash = sha1(decoded).hexdigest() | 149 image_hash = sha1(decoded).hexdigest() |
150 filename = self.avatar_path + '/' + image_hash | 150 filename = self.avatar_path + '/' + image_hash |
151 if not os.path.exists(filename): | 151 if not os.path.exists(filename): |
152 with open(filename, 'wb') as file: | 152 with open(filename, 'wb') as file_: |
153 file.write(decoded) | 153 file_.write(decoded) |
154 log.debug(_("file saved to %s") % image_hash) | 154 log.debug(_("file saved to %s") % image_hash) |
155 else: | 155 else: |
156 log.debug(_("file [%s] already in cache") % image_hash) | 156 log.debug(_("file [%s] already in cache") % image_hash) |
157 return image_hash | 157 return image_hash |
158 | 158 |