Esempio n. 1
0
def create_db():
    """
    Create the database and return the connection
    """
    db_file = Path(user_data_dir(app_name, roaming=True)) / "wondb.sqlite"
    if not db_file.is_file():
        # create parent dirs
        db_file.parent.mkdir(parents=True, exist_ok=True)
        db_file.touch()
    return SqliteDatabase(db_file)
Esempio n. 2
0
from pathlib import Path
from typing import Union

from platformdirs import user_data_dir

DATA_DIR = Path(user_data_dir()) / 'pyinaturalist'
DEFAULT_DB_PATH = DATA_DIR / 'inaturalist-open-data.db'
DEFAULT_DB_URI = f'sqlite:////{DEFAULT_DB_PATH}'

DWCA_DIR = DATA_DIR / 'dwca'
DWCA_URL = 'https://static.inaturalist.org/observations/gbif-observations-dwca.zip'
DWCA_TAXA_URL = 'https://www.inaturalist.org/taxa/inaturalist-taxonomy.dwca.zip'

ODP_ARCHIVE_NAME = 'inaturalist-open-data-latest.tar.gz'
ODP_BUCKET_NAME = 'inaturalist-open-data'
ODP_METADATA_KEY = f'metadata/{ODP_ARCHIVE_NAME}'
PHOTO_BASE_URL = 'https://inaturalist-open-data.s3.amazonaws.com/photos/'

PathOrStr = Union[Path, str]
Esempio n. 3
0
# (C) Datadog, Inc. 2018-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os
from collections import deque
from copy import deepcopy

import toml
from atomicwrites import atomic_write
from platformdirs import user_data_dir

from ..fs import ensure_parent_dir_exists, file_exists, read_file

APP_DIR = user_data_dir('dd-checks-dev', '')
CONFIG_FILE = os.path.join(APP_DIR, 'config.toml')

SECRET_KEYS = {
    'dd_api_key',
    'dd_app_key',
    'orgs.*.api_key',
    'orgs.*.app_key',
    'github.token',
    'pypi.pass',
    'trello.key',
    'trello.token',
}

DEFAULT_CONFIG = {
    'repo':
    'core',
    'agent':
Esempio n. 4
0
def _default_app_data_dir(env):
    key = "VIRTUALENV_OVERRIDE_APP_DATA"
    if key in env:
        return env[key]
    else:
        return user_data_dir(appname="virtualenv", appauthor="pypa")
Esempio n. 5
0
import contextlib
import os
from typing import Iterator, Optional

from platformdirs import user_data_dir
from tinydb import TinyDB, Query, where
from tinydb.table import Table
from tinyrecord import transaction

DB_FILE = os.path.join(user_data_dir('pypinfo', appauthor=False), 'db.json')


@contextlib.contextmanager
def get_credentials_table(table: Optional[Table] = None) -> Iterator[Table]:
    if table is None:
        with TinyDB(DB_FILE, create_dirs=True) as db:
            yield db.table('credentials')
    else:
        yield table


def get_credentials(table: Optional[Table] = None) -> Optional[str]:
    with get_credentials_table(table) as table:
        query = table.search(Query().path.exists())
        return query[0]['path'] if query else None


def set_credentials(creds_file: str) -> None:
    with get_credentials_table() as table:
        exists = get_credentials(table)
        with transaction(table) as tr:
Esempio n. 6
0
import serde.json

from modlunky2.utils import is_windows

if is_windows():
    # Import for pyinstaller to detect this module
    import platformdirs.windows  # pylint: disable=unused-import

PROGRAMS_KEY = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
DEFAULT_PATH = Path("C:/Program Files (x86)/Steam/steamapps/common/Spelunky 2")
EXE_NAME = "Spel2.exe"

APP_AUTHOR = "spelunky.fyi"
APP_NAME = "modlunky2"
CONFIG_DIR = Path(user_config_dir(APP_NAME, APP_AUTHOR))
DATA_DIR = Path(user_data_dir(APP_NAME, APP_AUTHOR))
CACHE_DIR = Path(user_cache_dir(APP_NAME, APP_AUTHOR))
SHOW_PACKING_DEFAULT = False

MIN_WIDTH = 1280
MIN_HEIGHT = 768


# Sentinel for tracking unset fields
NOT_PRESENT = object()

SPELUNKY_FYI_ROOT_DEFAULT = "https://spelunky.fyi/"
LAST_INSTALL_BROWSE_DEFAULT = "/"

DEFAULT_COLOR_KEY = "#ff00ff"
Esempio n. 7
0
import os

import platformdirs
from pdm.project import ConfigItem
from pdm.project.config import ensure_boolean

venv_configs = {
    "venv.location":
    ConfigItem(
        "Parent directory for virtualenvs",
        os.path.join(platformdirs.user_data_dir("pdm"), "venvs"),
        global_only=True,
    ),
    "venv.backend":
    ConfigItem("Default backend to create virtualenv", default="virtualenv"),
    "venv.in_project":
    ConfigItem(
        "Create virtualenv in `.venv` under project root",
        default=False,
        env_var="PDM_VENV_IN_PROJECT",
        coerce=ensure_boolean,
    ),
    # Override the default use_venv value to True
    "python.use_venv":
    ConfigItem(
        "Install packages into the activated venv site packages instead of PEP 582",
        True,
        env_var="PDM_USE_VENV",
        coerce=ensure_boolean,
        replace="use_venv",
    ),
Esempio n. 8
0
@click.command(context_settings={'max_content_width': 120})
@click.option('-v', '--verbose', count=True, help="Be more verbose")
@click.option('--sync/--no-sync',
              default=True,
              show_default=True,
              help="Sync again or just use local database?")
@click.option('--access-token',
              type=str,
              envvar='FOURSQUARE_TOKEN',
              show_envvar=True,
              help="Foursquare oauth2 access token")
@click.option('--database',
              type=click.Path(writable=True),
              default=os.path.join(
                  platformdirs.user_data_dir(appname=__package__),
                  'checkins.sqlite'),
              show_default=True,
              help="SQLite database file")
@click.option('-e',
              '--emoji/--no-emoji',
              default=False,
              show_default=True,
              help="Prefix summary with venue category as emoji")
@click.option('-o',
              '--output',
              type=click.File('wb'),
              default='-',
              help="Output file")
@config_file.yaml_config_option()
@config_file.yaml_config_sample_option()
Esempio n. 9
0
from pathlib import Path
from typing import IO, Iterable, Optional, Union

from platformdirs import user_data_dir
from pyinaturalist import ICONIC_TAXA

from naturtag import __version__

# Resource directories
PKG_DIR = Path(__file__).parent.parent
ASSETS_DIR = PKG_DIR / 'assets'
KV_SRC_DIR = PKG_DIR / 'kv'
DATA_DIR = Path(user_data_dir()) / 'Naturtag'

# TODO: These may be useful as user-configurable settings
TRIGGER_DELAY = 0.1
AUTOCOMPLETE_DELAY = 0.5
AUTOCOMPLETE_MIN_CHARS = 3
IMAGE_FILETYPES = ['*.jpg', '*.jpeg', '*.png', '*.gif']
PHOTO_SIZES = ['square', 'small', 'medium', 'large', 'original']

# Thumnbnail & cache settings
THUMBNAILS_DIR = DATA_DIR / 'thumbnails'
THUMBNAIL_DEFAULT_FORMAT = 'png'
THUMBNAIL_SIZE_SM = (75, 75)
THUMBNAIL_SIZE_DEFAULT = (200, 200)
THUMBNAIL_SIZE_LG = (500, 500)
THUMBNAIL_SIZES = {
    'small': THUMBNAIL_SIZE_SM,
    'medium': THUMBNAIL_SIZE_DEFAULT,
    'large': THUMBNAIL_SIZE_LG,