Skip to content
Snippets Groups Projects
Unverified Commit 27012108 authored by jooola's avatar jooola
Browse files

style: format code using black (pre-commit)

parent 4314e3ed
No related branches found
No related tags found
1 merge request!61chore: update pre-commit hooks
Pipeline #28582 passed with warnings with stages
in 3 minutes and 18 seconds
......@@ -153,7 +153,6 @@ async def crawl(domain, use_public, detail, passes, sort):
aggregate = aggregate_crawl_results(results["results"])
if detail != NOOP:
click.echo("")
click.echo("Info per domain")
click.echo("===============")
......
......@@ -36,7 +36,7 @@ class DB:
yield self.pool.cursor()
async def create_domains_table(self):
with (await self.pool.cursor()) as cursor:
with await self.pool.cursor() as cursor:
await cursor.execute(
"""
CREATE TABLE IF NOT EXISTS domains (
......@@ -77,7 +77,7 @@ class DB:
ALTER TABLE checks ADD COLUMN IF NOT EXISTS usage_downloads_total INTEGER NULL;
SELECT create_hypertable('checks', 'time', if_not_exists => TRUE);
"""
with (await self.pool.cursor()) as cursor:
with await self.pool.cursor() as cursor:
await cursor.execute(sql)
cursor.close()
......@@ -86,7 +86,7 @@ class DB:
await create_handler()
async def clear(self):
with (await self.pool.cursor()) as cursor:
with await self.pool.cursor() as cursor:
for table, _ in self.TABLES:
await cursor.execute(f"DROP TABLE IF EXISTS {table} CASCADE")
......@@ -98,8 +98,8 @@ class DB:
WHERE private = %s AND domains.blocked = false
ORDER BY domain, time DESC
"""
with (
await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
with await self.pool.cursor(
cursor_factory=psycopg2.extras.RealDictCursor
) as cursor:
await cursor.execute(sql, [False])
return list(await cursor.fetchall())
......@@ -165,16 +165,16 @@ class DB:
return base_query.format(where_clause=""), []
async def get_all_domains(self):
with (
await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
with await self.pool.cursor(
cursor_factory=psycopg2.extras.RealDictCursor
) as cursor:
await cursor.execute("SELECT name FROM domains")
domains = list(await cursor.fetchall())
return domains
async def get_domains(self, **kwargs):
with (
await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
with await self.pool.cursor(
cursor_factory=psycopg2.extras.RealDictCursor
) as cursor:
filters = kwargs.copy()
filters.setdefault("private", False)
......@@ -209,15 +209,15 @@ class DB:
return True
async def get_domain(self, name):
with (
await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
with await self.pool.cursor(
cursor_factory=psycopg2.extras.RealDictCursor
) as cursor:
await cursor.execute("SELECT * FROM domains WHERE name = %s", (name,))
return list(await cursor.fetchall())[0]
async def save_check(self, data):
with (
await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
with await self.pool.cursor(
cursor_factory=psycopg2.extras.RealDictCursor
) as cursor:
node_name = data.pop("node_name", None)
fields, values = [], []
......@@ -245,8 +245,8 @@ class DB:
return check
async def create_domain(self, data):
with (
await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
with await self.pool.cursor(
cursor_factory=psycopg2.extras.RealDictCursor
) as cursor:
sql = "INSERT INTO domains (name) VALUES (%s) ON CONFLICT DO NOTHING RETURNING *"
await cursor.execute(sql, [data["name"]])
......
......@@ -51,7 +51,6 @@ def get_value(obj, config, truncate=30):
def table(objects, fields, type, headers=True, format="simple", sort=None):
configs = {}
if sort:
......
......@@ -14,7 +14,6 @@ async def test_create_domain_ignore_duplicate(populated_db):
async def test_db_create():
async with DB() as db:
try:
await db.create()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment