Skip to content

Commit

Permalink
g.extension: Remove six dependency (OSGeo#2828)
Browse files Browse the repository at this point in the history
* Removes imports from six, uses standard Python 3 imports.
* Removes Python <=2.4 ElementTree import.
* Removes future print_function imports.

Removes six only from g.extension and g.extension.all. Leaves the rest as is.
  • Loading branch information
wenzeslaus authored and ninsbl committed Feb 17, 2023
1 parent 440fd28 commit c600dae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 4 additions & 7 deletions scripts/g.extension.all/g.extension.all.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,16 @@
# % key: f
# % label: Force operation (required for removal)
# % end
from __future__ import print_function

import http
import os
import re
import sys

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

from six.moves.urllib import request as urlrequest
from six.moves.urllib.error import HTTPError, URLError
from urllib import request as urlrequest
from urllib.error import HTTPError, URLError

import grass.script as gscript
from grass.exceptions import CalledModuleError
Expand Down
8 changes: 3 additions & 5 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@

# TODO: solve addon-extension(-module) confusion


from __future__ import print_function
import fileinput
import http
import os
Expand All @@ -172,9 +170,9 @@

copy_tree = partial(shutil.copytree, dirs_exist_ok=True)

from six.moves.urllib import request as urlrequest
from six.moves.urllib.error import HTTPError, URLError
from six.moves.urllib.parse import urlparse
from urllib import request as urlrequest
from urllib.error import HTTPError, URLError
from urllib.parse import urlparse

# Get the XML parsing exceptions to catch. The behavior changed with Python 2.7
# and ElementTree 1.3.
Expand Down

0 comments on commit c600dae

Please sign in to comment.