diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-03-19 14:27:26 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-03-19 14:30:01 +0100 |
commit | 3b0ebe9af7ca9e94b208fc7d79a19e081dd509d0 (patch) | |
tree | 14e1af1ab79e0143f1adbbe5751ce6a5be45ea30 /gbp | |
parent | 97c32c7a3931cbc916a0f1fd9d63b801c6595ee8 (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.py | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -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 |