Skip to content

Commit ae05276

Browse files
committed
add image info export
1 parent d9f7501 commit ae05276

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

.github/workflows/online_test_deck.yml

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
org.universal-blue.pkg.hhd=<version:hhd>
5959
org.universal-blue.pkg.adjustor=<version:adjustor>
6060
org.universal-blue.pkg.hhd-ui=<version:hhd-ui>
61+
62+
org.universal-blue.info=<imginfo>
6163
description: >
6264
Bazzite Deck <pretty>
6365
[Kernel: <relver:kernel>,

src/rechunk/model.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import NamedTuple
21
from datetime import datetime
2+
from typing import Literal, NamedTuple, Sequence, TypedDict
33

44

55
class File(NamedTuple):
@@ -16,11 +16,33 @@ class Package(NamedTuple):
1616
version: str = ""
1717
release: str = ""
1818

19+
1920
class MetaPackage(NamedTuple):
2021
index: int
2122
name: str
2223
nevra: tuple[str, ...]
2324
size: int
2425
updates: tuple[datetime, ...] = tuple()
2526
dedicated: bool = False
26-
meta: bool = False
27+
meta: bool = False
28+
29+
30+
class ExportInfoV1(TypedDict):
31+
version: Literal[1]
32+
33+
uniq: str
34+
packages: dict[str, str]
35+
36+
37+
def export_v1(
38+
uniq: str | None,
39+
base_pkg: Sequence[Package] | None,
40+
) -> str:
41+
import json
42+
43+
packages = {}
44+
if base_pkg:
45+
for p in base_pkg:
46+
packages[p.name] = f"{p.version}-{p.release}"
47+
48+
return json.dumps(ExportInfoV1(version=1, uniq=uniq or "", packages=packages))

src/rechunk/utils.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99
from tqdm.auto import tqdm as tqdm_orig
1010

11-
from .model import MetaPackage, Package
11+
from .model import MetaPackage, Package, export_v1
1212

1313
logger = logging.getLogger(__name__)
1414

@@ -180,6 +180,9 @@ def get_labels(
180180
with open(version_fn, "w") as f:
181181
f.write(new_version)
182182

183+
imginfo = None
184+
blacklist = dict()
185+
183186
if labels:
184187
for line in labels:
185188
if not "=" in line:
@@ -198,6 +201,11 @@ def get_labels(
198201
value = value.replace("<pretty>", pretty)
199202
if "<previous>" in value and prev_version:
200203
value = value.replace("<previous>", prev_version)
204+
if "<imginfo>" in value:
205+
if not imginfo:
206+
imginfo = export_v1(uniq=new_version, base_pkg=base_pkg)
207+
value = value.replace("<imginfo>", imginfo)
208+
blacklist[key] = "> IMGINFO V1 INSERTED"
201209

202210
if base_pkg:
203211
for pkg in base_pkg:
@@ -222,6 +230,8 @@ def get_labels(
222230
if new_labels:
223231
log = "Writing labels:\n"
224232
for key, value in new_labels.items():
233+
if key in blacklist:
234+
value = blacklist[key]
225235
log += f" - {key} =\n'{value}'\n"
226236
logger.info(log)
227237
else:

0 commit comments

Comments
 (0)