Skip to content

Commit

Permalink
Address issue #24
Browse files Browse the repository at this point in the history
Now whipper always follows XDG specifications. All changes were documented into the README file.
  • Loading branch information
JoeLametta committed Sep 5, 2016
1 parent e7ff3c1 commit c87e13f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 56 deletions.
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FORK INFORMATIONS
---------
The name of this fork is still to be decided: right now I'll be using whipper.

This branch is very close to morituri's master one (the internal 'morituri' references are still unchanged). As a starting point, I've just merged the following commits:
This branch is very close to morituri's master one (internal morituri references are still unchanged). As a starting point, I've just merged the following commits:
- [#79](https:/thomasvs/morituri/issues/79)
- [#92](https:/thomasvs/morituri/issues/92)
- [#109](https:/thomasvs/morituri/issues/109)
Expand All @@ -12,19 +12,37 @@ This branch is very close to morituri's master one (the internal 'morituri' refe
- [#140](https:/thomasvs/morituri/issues/140)
- [#141](https:/thomasvs/morituri/issues/141)

And changed the default logger to morituri-whatlogger's one.
And changed the default logger to [morituri-yamllogger](https:/JoeLametta/morituri-yamllogger)'s one.

In order to track whipper's development it's better to check its commit history (readme needs to be updated).
In order to track whipper's current development it's better to check its commit history (README *needs* to be updated).

**WARNING:** As whipper is still under heavy development sometimes I will force push (`--force-with-lease`) to the non master branches.

BACKWARD INCOMPATIBLE CHANGES
---------
* Whipper has adopted new config/cache/state file paths
* Now always follows XDG specifications
* Paths used when XDG environment variables are available:
* `$XDG_CONFIG_HOME/whipper`
* `$XDG_CACHE_HOME/whipper`
* `$XDG_DATA_HOME/whipper`
* Paths used when XDG environment variables are **NOT** available:
* `$HOME/.config/whipper`
* `$HOME/.cache/whipper`
* `$HOME/.local/share/whipper`
* Configuration file information:
* `.moriturirc`, `morituri.conf` aren't used anymore
* `$XDG_CONFIG_HOME/whipper/whipper.conf` (OR `$HOME/.config/whipper/whipper.conf`)
* Plugins folder path:
* `$XDG_DATA_HOME/whipper/plugins` (OR `$HOME/.local/share/whipper/plugins`)

WHIPPER [![Build Status](https://travis-ci.org/JoeLametta/whipper.svg?branch=master)](https://travis-ci.org/JoeLametta/whipper)
---------
whipper is a fork of the morituri project (CDDA ripper for *nix systems aiming for accuracy over speed).

It improves morituri which development seems to have halted/slowed down merging old pull requests and improving it with bugfixes and new functions.

If possible, I'll try to mainline the useful commits of this fork but, in the future, this may not be possible because of different project choices.

The project home page is still TBD.
If possible, I'll try to upstream the progress done here but, in the future, this may not be possible because of different project choices.

RATIONALE
---------
Expand Down Expand Up @@ -150,7 +168,7 @@ The simplest way to get started making accurate rips is:

FILING BUGS
-----------
whipper's bug tracker is still TBD.
whipper's bugs are tracked using the repository issue section provided by GitHub.

morituri's bug tracker is at [http://thomas.apestaart.org/morituri/trac/](
http://thomas.apestaart.org/morituri/trac/).
Expand Down Expand Up @@ -184,7 +202,7 @@ The configuration file is stored according to [XDG Base Directory Specification]
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
when possible.

It lives in `$XDG_CONFIG_HOME/morituri/morituri.conf`
It lives in `$XDG_CONFIG_HOME/whipper/whipper.conf` (or `$HOME/.config/whipper/whipper.conf`)

The configuration file follows python's ConfigParser syntax.

Expand Down Expand Up @@ -217,3 +235,4 @@ Note: to get a literal '%' character it must be doubled.
CONTRIBUTING
------------
- Please send pull requests through GitHub.

5 changes: 3 additions & 2 deletions morituri/common/accurip.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import urlparse
import urllib2

from morituri.common import log
from morituri.common import log, directory

_CACHE_DIR = os.path.join(os.path.expanduser('~'), '.morituri', 'cache')
d = directory.Directory()
_CACHE_DIR = d.getCache()


class AccuCache(log.Loggable):
Expand Down
4 changes: 2 additions & 2 deletions morituri/common/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def __init__(self, path=None):
self._pcache = PersistedCache(self._path)

def _getResultCachePath(self):
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
'result')
d = directory.Directory()
path = d.getCache('result')
return path

def getRipResult(self, cddbdiscid, create=True):
Expand Down
80 changes: 39 additions & 41 deletions morituri/common/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,54 @@
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)
config_directory = os.getenv('XDG_CONFIG_HOME')
if not config_directory:
config_directory = os.path.join(os.path.expanduser('~'),
u'.config')
path = os.path.join(config_directory, u'whipper/whipper.conf')
self.info('Configuration file path: %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)

cache_directory = os.getenv('XDG_CACHE_HOME')
if not cache_directory:
cache_directory = os.path.join(os.path.expanduser('~'), u'.cache')
path = os.path.join(cache_directory, u'whipper')
self.info('Cache directory path: %s' % path)
if not os.path.exists(path):
os.makedirs(path)
if name:
path = os.path.join(path, name)
if not os.path.exists(path):
os.makedirs(path)

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)

cache_directory = os.getenv('XDG_CACHE_HOME')
if not cache_directory:
cache_directory = os.path.join(os.path.expanduser('~'), u'.cache')
path = os.path.join(cache_directory, u'whipper')
self.info('Read cache path: %s' % path)
if not os.path.exists(path):
os.makedirs(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]

def getData(self, name=None):
data_directory = os.getenv('XDG_DATA_HOME')
if not data_directory:
data_directory = os.path.join(os.path.expanduser('~'),
u'.local/share')
path = os.path.join(data_directory, u'whipper')
self.info('Data directory path: %s' % path)
if not os.path.exists(path):
os.makedirs(path)
if name:
path = os.path.join(path, name)
if not os.path.exists(path):
os.makedirs(path)
return path

6 changes: 3 additions & 3 deletions morituri/rip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import pkg_resources

from morituri.common import log, logcommand, common, config
from morituri.common import log, logcommand, common, config, directory
from morituri.configure import configure

from morituri.rip import cd, offset, drive, image, accurip, debug
Expand All @@ -19,8 +19,8 @@ def main(argv):

from morituri.configure import configure
pluginsdir = configure.pluginsdir
homepluginsdir = os.path.join(os.path.expanduser('~'),
'.morituri', 'plugins')
d = directory.Directory()
homepluginsdir = d.getData('plugins')

distributions, errors = pkg_resources.working_set.find_plugins(
pkg_resources.Environment([pluginsdir, homepluginsdir]))
Expand Down

0 comments on commit c87e13f

Please sign in to comment.