Skip to content

Commit

Permalink
continuing to evolve the Bastion.Packers.TARs archive module; mostly …
Browse files Browse the repository at this point in the history
…in the structured reporting on results.
  • Loading branch information
ndenny committed Nov 25, 2024
1 parent 2c63a62 commit bc22106
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/Bastion/Packers/TARs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from Bastion.Common import *
from Bastion.CARP import ReportException
from Bastion.Chronology import

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -192,4 +193,17 @@ def unpack(self, halo, root, **kwargs):
raise NotImplementedError



def catalog(tarp):
"""
I answer the catalog of a tar file at the given path, tarp.
The catalog is a list of entries of the form (size, modified, path)
where size is in bytes, modified is the quantim of the file's mod timestamp, and path is a pathlib.Path object
"""
cats = [ ]
with tarfile.open(tarp) as tark:
for info in tark.getmembers():
sz = info.size
mq = quantim( datetime.datetime.fromtimestamp(info.mtime) )
pt = pathlib.PurePosixPath(info.name)
cats.append( (sz, mq, pt) )
return cats

0 comments on commit bc22106

Please sign in to comment.