Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for app.paths #1849

Merged
merged 8 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes/1569.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Corrected line length
Changed definition listed for cache and toga properties
Updated formating to use ReST styles
LunaMeadows marked this conversation as resolved.
Show resolved Hide resolved
26 changes: 24 additions & 2 deletions core/src/toga/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# Backwards compatibility - imporlib.metadata was added in Python 3.8
import importlib_metadata


# Make sure deprecation warnings are shown by default
warnings.filterwarnings("default", category=DeprecationWarning)

Expand Down Expand Up @@ -321,7 +320,7 @@ def __init__(

# Get a platform factory, and a paths instance from the factory.
self.factory = get_platform_factory()
self.paths = self.factory.paths
self._paths = self.factory.paths

# If an icon (or icon name) has been explicitly provided, use it;
# otherwise, the icon will be based on the app name.
Expand Down Expand Up @@ -349,6 +348,29 @@ def __init__(
def _create_impl(self):
return self.factory.App(interface=self)

@property
def paths(self):
"""
Paths for known safe system locations. Using paths makes sure you have a consistent and known location to store
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length is still an issue - it should be wrapped at ~80 chars.

There's also no mention of Pathlib as a return type, as previously requested.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I instead suggest that we wrap at 88 columns, the same as Black? That makes it much easier to set one line length in your editor and use it everywhere.

files for your app. Also, some platforms do not allow arbitrary file access to any location on disk.
On Android, there are many limitations when it comes to accessing file locations and the apis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an Android-specific thing. iOS has the same set of constraints - and technically, so do macOS and Windows when you use packaged/sandboxed apps.

Also - it's not just that they're known locations - it's that they're platform appropriate locations.

you can use to read from those locations.

:PROPERTIES:
* **app** – Location of where the apps code is run.

* **data** – System appropriate location to store user data.

* **cache** – File location for temporary files that may be removed by the system or user and
can be obtained again by the program.

* **logs** – Location of toga log files.

* **toga** – Location of the Toga core module.

"""
return self._paths

@property
def name(self):
"""The formal name of the app.
Expand Down