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

mosquito / debx / 14825141426

04 May 2025 09:01PM UTC coverage: 80.116% (-0.2%) from 80.349%
14825141426

push

github

mosquito
Keep archives option

0 of 4 new or added lines in 2 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

552 of 689 relevant lines covered (80.12%)

12.01 hits per line

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

24.32
/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

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

NEW
48
        if not args.keep_archives:
×
NEW
49
            log.info("Removing packed %s", file.name)
×
NEW
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