diff options
| author | mikeos <mike.osipov@gmail.com> | 2013-10-07 00:20:05 +0400 |
|---|---|---|
| committer | mikeos <mike.osipov@gmail.com> | 2013-10-07 00:20:05 +0400 |
| commit | 621671f490ec7c7155fed6521449148ad9a8faaf (patch) | |
| tree | 579846da3109af56fc5e741ed178fe323b193c85 | |
| parent | 6f6c2754c4b73946eab3faa4dc7e9e672eb373b8 (diff) | |
create default config on startup
| -rw-r--r-- | TODO | 2 | ||||
| -rw-r--r-- | cutter/config.py | 44 |
2 files changed, 43 insertions, 3 deletions
@@ -7,4 +7,4 @@ OK 6. copy file instead of convert if possible OK 7. substitute odd symbols in track names OK 8. add charset coding argument OK 9. prepare setup -10. create default config on startup +OK 10. create default config on startup diff --git a/cutter/config.py b/cutter/config.py index 655c0d6..d1a5f39 100644 --- a/cutter/config.py +++ b/cutter/config.py @@ -6,8 +6,48 @@ try: except ImportError: import ConfigParser as configparser +CONFIG_FILE_PATH = os.path.expanduser("~/.cutter.cfg") + ConfigParserClass = configparser.RawConfigParser +def __create_default(name): + fp = open(name, "w") + + fp.write( +"""[encoding] +# type = <default format type> + +# where to place new files +dir = . + +# use temporary directory for converted files +use_tempdir = false + +[output] +# sample_rate = +# channels = +# bits_per_sample = + +[filename] +format = %s + +# convert illegal for fat32 filesystem characters +convert_chars = false + +[flac] +# from the least compression (but fastest) to the best compression (but slowest) +# compression = <0 .. 8> + +[ogg] +# from the highest compression (lowest quality) to the lowest compression (highest quality) +# compression = <-1 .. 10> + +[mp3] +# bitrate = <32 .. 320> +""" % DEFAULT_FILENAME_FORMAT) + + fp.close() + def with_default(func, msg = None): def method(cls, section, option, default = None): try: @@ -41,12 +81,12 @@ class CfgParser: DEFAULT_FILENAME_FORMAT = "{tracknumber:02d}.{title}" cfg = CfgParser() -cfg.read(os.path.expanduser("~/.cutter.cfg")) +if not cfg.read(os.path.expanduser(CONFIG_FILE_PATH)): + __create_default(CONFIG_FILE_PATH) 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") |
