• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

deadc0de6 / catcli / 4399176145

pending completion
4399176145

Pull #30

github

GitHub
Merge ee2cf80d9 into 7590ad02c
Pull Request #30: Fuse

474 of 474 new or added lines in 13 files covered. (100.0%)

1304 of 1691 relevant lines covered (77.11%)

3.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.15
/catcli/decomp.py
1
"""
2
author: deadc0de6 (https://github.com/deadc0de6)
3
Copyright (c) 2017, deadc0de6
4

5
Catcli generic compressed data lister
6
"""
7

8
import os
5✔
9
import tarfile
5✔
10
import zipfile
5✔
11
from typing import List
5✔
12

13

14
class Decomp:
5✔
15
    """decompressor"""
16

17
    def __init__(self) -> None:
5✔
18
        self.ext = {
×
19
            'tar': self._tar,
20
            'tgz': self._tar,
21
            'gz': self._tar,
22
            'tar.gz': self._tar,
23
            'xz': self._tar,
24
            'tar.xz': self._tar,
25
            'lzma': self._tar,
26
            'tar.lzma': self._tar,
27
            'tlz': self._tar,
28
            'bz2': self._tar,
29
            'tar.bz2': self._tar,
30
            'zip': self._zip}
31

32
    def get_formats(self) -> List[str]:
5✔
33
        """return list of supported extensions"""
34
        return list(self.ext.keys())
×
35

36
    def get_names(self, path: str) -> List[str]:
5✔
37
        """get tree of compressed archive"""
38
        ext = os.path.splitext(path)[1][1:].lower()
×
39
        if ext in list(self.ext):
×
40
            return self.ext[ext](path)
×
41
        return []
×
42

43
    @staticmethod
5✔
44
    def _tar(path: str) -> List[str]:
5✔
45
        """return list of file names in tar"""
46
        if not tarfile.is_tarfile(path):
×
47
            return []
×
48
        with tarfile.open(path, "r") as tar:
×
49
            return tar.getnames()
×
50

51
    @staticmethod
5✔
52
    def _zip(path: str) -> List[str]:
5✔
53
        """return list of file names in zip"""
54
        if not zipfile.is_zipfile(path):
×
55
            return []
×
56
        with zipfile.ZipFile(path) as file:
×
57
            return file.namelist()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc