changeset 4:01015b36290a

look for home configuration file if it exists
author k0s <k0scist@gmail.com>
date Sat, 21 Nov 2009 19:52:10 -0500
parents c5f19f51e1e8
children 7328744920de
files setup.py smartopen/smartopen.py
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,12 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = '0.1'
+version = '0.1.1'
 
 setup(name='smartopen',
       version=version,
       description="open text in a browser contextually",
       long_description="""\
 """,
       classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
       keywords='',
--- a/smartopen/smartopen.py
+++ b/smartopen/smartopen.py
@@ -84,17 +84,19 @@ def main(args=sys.argv[1:]):
 
     # sanity check
     assert not (options.url and options.all)
     if not options.handlers:
         options.handlers = None
 
     # config
     config = ConfigParser()
-    if options.config and os.path.exists(options.config):
+    if not options.config:
+        options.config = os.path.join(os.environ.get('HOME', ''), '.smartopen.ini')
+    if os.path.exists(options.config):
         config.read(options.config)
         if not options.handlers and config.has_option('DEFAULTS', 'handlers'):
             options.handlers = [ i.strip() for i in config.get('DEFAULTS', 'handlers').split(',') ]
     _config = {}
     for section in config.sections():
         _config[section] = dict(config.items(section))
 
     # get the handlers