def _session(cachedir=None): # type: (...) -> requests.Session """ Return a requests.Session instance Parameters ---------- cachedir : Optional[str] HTTP cache location. Returns ------- session : requests.Session """ import cachecontrol.caches if cachedir is None: cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation) cachedir = os.path.join(cachedir, "networkcache", "requests") session = requests.Session() session = cachecontrol.CacheControl( session, cache=cachecontrol.caches.FileCache( directory=cachedir ) ) return session
def _session(cachedir=None): # type: (...) -> requests.Session """ Return a requests.Session instance Parameters ---------- cachedir : Optional[str] HTTP cache location. Returns ------- session : requests.Session """ import cachecontrol.caches if cachedir is None: cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation) cachedir = os.path.join(cachedir, "networkcache", "requests") session = requests.Session() session = cachecontrol.CacheControl( session, cache=cachecontrol.caches.FileCache( directory=cachedir ) ) return session
def data_dir_base(): """ Return the platform dependent generic application directory. This is usually - on windows: "%USERPROFILE%\\AppData\\Local\\" - on OSX: "~/Library/Application Support/" - other: "~/.local/share/ """ return QStandardPaths.writableLocation(QStandardPaths.GenericDataLocation)
def cache_dir(): """ Return the application cache directory. If the directory path does not yet exists then create it. """ init() cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation) version = QCoreApplication.applicationVersion() cachedir = os.path.join(cachedir, version) if not os.path.exists(cachedir): os.makedirs(cachedir) return cachedir
def cache_dir(): """ Return the application cache directory. If the directory path does not yet exists then create it. """ init() cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation) version = QCoreApplication.applicationVersion() cachedir = os.path.join(cachedir, version) if not os.path.exists(cachedir): os.makedirs(cachedir) return cachedir
def data_dir(): """ Return the application data directory. If the directory path does not yet exists then create it. """ init() datadir = QStandardPaths.writableLocation(QStandardPaths.DataLocation) version = QCoreApplication.applicationVersion() datadir = os.path.join(datadir, version) if not os.path.isdir(datadir): try: os.makedirs(datadir, exist_ok=True) except OSError: pass return datadir
def data_dir(): """ Return the application data directory. If the directory path does not yet exists then create it. """ init() datadir = QStandardPaths.writableLocation(QStandardPaths.DataLocation) version = QCoreApplication.applicationVersion() datadir = os.path.join(datadir, version) if not os.path.isdir(datadir): try: os.makedirs(datadir, exist_ok=True) except OSError: pass return datadir
def cache_dir(): """Return the application cache directory. If the directory path does not yet exists then create it. """ warnings.warn(f"'{__name__}.cache_dir' is deprecated.", DeprecationWarning, stacklevel=2) base = QStandardPaths.writableLocation(QStandardPaths.GenericCacheLocation) name = QCoreApplication.applicationName() version = QCoreApplication.applicationVersion() if not name: name = "Orange" if not version: version = "0.0.0" path = os.path.join(base, name, version) try: os.makedirs(path, exist_ok=True) except OSError: pass return path
def standard_location(type): warnings.warn("Use QStandardPaths.writableLocation", DeprecationWarning, stacklevel=2) return QStandardPaths.writableLocation(type)
def standard_location(type): warnings.warn( "Use QStandardPaths.writableLocation", DeprecationWarning, stacklevel=2 ) return QStandardPaths.writableLocation(type)
def standard_location(type): return QStandardPaths.writableLocation(type)