From c0ec95784258f159a2fe25e3335518e566c72116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Thu, 7 Oct 2010 07:15:41 +0000 Subject: [PATCH] util: Add function to generate a filename from the package info given --- pisi/util.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pisi/util.py b/pisi/util.py index c9b2d6ea..c982f348 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -639,6 +639,20 @@ def partition_freespace(directory): # Package/Repository Related Functions # ######################################## +def package_filename(name, version, release, distro_id=None, arch=None): + """Return a filename for a package with the given information. """ + + if distro_id is None: + distro_id = ctx.config.values.general.distribution_id + + if arch is None: + arch = ctx.config.values.general.architecture + + fn = "-".join((name, version, release, distro_id, arch)) + fn += ctx.const.package_suffix + + return fn + def parse_package_name_legacy(package_name): """Separate package name and version string for package formats <= 1.1.