Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made logging_helper de-facto soft dependency #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions https_everywhere/_chrome_preload_hsts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import requests

from logging_helper import setup_logging

from .logging import setup_logging
from ._fetch import _storage_location
from ._util import _check_in, _reverse_host

Expand Down
3 changes: 1 addition & 2 deletions https_everywhere/_mozilla_preload_hsts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import requests

from logging_helper import setup_logging

from .logging import setup_logging
from ._fetch import _storage_location
from ._util import _check_in, _reverse_host

Expand Down
2 changes: 1 addition & 1 deletion https_everywhere/_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from timeit import default_timer as timer

from cached_property import cached_property
from logging_helper import setup_logging
from urllib3.util.url import parse_url as urlparse

from .logging import setup_logging
from ._fetch import fetch_update
from ._fixme import (
# _FIXME_MULTIPLE_RULEST_PREFIXES,
Expand Down
3 changes: 1 addition & 2 deletions https_everywhere/_unregex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import sre_parse

from logging_helper import setup_logging

import urllib3
from urllib3.util.url import parse_url as urlparse

Expand All @@ -12,6 +10,7 @@
_FIXME_SUBDOMAIN_SUFFIXES,
_FIXME_EXTRA_REPLACEMENTS,
)
from .logging import setup_logging

logger = setup_logging()
valid_host_char = set(
Expand Down
3 changes: 1 addition & 2 deletions https_everywhere/adapter.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from __future__ import unicode_literals

from logging_helper import setup_logging

import urllib3
from urllib3.util.url import parse_url

import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.timeout import Timeout

from .logging import setup_logging
from ._rules import https_url_rewrite, _get_rulesets
from ._chrome_preload_hsts import _preload_including_subdomains
from ._mozilla_preload_hsts import _preload_remove_negative
Expand Down
23 changes: 23 additions & 0 deletions https_everywhere/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
__all__ = ("setup_logging",)

try:
from logging_helper import setup_logging
except ImportError:
from warnings import warn

class LoggerMock:
def info(self, *args, **kwargs):
pass

def debug(self, *args, **kwargs):
pass

def error(self, *args, **kwargs):
pass

def warning(self, *args, **kwargs):
pass

def setup_logging():
warn("logging_helper is not available, no logging is set up")
return LoggerMock()
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@
install_requires=[
"requests[security]",
"appdirs",
"logging-helper",
"cached-property",
],
extras_requires = {
"logging": ["logging-helper",],
},
classifiers=classifiers.splitlines(),
tests_require=["unittest-expander", "lxml", "tldextract", "regex"],
# lxml is optional, needed for testing upstream rules
Expand Down