[sysadmin-bin] ftpadmin: reuse functionality
- From: Olav Vitters <ovitters src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] ftpadmin: reuse functionality
- Date: Fri, 11 Mar 2011 09:38:58 +0000 (UTC)
commit a136c23499ac222784813271b79573dd6ad6bf0f
Author: Olav Vitters <olav vitters nl>
Date: Fri Mar 11 10:38:38 2011 +0100
ftpadmin: reuse functionality
ftpadmin | 25 ++++++++++---------------
1 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/ftpadmin b/ftpadmin
index 6c58a41..bf701d9 100755
--- a/ftpadmin
+++ b/ftpadmin
@@ -303,7 +303,6 @@ class TarInfo(BasicInfo):
return errors
-
class ModuleInfo(BasicInfo):
JSONVERSION = 2
@@ -403,17 +402,17 @@ class ModuleInfo(BasicInfo):
# save the new information
self.write_json()
- def determine_file(self, version, format):
+ def determine_file(self, version, format, fuzzy=True):
"""Determine file using version and format
- Might return a compressed version of the given format.
-
- Returns None if format cannot be found"""
+ If fuzzy is set, possibly return a compressed version of the given
+ format."""
if version not in self.info:
return None
formats = [format]
- formats.extend(("%s.%s" % (format, compression) for compression in ("gz", "bz2", "xz")))
+ if fuzzy and not "." in format:
+ formats.extend(("%s.%s" % (format, compression) for compression in ("gz", "bz2", "xz")))
info_formats = self.info[version]
for f in formats:
@@ -422,23 +421,19 @@ class ModuleInfo(BasicInfo):
return None
- def info_detailed(self, version, format):
+ def info_detailed(self, version, format, fuzzy=False):
"""Provides detailed information about file references by
version and format.
- Will NOT return a posibly compressed version."""
- if version not in self.info:
- return None
-
- info = self.info[version].get(format, None)
- if info is None:
+ If fuzzy is set, possibly return a compressed version of the given
+ format."""
+ realpath = self.determine_file(version, format, fuzzy)
+ if realpath is None:
return None
- realpath = os.path.join(self.FTPROOT, info)
stat = os.stat(realpath)
return (info, realpath, human_size(stat.st_size), stat)
-
def write_json(self):
if self.module is None: return False
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]