Skip to content

Commit 0136cbe

Browse files
committed
Made logging_helper de-facto soft dependency
1 parent d643a66 commit 0136cbe

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

https_everywhere/_chrome_preload_hsts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
import requests
55

6-
from logging_helper import setup_logging
7-
6+
from .logging import setup_logging
87
from ._fetch import _storage_location
98
from ._util import _check_in, _reverse_host
109

https_everywhere/_mozilla_preload_hsts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import requests
44

5-
from logging_helper import setup_logging
6-
5+
from .logging import setup_logging
76
from ._fetch import _storage_location
87
from ._util import _check_in, _reverse_host
98

https_everywhere/_rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from timeit import default_timer as timer
55

66
from cached_property import cached_property
7-
from logging_helper import setup_logging
87
from urllib3.util.url import parse_url as urlparse
98

9+
from .logging import setup_logging
1010
from ._fetch import fetch_update
1111
from ._fixme import (
1212
# _FIXME_MULTIPLE_RULEST_PREFIXES,

https_everywhere/_unregex.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import sre_parse
22

3-
from logging_helper import setup_logging
4-
53
import urllib3
64
from urllib3.util.url import parse_url as urlparse
75

@@ -12,6 +10,7 @@
1210
_FIXME_SUBDOMAIN_SUFFIXES,
1311
_FIXME_EXTRA_REPLACEMENTS,
1412
)
13+
from .logging import setup_logging
1514

1615
logger = setup_logging()
1716
valid_host_char = set(

https_everywhere/adapter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from __future__ import unicode_literals
22

3-
from logging_helper import setup_logging
4-
53
import urllib3
64
from urllib3.util.url import parse_url
75

86
import requests
97
from requests.adapters import HTTPAdapter
108
from requests.packages.urllib3.util.timeout import Timeout
119

10+
from .logging import setup_logging
1211
from ._rules import https_url_rewrite, _get_rulesets
1312
from ._chrome_preload_hsts import _preload_including_subdomains
1413
from ._mozilla_preload_hsts import _preload_remove_negative

https_everywhere/logging.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
__all__ = ("setup_logging",)
2+
3+
try:
4+
from logging_helper import setup_logging
5+
except ImportError:
6+
from warnings import warn
7+
8+
class LoggerMock:
9+
def info(self, *args, **kwargs):
10+
pass
11+
12+
def debug(self, *args, **kwargs):
13+
pass
14+
15+
def error(self, *args, **kwargs):
16+
pass
17+
18+
def warning(self, *args, **kwargs):
19+
pass
20+
21+
def setup_logging():
22+
warn("logging_helper is not available, no logging is set up")
23+
return LoggerMock()

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@
5555
install_requires=[
5656
"requests[security]",
5757
"appdirs",
58-
"logging-helper",
5958
"cached-property",
6059
],
60+
extras_requires = {
61+
"logging": ["logging-helper",],
62+
},
6163
classifiers=classifiers.splitlines(),
6264
tests_require=["unittest-expander", "lxml", "tldextract", "regex"],
6365
# lxml is optional, needed for testing upstream rules

0 commit comments

Comments
 (0)