3838 "UNDERLINE" : "\033 [4m" ,
3939}
4040
41+
4142def list_fetched_functions (fetched_functions : list ) -> None :
4243 """Simply lists out the functions described in fetch.py along with their DocString
43-
44+
4445 :param fetched_functions: List of function names along with their references in a tuple set
4546 :type fetched_functions: list
4647
@@ -51,16 +52,15 @@ def list_fetched_functions(fetched_functions: list) -> None:
5152 # Through each tuple in the format (name, reference)
5253 for index , function in enumerate (fetched_functions ):
5354
54- # Print out ...
55+ # Print out ...
5556 print (
56-
5757 # ... an index for the function, then the name of the function in cyan color ...
5858 f"{ index + 1 } . { colors ['OKCYAN' ]} { function [0 ]} { colors ['ENDC' ]} "
59-
6059 # ... then print the docstring as well
6160 f"- { function [1 ].__doc__ } "
6261 )
6362
63+
6464def save_as_geojson (data : dict ) -> None :
6565 """Saves the resulting geojson dictionary in a file tagged .geojson
6666
@@ -74,11 +74,14 @@ def save_as_geojson(data: dict) -> None:
7474 # TODO: Test if this works perfectly fine in Windows, since it uses the `os` package
7575
7676 # Save the file at the given path, create it if it does not exist
77- with open (f'{ os .path .abspath ("." )} /data/{ sys .argv [2 ]} .geojson' , mode = 'w' ) as geojson_file :
78-
77+ with open (
78+ f'{ os .path .abspath ("." )} /data/{ sys .argv [2 ]} .geojson' , mode = "w"
79+ ) as geojson_file :
80+
7981 # Save the dictionary as a json in a clean formatted way
8082 json .dump (data , geojson_file , sort_keys = True , indent = 4 )
8183
84+
8285def main ():
8386 """Main logic for the CLI"""
8487
@@ -88,18 +91,14 @@ def main():
8891 # If there are insufficient arguments
8992 if len (sys .argv ) < 3 :
9093
91- # Log an error ...
94+ # Log an error ...
9295 logging .error (
93-
9496 # ... indicating the source of the error ...
9597 " - client.py\n "
96-
9798 # ... the reason for the error ...
9899 f"{ colors ['FAIL' ]} Invalid format!{ colors ['ENDC' ]} \n "
99-
100100 # ... giving the user a format for the colors ...
101101 f"Try: python client.py { colors ['BOLD' ]} 'MLY|XXX'{ colors ['ENDC' ]} "
102-
103102 # ... format of the function called
104103 f"{ colors ['OKCYAN' ]} fetch_function_here{ colors ['ENDC' ]} \n "
105104 )
@@ -127,21 +126,18 @@ def main():
127126 # If the results ends up empty
128127 if result == {}:
129128
130- # Log an error ...
129+ # Log an error ...
131130 logging .error (
132-
133- # ... indicating the source of the error ...
131+ # ... indicating the source of the error ...
134132 " - client.py\n "
135-
136- # ... the reason for the error
133+ # ... the reason for the error
137134 f"{ colors ['FAIL' ]} Unrecognized function call!{ colors ['ENDC' ]} \n "
138135 )
139136
140137 # Finally, list the functions for the user
141138 list_fetched_functions (fetched_functions = fetched_functions )
142139
143140 # Saving the data
144- # TODO: Assumes user is working in Linux!
145141 save_as_geojson (result )
146142
147143
0 commit comments