xhtm 0.8__tar.gz → 0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {xhtm-0.8 → xhtm-0.9}/PKG-INFO +1 -1
  2. {xhtm-0.8 → xhtm-0.9}/xhtm.egg-info/PKG-INFO +1 -1
  3. {xhtm-0.8 → xhtm-0.9}/xhtm.egg-info/SOURCES.txt +2 -0
  4. {xhtm-0.8 → xhtm-0.9}/xhtml/attribute.py +1 -1
  5. xhtm-0.9/xhtml/header/authorization.py +61 -0
  6. xhtm-0.9/xhtml/header/cookie.py +29 -0
  7. {xhtm-0.8 → xhtm-0.9}/xhtml/header/headers.py +0 -27
  8. {xhtm-0.8 → xhtm-0.9}/LICENSE +0 -0
  9. {xhtm-0.8 → xhtm-0.9}/README.md +0 -0
  10. {xhtm-0.8 → xhtm-0.9}/setup.cfg +0 -0
  11. {xhtm-0.8 → xhtm-0.9}/setup.py +0 -0
  12. {xhtm-0.8 → xhtm-0.9}/xhtm.egg-info/dependency_links.txt +0 -0
  13. {xhtm-0.8 → xhtm-0.9}/xhtm.egg-info/requires.txt +0 -0
  14. {xhtm-0.8 → xhtm-0.9}/xhtm.egg-info/top_level.txt +0 -0
  15. {xhtm-0.8 → xhtm-0.9}/xhtm.egg-info/zip-safe +0 -0
  16. {xhtm-0.8 → xhtm-0.9}/xhtml/__init__.py +0 -0
  17. {xhtm-0.8 → xhtm-0.9}/xhtml/element/__init__.py +0 -0
  18. {xhtm-0.8 → xhtm-0.9}/xhtml/element/attr.py +0 -0
  19. {xhtm-0.8 → xhtm-0.9}/xhtml/element/css.py +0 -0
  20. {xhtm-0.8 → xhtm-0.9}/xhtml/element/doc.py +0 -0
  21. {xhtm-0.8 → xhtm-0.9}/xhtml/element/tag.py +0 -0
  22. {xhtm-0.8 → xhtm-0.9}/xhtml/header/__init__.py +0 -0
  23. {xhtm-0.8 → xhtm-0.9}/xhtml/header/accept.py +0 -0
  24. {xhtm-0.8 → xhtm-0.9}/xhtml/header/content.py +0 -0
  25. {xhtm-0.8 → xhtm-0.9}/xhtml/locale/__init__.py +0 -0
  26. {xhtm-0.8 → xhtm-0.9}/xhtml/locale/template.py +0 -0
  27. {xhtm-0.8 → xhtm-0.9}/xhtml/resource/__init__.py +0 -0
  28. {xhtm-0.8 → xhtm-0.9}/xhtml/resource/favicon.ico +0 -0
  29. {xhtm-0.8 → xhtm-0.9}/xhtml/resource/logo.svg +0 -0
  30. {xhtm-0.8 → xhtm-0.9}/xhtml/template/__init__.py +0 -0
  31. {xhtm-0.8 → xhtm-0.9}/xhtml/template/hello.html +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xhtm
3
- Version: 0.8
3
+ Version: 0.9
4
4
  Summary: Rendering HTML Text
5
5
  Home-page: https://github.com/bondbox/xhtm
6
6
  Author: Mingzhe Zou
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xhtm
3
- Version: 0.8
3
+ Version: 0.9
4
4
  Summary: Rendering HTML Text
5
5
  Home-page: https://github.com/bondbox/xhtm
6
6
  Author: Mingzhe Zou
@@ -17,7 +17,9 @@ xhtml/element/doc.py
17
17
  xhtml/element/tag.py
18
18
  xhtml/header/__init__.py
19
19
  xhtml/header/accept.py
20
+ xhtml/header/authorization.py
20
21
  xhtml/header/content.py
22
+ xhtml/header/cookie.py
21
23
  xhtml/header/headers.py
22
24
  xhtml/locale/__init__.py
23
25
  xhtml/locale/template.py
@@ -1,7 +1,7 @@
1
1
  # coding:utf-8
2
2
 
3
3
  __project__ = "xhtm"
4
- __version__ = "0.8"
4
+ __version__ = "0.9"
5
5
  __urlhome__ = "https://github.com/bondbox/xhtm"
6
6
  __description__ = "Rendering HTML Text"
7
7
 
@@ -0,0 +1,61 @@
1
+ # coding:utf-8
2
+
3
+ class Authorization():
4
+ class Auth():
5
+ def __init__(self, type: str):
6
+ self.__type: str = type
7
+
8
+ @property
9
+ def type(self):
10
+ return self.__type
11
+
12
+ class Basic(Auth):
13
+ TYPE: str = "Basic"
14
+
15
+ def __init__(self, base64: str):
16
+ from base64 import b64decode
17
+
18
+ nameword: str = b64decode(base64).decode("utf-8")
19
+ username, password = nameword.split(":", maxsplit=1)
20
+ self.__username: str = username
21
+ self.__password: str = password
22
+ super().__init__(self.TYPE)
23
+
24
+ @property
25
+ def username(self):
26
+ return self.__username
27
+
28
+ @property
29
+ def password(self):
30
+ return self.__password
31
+
32
+ class Bearer(Auth):
33
+ TYPE: str = "Bearer"
34
+
35
+ def __init__(self, token: str):
36
+ super().__init__(self.TYPE)
37
+ self.__token = token
38
+
39
+ @property
40
+ def token(self):
41
+ return self.__token
42
+
43
+ class APIKey(Auth):
44
+ TYPE: str = "ApiKey"
45
+
46
+ def __init__(self, key: str):
47
+ super().__init__(self.TYPE)
48
+ self.__key = key
49
+
50
+ @property
51
+ def key(self):
52
+ return self.__key
53
+
54
+ @classmethod
55
+ def paser(cls, authorization: str) -> Auth:
56
+ k, v = authorization.split(" ", maxsplit=1)
57
+ return {
58
+ cls.Basic.TYPE: cls.Basic,
59
+ cls.Bearer.TYPE: cls.Bearer,
60
+ cls.APIKey.TYPE: cls.APIKey,
61
+ }[k](v)
@@ -0,0 +1,29 @@
1
+ # coding:utf-8
2
+
3
+ from typing import Dict
4
+ from typing import Iterator
5
+
6
+
7
+ class Cookies():
8
+ def __init__(self, *cookies: str):
9
+ self.__cookies: Dict[str, str] = {}
10
+ for items in cookies:
11
+ for item in items.split(";"):
12
+ if cookie := item.strip():
13
+ k, v = cookie.split("=", maxsplit=1)
14
+ self.__cookies[k.strip()] = v.strip()
15
+
16
+ def __len__(self) -> int:
17
+ return len(self.__cookies)
18
+
19
+ def __iter__(self) -> Iterator[str]:
20
+ return iter(self.__cookies)
21
+
22
+ def __getitem__(self, key: str) -> str:
23
+ return self.__cookies[key]
24
+
25
+ def __contains__(self, key: str) -> bool:
26
+ return key in self.__cookies
27
+
28
+ def get(self, key: str, default: str = "") -> str:
29
+ return self.__cookies.get(key, default)
@@ -1,8 +1,6 @@
1
1
  # coding:utf-8
2
2
 
3
3
  from enum import Enum
4
- from typing import Dict
5
- from typing import Iterator
6
4
 
7
5
 
8
6
  class RequestLine():
@@ -119,28 +117,3 @@ class Headers(Enum):
119
117
  VARY = "Vary"
120
118
  VIA = "Via"
121
119
  WARNING = "Warning"
122
-
123
-
124
- class Cookies():
125
- def __init__(self, *cookies: str):
126
- self.__cookies: Dict[str, str] = {}
127
- for items in cookies:
128
- for item in items.split(";"):
129
- if cookie := item.strip():
130
- k, v = cookie.split("=", maxsplit=1)
131
- self.__cookies[k.strip()] = v.strip()
132
-
133
- def __len__(self) -> int:
134
- return len(self.__cookies)
135
-
136
- def __iter__(self) -> Iterator[str]:
137
- return iter(self.__cookies)
138
-
139
- def __getitem__(self, key: str) -> str:
140
- return self.__cookies[key]
141
-
142
- def __contains__(self, key: str) -> bool:
143
- return key in self.__cookies
144
-
145
- def get(self, key: str, default: str = "") -> str:
146
- return self.__cookies.get(key, default)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes