Commits

Hugo Ruscitti  committed 40994a7

refactoring config module and creating INSTALL file.

  • Participants
  • Parent commits e2aba3a

Comments (0)

Files changed (2)

+If you are in debian or ubuntu system, run this command
+to install all required packages::
+
+    sudo apt-get install python-keybinder python-wnck
+
+
+and then, run azulejo::
+
+    python run.py

File azulejo/configuration.py

-#This file is part of azulejo
+# This file is part of azulejo
 #
 # Author: Pedro
 #
-#This code takes care of setting up or loading configurations.
-#Do not edit this file directly. This is only used for bootstrap, once executed,
-#this script will write configurations to ~/.azulejorc.js. If you want to
-#personalize shortcuts and geometries, edit that file instead.
+# This code takes care of setting up or loading configurations.
+# Do not edit this file directly. This is only used for bootstrap, once executed,
+# this script will write configurations to ~/.azulejorc.js. If you want to
+# personalize shortcuts and geometries, edit that file instead.
 #
 
 import json
 import os.path
 
+def read_file(path):
+    """Returns file content as string."""
+    file_handler = open(path, 'r')
+    content = file_handler.read()
+    file_handler.close()
+    return content
+
 def get_initial_config_content():
     """Returns the initial config values as string."""
     this_dir = os.path.dirname(os.path.abspath(__file__))
     initial_config_path = os.path.join(this_dir, 'initial_config.json')
-
-    config_file = open(initial_config_path, 'r')
-    content = config_file.read()
-    config_file.close()
-    return content
+    return read_file(initial_config_path)
 
 def create_inicial_config_file(conf_filename):
+    """Create a file with config values."""
     fw = open(conf_filename, 'w')
     raw_json = get_initial_config_content()
     fw.write(raw_json)
     create_inicial_config_file(conf_filename)
 
 print "Reading config file: '%s'" %(conf_filename)
-fr = open(conf_filename, 'r')
-json_string = fr.read()
-fr.close()
+json_string = read_file(conf_filename)
 
 conf_data = json.loads(json_string)
-