mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-11 01:41:57 -04:00
add octal_int validator
This commit is contained in:
parent
ee58cb4e44
commit
71212d2d7f
4 changed files with 11 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ from ..constants import * # NOQA
|
|||
from ..cache import Cache, assert_secure
|
||||
from ..helpers import Error
|
||||
from ..helpers import SortBySpec, positive_int_validator, location_validator, Location, relative_time_marker_validator
|
||||
from ..helpers import Highlander
|
||||
from ..helpers import Highlander, octal_int
|
||||
from ..helpers.argparsing import SUPPRESS
|
||||
from ..helpers.nanorst import rst_to_terminal
|
||||
from ..manifest import Manifest, AI_HUMAN_SORT_KEYS
|
||||
|
|
@ -510,7 +510,7 @@ def define_common_options(add_common_option):
|
|||
"--umask",
|
||||
metavar="M",
|
||||
dest="umask",
|
||||
type=lambda s: s if isinstance(s, int) else int(s, 8),
|
||||
type=octal_int,
|
||||
default=UMASK_DEFAULT,
|
||||
action=Highlander,
|
||||
help="set umask to M (local only, default: %(default)04o)",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ from ..archive import FilesystemObjectProcessors, MetadataCollector, ChunksProce
|
|||
from ..cache import Cache
|
||||
from ..constants import * # NOQA
|
||||
from ..helpers import comment_validator, ChunkerParams, FilesystemPathSpec, CompressionSpec
|
||||
from ..helpers import archivename_validator, FilesCacheMode
|
||||
from ..helpers import archivename_validator, FilesCacheMode, octal_int
|
||||
from ..helpers import eval_escapes
|
||||
from ..helpers import timestamp, archive_ts_now
|
||||
from ..helpers import get_cache_dir, os_stat, get_strip_prefix, slashify
|
||||
|
|
@ -827,7 +827,7 @@ class CreateMixIn:
|
|||
"--stdin-mode",
|
||||
metavar="M",
|
||||
dest="stdin_mode",
|
||||
type=lambda s: s if isinstance(s, int) else int(s, 8),
|
||||
type=octal_int,
|
||||
default=STDIN_MODE_DEFAULT,
|
||||
action=Highlander,
|
||||
help="set mode to M in archive for stdin data (default: %(default)04o)",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from .fs import O_, flags_dir, flags_special_follow, flags_special, flags_base,
|
|||
from .fs import HardLinkManager
|
||||
from .misc import sysinfo, log_multi, consume
|
||||
from .misc import ChunkIteratorFileWrapper, open_item, chunkit, iter_separated, ErrorIgnoringTextIOWrapper
|
||||
from .parseformat import bin_to_hex, hex_to_bin, safe_encode, safe_decode
|
||||
from .parseformat import octal_int, bin_to_hex, hex_to_bin, safe_encode, safe_decode
|
||||
from .parseformat import text_to_json, binary_to_json, remove_surrogates, join_cmd
|
||||
from .parseformat import eval_escapes, decode_dict, positive_int_validator, interval
|
||||
from .parseformat import (
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ if TYPE_CHECKING:
|
|||
from ..item import ItemDiff
|
||||
|
||||
|
||||
def octal_int(s):
|
||||
if isinstance(s, int):
|
||||
return s
|
||||
return int(s, 8)
|
||||
|
||||
|
||||
def bin_to_hex(binary):
|
||||
return binascii.hexlify(binary).decode("ascii")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue