rpmfile icon indicating copy to clipboard operation
rpmfile copied to clipboard

Add `is_rpmfile` function

Open LeStahL opened this issue 1 year ago • 1 comments

The module currently has no function is_rpmfile() -> bool (similiar to https://docs.python.org/3/library/tarfile.html#tarfile.is_tarfile).

It could check the magic bytes from the file lead and return accordingly.

LeStahL avatar Dec 07 '23 14:12 LeStahL

@LeStahL what if you could use this?

rpm = None
is_rpmfile = False
try:
    rpm = rpmfile.open(...)
    is_rpmfile = isinstance(rpm, rpmfile.RPMFile)
except rpmfile.errors.RPMError:
    pass

Then at least you have your check without code changes.

grepwood avatar Jul 28 '25 18:07 grepwood