Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
This commit is contained in:
Alexander Piskun 2023-10-04 12:03:23 +03:00
Родитель b8aa3985e3
Коммит 1759238008
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1F0BF0EC3CF22721
19 изменённых файлов: 39 добавлений и 35 удалений

Просмотреть файл

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Poetry (appstore)" />
</component>
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>

Просмотреть файл

@ -98,7 +98,7 @@ class GunZipAppMetadataExtractor:
} # type: dict[str, str]
for code, _ in self.config.languages:
trans_changelog = get_contents("%s/CHANGELOG.%s.md" % (app_id, code), tar, self.config.max_file_size, "")
trans_changelog = get_contents(f"{app_id}/CHANGELOG.{code}.md", tar, self.config.max_file_size, "")
if trans_changelog:
changelog[code] = trans_changelog
@ -169,7 +169,7 @@ def test_blacklisted_members(tar, blacklist):
for error, regex in blacklist.items():
regex = re.compile(regex)
if regex.search(name):
msg = 'Blacklist rule "%s": Directory %s is not allowed to be present in the app archive' % (
msg = 'Blacklist rule "{}": Directory {} is not allowed to be present in the app archive'.format(
error,
name,
)
@ -392,7 +392,7 @@ def find_member(tar: Any, path: str) -> Any:
constructed from the last element and the current element
"""
if prev:
return prev + ["%s/%s" % (prev[-1], curr)]
return prev + ["{}/{}".format(prev[-1], curr)]
else:
return [curr]

Просмотреть файл

@ -44,7 +44,7 @@ class AppReleaseProvider:
validate_database(meta.database_xml, self.config.db_schema, self.config.pre_db_xslt)
info_app_id = info["app"]["id"]
if meta.app_id != info_app_id:
msg = "Archive app folder is %s but info.xml reports id %s" % (meta.app_id, info_app_id)
msg = "Archive app folder is {} but info.xml reports id {}".format(meta.app_id, info_app_id)
raise InvalidAppDirectoryException(msg)
release = info["app"]["release"]

Просмотреть файл

@ -13,7 +13,7 @@ class ApiTest(TestCase):
self.api_client = APIClient()
def _login(self, user="test", password="test"):
credentials = "%s:%s" % (user, password)
credentials = "{}:{}".format(user, password)
base64_credentials = base64.b64encode(credentials.encode(HTTP_HEADER_ENCODING)).decode(HTTP_HEADER_ENCODING)
auth = "Basic %s" % base64_credentials
self.api_client.credentials(HTTP_AUTHORIZATION=auth)

Просмотреть файл

@ -192,7 +192,7 @@ class AppRegisterView(APIView):
return Response(status=201)
def _create_discourse_category(self, app_id: str) -> None:
url = "%s/categories?api_key=%s&api_username=%s" % (
url = "{}/categories?api_key={}&api_username={}".format(
settings.DISCOURSE_URL.rstrip("/"),
settings.DISCOURSE_TOKEN,
settings.DISCOURSE_USER,

Просмотреть файл

@ -59,7 +59,7 @@ class CertificateValidator:
try:
verify(cert, b64decode(signature.encode()), data, self.config.digest)
except Exception as e:
raise InvalidSignatureException("%s: %s" % (err_msg, str(e)))
raise InvalidSignatureException("{}: {}".format(err_msg, str(e)))
def validate_certificate(self, certificate: str, chain: str, crl: str | None = None) -> None:
"""
@ -90,7 +90,7 @@ class CertificateValidator:
try:
ctx.verify_certificate()
except Exception as e:
raise InvalidCertificateException("%s: %s" % (err_msg, str(e)))
raise InvalidCertificateException("{}: {}".format(err_msg, str(e)))
def get_cn(self, certificate: str) -> str:
"""
@ -113,12 +113,12 @@ class CertificateValidator:
"""
cn = self.get_cn(certificate)
if cn != app_id:
msg = "App id %s does not match cert CN %s" % (app_id, cn)
msg = "App id {} does not match cert CN {}".format(app_id, cn)
raise CertificateAppIdMismatchException(msg)
def _to_cert(self, certificate: str) -> X509:
try:
return load_certificate(FILETYPE_PEM, certificate.encode())
except Exception as e:
msg = "%s: %s" % ("Invalid certificate", str(e))
msg = "{}: {}".format("Invalid certificate", str(e))
raise InvalidCertificateException(msg)

Просмотреть файл

@ -30,31 +30,31 @@ class AppReleaseRssFeed(Feed):
return queryset[:10]
def item_title(self, item):
return "%s (%s)" % (item.app.name, item.version)
return "{} ({})".format(item.app.name, item.version)
def item_description(self, item):
try:
if item.changelog:
changelog = "\n\n# %s\n\n%s" % (_("Changes"), item.changelog)
changelog = "\n\n# {}\n\n{}".format(_("Changes"), item.changelog)
else:
changelog = ""
content = "%s%s" % (item.app.description, changelog)
content = "{}{}".format(item.app.description, changelog)
except TranslationDoesNotExist:
content = item.app.description
content += "\n\n [%s](%s)" % (_("Download"), item.download)
content += "\n\n [{}]({})".format(_("Download"), item.download)
return clean(
markdown(content), attributes=settings.MARKDOWN_ALLOWED_ATTRIBUTES, tags=settings.MARKDOWN_ALLOWED_TAGS
)
def item_guid(self, obj):
nightly = "-nightly" if obj.is_nightly else ""
return "%s-%s%s" % (obj.app.id, obj.version, nightly)
return "{}-{}{}".format(obj.app.id, obj.version, nightly)
def item_link(self, item):
return reverse("app-detail", kwargs={"id": item.app.id})
def item_author_name(self, item):
return "%s %s" % (item.app.owner.first_name, item.app.owner.last_name)
return "{} {}".format(item.app.owner.first_name, item.app.owner.last_name)
def item_pubdate(self, item):
return item.last_modified

Просмотреть файл

@ -138,7 +138,7 @@ class App(TranslatableModel):
if self.discussion:
return self.discussion
else:
return "%s/c/apps/%s" % (settings.DISCOURSE_URL, self.id.replace("_", "-"))
return "{}/c/apps/{}".format(settings.DISCOURSE_URL, self.id.replace("_", "-"))
def _get_grouped_releases(self, get_release_func):
releases = NextcloudRelease.objects.all()
@ -327,7 +327,7 @@ class AppAuthor(Model):
mail = "<%s>" % self.mail
else:
mail = ""
return "%s %s" % (self.name, mail)
return "{} {}".format(self.name, mail)
class Meta:
verbose_name = _("App author")
@ -397,7 +397,7 @@ class AppRelease(TranslatableModel):
return self.can_update(user)
def __str__(self) -> str:
return "%s %s" % (self.app, self.version)
return "{} {}".format(self.app, self.version)
def is_compatible(self, platform_version, inclusive=False):
"""Checks if a release is compatible with a platform version
@ -594,7 +594,7 @@ class DatabaseDependency(Model):
unique_together = (("app_release", "database", "version_spec"),)
def __str__(self) -> str:
return "%s: %s %s" % (self.app_release, self.database, self.version_spec)
return "{}: {} {}".format(self.app_release, self.database, self.version_spec)
class PhpExtension(Model):
@ -627,7 +627,7 @@ class PhpExtensionDependency(Model):
unique_together = (("app_release", "php_extension", "version_spec"),)
def __str__(self) -> str:
return "%s: %s %s" % (self.app_release.app, self.php_extension, self.version_spec)
return "{}: {} {}".format(self.app_release.app, self.php_extension, self.version_spec)
@receiver(post_delete, sender=App)

Просмотреть файл

@ -46,7 +46,7 @@ class BaseStoreTest(StaticLiveServerTestCase):
def go_to(self, url_name: str, kwargs: dict[str, str] = None) -> None:
app_url = reverse(url_name, kwargs=kwargs)
self.selenium.get("%s%s" % (self.live_server_url, app_url))
self.selenium.get("{}{}".format(self.live_server_url, app_url))
def go_to_app(self, app_id):
self.go_to("app-detail", {"id": app_id})
@ -58,7 +58,7 @@ class BaseStoreTest(StaticLiveServerTestCase):
self.go_to("app-upload")
def go_to_login(self):
self.selenium.get("%s%s" % (self.live_server_url, "/login/"))
self.selenium.get(f"{self.live_server_url}/login/")
def login(self, user: str = TEST_USER, password: str = TEST_PASSWORD):
self.go_to_login()

Просмотреть файл

@ -107,7 +107,7 @@ def to_raw_spec(min_version: str, max_version: str) -> str:
elif min_version == "*":
return "<=%s" % max_version
else:
return ">=%s,<=%s" % (min_version, max_version)
return ">={},<={}".format(min_version, max_version)
def to_spec(min_version: str, max_version: str) -> str:
@ -125,7 +125,7 @@ def to_spec(min_version: str, max_version: str) -> str:
elif min_version == "*":
return "<%s" % max_version
else:
return ">=%s,<%s" % (min_version, max_version)
return ">={},<{}".format(min_version, max_version)
GroupedVersions = dict[str, list[Any]]

Просмотреть файл

@ -38,7 +38,7 @@ def build_files(args: dict[str, str]) -> dict[str, str]:
for root, dirs, files in walk(base):
for file in files:
file_path = join(root, file)
rel_file_path = "%s/%s" % (vars["id"], relpath(file_path, base))
rel_file_path = "{}/{}".format(vars["id"], relpath(file_path, base))
with open(file_path, encoding="utf-8") as f:
t = Template(f.read())
result[rel_file_path] = apply_github_actions_fixer(rel_file_path, t.render(context))

Просмотреть файл

@ -119,7 +119,7 @@ class IntegrationScaffoldingForm(Form):
)
def _create_discourse_category(self, app_id: str) -> None:
url = "%s/categories?api_key=%s&api_username=%s" % (
url = "{}/categories?api_key={}&api_username={}".format(
settings.DISCOURSE_URL.rstrip("/"),
settings.DISCOURSE_TOKEN,
settings.DISCOURSE_USER,

Просмотреть файл

@ -23,7 +23,7 @@ class AppScaffoldingView(FormView):
init = {"platform": NextcloudRelease.get_current_main(), "categories": ("tools",)}
if self.request.user.is_authenticated:
user = self.request.user
init["author_name"] = "%s %s" % (user.first_name, user.last_name)
init["author_name"] = "{} {}".format(user.first_name, user.last_name)
init["author_email"] = user.email
return init

Просмотреть файл

@ -24,5 +24,5 @@ class Command(BaseCommand):
password = options["password"]
email = options["email"]
user = create_user(username, password, email)
msg = "Created user %s with password %s and email %s" % (user, password, email)
msg = "Created user {} with password {} and email {}".format(user, password, email)
self.stdout.write(self.style.SUCCESS(msg))

Просмотреть файл

@ -9,5 +9,5 @@ class Command(BaseCommand):
user = get_user_model().objects.get(username="admin")
user.set_password("admin")
user.save()
msg = "Successfully set password %s for user %s" % ("admin", "admin")
msg = "Successfully set password {} for user {}".format("admin", "admin")
self.stdout.write(self.style.SUCCESS(msg))

Просмотреть файл

@ -17,5 +17,5 @@ class Command(BaseCommand):
def handle(self, *args, **options):
username = options["username"]
token = update_token(username, options.get("token", None))
msg = "Successfully set token %s for user %s" % (token.key, username)
msg = "Successfully set token {} for user {}".format(token.key, username)
self.stdout.write(self.style.SUCCESS(msg))

Просмотреть файл

@ -14,5 +14,5 @@ class Command(BaseCommand):
username = options["username"]
email = options["email"]
verify_email(username, email)
msg = "Successfully verified email %s for user %s" % (email, username)
msg = "Successfully verified email {} for user {}".format(email, username)
self.stdout.write(self.style.SUCCESS(msg))

Просмотреть файл

@ -72,7 +72,8 @@ profile = "black"
[tool.ruff]
line-length = 120
target-version = "py310"
select = ["E", "F", "UP006", "UP007"]
select = ["E", "F", "UP006", "UP007", "UP031"]
#select = ["E", "F", "UP"]
[tool.ruff.extend-per-file-ignores]
"**/tests/**/__init__.py" = ["F403"]

Просмотреть файл

@ -33,14 +33,14 @@ def append_git_author(line: str, result_list: list[dict]) -> None:
def to_markdown(authors: Iterator[dict[str, str]]) -> tuple[str, str]:
result = ["# Authors", ""]
for author in authors:
result += ["* [%s](mailto:%s)" % (author["name"], author["email"])]
result += ["* [{}](mailto:{})".format(author["name"], author["email"])]
return "\n".join(result) + "\n", "md"
def to_rst(authors: Iterator[dict[str, str]]) -> tuple[str, str]:
result = ["Authors", "=======", ""]
for author in authors:
result += ["* `%s <mailto:%s>`_" % (author["name"], author["email"])]
result += ["* `{} <mailto:{}>`_".format(author["name"], author["email"])]
return "\n".join(result) + "\n", "rst"