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

mosquito / debx / 14815206409

03 May 2025 10:36PM UTC coverage: 81.538% (-6.9%) from 88.441%
14815206409

push

github

mosquito
Add inspect command

228 of 307 new or added lines in 5 files covered. (74.27%)

14 existing lines in 1 file now uncovered.

477 of 585 relevant lines covered (81.54%)

4.08 hits per line

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

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

6
from ..ar import unpack_ar_archive
5✔
7
from .types import TAR_EXTENSIONS
5✔
8

9

10
log = logging.getLogger(__name__)
5✔
11

12

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

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

NEW
20
    files = []
×
21

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

NEW
29
            files.append(entry_path)
×
30

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

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

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

NEW
44
            tar.extractall(path=target_dir, filter=extract_filter)
×
45

NEW
46
        log.info("Removing packed %s", file.name)
×
NEW
47
        file.unlink()
×
48

NEW
49
    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