Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_helpers(self):
self.assertIsInstance(
appdirs.user_data_dir('MyApp', 'MyCompany'), STRING_TYPE)
self.assertIsInstance(
appdirs.site_data_dir('MyApp', 'MyCompany'), STRING_TYPE)
self.assertIsInstance(
appdirs.user_cache_dir('MyApp', 'MyCompany'), STRING_TYPE)
self.assertIsInstance(
appdirs.user_state_dir('MyApp', 'MyCompany'), STRING_TYPE)
self.assertIsInstance(
appdirs.user_log_dir('MyApp', 'MyCompany'), STRING_TYPE)
@manager.command
def init(site=False):
"Prompt the user for config"
if site:
base_dir = appdirs.site_data_dir(APP_NAME, APP_AUTHOR)
else:
base_dir = appdirs.user_data_dir(APP_NAME, APP_AUTHOR)
if not os.path.exists(base_dir):
os.makedirs(base_dir)
config_path = os.path.join(base_dir, 'config.py')
incomplete = os.path.realpath(prompt('Incomplete directory', 'incomplete'))
downloads = os.path.realpath(prompt('Downloads directory', 'downloads'))
torrents = os.path.realpath(prompt('Torrents directory', 'torrents'))
putio_token = prompt('OAuth Token')
config_dist = find_config_dist()
with open(config_dist, 'r') as source:
def _find_hunspell_files(self):
lang = self.lang
base_dirs = site_data_dir('hunspell', multipath=True).split(os.pathsep)
for base_dir in base_dirs:
aff_path = os.path.join(base_dir, lang + '.aff')
dic_path = os.path.join(base_dir, lang + '.dic')
if os.path.exists(aff_path) and os.path.exists(dic_path):
return dic_path, aff_path
def global_data_dir():
"""Return the global Intake catalog dir for the current environment"""
prefix = False
if VIRTUALENV_VAR in os.environ:
prefix = os.environ[VIRTUALENV_VAR]
elif CONDA_VAR in os.environ:
prefix = sys.prefix
elif which('conda'):
# conda exists but is not activated
prefix = conda_prefix()
if prefix:
# conda and virtualenv use Linux-style directory pattern
return make_path_posix(os.path.join(prefix, 'share', 'intake'))
else:
return appdirs.site_data_dir(appname='intake', appauthor='intake')
def __init__(self, name, clone_path):
"""Initialize the repository.
Args:
name (unicode):
The configured name of the repository.
clone_path (unicode):
The path of the hg repository to clone.
"""
self.name = name
self.clone_path = clone_path
self.repo_path = os.path.join(appdirs.site_data_dir('reviewbot'),
'repositories', name)
def _get_default_datadir():
home = os.path.expanduser('~')
if os.path.isdir(home):
func = appdirs.user_data_dir
else:
if sys.platform in ['win32', 'darwin']:
func = appdirs.site_data_dir
else:
func = lambda **kwarg: "/var/lib/%s" % kwarg['appname'].lower()
# No "version" kwarg as session and filestore paths are shared against series
return func(appname=release.product_name, appauthor=release.author)
def site_data_dir(self):
"""Return ``site_data_dir``."""
directory = appdirs.site_data_dir(self.appname, self.appauthor,
version=self.version, multipath=self.multipath)
if self.create:
self._ensure_directory_exists(directory)
return directory