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 4e90fb0e160b2e1278eaa4e9044fe2d18c125259..08270fc5ac296afcab9051179ef3d416459e06c3 100644 (file)
@@ -1,4 +1,3 @@
 include README.rst
 include rainbowstream/image.c
 include README.rst
 include rainbowstream/image.c
-include rainbowstream/consumer.pyc
 recursive-include rainbowstream/colorset *.json
 recursive-include rainbowstream/colorset *.json
index bc541a9297570e6f38a03dd9da4e1241ca4b98ad..e75ec6727ac00bc9716eb3da9088c5095c4e0cef 100644 (file)
@@ -3,7 +3,6 @@ import re
 import os
 import os.path
 
 import os
 import os.path
 
-
 # Regular expression for comments
 comment_re = re.compile(
     '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
 # 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)
 
             match = comment_re.search(content)
     return json.loads(content)
 
-# Load default colorset
+# Config dictionary
 c = {}
 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'
 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',
 # Load user's colorset
 rainbow_config = os.environ.get(
     'HOME',
index b7042876ce613fb704b557373acb6e5dd576ed60..29fbc537e1c28f67cd78b3d67326f90e1c64beb9 100644 (file)
@@ -781,6 +781,12 @@ def theme():
             else:
                 line = ' '*4 + line
             printNicely(line)
             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:
     else:
         # Change theme
         try:
@@ -1060,7 +1066,7 @@ def listen():
             ['@'],  # unblock
             ['@'],  # report
             [],  # cal
             ['@'],  # unblock
             ['@'],  # report
             [],  # cal
-            g['themes'],  # theme
+            g['themes'] + ['current_as_default'],  # theme
             [],  # help
             [],  # clear
             [],  # quit
             [],  # help
             [],  # clear
             [],  # quit
index 0db589b18264e74889f14154a5e8d5ea98e8cbe4..73080a4b1ae4162328af424dadf46fe77a5d792a 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 from setuptools import setup, find_packages
 
 from setuptools import setup, find_packages
 
-version = '0.1.10'
+version = '0.2.0'
 
 install_requires = [
     "SQLAlchemy",
 
 install_requires = [
     "SQLAlchemy",