changeset 49:fbac55e481eb

move this to its own method
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 17 Dec 2012 11:49:21 -0800
parents 98a2a78dbcfd
children 935f8991ebb6
files bzconsole/command.py
diffstat 1 files changed, 18 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/bzconsole/command.py	Mon Dec 17 11:34:38 2012 -0800
+++ b/bzconsole/command.py	Mon Dec 17 11:49:21 2012 -0800
@@ -11,8 +11,24 @@
 from optparse import OptionParser
 from pprint import pprint
 
-def read_dotfile(self):
+def read_dotfile():
     """read information from ~/.bz"""
+    options = {}
+    dotfile = os.path.join(os.environ['HOME'], '.bz')
+    if not os.path.exists(dotfile):
+        return {}
+    f = file(dotfile)
+    for line in f.readlines():
+        line = line.strip()
+        if not line:
+            continue
+        if ':' in line:
+            key, value = [i.strip()
+                          for i in line.split(':', 1)]
+            options[key] = value
+        else:
+            print >> sys.stderr, "Bad option line: " + line
+    return options
 
 class Undefined(object):
   def __init__(self, default):
@@ -98,20 +114,7 @@
         name, args = self.parse(args)
 
         # setup
-        options = {}
-        dotfile = os.path.join(os.environ['HOME'], '.bz')
-        if os.path.exists(dotfile):
-            f = file(dotfile)
-            for line in f.readlines():
-                line = line.strip()
-                if not line:
-                    continue
-                if ':' in line:
-                    key, value = [i.strip()
-                                  for i in line.split(':', 1)]
-                    options[key] = value
-                else:
-                    print >> sys.stderr, "Bad option line: " + line
+        options = read_dotfile()
         for key, value in self.options.__dict__.items():
             if isinstance(value, Undefined):
                 if key in options: