style
This commit is contained in:
parent
cd18efa40d
commit
dcc5e859a5
4 changed files with 8 additions and 8 deletions
|
@ -93,7 +93,7 @@ class Peer(object):
|
||||||
elif action == 'edititem':
|
elif action == 'edititem':
|
||||||
itemid, meta = args
|
itemid, meta = args
|
||||||
item = self.library.get(itemid, {})
|
item = self.library.get(itemid, {})
|
||||||
if not 'meta' in item:
|
if 'meta' not in item:
|
||||||
item['meta'] = meta
|
item['meta'] = meta
|
||||||
else:
|
else:
|
||||||
item['meta'].update(meta)
|
item['meta'].update(meta)
|
||||||
|
@ -111,7 +111,7 @@ class Peer(object):
|
||||||
name = args[0]
|
name = args[0]
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
query = args[1]
|
query = args[1]
|
||||||
if not name in self.info['lists']:
|
if name not in self.info['lists']:
|
||||||
self.info['lists'][name] = []
|
self.info['lists'][name] = []
|
||||||
elif action == 'editlist':
|
elif action == 'editlist':
|
||||||
name, new = args
|
name, new = args
|
||||||
|
@ -127,7 +127,7 @@ class Peer(object):
|
||||||
del self.info['lists'][name]
|
del self.info['lists'][name]
|
||||||
elif action == 'addlistitems':
|
elif action == 'addlistitems':
|
||||||
name, ids = args
|
name, ids = args
|
||||||
if not name in self.info['lists']:
|
if name not in self.info['lists']:
|
||||||
self.info['lists'][name] = []
|
self.info['lists'][name] = []
|
||||||
self.info['lists'][name] = list(set(self.info['lists'][name]) | set(ids))
|
self.info['lists'][name] = list(set(self.info['lists'][name]) | set(ids))
|
||||||
elif action == 'removelistitems':
|
elif action == 'removelistitems':
|
||||||
|
@ -141,14 +141,14 @@ class Peer(object):
|
||||||
# fixme, just trigger peer update here
|
# fixme, just trigger peer update here
|
||||||
from user.models import User
|
from user.models import User
|
||||||
peer = User.get_or_create(peerid)
|
peer = User.get_or_create(peerid)
|
||||||
if not 'username' in peer.info:
|
if 'username' not in peer.info:
|
||||||
peer.info['username'] = username
|
peer.info['username'] = username
|
||||||
peer.update_name()
|
peer.update_name()
|
||||||
peer.save()
|
peer.save()
|
||||||
elif action == 'editpeer':
|
elif action == 'editpeer':
|
||||||
peerid, data = args
|
peerid, data = args
|
||||||
if len(peerid) == 16:
|
if len(peerid) == 16:
|
||||||
if not peerid in self.info['peers']:
|
if peerid not in self.info['peers']:
|
||||||
self.info['peers'][peerid] = {}
|
self.info['peers'][peerid] = {}
|
||||||
for key in ('username', 'contact'):
|
for key in ('username', 'contact'):
|
||||||
if key in data:
|
if key in data:
|
||||||
|
|
|
@ -21,7 +21,7 @@ class pdict(dict):
|
||||||
json.dump(self, fd, indent=4, sort_keys=True, ensure_ascii=False)
|
json.dump(self, fd, indent=4, sort_keys=True, ensure_ascii=False)
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
if default == None and self._defaults:
|
if default is None and self._defaults:
|
||||||
default = self._defaults.get(key)
|
default = self._defaults.get(key)
|
||||||
return dict.get(self, key, default)
|
return dict.get(self, key, default)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue