| Conditions | 5 |
| Total Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 16 | ||
| Bugs | 3 | Features | 6 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | from qpage import * |
||
| 112 | def main_handler(control_flag=True): |
||
| 113 | """ |
||
| 114 | Main Handler |
||
| 115 | :param control_flag: Check if VERSION control passed in prev step then Check for new VERSION of qpage |
||
| 116 | :type control_flag:bool |
||
| 117 | :return:None |
||
| 118 | call: |
||
| 119 | -generation_time |
||
| 120 | -create_folder |
||
| 121 | -print_logo |
||
| 122 | -address_print |
||
| 123 | -version_control |
||
| 124 | -sample_handler |
||
| 125 | -response_handler |
||
| 126 | -page_name_update |
||
| 127 | -main_handler_2 |
||
| 128 | -error_log |
||
| 129 | -logger |
||
| 130 | -close_files |
||
| 131 | -enter_to_exit |
||
| 132 | """ |
||
| 133 | try: |
||
| 134 | start_time = generation_time() |
||
| 135 | response = create_folder() # Check Folder and Files Status |
||
| 136 | address_print() # Print Files Location |
||
| 137 | if control_flag: # Check if VERSION control passed in prev step |
||
| 138 | print("QPAGE By S.Haghighi & M.M.Rahimi") |
||
| 139 | print("VERSION : " + VERSION) |
||
| 140 | print_logo() |
||
| 141 | version_control() # Check for new VERSION of qpage |
||
| 142 | response_handler(response) # call response_handler |
||
| 143 | sample_browser() |
||
| 144 | sample_handler() # run sample handler |
||
| 145 | clear_folder(OUT_DIR) # clear all of files in output directory |
||
| 146 | page_name_update() # update page names |
||
| 147 | main_handler_2(time_1=start_time) # call part_2 of main_handler |
||
| 148 | except FileNotFoundError as e: # error exception in FileNotFound ( When Something Missed) |
||
| 149 | error_log(e) |
||
| 150 | logger(False) # Add Failed Run to local logger file |
||
| 151 | error_handler() # call error_handler |
||
| 152 | except ValueError as e: |
||
| 153 | error_log(e) |
||
| 154 | print("Bad Input") |
||
| 155 | logger(False) # Add Failed Run to local logger file |
||
| 156 | close_files() # Close all of the opne files |
||
| 157 | enter_to_exit() # get input from user to continue |
||
| 158 | main_handler() # call part_1 of main_handler , restart from the first |
||
| 159 | except PermissionError as e: |
||
| 160 | error_log(e) |
||
| 161 | logger(False) # Add Failed Run to local logger file |
||
| 162 | print("Files Is Open By Another Program") |
||
| 163 | close_files() # Close all of the open files |
||
| 164 | enter_to_exit() # get input from user to continue |
||
| 165 | main_handler() # call part_1 of main_handler , restart from the first |
||
| 166 | if __name__ == "__main__": |
||
| 175 |