mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Refactor code to comply with flake8 and isort
Signed-off-by: Filipe Laíns <lains@archlinux.org> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
48b58b1c2f
commit
8d1be7ea8a
11 changed files with 206 additions and 197 deletions
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
|
||||||
import shlex
|
|
||||||
import re
|
import re
|
||||||
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import aurweb.config
|
import aurweb.config
|
||||||
|
|
|
@ -472,7 +472,7 @@ def checkarg(cmdargv, *argdesc):
|
||||||
checkarg_atmost(cmdargv, *argdesc)
|
checkarg_atmost(cmdargv, *argdesc)
|
||||||
|
|
||||||
|
|
||||||
def serve(action, cmdargv, user, privileged, remote_addr):
|
def serve(action, cmdargv, user, privileged, remote_addr): # noqa: C901
|
||||||
if enable_maintenance:
|
if enable_maintenance:
|
||||||
if remote_addr not in maintenance_exc:
|
if remote_addr not in maintenance_exc:
|
||||||
raise aurweb.exceptions.MaintenanceException
|
raise aurweb.exceptions.MaintenanceException
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pygit2
|
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import pygit2
|
||||||
import srcinfo.parse
|
import srcinfo.parse
|
||||||
import srcinfo.utils
|
import srcinfo.utils
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ def create_pkgbase(conn, pkgbase, user):
|
||||||
return pkgbase_id
|
return pkgbase_id
|
||||||
|
|
||||||
|
|
||||||
def save_metadata(metadata, conn, user):
|
def save_metadata(metadata, conn, user): # noqa: C901
|
||||||
# Obtain package base ID and previous maintainer.
|
# Obtain package base ID and previous maintainer.
|
||||||
pkgbase = metadata['pkgbase']
|
pkgbase = metadata['pkgbase']
|
||||||
cur = conn.execute("SELECT ID, MaintainerUID FROM PackageBases "
|
cur = conn.execute("SELECT ID, MaintainerUID FROM PackageBases "
|
||||||
|
@ -232,7 +232,7 @@ def die_commit(msg, commit):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(): # noqa: C901
|
||||||
repo = pygit2.Repository(repo_path)
|
repo = pygit2.Repository(repo_path)
|
||||||
|
|
||||||
user = os.environ.get("AUR_USER")
|
user = os.environ.get("AUR_USER")
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import aurweb.db
|
import argparse
|
||||||
import aurweb.schema
|
|
||||||
|
|
||||||
import alembic.command
|
import alembic.command
|
||||||
import alembic.config
|
import alembic.config
|
||||||
import argparse
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
|
import aurweb.db
|
||||||
|
import aurweb.schema
|
||||||
|
|
||||||
|
|
||||||
def feed_initial_data(conn):
|
def feed_initial_data(conn):
|
||||||
conn.execute(aurweb.schema.AccountTypes.insert(), [
|
conn.execute(aurweb.schema.AccountTypes.insert(), [
|
||||||
|
|
|
@ -16,4 +16,4 @@ class Translator:
|
||||||
self._localedir,
|
self._localedir,
|
||||||
languages=[lang])
|
languages=[lang])
|
||||||
self._translator[lang].install()
|
self._translator[lang].install()
|
||||||
return _(s)
|
return _(s) # _ is not defined, what is this? # noqa: F821
|
||||||
|
|
|
@ -6,7 +6,7 @@ usually be automatically generated. See `migrations/README` for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from sqlalchemy import CHAR, Column, ForeignKey, Index, MetaData, String, TIMESTAMP, Table, Text, text
|
from sqlalchemy import CHAR, TIMESTAMP, Column, ForeignKey, Index, MetaData, String, Table, Text, text
|
||||||
from sqlalchemy.dialects.mysql import BIGINT, DECIMAL, INTEGER, TINYINT
|
from sqlalchemy.dialects.mysql import BIGINT, DECIMAL, INTEGER, TINYINT
|
||||||
from sqlalchemy.ext.compiler import compiles
|
from sqlalchemy.ext.compiler import compiles
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def compile_bigint_sqlite(type_, compiler, **kw):
|
||||||
to INTEGER. Aside from that, BIGINT is the same as INTEGER for SQLite.
|
to INTEGER. Aside from that, BIGINT is the same as INTEGER for SQLite.
|
||||||
|
|
||||||
See https://docs.sqlalchemy.org/en/13/dialects/sqlite.html#allowing-autoincrement-behavior-sqlalchemy-types-other-than-integer-integer
|
See https://docs.sqlalchemy.org/en/13/dialects/sqlite.html#allowing-autoincrement-behavior-sqlalchemy-types-other-than-integer-integer
|
||||||
"""
|
""" # noqa: E501
|
||||||
return 'INTEGER'
|
return 'INTEGER'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import pyalpm
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import pyalpm
|
||||||
|
|
||||||
import aurweb.config
|
import aurweb.config
|
||||||
import aurweb.db
|
import aurweb.db
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import re
|
|
||||||
import pygit2
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import bleach
|
import bleach
|
||||||
import markdown
|
import markdown
|
||||||
|
import pygit2
|
||||||
|
|
||||||
import aurweb.config
|
import aurweb.config
|
||||||
import aurweb.db
|
import aurweb.db
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import aurweb.db
|
|
||||||
import aurweb.schema
|
|
||||||
|
|
||||||
from alembic import context
|
|
||||||
import logging.config
|
import logging.config
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
|
from alembic import context
|
||||||
|
|
||||||
|
import aurweb.db
|
||||||
|
import aurweb.schema
|
||||||
|
|
||||||
# this is the Alembic Config object, which provides
|
# this is the Alembic Config object, which provides
|
||||||
# access to the values within the .ini file in use.
|
# access to the values within the .ini file in use.
|
||||||
|
|
|
@ -10,12 +10,11 @@ usage: gendummydata.py outputfilename.sql
|
||||||
# insert these users/packages into the AUR database.
|
# insert these users/packages into the AUR database.
|
||||||
#
|
#
|
||||||
import hashlib
|
import hashlib
|
||||||
import random
|
|
||||||
import time
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import io
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
LOG_LEVEL = logging.DEBUG # logging level. set to logging.INFO to reduce output
|
LOG_LEVEL = logging.DEBUG # logging level. set to logging.INFO to reduce output
|
||||||
SEED_FILE = "/usr/share/dict/words"
|
SEED_FILE = "/usr/share/dict/words"
|
||||||
|
@ -69,6 +68,7 @@ seen_users = {}
|
||||||
seen_pkgs = {}
|
seen_pkgs = {}
|
||||||
user_keys = []
|
user_keys = []
|
||||||
|
|
||||||
|
|
||||||
# some functions to generate random data
|
# some functions to generate random data
|
||||||
#
|
#
|
||||||
def genVersion():
|
def genVersion():
|
||||||
|
@ -78,10 +78,16 @@ def genVersion():
|
||||||
if random.randrange(0, 2) == 0:
|
if random.randrange(0, 2) == 0:
|
||||||
ver.append("%d" % random.randrange(0, 100))
|
ver.append("%d" % random.randrange(0, 100))
|
||||||
return ".".join(ver) + "-%d" % random.randrange(1, 11)
|
return ".".join(ver) + "-%d" % random.randrange(1, 11)
|
||||||
|
|
||||||
|
|
||||||
def genCategory():
|
def genCategory():
|
||||||
return random.randrange(1, CATEGORIES_COUNT)
|
return random.randrange(1, CATEGORIES_COUNT)
|
||||||
|
|
||||||
|
|
||||||
def genUID():
|
def genUID():
|
||||||
return seen_users[user_keys[random.randrange(0, len(user_keys))]]
|
return seen_users[user_keys[random.randrange(0, len(user_keys))]]
|
||||||
|
|
||||||
|
|
||||||
def genFortune():
|
def genFortune():
|
||||||
return fortunes[random.randrange(0, len(fortunes))].replace("'", "")
|
return fortunes[random.randrange(0, len(fortunes))].replace("'", "")
|
||||||
|
|
||||||
|
@ -172,7 +178,7 @@ for u in user_keys:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
h = hashlib.new('md5')
|
h = hashlib.new('md5')
|
||||||
h.update(u.encode());
|
h.update(u.encode())
|
||||||
s = ("INSERT INTO Users (ID, AccountTypeID, Username, Email, Passwd)"
|
s = ("INSERT INTO Users (ID, AccountTypeID, Username, Email, Passwd)"
|
||||||
" VALUES (%d, %d, '%s', '%s@example.com', '%s');\n")
|
" VALUES (%d, %d, '%s', '%s@example.com', '%s');\n")
|
||||||
s = s % (seen_users[u], account_type, u, u, h.hexdigest())
|
s = s % (seen_users[u], account_type, u, u, h.hexdigest())
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -1,7 +1,8 @@
|
||||||
import re
|
import re
|
||||||
from setuptools import setup, find_packages
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
version = None
|
version = None
|
||||||
with open('web/lib/version.inc.php', 'r') as f:
|
with open('web/lib/version.inc.php', 'r') as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
|
|
Loading…
Add table
Reference in a new issue