From 17bb3d2122851614fd61e40a657699f0cab48ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 4 May 2016 15:41:46 +0200 Subject: [PATCH] [metadata] Simplify writing media.repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit also removes the ability to generate timestamp. It must now always be passed explicitly. The feature was not used anywhere and it actually did not work. Signed-off-by: Lubomír Sedlář --- pungi/compose_metadata/discinfo.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pungi/compose_metadata/discinfo.py b/pungi/compose_metadata/discinfo.py index 0042015e..788a2601 100644 --- a/pungi/compose_metadata/discinfo.py +++ b/pungi/compose_metadata/discinfo.py @@ -70,16 +70,11 @@ def read_discinfo(file_path): return result -def write_media_repo(file_path, description, timestamp=None): +def write_media_repo(file_path, description, timestamp): """ Write media.repo file for the disc to be used on installed system. PackageKit uses this. """ - - if not timestamp: - raise - timestamp = "%f" % time.time() - data = [ "[InstallMedia]", "name=%s" % description, @@ -90,7 +85,6 @@ def write_media_repo(file_path, description, timestamp=None): "", ] - repo_file = open(file_path, "w") - repo_file.write("\n".join(data)) - repo_file.close() + with open(file_path, "w") as repo_file: + repo_file.write("\n".join(data)) return timestamp