[Opensrf-commits] r1157 - trunk/src/python

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Dec 7 00:20:47 EST 2007


Author: dbs
Date: 2007-12-07 00:00:55 -0500 (Fri, 07 Dec 2007)
New Revision: 1157

Modified:
   trunk/src/python/srfsh.py
Log:
Minor code cleanup:
Avoid stepping on str's toes by renaming the variable 'str' to string.
Explicitly call osrf.json and str methods rather than polluting global name space.


Modified: trunk/src/python/srfsh.py
===================================================================
--- trunk/src/python/srfsh.py	2007-12-05 14:44:54 UTC (rev 1156)
+++ trunk/src/python/srfsh.py	2007-12-07 05:00:55 UTC (rev 1157)
@@ -1,9 +1,8 @@
 #!/usr/bin/python
 # vim:et:ts=4
 import os, sys, time, readline, atexit, re
-from string import *
+import osrf.json
 from osrf.system import osrfConnect
-from osrf.json import *
 from osrf.ses import osrfClientSession
 from osrf.conf import osrfConfigValue
 
@@ -19,9 +18,9 @@
             line = raw_input("\033[01;32msrfsh\033[01;34m% \033[00m")
             if not len(line): 
                 continue
-            if lower(line) == 'exit' or lower(line) == 'quit': 
+            if str.lower(line) == 'exit' or str.lower(line) == 'quit': 
                 break
-            parts = split(line)
+            parts = str.split(line)
 
             command = parts[0]
         
@@ -109,7 +108,7 @@
     params = None
 
     try:
-        params = osrfJSONToObject(jstr)
+        params = osrf.json.osrfJSONToObject(jstr)
     except:
         print "Error parsing JSON: %s" % jstr
         return
@@ -130,9 +129,9 @@
 
         otp = get_var('SRFSH_OUTPUT')
         if otp == 'pretty':
-            print "\n" + osrfDebugNetworkObject(resp.content())
+            print "\n" + osrf.json.osrfDebugNetworkObject(resp.content())
         else:
-            print osrfFormatJSON(osrfObjectToJSON(resp.content()))
+            print osrf.json.osrfFormatJSON(osrfObjectToJSON(resp.content()))
 
     req.cleanup()
     ses.cleanup()
@@ -240,8 +239,8 @@
         print_green("Loading module %s..." % name)
 
         try:
-            str = 'from %s import %s\n%s()' % (name, init, init)
-            exec(str)
+            string = 'from %s import %s\n%s()' % (name, init, init)
+            exec(string)
             print_red('OK\n')
 
         except Exception, e:
@@ -261,15 +260,15 @@
     except: return ''
     
     
-def print_green(str):
+def print_green(string):
     sys.stdout.write("\033[01;32m")
-    sys.stdout.write(str)
+    sys.stdout.write(string)
     sys.stdout.write("\033[00m")
     sys.stdout.flush()
 
-def print_red(str):
+def print_red(string):
     sys.stdout.write("\033[01;31m")
-    sys.stdout.write(str)
+    sys.stdout.write(string)
     sys.stdout.write("\033[00m")
     sys.stdout.flush()
 



More information about the opensrf-commits mailing list