Coverage for src/fastapi_cloud_cli/commands/domains/_shared.py: 100%
11 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
1import string 1abcdefg
3from rich_toolkit.menu import Option 1abcdefg
5from fastapi_cloud_cli.api import CustomDomain 1abcdefg
6from fastapi_cloud_cli.utils.cli import FastAPIRichToolkit 1abcdefg
9def _normalize_domain_name(name: str) -> str: 1abcdefg
10 return name.strip(string.whitespace + ".").lower() 2xbybzbAbBbCbDbEbh i j k l m n o p q r s t u v FbGbHbIbJbKbLbMbw x y z A B C D E F G H I J K NbObPbQbRbSbTbUbL M N O P Q R S T U V W X Y Z VbWbXbYbZb0b1b2b0 1 2 3 4 5 6 7 8 9 ! # $ % ' 3b4b5b6b7b8b9b!b( ) * + , - . / : ; = ? @ [ ] #b$b%b'b(b)b*b+b^ _ ` { | } ~ abbbcbdbebfbgbhb,b-b.b/b:b;b=b?bibjbkblbmbnbobpbqbrbsbtbubvbwb
13def _find_custom_domain( 1abcdefg
14 domains: list[CustomDomain],
15 name_or_id: str,
16) -> CustomDomain | None:
17 normalized = _normalize_domain_name(name_or_id) 2h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwb
19 return next( 2h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwb
20 (
21 domain
22 for domain in domains
23 if domain.id.lower() == normalized
24 or _normalize_domain_name(domain.name) == normalized
25 ),
26 None,
27 )
30def _select_custom_domain( 1abcdefg
31 toolkit: FastAPIRichToolkit,
32 domains: list[CustomDomain],
33 *,
34 prompt: str,
35) -> CustomDomain:
36 return toolkit.ask( 2@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckc
37 prompt,
38 options=[Option({"name": domain.name, "value": domain}) for domain in domains],
39 bullet=False,
40 )