Library-wide settings interface.
| 46 | |
| 47 | |
| 48 | class Settings: |
| 49 | """Library-wide settings interface.""" |
| 50 | |
| 51 | __slots__ = '_default_tls_verify_paths', '_ssl_cert_dir', '_ssl_cert_file' |
| 52 | |
| 53 | _search_path = SearchPathList() |
| 54 | _default_tls_verify_paths: DefaultVerifyPaths | None |
| 55 | _ssl_cert_file: str | bytes | None |
| 56 | _ssl_cert_dir: str | bytes | None |
| 57 | |
| 58 | def __init__(self) -> None: |
| 59 | """Initialize global pygit2 and libgit2 settings.""" |
| 60 | self._initialize_tls_certificate_locations() |
| 61 | |
| 62 | def _initialize_tls_certificate_locations(self) -> None: |
| 63 | """Set up initial TLS file and directory lookup locations.""" |
| 64 | self._default_tls_verify_paths = get_default_verify_paths() |
| 65 | try: |
| 66 | self.set_ssl_cert_locations( |
| 67 | self._default_tls_verify_paths.cafile, |
| 68 | self._default_tls_verify_paths.capath, |
| 69 | ) |
| 70 | except GitError as git_err: |
| 71 | valid_msg = "TLS backend doesn't support certificate locations" |
| 72 | if str(git_err) != valid_msg: |
| 73 | raise |
| 74 | self._default_tls_verify_paths = None |
| 75 | self._ssl_cert_file = None |
| 76 | self._ssl_cert_dir = None |
| 77 | |
| 78 | @property |
| 79 | def search_path(self) -> SearchPathList: |
| 80 | """Configuration file search path. |
| 81 | |
| 82 | This behaves like an array whose indices correspond to ConfigLevel values. |
| 83 | The local search path cannot be changed. |
| 84 | """ |
| 85 | return self._search_path |
| 86 | |
| 87 | @property |
| 88 | def mwindow_size(self) -> int: |
| 89 | """Get or set the maximum mmap window size""" |
| 90 | return option(Option.GET_MWINDOW_SIZE) |
| 91 | |
| 92 | @mwindow_size.setter |
| 93 | def mwindow_size(self, value: int) -> None: |
| 94 | option(Option.SET_MWINDOW_SIZE, value) |
| 95 | |
| 96 | @property |
| 97 | def mwindow_mapped_limit(self) -> int: |
| 98 | """ |
| 99 | Get or set the maximum memory that will be mapped in total by the |
| 100 | library |
| 101 | """ |
| 102 | return option(Option.GET_MWINDOW_MAPPED_LIMIT) |
| 103 | |
| 104 | @mwindow_mapped_limit.setter |
| 105 | def mwindow_mapped_limit(self, value: int) -> None: |
no test coverage detected
searching dependent graphs…