set theme as default
authorOrakaro <nhatminh_179@hotmail.com>
Fri, 4 Jul 2014 14:19:52 +0000 (23:19 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Fri, 4 Jul 2014 14:19:52 +0000 (23:19 +0900)
MANIFEST.in
rainbowstream/config.py
rainbowstream/rainbow.py
setup.py

index 4e90fb0..08270fc 100644 (file)
@@ -1,4 +1,3 @@
 include README.rst
 include rainbowstream/image.c
-include rainbowstream/consumer.pyc
 recursive-include rainbowstream/colorset *.json
index bc541a9..e75ec67 100644 (file)
@@ -3,7 +3,6 @@ import re
 import os
 import os.path
 
-
 # Regular expression for comments
 comment_re = re.compile(
     '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
@@ -23,13 +22,30 @@ def load_config(filepath):
             match = comment_re.search(content)
     return json.loads(content)
 
-# Load default colorset
+# Config dictionary
 c = {}
+# Load default
 default_config = os.path.dirname(__file__) + '/colorset/default.json'
 data = load_config(default_config)
 for d in data:
     c[d] = data[d]
 c['theme'] = 'default'
+# Load init if exist
+try:
+    path = os.path.dirname(__file__) + '/colorset/init'
+    f = open(path)
+    lines = f.readlines()
+    if len(lines) > 1:
+        raise Exception('More than 1 default theme')
+    theme_name = lines[0].strip()
+    default_config = os.path.dirname(__file__)+'/colorset/'+theme_name+'.json'
+    data = load_config(default_config)
+    for d in data:
+        c[d] = data[d]
+    c['theme'] = theme_name
+    f.close()
+except:
+    pass
 # Load user's colorset
 rainbow_config = os.environ.get(
     'HOME',
index b704287..29fbc53 100644 (file)
@@ -781,6 +781,12 @@ def theme():
             else:
                 line = ' '*4 + line
             printNicely(line)
+    elif g['stuff'] == 'current_as_default':
+        path = os.path.dirname(__file__) + '/colorset/init'
+        f = open(path,'w')
+        f.write(c['theme'])
+        f.close()
+        printNicely(light_green('Okay it will be applied from next time :)'))
     else:
         # Change theme
         try:
@@ -1060,7 +1066,7 @@ def listen():
             ['@'],  # unblock
             ['@'],  # report
             [],  # cal
-            g['themes'],  # theme
+            g['themes'] + ['current_as_default'],  # theme
             [],  # help
             [],  # clear
             [],  # quit
index 0db589b..73080a4 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 from setuptools import setup, find_packages
 
-version = '0.1.10'
+version = '0.2.0'
 
 install_requires = [
     "SQLAlchemy",