|
1 | 1 | import uuid |
| 2 | +from logging import Logger |
2 | 3 |
|
3 | 4 | from afw_runtime import AFWFuncAbc, AFWResponse |
4 | 5 |
|
5 | 6 |
|
6 | 7 | class AFWFunc(AFWFuncAbc): |
7 | | - _data: uuid.UUID | None = None |
| 8 | + _uuid: uuid.UUID | None = None |
8 | 9 | _tips = False |
9 | 10 |
|
10 | | - def make_responses_from_uuid(self, u: uuid.UUID) -> list[AFWResponse]: |
| 11 | + def make_responses_from_uuid(self) -> list[AFWResponse]: |
11 | 12 | return [ |
12 | 13 | AFWResponse( |
13 | | - title=str(u), |
| 14 | + title=str(self._uuid), |
14 | 15 | subtitle="The UUID as a 32-character lowercase hexadecimal string with dash.", |
15 | 16 | icon=self.icon_info, |
16 | 17 | ), |
17 | 18 | AFWResponse( |
18 | | - title=u.hex, |
| 19 | + title=self._uuid.hex, |
19 | 20 | subtitle="The UUID as a 32-character lowercase hexadecimal string.", |
20 | 21 | icon=self.icon_info, |
21 | 22 | ), |
22 | 23 | AFWResponse( |
23 | | - title=str(u.int), |
| 24 | + title=str(self._uuid.int), |
24 | 25 | subtitle="The UUID as a 128-bit integer.", |
25 | 26 | icon=self.icon_info, |
26 | 27 | ), |
27 | 28 | AFWResponse( |
28 | | - title=str(u.urn), |
| 29 | + title=str(self._uuid.urn), |
29 | 30 | subtitle="The UUID as a URN as specified in RFC 4122.", |
30 | 31 | icon=self.icon_info, |
31 | 32 | ), |
32 | 33 | AFWResponse( |
33 | | - title=f"{u.version}", |
| 34 | + title=f"{self._uuid.version}", |
34 | 35 | subtitle="The UUID version number (1 through 5, specified is RFC_4122).", |
35 | 36 | icon=self.icon_info, |
36 | 37 | arg=4, |
@@ -80,20 +81,20 @@ def _guess_input(self) -> uuid.UUID | None: |
80 | 81 | return u |
81 | 82 |
|
82 | 83 | def _createa_responses(self): |
83 | | - if self._data: |
84 | | - self.append_responses(self.make_responses_from_uuid(self._data)) |
| 84 | + if self._uuid: |
| 85 | + self.append_responses(self.make_responses_from_uuid()) |
85 | 86 |
|
86 | 87 | if self._tips: |
87 | 88 | self.append_tips() |
88 | 89 |
|
89 | 90 | def _process(self) -> None: |
90 | | - self._data = self._guess_input() |
91 | | - if self._data is None: |
| 91 | + self._uuid = self._guess_input() |
| 92 | + if self._uuid is None: |
92 | 93 | self._tips = True |
93 | 94 |
|
94 | 95 | self._createa_responses() |
95 | 96 | return |
96 | 97 |
|
97 | 98 |
|
98 | | -def main(args: list[str], logger) -> list[AFWResponse]: |
| 99 | +def main(args: list[str], logger: Logger) -> list[dict]: |
99 | 100 | return AFWFunc(args, logger)() |
0 commit comments