API: rename {open_file, open_clan_folder} into {get_system_file, get_clan_folder}
This commit is contained in:
@@ -103,16 +103,16 @@ class MethodRegistry:
|
||||
---
|
||||
# Example
|
||||
|
||||
The function 'open_file()' depends on the platform.
|
||||
The function 'get_system_file()' depends on the platform.
|
||||
|
||||
def open_file(file_request: FileRequest) -> str | None:
|
||||
def get_system_file(file_request: FileRequest) -> str | None:
|
||||
# In GTK we open a file dialog window
|
||||
# In Android we open a file picker dialog
|
||||
# and so on.
|
||||
pass
|
||||
|
||||
# At runtime the clan-app must override platform specific functions
|
||||
API.register(open_file)
|
||||
API.register(get_system_file)
|
||||
---
|
||||
"""
|
||||
raise NotImplementedError(msg)
|
||||
|
||||
@@ -20,7 +20,7 @@ class FileFilter:
|
||||
@dataclass
|
||||
class FileRequest:
|
||||
# Mode of the os dialog window
|
||||
mode: Literal["open_file", "select_folder", "save", "open_multiple_files"]
|
||||
mode: Literal["get_system_file", "select_folder", "save", "open_multiple_files"]
|
||||
# Title of the os dialog window
|
||||
title: str | None = field(default=None)
|
||||
# Pre-applied filters for the file dialog
|
||||
@@ -30,25 +30,25 @@ class FileRequest:
|
||||
|
||||
|
||||
@API.register_abstract
|
||||
def open_file(file_request: FileRequest) -> list[str] | None:
|
||||
def get_system_file(file_request: FileRequest) -> list[str] | None:
|
||||
"""
|
||||
Api method to open a file dialog window.
|
||||
|
||||
Implementations is specific to the platform and
|
||||
returns the name of the selected file or None if no file was selected.
|
||||
"""
|
||||
msg = "open_file() is not implemented"
|
||||
msg = "get_system_file() is not implemented"
|
||||
raise NotImplementedError(msg)
|
||||
|
||||
|
||||
@API.register_abstract
|
||||
def open_clan_folder() -> Flake:
|
||||
def get_clan_folder() -> Flake:
|
||||
"""
|
||||
Api method to open the clan folder.
|
||||
|
||||
Implementations is specific to the platform and returns the path to the clan folder.
|
||||
"""
|
||||
msg = "open_clan_folder() is not implemented"
|
||||
msg = "get_clan_folder() is not implemented"
|
||||
raise NotImplementedError(msg)
|
||||
|
||||
|
||||
|
||||
@@ -324,10 +324,10 @@ def test_private_public_fields() -> None:
|
||||
def test_literal_field() -> None:
|
||||
@dataclass
|
||||
class Person:
|
||||
name: Literal["open_file", "select_folder", "save"]
|
||||
name: Literal["get_system_file", "select_folder", "save"]
|
||||
|
||||
data = {"name": "open_file"}
|
||||
expected = Person(name="open_file")
|
||||
data = {"name": "get_system_file"}
|
||||
expected = Person(name="get_system_file")
|
||||
assert from_dict(Person, data) == expected
|
||||
|
||||
assert dataclass_to_dict(expected) == data
|
||||
|
||||
Reference in New Issue
Block a user