Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
altlinux-packages-bot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Unitsaev
altlinux-packages-bot
Commits
a50bfbe4
Verified
Commit
a50bfbe4
authored
Mar 09, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
appstream: build cache on startup and after updates
parent
19fece2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
methods.py
src/altrepo/appstream/methods.py
+27
-5
No files found.
src/altrepo/appstream/methods.py
View file @
a50bfbe4
...
...
@@ -31,6 +31,7 @@ class DataInfo:
def
__init__
(
self
,
client
:
AppStreamClient
,
appstream_dir
:
str
):
self
.
client
=
client
self
.
dir
=
appstream_dir
self
.
_on_update
=
None
os
.
makedirs
(
self
.
dir
,
exist_ok
=
True
)
async
def
load_by_branch
(
self
,
branch
:
str
,
version
:
str
):
...
...
@@ -47,6 +48,9 @@ class DataInfo:
with
open
(
filepath
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
text
)
if
self
.
_on_update
:
self
.
_on_update
(
branch
)
def
get_file_path
(
self
,
branch
:
str
)
->
str
|
None
:
for
fname
in
os
.
listdir
(
self
.
dir
):
if
fname
.
startswith
(
f
"{branch}-"
)
and
fname
.
endswith
(
".xml"
):
...
...
@@ -68,23 +72,41 @@ class PackageInfo:
def
__init__
(
self
,
client
:
AppStreamClient
,
data
:
DataInfo
):
self
.
client
=
client
self
.
_data
=
data
self
.
_cache
:
dict
[
str
,
dict
[
str
,
str
]]
=
{}
def
id_by_pkgname
(
self
,
pkgname
:
str
,
branch
:
str
)
->
str
|
None
:
def
rebuild_cache
(
self
,
branch
:
str
)
->
None
:
path
=
self
.
_data
.
get_file_path
(
branch
)
if
not
path
:
return
None
self
.
_cache
.
pop
(
branch
,
None
)
return
result
:
dict
[
str
,
str
]
=
{}
context
=
etree
.
iterparse
(
path
,
events
=
(
"end"
,),
recover
=
True
)
for
_
,
elem
in
context
:
if
elem
.
tag
==
"component"
and
elem
.
get
(
"type"
)
!=
"addon"
:
if
elem
.
findtext
(
"pkgname"
)
==
pkgname
:
return
elem
.
findtext
(
"id"
)
pkgname
=
elem
.
findtext
(
"pkgname"
)
app_id
=
elem
.
findtext
(
"id"
)
if
pkgname
and
app_id
:
result
[
pkgname
]
=
app_id
elem
.
clear
()
return
None
self
.
_cache
[
branch
]
=
result
def
id_by_pkgname
(
self
,
pkgname
:
str
,
branch
:
str
)
->
str
|
None
:
if
branch
not
in
self
.
_cache
:
return
None
return
self
.
_cache
[
branch
]
.
get
(
pkgname
)
class
ALTRepoAppStream
:
BRANCHES
=
[
"sisyphus"
,
"p11"
]
def
__init__
(
self
,
session
:
aiohttp
.
ClientSession
,
appstream_dir
:
str
):
self
.
_client
=
AppStreamClient
(
session
)
self
.
data
=
DataInfo
(
self
.
_client
,
appstream_dir
)
self
.
package
=
PackageInfo
(
self
.
_client
,
self
.
data
)
self
.
data
.
_on_update
=
self
.
package
.
rebuild_cache
for
branch
in
self
.
BRANCHES
:
if
self
.
data
.
has_file
(
branch
):
self
.
package
.
rebuild_cache
(
branch
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment