Skip to content

Commit

Permalink
Python: Python2 removal, remove Six from Requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-detiste committed Jul 12, 2023
1 parent e225508 commit 8b94066
Show file tree
Hide file tree
Showing 85 changed files with 245 additions and 497 deletions.
4 changes: 0 additions & 4 deletions REQUIREMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ Note: also the respective development packages (commonly named `xxx-dev` or
[https://matplotlib.org/](https://matplotlib.org/)
- **python-termcolor** (recommended for `g.search.modules`)
[https://pypi.org/project/termcolor/](https://pypi.org/project/termcolor/)
- **six** (`python-six`, needed for Python API and for cross-version Python
compatibility)
[https://pypi.python.org/pypi/six](https://pypi.python.org/pypi/six)
[https://github.com/benjaminp/six](https://github.com/benjaminp/six)
- **FFMPEG or alternative** (for wxGUI Animation tool - `g.gui.module`),
specifically ffmpeg tool
[https://ffmpeg.org](https://ffmpeg.org)
Expand Down
2 changes: 0 additions & 2 deletions gui/wxpython/animation/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
@author Anna Petrasova <kratochanna gmail.com>
"""

from __future__ import print_function

import os
import wx
import copy
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/animation/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import os
import wx
import wx.aui
import six

import grass.script as gcore
import grass.temporal as tgis
Expand Down Expand Up @@ -143,7 +142,7 @@ def _addPanes(self):
.DestroyOnClose(True)
.Layer(0),
)
for name, slider in six.iteritems(self.animationSliders):
for name, slider in self.animationSliders.items():
self._mgr.AddPane(
slider,
wx.aui.AuiPaneInfo()
Expand Down
7 changes: 1 addition & 6 deletions gui/wxpython/animation/nviztask.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
@author Anna Petrasova <kratochanna gmail.com>
"""

from __future__ import print_function

try:
import xml.etree.ElementTree as etree
except ImportError:
import elementtree.ElementTree as etree # Python <= 2.4
import xml.etree.ElementTree as etree

from core.workspace import ProcessWorkspaceFile
from core.gcmd import RunCommand, GException
Expand Down
2 changes: 0 additions & 2 deletions gui/wxpython/animation/temporal_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
@author Anna Kratochvilova <kratochanna gmail.com>
"""

from __future__ import print_function

import datetime

import grass.script as grass
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/animation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import os
import wx
import hashlib
import six
from multiprocessing import cpu_count

try:
Expand Down Expand Up @@ -99,7 +98,7 @@ def validateMapNames(names, etype):
raise GException(_("Map <%s> not found.") % name)
else:
found = False
for mapset, mapNames in six.iteritems(mapDict):
for mapset, mapNames in mapDict.items():
if name in mapNames:
found = True
newNames.append(name + "@" + mapset)
Expand Down
5 changes: 0 additions & 5 deletions gui/wxpython/core/gcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
@author Martin Landa <landa.martin gmail.com>
"""

from __future__ import print_function

import os
import sys
import time
Expand All @@ -53,9 +51,6 @@
from grass.script import core as grass
from grass.script.utils import decode, encode

if sys.version_info.major == 2:
bytes = str


def DecodeString(string):
"""Decode string using system encoding
Expand Down
5 changes: 1 addition & 4 deletions gui/wxpython/core/gthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@

import sys

if sys.version_info.major == 2:
import Queue
else:
import queue as Queue
import queue as Queue

from core.gconsole import EVT_CMD_DONE, wxCmdDone

Expand Down
8 changes: 1 addition & 7 deletions gui/wxpython/core/menutree.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,10 @@
@author Anna Petrasova <kratochanna gmail.com>
"""

from __future__ import print_function

import os
import sys
import copy

try:
import xml.etree.ElementTree as etree
except ImportError:
import elementtree.ElementTree as etree # Python <= 2.4
import xml.etree.ElementTree as etree

import wx

Expand Down
2 changes: 0 additions & 2 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
@author Luca Delucchi <lucadeluge gmail.com> (language choice)
"""

from __future__ import print_function

import os
import sys
import copy
Expand Down
2 changes: 0 additions & 2 deletions gui/wxpython/core/toolboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
@author Anna Petrasova <kratochanna gmail.com>
"""

from __future__ import print_function

import os
import sys
import copy
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/core/treemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@author Anna Petrasova <kratochanna gmail.com>
"""
import six
import copy

from grass.script.utils import naturally_sort
Expand Down Expand Up @@ -219,7 +218,7 @@ def children(self):
def nprint(self, text, indent=0):
text.append(indent * " " + self.label)
if self.data:
for key, value in six.iteritems(self.data):
for key, value in self.data.items():
text.append(
"%(indent)s* %(key)s : %(value)s"
% {"indent": (indent + 2) * " ", "key": key, "value": value}
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/core/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
@author Martin Landa <landa.martin gmail.com>
"""

import six
import math

if __name__ == "__main__":
Expand Down Expand Up @@ -80,7 +79,7 @@ def GetUnitsIndex(self, type, key):
:return: index
"""
for k, u in six.iteritems(self._units[type]):
for k, u in self._units[type].items():
if u["key"] == key:
return k
return 0
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import re
import inspect
import operator
import six

from grass.script import core as grass
from grass.script import task as gtask
Expand Down Expand Up @@ -878,7 +877,7 @@ def StoreEnvVariable(key, value=None, envFile=None):
else:
expCmd = "export"

for key, value in six.iteritems(environ):
for key, value in environ.items():
fd.write("%s %s=%s\n" % (expCmd, key, value))

# write also skipped lines
Expand Down
37 changes: 16 additions & 21 deletions gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
"""

import os
from io import StringIO

import wx
import six

try:
from StringIO import StringIO
except ImportError:
from io import StringIO

from core.utils import normalize_whitespace
from core.settings import UserSettings
Expand Down Expand Up @@ -1101,7 +1096,7 @@ def __writeLayer(self, mapTree, item):
# layer properties
self.file.write('%s<task name="%s">\n' % (" " * self.indent, cmd[0]))
self.indent += 4
for key, val in six.iteritems(cmd[1]):
for key, val in cmd[1].items():
if key == "flags":
for f in val:
self.file.write(
Expand Down Expand Up @@ -1130,7 +1125,7 @@ def __writeLayer(self, mapTree, item):
self.file.write("%s<vdigit>\n" % (" " * self.indent))
if "geomAttr" in vdigit:
self.indent += 4
for type, val in six.iteritems(vdigit["geomAttr"]):
for type, val in vdigit["geomAttr"].items():
units = ""
if val["units"] != "mu":
units = ' units="%s"' % val["units"]
Expand Down Expand Up @@ -1166,13 +1161,13 @@ def __writeNvizSurface(self, data):
self.indent += 4
self.file.write("%s<surface>\n" % (" " * self.indent))
self.indent += 4
for attrb in six.iterkeys(data):
for attrb in data.keys():
if len(data[attrb]) < 1: # skip empty attributes
continue
if attrb == "object":
continue

for name in six.iterkeys(data[attrb]):
for name in data[attrb].keys():
# surface attribute
if attrb == "attribute":
if data[attrb][name]["map"] is None:
Expand All @@ -1194,7 +1189,7 @@ def __writeNvizSurface(self, data):
if attrb == "draw":
self.file.write("%s<%s" % (" " * self.indent, attrb))
if "mode" in data[attrb]:
for tag, value in six.iteritems(data[attrb]["mode"]["desc"]):
for tag, value in data[attrb]["mode"]["desc"].items():
self.file.write(' %s="%s"' % (tag, value))
self.file.write(">\n") # <draw ...>

Expand Down Expand Up @@ -1252,14 +1247,14 @@ def __writeNvizVolume(self, data):
self.indent += 4
self.file.write("%s<volume>\n" % (" " * self.indent))
self.indent += 4
for attrb in six.iterkeys(data):
for attrb in data.keys():
if len(data[attrb]) < 1: # skip empty attributes
continue
if attrb == "object":
continue

if attrb == "attribute":
for name in six.iterkeys(data[attrb]):
for name in data[attrb].keys():
# surface attribute
if data[attrb][name]["map"] is None:
continue
Expand Down Expand Up @@ -1343,10 +1338,10 @@ def __writeNvizVolume(self, data):
if attrb == "isosurface":
for isosurface in data[attrb]:
self.file.write("%s<%s>\n" % (" " * self.indent, attrb))
for name in six.iterkeys(isosurface):
for name in isosurface.keys():
self.indent += 4
self.file.write("%s<%s>\n" % (" " * self.indent, name))
for att in six.iterkeys(isosurface[name]):
for att in isosurface[name].keys():
if isosurface[name][att] is True:
val = "1"
elif isosurface[name][att] is False:
Expand All @@ -1370,10 +1365,10 @@ def __writeNvizVolume(self, data):
if attrb == "slice":
for slice_ in data[attrb]:
self.file.write("%s<%s>\n" % (" " * self.indent, attrb))
for name in six.iterkeys(slice_):
for name in slice_.keys():
self.indent += 4
self.file.write("%s<%s>\n" % (" " * self.indent, name))
for att in six.iterkeys(slice_[name]):
for att in slice_[name].keys():
if att in ("map", "update"):
continue
val = slice_[name][att]
Expand Down Expand Up @@ -1401,7 +1396,7 @@ def __writeNvizVector(self, data):
:param data: Nviz layer properties
"""
self.indent += 4
for attrb in six.iterkeys(data):
for attrb in data.keys():
if len(data[attrb]) < 1: # skip empty attributes
continue

Expand All @@ -1421,7 +1416,7 @@ def __writeNvizVector(self, data):
'%s<v%s marker="%s">\n' % (" " * self.indent, attrb, marker)
)
self.indent += 4
for name in six.iterkeys(data[attrb]):
for name in data[attrb].keys():
if name in ("object", "marker"):
continue
if name == "mode":
Expand Down Expand Up @@ -1450,14 +1445,14 @@ def __writeNvizVector(self, data):
self.file.write("%s</%s>\n" % ((" " * self.indent, name)))
elif name == "thematic":
self.file.write("%s<%s " % (" " * self.indent, name))
for key in six.iterkeys(data[attrb][name]):
for key in data[attrb][name].keys():
if key.startswith("use"):
self.file.write(
'%s="%s" ' % (key, int(data[attrb][name][key]))
)
self.file.write(">\n")
self.indent += 4
for key, value in six.iteritems(data[attrb][name]):
for key, value in data[attrb][name].items():
if key.startswith("use"):
continue
if value is None:
Expand Down
6 changes: 2 additions & 4 deletions gui/wxpython/dbmgr/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
@author Refactoring by Stepan Turek <stepan.turek seznam.cz> (GSoC 2012, mentor: Martin Landa)
"""

import six

import wx
import wx.lib.scrolledpanel as scrolled

Expand Down Expand Up @@ -537,7 +535,7 @@ def UpdateDialog(self, map=None, query=None, cats=None, fid=-1, action=None):
ctype = columns[name]["ctype"]

if columns[name]["values"][idx] is not None:
if not isinstance(columns[name]["ctype"], six.string_types):
if not isinstance(columns[name]["ctype"], str):
value = str(columns[name]["values"][idx])
else:
value = columns[name]["values"][idx]
Expand Down Expand Up @@ -598,7 +596,7 @@ def SetColumnValue(self, layer, column, value):
table = self.mapDBInfo.GetTable(layer)
columns = self.mapDBInfo.GetTableDesc(table)

for key, col in six.iteritems(columns):
for key, col in columns.items():
if key == column:
col["values"] = [
col["ctype"](value),
Expand Down
Loading

0 comments on commit 8b94066

Please sign in to comment.