CLI: Remove unnecessary urllib imports

This commit is contained in:
Mike Auty
2021-03-11 15:50:45 +00:00
parent a9e91ea19b
commit 5eaa5ef7b2
3 changed files with 5 additions and 10 deletions
+5 -7
View File
@@ -19,7 +19,6 @@ import os
import sys
import tempfile
import traceback
import urllib
from typing import Dict, Type, Union, Any
from urllib import parse, request
@@ -338,17 +337,16 @@ class CommandLine:
The URL for the location of the file
"""
# We want to work in URLs, but we need to accept absolute and relative files (including on windows)
single_location = urllib.parse.urlparse(filename, '')
single_location = parse.urlparse(filename, '')
if single_location.scheme == '' or len(single_location.scheme) == 1:
single_location = urllib.parse.urlparse(
urllib.parse.urljoin('file:', urllib.request.pathname2url(os.path.abspath(filename))))
single_location = parse.urlparse(parse.urljoin('file:', request.pathname2url(os.path.abspath(filename))))
if single_location.scheme == 'file':
if not os.path.exists(urllib.request.url2pathname(single_location.path)):
filename = urllib.request.url2pathname(single_location.path)
if not os.path.exists(request.url2pathname(single_location.path)):
filename = request.url2pathname(single_location.path)
if not filename:
raise ValueError("File URL looks incorrect (potentially missing /)")
raise ValueError("File does not exist: {}".format(filename))
return urllib.parse.urlunparse(single_location)
return parse.urlunparse(single_location)
def process_exceptions(self, excp):
"""Provide useful feedback if an exception occurs during a run of a plugin."""
-2
View File
@@ -7,8 +7,6 @@ import json
import logging
import os
import sys
import urllib
from urllib import request
import volatility3.plugins
import volatility3.symbols
@@ -9,7 +9,6 @@ import json
import logging
import lzma
import os
import urllib
from bisect import bisect
from typing import Tuple, Dict, Any, Optional, Union, List
from urllib import request, error, parse