xhtm 0.7__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.7 → xhtm-0.9}/PKG-INFO +1 -1
  2. {xhtm-0.7 → xhtm-0.9}/xhtm.egg-info/PKG-INFO +1 -1
  3. {xhtm-0.7 → xhtm-0.9}/xhtm.egg-info/SOURCES.txt +2 -0
  4. {xhtm-0.7 → 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.7 → xhtm-0.9}/xhtml/header/headers.py +52 -27
  8. {xhtm-0.7 → xhtm-0.9}/LICENSE +0 -0
  9. {xhtm-0.7 → xhtm-0.9}/README.md +0 -0
  10. {xhtm-0.7 → xhtm-0.9}/setup.cfg +0 -0
  11. {xhtm-0.7 → xhtm-0.9}/setup.py +0 -0
  12. {xhtm-0.7 → xhtm-0.9}/xhtm.egg-info/dependency_links.txt +0 -0
  13. {xhtm-0.7 → xhtm-0.9}/xhtm.egg-info/requires.txt +0 -0
  14. {xhtm-0.7 → xhtm-0.9}/xhtm.egg-info/top_level.txt +0 -0
  15. {xhtm-0.7 → xhtm-0.9}/xhtm.egg-info/zip-safe +0 -0
  16. {xhtm-0.7 → xhtm-0.9}/xhtml/__init__.py +0 -0
  17. {xhtm-0.7 → xhtm-0.9}/xhtml/element/__init__.py +0 -0
  18. {xhtm-0.7 → xhtm-0.9}/xhtml/element/attr.py +0 -0
  19. {xhtm-0.7 → xhtm-0.9}/xhtml/element/css.py +0 -0
  20. {xhtm-0.7 → xhtm-0.9}/xhtml/element/doc.py +0 -0
  21. {xhtm-0.7 → xhtm-0.9}/xhtml/element/tag.py +0 -0
  22. {xhtm-0.7 → xhtm-0.9}/xhtml/header/__init__.py +0 -0
  23. {xhtm-0.7 → xhtm-0.9}/xhtml/header/accept.py +0 -0
  24. {xhtm-0.7 → xhtm-0.9}/xhtml/header/content.py +0 -0
  25. {xhtm-0.7 → xhtm-0.9}/xhtml/locale/__init__.py +0 -0
  26. {xhtm-0.7 → xhtm-0.9}/xhtml/locale/template.py +0 -0
  27. {xhtm-0.7 → xhtm-0.9}/xhtml/resource/__init__.py +0 -0
  28. {xhtm-0.7 → xhtm-0.9}/xhtml/resource/favicon.ico +0 -0
  29. {xhtm-0.7 → xhtm-0.9}/xhtml/resource/logo.svg +0 -0
  30. {xhtm-0.7 → xhtm-0.9}/xhtml/template/__init__.py +0 -0
  31. {xhtm-0.7 → 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.7
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.7
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.7"
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,58 @@
1
1
  # coding:utf-8
2
2
 
3
3
  from enum import Enum
4
- from typing import Dict
5
- from typing import Iterator
4
+
5
+
6
+ class RequestLine():
7
+ """HTTP requests
8
+
9
+ Reference:
10
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Messages#http_requests
11
+ """
12
+
13
+ def __init__(self, request_line: str):
14
+ method, target, protocol = request_line.split()
15
+ self.__protocol: str = protocol.strip()
16
+ self.__method: str = method.strip()
17
+ self.__target: str = target.strip()
18
+
19
+ @property
20
+ def protocol(self) -> str:
21
+ return self.__protocol
22
+
23
+ @property
24
+ def method(self) -> str:
25
+ return self.__method
26
+
27
+ @property
28
+ def target(self) -> str:
29
+ return self.__target
30
+
31
+
32
+ class StatusLine():
33
+ """HTTP responses
34
+
35
+ Reference:
36
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Messages#http_responses
37
+ """
38
+
39
+ def __init__(self, status_line: str):
40
+ protocol, status_code, status_text = status_line.split(maxsplit=2)
41
+ self.__status_code: int = int(status_code.strip())
42
+ self.__status_text: str = status_text.strip()
43
+ self.__protocol: str = protocol.strip()
44
+
45
+ @property
46
+ def protocol(self) -> str:
47
+ return self.__protocol
48
+
49
+ @property
50
+ def status_code(self) -> int:
51
+ return self.__status_code
52
+
53
+ @property
54
+ def status_text(self) -> str:
55
+ return self.__status_text
6
56
 
7
57
 
8
58
  class Headers(Enum):
@@ -67,28 +117,3 @@ class Headers(Enum):
67
117
  VARY = "Vary"
68
118
  VIA = "Via"
69
119
  WARNING = "Warning"
70
-
71
-
72
- class Cookies():
73
- def __init__(self, *cookies: str):
74
- self.__cookies: Dict[str, str] = {}
75
- for items in cookies:
76
- for item in items.split(";"):
77
- if cookie := item.strip():
78
- k, v = cookie.split("=", maxsplit=1)
79
- self.__cookies[k.strip()] = v.strip()
80
-
81
- def __len__(self) -> int:
82
- return len(self.__cookies)
83
-
84
- def __iter__(self) -> Iterator[str]:
85
- return iter(self.__cookies)
86
-
87
- def __getitem__(self, key: str) -> str:
88
- return self.__cookies[key]
89
-
90
- def __contains__(self, key: str) -> bool:
91
- return key in self.__cookies
92
-
93
- def get(self, key: str, default: str = "") -> str:
94
- 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