From 3b0ebe9af7ca9e94b208fc7d79a19e081dd509d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Sat, 19 Mar 2011 14:27:26 +0100 Subject: [PATCH] gbp: Don't fail on paths without extensions in get_compression() and add doctests for that. Closes: #618893 --- gbp/deb.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gbp/deb.py b/gbp/deb.py index 1a53563c..4d650676 100644 --- a/gbp/deb.py +++ b/gbp/deb.py @@ -256,8 +256,19 @@ def is_valid_upstreamversion(version): return upstreamversion_re.match(version) def get_compression(orig_file): - "Given an orig file return the compression used" - ext = orig_file.rsplit('.',1)[1] + """ + Given an orig file return the compression used + >>> get_compression("abc.tar.gz") + 'gzip' + >>> get_compression("abc.tar.bz2") + 'bzip2' + >>> get_compression("abc.tar.foo") + >>> get_compression("abc") + """ + try: + ext = orig_file.rsplit('.',1)[1] + except IndexError: + return None for (c, o) in compressor_opts.iteritems(): if o[1] == ext: return c -- 2.34.1