♻️ Py3: get rid of some py2 import stragglers
This commit is contained in:
1 parent
f510cc4218
commit
d98a6da7b2
6 files changed
+8
-37
No files matched your search
@@ -2004,11 +2004,7 @@ class SlicerPlugin(OctoPrintPlugin):
|
||||
..versionadded:: 1.3.0
|
||||
"""
|
||||
import os
|
||||
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
from scandir import scandir
|
||||
from os import scandir
|
||||
|
||||
lms = [os.stat(profile_path).st_mtime]
|
||||
lms += [
|
||||
|
||||
@@ -407,13 +407,7 @@ class DiscoveryPlugin(
|
||||
|
||||
import io
|
||||
import threading
|
||||
|
||||
try:
|
||||
# noinspection PyCompatibility
|
||||
from http.client import HTTPResponse # py3
|
||||
except ImportError:
|
||||
# noinspection PyCompatibility
|
||||
from httplib import HTTPResponse # py2
|
||||
from http.client import HTTPResponse
|
||||
|
||||
class Response(HTTPResponse):
|
||||
def __init__(self, response_text):
|
||||
|
||||
@@ -668,12 +668,7 @@ class PluginManagerPlugin(
|
||||
409,
|
||||
)
|
||||
|
||||
try:
|
||||
# Py3
|
||||
from urllib.parse import quote as url_quote
|
||||
except ImportError:
|
||||
# Py2
|
||||
from urllib import quote as url_quote
|
||||
from urllib.parse import quote as url_quote
|
||||
|
||||
path = os.path.abspath(path)
|
||||
if os.sep != "/":
|
||||
|
||||
@@ -626,10 +626,8 @@ def _extended_header_value(value):
|
||||
|
||||
if value.lower().startswith("iso-8859-1'") or value.lower().startswith("utf-8'"):
|
||||
# RFC 5987 section 3.2
|
||||
try:
|
||||
from urllib import unquote
|
||||
except ImportError:
|
||||
from urllib.parse import unquote
|
||||
from urllib.parse import unquote
|
||||
|
||||
encoding, _, value = value.split("'", 2)
|
||||
return unquote(value, encoding=encoding)
|
||||
else:
|
||||
|
||||
@@ -14,6 +14,7 @@ import shutil
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from os import scandir
|
||||
|
||||
import requests
|
||||
import sarge
|
||||
@@ -27,12 +28,6 @@ from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
from octoprint.util import sv
|
||||
from octoprint.util.commandline import CommandlineCaller
|
||||
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
from scandir import scandir
|
||||
|
||||
|
||||
# currently configured timelapse
|
||||
current = None
|
||||
|
||||
|
||||
@@ -1310,16 +1310,9 @@ def utmify(link, source=None, medium=None, name=None, term=None, content=None):
|
||||
if source is None:
|
||||
return link
|
||||
|
||||
import urllib.parse as urlparse
|
||||
from collections import OrderedDict
|
||||
|
||||
try:
|
||||
from urllib import urlencode
|
||||
|
||||
import urlparse
|
||||
except ImportError:
|
||||
# python 3
|
||||
import urllib.parse as urlparse
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import urlencode
|
||||
|
||||
# inspired by https://stackoverflow.com/a/2506477
|
||||
parts = list(urlparse.urlparse(link))
|
||||
|
||||
Reference in new issue
Block a user