Created
August 30, 2016 22:50
-
-
Save tobbez/ea20786727a544df2ba184f84922cdbe to your computer and use it in GitHub Desktop.
whipper/morituri patch for directory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/morituri/common/directory.py b/morituri/common/directory.py | |
index 47aac11..7af0df3 100644 | |
--- a/morituri/common/directory.py | |
+++ b/morituri/common/directory.py | |
@@ -22,34 +22,21 @@ | |
import os | |
+from xdg import BaseDirectory | |
+ | |
from morituri.common import log | |
class Directory(log.Loggable): | |
- | |
def getConfig(self): | |
- try: | |
- from xdg import BaseDirectory | |
- directory = BaseDirectory.save_config_path('morituri') | |
- path = os.path.join(directory, 'morituri.conf') | |
- self.info('Using XDG, configuration file is %s' % path) | |
- except ImportError: | |
- path = os.path.join(os.path.expanduser('~'), '.moriturirc') | |
- self.info('Not using XDG, configuration file is %s' % path) | |
+ directory = BaseDirectory.save_config_path('whipper') | |
+ path = os.path.join(directory, 'whipper.conf') | |
+ self.info('Configuration file is %s' % path) | |
return path | |
- | |
def getCache(self, name=None): | |
- try: | |
- from xdg import BaseDirectory | |
- path = BaseDirectory.save_cache_path('morituri') | |
- self.info('Using XDG, cache directory is %s' % path) | |
- except (ImportError, AttributeError): | |
- # save_cache_path was added in pyxdg 0.25 | |
- path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache') | |
- if not os.path.exists(path): | |
- os.makedirs(path) | |
- self.info('Not using XDG, cache directory is %s' % path) | |
+ path = BaseDirectory.save_cache_path('whipper') | |
+ self.info('Cache directory is %s' % path) | |
if name: | |
path = os.path.join(path, name) | |
@@ -59,25 +46,12 @@ class Directory(log.Loggable): | |
return path | |
def getReadCaches(self, name=None): | |
- paths = [] | |
- | |
- try: | |
- from xdg import BaseDirectory | |
- path = BaseDirectory.save_cache_path('morituri') | |
- self.info('For XDG, read cache directory is %s' % path) | |
- paths.append(path) | |
- except (ImportError, AttributeError): | |
- # save_cache_path was added in pyxdg 0.21 | |
- pass | |
- | |
- path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache') | |
- if os.path.exists(path): | |
- self.info('From before XDG, read cache directory is %s' % path) | |
- paths.append(path) | |
+ path = BaseDirectory.save_cache_path('whipper') | |
+ self.info('Read cache directory is %s' % path) | |
if name: | |
- paths = [os.path.join(p, name) for p in paths] | |
- | |
- return paths | |
- | |
+ path = os.path.join(path, name) | |
+ if not os.path.exists(path): | |
+ os.makedirs(path) | |
+ return [path] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment