Skip to content

Commit

Permalink
✨ Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Mar 14, 2024
1 parent 70662c1 commit 412ac18
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
17 changes: 10 additions & 7 deletions browsr/widgets/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ def render(self) -> RenderableType:
if self.file_info is None or not self.file_info.is_file:
return Text("")
status_string = "🗄️️️ " + self._convert_size(self.file_info.size)
if self.file_info.last_modified is not None:
if (
self.file_info.last_modified is not None
and self.file_info.last_modified.timestamp() != 0
):
modify_time = self.file_info.last_modified.strftime("%b %d, %Y %I:%M %p")
status_string += " 📅 " + modify_time
status_string += (
" 💾 "
+ self.file_info.file.name
+ " 📂 "
+ self.file_info.file.parent.name
)
parent_name = self.file_info.file.parent.name
if not parent_name:
parent_name = str(self.file_info.file.parent)
parent_name = parent_name.lstrip(f"{self.file_info.file.protocol}://")
parent_name = parent_name.rstrip("/")
status_string += " 💾 " + self.file_info.file.name + " 📂 " + parent_name
if self.file_info.owner not in ["", None]:
status_string += " 👤 " + self.file_info.owner
if self.file_info.group.strip() not in ["", None]:
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pyperclip
import pytest
from click.testing import CliRunner
from textual_universal_directorytree import GitHubPath
from textual_universal_directorytree import GitHubTextualPath


@pytest.fixture
Expand Down Expand Up @@ -36,13 +36,13 @@ def screenshot_dir(repo_dir: pathlib.Path) -> pathlib.Path:


@pytest.fixture
def github_release_path() -> GitHubPath:
def github_release_path() -> GitHubTextualPath:
"""
Return the path to the Github Release
"""
release = "v1.6.0"
uri = f"github://juftin:browsr@{release}"
return GitHubPath(uri)
return GitHubTextualPath(uri)


@pytest.fixture(autouse=True)
Expand Down
4 changes: 3 additions & 1 deletion tests/debug_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ async def test_debug_app() -> None:
"""
Test the actual browsr app
"""
config = TextualAppContext(file_path="s3://", debug=True)
config = TextualAppContext(
file_path="github://juftin:textual-universal-directorytree@main", debug=True
)
app = Browsr(config_object=config)
async with app.run_test() as pilot:
_ = pilot.app
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pathlib
from dataclasses import is_dataclass

from textual_universal_directorytree import GitHubPath
from textual_universal_directorytree import GitHubTextualPath

from browsr.base import TextualAppContext
from browsr.config import favorite_themes
Expand Down Expand Up @@ -54,5 +54,5 @@ def test_textual_app_context_path_github() -> None:
context = TextualAppContext(file_path=_github_string)
handled_github_url = context.path
expected_file_path = "github://juftin:browsr@main/"
assert handled_github_url == GitHubPath(expected_file_path)
assert handled_github_url == GitHubTextualPath(expected_file_path)
assert str(handled_github_url) == expected_file_path
8 changes: 4 additions & 4 deletions tests/test_screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Callable, Tuple

import pytest
from textual_universal_directorytree import GitHubPath
from textual_universal_directorytree import GitHubTextualPath

from tests.conftest import cassette

Expand Down Expand Up @@ -35,7 +35,7 @@ def test_github_screenshot(
snap_compare: Callable[..., bool],
tmp_path: pathlib.Path,
app_file: str,
github_release_path: GitHubPath,
github_release_path: GitHubTextualPath,
terminal_size: Tuple[int, int],
) -> None:
"""
Expand All @@ -51,7 +51,7 @@ def test_github_screenshot_license(
snap_compare: Callable[..., bool],
tmp_path: pathlib.Path,
app_file: str,
github_release_path: GitHubPath,
github_release_path: GitHubTextualPath,
terminal_size: Tuple[int, int],
) -> None:
"""
Expand All @@ -69,7 +69,7 @@ def test_mkdocs_screenshot(
tmp_path: pathlib.Path,
app_file: str,
terminal_size: Tuple[int, int],
github_release_path: GitHubPath,
github_release_path: GitHubTextualPath,
) -> None:
"""
Snapshot the pyproject.toml file
Expand Down

0 comments on commit 412ac18

Please sign in to comment.