Skip to content

Commit

Permalink
core.common: use kompress directly instead of attempting to import ve…
Browse files Browse the repository at this point in the history
…ndorised version

this avoids unnecessary warning when guess_compression=True is used

follow up for cf8b031
  • Loading branch information
karlicoss committed Feb 5, 2025
1 parent acb4f6b commit 9e9cbff
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/my/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,22 @@ def caller() -> str:

if len(paths) == 0:
# todo make it conditionally defensive based on some global settings
warnings.high(f'''
warnings.high(
f'''
{caller()}: no paths were matched against {pp}. This might result in missing data. Likely, the directory you passed is empty.
'''.strip())
'''.strip()
)
# traceback is useful to figure out what config caused it?
import traceback

traceback.print_stack()

if guess_compression:
from .kompress import CPath, ZipPath, is_compressed

# NOTE: wrap is just for backwards compat with vendorized kompress
# with kompress library, only is_compressed check and Cpath should be enough
def wrap(p: Path) -> Path:
if isinstance(p, ZipPath):
return p
if p.suffix == '.zip':
return ZipPath(p) # type: ignore[return-value]
if is_compressed(p):
return CPath(p)
return p

paths = [wrap(p) for p in paths]

from kompress import CPath

# note: CPath will leave path unchanged if it's not compressed
paths = [CPath(p) for p in paths]
return tuple(paths)


Expand Down

0 comments on commit 9e9cbff

Please sign in to comment.