本文整理匯總了Python中click.get_app_dir方法的典型用法代碼示例。如果您正苦於以下問題:Python click.get_app_dir方法的具體用法?Python click.get_app_dir怎麽用?Python click.get_app_dir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類click
的用法示例。
在下文中一共展示了click.get_app_dir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setup_assistant
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def setup_assistant():
# Load credentials.
try:
credentials = os.path.join(
click.get_app_dir(common_settings.ASSISTANT_APP_NAME),
common_settings.ASSISTANT_CREDENTIALS_FILENAME
)
global creds
creds = auth_helpers.load_credentials(credentials, scopes=[common_settings.ASSISTANT_OAUTH_SCOPE, common_settings.PUBSUB_OAUTH_SCOPE])
except Exception as e:
logging.error('Error loading credentials: %s', e)
logging.error('Run auth_helpers to initialize new OAuth2 credentials.')
return -1
# Create gRPC channel
grpc_channel = auth_helpers.create_grpc_channel(ASSISTANT_API_ENDPOINT, creds)
logging.info('Connecting to %s', ASSISTANT_API_ENDPOINT)
# Create Google Assistant API gRPC client.
global assistant
assistant = embedded_assistant_pb2.EmbeddedAssistantStub(grpc_channel)
return 0
示例2: get
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def get(ctx, model_id):
"""
Retrieves a model from the repository.
"""
from kraken import repo
try:
os.makedirs(click.get_app_dir(APP_NAME))
except OSError:
pass
message('Retrieving model ', nl=False)
filename = repo.get_model(model_id, click.get_app_dir(APP_NAME),
partial(message, '.', nl=False))
message('\b\u2713', fg='green', nl=False)
message('\033[?25h')
message(f'Model name: {filename}')
ctx.exit(0)
示例3: __init__
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def __init__(self, **kwargs):
"""
:param frames: If given, should be a list representing the
frames.
If not given, the value is extracted
from the frames file.
:type frames: list
:param current: If given, should be a dict representing the
current frame.
If not given, the value is extracted
from the state file.
:type current: dict
:param config_dir: If given, the directory where the configuration
files will be
"""
self._current = None
self._old_state = None
self._frames = None
self._last_sync = None
self._config = None
self._config_changed = False
self._dir = (kwargs.pop('config_dir', None) or
click.get_app_dir('watson'))
self.config_file = os.path.join(self._dir, 'config')
self.frames_file = os.path.join(self._dir, 'frames')
self.state_file = os.path.join(self._dir, 'state')
self.last_sync_file = os.path.join(self._dir, 'last_sync')
if 'frames' in kwargs:
self.frames = kwargs['frames']
if 'current' in kwargs:
self.current = kwargs['current']
if 'last_sync' in kwargs:
self.last_sync = kwargs['last_sync']
示例4: test_empty_config_dir
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def test_empty_config_dir():
watson = Watson()
assert watson._dir == get_app_dir('watson')
示例5: get_data_dir
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def get_data_dir():
'''
Gets the folder directory selescrape will store data,
such as cookies or browser extensions and logs.
'''
APP_NAME = 'anime downloader'
return os.path.join(click.get_app_dir(APP_NAME), 'data')
示例6: __init__
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def __init__(self, file=None, ctx=None):
if not file:
file = os.path.join(click.get_app_dir('PROS'), 'cli.pros')
self.default_libraries = [] # type: list(str)
self.providers = []
self.applyDefaultProviders()
super(CliConfig, self).__init__(file, ctx=ctx)
示例7: __init__
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def __init__(self,
file=None, name=None, registrar=None, location=None,
registrar_options=None,
types=None,
root_dir=None):
self.name = name # type: str
self.registrar = registrar # type: str
self.location = location # type: str
self.types = types if types is not None else [] # type: List[TemplateTypes]
self.registrar_options = registrar_options if registrar_options is not None else dict() # type: Dict[str, str]
if not file:
file = os.path.join((root_dir if root_dir is not None else click.get_app_dir('PROS')), name, 'depot.pros')
super(DepotConfig, self).__init__(file)
示例8: get_template_dir
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def get_template_dir(depot, identifier):
if isinstance(depot, DepotConfig):
depot = depot.name
elif isinstance(depot, DepotProvider):
depot = depot.config.name
elif not isinstance(depot, str):
raise ValueError('Depot must a str, DepotConfig, or DepotProvider')
assert isinstance(depot, str)
return os.path.join(click.get_app_dir('PROS'), depot, '{}-{}'.format(identifier.name, identifier.version))
示例9: __init__
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def __init__(self, loop):
"""
:param asyncio.AbstractEventLoop | None loop:
"""
# Information about host and user.
self.host_name = os.uname()[1]
self.user_name = get_login_username()
self.user_uid = getpwnam(self.user_name).pw_uid
self.user_home = os.path.expanduser('~' + self.user_name)
self.config_dir = click.get_app_dir('onedrived')
self._create_config_dir_if_missing()
self.config = self.DEFAULT_CONFIG
self.loop = loop
self._watcher = None
示例10: setUp
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def setUp(self):
self.tempdir = tempfile.TemporaryDirectory()
click.get_app_dir = lambda x: self.tempdir.name + '/' + x
od_pref.context = od_pref.load_context()
od_pref.context._create_config_dir_if_missing()
示例11: setUp
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def setUp(self):
self.tempdir = tempfile.TemporaryDirectory()
click.get_app_dir = lambda x: self.tempdir.name + '/' + x
od_main.context = od_main.load_context()
od_main.context._create_config_dir_if_missing()
示例12: _get_global_config_dir
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def _get_global_config_dir():
"""Return user's config directory."""
return click.get_app_dir(APP_NAME, force_posix=True)
示例13: _get_config_path
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def _get_config_path():
return os.path.join(click.get_app_dir(APP_NAME), 'config.ini')
示例14: __init__
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def __init__(self, api_key=None, library_id=None, library_type='user',
autosync=False):
""" Service class for communicating with the Zotero API.
This is mainly a thin wrapper around :py:class:`pyzotero.zotero.Zotero`
that handles things like transparent HTML<->[edit-formt] conversion.
:param api_key: API key for the Zotero API, will be loaded from
the configuration if not specified
:param library_id: Zotero library ID the API key is valid for, will
be loaded from the configuration if not specified
:param library_type: Type of the library, can be 'user' or 'group'
"""
self._logger = logging.getLogger()
idx_path = os.path.join(click.get_app_dir(APP_NAME), 'index.sqlite')
self.config = load_config()
self.note_format = self.config['zotcli.note_format']
self.storage_dir = self.config.get('zotcli.storage_dir')
api_key = api_key or self.config.get('zotcli.api_key')
library_id = library_id or self.config.get('zotcli.library_id')
if not api_key or not library_id:
raise ValueError(
"Please set your API key and library ID by running "
"`zotcli configure` or pass them as command-line options.")
self._zot = Zotero(library_id=library_id, api_key=api_key,
library_type=library_type)
self._index = SearchIndex(idx_path)
sync_interval = self.config.get('zotcli.sync_interval', 300)
since_last_sync = int(time.time()) - self._index.last_modified
if autosync and since_last_sync >= int(sync_interval):
click.echo("{} seconds since last sync, synchronizing."
.format(since_last_sync))
num_updated = self.synchronize()
click.echo("Updated {} items".format(num_updated))
示例15: __init__
# 需要導入模塊: import click [as 別名]
# 或者: from click import get_app_dir [as 別名]
def __init__(self):
self._config_dir = click.get_app_dir('canari', False, True)
self._config_file = os.path.join(self.config_dir, 'canari.conf')
self._config = None
self._project = None
self._working_dir = None