MCPcopy
hub / github.com/borgbackup/borg / Location

Class Location

src/borg/helpers/parseformat.py:506–724  ·  view source on GitHub ↗

Object representing a repository location

Source from the content-addressed store, hash-verified

504
505
506class Location:
507 """Object representing a repository location"""
508
509 # user@ (optional)
510 # user must not contain "@", ":" or "/".
511 # Quoting adduser error message:
512 # "To avoid problems, the username should consist only of letters, digits,
513 # underscores, periods, at signs and dashes, and not start with a dash
514 # (as defined by IEEE Std 1003.1-2001)."
515 # We use "@" as separator between username and hostname, so we must
516 # disallow it within the pure username part.
517 optional_user_re = r"(?:(?P<user>[^@:/]+)@)?"
518
519 # host NAME, or host IP ADDRESS (v4 or v6, v6 must be in square brackets)
520 host_re = r"""
521 (?P<host>(
522 (?!\[)[^:/]+(?<!\]) # hostname or v4 addr, not containing : or / (does not match v6 addr: no brackets!)
523 |
524 \[[0-9a-fA-F:.]+\]) # ipv6 address in brackets
525 )
526 """
527
528 # :port (optional)
529 optional_port_re = r"(?::(?P<port>\d+))?"
530
531 # path may contain any chars. to avoid ambiguities with other regexes,
532 # it must not start with "//" nor with "scheme://" nor with "rclone:".
533 local_path_re = r"""
534 (?!(//|(ssh|socket|sftp|file)://|(rclone|s3|b2):))
535 (?P<path>.+)
536 """
537
538 # abs_path must start with a slash (or drive letter on Windows).
539 abs_path_re = r"(?P<path>[A-Za-z]:/.+)" if is_win32 else r"(?P<path>/.+)"
540
541 # path may or may not start with a slash.
542 abs_or_rel_path_re = r"(?P<path>.+)"
543
544 # regexes for misc. kinds of supported location specifiers:
545 ssh_or_sftp_re = re.compile(
546 r"(?P<proto>(ssh|sftp))://"
547 + optional_user_re
548 + host_re
549 + optional_port_re
550 + r"/" # this is the separator, not part of the path!
551 + abs_or_rel_path_re,
552 re.VERBOSE,
553 )
554
555 # BorgStore REST server
556 # (http|https)://user:pass@host:port/
557 http_re = re.compile(
558 r"(?P<proto>http|https)://"
559 + r"((?P<user>[^:@]+):(?P<pass>[^@]+)@)?"
560 + host_re
561 + optional_port_re
562 + r"(?P<path>/)",
563 re.VERBOSE,

Callers 15

__init__Method · 0.85
__init__Method · 0.85
with_timestampMethod · 0.85
validatorFunction · 0.85
build_parser_transferMethod · 0.85
define_common_optionsFunction · 0.85
remote_repositoryFunction · 0.85
test_remote_ssh_cmdFunction · 0.85
test_remote_borg_cmdFunction · 0.85
remote_repositoryFunction · 0.85
test_remote_ssh_cmdFunction · 0.85

Calls

no outgoing calls

Tested by 15

remote_repositoryFunction · 0.68
test_remote_ssh_cmdFunction · 0.68
test_remote_borg_cmdFunction · 0.68
remote_repositoryFunction · 0.68
test_remote_ssh_cmdFunction · 0.68
test_remote_borg_cmdFunction · 0.68
test_sshMethod · 0.68
test_s3Method · 0.68
test_rcloneMethod · 0.68
test_sftpMethod · 0.68
test_httpMethod · 0.68
test_socketMethod · 0.68