mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-10 06:03:38 +00:00
make tests and build work again in usage using environment
this is such a crude hack it is totally embarrassing.... the proper solution would probably be to move the `build_parser()` function out of `Archiver` completely, but this is such an undertaking that i doubt it is worth doing since we're looking at switching to click anyways. the main problem in moving build_parser() out is that it references `self` all the time, so it *needs* an archiver context that it can reuse. we could make the function static and pass self in there by hand, but it seems like almost a worse hack... and besides, we would need to load the archiver in order to do that, which would break usage all over again...
This commit is contained in:
parent
8fe56f001c
commit
9cbc868764
6 changed files with 21 additions and 14 deletions
|
@ -12,9 +12,10 @@ import sys
|
||||||
import time
|
import time
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from . import xattr
|
from . import xattr
|
||||||
from .platform import acl_get, acl_set
|
if not os.environ.get('BORG_GEN_USAGE', False):
|
||||||
from .chunker import Chunker
|
from .platform import acl_get, acl_set
|
||||||
from .hashindex import ChunkIndex
|
from .chunker import Chunker
|
||||||
|
from .hashindex import ChunkIndex
|
||||||
from .helpers import parse_timestamp, Error, uid2user, user2uid, gid2group, group2gid, \
|
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
|
Manifest, Statistics, decode_dict, st_mtime_ns, make_path_safe, StableDict, int_to_bigint, bigint_to_int
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,13 @@ import textwrap
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
|
if not os.environ.get('BORG_GEN_USAGE', False):
|
||||||
|
from .compress import Compressor, COMPR_BUFFER
|
||||||
|
from .upgrader import AtticRepositoryUpgrader
|
||||||
|
from .repository import Repository
|
||||||
|
from .cache import Cache
|
||||||
|
from .key import key_creator
|
||||||
from .archive import Archive, ArchiveChecker, CHUNKER_PARAMS
|
from .archive import Archive, ArchiveChecker, CHUNKER_PARAMS
|
||||||
from .compress import Compressor, COMPR_BUFFER
|
|
||||||
from .upgrader import AtticRepositoryUpgrader
|
|
||||||
from .repository import Repository
|
|
||||||
from .cache import Cache
|
|
||||||
from .key import key_creator
|
|
||||||
from .helpers import Error, location_validator, format_time, format_file_size, \
|
from .helpers import Error, location_validator, format_time, format_file_size, \
|
||||||
format_file_mode, ExcludePattern, IncludePattern, exclude_path, adjust_patterns, to_localtime, timestamp, \
|
format_file_mode, ExcludePattern, IncludePattern, exclude_path, adjust_patterns, to_localtime, timestamp, \
|
||||||
get_cache_dir, get_keys_dir, format_timedelta, prune_within, prune_split, \
|
get_cache_dir, get_keys_dir, format_timedelta, prune_within, prune_split, \
|
||||||
|
|
|
@ -18,9 +18,10 @@ from operator import attrgetter
|
||||||
|
|
||||||
import msgpack
|
import msgpack
|
||||||
|
|
||||||
from . import hashindex
|
if not os.environ.get('BORG_GEN_USAGE', False):
|
||||||
from . import chunker
|
from . import hashindex
|
||||||
from . import crypto
|
from . import chunker
|
||||||
|
from . import crypto
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
|
|
|
@ -7,8 +7,9 @@ import textwrap
|
||||||
import hmac
|
import hmac
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
|
|
||||||
from .crypto import pbkdf2_sha256, get_random_bytes, AES, bytes_to_long, long_to_bytes, bytes_to_int, num_aes_blocks
|
if not os.environ.get('BORG_GEN_USAGE', False):
|
||||||
from .compress import Compressor, COMPR_BUFFER
|
from .crypto import pbkdf2_sha256, get_random_bytes, AES, bytes_to_long, long_to_bytes, bytes_to_int, num_aes_blocks
|
||||||
|
from .compress import Compressor, COMPR_BUFFER
|
||||||
from .helpers import IntegrityError, get_keys_dir, Error
|
from .helpers import IntegrityError, get_keys_dir, Error
|
||||||
|
|
||||||
PREFIX = b'\0' * 8
|
PREFIX = b'\0' * 8
|
||||||
|
|
|
@ -8,7 +8,8 @@ import struct
|
||||||
import sys
|
import sys
|
||||||
from zlib import crc32
|
from zlib import crc32
|
||||||
|
|
||||||
from .hashindex import NSIndex
|
if not os.environ.get('BORG_GEN_USAGE', False):
|
||||||
|
from .hashindex import NSIndex
|
||||||
from .helpers import Error, IntegrityError, read_msgpack, write_msgpack, unhexlify
|
from .helpers import Error, IntegrityError, read_msgpack, write_msgpack, unhexlify
|
||||||
from .locking import UpgradableLock
|
from .locking import UpgradableLock
|
||||||
from .lrucache import LRUCache
|
from .lrucache import LRUCache
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -136,6 +136,8 @@ class build_usage(Command):
|
||||||
def run(self):
|
def run(self):
|
||||||
import pdb
|
import pdb
|
||||||
print('generating usage docs')
|
print('generating usage docs')
|
||||||
|
# XXX: gross hack: allows us to skip loading C modules during help generation
|
||||||
|
os.environ['BORG_GEN_USAGE'] = "True"
|
||||||
from borg.archiver import Archiver
|
from borg.archiver import Archiver
|
||||||
parser = Archiver().build_parser(prog='borg')
|
parser = Archiver().build_parser(prog='borg')
|
||||||
choices = {}
|
choices = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue