Commit 371cb00e authored by Elizabeth Myers's avatar Elizabeth Myers 💬
Browse files

Autopep8

parent 7d85e676
from sqlalchemy.future import select
from sqlalchemy.exc import NoResultFound
from dcp.config import conf
from dcp.db import (StorageUser,StorageGroup,StorageGroupAcl,
StorageGroupMember,StorageUserLine,StorageGroupLine,
from dcp.db import (StorageUser, StorageGroup, StorageGroupAcl,
StorageGroupMember, StorageUserLine, StorageGroupLine,
async_session)
from dcp.frame import Frame
from dcp.client import username_to_client
from dcp.send import sendto_user, sendto_group, filt_exclude_client
from dcp.commands import Command, CommandError
class ListGroups(Command):
name = 'listgroups'
async def pre_reg(self, _client, _frame):
raise CommandError('You have not identified')
async def reg(self, client, frame):
target = 'none'
print(frame.dst)
if len(frame.dst)>1:
target=frame.dst
if len(frame.dst) > 1:
target = frame.dst
if target != 'user' and target != 'none':
raise CommandError(f'{target} is Invalid usage. Accepts user '
f'or none, for listing groups you are a '
......@@ -27,15 +29,17 @@ class ListGroups(Command):
async with async_session() as session:
async with session.begin():
if target == 'user':
stmt = (select(StorageGroup)
.join(StorageGroupMember,StorageGroupMember.group_id==StorageGroup.id)
.where(StorageUser.username==client.username))
stmt = (
select(StorageGroup) .join(
StorageGroupMember,
StorageGroupMember.group_id == StorageGroup.id) .where(
StorageUser.username == client.username))
else:
stmt = (select(StorageGroup))
result = await session.execute(stmt)
reply = Frame.create(f'@{client.username}', frame.dst,
'listgroups',frame.related,
{'groups':[i.StorageGroup.name for i in result]})
'listgroups', frame.related,
{'groups': [i.StorageGroup.name for i in result]})
await sendto_user(client.username,reply)
await sendto_user(client.username, reply)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment