Skip to content

Commit f049705

Browse files
committed
Further cleanup - unused code and style fixes
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
1 parent bc2e544 commit f049705

24 files changed

+757
-1352
lines changed

src/fetchcode/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, location, content_type, size, url):
4141
def fetch_http(url, location):
4242
"""
4343
Return a `Response` object built from fetching the content at a HTTP/HTTPS based `url` URL string
44-
saving the content in a file at `location`
44+
saving the content in a file at `location`
4545
"""
4646
r = requests.get(url)
4747
with open(location, 'wb') as f:
@@ -59,7 +59,7 @@ def fetch_http(url, location):
5959
def fetch_ftp(url, location):
6060
"""
6161
Return a `Response` object built from fetching the content at a FTP based `url` URL string
62-
saving the content in a file at `location`
62+
saving the content in a file at `location`
6363
"""
6464
url_parts = urlparse(url)
6565

src/fetchcode/vcs/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
class VCSResponse:
3030
"""
3131
Represent the response from fetching a VCS URL with:
32-
- `dest_dir`: destination of directory
33-
- `vcs_type`: VCS Type of URL (git,bzr,hg,svn)
34-
- `domain` : Source of git VCS (GitHub, Gitlab, Bitbucket)
32+
- `dest_dir`: destination of directory
33+
- `vcs_type`: VCS Type of URL (git,bzr,hg,svn)
34+
- `domain` : Source of git VCS (GitHub, Gitlab, Bitbucket)
3535
"""
3636

3737
def __init__(self, dest_dir, vcs_type, domain):
@@ -43,7 +43,7 @@ def __init__(self, dest_dir, vcs_type, domain):
4343
def fetch_via_vcs(url):
4444
"""
4545
Take `url` as input and store the content of it at location specified at `location` string
46-
Return a VCSResponse object
46+
Return a VCSResponse object
4747
"""
4848
parsed_url = urlparse(url)
4949
scheme = parsed_url.scheme

src/fetchcode/vcs/pip/__init__.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/fetchcode/vcs/pip/_internal/exceptions.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
"""Exceptions used throughout package"""
55

66
from itertools import groupby
7-
from typing import TYPE_CHECKING, Dict, List
7+
from typing import List
88

99
from requests.models import Request, Response
1010

11-
if TYPE_CHECKING:
12-
from hashlib import _Hash
1311

1412
class PipError(Exception):
1513
"""Base pip exception"""
1614

15+
1716
class InstallationError(PipError):
1817
"""General exception during installation"""
1918

@@ -38,8 +37,11 @@ def __init__(self, error_msg, response=None, request=None):
3837
self.response = response
3938
self.request = request
4039
self.error_msg = error_msg
41-
if (self.response is not None and not self.request and
42-
hasattr(response, 'request')):
40+
if (
41+
self.response is not None
42+
and not self.request
43+
and hasattr(response, "request")
44+
):
4345
self.request = self.response.request
4446
super().__init__(error_msg, response, request)
4547

@@ -50,6 +52,7 @@ def __str__(self):
5052

5153
class InstallationSubprocessError(InstallationError):
5254
"""A subprocess call failed during installation."""
55+
5356
def __init__(self, returncode, description):
5457
# type: (int, str) -> None
5558
self.returncode = returncode
@@ -82,8 +85,8 @@ def __str__(self):
8285
lines.append(cls.head)
8386
lines.extend(e.body() for e in errors_of_cls)
8487
if lines:
85-
return '\n'.join(lines)
86-
return ''
88+
return "\n".join(lines)
89+
return ""
8790

8891
def __nonzero__(self):
8992
# type: () -> bool
@@ -107,19 +110,21 @@ class HashError(InstallationError):
107110
exceptions of this kind
108111
109112
"""
110-
head = ''
113+
114+
head = ""
111115
order = -1 # type: int
112116

113117
def __str__(self):
114118
# type: () -> str
115-
return f'{self.head}'
119+
return f"{self.head}"
116120

117121

118122
class VcsHashUnsupported(HashError):
119123
"""A hash was provided for a version-control-system-based requirement, but
120124
we don't have a method for hashing those."""
121125

122126
order = 0
123-
head = ("Can't verify hashes for these requirements because we don't "
124-
"have a way to hash version control repositories:")
125-
127+
head = (
128+
"Can't verify hashes for these requirements because we don't "
129+
"have a way to hash version control repositories:"
130+
)

src/fetchcode/vcs/pip/_internal/utils/_log.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/fetchcode/vcs/pip/_internal/utils/compat.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,12 @@
88
import os
99
import sys
1010

11-
__all__ = ["get_path_uid", "stdlib_pkgs", "WINDOWS"]
11+
__all__ = ["WINDOWS"]
1212

1313

1414
logger = logging.getLogger(__name__)
1515

1616

17-
def has_tls() -> bool:
18-
try:
19-
import _ssl # noqa: F401 # ignore unused
20-
21-
return True
22-
except ImportError:
23-
pass
24-
25-
from urllib3.util import IS_PYOPENSSL
26-
27-
return IS_PYOPENSSL
28-
29-
30-
def get_path_uid(path: str) -> int:
31-
"""
32-
Return path's uid.
33-
34-
Does not follow symlinks:
35-
https://github.com/pypa/pip/pull/935#discussion_r5307003
36-
37-
Placed this function in compat due to differences on AIX and
38-
Jython, that should eventually go away.
39-
40-
:raises OSError: When path is a symlink or can't be read.
41-
"""
42-
if hasattr(os, "O_NOFOLLOW"):
43-
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW)
44-
file_uid = os.fstat(fd).st_uid
45-
os.close(fd)
46-
else: # AIX and Jython
47-
# WARNING: time of check vulnerability, but best we can do w/o NOFOLLOW
48-
if not os.path.islink(path):
49-
# older versions of Jython don't have `os.fstat`
50-
file_uid = os.stat(path).st_uid
51-
else:
52-
# raise OSError for parity with os.O_NOFOLLOW above
53-
raise OSError(f"{path} is a symlink; Will not return uid for symlinks")
54-
return file_uid
55-
56-
5717
# packages in the stdlib that may have installation metadata, but should not be
5818
# considered 'installed'. this theoretically could be determined based on
5919
# dist.location (py27:`sysconfig.get_paths()['stdlib']`,

0 commit comments

Comments
 (0)