Skip to content

Commit

Permalink
finish importer
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Feb 25, 2024
1 parent d150a10 commit 3749fcb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/tasks/importtasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import json
import os
import shutil
import sys
from json import JSONDecodeError
from zipfile import ZipFile

Expand All @@ -27,7 +26,8 @@
from git import GitCommandError
from git_archive_all import GitArchiver
from kombu import uuid
from sqlalchemy import and_, insert
from sqlalchemy import and_
from sqlalchemy.dialects.postgresql import insert

from app.models import AuditSeverity, db, NotificationType, PackageRelease, MetaPackage, Dependency, PackageType, \
MinetestRelease, Package, PackageState, PackageScreenshot, PackageUpdateTrigger, PackageUpdateConfig, \
Expand Down Expand Up @@ -164,15 +164,13 @@ def get_meta_packages(names):
db.session.add(Dependency(package, meta=meta, optional=True))

# Read translations
allowed_languages = set(db.session.query(Language.id).all())
print(f"Allowed languages {allowed_languages}", file=sys.stderr)

textdomain = tree.get("textdomain", tree.name)
raw_translations = tree.get_translations(textdomain)
allowed_languages = set([x[0] for x in db.session.query(Language.id).all()])
allowed_languages.discard("en")
raw_translations = tree.get_translations(tree.get("textdomain", tree.name))
conn = db.session.connection()
for raw_translation in raw_translations:
if raw_translation.language not in allowed_languages:
print(f"Ignoring language {raw_translation.language}", file=sys.stderr)
continue

to_update = {
"title": raw_translation.entries.get(tree.get("title", package.title)),
Expand Down

0 comments on commit 3749fcb

Please sign in to comment.