Skip to content

Commit

Permalink
Merge pull request #35 from thetacom/34-pathowner-is-unsupported-on-t…
Browse files Browse the repository at this point in the history
…his-system

Path.owner() is unsupported on Windows
  • Loading branch information
thetacom authored Mar 20, 2024
2 parents a5f4219 + b6ef6ec commit eb752bd
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -22,26 +22,26 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.8
hooks:
- id: bandit
args: [-r, -ll, -c, pyproject.toml]
additional_dependencies: ['bandit[toml]']

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.3.0
hooks:
- id: black
args: [--safe, --quiet]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: [--profile, black, --filter-files, -l, "120"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
rev: v1.9.0
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
Expand All @@ -55,7 +55,7 @@ repos:
]

- repo: https://github.com/python-poetry/poetry
rev: 1.7.1
rev: 1.8.2
hooks:
- id: poetry-check
- id: poetry-lock
Expand Down Expand Up @@ -85,7 +85,7 @@ repos:
types: [file]

- repo: https://github.com/pylint-dev/pylint
rev: v2.17.1
rev: v3.1.0
hooks:
- id: pylint

Expand All @@ -96,19 +96,19 @@ repos:
args: [-d, --min=9, .]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py39-plus]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.260
rev: v0.3.3
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/rstcheck/rstcheck
rev: v6.1.2
rev: v6.2.0
hooks:
- id: rstcheck
args: [--report-level=warning, --ignore-directives, automodule]
Expand Down
10 changes: 7 additions & 3 deletions hexabyte/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Haxabyte Package Main."""

import argparse
from importlib.metadata import version
from pathlib import Path
Expand Down Expand Up @@ -37,9 +38,12 @@ def main():
raise ValueError("Must specify at least one filename")
if len(args.files) > MAX_FILE_COUNT:
raise ValueError("Must not specify more than two filenames")
expanded_files = []
for filename in args.files:
if not filename.exists():
raise FileNotFoundError(f"File not found: {filename}")
expanded_filename = filename.expanduser()
if not expanded_filename.exists():
raise FileNotFoundError(f"File not found: {expanded_filename}")
expanded_files.append(expanded_filename)
context.config = Config.from_file(args.config)
load_plugins()
if len(args.files) > 1:
Expand All @@ -49,7 +53,7 @@ def main():
else:
file_mode = FileMode.NORMAL
context.file_mode = file_mode
context.files = args.files
context.files = expanded_files
app = HexabyteApp()
app.run()
context.config.save()
Expand Down
19 changes: 11 additions & 8 deletions hexabyte/widgets/info_panel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Sidebar Info Panel."""

import stat
from hashlib import md5, sha1
from pathlib import Path
from sys import platform

from textual.app import ComposeResult
from textual.containers import Horizontal
Expand Down Expand Up @@ -54,8 +56,9 @@ def compose(self) -> ComposeResult:
yield InfoItem(name="filename")
yield InfoItem(name="path")
yield InfoItem(name="size")
yield InfoItem(name="owner")
yield InfoItem(name="group")
if platform != "win32":
yield InfoItem(name="owner")
yield InfoItem(name="group")
yield InfoItem(name="permissions")
yield InfoItem(name="md5")
yield InfoItem(name="sha1")
Expand Down Expand Up @@ -87,14 +90,14 @@ def update_stats(self) -> None:
else:
kb_size = file_size // KB
size_value.update(f"{kb_size:,} KB ({file_size:,} bytes)")
owner_value = self.query_one("#owner-value", Static)
owner_value.update(filepath.owner())

group_value = self.query_one("#group-value", Static)
group_value.update(filepath.group())

perm_value = self.query_one("#permissions-value", Static)
perm_value.update(stat.filemode(stats.st_mode))
if platform != "win32":
owner_value = self.query_one("#owner-value", Static)
owner_value.update(filepath.owner())

group_value = self.query_one("#group-value", Static)
group_value.update(filepath.group())

def watch_editor(self) -> None:
"""React to changed editor."""
Expand Down
29 changes: 14 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hexabyte"
version = "0.8.6"
version = "0.8.7"
description = "A modern, modular, and robust TUI hex editor."
keywords = ["commandline", "hexeditor", "binary", "hexadecimal", "raw", "byteview", "bytes"]
repository = "https://github.com/thetacom/hexabyte"
Expand All @@ -17,6 +17,7 @@ classifiers = [
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
Expand All @@ -32,12 +33,11 @@ packages = [{ include = 'hexabyte' }]

[tool.poetry.dependencies]
python = "^3.9"
textual = "^0.44.1"
textual = "^0.53.1"
toml = "^0.10.2"
munch = "^4.0.0"
hilbertcurve = "^2.0.5"


[tool.poetry.group.dev.dependencies]
black = "^23.9.1"
bandit = "^1.7.5"
Expand Down
12 changes: 3 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
hilbertcurve==2.0.5 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:6a7703d9a2f1fe748c86d86908bf183e7d139b973645e4b2526e10b34e75796d \
--hash=sha256:dbaad510237d3cd4355c189f00e8dbe66a9e66e03af37f9d3f257799292da363
importlib-metadata==7.0.2 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:198f568f3230878cb1b44fbd7975f87906c22336dba2e4a7f05278c281fbd792 \
--hash=sha256:f4bc4c0c070c490abf4ce96d715f68e95923320370efb66143df00199bb6c100
linkify-it-py==2.0.3 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:68cda27e162e9215c17d786649d1da0021a451bdc436ef9e0fa0ba5234b9b048 \
--hash=sha256:6bcbc417b0ac14323382aef5c5192c0075bf8a9d6b41820a2b66371eac6b6d79
Expand Down Expand Up @@ -65,9 +62,9 @@ pygments==2.17.2 ; python_version >= "3.9" and python_version < "4.0" \
rich==13.7.1 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222 \
--hash=sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432
textual==0.44.1 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:19cfd3a0c623bff02cc80d872ba3e93e1a5b77289fecf74c16ffcfa7407b49a1 \
--hash=sha256:7a45b85943957095b97d0a90c4fa4d3e1028fa26493c0720f403d879157a6589
textual==0.53.1 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:23ba673be7974819ded35ea88d28df7117987e53d58f15b2cc890ac2ecf56401 \
--hash=sha256:32201aa9d334ed064d5e670f15fe3d7f19c736ca54cecb054a5b995691104434
toml==0.10.2 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \
--hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f
Expand All @@ -77,6 +74,3 @@ typing-extensions==4.10.0 ; python_version >= "3.9" and python_version < "4.0" \
uc-micro-py==1.0.3 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:d321b92cff673ec58027c04015fcaa8bb1e005478643ff4a500882eaab88c48a \
--hash=sha256:db1dffff340817673d7b466ec86114a9dc0e9d4d9b5ba229d9d60e5c12600cd5
zipp==3.18.1 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:206f5a15f2af3dbaee80769fb7dc6f249695e940acca08dfb2a4769fe61e538b \
--hash=sha256:2884ed22e7d8961de1c9a05142eb69a247f120291bc0206a00a7642f09b5b715

0 comments on commit eb752bd

Please sign in to comment.