diff --git a/.flake8 b/.flake8 index 99c6e425717..03013aa973a 100644 --- a/.flake8 +++ b/.flake8 @@ -25,7 +25,7 @@ per-file-ignores = gui/wxpython/image2target/g.gui.image2target.py: E501 gui/wxpython/photo2image/g.gui.photo2image.py: E501 gui/wxpython/psmap/*: E501 - gui/wxpython/vdigit/*: E722, F405, F403 + gui/wxpython/vdigit/*: F405, F403 gui/wxpython/animation/g.gui.animation.py: E501 gui/wxpython/tplot/g.gui.tplot.py: E501 gui/wxpython/iclass/g.gui.iclass.py: E501 diff --git a/gui/wxpython/vdigit/wxdigit.py b/gui/wxpython/vdigit/wxdigit.py index b4b7b0dfd7b..862b747481b 100644 --- a/gui/wxpython/vdigit/wxdigit.py +++ b/gui/wxpython/vdigit/wxdigit.py @@ -26,22 +26,156 @@ @author Martin Landa """ -import grass.script.core as grass - -from grass.pydispatch.signal import Signal +import os +import sys +from ctypes import byref, c_double, c_int, create_string_buffer, pointer -from core.gcmd import GError +import grass.script.core as grass from core.debug import Debug +from core.gcmd import GError from core.settings import UserSettings +from grass.lib.dbmi import ( + DB_C_TYPE_STRING, + DB_NEXT, + DB_OK, + DB_SEQUENTIAL, + db_append_string, + db_close_database_shutdown_driver, + db_convert_column_value_to_string, + db_execute_immediate, + db_fetch, + db_get_column_name, + db_get_column_sqltype, + db_get_column_value, + db_get_cursor_table, + db_get_string, + db_get_table_column, + db_get_table_number_of_columns, + db_init_handle, + db_init_string, + db_open_database, + db_open_select_cursor, + db_set_handle, + db_set_string, + db_shutdown_driver, + db_sqltype_to_Ctype, + db_start_driver, + db_test_value_isnull, + dbCursor, + dbHandle, + dbString, +) +from grass.lib.gis import ( + GMAPSET_MAX, + GNAME_MAX, + G_find_vector2, + G_free, + G_name_is_fully_qualified, +) +from grass.lib.vector import ( + GV_AREA, + GV_BOUNDARY, + GV_CENTROID, + GV_LINE, + GV_LINES, + GV_POINT, + GV_POINTS, + GV_TOPO_PSEUDO, + WITHOUT_Z, + Map_info, + Vect_append_point, + Vect_area_alive, + Vect_area_perimeter, + Vect_break_lines_list, + Vect_cat_set, + Vect_cidx_get_cat_by_index, + Vect_cidx_get_field_number, + Vect_cidx_get_num_cats_by_index, + Vect_cidx_get_num_fields, + Vect_close, + Vect_delete_line, + Vect_destroy_boxlist, + Vect_destroy_cats_struct, + Vect_destroy_line_struct, + Vect_destroy_list, + Vect_field_cat_del, + Vect_get_area_area, + Vect_get_area_boundaries, + Vect_get_area_centroid, + Vect_get_area_points, + Vect_get_centroid_area, + Vect_get_dblink, + Vect_get_field, + Vect_get_finfo_geometry_type, + Vect_get_finfo_topology_info, + Vect_get_line_areas, + Vect_get_line_box, + Vect_get_line_type, + Vect_get_mapset, + Vect_get_name, + Vect_get_num_dblinks, + Vect_get_num_lines, + Vect_get_num_updated_lines, + Vect_get_point_in_area, + Vect_get_updated_line, + Vect_get_updated_line_offset, + Vect_is_3d, + Vect_line_alive, + Vect_line_check_intersection, + Vect_line_length, + Vect_list_append, + Vect_new_boxlist, + Vect_new_cats_struct, + Vect_new_line_struct, + Vect_new_list, + Vect_open_old, + Vect_points_distance, + Vect_read_line, + Vect_reset_cats, + Vect_reset_line, + Vect_reset_updated, + Vect_restore_line, + Vect_rewrite_line, + Vect_select_lines_by_box, + Vect_select_lines_by_polygon, + Vect_set_updated, + Vect_snap_lines_list, + Vect_write_line, + bound_box, +) +from grass.lib.vedit import ( + NO_SNAP, + SNAP, + SNAPVERTEX, + Vedit_add_vertex, + Vedit_bulk_labeling, + Vedit_chtype_lines, + Vedit_connect_lines, + Vedit_copy_lines, + Vedit_delete_area_centroid, + Vedit_delete_lines, + Vedit_flip_lines, + Vedit_merge_lines, + Vedit_move_lines, + Vedit_move_vertex, + Vedit_remove_vertex, + Vedit_select_by_query, + Vedit_snap_line, + Vedit_split_lines, +) +from grass.pydispatch.signal import Signal from vdigit.wxdisplay import DisplayDriver, GetLastError -try: - from grass.lib.gis import * - from grass.lib.vector import * - from grass.lib.vedit import * - from grass.lib.dbmi import * -except (ImportError, OSError, TypeError) as e: - print("wxdigit.py: {}".format(e), file=sys.stderr) +# Define missing constants +QUERY_UNKNOWN = 0 +QUERY_LENGTH = 1 +QUERY_DANGLE = 2 + +none = None # Python's None for C compatibility +ret = 0 # Initialize return value +line = Vect_new_line_struct() # Create new line structure +changeset = [] # Initialize changeset list +new_bboxs = [] # Initialize new bboxes list class VDigitError: @@ -1943,7 +2077,7 @@ def _addFeature(self, ftype, coords, layer, cat, snap, threshold): ) if newc < 0: self._error.WriteLine() - return len(fids, fids) + return len(fids), fids fids.append(newc) Vect_destroy_line_struct(bpoints)