From 91a92547796f7c34ff5d167c8c382a8bc1556521 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Bartoszkiewicz?= Date: Thu, 7 Feb 2013 02:49:03 +0100 Subject: [PATCH] =?utf8?q?Tworzenie=20symlink=C3=B3w=20z=20rozszerzeniem.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- man-symlinker | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/man-symlinker b/man-symlinker index cdca274..d2d8e2f 100755 --- a/man-symlinker +++ b/man-symlinker @@ -11,7 +11,13 @@ MAN_NAME_RE = re.compile(r'/man/(?:[^/]+/)?man([^/]+)/[^/]+.\1$') MAX_LEN = 1024 SO_RE = re.compile(r'^\.so\s+(.*)$') -def process_file(name): +SUFFIXES = { + 'xz': '.xz', + 'bzip2': '.bz2', + 'gzip': '.gz', +} + +def process_file(name, suffix): full_name = os.path.abspath(name) m = MAN_NAME_RE.search(full_name) if not m: @@ -36,7 +42,7 @@ def process_file(name): elif '/' in link: link = '../' + link os.unlink(name) - os.symlink(link, name) + os.symlink(link + suffix, name + suffix) print 'Converted {} into a symlink to {}'.format(full_name, link) return True @@ -49,9 +55,13 @@ def main(args=[]): else: compressor = args[:dashes] all_files = args[dashes+1:] + if compressor: + suffix = SUFFIXES.get(compressor[0], '') + else: + suffix = '' files = [] for name in all_files: - if not process_file(name): + if not process_file(name, suffix): files.append(name) if not compressor or not files: return 0 -- 2.43.2