Skip to content

Commit 13b6b17

Browse files
committed
simplify
1 parent c57e4d4 commit 13b6b17

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

fs/bin/add_build_info.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@
2323
BUILD_INFO_FILE = "xpra/build_info.py"
2424

2525

26-
def update_properties(props: dict, filename: str) -> None:
26+
def update_properties(props: dict[str, Any], filename: str) -> None:
2727
eprops = get_properties(filename)
28-
for key, value in props.items():
29-
if value is None:
30-
continue
31-
if value not in ("unknown", "") or not props.get(key):
32-
props[key] = value
28+
eprops.update(props)
3329
save_properties(eprops, filename)
3430

3531

36-
def save_properties(props: dict, filename: str) -> None:
32+
def save_properties(props: dict[str, Any], filename: str) -> None:
3733
if os.path.exists(filename):
3834
try:
3935
os.unlink(filename)
@@ -395,18 +391,14 @@ def record_src_info() -> None:
395391
update_properties(get_vcs_props(), SRC_INFO_FILE)
396392

397393

398-
def has_src_info() -> bool:
399-
return os.path.exists(SRC_INFO_FILE) and os.path.isfile(SRC_INFO_FILE)
400-
401-
402-
def has_build_info() -> bool:
403-
return os.path.exists(BUILD_INFO_FILE) and os.path.isfile(BUILD_INFO_FILE)
394+
def check_file(filename: str) -> bool:
395+
return os.path.exists(filename) and os.path.isfile(filename) and os.stat(filename).st_size > 0
404396

405397

406398
def main(args):
407-
if not has_src_info() or "src" in args:
399+
if not check_file(SRC_INFO_FILE) or "src" in args:
408400
record_src_info()
409-
if not has_build_info() or "build" in args:
401+
if not check_file(BUILD_INFO_FILE) or "build" in args:
410402
record_build_info()
411403
if "revision" in args:
412404
props = get_vcs_props()

0 commit comments

Comments
 (0)