|
22 | 22 | import xdg.BaseDirectory
|
23 | 23 |
|
24 | 24 |
|
25 |
| -__version__ = "3.1.0" |
| 25 | +__version__ = "3.2.0" |
26 | 26 |
|
27 | 27 | LOGGER = logging.getLogger()
|
28 | 28 | CONFIG_FILE_NAME = "git-pass-mapping.ini"
|
@@ -314,6 +314,13 @@ def get_value(
|
314 | 314 | ),
|
315 | 315 | "entry_name": EntryNameExtractor(option_suffix="_username"),
|
316 | 316 | }
|
| 317 | +_password_extractors = { |
| 318 | + _line_extractor_name: SpecificLineExtractor(0, 0, option_suffix="_password"), |
| 319 | + "regex_search": RegexSearchExtractor( |
| 320 | + r"^password: +(.*)$", option_suffix="_password" |
| 321 | + ), |
| 322 | + "entry_name": EntryNameExtractor(option_suffix="_password"), |
| 323 | +} |
317 | 324 |
|
318 | 325 |
|
319 | 326 | def find_mapping_section(
|
@@ -386,7 +393,17 @@ def get_password(
|
386 | 393 |
|
387 | 394 | pass_target = define_pass_target(section, request)
|
388 | 395 |
|
389 |
| - password_extractor = SpecificLineExtractor(0, 0, option_suffix="_password") |
| 396 | + password_extractor_name: str = section.get("password_extractor") # type: ignore |
| 397 | + |
| 398 | + if password_extractor_name: |
| 399 | + password_extractor = _password_extractors.get(password_extractor_name) |
| 400 | + else: |
| 401 | + password_extractor = SpecificLineExtractor(0, 0, option_suffix="_password") |
| 402 | + |
| 403 | + if password_extractor is None: |
| 404 | + raise ValueError( |
| 405 | + f"A password_extractor of type '{password_extractor_name}' does not exist" |
| 406 | + ) |
390 | 407 | password_extractor.configure(section)
|
391 | 408 |
|
392 | 409 | username_extractor_name: str = section.get( # type: ignore
|
|
0 commit comments