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

mosquito / debx / 14820932445

04 May 2025 11:52AM UTC coverage: 82.039%. First build
14820932445

push

github

mosquito
fix windows tests

15 of 18 new or added lines in 2 files covered. (83.33%)

507 of 618 relevant lines covered (82.04%)

12.3 hits per line

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

25.0
/debx/cli/unpack.py
1
import logging
15✔
2
import sys
15✔
3
import tarfile
15✔
4
from argparse import Namespace
15✔
5
from pathlib import Path
15✔
6

7
from ..ar import unpack_ar_archive
15✔
8
from .types import TAR_EXTENSIONS
15✔
9

10

11
log = logging.getLogger(__name__)
15✔
12

13

14
def cli_unpack(args: Namespace) -> int:
15✔
15
    if args.directory is None:
×
16
        args.directory = args.package[:args.package.rfind(".deb")]
×
17

18
    unpack_to = Path(args.directory)
×
19
    unpack_to.mkdir(parents=True, exist_ok=True)
×
20

21
    files = []
×
22

23
    with open(args.package, "rb") as package_fp:
×
24
        for entry in unpack_ar_archive(package_fp):
×
25
            entry_path = unpack_to / entry.name
×
26
            log.info("Unpacking %s", entry_path)
×
27
            with entry_path.open("wb") as entry_fp:
×
28
                entry_fp.write(entry.content)
×
29

30
            files.append(entry_path)
×
31

32
    for file in files:
×
33
        if not any(file.name.endswith(ext) for ext in TAR_EXTENSIONS):
×
34
            continue
×
35

36
        target_dir = unpack_to / file.name[:file.name.find("tar") - 1]
×
37
        log.info("Unpacking %s -> %s", file.name, target_dir)
×
38
        target_dir.mkdir(parents=True, exist_ok=True)
×
39

40
        with tarfile.open(file, "r:*") as tar:
×
41
            def extract_filter(tarinfo: tarfile.TarInfo, _: str) -> tarfile.TarInfo:
×
42
                log.info("Extracting %s/%s", target_dir, tarinfo.name)
×
43
                return tarinfo
×
44

45

NEW
46
            kw = {'filter': extract_filter} if sys.version_info >= (3, 12) else {}
×
NEW
47
            tar.extractall(path=target_dir, **kw)
×
48

49
        log.info("Removing packed %s", file.name)
×
50
        file.unlink()
×
51

52
    return 0
×
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