Skip to content

Commit

Permalink
Merge pull request #487 from Backblaze/v2.x
Browse files Browse the repository at this point in the history
semver v2 release
  • Loading branch information
mjurbanski-reef authored Apr 2, 2024
2 parents e26d007 + 055cbd0 commit e19fa01
Show file tree
Hide file tree
Showing 190 changed files with 1,304 additions and 1,235 deletions.
13 changes: 0 additions & 13 deletions b2sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
######################################################################
from __future__ import annotations

# Set default logging handler to avoid "No handler found" warnings.
import logging

logging.getLogger(__name__).addHandler(logging.NullHandler())


class UrllibWarningFilter:
def filter(self, record):
return record.msg != "Connection pool is full, discarding connection: %s"


logging.getLogger('urllib3.connectionpool').addFilter(UrllibWarningFilter())

import b2sdk.version # noqa: E402
__version__ = b2sdk.version.VERSION
assert __version__ # PEP-0396
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/account_info/__init__.py
# File: b2sdk/_internal/account_info/__init__.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/account_info/abstract.py
# File: b2sdk/_internal/account_info/abstract.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand All @@ -11,9 +11,9 @@

from abc import abstractmethod

from b2sdk.account_info import exception
from b2sdk.raw_api import ALL_CAPABILITIES
from b2sdk.utils import B2TraceMetaAbstract, limit_trace_arguments
from b2sdk._internal.account_info import exception
from b2sdk._internal.raw_api import ALL_CAPABILITIES
from b2sdk._internal.utils import B2TraceMetaAbstract, limit_trace_arguments


class AbstractAccountInfo(metaclass=B2TraceMetaAbstract):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/account_info/exception.py
# File: b2sdk/_internal/account_info/exception.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/account_info/in_memory.py
# File: b2sdk/_internal/account_info/in_memory.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/account_info/sqlite_account_info.py
# File: b2sdk/_internal/account_info/sqlite_account_info.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/account_info/stub.py
# File: b2sdk/_internal/account_info/stub.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/account_info/upload_url_pool.py
# File: b2sdk/_internal/account_info/upload_url_pool.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
10 changes: 6 additions & 4 deletions b2sdk/api.py → b2sdk/_internal/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/api.py
# File: b2sdk/_internal/api.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down Expand Up @@ -160,7 +160,7 @@ def __init__(
:class:`~b2sdk.v2.SqliteAccountInfo`
:param cache: It is used by B2Api to cache the mapping between bucket name and bucket ids.
default is :class:`~b2sdk.cache.DummyCache`
default is :class:`~b2sdk._internal.cache.DummyCache`
:param max_upload_workers: a number of upload threads
:param max_copy_workers: a number of copy threads
Expand Down Expand Up @@ -198,8 +198,10 @@ def cache(self):
def raw_api(self):
"""
.. warning::
:class:`~b2sdk.raw_api.B2RawHTTPApi` attribute is deprecated.
:class:`~b2sdk.session.B2Session` expose all :class:`~b2sdk.raw_api.B2RawHTTPApi` methods now."""
:class:`~b2sdk._internal.raw_api.B2RawHTTPApi` attribute is deprecated.
:class:`~b2sdk._internal.session.B2Session` expose all
:class:`~b2sdk._internal.raw_api.B2RawHTTPApi` methods now.
"""
return self.session.raw_api

def authorize_automatically(self):
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/api_config.py → b2sdk/_internal/api_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/api_config.py
# File: b2sdk/_internal/api_config.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/application_key.py
# File: b2sdk/_internal/application_key.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
7 changes: 4 additions & 3 deletions b2sdk/b2http.py → b2sdk/_internal/b2http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/b2http.py
# File: b2sdk/_internal/b2http.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down Expand Up @@ -29,6 +29,8 @@
import requests
from requests.adapters import HTTPAdapter

from b2sdk.version import USER_AGENT

from .api_config import DEFAULT_HTTP_API_CONFIG, B2HttpApiConfig
from .exception import (
B2ConnectionError,
Expand All @@ -46,7 +48,6 @@
)
from .requests import NotDecompressingResponse
from .utils.typing import JSON
from .version import USER_AGENT

LOCALE_LOCK = threading.Lock()
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -616,7 +617,7 @@ def _translate_and_retry(

class NotDecompressingHTTPAdapter(HTTPAdapter):
"""
HTTP adapter that uses :class:`b2sdk.requests.NotDecompressingResponse` instead of the default
HTTP adapter that uses :class:`b2sdk._internal.requests.NotDecompressingResponse` instead of the default
:code:`requests.Response` class.
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/bounded_queue_executor.py
# File: b2sdk/_internal/bounded_queue_executor.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/bucket.py → b2sdk/_internal/bucket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/bucket.py
# File: b2sdk/_internal/bucket.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
4 changes: 2 additions & 2 deletions b2sdk/cache.py → b2sdk/_internal/cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/cache.py
# File: b2sdk/_internal/cache.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand All @@ -13,7 +13,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from b2sdk.account_info.abstract import AbstractAccountInfo
from b2sdk._internal.account_info.abstract import AbstractAccountInfo


class AbstractCache(metaclass=ABCMeta):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/encryption/__init__.py
# File: b2sdk/_internal/encryption/__init__.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/encryption/setting.py
# File: b2sdk/_internal/encryption/setting.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/encryption/types.py
# File: b2sdk/_internal/encryption/types.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/exception.py → b2sdk/_internal/exception.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/exception.py
# File: b2sdk/_internal/exception.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/file_lock.py → b2sdk/_internal/file_lock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/file_lock.py
# File: b2sdk/_internal/file_lock.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/file_version.py → b2sdk/_internal/file_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/file_version.py
# File: b2sdk/_internal/file_version.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/filter.py → b2sdk/_internal/filter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/filter.py
# File: b2sdk/_internal/filter.py
#
# Copyright 2024 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/http_constants.py
# File: b2sdk/_internal/http_constants.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/included_sources.py
# File: b2sdk/_internal/included_sources.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/transfer/emerge/__init__.py
# File: b2sdk/_internal/large_file/__init__.py
#
# Copyright 2020 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/large_file/part.py
# File: b2sdk/_internal/large_file/part.py
#
# Copyright 2020 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/large_file/services.py
# File: b2sdk/_internal/large_file/services.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand All @@ -9,11 +9,11 @@
######################################################################
from __future__ import annotations

from b2sdk.encryption.setting import EncryptionSetting
from b2sdk.file_lock import FileRetentionSetting, LegalHold
from b2sdk.file_version import FileIdAndName
from b2sdk.large_file.part import PartFactory
from b2sdk.large_file.unfinished_large_file import UnfinishedLargeFile
from b2sdk._internal.encryption.setting import EncryptionSetting
from b2sdk._internal.file_lock import FileRetentionSetting, LegalHold
from b2sdk._internal.file_version import FileIdAndName
from b2sdk._internal.large_file.part import PartFactory
from b2sdk._internal.large_file.unfinished_large_file import UnfinishedLargeFile


class LargeFileServices:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/large_file/unfinished_large_file.py
# File: b2sdk/_internal/large_file/unfinished_large_file.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand All @@ -11,9 +11,9 @@

import datetime as dt

from b2sdk.encryption.setting import EncryptionSettingFactory
from b2sdk.file_lock import FileRetentionSetting, LegalHold
from b2sdk.utils.http_date import parse_http_date
from b2sdk._internal.encryption.setting import EncryptionSettingFactory
from b2sdk._internal.file_lock import FileRetentionSetting, LegalHold
from b2sdk._internal.utils.http_date import parse_http_date


class UnfinishedLargeFile:
Expand Down
8 changes: 6 additions & 2 deletions b2sdk/progress.py → b2sdk/_internal/progress.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/progress.py
# File: b2sdk/_internal/progress.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
Expand Down Expand Up @@ -104,9 +104,13 @@ def __exit__(self, exc_type, exc_val, exc_tb):
class TqdmProgressListener(AbstractProgressListener):
"""
Progress listener based on tqdm library.
This listener displays a nice progress bar, but requires `tqdm` package to be installed.
"""

def __init__(self, *args, **kwargs):
if tqdm is None:
raise ModuleNotFoundError("No module named 'tqdm' found")
self.tqdm = None # set in set_total_bytes()
self.prev_value = 0
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -212,7 +216,7 @@ def get_calls(self) -> list[str]:

def make_progress_listener(description: str, quiet: bool) -> AbstractProgressListener:
"""
Return a progress listener object depending on some conditions.
Produce the best progress listener available for the given parameters.
:param description: listener description
:param quiet: if ``True``, do not output anything
Expand Down
7 changes: 3 additions & 4 deletions b2sdk/raw_api.py → b2sdk/_internal/raw_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2sdk/raw_api.py
# File: b2sdk/_internal/raw_api.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
Expand All @@ -23,9 +23,6 @@
except ImportError:
from typing import NotRequired, TypedDict

from b2sdk.http_constants import FILE_INFO_HEADER_PREFIX
from b2sdk.utils.docs import ensure_b2sdk_doc_urls

from .encryption.setting import EncryptionMode, EncryptionSetting
from .exception import (
AccessDenied,
Expand All @@ -38,8 +35,10 @@
WrongEncryptionModeForBucketDefault,
)
from .file_lock import BucketRetentionSetting, FileRetentionSetting, LegalHold
from .http_constants import FILE_INFO_HEADER_PREFIX
from .replication.setting import ReplicationConfiguration
from .utils import b2_url_encode
from .utils.docs import ensure_b2sdk_doc_urls

# All supported realms
REALM_URLS = {
Expand Down
Loading

0 comments on commit e19fa01

Please sign in to comment.