From e99f979b44d6e129cd988145ca3d19bd616fd341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 1 Jul 2024 02:11:55 -0400 Subject: [PATCH] style: Fixes unnecessary-collection-call (C408) for empty collections (#3945) * style: Fixes unnecessary-collection-call (C408) for empty collections Only applies fixes to empty collections by `ruff check --select "C408" --unsafe-fixes --fix --config "lint.flake8-comprehensions.allow-dict-calls-with-keyword-arguments = true"` in order to limit the review scope. * style: apply black * Apply suggestions from code review --------- Co-authored-by: Stefan Blumentrath --- gui/wxpython/animation/frame.py | 2 +- gui/wxpython/animation/provider.py | 2 +- gui/wxpython/core/render.py | 20 ++-- gui/wxpython/core/settings.py | 10 +- gui/wxpython/core/units.py | 4 +- gui/wxpython/core/utils.py | 18 ++-- gui/wxpython/core/workspace.py | 12 +-- gui/wxpython/datacatalog/tree.py | 4 +- gui/wxpython/dbmgr/base.py | 2 +- gui/wxpython/dbmgr/dialogs.py | 2 +- gui/wxpython/dbmgr/vinfo.py | 4 +- gui/wxpython/gmodeler/canvas.py | 10 +- gui/wxpython/gmodeler/dialogs.py | 24 ++--- gui/wxpython/gmodeler/model.py | 104 ++++++++++---------- gui/wxpython/gmodeler/panels.py | 2 +- gui/wxpython/gui_core/dialogs.py | 10 +- gui/wxpython/gui_core/forms.py | 14 +-- gui/wxpython/gui_core/ghelp.py | 12 +-- gui/wxpython/gui_core/gselect.py | 22 ++--- gui/wxpython/gui_core/menu.py | 2 +- gui/wxpython/gui_core/preferences.py | 4 +- gui/wxpython/gui_core/prompt.py | 26 ++--- gui/wxpython/gui_core/toolbars.py | 2 +- gui/wxpython/gui_core/vselect.py | 6 +- gui/wxpython/gui_core/widgets.py | 6 +- gui/wxpython/iclass/frame.py | 2 +- gui/wxpython/icons/grass_icons.py | 2 +- gui/wxpython/image2target/ii2t_gis_set.py | 2 +- gui/wxpython/iscatt/dialogs.py | 2 +- gui/wxpython/lmgr/frame.py | 6 +- gui/wxpython/lmgr/layertree.py | 2 +- gui/wxpython/lmgr/workspace.py | 2 +- gui/wxpython/location_wizard/wizard.py | 12 +-- gui/wxpython/main_window/frame.py | 6 +- gui/wxpython/mapdisp/frame.py | 2 +- gui/wxpython/mapdisp/main.py | 6 +- gui/wxpython/mapdisp/statusbar.py | 2 +- gui/wxpython/mapwin/buffered.py | 4 +- gui/wxpython/modules/colorrules.py | 2 +- gui/wxpython/modules/extensions.py | 10 +- gui/wxpython/modules/import_export.py | 6 +- gui/wxpython/modules/mcalc_builder.py | 2 +- gui/wxpython/nviz/mapwindow.py | 16 +-- gui/wxpython/nviz/tools.py | 8 +- gui/wxpython/nviz/workspace.py | 16 +-- gui/wxpython/psmap/dialogs.py | 12 +-- gui/wxpython/psmap/frame.py | 2 +- gui/wxpython/psmap/instructions.py | 6 +- gui/wxpython/tools/update_menudata.py | 8 +- gui/wxpython/vdigit/mapwindow.py | 4 +- gui/wxpython/vdigit/preferences.py | 2 +- gui/wxpython/vdigit/wxdigit.py | 20 ++-- gui/wxpython/vdigit/wxdisplay.py | 32 +++--- gui/wxpython/wxplot/dialogs.py | 6 +- python/grass/grassdb/checks.py | 2 +- python/grass/grassdb/history.py | 4 +- python/grass/pygrass/raster/category.py | 2 +- python/grass/pygrass/vector/table.py | 2 +- python/grass/script/core.py | 8 +- python/grass/script/raster.py | 4 +- python/grass/script/task.py | 12 +-- python/grass/script/testsuite/test_utils.py | 2 +- python/grass/script/vector.py | 8 +- python/grass/semantic_label/reader.py | 2 +- scripts/g.extension.all/g.extension.all.py | 2 +- scripts/g.extension/g.extension.py | 66 ++++++------- scripts/r.fillnulls/r.fillnulls.py | 8 +- utils/thumbnails.py | 2 +- 68 files changed, 323 insertions(+), 327 deletions(-) diff --git a/gui/wxpython/animation/frame.py b/gui/wxpython/animation/frame.py index e5bbd389d4c..9e15dfcf595 100644 --- a/gui/wxpython/animation/frame.py +++ b/gui/wxpython/animation/frame.py @@ -118,7 +118,7 @@ def __init__( self._addPanes() self._mgr.Update() - self.dialogs = dict() + self.dialogs = {} self.dialogs["speed"] = None self.dialogs["preferences"] = None diff --git a/gui/wxpython/animation/provider.py b/gui/wxpython/animation/provider.py index c23cede79ef..46eddea7294 100644 --- a/gui/wxpython/animation/provider.py +++ b/gui/wxpython/animation/provider.py @@ -121,7 +121,7 @@ def SetCmds3D(self, cmds, region): def _getUniqueCmds(self): """Returns list of unique commands. Takes into account the region assigned.""" - unique = list() + unique = [] for cmdList, region in zip(self._cmdsForComposition, self._regions): for cmd in cmdList: if region: diff --git a/gui/wxpython/core/render.py b/gui/wxpython/core/render.py index 4f8479aaca7..73a0b89864f 100644 --- a/gui/wxpython/core/render.py +++ b/gui/wxpython/core/render.py @@ -118,7 +118,7 @@ def __init__( self.name = name if self.type == "command": - self.cmd = list() + self.cmd = [] for c in cmd: self.cmd.append(cmdlist_to_tuple(c)) else: @@ -670,9 +670,9 @@ def OnRenderDone(self, env): """ stopTime = time.time() - maps = list() - masks = list() - opacities = list() + maps = [] + masks = [] + opacities = [] # TODO: g.pnmcomp is now called every time # even when only overlays are rendered @@ -824,16 +824,16 @@ def __init__(self, gisrc=None): """ Debug.msg(1, "Map.__init__(): gisrc=%s" % gisrc) # region/extent settings - self.wind = dict() # WIND settings (wind file) - self.region = dict() # region settings (g.region) + self.wind = {} # WIND settings (wind file) + self.region = {} # region settings (g.region) self.width = 640 # map width self.height = 480 # map height # list of layers - self.layers = list() # stack of available GRASS layer + self.layers = [] # stack of available GRASS layer - self.overlays = list() # stack of available overlays - self.ovlookup = dict() # lookup dictionary for overlay items and overlays + self.overlays = [] # stack of available overlays + self.ovlookup = {} # lookup dictionary for overlay items and overlays # path to external gisrc self.gisrc = gisrc @@ -866,7 +866,7 @@ def GetProjInfo(self): def _projInfo(self): """Return region projection and map units information""" - projinfo = dict() + projinfo = {} if not grass.find_program("g.proj", "--help"): sys.exit( _("GRASS tool '%s' not found. Unable to start map " "display window.") diff --git a/gui/wxpython/core/settings.py b/gui/wxpython/core/settings.py index 0a6d11256d7..a4f2b60e3fd 100644 --- a/gui/wxpython/core/settings.py +++ b/gui/wxpython/core/settings.py @@ -1065,9 +1065,7 @@ def Get(self, group, key=None, subkey=None, settings_type="user"): else: return settings[group][key] else: - if isinstance(subkey, type(tuple())) or isinstance( - subkey, type(list()) - ): + if isinstance(subkey, tuple) or isinstance(subkey, list): return settings[group][key][subkey[0]][subkey[1]] else: return settings[group][key][subkey] @@ -1104,9 +1102,7 @@ def Set(self, group, value, key=None, subkey=None, settings_type="user"): else: settings[group][key] = value else: - if isinstance(subkey, type(tuple())) or isinstance( - subkey, type(list()) - ): + if isinstance(subkey, tuple) or isinstance(subkey, list): settings[group][key][subkey[0]][subkey[1]] = value else: settings[group][key][subkey] = value @@ -1201,7 +1197,7 @@ def Reset(self, key=None): def GetDisplayVectSettings(): - settings = list() + settings = [] if not UserSettings.Get( group="vectorLayer", key="featureColor", subkey=["transparent", "enabled"] ): diff --git a/gui/wxpython/core/units.py b/gui/wxpython/core/units.py index f2640710239..3947d205760 100644 --- a/gui/wxpython/core/units.py +++ b/gui/wxpython/core/units.py @@ -29,7 +29,7 @@ class BaseUnits: def __init__(self): - self._units = dict() + self._units = {} self._units["length"] = { 0: {"key": "mu", "label": _("map units")}, 1: {"key": "me", "label": _("meters")}, @@ -53,7 +53,7 @@ def GetUnitsList(self, type): :return: list of units labels """ - result = list() + result = [] try: keys = sorted(self._units[type].keys()) for idx in keys: diff --git a/gui/wxpython/core/utils.py b/gui/wxpython/core/utils.py index 86d73b1e954..7317c2f26a9 100644 --- a/gui/wxpython/core/utils.py +++ b/gui/wxpython/core/utils.py @@ -109,7 +109,7 @@ def GetLayerNameFromCmd(dcmd, fullyQualified=False, param=None, layerType=None): elif "d.graph" in dcmd[0]: mapname = "graph" else: - params = list() + params = [] for idx in range(len(dcmd)): try: p, v = dcmd[idx].split("=", 1) @@ -186,7 +186,7 @@ def GetLayerNameFromCmd(dcmd, fullyQualified=False, param=None, layerType=None): if i in mapsets and mapsets[i]: dcmd[i] += "@" + mapsets[i] - maps = list() + maps = [] ogr = False for i, p, v in params: if v.lower().rfind("@ogr") > -1: @@ -321,7 +321,7 @@ def ListSortLower(list): def GetVectorNumberOfLayers(vector): """Get list of all vector layers""" - layers = list() + layers = [] if not vector: return layers @@ -514,7 +514,7 @@ def ReadEpsgCodes(): :return: dictionary of EPSG code """ - epsgCodeDict = dict() + epsgCodeDict = {} ret = RunCommand("g.proj", read=True, list_codes="EPSG") @@ -570,7 +570,7 @@ def GetListOfLocations(dbase): :return: list of locations (sorted) """ - listOfLocations = list() + listOfLocations = [] try: for location in glob.glob(os.path.join(dbase, "*")): @@ -598,7 +598,7 @@ def GetListOfMapsets(dbase, location, selectable=False): :return: list of mapsets - sorted (PERMANENT first) """ - listOfMapsets = list() + listOfMapsets = [] if selectable: ret = RunCommand( @@ -625,7 +625,7 @@ def GetColorTables(): """Get list of color tables""" ret = RunCommand("r.colors", read=True, flags="l") if not ret: - return list() + return [] return ret.splitlines() @@ -835,8 +835,8 @@ def StoreEnvVariable(key, value=None, envFile=None): ) # read env file - environ = dict() - lineSkipped = list() + environ = {} + lineSkipped = [] if os.path.exists(envFile): try: fd = open(envFile) diff --git a/gui/wxpython/core/workspace.py b/gui/wxpython/core/workspace.py index b9efe693951..12fd08247a9 100644 --- a/gui/wxpython/core/workspace.py +++ b/gui/wxpython/core/workspace.py @@ -282,7 +282,7 @@ def __processLayer(self, layer): :param layer: tree node """ - cmd = list() + cmd = [] # # layer attributes (task) - 2D settings @@ -344,7 +344,7 @@ def __processOverlay(self, node_overlay): Process overlay item :param overlay: tree node """ - cmd = list() + cmd = [] cmd.append(node_overlay.get("name", "unknown")) @@ -374,12 +374,12 @@ def __processLayerVdigit(self, node_vdigit): :param node_vdigit: vdigit node """ # init nviz layer properties - vdigit = dict() + vdigit = {} for node in node_vdigit.findall("geometryAttribute"): if "geomAttr" not in vdigit: - vdigit["geomAttr"] = dict() + vdigit["geomAttr"] = {} type = node.get("type") - vdigit["geomAttr"][type] = dict() + vdigit["geomAttr"][type] = {} vdigit["geomAttr"][type]["column"] = node.get("column") # required # default map units vdigit["geomAttr"][type]["units"] = node.get("units", "mu") @@ -736,7 +736,7 @@ def __processLayerNvizNode(self, node, tag, cast, dc=None): else: value = None if dc: - dc[tag] = dict() + dc[tag] = {} dc[tag]["value"] = value else: return value diff --git a/gui/wxpython/datacatalog/tree.py b/gui/wxpython/datacatalog/tree.py index c1e97579734..f9c3b0a827b 100644 --- a/gui/wxpython/datacatalog/tree.py +++ b/gui/wxpython/datacatalog/tree.py @@ -503,13 +503,13 @@ def _reloadGrassDBNode(self, grassdb_node): except NotImplementedError: nprocs = 1 - results = dict() + results = {} errors = [] location_nodes = [] all_location_nodes = [] nlocations = len(locations) for location in locations: - results[location] = dict() + results[location] = {} varloc = self._model.AppendNode( parent=grassdb_node, data={"type": "location", "name": location} ) diff --git a/gui/wxpython/dbmgr/base.py b/gui/wxpython/dbmgr/base.py index 3ce82188587..0204152e6c4 100644 --- a/gui/wxpython/dbmgr/base.py +++ b/gui/wxpython/dbmgr/base.py @@ -1538,7 +1538,7 @@ def OnDataItemEdit(self, event): if dlg.ShowModal() == wx.ID_OK: values = dlg.GetValues() # string - updateList = list() + updateList = [] try: for i in range(len(values)): if i == keyId: # skip key column diff --git a/gui/wxpython/dbmgr/dialogs.py b/gui/wxpython/dbmgr/dialogs.py index c474d80f00f..5512ca7349c 100644 --- a/gui/wxpython/dbmgr/dialogs.py +++ b/gui/wxpython/dbmgr/dialogs.py @@ -745,7 +745,7 @@ def GetValues(self, columns=None): If columns is given (list), return only values of given columns. """ - valueList = list() + valueList = [] for labelId, ctypeId, valueId in self.widgets: column = self.FindWindowById(labelId).GetLabel() if columns is None or column in columns: diff --git a/gui/wxpython/dbmgr/vinfo.py b/gui/wxpython/dbmgr/vinfo.py index c6a4850e7e1..7c3d92dd6c0 100644 --- a/gui/wxpython/dbmgr/vinfo.py +++ b/gui/wxpython/dbmgr/vinfo.py @@ -124,9 +124,9 @@ def SelectByPoint(self, queryCoords, qdist): return None # process attributes - ret = dict() + ret = {} for key in ["Category", "Layer", "Table", "Id"]: - ret[key] = list() + ret[key] = [] for record in data: if "Table" not in record: diff --git a/gui/wxpython/gmodeler/canvas.py b/gui/wxpython/gmodeler/canvas.py index eeaa6909731..ddd21f7a848 100644 --- a/gui/wxpython/gmodeler/canvas.py +++ b/gui/wxpython/gmodeler/canvas.py @@ -109,7 +109,7 @@ def GetNewShapePos(self, yoffset=50): def GetShapesSelected(self): """Get list of selected shapes""" - selected = list() + selected = [] diagram = self.GetDiagram() for shape in diagram.GetShapeList(): if shape.Selected(): @@ -218,7 +218,7 @@ def OnProperties(self, event=None): shape.SetLabel(dlg.GetCondition()) model = self.frame.GetModel() ids = dlg.GetItems() - alist = list() + alist = [] for aId in ids["unchecked"]: action = model.GetItem(aId, objType=ModelAction) if action: @@ -243,7 +243,7 @@ def OnProperties(self, event=None): model = self.frame.GetModel() ids = dlg.GetItems() for b in ids.keys(): - alist = list() + alist = [] for aId in ids[b]["unchecked"]: action = model.GetItem(aId, objType=ModelAction) action.UnSetBlock(shape) @@ -294,7 +294,7 @@ def OnEndSize(self, x, y): def OnRightClick(self, x, y, keys=0, attachment=0): """Right click -> pop-up menu""" if not hasattr(self, "popupID"): - self.popupID = dict() + self.popupID = {} for key in ( "remove", "enable", @@ -444,7 +444,7 @@ def _onSelectShape(self, shape, append=False): shape.Select(False, dc) else: shapeList = canvas.GetDiagram().GetShapeList() - toUnselect = list() + toUnselect = [] if not append: for s in shapeList: diff --git a/gui/wxpython/gmodeler/dialogs.py b/gui/wxpython/gmodeler/dialogs.py index ec7585e80be..0ad1ebeb045 100644 --- a/gui/wxpython/gmodeler/dialogs.py +++ b/gui/wxpython/gmodeler/dialogs.py @@ -287,7 +287,7 @@ def GetPanel(self): def _getCmd(self): line = self.cmd_prompt.GetCurLine()[0].strip() if len(line) == 0: - cmd = list() + cmd = [] else: cmd = utils.split(str(line)) return cmd @@ -801,7 +801,7 @@ def GetData(self): def Populate(self, data): """Populate the list""" - self.itemDataMap = dict() + self.itemDataMap = {} i = 0 for name, values in data.items(): self.itemDataMap[i] = [ @@ -875,7 +875,7 @@ def OnRemoveAll(self, event): return self.DeleteAllItems() - self.itemDataMap = dict() + self.itemDataMap = {} self.parent.UpdateModelVariables() @@ -926,7 +926,7 @@ def __init__(self, parent, columns, frame, disablePopup=False, **kwargs): self.disablePopup = disablePopup ModelListCtrl.__init__(self, parent, columns, frame, **kwargs) - self.itemIdMap = list() + self.itemIdMap = [] self.SetColumnWidth(0, 100) self.SetColumnWidth(1, 75) @@ -939,8 +939,8 @@ def GetData(self): def Populate(self, data): """Populate the list""" - self.itemDataMap = dict() - self.itemIdMap = list() + self.itemDataMap = {} + self.itemIdMap = [] if self.shape: items = self.frame.GetModel().GetItems(objType=ModelAction) @@ -956,11 +956,11 @@ def Populate(self, data): else: shapeItems = map(lambda x: x.GetId(), self.shape.GetItems(items)) else: - shapeItems = list() + shapeItems = [] i = 0 if len(self.columns) == 2: # ItemCheckList - checked = list() + checked = [] for action in data: if isinstance(action, ModelData) or action == self.shape: continue @@ -1065,7 +1065,7 @@ def OnRightUp(self, event): return if not hasattr(self, "popupId"): - self.popupID = dict() + self.popupID = {} self.popupID["remove"] = NewId() self.popupID["reload"] = NewId() self.Bind(wx.EVT_MENU, self.OnRemove, id=self.popupID["remove"]) @@ -1103,8 +1103,8 @@ def MoveItems(self, items, up): model = self.frame.GetModel() modelActions = model.GetItems(objType=ModelAction) - idxList = dict() - itemsToSelect = list() + idxList = {} + itemsToSelect = [] for i in items: if up: idx = i - 1 @@ -1154,7 +1154,7 @@ def OnCheckItem(self, index, flag): def GetItems(self): """Get list of selected actions""" - ids = {"checked": list(), "unchecked": list()} + ids = {"checked": [], "unchecked": []} # action ids start at 1 for i in range(self.GetItemCount()): diff --git a/gui/wxpython/gmodeler/model.py b/gui/wxpython/gmodeler/model.py index 0c162fe0038..76d8e98da8e 100644 --- a/gui/wxpython/gmodeler/model.py +++ b/gui/wxpython/gmodeler/model.py @@ -73,7 +73,7 @@ def __init__( giface, canvas=None, ): - self.items = list() # list of ordered items (action/loop/condition) + self.items = [] # list of ordered items (action/loop/condition) # model properties self.properties = { @@ -82,8 +82,8 @@ def __init__( "author": getpass.getuser(), } # model variables - self.variables = dict() - self.variablesParams = dict() + self.variables = {} + self.variablesParams = {} self.canvas = canvas self._giface = giface @@ -100,7 +100,7 @@ def GetItems(self, objType=None): if not objType: return self.items - result = list() + result = [] for item in self.items: if isinstance(item, objType): result.append(item) @@ -134,7 +134,7 @@ def GetNumItems(self, actionOnly=False): return len(self.GetItems()) def ReorderItems(self, idxList): - items = list() + items = [] for oldIdx, newIdx in idxList.items(): item = self.items.pop(oldIdx) items.append(item) @@ -210,7 +210,7 @@ def SetVariables(self, data): def Reset(self): """Reset model""" - self.items = list() + self.items = [] def RemoveItem(self, item, reference=None): """Remove item from model @@ -220,8 +220,8 @@ def RemoveItem(self, item, reference=None): :return: list of related items to remove/update """ - relList = list() - upList = list() + relList = [] + upList = [] doRemove = True if isinstance(item, ModelAction): @@ -269,7 +269,7 @@ def GetMaps(self, prompt): """Get list of maps of selected type :param prompt: to filter maps""" - maps = list() + maps = [] for data in self.GetData(): if prompt == data.GetPrompt(): mapName = data.GetValue() @@ -281,7 +281,7 @@ def GetMaps(self, prompt): def GetData(self): """Get list of data items""" - result = list() + result = [] dataItems = self.GetItems(objType=ModelData) for action in self.GetItems(objType=ModelAction): @@ -439,7 +439,7 @@ def LoadModel(self, filename): for condition in gxmXml.conditions: conditionItem = self.GetItem(condition["id"]) for b in condition["items"].keys(): - alist = list() + alist = [] for aId in condition["items"][b]: action = self.GetItem(aId) alist.append(action) @@ -485,7 +485,7 @@ def IsValid(self): def Validate(self): """Validate model, return None if model is valid otherwise error string""" - errList = list() + errList = [] variables = self.GetVariables().keys() pattern = re.compile(r"(.*)(%.+\s?)(.*)") @@ -532,9 +532,9 @@ def _substituteFile(self, item, params=None, checkOnly=False): :return: list of undefined variables """ - errList = list() + errList = [] - self.fileInput = dict() + self.fileInput = {} # collect ascii inputs for p in item.GetParams()["params"]: @@ -685,7 +685,7 @@ def Run(self, log, onDone, parent=None): GError(parent=parent, message="\n".join(err)) return - err = list() + err = [] for key, item in params.items(): for p in item["params"]: if p.get("value", "") == "": @@ -740,7 +740,7 @@ def Run(self, log, onDone, parent=None): ) pattern = re.compile("%" + condVar) # for vars()[condVar] in eval(condText): ? - vlist = list() + vlist = [] if condText[0] == "`" and condText[-1] == "`": # run command cmd, dcmd = gtask.cmdlist_to_tuple(condText[1:-1].split(" ")) @@ -789,9 +789,9 @@ def DeleteIntermediateData(self, log): def GetIntermediateData(self): """Get info about intermediate data""" - rast = list() - rast3d = list() - vect = list() + rast = [] + rast3d = [] + vect = [] for data in self.GetData(): if not data.IsIntermediate(): continue @@ -831,11 +831,11 @@ def IsParameterized(self): def Parameterize(self): """Return parameterized options""" - result = dict() + result = {} idx = 0 if self.variables: - params = list() - result["variables"] = {"flags": list(), "params": params, "idx": idx} + params = [] + result["variables"] = {"flags": [], "params": params, "idx": idx} for name, values in self.variables.items(): gtype = values.get("type", "string") if gtype in {"raster", "vector", "mapset", "file", "region", "dir"}: @@ -864,9 +864,9 @@ def Parameterize(self): "label": "", "guisection": "", "key_desc": "", - "values": list(), + "values": [], "parameterized": False, - "values_desc": list(), + "values_desc": [], "prompt": prompt, "element": element, "type": ptype, @@ -886,13 +886,13 @@ def Parameterize(self): if f.get("parameterized", False): if name not in result: increment = True - result[name] = {"flags": list(), "params": list(), "idx": idx} + result[name] = {"flags": [], "params": [], "idx": idx} result[name]["flags"].append(f) for p in params["params"]: if p.get("parameterized", False): if name not in result: increment = True - result[name] = {"flags": list(), "params": list(), "idx": idx} + result[name] = {"flags": [], "params": [], "idx": idx} result[name]["params"].append(p) if increment: idx += 1 @@ -906,10 +906,10 @@ class ModelObject: def __init__(self, id=-1, label=""): self.id = id # internal id, should be not changed self.label = "" - self.rels = list() # list of ModelRelations + self.rels = [] # list of ModelRelations self.isEnabled = True - self.inBlock = list() # list of related loops/conditions + self.inBlock = [] # list of related loops/conditions def __del__(self): pass @@ -947,7 +947,7 @@ def GetRelations(self, fdir=None): if fdir is None: return self.rels - result = list() + result = [] for rel in self.rels: if fdir == "from": if rel.GetFrom() == self: @@ -1001,7 +1001,7 @@ def GetBlockId(self): :return: list of ids """ - ret = list() + ret = [] for mo in self.inBlock: ret.append(mo.GetId()) @@ -1049,7 +1049,7 @@ def __init__( self.propWin = None - self.data = list() # list of connected data items + self.data = [] # list of connected data items self.isValid = False self.isParameterized = False @@ -1428,7 +1428,7 @@ def OnDraw(self, dc): def GetLog(self, string=True): """Get logging info""" - name = list() + name = [] for rel in self.GetRelations(): name.append(rel.GetLabel()) if name: @@ -1438,7 +1438,7 @@ def GetLog(self, string=True): def GetLabel(self): """Get list of names""" - name = list() + name = [] for rel in self.GetRelations(): name.append(rel.GetLabel()) @@ -1765,7 +1765,7 @@ def AddRelation(self, rel): def Clear(self): """Clear object, remove rels""" - self.rels = list() + self.rels = [] class ModelLoop(ModelItem, ogl.RectangleShape): @@ -1774,7 +1774,7 @@ def __init__( ): """Defines a loop""" ModelItem.__init__(self, parent, x, y, id, width, height, label, items) - self.itemIds = list() # unordered + self.itemIds = [] # unordered if not width: width = UserSettings.Get( @@ -1824,7 +1824,7 @@ def Update(self): def GetItems(self, items): """Get sorted items by id""" - result = list() + result = [] for item in items: if item.GetId() in self.itemIds: result.append(item) @@ -2009,13 +2009,13 @@ def __init__(self, tree): raise GException(_("Details: unsupported tag name '{0}'.").format(tagName)) # list of actions, data - self.properties = dict() - self.variables = dict() - self.actions = list() - self.data = list() - self.loops = list() - self.conditions = list() - self.comments = list() + self.properties = {} + self.variables = {} + self.actions = [] + self.data = [] + self.loops = [] + self.conditions = [] + self.comments = [] self._processWindow() self._processProperties() @@ -2170,14 +2170,14 @@ def _processData(self): display = False if data.find("display") is None else True - rels = list() + rels = [] for rel in data.findall("relation"): defrel = { "id": int(rel.get("id", -1)), "dir": rel.get("dir", "to"), "name": rel.get("name", ""), } - points = list() + points = [] for point in rel.findall("point"): x = self._filterValue(self._getNodeText(point, "x")) y = self._filterValue(self._getNodeText(point, "y")) @@ -2203,8 +2203,8 @@ def _processTask(self, node): :return: grassTask instance :return: None on error """ - cmd = list() - parameterized = list() + cmd = [] + parameterized = [] name = node.get("name", None) if not name: @@ -2249,7 +2249,7 @@ def _processLoops(self): for node in self.root.findall("loop"): pos, size = self._getDim(node) text = self._filterValue(self._getNodeText(node, "condition")).strip() - aid = list() + aid = [] for anode in node.findall("item"): try: aid.append(int(anode.text)) @@ -2271,7 +2271,7 @@ def _processConditions(self): for node in self.root.findall("if-else"): pos, size = self._getDim(node) text = self._filterValue(self._getNodeText(node, "condition")).strip() - aid = {"if": list(), "else": list()} + aid = {"if": [], "else": []} for b in aid.keys(): bnode = node.find(b) if bnode is None: @@ -2328,7 +2328,7 @@ def __init__(self, fd, model): self._variables() self._items() - dataList = list() + dataList = [] for action in model.GetItems(objType=ModelAction): for rel in action.GetRelations(): dataItem = rel.GetData() @@ -3694,7 +3694,7 @@ def __init__( self._model = model self._giface = giface self.params = params - self.tasks = list() # list of tasks/pages + self.tasks = [] # list of tasks/pages wx.Dialog.__init__( self, parent=parent, id=id, title=title, style=style, **kwargs @@ -3791,7 +3791,7 @@ def _createPage(self, name, params): def GetErrors(self): """Check for errors, get list of messages""" - errList = list() + errList = [] for task in self.tasks: errList += task.get_cmd_error() diff --git a/gui/wxpython/gmodeler/panels.py b/gui/wxpython/gmodeler/panels.py index 75e3654bd62..5aa0cf133ed 100644 --- a/gui/wxpython/gmodeler/panels.py +++ b/gui/wxpython/gmodeler/panels.py @@ -1475,7 +1475,7 @@ def OnAdd(self, event): def UpdateModelVariables(self): """Update model variables""" - variables = dict() + variables = {} for values in self.list.GetData().values(): name = values[0] variables[name] = {"type": str(values[1])} diff --git a/gui/wxpython/gui_core/dialogs.py b/gui/wxpython/gui_core/dialogs.py index e4c9cd50081..13283c01fd7 100644 --- a/gui/wxpython/gui_core/dialogs.py +++ b/gui/wxpython/gui_core/dialogs.py @@ -1139,7 +1139,7 @@ def GroupSelected(self): """Group was selected, check if changes were applied""" self._checkChange() group, s = self.GetSelectedGroup() - maps = list() + maps = [] groups = self.GetExistGroups() if group in groups: maps = self.GetGroupLayers(group) @@ -1179,7 +1179,7 @@ def SubGroupSelected(self): subgroup = self.subGroupSelect.GetValue().strip() group = self.currentGroup - gmaps = list() + gmaps = [] groups = self.GetExistGroups() self.subgmaps = {} @@ -1353,7 +1353,7 @@ def GetSelectedGroup(self): def GetGroupLayers(self, group, subgroup=None): """Get layers in group""" - kwargs = dict() + kwargs = {} kwargs["group"] = group if subgroup: kwargs["subgroup"] = subgroup @@ -1883,8 +1883,8 @@ def OnApply(self, event): def GetImageHandlers(image): """Get list of supported image handlers""" - lext = list() - ltype = list() + lext = [] + ltype = [] try: for h in image.GetHandlers(): lext.append(h.GetExtension()) diff --git a/gui/wxpython/gui_core/forms.py b/gui/wxpython/gui_core/forms.py index 96fad876eba..c9ec58461e9 100644 --- a/gui/wxpython/gui_core/forms.py +++ b/gui/wxpython/gui_core/forms.py @@ -197,7 +197,7 @@ def run(self): map = None # avoid running db.describe several times - cparams = dict() + cparams = {} cparams[map] = { "dbInfo": None, "layers": None, @@ -1216,7 +1216,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar isEnabled[defval] = "yes" # for multi checkboxes, this is an array of all wx IDs # for each individual checkbox - p["wxId"] = list() + p["wxId"] = [] idx = 0 for val in valuelist: try: @@ -2303,7 +2303,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar p["wxId"] = [self.win1.GetId()] def OnCheckItem(index=None, flag=None, event=None): - layers = list() + layers = [] geometry = None for layer, match, listId in self.win1.GetLayers(): if "|" in layer: @@ -2404,7 +2404,7 @@ def OnCheckItem(index=None, flag=None, event=None): pOpt = self.task.get_param(opt, element="name", raiseError=False) if pOpt and id: if "wxId-bind" not in p: - p["wxId-bind"] = list() + p["wxId-bind"] = [] p["wxId-bind"] += pOpt["wxId"] continue if p.get("gisprompt", False) is False: @@ -2574,7 +2574,7 @@ def _getValue(self, p): def OnFileLoad(self, event): """Load file to interactive input""" me = event.GetId() - win = dict() + win = {} for p in self.task.params: if "wxId" in p and me in p["wxId"]: win["file"] = self.FindWindowById(p["wxId"][0]) @@ -3091,7 +3091,7 @@ def __init__( self.checkError = checkError self.grass_task = None - self.cmd = list() + self.cmd = [] global _blackList if self.parent: @@ -3137,7 +3137,7 @@ def ParseCommand(self, cmd, completed=None): if "flags" in dcmd_params: self.grass_task.flags = dcmd_params["flags"] - err = list() + err = [] # update parameters if needed && validate command if len(cmd) > 1: i = 0 diff --git a/gui/wxpython/gui_core/ghelp.py b/gui/wxpython/gui_core/ghelp.py index 6c87b444081..1d0a74d19ad 100644 --- a/gui/wxpython/gui_core/ghelp.py +++ b/gui/wxpython/gui_core/ghelp.py @@ -387,8 +387,8 @@ def _pageContributors(self, extra=False): contribfile = os.path.join(os.getenv("GISBASE"), "contributors.csv") if os.path.exists(contribfile): contribFile = codecs.open(contribfile, encoding="utf-8", mode="r") - contribs = list() - errLines = list() + contribs = [] + errLines = [] for line in contribFile.readlines()[1:]: line = line.rstrip("\n") try: @@ -472,8 +472,8 @@ def _pageTranslators(self): translatorsfile = os.path.join(os.getenv("GISBASE"), "translators.csv") if os.path.exists(translatorsfile): translatorsFile = codecs.open(translatorsfile, encoding="utf-8", mode="r") - translators = dict() - errLines = list() + translators = {} + errLines = [] for line in translatorsFile.readlines()[1:]: line = line.rstrip("\n") try: @@ -483,7 +483,7 @@ def _pageTranslators(self): continue for language in languages.split(" "): if language not in translators: - translators[language] = list() + translators[language] = [] translators[language].append((name, email)) translatorsFile.close() @@ -747,7 +747,7 @@ def __init__(self, parent, command, text, skipDescription, **kwargs): HtmlWindow.__init__(self, parent=parent, **kwargs) self.loaded = False - self.history = list() + self.history = [] self.historyIdx = 0 self.fspath = os.path.join(os.getenv("GISBASE"), "docs", "html") diff --git a/gui/wxpython/gui_core/gselect.py b/gui/wxpython/gui_core/gselect.py index 2a8c8547657..ae2d3669146 100644 --- a/gui/wxpython/gui_core/gselect.py +++ b/gui/wxpython/gui_core/gselect.py @@ -441,7 +441,7 @@ def Init(self): self.mapsets = None self.onPopup = None self.fullyQualified = True - self.extraItems = dict() + self.extraItems = {} self.SetFilter(None) self.tgis_error = False @@ -977,7 +977,7 @@ def InsertLayers(self, vector=None, dsn=None): :param str vector: vector map name (native or connected via v.external) :param str dsn: OGR data source name """ - layers = list() + layers = [] if vector: layers = GetVectorNumberOfLayers(vector) @@ -1407,14 +1407,14 @@ def __init__( else: ftype = "gdal" - formats = list() + formats = [] for f in GetFormats()[ftype][srcType].items(): formats += f self.SetItems(formats) def GetExtension(self, name): """Get file extension by format name""" - formatToExt = dict() + formatToExt = {} formatToExt.update(rasterFormatExtension) formatToExt.update(vectorFormatExtension) @@ -1462,7 +1462,7 @@ def __init__( self.inputBox.SetLabel(" %s " % _("Source input")) # source type - sources = list() + sources = [] self.sourceMap = {"file": -1, "dir": -1, "db": -1, "pro": -1, "native": -1} idx = 0 if dest: @@ -1724,7 +1724,7 @@ def _postInit(self, sourceType, data): if k == "dbname": dsn = v break - optList = list() + optList = [] for k, v in data.items(): if k in {"format", "conninfo", "topology"}: continue @@ -1964,7 +1964,7 @@ def _layout(self): def _getExtension(self, name): """Get file extension by format name""" - formatToExt = dict() + formatToExt = {} formatToExt.update(rasterFormatExtension) formatToExt.update(vectorFormatExtension) @@ -2204,7 +2204,7 @@ def SetDatabase(self, db): p = grass.Popen([self._psql, "-ltA"], stdout=grass.PIPE) ret = p.communicate()[0] if ret: - dbNames = list() + dbNames = [] for line in ret.splitlines(): sline = line.split("|") if len(sline) < 2: @@ -2309,8 +2309,8 @@ def getProjMatchCaption(projectionMatch): if not dsn: return - data = list() - listData = list() + data = [] + listData = [] layerId = 1 if self.ogr: @@ -2727,7 +2727,7 @@ def UpdateItems(self, dbase, location, mapset): project=location, mapset=mapset, ) - listMaps = list() + listMaps = [] if ret: for line in ret.splitlines(): listMaps.append(line.strip()) diff --git a/gui/wxpython/gui_core/menu.py b/gui/wxpython/gui_core/menu.py index 3c1376cea0d..71d6d153f8b 100644 --- a/gui/wxpython/gui_core/menu.py +++ b/gui/wxpython/gui_core/menu.py @@ -50,7 +50,7 @@ def __init__(self, parent, model, class_handler=None): """ self.parent = parent self.model = model - self.menucmd = dict() + self.menucmd = {} self.bmpsize = (16, 16) self.class_handler = class_handler if class_handler is not None else parent diff --git a/gui/wxpython/gui_core/preferences.py b/gui/wxpython/gui_core/preferences.py index 5b91d3f37e1..8d90f323afe 100644 --- a/gui/wxpython/gui_core/preferences.py +++ b/gui/wxpython/gui_core/preferences.py @@ -1818,7 +1818,7 @@ def _createProjectionPage(self, notebook): epsgCode = wx.ComboBox( parent=panel, id=wx.ID_ANY, name="GetValue", size=(150, -1) ) - self.epsgCodeDict = dict() + self.epsgCodeDict = {} epsgCode.SetValue( str(self.settings.Get(group="projection", key="statusbar", subkey="epsg")) ) @@ -2044,7 +2044,7 @@ def OnLoadEpsgCodes(self, event): caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE, ) - self.epsgCodeDict = dict() + self.epsgCodeDict = {} epsgCombo.SetItems([]) epsgCombo.SetValue("") self.FindWindowById(self.winId["projection:statusbar:proj4"]).SetValue("") diff --git a/gui/wxpython/gui_core/prompt.py b/gui/wxpython/gui_core/prompt.py index 8f7c02999d8..088465a976e 100644 --- a/gui/wxpython/gui_core/prompt.py +++ b/gui/wxpython/gui_core/prompt.py @@ -58,14 +58,14 @@ def __init__(self, parent, giface, menuModel): self.mapsetList = utils.ListOfMapsets() # auto complete items - self.autoCompList = list() + self.autoCompList = [] self.autoCompFilter = None # command description (gtask.grassTask) self.cmdDesc = None # list of traced commands - self.commands = list() + self.commands = [] # reload map lists when needed if giface: @@ -74,7 +74,7 @@ def __init__(self, parent, giface, menuModel): def _getListOfMaps(self): """Get list of maps""" - result = dict() + result = {} result["raster"] = grass.list_strings("raster") result["vector"] = grass.list_strings("vector") @@ -423,7 +423,7 @@ def GetWordLeft(self, withDelimiter=False, ignoredDelimiter=None): """ textLeft = self.GetTextLeft() - parts = list() + parts = [] if ignoredDelimiter is None: ignoredDelimiter = "" @@ -510,7 +510,7 @@ def OnChar(self, event): pos = self.GetCurrentPos() # complete command after pressing '.' if event.GetKeyCode() == 46: - self.autoCompList = list() + self.autoCompList = [] entry = self.GetTextLeft() self.InsertText(pos, ".") self.CharRight() @@ -537,7 +537,7 @@ def OnChar(self, event): or event.GetKeyCode() == wx.WXK_NUMPAD_SUBTRACT or event.GetKeyCode() == wx.WXK_SUBTRACT ): - self.autoCompList = list() + self.autoCompList = [] entry = self.GetTextLeft() self.InsertText(pos, "-") self.CharRight() @@ -555,7 +555,7 @@ def OnChar(self, event): # complete map or values after parameter elif event.GetKeyCode() == 61: - self.autoCompList = list() + self.autoCompList = [] self.InsertText(pos, "=") self.CharRight() self.toComplete = self.EntityToComplete() @@ -572,7 +572,7 @@ def OnChar(self, event): # complete mapset ('@') elif event.GetKeyCode() == 64: - self.autoCompList = list() + self.autoCompList = [] self.InsertText(pos, "@") self.CharRight() self.toComplete = self.EntityToComplete() @@ -583,7 +583,7 @@ def OnChar(self, event): # complete after pressing CTRL + Space elif event.GetKeyCode() == wx.WXK_SPACE and event.ControlDown(): - self.autoCompList = list() + self.autoCompList = [] self.toComplete = self.EntityToComplete() # complete command @@ -613,7 +613,7 @@ def OnChar(self, event): # r.colors | ...-w, -q, -l, color, map, rast, rules # r.colors color=grey | ...-w, -q, -l, color, map, rast, rules elif self.toComplete["entity"] == "params+flags" and self.cmdDesc: - self.autoCompList = list() + self.autoCompList = [] for param in self.cmdDesc.get_options()["params"]: self.autoCompList.append(param["name"]) @@ -629,13 +629,13 @@ def OnChar(self, event): # r.buffer input=| ...list of raster maps # r.buffer units=| ... feet, kilometers, ... elif self.toComplete["entity"] == "raster map": - self.autoCompList = list() + self.autoCompList = [] self.autoCompList = self.mapList["raster"] elif self.toComplete["entity"] == "vector map": - self.autoCompList = list() + self.autoCompList = [] self.autoCompList = self.mapList["vector"] elif self.toComplete["entity"] == "param values": - self.autoCompList = list() + self.autoCompList = [] param = self.GetWordLeft( withDelimiter=False, ignoredDelimiter="=" ).strip(" =") diff --git a/gui/wxpython/gui_core/toolbars.py b/gui/wxpython/gui_core/toolbars.py index 3293574a944..02e4fdecad5 100644 --- a/gui/wxpython/gui_core/toolbars.py +++ b/gui/wxpython/gui_core/toolbars.py @@ -245,7 +245,7 @@ def EnableAll(self, enable=True): def _getToolbarData(self, data): """Define tool""" - retData = list() + retData = [] for args in data: retData.append(self._defineTool(*args)) return retData diff --git a/gui/wxpython/gui_core/vselect.py b/gui/wxpython/gui_core/vselect.py index 7c4a8f4b386..6800773c6c6 100644 --- a/gui/wxpython/gui_core/vselect.py +++ b/gui/wxpython/gui_core/vselect.py @@ -247,7 +247,7 @@ def _draw(self): + "@" + self.selectedFeatures[0]["Mapset"] ) - tmp = list() + tmp = [] for i in self.selectedFeatures: tmp.append(i["Category"]) @@ -405,7 +405,7 @@ def __init__(self, mapdisp, giface): self.giface = giface self.layerCat = {} self.data = {} - self.data["Category"] = list() + self.data["Category"] = [] self.data["Map"] = None self.data["Layer"] = None @@ -419,7 +419,7 @@ def SetCats(self, cats): self.data["Category"] = cats def Clear(self): - self.data["Category"] = list() + self.data["Category"] = [] self.data["Map"] = None self.data["Layer"] = None self.mapdisp.RemoveQueryLayer() diff --git a/gui/wxpython/gui_core/widgets.py b/gui/wxpython/gui_core/widgets.py index 0f0905e756c..ca71f4a1cbe 100644 --- a/gui/wxpython/gui_core/widgets.py +++ b/gui/wxpython/gui_core/widgets.py @@ -1567,7 +1567,7 @@ def _loadSettings(self): :return: empty dict on error """ - data = dict() + data = {} if not os.path.exists(self.settingsFile): return data @@ -1602,7 +1602,7 @@ def _loadSettings_v2(self, fd_lines): :return: parsed dict :return: empty dict on error """ - data = dict() + data = {} for line in fd_lines[1:]: try: @@ -1657,7 +1657,7 @@ def _loadSettings_v1(self, fd_lines): :return: parsed dict :return: empty dict on error """ - data = dict() + data = {} for line in fd_lines: try: diff --git a/gui/wxpython/iclass/frame.py b/gui/wxpython/iclass/frame.py index e189c8b93cb..47106aa79f5 100644 --- a/gui/wxpython/iclass/frame.py +++ b/gui/wxpython/iclass/frame.py @@ -179,7 +179,7 @@ def __init__( self.exportVector = None # dialogs - self.dialogs = dict() + self.dialogs = {} self.dialogs["classManager"] = None self.dialogs["scatt_plot"] = None # just to make digitizer happy diff --git a/gui/wxpython/icons/grass_icons.py b/gui/wxpython/icons/grass_icons.py index e4cd9b55ed7..01cdbe655ca 100644 --- a/gui/wxpython/icons/grass_icons.py +++ b/gui/wxpython/icons/grass_icons.py @@ -12,7 +12,7 @@ iconPath = os.path.join(globalvar.ICONDIR, "grass") -iconSet = dict() +iconSet = {} for icon in os.listdir(iconPath): name, ext = os.path.splitext(icon) diff --git a/gui/wxpython/image2target/ii2t_gis_set.py b/gui/wxpython/image2target/ii2t_gis_set.py index 12ee5938849..6847ae3138a 100644 --- a/gui/wxpython/image2target/ii2t_gis_set.py +++ b/gui/wxpython/image2target/ii2t_gis_set.py @@ -898,7 +898,7 @@ def UpdateMapsets(self, location): """Update list of mapsets""" self.FormerMapsetSelection = wx.NOT_FOUND # for non-selectable item - self.listOfMapsetsSelectable = list() + self.listOfMapsetsSelectable = [] self.listOfMapsets = GetListOfMapsets(self.gisdbase, location) self.lbmapsets.Clear() diff --git a/gui/wxpython/iscatt/dialogs.py b/gui/wxpython/iscatt/dialogs.py index 5fad1990875..5ac172515fe 100644 --- a/gui/wxpython/iscatt/dialogs.py +++ b/gui/wxpython/iscatt/dialogs.py @@ -428,7 +428,7 @@ def __init__( gridSizer = wx.GridBagSizer(vgap=1, hgap=1) row = 0 - setts = dict() + setts = {} setts.update(self.colorsSetts) setts.update(self.sizeSetts) diff --git a/gui/wxpython/lmgr/frame.py b/gui/wxpython/lmgr/frame.py index d0ecee37047..4652d72925d 100644 --- a/gui/wxpython/lmgr/frame.py +++ b/gui/wxpython/lmgr/frame.py @@ -150,10 +150,10 @@ def show_menu_errors(messages): self._auimgr = wx.aui.AuiManager(self) # list of open dialogs - self.dialogs = dict() + self.dialogs = {} self.dialogs["preferences"] = None self.dialogs["nvizPreferences"] = None - self.dialogs["atm"] = list() + self.dialogs["atm"] = [] # create widgets self._createMenuBar() @@ -1090,7 +1090,7 @@ def GetMapDisplay(self, onlyCurrent=True): else: return None else: # -> return list of all mapdisplays - mlist = list() + mlist = [] for idx in range(0, self.notebookLayers.GetPageCount()): mlist.append(self.notebookLayers.GetPage(idx).maptree.GetMapDisplay()) diff --git a/gui/wxpython/lmgr/layertree.py b/gui/wxpython/lmgr/layertree.py index 450dc9340e0..f19f1c1ae76 100644 --- a/gui/wxpython/lmgr/layertree.py +++ b/gui/wxpython/lmgr/layertree.py @@ -405,7 +405,7 @@ def OnLayerContextMenu(self, event): Debug.msg(4, "LayerTree.OnContextMenu: layertype=%s" % ltype) if not hasattr(self, "popupID"): - self.popupID = dict() + self.popupID = {} for key in ( "remove", "rename", diff --git a/gui/wxpython/lmgr/workspace.py b/gui/wxpython/lmgr/workspace.py index 68b0a9a366f..15313803c4b 100644 --- a/gui/wxpython/lmgr/workspace.py +++ b/gui/wxpython/lmgr/workspace.py @@ -213,7 +213,7 @@ def Load(self, filename): # start map displays first (list of layers can be empty) # displayId = 0 - mapdisplay = list() + mapdisplay = [] for display in gxwXml.displays: mapdisp = self.lmgr.NewDisplay(name=display["name"], show=False) mapdisplay.append(mapdisp) diff --git a/gui/wxpython/location_wizard/wizard.py b/gui/wxpython/location_wizard/wizard.py index 3392aa0ddd0..bea1f424f0a 100644 --- a/gui/wxpython/location_wizard/wizard.py +++ b/gui/wxpython/location_wizard/wizard.py @@ -835,7 +835,7 @@ def __init__(self, wizard, parent): self.panel = None self.prjParamSizer = None - self.pparam = dict() + self.pparam = {} self.p4projparams = "" self.projdesc = "" @@ -954,7 +954,7 @@ def OnEnterPage(self, event): self.paramSBox.SetLabel( _(" Enter parameters for %s projection ") % self.projdesc ) - self.pparam = dict() + self.pparam = {} row = 0 for paramgrp in self.parent.projections[self.parent.projpage.proj][1]: # get parameters @@ -1757,10 +1757,10 @@ def OnBrowseCodes(self, event, search=None): message=_("Unable to read EPGS codes: {0}").format(e), showTraceback=False, ) - self.epsglist.Populate(list(), update=True) + self.epsglist.Populate([], update=True) return - data = list() + data = [] for code, val in self.epsgCodeDict.items(): if code is not None: data.append((code, val[0], val[1])) @@ -2033,10 +2033,10 @@ def OnBrowseCodes(self, event, search=None): message=_("Unable to read IAU codes: {0}").format(e), showTraceback=False, ) - self.epsglist.Populate(list(), update=True) + self.epsglist.Populate([], update=True) return - data = list() + data = [] for code, val in self.epsgCodeDict.items(): if code is not None: data.append((code, val[0], val[1])) diff --git a/gui/wxpython/main_window/frame.py b/gui/wxpython/main_window/frame.py index 52322b5c77c..058a71516b0 100644 --- a/gui/wxpython/main_window/frame.py +++ b/gui/wxpython/main_window/frame.py @@ -167,10 +167,10 @@ def show_menu_errors(messages): self._auimgr = SingleWindowAuiManager(self) # list of open dialogs - self.dialogs = dict() + self.dialogs = {} self.dialogs["preferences"] = None self.dialogs["nvizPreferences"] = None - self.dialogs["atm"] = list() + self.dialogs["atm"] = [] # set pane sizes according to the full screen size of the primary monitor self.PANE_BEST_SIZE = tuple(t // 5 for t in self.size) @@ -1241,7 +1241,7 @@ def GetMapDisplay(self, onlyCurrent=True): else: return None else: # -> return list of all mapdisplays - mlist = list() + mlist = [] for idx in range(0, self.notebookLayers.GetPageCount()): mlist.append(self.notebookLayers.GetPage(idx).maptree.GetMapDisplay()) diff --git a/gui/wxpython/mapdisp/frame.py b/gui/wxpython/mapdisp/frame.py index 2aecda9368c..bc8d52d2cb3 100644 --- a/gui/wxpython/mapdisp/frame.py +++ b/gui/wxpython/mapdisp/frame.py @@ -1146,7 +1146,7 @@ def _queryHighlight(self, vectQuery): self._highlighter_layer.SetMap( vectQuery[0]["Map"] + "@" + vectQuery[0]["Mapset"] ) - tmp = list() + tmp = [] for i in vectQuery: tmp.append(i["Category"]) diff --git a/gui/wxpython/mapdisp/main.py b/gui/wxpython/mapdisp/main.py index 25256bb2f0c..5bef25ad128 100644 --- a/gui/wxpython/mapdisp/main.py +++ b/gui/wxpython/mapdisp/main.py @@ -78,7 +78,7 @@ def __init__(self, giface, cmdfile=None, mapfile=None): self._giface = giface # environment settings - self.env = dict() + self.env = {} self.cmdfile = cmdfile @@ -169,7 +169,7 @@ def GetLayersFromCmdFile(self): # next number in rendering order next_layer = 0 mapFile = None - render_env = dict() + render_env = {} for line in lines: if line.startswith("#"): if "GRASS_RENDER_FILE" in line: @@ -254,7 +254,7 @@ def GetLayersFromCmdFile(self): ) if render_env: mapLayer.GetRenderMgr().UpdateRenderEnv(render_env) - render_env = dict() + render_env = {} newLayer = self._addLayer(mapLayer) diff --git a/gui/wxpython/mapdisp/statusbar.py b/gui/wxpython/mapdisp/statusbar.py index cec575bc555..3c819c2d765 100644 --- a/gui/wxpython/mapdisp/statusbar.py +++ b/gui/wxpython/mapdisp/statusbar.py @@ -75,7 +75,7 @@ def __init__(self, mapframe, statusbar): self.mapFrame = mapframe self.statusbar = statusbar - self.statusbarItems = dict() + self.statusbarItems = {} self._postInitialized = False self._modeIndexSet = False diff --git a/gui/wxpython/mapwin/buffered.py b/gui/wxpython/mapwin/buffered.py index c0c56365ff3..e87a50c43ba 100644 --- a/gui/wxpython/mapwin/buffered.py +++ b/gui/wxpython/mapwin/buffered.py @@ -1902,7 +1902,7 @@ def ZoomBack(self): """ Debug.msg(4, "BufferedWindow.ZoomBack(): hist)=%s" % self.zoomhistory) - zoom = list() + zoom = [] if len(self.zoomhistory) > 1: self.zoomhistory.pop() @@ -1984,7 +1984,7 @@ def InitZoomHistory(self): def ResetZoomHistory(self): """Reset zoom history""" - self.zoomhistory = list() + self.zoomhistory = [] def ZoomToMap(self, layers=None, ignoreNulls=False, render=True): """Set display extents to match selected raster diff --git a/gui/wxpython/modules/colorrules.py b/gui/wxpython/modules/colorrules.py index 87c03d0963a..979f9a9ca02 100644 --- a/gui/wxpython/modules/colorrules.py +++ b/gui/wxpython/modules/colorrules.py @@ -722,7 +722,7 @@ def ReadColorTable(self, ctable): self.rulesPanel.ruleslines[count]["value"] = value self.rulesPanel.ruleslines[count]["color"] = color self.rulesPanel.mainPanel.FindWindowById(count + 1000).SetValue(value) - rgb = list() + rgb = [] for c in color.split(":"): rgb.append(int(c)) self.rulesPanel.mainPanel.FindWindowById(count + 2000).SetColour(rgb) diff --git a/gui/wxpython/modules/extensions.py b/gui/wxpython/modules/extensions.py index 84d9aeba315..9fbeb6737e3 100644 --- a/gui/wxpython/modules/extensions.py +++ b/gui/wxpython/modules/extensions.py @@ -47,7 +47,7 @@ def __init__( ): self.parent = parent self._giface = giface - self.options = dict() # list of options + self.options = {} # list of options wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs) self.SetIcon( @@ -190,7 +190,7 @@ def _getCmd(self): name = item[0].data["command"] - flags = list() + flags = [] for key in self.options.keys(): if self.options[key].IsChecked(): if len(key) == 1: @@ -240,7 +240,7 @@ def Filter(self, text): def OnContextMenu(self, node): if not hasattr(self, "popupID"): - self.popupID = dict() + self.popupID = {} for key in ("install", "help"): self.popupID[key] = NewId() @@ -301,7 +301,7 @@ class ExtensionTreeModelBuilder: """Tree model of available extensions.""" def __init__(self): - self.mainNodes = dict() + self.mainNodes = {} self.model = TreeModel(ModuleNode) for prefix in ( "display", @@ -557,7 +557,7 @@ def LoadData(self): def GetExtensions(self): """Get extensions to be un-installed""" - extList = list() + extList = [] for i in range(self.GetItemCount()): if self.IsItemChecked(i): name = self.GetItemText(i) diff --git a/gui/wxpython/modules/import_export.py b/gui/wxpython/modules/import_export.py index 83d2b447bdd..c7b8897e783 100644 --- a/gui/wxpython/modules/import_export.py +++ b/gui/wxpython/modules/import_export.py @@ -53,8 +53,8 @@ def __init__( self.parent = parent # GMFrame self._giface = giface # used to add layers self.importType = itype - self.options = dict() # list of options - self.options_par = dict() + self.options = {} # list of options + self.options_par = {} self.commandId = -1 # id of running command @@ -902,7 +902,7 @@ def OnSetDsn(self, event): if not path: return - data = list() + data = [] ret = RunCommand( "v.in.dxf", quiet=True, parent=self, read=True, flags="l", input=path ) diff --git a/gui/wxpython/modules/mcalc_builder.py b/gui/wxpython/modules/mcalc_builder.py index 3c2b2526834..cccc4926bb9 100644 --- a/gui/wxpython/modules/mcalc_builder.py +++ b/gui/wxpython/modules/mcalc_builder.py @@ -176,7 +176,7 @@ def __init__( self.btn_copy = Button(parent=self.panel, id=wx.ID_ANY, label=_("Copy")) self.btn_copy.SetToolTip(_("Copy the current command string to the clipboard")) - self.btn = dict() + self.btn = {} self.btn["pow"] = Button(parent=self.panel, id=wx.ID_ANY, label="^") self.btn["pow"].SetToolTip(_("exponent")) self.btn["div"] = Button(parent=self.panel, id=wx.ID_ANY, label="/") diff --git a/gui/wxpython/nviz/mapwindow.py b/gui/wxpython/nviz/mapwindow.py index d00bcd3bc86..40fb23e6a38 100644 --- a/gui/wxpython/nviz/mapwindow.py +++ b/gui/wxpython/nviz/mapwindow.py @@ -134,15 +134,15 @@ def __init__(self, parent, giface, frame, Map, tree, lmgr, id=wx.ID_ANY): self.mouse = {"use": "pointer"} # list of loaded map layers (layer tree items) - self.layers = list() + self.layers = [] # list of constant surfaces - self.constants = list() + self.constants = [] # id of base surface (when vector is loaded and no surface exist) self.baseId = -1 # list of cutting planes - self.cplanes = list() + self.cplanes = [] # list of query points - self.qpoints = list() + self.qpoints = [] # list of past views self.viewhistory = [] self.saveHistory = False @@ -1013,7 +1013,7 @@ def ViewHistory(self, view, iview): def ResetViewHistory(self): """Reset view history""" - self.viewhistory = list() + self.viewhistory = [] def GoTo(self, e, n): """Focus on given point""" @@ -1454,8 +1454,8 @@ def UnloadDataLayers(self, force=False): def SetVectorSurface(self, data): """Set reference surfaces of vector""" data["mode"]["surface"] = {} - data["mode"]["surface"]["value"] = list() - data["mode"]["surface"]["show"] = list() + data["mode"]["surface"]["value"] = [] + data["mode"]["surface"]["show"] = [] for name in self.GetLayerNames("raster"): data["mode"]["surface"]["value"].append(name) data["mode"]["surface"]["show"].append(True) @@ -1635,7 +1635,7 @@ def NewConstant(self): name = self.constants[-1]["constant"]["object"]["name"] + 1 except IndexError: name = 1 - data = dict() + data = {} self.constants.append(data) data = self.SetMapObjProperties(item=index, id=-1, nvizType="constant") self.AddConstant(data, name) diff --git a/gui/wxpython/nviz/tools.py b/gui/wxpython/nviz/tools.py index c727c92d472..cff26db4ca8 100644 --- a/gui/wxpython/nviz/tools.py +++ b/gui/wxpython/nviz/tools.py @@ -2008,7 +2008,7 @@ def _createVectorPage(self, parent): def GselectOnPopup(self, ltype, exclude=False): """Update gselect.Select() items""" - maps = list() + maps = [] for layer in self.mapWindow.Map.GetListOfLayers(ltype=ltype, active=True): maps.append(layer.GetName()) return maps, exclude @@ -3242,7 +3242,7 @@ def _createControl( floatSlider=False, ): """Add control (Slider + TextCtrl)""" - data[name] = dict() + data[name] = {} if sliderHor: style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_BOTTOM sizeW = (size, -1) @@ -4145,8 +4145,8 @@ def OnVectorLines(self, event): mode["type"] = "surface" mode["surface"] = {} checklist = self.FindWindowById(self.win["vector"]["lines"]["surface"]) - value = list() - checked = list() + value = [] + checked = [] for surface in range(checklist.GetCount()): value.append(checklist.GetString(surface)) checked.append(checklist.IsChecked(surface)) diff --git a/gui/wxpython/nviz/workspace.py b/gui/wxpython/nviz/workspace.py index b6975d415dc..1e38aee239a 100644 --- a/gui/wxpython/nviz/workspace.py +++ b/gui/wxpython/nviz/workspace.py @@ -30,7 +30,7 @@ def __init__(self): def SetConstantDefaultProp(self): """Set default constant data properties""" - data = dict() + data = {} for key, value in UserSettings.Get(group="nviz", key="constant").items(): data[key] = value color = ( @@ -47,7 +47,7 @@ def SetConstantDefaultProp(self): def SetSurfaceDefaultProp(self, data=None): """Set default surface data properties""" if not data: - data = dict() + data = {} for sec in ("attribute", "draw", "mask", "position"): data[sec] = {} @@ -105,11 +105,11 @@ def SetSurfaceDefaultProp(self, data=None): def SetVolumeDefaultProp(self): """Set default volume data properties""" - data = dict() + data = {} for sec in ("attribute", "draw", "position"): - data[sec] = dict() + data[sec] = {} for sec in ("isosurface", "slice"): - data[sec] = list() + data[sec] = [] # # draw @@ -172,7 +172,7 @@ def SetVolumeDefaultProp(self): def SetIsosurfaceDefaultProp(self): """Set default isosurface properties""" - data = dict() + data = {} for attr in ("shine", "topo", "transp", "color", "inout"): data[attr] = {} data[attr]["update"] = None @@ -187,7 +187,7 @@ def SetIsosurfaceDefaultProp(self): def SetSliceDefaultProp(self): """Set default slice properties""" - data = dict() + data = {} data["position"] = copy.deepcopy( UserSettings.Get(group="nviz", key="volume", subkey="slice_position") ) @@ -201,7 +201,7 @@ def SetSliceDefaultProp(self): def SetVectorDefaultProp(self, longDim, data=None): """Set default vector data properties""" if not data: - data = dict() + data = {} for sec in ("lines", "points"): data[sec] = {} diff --git a/gui/wxpython/psmap/dialogs.py b/gui/wxpython/psmap/dialogs.py index 5fe648d9e18..7924b3d807e 100644 --- a/gui/wxpython/psmap/dialogs.py +++ b/gui/wxpython/psmap/dialogs.py @@ -263,7 +263,7 @@ def __init__(self, parent, id, title, settings, env, apply=True): self.Bind(wx.EVT_CLOSE, self.OnClose) def AddUnits(self, parent, dialogDict): - parent.units = dict() + parent.units = {} parent.units["unitsLabel"] = StaticText(parent, id=wx.ID_ANY, label=_("Units:")) choices = self.unitConv.getPageUnitsNames() parent.units["unitsCtrl"] = Choice(parent, id=wx.ID_ANY, choices=choices) @@ -273,7 +273,7 @@ def AddUnits(self, parent, dialogDict): def AddPosition(self, parent, dialogDict): if not hasattr(parent, "position"): - parent.position = dict() + parent.position = {} parent.position["comment"] = StaticText( parent, id=wx.ID_ANY, @@ -307,7 +307,7 @@ def AddPosition(self, parent, dialogDict): def AddExtendedPosition(self, panel, gridBagSizer, dialogDict): """Add widgets for setting position relative to paper and to map""" - panel.position = dict() + panel.position = {} positionLabel = StaticText(panel, id=wx.ID_ANY, label=_("Position is given:")) panel.position["toPaper"] = RadioButton( panel, id=wx.ID_ANY, label=_("relative to paper"), style=wx.RB_GROUP @@ -435,7 +435,7 @@ def AddExtendedPosition(self, panel, gridBagSizer, dialogDict): gridBagSizer.Add(sizerM, pos=(2, 1), flag=wx.ALIGN_LEFT | wx.EXPAND, border=0) def AddFont(self, parent, dialogDict, color=True): - parent.font = dict() + parent.font = {} # parent.font["fontLabel"] = wx.StaticText( # parent, id=wx.ID_ANY, label=_("Choose font:") # ) @@ -758,7 +758,7 @@ def OnChoice(self, event): currPaper = self.paperTable[self.getCtrl("Format").GetSelection()] currUnit = self.unitConv.findUnit(self.getCtrl("Units").GetStringSelection()) currOrientIdx = self.getCtrl("Orientation").GetSelection() - newSize = dict() + newSize = {} for item in self.cat[3:]: newSize[item] = self.unitConv.convert( float(currPaper[item]), fromUnit="inch", toUnit=currUnit @@ -782,7 +782,7 @@ def getCtrl(self, item): return self.hBoxDict[item].GetItem(1).GetWindow() def _toList(self, paperStr): - sizeList = list() + sizeList = [] for line in paperStr.strip().split("\n"): d = dict(zip([self.cat[1]] + self.cat[3:], line.split())) sizeList.append(d) diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 029b8fd03d0..26fa77053ef 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -146,7 +146,7 @@ def __init__( parent=self, objectsToDraw=self.objectId, env=self.env ) # open dialogs - self.openDialogs = dict() + self.openDialogs = {} self.pageId = NewId() # current page of GNotebook diff --git a/gui/wxpython/psmap/instructions.py b/gui/wxpython/psmap/instructions.py index e4cd59f09c6..f2d200601cc 100644 --- a/gui/wxpython/psmap/instructions.py +++ b/gui/wxpython/psmap/instructions.py @@ -59,7 +59,7 @@ def __init__(self, parent, objectsToDraw, env): self.parent = parent self.objectsToDraw = objectsToDraw # here are kept objects like mapinfo, rasterlegend, etc. - self.instruction = list() + self.instruction = [] self.env = env def __str__(self): @@ -545,7 +545,7 @@ def __init__(self, id, env): self.env = env # default values - self.defaultInstruction = dict() + self.defaultInstruction = {} # current values self.instruction = self.defaultInstruction # converting units @@ -863,7 +863,7 @@ def Read(self, instruction, text, **kwargs): return True def _toDict(self, paperStr): - sizeDict = dict() + sizeDict = {} # cats = self.subInstr[ 'Width', 'Height', 'Left', 'Right', 'Top', 'Bottom'] for line in paperStr.strip().split("\n"): d = dict(zip(self.cats, line.split()[1:])) diff --git a/gui/wxpython/tools/update_menudata.py b/gui/wxpython/tools/update_menudata.py index 051bc62cd2e..f3ea5f4b88a 100644 --- a/gui/wxpython/tools/update_menudata.py +++ b/gui/wxpython/tools/update_menudata.py @@ -34,7 +34,7 @@ def parseModules(): """Parse modules' interface""" - modules = dict() + modules = {} # list of modules to be ignored ignore = ["g.mapsets_picker.py", "v.type_wrapper.py", "g.parser", "vcolors"] @@ -66,12 +66,12 @@ def updateData(data, modules): # list of modules to be ignored ignore = ["v.type_wrapper.py", "vcolors"] - menu_modules = list() + menu_modules = [] for node in data.tree.iter(): if node.tag != "menuitem": continue - item = dict() + item = {} for child in node: item[child.tag] = child.text @@ -149,7 +149,7 @@ def main(argv=None): grass.info("Step 1: running make...") grass.call(["make"], stderr=nuldev) grass.info("Step 2: parsing modules...") - modules = dict() + modules = {} modules = parseModules() grass.info("Step 3: reading menu data...") data = LayerManagerMenuData() diff --git a/gui/wxpython/vdigit/mapwindow.py b/gui/wxpython/vdigit/mapwindow.py index 5e554d46393..fd98537c3be 100644 --- a/gui/wxpython/vdigit/mapwindow.py +++ b/gui/wxpython/vdigit/mapwindow.py @@ -460,11 +460,11 @@ def OnLeftDownMoveLine(self, event): """Left mouse button pressed - vector digitizer move feature/vertex, edit linear feature """ - self.moveInfo = dict() + self.moveInfo = {} # geographic coordinates of initial position (left-down) self.moveInfo["begin"] = None # list of ids to modify - self.moveInfo["id"] = list() + self.moveInfo["id"] = [] # set pen if self.toolbar.GetAction() in {"moveVertex", "editLine"}: diff --git a/gui/wxpython/vdigit/preferences.py b/gui/wxpython/vdigit/preferences.py index 8fdc65478f0..51c14943073 100644 --- a/gui/wxpython/vdigit/preferences.py +++ b/gui/wxpython/vdigit/preferences.py @@ -999,7 +999,7 @@ def UpdateSettings(self): column = self.FindWindowById(val["column"]).GetValue() unitsIdx = self.FindWindowById(val["units"]).GetSelection() if item and not tree.GetLayerInfo(item, key="vdigit"): - tree.SetLayerInfo(item, key="vdigit", value={"geomAttr": dict()}) + tree.SetLayerInfo(item, key="vdigit", value={"geomAttr": {}}) if checked: # enable if key == "area": diff --git a/gui/wxpython/vdigit/wxdigit.py b/gui/wxpython/vdigit/wxdigit.py index ac95eb32131..45342878360 100644 --- a/gui/wxpython/vdigit/wxdigit.py +++ b/gui/wxpython/vdigit/wxdigit.py @@ -177,13 +177,13 @@ def __init__(self, giface, mapwindow, driver=DisplayDriver): # self.SetCategory() # layer / max category - self.cats = dict() + self.cats = {} - self._settings = dict() + self._settings = {} self.UpdateSettings() # -> self._settings # undo/redo - self.changesets = list() + self.changesets = [] self.changesetCurrent = -1 # first changeset to apply if self.poMapInfo: @@ -391,7 +391,7 @@ def _addChangeset(self): del self.changesets[self.changesetCurrent + 1 : changesetLast + 1] self.toolbar.EnableRedo(False) - data = list() + data = [] for i in range(Vect_get_num_updated_lines(self.poMapInfo) - 1, -1, -1): line = Vect_get_updated_line(self.poMapInfo, i) offset = Vect_get_updated_line_offset(self.poMapInfo, i) @@ -536,7 +536,7 @@ def DeleteSelectedLines(self): # collect categories for deleting if requested deleteRec = UserSettings.Get(group="vdigit", key="delRecord", subkey="enabled") - catDict = dict() + catDict = {} old_bboxs = [] old_areas_cats = [] @@ -562,7 +562,7 @@ def DeleteSelectedLines(self): nlines = Vedit_delete_lines(self.poMapInfo, poList) Vect_destroy_list(poList) - self._display.selected["ids"] = list() + self._display.selected["ids"] = [] if nlines > 0: if deleteRec: @@ -1449,7 +1449,7 @@ def SelectLinesByQuery(self, bbox): ftype = GV_POINTS | GV_LINES # TODO: 3D layer = 1 # TODO - ids = list() + ids = [] poList = Vect_new_list() coList = poList.contents if UserSettings.Get(group="vdigit", key="query", subkey="box"): @@ -1838,7 +1838,7 @@ def _addFeature(self, ftype, coords, layer, cat, snap, threshold): :return: tuple (number of added features, list of fids) :return: number of features -1 on error """ - fids = list() + fids = [] if not self._checkMap(): return (-1, None) @@ -2063,7 +2063,7 @@ def GetLineCats(self, line): :return: list of layer/cats """ - ret = dict() + ret = {} if not self._checkMap(): return ret @@ -2085,7 +2085,7 @@ def GetLineCats(self, line): for i in range(cats.n_cats): field = cats.field[i] if field not in ret: - ret[field] = list() + ret[field] = [] ret[field].append(cats.cat[i]) return ret diff --git a/gui/wxpython/vdigit/wxdisplay.py b/gui/wxpython/vdigit/wxdisplay.py index 49603ba415a..8891908c2cb 100644 --- a/gui/wxpython/vdigit/wxdisplay.py +++ b/gui/wxpython/vdigit/wxdisplay.py @@ -128,9 +128,9 @@ def __init__(self, device, deviceTmp, mapObj, window, glog, gprogress): # selected objects self.selected = { "field": -1, # field number - "cats": list(), # list of cats - "ids": list(), # list of ids - "idsDupl": list(), # list of duplicated features + "cats": [], # list of cats + "ids": [], # list of ids + "idsDupl": [], # list of duplicated features } # digitizer settings @@ -350,7 +350,7 @@ def _drawObject(self, robj): ), ) else: - points = list() + points = [] for i in range(robj.npoints): p = robj.point[i] points.append(wx.Point(p.x, p.y)) @@ -536,7 +536,7 @@ def DrawMap(self, force=False): # reset list of selected features by cat # list of ids - see IsSelected() self.selected["field"] = -1 - self.selected["cats"] = list() + self.selected["cats"] = [] def _getSelectType(self): """Get type(s) to be selected @@ -596,7 +596,7 @@ def SelectLinesByBox(self, bbox, ltype=None, drawSeg=False, poMapInfo=None): self._drawSelected = True # select by ids - self.selected["cats"] = list() + self.selected["cats"] = [] poList = Vect_new_list() x1, y1 = bbox[0] @@ -689,7 +689,7 @@ def SelectLineByPoint(self, point, ltype=None, poMapInfo=None): if thisMapInfo: self._drawSelected = True # select by ids - self.selected["cats"] = list() + self.selected["cats"] = [] poFound = Vect_new_list() @@ -788,7 +788,7 @@ def GetSelected(self, grassId=True): if grassId: return self.selected["ids"] - dc_ids = list() + dc_ids = [] if not self._drawSegments: dc_ids.append(1) @@ -816,7 +816,7 @@ def SetSelected(self, ids, layer=-1): self.selected["field"] = layer if layer > 0: self.selected["cats"] = ids - self.selected["ids"] = list() + self.selected["ids"] = [] # cidx is not up-to-date # Vect_cidx_find_all(self.poMapInfo, # layer, GV_POINTS | GV_LINES, lid, ilist) @@ -853,7 +853,7 @@ def GetSelectedVertex(self, pos): :return: 0 no line found :return: -1 on error """ - returnId = list() + returnId = [] # only one object can be selected if len(self.selected["ids"]) != 1 or not self._drawSegments: return returnId @@ -1059,7 +1059,7 @@ def UpdateSettings(self, alpha=255): :param alpha: color value for alpha channel """ - color = dict() + color = {} for key in self.settings.keys(): if key == "lineWidth": self.settings[key] = int( @@ -1137,11 +1137,11 @@ def GetDuplicates(self): if not self.poMapInfo: return - ids = dict() + ids = {} APoints = Vect_new_line_struct() BPoints = Vect_new_line_struct() - self.selected["idsDupl"] = list() + self.selected["idsDupl"] = [] for i in range(len(self.selected["ids"])): line1 = self.selected["ids"][i] @@ -1158,7 +1158,7 @@ def GetDuplicates(self): if Vect_line_check_duplicate(APoints, BPoints, WITHOUT_Z): if i not in ids: - ids[i] = list() + ids[i] = [] ids[i].append((line1, self._getCatString(line1))) self.selected["idsDupl"].append(line1) @@ -1174,11 +1174,11 @@ def _getCatString(self, line): Vect_read_line(self.poMapInfo, None, self.poCats, line) cats = self.poCats.contents - catsDict = dict() + catsDict = {} for i in range(cats.n_cats): layer = cats.field[i] if layer not in catsDict: - catsDict[layer] = list() + catsDict[layer] = [] catsDict[layer].append(cats.cat[i]) catsStr = "" diff --git a/gui/wxpython/wxplot/dialogs.py b/gui/wxpython/wxplot/dialogs.py index ac23bb61547..d2273d7083c 100755 --- a/gui/wxpython/wxplot/dialogs.py +++ b/gui/wxpython/wxplot/dialogs.py @@ -271,13 +271,13 @@ def OnSetScattertypes(self, event): def GetRasterPairs(self): """Get raster pairs""" - pairsList = list() - pair = list() + pairsList = [] + pair = [] for r in self.rasterList: pair.append(r) if len(pair) == 2: pairsList.append(tuple(pair)) - pair = list() + pair = [] return list(pairsList) diff --git a/python/grass/grassdb/checks.py b/python/grass/grassdb/checks.py index 20c6ba9df6d..c1ef7cc76c2 100644 --- a/python/grass/grassdb/checks.py +++ b/python/grass/grassdb/checks.py @@ -617,7 +617,7 @@ def get_list_of_locations(dbase): :return: list of locations (sorted) """ - locations = list() + locations = [] for location in glob.glob(os.path.join(dbase, "*")): if os.path.join(location, "PERMANENT") in glob.glob( os.path.join(location, "*") diff --git a/python/grass/grassdb/history.py b/python/grass/grassdb/history.py index b9a90bd896c..2657632c9e1 100644 --- a/python/grass/grassdb/history.py +++ b/python/grass/grassdb/history.py @@ -80,7 +80,7 @@ def _read_from_plain_text(history_path): with 'command' and 'command_info' keys 'command_info' is always empty since plain text history file stores only executed commands.""" - content_list = list() + content_list = [] try: with open( history_path, encoding="utf-8", mode="r", errors="replace" @@ -103,7 +103,7 @@ def _read_from_JSON(history_path): :return content_list: list of dictionaries with 'command' and 'command_info' keys """ - content_list = list() + content_list = [] try: with open( history_path, encoding="utf-8", mode="r", errors="replace" diff --git a/python/grass/pygrass/raster/category.py b/python/grass/pygrass/raster/category.py index 88229752e1f..04049754954 100644 --- a/python/grass/pygrass/raster/category.py +++ b/python/grass/pygrass/raster/category.py @@ -93,7 +93,7 @@ def __list__(self): return cats def __dict__(self): - diz = dict() + diz = {} for cat in self.__iter__(): label, min_cat, max_cat = cat diz[(min_cat, max_cat)] = label diff --git a/python/grass/pygrass/vector/table.py b/python/grass/pygrass/vector/table.py index 48badee09f0..fa111318c19 100644 --- a/python/grass/pygrass/vector/table.py +++ b/python/grass/pygrass/vector/table.py @@ -150,7 +150,7 @@ def group_by(self, *groupby): def get_sql(self): """Return the SQL query""" - sql_list = list() + sql_list = [] if self._select is None: self.select() sql_list.append(self._select) diff --git a/python/grass/script/core.py b/python/grass/script/core.py index b0b8e11e826..3c05b0a58f4 100644 --- a/python/grass/script/core.py +++ b/python/grass/script/core.py @@ -155,8 +155,8 @@ def get_commands(*, env=None): gisbase = get_install_path() - cmd = list() - scripts = {".py": list()} if sys.platform == "win32" else {} + cmd = [] + scripts = {".py": []} if sys.platform == "win32" else {} def scan(gisbase, directory): dir_path = os.path.join(gisbase, directory) @@ -1459,7 +1459,7 @@ def list_strings(type, pattern=None, mapset=None, exclude=None, flag="", env=Non if type == "cell": verbose(_('Element type should be "raster" and not "%s"') % type) - result = list() + result = [] for line in read_command( "g.list", quiet=True, @@ -1807,7 +1807,7 @@ def create_project( shutil.rmtree(os.path.join(mapset_path.directory, mapset_path.location)) stdin = None - kwargs = dict() + kwargs = {} if datum: kwargs["datum"] = datum if datum_trans: diff --git a/python/grass/script/raster.py b/python/grass/script/raster.py index 4b3bfe656de..caf9a2a5b44 100644 --- a/python/grass/script/raster.py +++ b/python/grass/script/raster.py @@ -224,7 +224,7 @@ def raster_what(map, coord, env=None, localized=False): else: map_list = map - coord_list = list() + coord_list = [] if isinstance(coord, tuple): coord_list.append("%f,%f" % (coord[0], coord[1])) else: @@ -244,7 +244,7 @@ def raster_what(map, coord, env=None, localized=False): quiet=True, env=env, ) - data = list() + data = [] if not ret: return data diff --git a/python/grass/script/task.py b/python/grass/script/task.py index 6c181b9e27b..6a07c302d4a 100644 --- a/python/grass/script/task.py +++ b/python/grass/script/task.py @@ -48,11 +48,11 @@ class grassTask: def __init__(self, path=None, blackList=None): self.path = path self.name = _("unknown") - self.params = list() + self.params = [] self.description = "" self.label = "" - self.flags = list() - self.keywords = list() + self.flags = [] + self.keywords = [] self.errorMsg = "" self.firstParam = None if blackList: @@ -177,7 +177,7 @@ def get_cmd_error(self): :return: list of errors """ - errorList = list() + errorList = [] # determine if suppress_required flag is given for f in self.flags: if f["value"] and f["suppress_required"]: @@ -585,8 +585,8 @@ def command_info(cmd): cmdinfo["params"] = params = task.get_options()["params"] usage = task.get_name() - flags_short = list() - flags_long = list() + flags_short = [] + flags_long = [] for f in flags: fname = f.get("name", "unknown") if len(fname) > 1: diff --git a/python/grass/script/testsuite/test_utils.py b/python/grass/script/testsuite/test_utils.py index 0dce79eb001..acdf7fe157e 100644 --- a/python/grass/script/testsuite/test_utils.py +++ b/python/grass/script/testsuite/test_utils.py @@ -7,7 +7,7 @@ class EnvironChange(TestCase): - env = dict() + env = {} NOT_FOUND = "Not found!" def setUp(self): diff --git a/python/grass/script/vector.py b/python/grass/script/vector.py index 543e9654815..4a57b5db07b 100644 --- a/python/grass/script/vector.py +++ b/python/grass/script/vector.py @@ -130,9 +130,9 @@ def vector_columns(map, layer=None, getDict=True, env=None, **kwargs): "v.info", flags="c", map=map, layer=layer, quiet=True, env=env, **kwargs ) if getDict: - result = dict() + result = {} else: - result = list() + result = [] i = 0 for line in s.splitlines(): ctype, cname = line.split("|") @@ -397,7 +397,7 @@ def vector_what( else: layer_list = ["-1"] * len(map_list) - coord_list = list() + coord_list = [] if isinstance(coord, tuple): coord_list.append("%f,%f" % (coord[0], coord[1])) else: @@ -425,7 +425,7 @@ def vector_what( except CalledModuleError as e: raise ScriptError(e.msg) - data = list() + data = [] if not ret: return data diff --git a/python/grass/semantic_label/reader.py b/python/grass/semantic_label/reader.py index 3af558eccf6..bd19af69110 100644 --- a/python/grass/semantic_label/reader.py +++ b/python/grass/semantic_label/reader.py @@ -32,7 +32,7 @@ def __init__(self): def _read_config(self): """Read configuration""" - self.config = dict() + self.config = {} for json_file in self._json_files: try: with open(json_file) as fd: diff --git a/scripts/g.extension.all/g.extension.all.py b/scripts/g.extension.all/g.extension.all.py index e8a24f86fd0..14a928ff9a1 100644 --- a/scripts/g.extension.all/g.extension.all.py +++ b/scripts/g.extension.all/g.extension.all.py @@ -75,7 +75,7 @@ def get_extensions(): fo.close() libgis_rev = gscript.version()["libgis_revision"] - ret = list() + ret = [] for tnode in tree.findall("task"): gnode = tnode.find("libgis") if gnode is not None and gnode.get("revision", "") != libgis_rev: diff --git a/scripts/g.extension/g.extension.py b/scripts/g.extension/g.extension.py index 85753bd7dba..e8fc6f3a440 100644 --- a/scripts/g.extension/g.extension.py +++ b/scripts/g.extension/g.extension.py @@ -691,7 +691,7 @@ def get_installed_toolboxes(force=False): os.remove(xml_file) write_xml_toolboxes(xml_file) return [] - ret = list() + ret = [] for tnode in tree.findall("toolbox"): ret.append(tnode.get("code")) return ret @@ -718,7 +718,7 @@ def get_installed_modules(force=False): os.remove(xml_file) write_xml_modules(xml_file) return [] - ret = list() + ret = [] for tnode in tree.findall("task"): if flags["g"]: desc, keyw = get_optional_params(tnode) @@ -767,13 +767,13 @@ def list_available_extensions(url): def get_available_toolboxes(url): """Return toolboxes available in the repository""" - tdict = dict() + tdict = {} url = url + "toolboxes.xml" try: tree = etree_fromurl(url) for tnode in tree.findall("toolbox"): - mlist = list() - clist = list() + mlist = [] + clist = [] tdict[tnode.get("code")] = { "name": tnode.get("name"), "correlate": clist, @@ -798,7 +798,7 @@ def get_toolbox_extensions(url, name): :param name: toolbox name """ # dictionary of extensions - edict = dict() + edict = {} url = url + "toolboxes.xml" @@ -809,11 +809,11 @@ def get_toolbox_extensions(url, name): for enode in tnode.findall("task"): # extension name ename = enode.get("name") - edict[ename] = dict() + edict[ename] = {} # list of modules installed by this extension - edict[ename]["mlist"] = list() + edict[ename]["mlist"] = [] # list of files installed by this extension - edict[ename]["flist"] = list() + edict[ename]["flist"] = [] break except (HTTPError, OSError): gs.fatal(_("Unable to fetch addons metadata file")) @@ -982,7 +982,7 @@ def get_wxgui_extensions(url): :param url: a directory URL (filename will be attached) """ - mlist = list() + mlist = [] gs.debug( "Fetching list of wxGUI extensions from " "GRASS-Addons SVN repository (be patient)..." @@ -1175,12 +1175,12 @@ def install_extension(source=None, url=None, xmlurl=None, branch=None): gs.message(_("Installing toolbox <%s>...") % options["extension"]) edict = get_toolbox_extensions(xmlurl, options["extension"]) else: - edict = dict() - edict[options["extension"]] = dict() + edict = {} + edict[options["extension"]] = {} # list of modules installed by this extension - edict[options["extension"]]["mlist"] = list() + edict[options["extension"]]["mlist"] = [] # list of files installed by this extension - edict[options["extension"]]["flist"] = list() + edict[options["extension"]]["flist"] = [] if not edict: gs.warning(_("Nothing to install")) return @@ -1188,7 +1188,7 @@ def install_extension(source=None, url=None, xmlurl=None, branch=None): ret = 0 tmp_dir = None - new_modules = list() + new_modules = [] for extension in edict: ret1 = 0 new_modules_ext = None @@ -1253,15 +1253,15 @@ def get_toolboxes_metadata(url): and dictionary with dest, keyw, files keys as value, the second item is list of 'binary' files (installation files) """ - data = dict() + data = {} try: tree = etree_fromurl(url) for tnode in tree.findall("toolbox"): - clist = list() + clist = [] for cnode in tnode.findall("correlate"): clist.append(cnode.get("code")) - mlist = list() + mlist = [] for mnode in tnode.findall("task"): mlist.append(mnode.get("name")) @@ -1355,7 +1355,7 @@ def get_addons_metadata(url, mlist): name = mnode.get("name") if name not in mlist: continue - file_list = list() + file_list = [] bnode = mnode.find("binary") windows = sys.platform == "win32" if bnode is not None: @@ -1635,7 +1635,7 @@ def install_extension_win(name): ) # collect module names and file names - module_list = list() + module_list = [] module_name_pattern = re.compile( r"^([d,g,i,m,p,r,s,t,v]|^db|^ps|^r3|^wx)\..*[\.py,\.exe]$" ) @@ -1659,7 +1659,7 @@ def install_extension_win(name): replace_shebang_win(filename) # collect old files - old_file_list = list() + old_file_list = [] for r, d, f in os.walk(options["prefix"]): for filename in f: fullname = os.path.join(r, filename) @@ -1671,7 +1671,7 @@ def install_extension_win(name): ) # collect new files - file_list = list() + file_list = [] for r, d, f in os.walk(options["prefix"]): for filename in f: fullname = os.path.join(r, filename) @@ -1994,7 +1994,7 @@ def install_extension_std_platforms(name, source, url, branch): "Module name not found." " Check module Makefile syntax (PGM variable)." ) # collect module names - module_list = list() + module_list = [] for r, d, f in os.walk(srcdir): for filename in f: if filename == "Makefile": @@ -2087,7 +2087,7 @@ def install_extension_std_platforms(name, source, url, branch): return 0, None, None, None # collect old files - old_file_list = list() + old_file_list = [] for r, d, f in os.walk(options["prefix"]): for filename in f: fullname = os.path.join(r, filename) @@ -2097,7 +2097,7 @@ def install_extension_std_platforms(name, source, url, branch): ret = gs.call(install_cmd, stdout=outdev) # collect new files - file_list = list() + file_list = [] for r, d, f in os.walk(options["prefix"]): for filename in f: fullname = os.path.join(r, filename) @@ -2113,15 +2113,15 @@ def remove_extension(force=False): if flags["t"]: edict = get_toolbox_extensions(options["prefix"], options["extension"]) else: - edict = dict() - edict[options["extension"]] = dict() + edict = {} + edict[options["extension"]] = {} # list of modules installed by this extension - edict[options["extension"]]["mlist"] = list() + edict[options["extension"]]["mlist"] = [] # list of files installed by this extension - edict[options["extension"]]["flist"] = list() + edict[options["extension"]]["flist"] = [] # collect modules and files installed by these extensions - mlist = list() + mlist = [] xml_file = os.path.join(options["prefix"], "extensions.xml") if os.path.exists(xml_file): # read XML file @@ -2228,8 +2228,8 @@ def remove_extension_files(edict, force=False): # try to read XML metadata file first xml_file = os.path.join(options["prefix"], "extensions.xml") - einstalled = list() - eremoved = list() + einstalled = [] + eremoved = [] if os.path.exists(xml_file): tree = etree_fromfile(xml_file) @@ -2243,7 +2243,7 @@ def remove_extension_files(edict, force=False): for name in edict: removed = True if len(edict[name]["flist"]) > 0: - err = list() + err = [] for fpath in edict[name]["flist"]: gs.verbose(fpath) if force: diff --git a/scripts/r.fillnulls/r.fillnulls.py b/scripts/r.fillnulls/r.fillnulls.py index 7744d01ca25..b09ea17889d 100755 --- a/scripts/r.fillnulls/r.fillnulls.py +++ b/scripts/r.fillnulls/r.fillnulls.py @@ -108,8 +108,8 @@ import grass.script as grass from grass.exceptions import CalledModuleError -tmp_rmaps = list() -tmp_vmaps = list() +tmp_rmaps = [] +tmp_vmaps = [] usermask = None mapset = None @@ -151,7 +151,7 @@ def main(): unique = str(os.getpid()) # Shouldn't we use temp name? prefix = "r_fillnulls_%s_" % unique failed_list = ( - list() + [] ) # a list of failed holes. Caused by issues with v.surf.rst. Connected with #1813 # check if input file exists @@ -292,7 +292,7 @@ def main(): file=cats_file_name, quiet=quiet, ) - cat_list = list() + cat_list = [] cats_file = open(cats_file_name) for line in cats_file: cat_list.append(line.rstrip("\n")) diff --git a/utils/thumbnails.py b/utils/thumbnails.py index 310e60c1dbf..a42000089ef 100755 --- a/utils/thumbnails.py +++ b/utils/thumbnails.py @@ -39,7 +39,7 @@ def make_gradient(path): fh.close() lines = text.splitlines() - records = list() + records = [] for line in lines: if line.startswith("#"): # skip comments