Skip to content

Commit

Permalink
fix all references to package name
Browse files Browse the repository at this point in the history
use relative imports if possible
reorder imports (1. stdlib 2. dependencies 3. borg 4. borg.testsuite)
  • Loading branch information
ThomasWaldmann committed May 22, 2015
1 parent 78bfc58 commit 5e98400
Show file tree
Hide file tree
Showing 32 changed files with 136 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
attic/_version.py export-subst
borg/_version.py export-subst
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ install:
- "pip install --use-mirrors Cython"
- "pip install -e ."
# command to run tests
script: fakeroot -u python -m attic.testsuite.run -vb
script: fakeroot -u python -m borg.testsuite.run -vb
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include README.rst LICENSE CHANGES MANIFEST.in versioneer.py
recursive-include attic *.pyx
recursive-include borg *.pyx
recursive-include docs *
recursive-exclude docs *.pyc
recursive-exclude docs *.pyo
prune docs/_build
include attic/_version.py
include borg/_version.py
2 changes: 1 addition & 1 deletion borg/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# these strings are filled in when 'setup.py versioneer' creates _version.py
tag_prefix = ""
parentdir_prefix = "borgbackup-"
versionfile_source = "attic/_version.py"
versionfile_source = "borg/_version.py"


def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
Expand Down
14 changes: 7 additions & 7 deletions borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
import errno
import shutil
import tempfile
from attic.key import key_factory
from attic.remote import cache_if_remote
from .key import key_factory
from .remote import cache_if_remote
import msgpack
import os
import socket
import stat
import sys
import time
from io import BytesIO
from attic import xattr
from attic.platform import acl_get, acl_set
from attic.chunker import Chunker
from attic.hashindex import ChunkIndex
from attic.helpers import parse_timestamp, Error, uid2user, user2uid, gid2group, group2gid, \
from . import xattr
from .platform import acl_get, acl_set
from .chunker import Chunker
from .hashindex import ChunkIndex
from .helpers import parse_timestamp, Error, uid2user, user2uid, gid2group, group2gid, \
Manifest, Statistics, decode_dict, st_mtime_ns, make_path_safe, StableDict, int_to_bigint, bigint_to_int

ITEMS_BUFFER = 1024 * 1024
Expand Down
20 changes: 10 additions & 10 deletions borg/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
import textwrap
import traceback

from attic import __version__
from attic.archive import Archive, ArchiveChecker
from attic.repository import Repository
from attic.cache import Cache
from attic.key import key_creator
from attic.helpers import Error, location_validator, format_time, format_file_size, \
from . import __version__
from .archive import Archive, ArchiveChecker
from .repository import Repository
from .cache import Cache
from .key import key_creator
from .helpers import Error, location_validator, format_time, format_file_size, \
format_file_mode, ExcludePattern, exclude_path, adjust_patterns, to_localtime, timestamp, \
get_cache_dir, get_keys_dir, format_timedelta, prune_within, prune_split, \
Manifest, remove_surrogates, update_excludes, format_archive, check_extension_modules, Statistics, \
is_cachedir, bigint_to_int
from attic.remote import RepositoryServer, RemoteRepository
from .remote import RepositoryServer, RemoteRepository


class Archiver:
Expand Down Expand Up @@ -296,7 +296,7 @@ def do_delete(self, args):
def do_mount(self, args):
"""Mount archive or an entire repository as a FUSE fileystem"""
try:
from attic.fuse import FuseOperations
from .fuse import FuseOperations
except ImportError as e:
self.print_error('loading fuse support failed [ImportError: %s]' % str(e))
return self.exit_code
Expand Down Expand Up @@ -814,7 +814,7 @@ def sig_info_handler(signum, stack):
"""search the stack for infos about the currently processed file and print them"""
for frame in inspect.getouterframes(stack):
func, loc = frame[3], frame[0].f_locals
if func in ('process_file', '_process', ): # attic create
if func in ('process_file', '_process', ): # create op
path = loc['path']
try:
pos = loc['fd'].tell()
Expand All @@ -823,7 +823,7 @@ def sig_info_handler(signum, stack):
pos, total = 0, 0
print("{0} {1}/{2}".format(path, format_file_size(pos), format_file_size(total)))
break
if func in ('extract_item', ): # attic extract
if func in ('extract_item', ): # extract op
path = loc['item'][b'path']
try:
pos = loc['fd'].tell()
Expand Down
2 changes: 1 addition & 1 deletion borg/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from configparser import RawConfigParser
from attic.remote import cache_if_remote
from .remote import cache_if_remote
import msgpack
import os
import sys
Expand Down
6 changes: 3 additions & 3 deletions borg/fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import stat
import tempfile
import time
from attic.archive import Archive
from attic.helpers import daemonize
from attic.remote import cache_if_remote
from .archive import Archive
from .helpers import daemonize
from .remote import cache_if_remote

# Does this version of llfuse support ns precision?
have_fuse_mtime_ns = hasattr(llfuse.EntryAttributes, 'st_mtime_ns')
Expand Down
16 changes: 8 additions & 8 deletions borg/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from operator import attrgetter
import fcntl

import attic.hashindex
import attic.chunker
import attic.crypto
from . import hashindex
from . import chunker
from . import crypto


class Error(Exception):
Expand Down Expand Up @@ -71,11 +71,11 @@ def release(self):


def check_extension_modules():
import attic.platform
if (attic.hashindex.API_VERSION != 2 or
attic.chunker.API_VERSION != 2 or
attic.crypto.API_VERSION != 2 or
attic.platform.API_VERSION != 2):
from . import platform
if (hashindex.API_VERSION != 2 or
chunker.API_VERSION != 2 or
crypto.API_VERSION != 2 or
platform.API_VERSION != 2):
raise ExtensionModuleError


Expand Down
4 changes: 2 additions & 2 deletions borg/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from hashlib import sha256
import zlib

from attic.crypto import pbkdf2_sha256, get_random_bytes, AES, bytes_to_long, long_to_bytes, bytes_to_int, num_aes_blocks
from attic.helpers import IntegrityError, get_keys_dir, Error
from .crypto import pbkdf2_sha256, get_random_bytes, AES, bytes_to_long, long_to_bytes, bytes_to_int, num_aes_blocks
from .helpers import IntegrityError, get_keys_dir, Error

PREFIX = b'\0' * 8

Expand Down
6 changes: 3 additions & 3 deletions borg/platform.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sys

if sys.platform.startswith('linux'):
from attic.platform_linux import acl_get, acl_set, API_VERSION
from .platform_linux import acl_get, acl_set, API_VERSION
elif sys.platform.startswith('freebsd'):
from attic.platform_freebsd import acl_get, acl_set, API_VERSION
from .platform_freebsd import acl_get, acl_set, API_VERSION
elif sys.platform == 'darwin':
from attic.platform_darwin import acl_get, acl_set, API_VERSION
from .platform_darwin import acl_get, acl_set, API_VERSION
else:
API_VERSION = 2

Expand Down
2 changes: 1 addition & 1 deletion borg/platform_darwin.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from attic.helpers import user2uid, group2gid
from .helpers import user2uid, group2gid

API_VERSION = 2

Expand Down
2 changes: 1 addition & 1 deletion borg/platform_freebsd.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from attic.helpers import posix_acl_use_stored_uid_gid
from .helpers import posix_acl_use_stored_uid_gid

API_VERSION = 2

Expand Down
2 changes: 1 addition & 1 deletion borg/platform_linux.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import re
from stat import S_ISLNK
from attic.helpers import posix_acl_use_stored_uid_gid, user2uid, group2gid
from .helpers import posix_acl_use_stored_uid_gid, user2uid, group2gid

API_VERSION = 2

Expand Down
4 changes: 2 additions & 2 deletions borg/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tempfile
import traceback

from attic import __version__
from . import __version__

from .hashindex import NSIndex
from .helpers import Error, IntegrityError
Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(self, location, create=False):
self.unpacker = msgpack.Unpacker(use_list=False)
self.p = None
if location.host == '__testsuite__':
args = [sys.executable, '-m', 'attic.archiver', 'serve'] + self.extra_test_args
args = [sys.executable, '-m', 'borg.archiver', 'serve'] + self.extra_test_args
else:
args = ['ssh']
if location.port:
Expand Down
6 changes: 3 additions & 3 deletions borg/testsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import sysconfig
import time
import unittest
from attic.helpers import st_mtime_ns
from attic.xattr import get_all
from ..helpers import st_mtime_ns
from ..xattr import get_all

try:
import llfuse
Expand Down Expand Up @@ -113,7 +113,7 @@ class TestLoader(unittest.TestLoader):
"""

def loadTestsFromName(self, pattern, module=None):
suite = self.discover('attic.testsuite', '*.py')
suite = self.discover('borg.testsuite', '*.py')
tests = unittest.TestSuite()
for test in get_tests(suite):
if pattern.lower() in test.id().lower():
Expand Down
14 changes: 8 additions & 6 deletions borg/testsuite/archive.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import msgpack
from attic.testsuite import BaseTestCase
from attic.testsuite.mock import Mock
from attic.archive import Archive, CacheChunkBuffer, RobustUnpacker
from attic.key import PlaintextKey
from attic.helpers import Manifest
from datetime import datetime, timezone

import msgpack

from ..archive import Archive, CacheChunkBuffer, RobustUnpacker
from ..key import PlaintextKey
from ..helpers import Manifest
from . import BaseTestCase
from .mock import Mock


class MockCache:

Expand Down
23 changes: 12 additions & 11 deletions borg/testsuite/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
import time
import unittest
from hashlib import sha256
from attic import xattr
from attic.archive import Archive, ChunkBuffer, CHUNK_MAX
from attic.archiver import Archiver
from attic.cache import Cache
from attic.crypto import bytes_to_long, num_aes_blocks
from attic.helpers import Manifest
from attic.remote import RemoteRepository, PathNotAllowed
from attic.repository import Repository
from attic.testsuite import BaseTestCase
from attic.testsuite.mock import patch

from .. import xattr
from ..archive import Archive, ChunkBuffer, CHUNK_MAX
from ..archiver import Archiver
from ..cache import Cache
from ..crypto import bytes_to_long, num_aes_blocks
from ..helpers import Manifest
from ..remote import RemoteRepository, PathNotAllowed
from ..repository import Repository
from . import BaseTestCase
from .mock import patch

try:
import llfuse
Expand Down Expand Up @@ -95,7 +96,7 @@ def cmd(self, *args, **kw):
fork = kw.get('fork', False)
if fork:
try:
output = subprocess.check_output((sys.executable, '-m', 'attic.archiver') + args)
output = subprocess.check_output((sys.executable, '-m', 'borg.archiver') + args)
ret = 0
except subprocess.CalledProcessError as e:
output = e.output
Expand Down
7 changes: 4 additions & 3 deletions borg/testsuite/chunker.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from attic.chunker import Chunker, buzhash, buzhash_update
from attic.testsuite import BaseTestCase
from attic.archive import CHUNK_MAX
from io import BytesIO

from ..chunker import Chunker, buzhash, buzhash_update
from ..archive import CHUNK_MAX
from . import BaseTestCase


class ChunkerTestCase(BaseTestCase):

Expand Down
5 changes: 3 additions & 2 deletions borg/testsuite/crypto.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from binascii import hexlify
from attic.testsuite import BaseTestCase
from attic.crypto import AES, bytes_to_long, bytes_to_int, long_to_bytes, pbkdf2_sha256, get_random_bytes

from ..crypto import AES, bytes_to_long, bytes_to_int, long_to_bytes, pbkdf2_sha256, get_random_bytes
from . import BaseTestCase


class CryptoTestCase(BaseTestCase):
Expand Down
5 changes: 3 additions & 2 deletions borg/testsuite/hashindex.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import hashlib
import os
import tempfile
from attic.hashindex import NSIndex, ChunkIndex
from attic.testsuite import BaseTestCase

from ..hashindex import NSIndex, ChunkIndex
from . import BaseTestCase


class HashIndexTestCase(BaseTestCase):
Expand Down
8 changes: 5 additions & 3 deletions borg/testsuite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import os
import tempfile
import unittest
from attic.helpers import adjust_patterns, exclude_path, Location, format_timedelta, IncludePattern, ExcludePattern, make_path_safe, UpgradableLock, prune_within, prune_split, to_localtime, \
StableDict, int_to_bigint, bigint_to_int, parse_timestamp
from attic.testsuite import BaseTestCase

import msgpack

from ..helpers import adjust_patterns, exclude_path, Location, format_timedelta, IncludePattern, ExcludePattern, make_path_safe, UpgradableLock, prune_within, prune_split, to_localtime, \
StableDict, int_to_bigint, bigint_to_int, parse_timestamp
from . import BaseTestCase


class BigIntTestCase(BaseTestCase):

Expand Down
9 changes: 5 additions & 4 deletions borg/testsuite/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import shutil
import tempfile
from binascii import hexlify
from attic.crypto import bytes_to_long, num_aes_blocks
from attic.testsuite import BaseTestCase
from attic.key import PlaintextKey, PassphraseKey, KeyfileKey
from attic.helpers import Location, unhexlify

from ..crypto import bytes_to_long, num_aes_blocks
from ..key import PlaintextKey, PassphraseKey, KeyfileKey
from ..helpers import Location, unhexlify
from . import BaseTestCase


class KeyTestCase(BaseTestCase):
Expand Down
4 changes: 2 additions & 2 deletions borg/testsuite/lrucache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from attic.lrucache import LRUCache
from attic.testsuite import BaseTestCase
from ..lrucache import LRUCache
from . import BaseTestCase


class LRUCacheTestCase(BaseTestCase):
Expand Down
5 changes: 3 additions & 2 deletions borg/testsuite/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import sys
import tempfile
import unittest
from attic.platform import acl_get, acl_set
from attic.testsuite import BaseTestCase

from ..platform import acl_get, acl_set
from . import BaseTestCase


ACCESS_ACL = """
Expand Down
Loading

0 comments on commit 5e98400

Please sign in to comment.