Skip to content

Commit c30e249

Browse files
committed
improve printing, stabilize at 1.0
Signed-off-by: Zen <[email protected]>
1 parent c7a3900 commit c30e249

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pycpio"
7-
version = "0.9.2"
7+
version = "1.0.0"
88
authors = [
99
{ name="Desultory", email="[email protected]" },
1010
]
@@ -16,7 +16,7 @@ classifiers = [
1616
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
1717
"Operating System :: OS Independent",
1818
]
19-
dependencies = ["zenlib >= 1.7.3"]
19+
dependencies = ["zenlib >= 2.0.0"]
2020

2121
[project.scripts]
2222
pycpio = "pycpio.main:main"

src/pycpio/cpio/data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ def __init__(self, data: bytes, header, *args, **kwargs):
184184
self.data = data if data is not None else b''
185185

186186
def __str__(self):
187-
return f"\n{self.header}\nSHA256: {self.hash}\n{self.__class__.__name__}"
187+
out_str = f"{self.__class__.__name__} {self.header}"
188+
out_str += f"\nSHA256: {self.hash} " if self.hash else " "
189+
return out_str
188190

189191
def __bytes__(self):
190192
""" Convert the data to bytes """

src/pycpio/header/cpioheader.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,25 @@ def __str__(self):
176176
out_str += "Header:\n" if not hasattr(self, 'name') else f"{self.name}:\n"
177177

178178
for attr in self.structure:
179-
if attr in ['ino', 'mode', 'devmajor', 'devminor',
179+
if attr in ['ino', 'mode', 'devmajor', 'devminor', 'uid', 'gid',
180180
'rdevmajor', 'rdevminor', 'namesize', 'filesize', 'check']:
181181
continue
182182
elif attr == 'nlink':
183183
if int(self.nlink, 16) > 1:
184184
out_str += f" {attr}: {int(self.nlink, 16)}\n"
185185
elif attr == 'magic':
186-
out_str += f" {attr}: {self.magic}\n"
186+
if self.logger.level < 20:
187+
out_str += f" {attr}: {self.magic}\n"
188+
else:
189+
continue
187190
elif attr == 'mtime':
188-
out_str += f" {attr}: {datetime.fromtimestamp(int(self.mtime, 16))}\n"
191+
if self.logger.level < 20:
192+
out_str += f" {attr}: {datetime.fromtimestamp(int(self.mtime, 16))}\n"
193+
else:
194+
continue
189195
else:
190-
out_str += f" {attr}: {int(getattr(self, attr), 16)}\n"
196+
out_str += f" {attr}: {int(getattr(self, attr), 16)}"
191197

192-
out_str += f" Permissions: {print_permissions(self.permissions)}\n"
198+
out_str += f" Permissions: {print_permissions(self.permissions)} {int(self.uid)} {int(self.gid)}"
193199
return out_str
194200

src/pycpio/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def main():
2525
{'flags': ['-l', '--list'], 'action': 'store_true', 'help': 'list CPIO contents'},
2626
{'flags': ['-p', '--print'], 'action': 'store_true', 'help': 'print CPIO contents'}]
2727

28-
args, logger = get_args_n_logger(package=__package__, description='PyCPIO', arguments=arguments)
28+
args, logger = get_args_n_logger(package=__package__, description='PyCPIO', arguments=arguments, drop_default=True)
2929
kwargs = get_kwargs_from_args(args, logger=logger)
3030

3131
c = PyCPIO(**kwargs)

src/pycpio/masks/permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def print_permissions(passed_perms: set, extended=False) -> str:
5353
out += "-"
5454

5555
if permission.name[0].lower() == 'x':
56-
out += " "
56+
out += "-"
5757

5858
return out.rstrip()
5959

0 commit comments

Comments
 (0)