This commit is contained in:
j 2019-01-11 15:18:53 +05:30
parent cd18efa40d
commit dcc5e859a5
4 changed files with 8 additions and 8 deletions

View file

@ -116,7 +116,7 @@ def drop_columns(table, columns):
} }
create_table = get_create_table(table) create_table = get_create_table(table)
for column in columns: for column in columns:
create_table = re.sub('(%s .*?,)'%column, '', create_table) create_table = re.sub('(%s .*?,)' % column, '', create_table)
create_table = create_table.replace('\n', '').replace(',', ',\n') create_table = create_table.replace('\n', '').replace(',', ',\n')
create_table = re.sub('\n *', '\n ', create_table).replace('( ', '(\n ') create_table = re.sub('\n *', '\n ', create_table).replace('( ', '(\n ')
sql = [ sql = [

View file

@ -9,7 +9,7 @@ from sqlalchemy.sql.expression import text
from sqlalchemy import func from sqlalchemy import func
from oxtornado import actions from oxtornado import actions
import utils #utils must be imported before websocket to avoid loop import utils # utils must be imported before websocket to avoid loop
from websocket import trigger_event from websocket import trigger_event
import meta import meta
from . import models from . import models

View file

@ -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:

View file

@ -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)