Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'appname' : __name__.split(".")[0],
'apptitle' : "Legendas.TV",
'version' : "1.0",
'notifier' : None,
}
globals.update({
'appicon' : os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)),
"..", globals['appname'] + ".png")),
'cache_dir' : os.path.join(xdg.xdg_cache_home, globals['appname']),
'config_dir': xdg.save_config_path(globals['appname']),
})
globals.update({
'notify_icon' : globals['appicon'],
'config_file' : os.path.join(globals['config_dir'],
globals['appname'] + ".ini"),
'log_file' : os.path.join(globals['cache_dir'],
globals['appname'] + ".log"),
})
# These factory settings are also available at config file
options = {
def __init__(self):
self.cache_root = os.path.join(BaseDirectory.xdg_cache_home, "snapcraft")
def _create_file_structure():
def check_or_mkdir(path):
if not os.path.exists(path):
os.mkdir(path)
g.register('CONFIG_DIR', os.path.join(BaseDirectory.xdg_config_dirs[0], 'moosecat'))
check_or_mkdir(g.CONFIG_DIR)
g.register('CACHE_DIR', os.path.join(BaseDirectory.xdg_cache_home, 'moosecat'))
check_or_mkdir(g.CACHE_DIR)
g.register('USER_PLUGIN_DIR', os.path.join(g.CONFIG_DIR, 'plugins'))
check_or_mkdir(g.USER_PLUGIN_DIR)
g.register('CONFIG_FILE', os.path.join(g.CONFIG_DIR, 'config.yaml'))
g.register('LOG_FILE', os.path.join(g.CONFIG_DIR, 'app.log'))
"Returns the name of the current user"
import getpass
return getpass.getuser()
def gethomedir(user=''):
return os.path.expanduser("~" + user)
# see http://standards.freedesktop.org/basedir-spec
CONFIG_HOME = os.path.join(os.path.expanduser("~/.config"), 'crm')
CACHE_HOME = os.path.join(os.path.expanduser("~/.cache"), 'crm')
try:
from xdg import BaseDirectory
CONFIG_HOME = os.path.join(BaseDirectory.xdg_config_home, 'crm')
CACHE_HOME = os.path.join(BaseDirectory.xdg_cache_home, 'crm')
except:
pass
# TODO: move to CONFIG_HOME
HISTORY_FILE = os.path.expanduser("~/.crm_history")
RC_FILE = os.path.expanduser("~/.crm.rc")
CRMCONF_DIR = os.path.expanduser("~/.crmconf")
GRAPHVIZ_USER_FILE = os.path.join(CONFIG_HOME, "graphviz")
def mv_user_files():
'''
Called from main
'''
global HISTORY_FILE
def __init__(self, account_id):
ConfigBase.__init__(self, default=ACCOUNT_CFG)
self.log = logging.getLogger('AccountConfig')
self.basedir = os.path.join(BASEDIR, 'accounts', account_id)
if XDG_CACHE:
cachedir = BaseDirectory.xdg_cache_home
self.imgdir = os.path.join(cachedir, 'turpial', account_id, 'images')
else:
self.imgdir = os.path.join(self.basedir, 'images')
self.configpath = os.path.join(self.basedir, 'config')
self.log.debug('CACHEDIR: %s' % self.imgdir)
self.log.debug('CONFIGFILE: %s' % self.configpath)
if not os.path.isdir(self.basedir):
os.makedirs(self.basedir)
if not os.path.isdir(self.imgdir):
os.makedirs(self.imgdir)
if not self.exists(account_id):
self.create()
def synchronizeWorker(self):
self.update_status(_("Downloading task list..."))
self.update_progressbar(0.1)
self.__log("RTM sync started!")
self.gtg_proxy.generateTaskList()
self.rtm_proxy.generateTaskList()
self.update_status(_("Analyzing tasks..."))
self.update_progressbar(0.2)
self.gtg_list = self.gtg_proxy.task_list
self.rtm_list = self.rtm_proxy.task_list
## loading the mapping of the last sync
cache_dir = os.path.join(xdg_cache_home, 'gtg/plugins/rtm-sync')
gtg_to_rtm_id_mapping = smartLoadFromFile(\
cache_dir, 'gtg_to_rtm_id_mapping')
if gtg_to_rtm_id_mapping is None:
###this is the first synchronization
self.update_status(_("Running first synchronization..."))
self.update_progressbar(0.3)
gtg_to_rtm_id_mapping = \
self._firstSynchronization()
else:
###this is an update
self.update_status(_("Analyzing last sync..."))
self.update_progressbar(0.3)
gtg_id_current_set = set(map(lambda x: x.id, self.gtg_list))
rtm_id_current_set = set(map(lambda x: x.id, self.rtm_list))
if len(gtg_to_rtm_id_mapping)>0:
gtg_id_previous_list, rtm_id_previous_list = \
from ..logging import make_logger
log = make_logger(__name__)
import os
from xdg.BaseDirectory import xdg_config_home as XDG_CONFIG_HOME
from xdg.BaseDirectory import xdg_cache_home as XDG_CACHE_HOME
from xdg.BaseDirectory import xdg_data_home as XDG_DATA_HOME
from .. import __appname__
from ..views import (torrent, file, peer, tracker, setting)
from ..client.sorters import (TorrentSorter, PeerSorter, TrackerSorter, SettingSorter)
DEFAULT_RCFILE = os.path.join(XDG_CONFIG_HOME, __appname__, 'rc')
DEFAULT_HISTORY_DIR = os.path.join(XDG_DATA_HOME, __appname__, 'histories')
DEFAULT_GEOIP_DIR = os.path.join(XDG_CACHE_HOME, __appname__)
DEFAULT_THEME_FILE = os.path.join(os.path.dirname(__file__), 'default.theme')
def init_defaults(localcfg):
from ..utils.usertypes import (String, Int, Float, Bool, Path, Tuple, Option)
class SortOrder(str):
"""String that is equal to the same string with '!' or '.' prepended"""
_invert_chars = ''.join(TorrentSorter.INVERT_CHARS)
def __eq__(self, other):
return self.lstrip(self._invert_chars) == other.lstrip(self._invert_chars)
# An overloaded __eq__() obligates an overloaded __hash__(), or
# instances won't be hashable.
def __hash__(self):
return super().__hash__()
def __init__(self, name='', level='INFO'):
self.name = name
self._file_format = ''
self._console_format = ''
self._log_file = Path(os.path.join(xdg_cache_home, 'ytmdl/logs/log.cat'))
self._check_logfile()
self._level_number = {
'DEBUG': 0,
'INFO': 1,
'WARNING': 2,
'ERROR': 3,
'CRITICAL': 4
}
self.level = self._level_number[level]
__ulauncher_data_directory__ = '../data/'
__license__ = 'GPL-3'
__version__ = 'VERSION'
import os
from uuid import uuid4
from time import time
from functools import lru_cache
from gettext import gettext
from xdg.BaseDirectory import xdg_config_home, xdg_cache_home, xdg_data_dirs, xdg_data_home
DATA_DIR = os.path.join(xdg_data_home, 'ulauncher')
# Use ulauncher_cache dir because of the WebKit bug
# https://bugs.webkit.org/show_bug.cgi?id=151646
CACHE_DIR = os.path.join(xdg_cache_home, 'ulauncher_cache')
CONFIG_DIR = os.path.join(xdg_config_home, 'ulauncher')
SETTINGS_FILE_PATH = os.path.join(CONFIG_DIR, 'settings.json')
# spec: https://specifications.freedesktop.org/menu-spec/latest/ar01s02.html
DESKTOP_DIRS = list(filter(os.path.exists, [os.path.join(dir, "applications") for dir in xdg_data_dirs]))
EXTENSIONS_DIR = os.path.join(DATA_DIR, 'extensions')
EXT_PREFERENCES_DIR = os.path.join(CONFIG_DIR, 'ext_preferences')
ULAUNCHER_APP_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
class ProjectPathNotFoundError(Exception):
"""Raised when we can't find the project directory."""
def get_data_file(*path_segments):
"""Get the full path to a data file.
def get_cache_file(path):
''' get cache file. '''
cachefile = os.path.join(xdg_cache_home, PROGRAM_NAME, path)
cachedir = os.path.dirname(cachefile)
if not os.path.isdir(cachedir):
os.makedirs(cachedir)
return cachefile