Move System and Member to separate files

This commit is contained in:
Ske 2018-09-09 19:53:32 +02:00
parent 138c0b7f8c
commit 49b4e4c1ef
9 changed files with 66 additions and 53 deletions

0
src/__init__.py Normal file
View File

View File

@ -1,48 +0,0 @@
from collections import namedtuple
from datetime import date, datetime
class System(namedtuple("System", ["id", "hid", "name", "description", "tag", "avatar_url", "created"])):
id: int
hid: str
name: str
description: str
tag: str
avatar_url: str
created: datetime
def to_json(self):
return {
"id": self.hid,
"name": self.name,
"description": self.description,
"tag": self.tag,
"avatar_url": self.avatar_url
}
class Member(namedtuple("Member", ["id", "hid", "system", "color", "avatar_url", "name", "birthday", "pronouns", "description", "prefix", "suffix", "created"])):
id: int
hid: str
system: int
color: str
avatar_url: str
name: str
birthday: date
pronouns: str
description: str
prefix: str
suffix: str
created: datetime
def to_json(self):
return {
"id": self.hid,
"name": self.name,
"color": self.color,
"avatar_url": self.avatar_url,
"birthday": self.birthday.isoformat() if self.birthday else None,
"pronouns": self.pronouns,
"description": self.description,
"prefix": self.prefix,
"suffix": self.suffix
}

View File

@ -6,7 +6,9 @@ import re
import traceback import traceback
from typing import Tuple, Optional from typing import Tuple, Optional
from pluralkit import db, System, Member from pluralkit import db
from pluralkit.system import System
from pluralkit.member import Member
from pluralkit.bot import embeds, utils from pluralkit.bot import embeds, utils
logger = logging.getLogger("pluralkit.bot.commands") logger = logging.getLogger("pluralkit.bot.commands")

View File

@ -1,11 +1,12 @@
import dateparser import dateparser
import humanize import humanize
from datetime import datetime, timezone from datetime import datetime
from typing import List from typing import List
import pluralkit.utils import pluralkit.utils
from pluralkit.bot import help from pluralkit.bot import help
from pluralkit.bot.commands import * from pluralkit.bot.commands import *
from pluralkit.member import Member
logger = logging.getLogger("pluralkit.commands") logger = logging.getLogger("pluralkit.commands")

View File

@ -6,7 +6,9 @@ import string
import discord import discord
import humanize import humanize
from pluralkit import System, Member, db from pluralkit import db
from pluralkit.system import System
from pluralkit.member import Member
from pluralkit.utils import get_fronters from pluralkit.utils import get_fronters
logger = logging.getLogger("pluralkit.utils") logger = logging.getLogger("pluralkit.utils")

View File

@ -8,7 +8,9 @@ import asyncpg
import asyncpg.exceptions import asyncpg.exceptions
from discord.utils import snowflake_time from discord.utils import snowflake_time
from pluralkit import System, Member, stats from pluralkit import stats
from pluralkit.system import System
from pluralkit.member import Member
logger = logging.getLogger("pluralkit.db") logger = logging.getLogger("pluralkit.db")
async def connect(username, password, database, host, port): async def connect(username, password, database, host, port):

31
src/pluralkit/member.py Normal file
View File

@ -0,0 +1,31 @@
from datetime import date, datetime
from collections.__init__ import namedtuple
class Member(namedtuple("Member", ["id", "hid", "system", "color", "avatar_url", "name", "birthday", "pronouns", "description", "prefix", "suffix", "created"])):
id: int
hid: str
system: int
color: str
avatar_url: str
name: str
birthday: date
pronouns: str
description: str
prefix: str
suffix: str
created: datetime
def to_json(self):
return {
"id": self.hid,
"name": self.name,
"color": self.color,
"avatar_url": self.avatar_url,
"birthday": self.birthday.isoformat() if self.birthday else None,
"pronouns": self.pronouns,
"description": self.description,
"prefix": self.prefix,
"suffix": self.suffix
}

22
src/pluralkit/system.py Normal file
View File

@ -0,0 +1,22 @@
from datetime import datetime
from collections.__init__ import namedtuple
class System(namedtuple("System", ["id", "hid", "name", "description", "tag", "avatar_url", "created"])):
id: int
hid: str
name: str
description: str
tag: str
avatar_url: str
created: datetime
def to_json(self):
return {
"id": self.hid,
"name": self.name,
"description": self.description,
"tag": self.tag,
"avatar_url": self.avatar_url
}

View File

@ -1,7 +1,8 @@
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import List, Tuple from typing import List, Tuple
from pluralkit import db, Member from pluralkit import db
from pluralkit.member import Member
def fix_time(time: datetime): def fix_time(time: datetime):