aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-03-19 14:27:26 +0100
committerGuido Günther <agx@sigxcpu.org>2011-03-19 14:30:01 +0100
commit3b0ebe9af7ca9e94b208fc7d79a19e081dd509d0 (patch)
tree14e1af1ab79e0143f1adbbe5751ce6a5be45ea30 /gbp
parent97c32c7a3931cbc916a0f1fd9d63b801c6595ee8 (diff)
gbp: Don't fail on paths without extensions in get_compression()
and add doctests for that. Closes: #618893
Diffstat (limited to 'gbp')
-rw-r--r--gbp/deb.py15
1 files 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