File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ def list_functions():
9090 )
9191 return '\n ' .join (s )
9292
93- def function_help (function ):
93+ def function_help (function , return_as_string = False ):
9494 function = FUNCTIONS [function ]
9595
9696 s = [
@@ -117,7 +117,10 @@ def function_help(function):
117117
118118 s = "\n " .join (s )
119119
120- return s
120+ if return_as_string :
121+ return s
122+ else :
123+ print (s )
121124
122125def input_help ():
123126 s = [
Original file line number Diff line number Diff line change @@ -129,13 +129,18 @@ def __getattr__(self, name):
129129 def __getitem__ (self , name ):
130130 return self .__getattr__ (name )
131131
132- def help (self , name = None ):
132+ def help (self , name = None , return_as_string = False ):
133133 if name :
134134 if name .upper () == 'INPUT' :
135- return input_help ()
135+ return_val = input_help ()
136136 try :
137- return function_help (name )
137+ return_val = function_help (name , return_as_string )
138138 except KeyError :
139- return "Function '%s' does not exist." % name
139+ return_val = "Function '%s' does not exist." % name
140140 else :
141- return list_functions ()
141+ return_val = list_functions ()
142+
143+ if return_as_string :
144+ return return_val
145+ elif return_val :
146+ print (return_val )
Original file line number Diff line number Diff line change 1616
1717setup (
1818 name = 'python-geosupport' ,
19- version = '1.0.2 ' ,
19+ version = '1.0.3 ' ,
2020 url = 'https://github.com/ishiland/python-geosupport' ,
2121 description = 'Python bindings for NYC Geosupport Desktop Edition' ,
2222 long_description = long_description ,
Original file line number Diff line number Diff line change 1+ import io
2+ import sys
3+
14from ..testcase import TestCase
25
36class TestHelp (TestCase ):
47
58 def test_get_function_list (self ):
6- h = self .geosupport .help ()
9+ h = self .geosupport .help (return_as_string = True )
710
811 self .assertTrue ("1" in h )
912 self .assertTrue ("bbl" in h )
1013
1114 def test_function_help (self ):
12- h = self .geosupport .help ("bbl" )
15+ h = self .geosupport .help ("bbl" , return_as_string = True )
1316
1417 self .assertTrue ("Function BL processes" in h )
1518 self .assertTrue ("Input: Borough" in h )
@@ -18,6 +21,17 @@ def test_function_help(self):
1821 self .assertTrue ("Mode Switch" in h )
1922
2023 def test_invalid_function_help (self ):
21- h = self .geosupport .help ("fake" )
24+ h = self .geosupport .help ("fake" , return_as_string = True )
2225
2326 self .assertEqual (h , "Function 'fake' does not exist." )
27+
28+ def test_print (self ):
29+ h = io .StringIO ()
30+ sys .stdout = h
31+
32+ o = self .geosupport .help ()
33+
34+ sys .stdout = sys .__stdout__
35+
36+ self .assertTrue ("bbl" in h .getvalue ())
37+ self .assertTrue (o is None )
You can’t perform that action at this time.
0 commit comments