Codestyle++

This commit is contained in:
Patrick Jentsch 2020-03-27 10:13:42 +01:00
parent ca8d438e79
commit b0c2415f55

View File

@ -59,13 +59,12 @@ def user_ressource_session_handler(app, user_id, session_id, foreign=False):
' NOTE: The initial values are send as a init events. ' NOTE: The initial values are send as a init events.
' The JSON patches are send as update events. ' The JSON patches are send as update events.
''' '''
init_events = {'corpora': 'foreign_corpora_init' if foreign init_events = \
else 'corpora_init', {'corpora': 'foreign_corpora_init' if foreign else 'corpora_init',
'jobs': 'foreign_jobs_init' if foreign else 'jobs_init'} 'jobs': 'foreign_jobs_init' if foreign else 'jobs_init'}
update_events = {'corpora': 'foreign_corpora_update' if foreign update_events = \
else 'corpora_update', {'corpora': 'foreign_corpora_update' if foreign else 'corpora_update',
'jobs': 'foreign_jobs_update' if foreign 'jobs': 'foreign_jobs_update' if foreign else 'jobs_update'}
else 'jobs_update'}
with app.app_context(): with app.app_context():
# Gather current values from database. # Gather current values from database.
user = User.query.get(user_id) user = User.query.get(user_id)
@ -77,7 +76,8 @@ def user_ressource_session_handler(app, user_id, session_id, foreign=False):
socketio.emit(init_events['jobs'], json.dumps(jobs), room=session_id) socketio.emit(init_events['jobs'], json.dumps(jobs), room=session_id)
while session_id in connected_sessions: while session_id in connected_sessions:
# Get new values from the database # Get new values from the database
new_corpora = {corpus.id: corpus.to_dict() for corpus in user.corpora} new_corpora = {corpus.id: corpus.to_dict()
for corpus in user.corpora}
new_jobs = {job.id: job.to_dict() for job in user.jobs} new_jobs = {job.id: job.to_dict() for job in user.jobs}
# Compute JSON patches. # Compute JSON patches.
corpora_patch = jsonpatch.JsonPatch.from_diff(corpora, new_corpora) corpora_patch = jsonpatch.JsonPatch.from_diff(corpora, new_corpora)