(
name: str,
permissions: abc.Iterable[T.Union[int, Permission]],
verify: bool = True,
exact: bool = False,
api_url: str = DEFAULT_API_URL,
)
| 42 | |
| 43 | |
| 44 | def cli_request_api_key( |
| 45 | name: str, |
| 46 | permissions: abc.Iterable[T.Union[int, Permission]], |
| 47 | verify: bool = True, |
| 48 | exact: bool = False, |
| 49 | api_url: str = DEFAULT_API_URL, |
| 50 | ) -> str: |
| 51 | while True: |
| 52 | input( |
| 53 | 'Navigate to "services->review services->local->client api" in the Hydrus client and click "add->from api ' |
| 54 | 'request". Then press enter to continue...' |
| 55 | ) |
| 56 | access_key = Client(api_url=api_url).request_new_permissions(name, permissions) |
| 57 | input( |
| 58 | "Press OK and then apply in the Hydrus client dialog. Then press enter to continue..." |
| 59 | ) |
| 60 | |
| 61 | client = Client(access_key, api_url) |
| 62 | if verify and not verify_permissions(client, permissions, exact): |
| 63 | granted = client.verify_access_key()["basic_permissions"] |
| 64 | print( |
| 65 | f"The granted permissions ({granted}) differ from the requested permissions ({permissions}), please " |
| 66 | "grant all requested permissions." |
| 67 | ) |
| 68 | continue |
| 69 | |
| 70 | return access_key |
| 71 | |
| 72 | |
| 73 | def parse_hydrus_metadata( |
nothing calls this directly
no test coverage detected