Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 412ac18

Browse files
committed
✨ Python 3.12
1 parent 70662c1 commit 412ac18

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

browsr/widgets/files.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,18 @@ def render(self) -> RenderableType:
5959
if self.file_info is None or not self.file_info.is_file:
6060
return Text("")
6161
status_string = "🗄️️️ " + self._convert_size(self.file_info.size)
62-
if self.file_info.last_modified is not None:
62+
if (
63+
self.file_info.last_modified is not None
64+
and self.file_info.last_modified.timestamp() != 0
65+
):
6366
modify_time = self.file_info.last_modified.strftime("%b %d, %Y %I:%M %p")
6467
status_string += " 📅 " + modify_time
65-
status_string += (
66-
" 💾 "
67-
+ self.file_info.file.name
68-
+ " 📂 "
69-
+ self.file_info.file.parent.name
70-
)
68+
parent_name = self.file_info.file.parent.name
69+
if not parent_name:
70+
parent_name = str(self.file_info.file.parent)
71+
parent_name = parent_name.lstrip(f"{self.file_info.file.protocol}://")
72+
parent_name = parent_name.rstrip("/")
73+
status_string += " 💾 " + self.file_info.file.name + " 📂 " + parent_name
7174
if self.file_info.owner not in ["", None]:
7275
status_string += " 👤 " + self.file_info.owner
7376
if self.file_info.group.strip() not in ["", None]:

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pyperclip
99
import pytest
1010
from click.testing import CliRunner
11-
from textual_universal_directorytree import GitHubPath
11+
from textual_universal_directorytree import GitHubTextualPath
1212

1313

1414
@pytest.fixture
@@ -36,13 +36,13 @@ def screenshot_dir(repo_dir: pathlib.Path) -> pathlib.Path:
3636

3737

3838
@pytest.fixture
39-
def github_release_path() -> GitHubPath:
39+
def github_release_path() -> GitHubTextualPath:
4040
"""
4141
Return the path to the Github Release
4242
"""
4343
release = "v1.6.0"
4444
uri = f"github://juftin:browsr@{release}"
45-
return GitHubPath(uri)
45+
return GitHubTextualPath(uri)
4646

4747

4848
@pytest.fixture(autouse=True)

tests/debug_app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ async def test_debug_app() -> None:
1313
"""
1414
Test the actual browsr app
1515
"""
16-
config = TextualAppContext(file_path="s3://", debug=True)
16+
config = TextualAppContext(
17+
file_path="github://juftin:textual-universal-directorytree@main", debug=True
18+
)
1719
app = Browsr(config_object=config)
1820
async with app.run_test() as pilot:
1921
_ = pilot.app

tests/test_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pathlib
55
from dataclasses import is_dataclass
66

7-
from textual_universal_directorytree import GitHubPath
7+
from textual_universal_directorytree import GitHubTextualPath
88

99
from browsr.base import TextualAppContext
1010
from browsr.config import favorite_themes
@@ -54,5 +54,5 @@ def test_textual_app_context_path_github() -> None:
5454
context = TextualAppContext(file_path=_github_string)
5555
handled_github_url = context.path
5656
expected_file_path = "github://juftin:browsr@main/"
57-
assert handled_github_url == GitHubPath(expected_file_path)
57+
assert handled_github_url == GitHubTextualPath(expected_file_path)
5858
assert str(handled_github_url) == expected_file_path

tests/test_screenshots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Callable, Tuple
88

99
import pytest
10-
from textual_universal_directorytree import GitHubPath
10+
from textual_universal_directorytree import GitHubTextualPath
1111

1212
from tests.conftest import cassette
1313

@@ -35,7 +35,7 @@ def test_github_screenshot(
3535
snap_compare: Callable[..., bool],
3636
tmp_path: pathlib.Path,
3737
app_file: str,
38-
github_release_path: GitHubPath,
38+
github_release_path: GitHubTextualPath,
3939
terminal_size: Tuple[int, int],
4040
) -> None:
4141
"""
@@ -51,7 +51,7 @@ def test_github_screenshot_license(
5151
snap_compare: Callable[..., bool],
5252
tmp_path: pathlib.Path,
5353
app_file: str,
54-
github_release_path: GitHubPath,
54+
github_release_path: GitHubTextualPath,
5555
terminal_size: Tuple[int, int],
5656
) -> None:
5757
"""
@@ -69,7 +69,7 @@ def test_mkdocs_screenshot(
6969
tmp_path: pathlib.Path,
7070
app_file: str,
7171
terminal_size: Tuple[int, int],
72-
github_release_path: GitHubPath,
72+
github_release_path: GitHubTextualPath,
7373
) -> None:
7474
"""
7575
Snapshot the pyproject.toml file

0 commit comments

Comments
 (0)