Merge pull request #24684 from furgo16/patch-34

BIM: remove obsolete Python 2 urllib2 import
This commit is contained in:
Chris Hennes
2025-10-16 15:48:43 -05:00
committed by GitHub
2 changed files with 4 additions and 11 deletions

View File

@@ -759,10 +759,7 @@ def download(url, force=False):
"""download(url,force=False): downloads a file from the given URL and saves it in the
macro path. Returns the path to the saved file. If force is True, the file will be
downloaded again evn if it already exists."""
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from urllib.request import urlopen
import os
name = url.split("/")[-1]

View File

@@ -97,11 +97,7 @@ class BIM_Tutorial:
import codecs
import re
import sys
if sys.version_info.major < 3:
import urllib2
else:
import urllib.request as urllib2
from urllib.request import urlopen
# initial loading
@@ -111,7 +107,7 @@ class BIM_Tutorial:
# load tutorial from wiki
offlineloc = os.path.join(FreeCAD.getUserAppDataDir(), "BIM", "Tutorial", "Tutorial.html")
try:
u = urllib2.urlopen(URL)
u = urlopen(URL)
html = u.read()
if sys.version_info.major >= 3:
html = html.decode("utf8")
@@ -183,7 +179,7 @@ class BIM_Tutorial:
fullpath = "https://www.freecadweb.org/wiki" + path
else:
fullpath = path
u = urllib2.urlopen(fullpath)
u = urlopen(fullpath)
imagedata = u.read()
f = open(storename, "wb")
f.write(imagedata)