diff options
| author | mikeos <mike.osipov@gmail.com> | 2013-09-30 22:11:41 +0400 |
|---|---|---|
| committer | mikeos <mike.osipov@gmail.com> | 2013-09-30 22:23:41 +0400 |
| commit | 6f6c2754c4b73946eab3faa4dc7e9e672eb373b8 (patch) | |
| tree | 3daa8109c4c0d5978a1aa83112b4dafdebe52cde /config.py | |
| parent | 0ae5a430e4f92ee7bf9e458cf584a0a12fd5c25a (diff) | |
setup.py
Diffstat (limited to 'config.py')
| -rw-r--r-- | config.py | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/config.py b/config.py deleted file mode 100644 index c9e8b96..0000000 --- a/config.py +++ /dev/null @@ -1,60 +0,0 @@ -from coding import is_python_v2, to_unicode -import os - -try: - import configparser -except ImportError: - import ConfigParser as configparser - -ConfigParserClass = configparser.RawConfigParser - -def with_default(func, msg = None): - def method(cls, section, option, default = None): - try: - return func(cls.parser, section, option) - except configparser.NoSectionError: - return default - except configparser.NoOptionError: - return default - except ValueError as err: - raise Exception("%s::%s: %s" % (section, option, msg or err)) - return method - -class CfgParser: - def __init__(self): - self.parser = ConfigParserClass() - - __get = with_default(ConfigParserClass.get) - - if not is_python_v2(): - get = __get - else: - def get(self, *args): - return to_unicode(self.__get(*args)) - - getint = with_default(ConfigParserClass.getint, "invalid number") - getbool = with_default(ConfigParserClass.getboolean, "invalid bool") - - def __getattr__(self, attr): - return getattr(self.parser, attr) - -DEFAULT_FILENAME_FORMAT = "{tracknumber:02d}.{title}" - -cfg = CfgParser() -cfg.read(os.path.expanduser("~/.cutter.cfg")) - -DIR = cfg.get("encoding", "dir", ".") -TYPE = cfg.get("encoding", "type") -USE_TEMPDIR = cfg.getbool("encoding", "use_tempdir") -COMPRESSION = cfg.getint("encoding", "compression") - -SAMPLE_RATE = cfg.getint("output", "sample_rate") -CHANNELS = cfg.getint("output", "channels") -BITS_PER_SAMPLE = cfg.getint("output", "bits_per_sample") - -FILENAME_FORMAT = cfg.get("filename", "format", DEFAULT_FILENAME_FORMAT) -CONVERT_CHARS = cfg.getbool("filename", "convert_chars", False) - -FLAC_COMPRESSION = cfg.getint("flac", "compression") -OGG_COMPRESSION = cfg.getint("ogg", "compression") -MP3_BITRATE = cfg.getint("mp3", "bitrate") |
