mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-15 00:21:56 +00:00
use relative imports
Use relative imports where trivially possible for more consistency and to avoid using the borg module name explicitly.
This commit is contained in:
parent
c34df51e3e
commit
fd34fa2d02
4 changed files with 13 additions and 14 deletions
|
@ -622,7 +622,7 @@ class Archiver:
|
||||||
key_96 = os.urandom(12)
|
key_96 = os.urandom(12)
|
||||||
|
|
||||||
import io
|
import io
|
||||||
from borg.chunker import get_chunker
|
from .chunker import get_chunker
|
||||||
print("Chunkers =======================================================")
|
print("Chunkers =======================================================")
|
||||||
size = "1GB"
|
size = "1GB"
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ class Archiver:
|
||||||
print(f"{spec:<24} {size:<10} {timeit(func, number=100):.3f}s")
|
print(f"{spec:<24} {size:<10} {timeit(func, number=100):.3f}s")
|
||||||
|
|
||||||
import zlib
|
import zlib
|
||||||
from borg.checksums import crc32, deflate_crc32, xxh64
|
from .checksums import crc32, deflate_crc32, xxh64
|
||||||
print("Non-cryptographic checksums / hashes ===========================")
|
print("Non-cryptographic checksums / hashes ===========================")
|
||||||
size = "1GB"
|
size = "1GB"
|
||||||
tests = [
|
tests = [
|
||||||
|
@ -656,7 +656,7 @@ class Archiver:
|
||||||
for spec, func in tests:
|
for spec, func in tests:
|
||||||
print(f"{spec:<24} {size:<10} {timeit(func, number=100):.3f}s")
|
print(f"{spec:<24} {size:<10} {timeit(func, number=100):.3f}s")
|
||||||
|
|
||||||
from borg.crypto.low_level import hmac_sha256, blake2b_256
|
from .crypto.low_level import hmac_sha256, blake2b_256
|
||||||
print("Cryptographic hashes / MACs ====================================")
|
print("Cryptographic hashes / MACs ====================================")
|
||||||
size = "1GB"
|
size = "1GB"
|
||||||
for spec, func in [
|
for spec, func in [
|
||||||
|
@ -665,8 +665,8 @@ class Archiver:
|
||||||
]:
|
]:
|
||||||
print(f"{spec:<24} {size:<10} {timeit(func, number=100):.3f}s")
|
print(f"{spec:<24} {size:<10} {timeit(func, number=100):.3f}s")
|
||||||
|
|
||||||
from borg.crypto.low_level import AES256_CTR_BLAKE2b, AES256_CTR_HMAC_SHA256
|
from .crypto.low_level import AES256_CTR_BLAKE2b, AES256_CTR_HMAC_SHA256
|
||||||
from borg.crypto.low_level import AES256_OCB, CHACHA20_POLY1305
|
from .crypto.low_level import AES256_OCB, CHACHA20_POLY1305
|
||||||
print("Encryption =====================================================")
|
print("Encryption =====================================================")
|
||||||
size = "1GB"
|
size = "1GB"
|
||||||
|
|
||||||
|
@ -691,7 +691,7 @@ class Archiver:
|
||||||
]:
|
]:
|
||||||
print(f"{spec:<24} {count:<10} {timeit(func, number=count):.3f}s")
|
print(f"{spec:<24} {count:<10} {timeit(func, number=count):.3f}s")
|
||||||
|
|
||||||
from borg.compress import CompressionSpec
|
from .compress import CompressionSpec
|
||||||
print("Compression ====================================================")
|
print("Compression ====================================================")
|
||||||
for spec in [
|
for spec in [
|
||||||
'lz4',
|
'lz4',
|
||||||
|
|
|
@ -23,15 +23,14 @@ class ExtensionModuleError(Error):
|
||||||
|
|
||||||
|
|
||||||
def check_extension_modules():
|
def check_extension_modules():
|
||||||
import borg.crypto.low_level
|
from .. import platform, compress, crypto, item, chunker, hashindex
|
||||||
from .. import platform, compress, item, chunker, hashindex
|
|
||||||
if hashindex.API_VERSION != '1.2_01':
|
if hashindex.API_VERSION != '1.2_01':
|
||||||
raise ExtensionModuleError
|
raise ExtensionModuleError
|
||||||
if chunker.API_VERSION != '1.2_01':
|
if chunker.API_VERSION != '1.2_01':
|
||||||
raise ExtensionModuleError
|
raise ExtensionModuleError
|
||||||
if compress.API_VERSION != '1.2_02':
|
if compress.API_VERSION != '1.2_02':
|
||||||
raise ExtensionModuleError
|
raise ExtensionModuleError
|
||||||
if borg.crypto.low_level.API_VERSION != '1.3_01':
|
if crypto.low_level.API_VERSION != '1.3_01':
|
||||||
raise ExtensionModuleError
|
raise ExtensionModuleError
|
||||||
if item.API_VERSION != '1.2_01':
|
if item.API_VERSION != '1.2_01':
|
||||||
raise ExtensionModuleError
|
raise ExtensionModuleError
|
||||||
|
|
|
@ -4,9 +4,9 @@ import socket
|
||||||
import tempfile
|
import tempfile
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from borg.constants import UMASK_DEFAULT
|
from ..constants import UMASK_DEFAULT
|
||||||
from borg.helpers import safe_unlink
|
from ..helpers import safe_unlink
|
||||||
from borg.platformflags import is_win32
|
from ..platformflags import is_win32
|
||||||
|
|
||||||
"""
|
"""
|
||||||
platform base module
|
platform base module
|
||||||
|
|
|
@ -245,7 +245,7 @@ class TestLocationWithoutEnv:
|
||||||
Location('ssh://user@host:/path')
|
Location('ssh://user@host:/path')
|
||||||
|
|
||||||
def test_omit_archive(self):
|
def test_omit_archive(self):
|
||||||
from borg.platform import hostname
|
from ..platform import hostname
|
||||||
loc = Location('ssh://user@host:1234/repos/{hostname}::archive')
|
loc = Location('ssh://user@host:1234/repos/{hostname}::archive')
|
||||||
loc_without_archive = loc.omit_archive()
|
loc_without_archive = loc.omit_archive()
|
||||||
assert loc_without_archive.archive is None
|
assert loc_without_archive.archive is None
|
||||||
|
@ -264,7 +264,7 @@ class TestLocationWithEnv:
|
||||||
"Location(proto='ssh', user='user', host='host', port=1234, path='/some/path', archive=None)"
|
"Location(proto='ssh', user='user', host='host', port=1234, path='/some/path', archive=None)"
|
||||||
|
|
||||||
def test_ssh_placeholder(self, monkeypatch):
|
def test_ssh_placeholder(self, monkeypatch):
|
||||||
from borg.platform import hostname
|
from ..platform import hostname
|
||||||
monkeypatch.setenv('BORG_REPO', 'ssh://user@host:1234/{hostname}')
|
monkeypatch.setenv('BORG_REPO', 'ssh://user@host:1234/{hostname}')
|
||||||
assert repr(Location('::archive')) == \
|
assert repr(Location('::archive')) == \
|
||||||
f"Location(proto='ssh', user='user', host='host', port=1234, path='/{hostname}', archive='archive')"
|
f"Location(proto='ssh', user='user', host='host', port=1234, path='/{hostname}', archive='archive')"
|
||||||
|
|
Loading…
Add table
Reference in a new issue