def main(app, argv): script_name = os.path.basename(__file__) # options/arguments try: opts, args = getopt.getopt( argv, "h", [ "help" ] ) for opt, arg in opts: if opt in ("-h", "--help"): raise C_Exceptions.DisplayHelpError except getopt.GetoptError: C_Exceptions.OptionsError() C_Help.display(script_name) return except (C_Exceptions.DisplayHelpError): C_Help.display(script_name) return # list algorithms AlgorithmTools.list_all(app)
def main(argv): script_name = os.path.basename(__file__) try: # options/arguments + initialization print("Initialization...") aaif = Add(argv) # load input layer print("Loading input layer...") input_layer = aaif.create_vector_layer(aaif.get_input_layer_path(), script_name) # split input layer print("Adding autoincremental field...") aaif.add_autoincremental_field(processing, input_layer, aaif.get_field_name(), aaif.get_start(), aaif.get_output_file_path()) except ( \ C_Exceptions.DisplayHelpError, \ C_Exceptions.MissingArgumentsError, \ C_Exceptions.OptionsError): C_Help.display(script_name) except ( \ C_Exceptions.LoadVectorLayerError, \ C_Exceptions.LoadVectorLayerNotValidError, \ C_Exceptions.ProcessingError, \ C_Exceptions.UnexpectedError): pass except Exception as ex: C_Exceptions.UnexpectedError(ex)
def main(argv): script_name = os.path.basename(__file__) try: # options/arguments + initialization print("Initialization...") simplify = Simplify(argv) # load input layer print("Loading input layer...") input_layer = simplify.create_vector_layer(simplify.get_input_layer_path(), script_name) # simplify polygon print("Simplifying geometries...") simplify.simplify_geometries(processing, input_layer, simplify.get_method(), simplify.get_tolerance(), simplify.get_output_file_path()) except ( \ C_Exceptions.DisplayHelpError, \ C_Exceptions.MissingArgumentsError, \ C_Exceptions.OptionsError): C_Help.display(script_name) except ( \ C_Exceptions.LoadVectorLayerError, \ C_Exceptions.LoadVectorLayerNotValidError, \ C_Exceptions.ProcessingError, \ C_Exceptions.UnexpectedError): pass except Exception as ex: C_Exceptions.UnexpectedError(ex)
def main(argv): script_name = os.path.basename(__file__) try: # options/arguments + initialization print("Initialization...") cgrid = Create(argv) # load grid extent layer print("Loading grid extent layer...") grid_extent = cgrid.create_vector_layer(cgrid.get_grid_extent_path(), script_name) # create grid from extent layer print("Creating grid from extent layer...") cgrid.create_grid(processing, grid_extent) except ( \ C_Exceptions.DisplayHelpError, \ C_Exceptions.MissingArgumentsError, \ C_Exceptions.OptionsError): C_Help.display(script_name) except ( \ C_Exceptions.LoadVectorLayerError, \ C_Exceptions.LoadVectorLayerNotValidError, \ C_Exceptions.ProcessingError, \ C_Exceptions.UnexpectedError): pass except Exception as ex: C_Exceptions.UnexpectedError(ex)
def main(processing, argv): script_name = os.path.basename(__file__) provider = None algorithm = None # options/arguments try: opts, args = getopt.getopt(argv, "hp:a:", ["help", "provider=", "algorithm="]) for opt, arg in opts: if opt in ("-h", "--help"): raise C_Exceptions.DisplayHelpError elif opt in ("-p", "--provider"): provider = arg elif opt in ("-a", "--algorithm"): algorithm = arg if provider is None or algorithm is None: raise C_Exceptions.MissingArgumentsError except getopt.GetoptError: C_Exceptions.OptionsError() C_Help.display(script_name) return except (C_Exceptions.DisplayHelpError, C_Exceptions.MissingArgumentsError): C_Help.display(script_name) return # display algorithm usage help Tools.display_usage(processing, provider, algorithm)
def main(argv): script_name = os.path.basename(__file__) # options/arguments + initialization print("Initialization...") try: jabl = Join(argv) except (C_Exceptions.DisplayHelpError, C_Exceptions.MissingArgumentsError, C_Exceptions.OptionsError): C_Help.display(script_name) return # create join layer print("Creating join layer {}...".format(jabl.get_join_layer_name())) try: join_layer = jabl.create_join_layer() except (C_Exceptions.LoadVectorLayerError, C_Exceptions.LoadVectorLayerNotValidError, C_Exceptions.UnexpectedError): return except Exception as ex: C_Exceptions.UnknownError(ex) return # parse all input files print("Parsing input files...") path_list = jabl.get_input_path_list() for path in path_list: path_in_str = str(path) # create input file layer input_file = os.path.basename(path_in_str) print("Creating input layer for {}...".format(input_file)) try: input_layer = jabl.create_input_layer(input_file, path_in_str, input_file) except (C_Exceptions.LoadVectorLayerError, C_Exceptions.LoadVectorLayerNotValidError, C_Exceptions.UnexpectedError): continue except Exception as ex: C_Exceptions.UnknownError(ex) continue # join join-layer and input-layer output_file_name = os.path.splitext(input_file)[0] print("Joining with layer {}...".format(jabl.get_join_layer_name())) try: joined = jabl.join(processing, output_file_name, input_layer, join_layer) except Exception as ex: C_Exceptions.UnknownError(ex) if joined is not None: print(f"{joined} joined") else: print("Failed to join!")
def main(argv): script_name = os.path.basename(__file__) try: # options/arguments + initialization print("Initialization...") split = Split(argv) # load input layer print("Loading input layer...") input_layer = split.create_vector_layer(split.get_input_layer_path(), script_name) # load split layer print("Loading split layer...") split_layer = split.create_vector_layer(split.get_split_layer_path(), script_name) # split input layer print("Splitting input layer...") split.split_with_lines(processing, input_layer, split_layer, split.get_output_file_path()) except ( \ C_Exceptions.DisplayHelpError, \ C_Exceptions.MissingArgumentsError, \ C_Exceptions.OptionsError): C_Help.display(script_name) except ( \ C_Exceptions.LoadVectorLayerError, \ C_Exceptions.LoadVectorLayerNotValidError, \ C_Exceptions.ProcessingError, \ C_Exceptions.UnexpectedError): pass except Exception as ex: C_Exceptions.UnexpectedError(ex)