Implemented #689
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.49.0"
|
||||
__version__ = "0.49.1"
|
||||
|
||||
@@ -258,6 +258,20 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
|
||||
ISC_LICENSE = """
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
"""
|
||||
|
||||
LICENSE = dedent(
|
||||
f"""
|
||||
osxphotos is copyright (c) 2019-2022 by Rhet Turnbull and is licensed under the MIT license:
|
||||
@@ -273,6 +287,12 @@ osxphotos uses the following 3rd party software licensed under the Apache 2.0 Li
|
||||
tenacity (Copyright Julien Danjou)
|
||||
|
||||
{APACHE_2_0_LICENSE}
|
||||
|
||||
osxphotos uses the following 3rd part software licensed under the ISC License:
|
||||
|
||||
xdg (Copyright 2016-2021 Scott Stevenson <scott@stevenson.io>)
|
||||
|
||||
{ISC_LICENSE}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from datetime import datetime
|
||||
|
||||
import click
|
||||
from packaging import version
|
||||
from xdg import xdg_config_home, xdg_data_home
|
||||
|
||||
import osxphotos
|
||||
from osxphotos._constants import APP_NAME
|
||||
@@ -582,12 +583,20 @@ def load_uuid_from_file(filename):
|
||||
|
||||
def get_config_dir() -> pathlib.Path:
|
||||
"""Get the directory where config files are stored; create it if necessary."""
|
||||
config_dir = pathlib.Path.home() / ".config" / APP_NAME
|
||||
config_dir = xdg_config_home() / APP_NAME
|
||||
if not config_dir.is_dir():
|
||||
config_dir.mkdir(parents=True)
|
||||
return config_dir
|
||||
|
||||
|
||||
def get_data_dir() -> pathlib.Path:
|
||||
"""Get the director where local user data files are stored; create it if necessary"""
|
||||
data_dir = xdg_data_home() / APP_NAME
|
||||
if not data_dir.is_dir():
|
||||
data_dir.mkdir(parents=True)
|
||||
return data_dir
|
||||
|
||||
|
||||
def check_version():
|
||||
"""Check for updates"""
|
||||
latest_version, _ = get_latest_version()
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
import pathlib
|
||||
import shutil
|
||||
import zipfile
|
||||
from contextlib import suppress
|
||||
from typing import Optional
|
||||
|
||||
import click
|
||||
|
||||
from osxphotos._version import __version__
|
||||
|
||||
from .common import get_config_dir
|
||||
from .common import get_config_dir, get_data_dir
|
||||
|
||||
|
||||
@click.command()
|
||||
@@ -18,7 +19,14 @@ from .common import get_config_dir
|
||||
def docs(ctx, cli_obj):
|
||||
"""Open osxphotos documentation in your browser."""
|
||||
|
||||
docs_dir = get_config_dir() / "docs"
|
||||
# first check if docs installed in old location in confir dir and if so, delete them
|
||||
old_docs_dir = get_config_dir() / "docs"
|
||||
if old_docs_dir.exists():
|
||||
with suppress(Exception):
|
||||
shutil.rmtree(str(old_docs_dir))
|
||||
|
||||
# now check if docs installed in correct location in data dir and if not, copy them
|
||||
docs_dir = get_data_dir() / "docs"
|
||||
docs_version = get_docs_version(docs_dir)
|
||||
if not docs_version or docs_version != __version__:
|
||||
click.echo(f"Copying docs for osxphotos version {__version__}")
|
||||
@@ -50,10 +58,10 @@ def copy_docs():
|
||||
# docs are in osxphotos/docs and this file is in osxphotos/cli
|
||||
src_dir = pathlib.Path(__file__).parent.parent / "docs"
|
||||
docs_zip = src_dir / "docs.zip"
|
||||
config_dir = get_config_dir()
|
||||
data_dir = get_data_dir()
|
||||
with zipfile.ZipFile(str(docs_zip), "r") as zf:
|
||||
zf.extractall(path=str(config_dir))
|
||||
set_docs_version(config_dir / "docs", __version__)
|
||||
zf.extractall(path=str(data_dir))
|
||||
set_docs_version(data_dir / "docs", __version__)
|
||||
|
||||
|
||||
def set_docs_version(docs_dir: pathlib.Path, version: str):
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user