IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Verified Commit 5118d94a authored by Emi Simpson's avatar Emi Simpson
Browse files

Clean up unused code

parent 00aaaca3
Pipeline #1120 failed with stage
in 7 seconds
......@@ -16,13 +16,10 @@ Similarly, any attempts to update fields of the model will not be processed unti
is called.
"""
from mystic.sources import SOURCE_PROCESSORS, Source
from functools import reduce
from typing import List, Optional, Dict, Tuple, Type, Union, cast
from typing import List, Optional, Tuple, Union, cast
from pymysql.cursors import Cursor
import markdown
import bleach
_alphabet = 'abcdefghijklmnopqrstuvwxyz'
......@@ -40,7 +37,7 @@ class Project:
mystic.database.MalformedId: The ID of the project is invalid
"""
MalformedId.check_malformed(project_id)
self._project_id: int = project_id
self.project_id: int = project_id
self._display_name: Optional[str] = None
self._description: Optional[str] = None
self._slug: Optional[str] = None
......@@ -80,10 +77,10 @@ class Project:
mystic.database.NonexistantId: The project was initialized with an ID
that was not found
"""
c.execute('SELECT * FROM projects WHERE project_id = %s;', (self._project_id,))
c.execute('SELECT * FROM projects WHERE project_id = %s;', (self.project_id,))
record = c.fetchone()
if record is None:
raise NonexistantId('project', self._project_id)
raise NonexistantId('project', self.project_id)
self._slug = record[1]
self._display_name = record[2]
self._description = record[3]
......@@ -195,7 +192,7 @@ class Project:
JOIN projects
ON projects.project_id = data_sources.project_id
WHERE data_sources.project_id = %s
''', (self._project_id,))
''', (self.project_id,))
records = cast(Tuple[Tuple[int, int, str, str, str, Optional[int], str, str, bool]], c.fetchall())
source_tuples = (
Source(
......@@ -223,12 +220,12 @@ class Project:
def __eq__(self, other: object) -> bool:
if isinstance(other, Project):
return self._project_id == other._project_id
return self.project_id == other.project_id
else:
return False
def __hash__(self) -> int:
return self._project_id
return self.project_id
class User:
def __init__(self, user_id: int) -> None:
......@@ -304,7 +301,7 @@ class User:
FROM owners
WHERE user_id = %s
AND project_id = %s;
''', (self._user_id, project._project_id))
''', (self._user_id, project.project_id))
return len(c.fetchall()) != 0
def delete_source_if_owned(self, c: Cursor, src_id: int) -> bool:
......
......@@ -13,8 +13,5 @@ setup(
'msgpack==1.0.2',
'msgpack-types',
'argon2-cffi',
'markdown',
'bleach',
'Pygments',
],
)
Supports Markdown
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