python-liquid 2.3.6__py3-none-any.whl → 3.0.0__py3-none-any.whl

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 (212) hide show
  1. liquid/__about__.py +1 -0
  2. liquid/__init__.py +161 -187
  3. liquid/_base_tag.py +66 -0
  4. liquid/{utils/chain_map.py → _chain_map.py} +18 -19
  5. liquid/_context.py +465 -0
  6. liquid/_drop.py +108 -0
  7. liquid/_filter.py +174 -0
  8. liquid/_io.py +18 -0
  9. liquid/_lax_parser_mixin.py +100 -0
  10. liquid/_lexer.py +93 -0
  11. liquid/_lexer_extended.py +623 -0
  12. liquid/_lexer_legacy.py +536 -0
  13. liquid/_loader.py +84 -0
  14. liquid/{utils/lru_cache.py → _lru_cache.py} +28 -36
  15. liquid/_markup.py +253 -0
  16. liquid/_messages.py +292 -0
  17. liquid/_missing.py +3 -0
  18. liquid/_nothing.py +28 -0
  19. liquid/_parser.py +460 -0
  20. liquid/_parser_extended.py +293 -0
  21. liquid/_parser_legacy.py +819 -0
  22. liquid/_resource_limits.py +50 -0
  23. liquid/_slice.py +41 -0
  24. liquid/_static_analysis.py +503 -0
  25. liquid/_strftime.py +186 -0
  26. liquid/_template.py +536 -0
  27. liquid/drops/__init__.py +20 -0
  28. liquid/drops/forloop.py +78 -0
  29. liquid/drops/iterable.py +25 -0
  30. liquid/drops/range.py +76 -0
  31. liquid/drops/self_.py +45 -0
  32. liquid/drops/tablerowloop.py +142 -0
  33. liquid/drops/undefined.py +228 -0
  34. liquid/environment.py +717 -551
  35. liquid/exceptions.py +67 -214
  36. liquid/expressions.py +1184 -0
  37. liquid/filters/__init__.py +134 -0
  38. liquid/filters/abs.py +7 -0
  39. liquid/filters/append.py +5 -0
  40. liquid/filters/at_least.py +9 -0
  41. liquid/filters/at_most.py +9 -0
  42. liquid/filters/babel.py +560 -0
  43. liquid/filters/base64.py +26 -0
  44. liquid/filters/capitalize.py +5 -0
  45. liquid/filters/ceil.py +8 -0
  46. liquid/filters/compact.py +25 -0
  47. liquid/filters/concat.py +11 -0
  48. liquid/filters/date.py +27 -0
  49. liquid/filters/default.py +25 -0
  50. liquid/filters/divided_by.py +21 -0
  51. liquid/filters/downcase.py +5 -0
  52. liquid/filters/escape.py +56 -0
  53. liquid/filters/find.py +56 -0
  54. liquid/filters/first.py +19 -0
  55. liquid/filters/floor.py +8 -0
  56. liquid/filters/html.py +23 -0
  57. liquid/filters/index.py +12 -0
  58. liquid/filters/join.py +13 -0
  59. liquid/filters/json_.py +30 -0
  60. liquid/filters/last.py +17 -0
  61. liquid/filters/map.py +5 -0
  62. liquid/filters/minus.py +13 -0
  63. liquid/filters/modulo.py +18 -0
  64. liquid/filters/newline_to_br.py +16 -0
  65. liquid/filters/plus.py +13 -0
  66. liquid/filters/prepend.py +5 -0
  67. liquid/filters/reject.py +19 -0
  68. liquid/filters/remove.py +36 -0
  69. liquid/filters/replace.py +32 -0
  70. liquid/filters/reverse.py +5 -0
  71. liquid/filters/round.py +35 -0
  72. liquid/filters/size.py +25 -0
  73. liquid/filters/slice.py +39 -0
  74. liquid/filters/sort.py +148 -0
  75. liquid/filters/split.py +34 -0
  76. liquid/filters/squish.py +9 -0
  77. liquid/filters/strip.py +13 -0
  78. liquid/filters/strip_html.py +19 -0
  79. liquid/filters/strip_newlines.py +17 -0
  80. liquid/filters/sum.py +21 -0
  81. liquid/filters/times.py +13 -0
  82. liquid/filters/translate.py +380 -0
  83. liquid/filters/truncate.py +39 -0
  84. liquid/filters/uniq.py +11 -0
  85. liquid/filters/upcase.py +5 -0
  86. liquid/filters/url.py +18 -0
  87. liquid/filters/where.py +18 -0
  88. liquid/loaders/__init__.py +17 -0
  89. liquid/loaders/caching_file_system_loader.py +64 -0
  90. liquid/loaders/choice_loader.py +93 -0
  91. liquid/loaders/dict_loader.py +56 -0
  92. liquid/{builtin/loaders → loaders}/file_system_loader.py +51 -55
  93. liquid/{builtin/loaders → loaders}/mixins.py +39 -51
  94. liquid/loaders/package_loader.py +110 -0
  95. liquid/tags/__init__.py +61 -0
  96. liquid/tags/assign.py +68 -0
  97. liquid/tags/capture.py +83 -0
  98. liquid/tags/case.py +199 -0
  99. liquid/tags/comment.py +56 -0
  100. liquid/tags/cycle.py +131 -0
  101. liquid/tags/decrement.py +55 -0
  102. liquid/tags/doc.py +56 -0
  103. liquid/tags/echo.py +65 -0
  104. liquid/tags/else_.py +53 -0
  105. liquid/tags/error.py +51 -0
  106. liquid/tags/extends.py +448 -0
  107. liquid/tags/for_.py +421 -0
  108. liquid/tags/if_.py +156 -0
  109. liquid/tags/ifchanged.py +69 -0
  110. liquid/tags/include.py +223 -0
  111. liquid/tags/increment.py +55 -0
  112. liquid/tags/inline_comment.py +70 -0
  113. liquid/tags/liquid.py +56 -0
  114. liquid/tags/macro.py +281 -0
  115. liquid/tags/output.py +58 -0
  116. liquid/tags/raw.py +60 -0
  117. liquid/tags/render.py +245 -0
  118. liquid/tags/tablerow.py +254 -0
  119. liquid/tags/template_comment.py +56 -0
  120. liquid/tags/translate.py +316 -0
  121. liquid/tags/unless.py +121 -0
  122. liquid/tags/with_.py +83 -0
  123. liquid/tokens.py +370 -0
  124. {python_liquid-2.3.6.dist-info → python_liquid-3.0.0.dist-info}/METADATA +32 -39
  125. python_liquid-3.0.0.dist-info/RECORD +128 -0
  126. {python_liquid-2.3.6.dist-info → python_liquid-3.0.0.dist-info}/WHEEL +1 -1
  127. {python_liquid-2.3.6.dist-info → python_liquid-3.0.0.dist-info}/licenses/LICENSE +1 -1
  128. liquid/analyze_tags.py +0 -214
  129. liquid/ast.py +0 -252
  130. liquid/builtin/__init__.py +0 -203
  131. liquid/builtin/content.py +0 -41
  132. liquid/builtin/drops/__init__.py +0 -3
  133. liquid/builtin/drops/drops.py +0 -13
  134. liquid/builtin/expressions/__init__.py +0 -47
  135. liquid/builtin/expressions/_tokenize.py +0 -186
  136. liquid/builtin/expressions/arguments.py +0 -207
  137. liquid/builtin/expressions/filtered.py +0 -387
  138. liquid/builtin/expressions/logical.py +0 -672
  139. liquid/builtin/expressions/loop.py +0 -275
  140. liquid/builtin/expressions/path.py +0 -163
  141. liquid/builtin/expressions/primitive.py +0 -417
  142. liquid/builtin/filters/__init__.py +0 -0
  143. liquid/builtin/filters/array.py +0 -329
  144. liquid/builtin/filters/extra.py +0 -83
  145. liquid/builtin/filters/math.py +0 -129
  146. liquid/builtin/filters/misc.py +0 -137
  147. liquid/builtin/filters/string.py +0 -416
  148. liquid/builtin/illegal.py +0 -28
  149. liquid/builtin/loaders/__init__.py +0 -0
  150. liquid/builtin/loaders/caching_file_system_loader.py +0 -61
  151. liquid/builtin/loaders/choice_loader.py +0 -94
  152. liquid/builtin/loaders/dict_loader.py +0 -64
  153. liquid/builtin/loaders/package_loader.py +0 -132
  154. liquid/builtin/output.py +0 -74
  155. liquid/builtin/tags/__init__.py +0 -0
  156. liquid/builtin/tags/assign_tag.py +0 -75
  157. liquid/builtin/tags/capture_tag.py +0 -98
  158. liquid/builtin/tags/case_tag.py +0 -287
  159. liquid/builtin/tags/comment_tag.py +0 -77
  160. liquid/builtin/tags/cycle_tag.py +0 -132
  161. liquid/builtin/tags/decrement_tag.py +0 -59
  162. liquid/builtin/tags/doc_tag.py +0 -68
  163. liquid/builtin/tags/echo_tag.py +0 -45
  164. liquid/builtin/tags/for_tag.py +0 -337
  165. liquid/builtin/tags/if_tag.py +0 -209
  166. liquid/builtin/tags/ifchanged_tag.py +0 -94
  167. liquid/builtin/tags/include_tag.py +0 -251
  168. liquid/builtin/tags/increment_tag.py +0 -60
  169. liquid/builtin/tags/inline_comment_tag.py +0 -47
  170. liquid/builtin/tags/liquid_tag.py +0 -183
  171. liquid/builtin/tags/render_tag.py +0 -371
  172. liquid/builtin/tags/tablerow_tag.py +0 -320
  173. liquid/builtin/tags/unless_tag.py +0 -218
  174. liquid/context.py +0 -615
  175. liquid/expression.py +0 -41
  176. liquid/extra/__init__.py +0 -98
  177. liquid/extra/filters/__init__.py +0 -33
  178. liquid/extra/filters/_json.py +0 -33
  179. liquid/extra/filters/array.py +0 -60
  180. liquid/extra/filters/babel.py +0 -552
  181. liquid/extra/filters/html.py +0 -32
  182. liquid/extra/filters/translate.py +0 -448
  183. liquid/extra/tags/__init__.py +0 -17
  184. liquid/extra/tags/_with.py +0 -80
  185. liquid/extra/tags/extends_tag.py +0 -576
  186. liquid/extra/tags/macro_tag.py +0 -270
  187. liquid/extra/tags/snippet_tag.py +0 -107
  188. liquid/extra/tags/translate_tag.py +0 -388
  189. liquid/filter.py +0 -230
  190. liquid/future/__init__.py +0 -3
  191. liquid/future/environment.py +0 -30
  192. liquid/future/filters/__init__.py +0 -1
  193. liquid/future/tags/__init__.py +0 -1
  194. liquid/lex.py +0 -260
  195. liquid/limits.py +0 -66
  196. liquid/loader.py +0 -141
  197. liquid/messages.py +0 -357
  198. liquid/mode.py +0 -12
  199. liquid/output.py +0 -35
  200. liquid/parser.py +0 -119
  201. liquid/span.py +0 -35
  202. liquid/static_analysis.py +0 -443
  203. liquid/stream.py +0 -148
  204. liquid/stringify.py +0 -31
  205. liquid/tag.py +0 -47
  206. liquid/template.py +0 -658
  207. liquid/token.py +0 -145
  208. liquid/undefined.py +0 -218
  209. liquid/utils/__init__.py +0 -15
  210. liquid/utils/html.py +0 -57
  211. liquid/utils/text.py +0 -28
  212. python_liquid-2.3.6.dist-info/RECORD +0 -96
liquid/token.py DELETED
@@ -1,145 +0,0 @@
1
- """Token definitions."""
2
-
3
- import sys
4
- from typing import NamedTuple
5
-
6
- TOKEN_ILLEGAL = sys.intern("illegal")
7
- TOKEN_INITIAL = sys.intern("initial")
8
- TOKEN_EOF = sys.intern("end of expression")
9
- TOKEN_NEWLINE = sys.intern("newline")
10
- TOKEN_SKIP = sys.intern("skip")
11
-
12
- TOKEN_TAG = sys.intern("tag")
13
- TOKEN_EXPRESSION = sys.intern("expression")
14
- TOKEN_OUTPUT = sys.intern("output")
15
- TOKEN_CONTENT = sys.intern("content")
16
- TOKEN_COMMENT = sys.intern("comment")
17
- TOKEN_DOC = sys.intern("doc")
18
-
19
- TOKEN_WORD = sys.intern("word")
20
- TOKEN_IDENTINDEX = sys.intern("identindex")
21
- TOKEN_IDENTSTRING = sys.intern("identstring")
22
- TOKEN_STRING = sys.intern("string")
23
- TOKEN_INTEGER = sys.intern("integer")
24
- TOKEN_FLOAT = sys.intern("float")
25
- TOKEN_EMPTY = sys.intern("empty")
26
- TOKEN_NIL = sys.intern("nil")
27
- TOKEN_NULL = sys.intern("null")
28
- TOKEN_BLANK = sys.intern("blank")
29
-
30
- # "include" and "render" keywords
31
- TOKEN_WITH = sys.intern("with")
32
- TOKEN_FOR = sys.intern("for")
33
- TOKEN_AS = sys.intern("as")
34
-
35
- # "paginate" keywords
36
- TOKEN_BY = sys.intern("by")
37
-
38
- TOKEN_NEGATIVE = sys.intern("negative")
39
-
40
- TOKEN_TRUE = sys.intern("true")
41
- TOKEN_FALSE = sys.intern("false")
42
-
43
- # String, array and hash membership
44
- TOKEN_CONTAINS = sys.intern("contains")
45
-
46
- # Looping symbols and keywords. Use by `for` and `tablerow` tags.
47
- TOKEN_IN = sys.intern("in")
48
- TOKEN_LPAREN = sys.intern("lparen")
49
- TOKEN_RPAREN = sys.intern("rparen")
50
- TOKEN_RANGE = sys.intern("range")
51
- TOKEN_RANGE_LITERAL = sys.intern("rangeexpression")
52
- TOKEN_LIMIT = sys.intern("limit")
53
- TOKEN_OFFSET = sys.intern("offset")
54
- TOKEN_REVERSED = sys.intern("reversed")
55
- TOKEN_CONTINUE = sys.intern("continue")
56
-
57
- # Tablerow specific argument
58
- TOKEN_COLS = sys.intern("cols")
59
-
60
- # Template inheritance keywords
61
- TOKEN_REQUIRED = sys.intern("required")
62
-
63
- # Comparison symbols and logic operators for `if` and `unless` tags.
64
- TOKEN_EQ = sys.intern("eq")
65
- TOKEN_NE = sys.intern("ne")
66
- TOKEN_LG = sys.intern("ltgt")
67
- TOKEN_LT = sys.intern("lt")
68
- TOKEN_GT = sys.intern("gt")
69
- TOKEN_LE = sys.intern("le")
70
- TOKEN_GE = sys.intern("ge")
71
- TOKEN_AND = sys.intern("and")
72
- TOKEN_OR = sys.intern("or")
73
- TOKEN_NOT = sys.intern("not")
74
- TOKEN_ELSE = sys.intern("else")
75
- TOKEN_IF = sys.intern("if")
76
-
77
-
78
- # Filter symbols
79
- TOKEN_PIPE = sys.intern("pipe")
80
- TOKEN_COLON = sys.intern("colon")
81
- TOKEN_COMMA = sys.intern("comma")
82
- TOKEN_DPIPE = sys.intern("dpipe")
83
-
84
- # Identifier symbols
85
- TOKEN_DOT = sys.intern("dot")
86
- TOKEN_LBRACKET = sys.intern("lbracket")
87
- TOKEN_RBRACKET = sys.intern("rbracket")
88
-
89
- # Assignment
90
- TOKEN_ASSIGN = sys.intern("assign")
91
-
92
- # Non-standard key/value argument separator. Standard liquid uses TOKEN_COLON.
93
- TOKEN_EQUALS = sys.intern("equals")
94
-
95
- operators = {
96
- "==": TOKEN_EQ,
97
- "!=": TOKEN_NE,
98
- "<>": TOKEN_LG,
99
- "<": TOKEN_LT,
100
- ">": TOKEN_GT,
101
- "<=": TOKEN_LE,
102
- ">=": TOKEN_GE,
103
- "|": TOKEN_PIPE,
104
- ":": TOKEN_COLON,
105
- ",": TOKEN_COMMA,
106
- ".": TOKEN_DOT,
107
- "-": TOKEN_NEGATIVE,
108
- "(": TOKEN_LPAREN,
109
- ")": TOKEN_RPAREN,
110
- "..": TOKEN_RANGE,
111
- "[": TOKEN_LBRACKET,
112
- "]": TOKEN_RBRACKET,
113
- "=": TOKEN_ASSIGN,
114
- }
115
-
116
- reverse_operators = {v: k for k, v in operators.items()}
117
-
118
-
119
- class Token(NamedTuple):
120
- """A substring into Liquid template source text along with its type."""
121
-
122
- kind: str
123
- """The type of the token.
124
-
125
- Could be one of `TOKEN_TAG`, `TOKEN_OUTPUT`, `TOKEN_EXPRESSION` or `TOKEN_CONTENT`
126
- indicating that it is a "top-level" token. All other tokens kinds are for tag and
127
- output expressions.
128
- """
129
-
130
- value: str
131
- """The substring associated with this token."""
132
-
133
- start_index: int
134
- """The index into _source_ where this token starts."""
135
-
136
- source: str
137
- """A reference to the template source text from which this token came."""
138
-
139
- def test(self, typ: str) -> bool:
140
- """Return `True` if this token's type matches the `typ` argument."""
141
- return self.kind == typ
142
-
143
- def is_tag(self, name: str) -> bool:
144
- """Return `True` if this token is a tag and has the given name."""
145
- return self.kind == TOKEN_TAG and self.value == name
liquid/undefined.py DELETED
@@ -1,218 +0,0 @@
1
- """Manage undefined template variables.
2
-
3
- When rendering a Liquid template, if a variable name can not be resolved, an instance of
4
- liquid.Undefined, or a subclass, is used instead.
5
- """
6
-
7
- from __future__ import annotations
8
-
9
- from typing import TYPE_CHECKING
10
- from typing import Any
11
- from typing import Iterable
12
- from typing import Iterator
13
- from typing import Mapping
14
- from typing import Optional
15
-
16
- from liquid.exceptions import UndefinedError
17
-
18
- if TYPE_CHECKING:
19
- from liquid import Token
20
-
21
- UNDEFINED = object()
22
-
23
-
24
- class Undefined(Mapping[Any, object]):
25
- """The default undefined type.
26
-
27
- Always evaluates to an empty string. Can be iterated over and indexed without error.
28
- """
29
-
30
- __slots__ = ("name", "obj", "hint", "token")
31
-
32
- def __init__(
33
- self,
34
- name: str,
35
- *,
36
- token: Optional[Token] = None,
37
- obj: object = UNDEFINED,
38
- hint: Optional[str] = None,
39
- ):
40
- self.name = name
41
- self.token = token
42
- self.obj = obj
43
- self.hint = hint
44
-
45
- def __contains__(self, item: object) -> bool:
46
- return False
47
-
48
- def __eq__(self, other: object) -> bool:
49
- return isinstance(other, Undefined) or other is None
50
-
51
- def __getitem__(self, key: str) -> object:
52
- return self
53
-
54
- def __len__(self) -> int:
55
- return 0
56
-
57
- def __iter__(self) -> Iterator[Any]:
58
- return iter([])
59
-
60
- def __str__(self) -> str:
61
- return ""
62
-
63
- def __repr__(self) -> str: # pragma: no cover
64
- return f"Undefined({self.name})"
65
-
66
- def __int__(self) -> int:
67
- return 0
68
-
69
- def __hash__(self) -> int:
70
- return hash(self.name)
71
-
72
- def __reversed__(self) -> Iterable[Any]:
73
- return []
74
-
75
- def __liquid__(self) -> object:
76
- return None
77
-
78
- def poke(self) -> bool:
79
- """Prod the type, giving it the opportunity to raise an exception."""
80
- return True
81
-
82
-
83
- class DebugUndefined(Undefined):
84
- """An undefined that returns debug information when rendered."""
85
-
86
- __slots__ = ()
87
-
88
- def __str__(self) -> str:
89
- if self.hint:
90
- return self.hint
91
- if self.obj is not UNDEFINED:
92
- return f"{type(self.obj).__name__} has no attribute '{self.name}'"
93
- return f"'{self.name}' is undefined"
94
-
95
- def __repr__(self) -> str: # pragma: no cover
96
- return f"Undefined({self.name})"
97
-
98
-
99
- class StrictUndefined(Undefined):
100
- """An undefined that raises an exception for everything other than `repr`."""
101
-
102
- __slots__ = ("msg",)
103
-
104
- # Properties that don't raise an UndefinedError.
105
- allowed_properties = frozenset(
106
- [
107
- "__repr__",
108
- # "__class__",
109
- "force_liquid_default",
110
- "name",
111
- "hint",
112
- "obj",
113
- "msg",
114
- "path",
115
- "token",
116
- ]
117
- )
118
-
119
- def __init__(
120
- self,
121
- name: str,
122
- *,
123
- token: Optional[Token],
124
- obj: object = UNDEFINED,
125
- hint: Optional[str] = None,
126
- ):
127
- super().__init__(name, token=token, obj=obj, hint=hint)
128
- self.msg = self.hint if self.hint else f"'{self.name}' is undefined"
129
-
130
- def __getattribute__(self, name: str) -> object:
131
- if name in object.__getattribute__(self, "allowed_properties"):
132
- return object.__getattribute__(self, name)
133
- raise UndefinedError(object.__getattribute__(self, "msg"), token=self.token)
134
-
135
- def __contains__(self, item: object) -> bool:
136
- raise UndefinedError(self.msg, token=self.token)
137
-
138
- def __eq__(self, other: object) -> bool:
139
- raise UndefinedError(self.msg, token=self.token)
140
-
141
- def __getitem__(self, key: str) -> object:
142
- raise UndefinedError(self.msg, token=self.token)
143
-
144
- def __len__(self) -> int:
145
- raise UndefinedError(self.msg, token=self.token)
146
-
147
- def __iter__(self) -> Iterator[Any]:
148
- raise UndefinedError(self.msg, token=self.token)
149
-
150
- def __str__(self) -> str:
151
- raise UndefinedError(self.msg, token=self.token)
152
-
153
- def __repr__(self) -> str:
154
- return f"StrictUndefined({self.name})"
155
-
156
- def __bool__(self) -> bool:
157
- raise UndefinedError(self.msg, token=self.token)
158
-
159
- def __int__(self) -> int:
160
- raise UndefinedError(self.msg, token=self.token)
161
-
162
- def __hash__(self) -> int:
163
- raise UndefinedError(self.msg, token=self.token)
164
-
165
- def __reversed__(self) -> Iterable[Any]:
166
- raise UndefinedError(self.msg, token=self.token)
167
-
168
-
169
- class StrictDefaultUndefined(StrictUndefined):
170
- """An undefined that plays nicely with the `default` filter."""
171
-
172
- # Force the `default` filter to return its default value
173
- # without inspecting this class type.
174
- force_liquid_default = True
175
-
176
- # # Properties that don't raise an UndefinedError.
177
- # allowed_properties = frozenset(
178
- # [
179
- # "__repr__",
180
- # "force_liquid_default",
181
- # "name",
182
- # "hint",
183
- # "obj",
184
- # "msg",
185
- # ]
186
- # )
187
-
188
-
189
- class FalsyStrictUndefined(StrictUndefined):
190
- """An strict undefined type that can be tested for truthiness."""
191
-
192
- allowed_properties = frozenset(
193
- [
194
- "__repr__",
195
- "__bool__",
196
- "__eq__",
197
- "__liquid__",
198
- "__class__",
199
- "name",
200
- "hint",
201
- "obj",
202
- "msg",
203
- "force_liquid_default",
204
- "path",
205
- "token",
206
- ]
207
- )
208
-
209
- def __bool__(self) -> bool:
210
- return False
211
-
212
- def __eq__(self, other: object) -> bool:
213
- return other is False
214
-
215
-
216
- def is_undefined(obj: object) -> bool:
217
- """Return `True` if `obj` is undefined. `False` otherwise."""
218
- return isinstance(obj, Undefined)
liquid/utils/__init__.py DELETED
@@ -1,15 +0,0 @@
1
- from .chain_map import ReadOnlyChainMap # noqa: D104
2
- from .html import strip_tags
3
- from .lru_cache import LRUCache
4
- from .lru_cache import ThreadSafeLRUCache
5
- from .text import truncate_chars
6
- from .text import truncate_words
7
-
8
- __all__ = (
9
- "LRUCache",
10
- "ThreadSafeLRUCache",
11
- "strip_tags",
12
- "truncate_chars",
13
- "truncate_words",
14
- "ReadOnlyChainMap",
15
- )
liquid/utils/html.py DELETED
@@ -1,57 +0,0 @@
1
- """Utilities for working with strings of HTML."""
2
-
3
- from html.parser import HTMLParser
4
- from typing import Optional
5
-
6
- # ruff: noqa: D102
7
-
8
-
9
- class StripParser(HTMLParser):
10
- """An HTML parser that strips out tags."""
11
-
12
- def __init__(self) -> None:
13
- super().__init__(convert_charrefs=False)
14
- self.reset()
15
- self.script_depth = 0
16
- self.style_depth = 0
17
- self.dat: list[str] = []
18
-
19
- def handle_starttag(self, tag: str, attrs: list[tuple[str, Optional[str]]]) -> None:
20
- if tag == "script":
21
- self.script_depth += 1
22
- elif tag == "style":
23
- self.style_depth += 1
24
- return super().handle_starttag(tag, attrs)
25
-
26
- def handle_endtag(self, tag: str) -> None:
27
- if tag == "script":
28
- self.script_depth -= 1
29
- elif tag == "style":
30
- self.style_depth -= 1
31
- return super().handle_endtag(tag)
32
-
33
- def handle_data(self, data: str) -> None:
34
- if not self.script_depth and not self.style_depth:
35
- self.dat.append(data)
36
-
37
- def handle_entityref(self, name: str) -> None:
38
- if not self.script_depth and not self.style_depth:
39
- self.dat.append(f"&{name};")
40
-
41
- def handle_charref(self, name: str) -> None:
42
- if not self.script_depth and not self.style_depth:
43
- self.dat.append(f"&#{name};")
44
-
45
- def get_data(self) -> str:
46
- """Return accumulated data."""
47
- return "".join(self.dat)
48
-
49
-
50
- def strip_tags(value: str) -> str:
51
- """Return the given value with all HTML tags removed."""
52
- if "<" in value and ">" in value:
53
- parser = StripParser()
54
- parser.feed(value)
55
- parser.close()
56
- return parser.get_data()
57
- return value
liquid/utils/text.py DELETED
@@ -1,28 +0,0 @@
1
- """Text processing utilities."""
2
-
3
-
4
- def truncate_chars(val: str, num: int, end: str = "...") -> str:
5
- """Truncates a string if it is longer than the specified number of characters.
6
- Truncated strings will end with `end`, an ellipsis by default.
7
- """ # noqa: D205
8
- val_length = len(val)
9
- end_length = len(end)
10
-
11
- if val_length < num:
12
- return val
13
-
14
- return f"{val[:num-end_length]}{end}"
15
-
16
-
17
- # Note: truncate_words is no longer used by the truncatewords filter.
18
-
19
-
20
- def truncate_words(val: str, num: int, end: str = "...") -> str: # pragma: no cover
21
- """Truncates a string down to the number of words passed as the first parameter."""
22
- # Replaces consecutive whitespace with a single newline.
23
- words = val.split()
24
-
25
- if len(words) < num:
26
- return " ".join(words)
27
-
28
- return " ".join(words[:num]) + end
@@ -1,96 +0,0 @@
1
- liquid/__init__.py,sha256=bpF7HaxYagzD51WtLErxRvxMLSm0_XWUuoXkjg2xhMM,7696
2
- liquid/analyze_tags.py,sha256=Uc1nueKLRiIejs2JyQIC7u2pxp9l-5HJAMWlg-Qj1m8,7615
3
- liquid/ast.py,sha256=4ZqSbuW4mv9IvoIMPk3OICUaOI1vPh8P8uFCrXI_3XA,8140
4
- liquid/context.py,sha256=GYMG5-u3JI3w1jN_osEtyNsjziWgjBBMFZTilJEMap0,21931
5
- liquid/environment.py,sha256=7lq5Y6jAaN6dzWMbqXYnUcSBuOke768xoPidP-WK2Y4,24157
6
- liquid/exceptions.py,sha256=NNEWqVdY2QCjCvTtfqnV0_b1C0jL96IHOn6NlnabBXY,8451
7
- liquid/expression.py,sha256=Ozgajah2R5eg1yWA4ITFGaMFoOLt8GIjkE1NKqbBEzk,1143
8
- liquid/filter.py,sha256=3NtqGk6nHNwe6ux3X6ZIzzcEMJNA_SaMrBmMQA8hf-I,6735
9
- liquid/lex.py,sha256=vM8mU7OnqH_nLlvnT0S3GJT2VxdnXjRXr_TRkp2y2ZE,8139
10
- liquid/limits.py,sha256=BxqiC4Ax5iadmh6jDRcUNjFfOvbMkvZ1a046R1Cb8UA,1700
11
- liquid/loader.py,sha256=R_RniSRszCXmRVZgXlu9WjV130cWvspVcC3vIVpf-qg,4381
12
- liquid/messages.py,sha256=r6OcJG4-dLEULc9JtQ-mh3Jf6nNZ9Aa2reun7zYiUyc,11861
13
- liquid/mode.py,sha256=pgMF9oEl5nT5Q3Poi1gfWG9ozSXX5B6f4sfzOQX_Gow,206
14
- liquid/output.py,sha256=1rgPmXGWUTut-aBBbHs-TCCZ2UGUhmbJYRmCsnqIOCk,1000
15
- liquid/parser.py,sha256=vh24F3c-fJj_IlbugoDHd3Smhkc_Ns8jpGk9otvlq7s,4072
16
- liquid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- liquid/span.py,sha256=Z7Xb5V_h3WLvVmZUBebZeZkJFHKa33Bfcqq3S60SMSk,1122
18
- liquid/static_analysis.py,sha256=iPUqxiufXyK5EoPZQ9WNRKAzkqBYiX1HaSfX8oZhL9c,14537
19
- liquid/stream.py,sha256=WAP9iPanapyY6ObQvw5ksa-5iLxNPjxRLYjkG6JmxpE,4939
20
- liquid/stringify.py,sha256=TkRO0KbZVCY3usNV6EXfG6CbtWhuLoI7joxcrEArSNE,892
21
- liquid/tag.py,sha256=h5jexl6NjUQnM2py4s5db1ksh0s8vi31YHud5kHJt1E,1189
22
- liquid/template.py,sha256=ne1abyNX8Tytl-d-vAROxtn-hHt_-O4nrn0eb2b_5fU,24062
23
- liquid/token.py,sha256=gxqMGcGk1fWihz5gQ2BQJzqSEcY7tCAZiIjcdC34P1w,3995
24
- liquid/undefined.py,sha256=Y57D69YR6yXSHV4x1rg1xtoTe-6M49h-mqlSO7pcRSE,5673
25
- liquid/builtin/__init__.py,sha256=YNQlg5dzSBnU4asR_1yX111l6Cl1Rj_JqwEnOdT7l5U,7090
26
- liquid/builtin/content.py,sha256=HXo2ty2cQxsOkXJDhWmcAWC0ny73w9oABaer50zGp70,1122
27
- liquid/builtin/illegal.py,sha256=RRzzlqo2_scdtbMt_hZq0pr-7khgbxrdub9XH-_goPs,844
28
- liquid/builtin/output.py,sha256=4r_QJimFTbBdubhdIOG_nweROEOXiWHlp_xNmWXy564,2279
29
- liquid/builtin/drops/__init__.py,sha256=ewOQFD_O5Wul9xWsTBzo-XuKSdvN6K3hbcQF8VdKmtM,75
30
- liquid/builtin/drops/drops.py,sha256=WF5vWNnFj1-huldxYeSzEJcjabvxdODApf817ZaycaE,366
31
- liquid/builtin/expressions/__init__.py,sha256=5scdgzOrMK9SxKpab3ebJnfO56Dl4bYLXO6xXgkCGrc,1256
32
- liquid/builtin/expressions/_tokenize.py,sha256=p7RbeOg8iwXDnW0fIL4_7FSrBulkPYrCm3ialpEIsDE,5737
33
- liquid/builtin/expressions/arguments.py,sha256=hlZh7LLFT5UismTo7mTlVjM87_ihUJo0BYuCxyTwKMI,6448
34
- liquid/builtin/expressions/filtered.py,sha256=FqPNZLjwDdlCfivtBa7e0wuQYwcJdKUl3_UY9AS3zG4,13073
35
- liquid/builtin/expressions/logical.py,sha256=6yCJjUOPvJ_ZE7xL6iDtc3-7bivoUVdGHYkUOp0WUgk,20982
36
- liquid/builtin/expressions/loop.py,sha256=F2mBD9_bXtarzmEKstak_u50cXF9ijlKs9Ip2Q_BbsQ,8839
37
- liquid/builtin/expressions/path.py,sha256=m1J33uIuEFlUaRXR_-G6qcsClOm0B5jbTZ0Pdt1P7Ak,5703
38
- liquid/builtin/expressions/primitive.py,sha256=MTREfbutdN-N0gDYrWrtP8X2cEUFUW3rs6nJmqv37rU,11378
39
- liquid/builtin/filters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- liquid/builtin/filters/array.py,sha256=jy35hoouAWI1yG2JX5OMG39Az2dmP--4IcuwqT59JMY,10281
41
- liquid/builtin/filters/extra.py,sha256=m13_1nbZyRBl3CZV9WWGLlUZueRPt8cKPEHRAioqM_o,2710
42
- liquid/builtin/filters/math.py,sha256=A_K2wg5gxm5Ncj9zMGDX_Lt7jjx4bRr3CywbCiCtqxo,3925
43
- liquid/builtin/filters/misc.py,sha256=12Sq2MYbPSrPg_CjBI4pDrTgLHmnDY7nQfar_R0_YZU,3768
44
- liquid/builtin/filters/string.py,sha256=mWG-14HttAqyPA1atLmwdXjbxwDpAowookbadk_jijI,12164
45
- liquid/builtin/loaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- liquid/builtin/loaders/caching_file_system_loader.py,sha256=V4OLa6UGT-RELGiV4eu02TeLL4P_JIE2kMYMrO3qy8U,2158
47
- liquid/builtin/loaders/choice_loader.py,sha256=FE23RLMOiWmsRGZv9t6QmlG7bgMEUSblnucAv3j0SBM,2816
48
- liquid/builtin/loaders/dict_loader.py,sha256=8TdMJqaYPLwllmIiEmuZNXqH6UOOsi4HuJ2t5sztOOw,1785
49
- liquid/builtin/loaders/file_system_loader.py,sha256=RZBpQXfqR-esrNVsR5BRYszf9tRD3_LkGRkoYrwqbq8,5052
50
- liquid/builtin/loaders/mixins.py,sha256=x83ir6zGZsLvDoJbeHvwGzTZDm150vvLjhpxKyO9H6k,5209
51
- liquid/builtin/loaders/package_loader.py,sha256=PNg-ygoRjfiALFu3bzEDRdps30rtsTIkt0voJKs9zCo,4061
52
- liquid/builtin/tags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
- liquid/builtin/tags/assign_tag.py,sha256=VTfkPbF-i0KLqMmaacBItFQHaBTP7ECWR-RvVh9Q6lY,2374
54
- liquid/builtin/tags/capture_tag.py,sha256=7bOG7qVwcqRx1eStb96AZKQ9tKLBjmzaYAe27LJTIm4,3037
55
- liquid/builtin/tags/case_tag.py,sha256=8ZN3pWP6axr-y7XAGIDjOkTDis0KSxpw7m1ITSElOVw,9040
56
- liquid/builtin/tags/comment_tag.py,sha256=BMvee7nVBim_iDScKWbcUBCxNXzbBvguYfQUG3GM1y8,2250
57
- liquid/builtin/tags/cycle_tag.py,sha256=Vl3DuDBkfpDKk2hxcLM99gFW1-OjWC2APHr23iGXkVE,3943
58
- liquid/builtin/tags/decrement_tag.py,sha256=WgkwWqjJgzjfEKffTKNw0ao6N0JxniadxGO_n1k8oZE,1660
59
- liquid/builtin/tags/doc_tag.py,sha256=luc2QI-4N7KF49vWak6dNm5Hs9jwlXTAfUlEsr6ZCNM,2055
60
- liquid/builtin/tags/echo_tag.py,sha256=VvYth9VuA-A9bsfGUOLlM4QxL_frsgWena3yBrrLKPI,1174
61
- liquid/builtin/tags/for_tag.py,sha256=vVSc9WJ0ZeLW8zgDwNs_dVr8qe9lrg92Ny90GmpO_Jo,9440
62
- liquid/builtin/tags/if_tag.py,sha256=4hGDjQo33PXxsXui6pZ75Wx2BkEtt5SOiZoK3Yb2pL8,6588
63
- liquid/builtin/tags/ifchanged_tag.py,sha256=VpJNDhT7MFXcNmRrYiWcJ9whhaRXh81oe_phatS5_Kg,2734
64
- liquid/builtin/tags/include_tag.py,sha256=eAnjcbJ2-e0382TkrV2WJ9dACFWi_UNUeKG-QRuiOig,9220
65
- liquid/builtin/tags/increment_tag.py,sha256=SV2nrbE90l4iz36WCROqGE0RkkzztWUpU1_Pyp2DDQo,1662
66
- liquid/builtin/tags/inline_comment_tag.py,sha256=hLLtvaI-VpJxzFeoLTwDTj46g13A1ke6blqVo2MP0Cs,1357
67
- liquid/builtin/tags/liquid_tag.py,sha256=o3ybbBmjIY94y_PpOUbgSwktENrGJ-jhZ124-rTlM4Q,5524
68
- liquid/builtin/tags/render_tag.py,sha256=iYWjKYQBmGHQVQ9OZgPZvVhraygFdmPzITin7cKJI5E,14309
69
- liquid/builtin/tags/tablerow_tag.py,sha256=IFG3G8e2zn94H-qFtlCaqYK46msNybp3LqbSlNIsI84,9052
70
- liquid/builtin/tags/unless_tag.py,sha256=udlHvVxILJsYfDaWRkj6Ynmnz2-2FF5RfkP0eizXt7k,6932
71
- liquid/extra/__init__.py,sha256=KrE9DAkwCAOLIaBHt73pnL6sb1tN5-UEKoQsX1b43Gg,2886
72
- liquid/extra/filters/__init__.py,sha256=tsEfSmaJvd6xN8DfKISPOm_KcHOmBVc4RSQqViD8NvY,733
73
- liquid/extra/filters/_json.py,sha256=Od7iJWKCWQzf1eZiIqOG1LGwx2JTiHCe95GO5DqgHYY,844
74
- liquid/extra/filters/array.py,sha256=QvuP2jPg0G4xgIGXOcCRvjpX0O5h7U-WpayAaYmYDdc,1590
75
- liquid/extra/filters/babel.py,sha256=K0kvw8r5Xy4NwvX4qv-lym14rZ25gB4fCnHqj-IVagI,19187
76
- liquid/extra/filters/html.py,sha256=j6ghLorvxlVwAtyfVJlmB1tnroGJb8hD-uxUVALVSEQ,929
77
- liquid/extra/filters/translate.py,sha256=PDEgvmdOvg45ChAKLsaqtamOqaBWOFh4XzQC8igXIyE,13019
78
- liquid/extra/tags/__init__.py,sha256=iqB5oOPYhZey-dyljrgAjGeni4lK8Q9-rW2cGRHa4hw,383
79
- liquid/extra/tags/_with.py,sha256=gZ3SjoQoSVFFsayMZQJimwwRpHK4c_tsuKU7wZvL0Hk,2432
80
- liquid/extra/tags/extends_tag.py,sha256=3PL1y1FHaeh6L4rA_Xz6wP6l5oHdiOY_u42ivS6c3xE,17893
81
- liquid/extra/tags/macro_tag.py,sha256=ErjPxOVB50KKn2qi7-2Icmrbx5Uldv2vUSj49TCs4bY,8749
82
- liquid/extra/tags/snippet_tag.py,sha256=8tFZWDvwhRId5IV0mNKhkFswJx3eTeAYs7-nAwiorNY,3155
83
- liquid/extra/tags/translate_tag.py,sha256=wv2uK9QtWDrArVeAWmH2QQ7fkM5EAM4gK2bWjlstcnE,12515
84
- liquid/future/__init__.py,sha256=5BUZi58WyWjPQDflh2C3sQJmuSKAZgNG_286ERyYKFE,79
85
- liquid/future/environment.py,sha256=Zx4RbgIOMmH5N_VH9poOGRLcSI9DAA5_EkUlP-L6ZlA,986
86
- liquid/future/filters/__init__.py,sha256=0eVFfVd2aZXTZHFXcLZnFk8MftII4cMhRBBYt3Hm3LI,13
87
- liquid/future/tags/__init__.py,sha256=0eVFfVd2aZXTZHFXcLZnFk8MftII4cMhRBBYt3Hm3LI,13
88
- liquid/utils/__init__.py,sha256=xNdanW5X6qXphmzK8fSrBeR1h6AwCtEGHmEvcrmDxAc,366
89
- liquid/utils/chain_map.py,sha256=nxkw3wwF6ddlGarIuL7Ii2elm4dU80LySgdQx1oift0,1517
90
- liquid/utils/html.py,sha256=TmqOOpRMsy7fqZLj7X5ybd_XQnWW2YDAVDwTP1Gwf40,1706
91
- liquid/utils/lru_cache.py,sha256=sDum97lCXOIHnT1zFsI36rfLWM9nv2y6xSSzxDnq_E4,4021
92
- liquid/utils/text.py,sha256=1SwDECNMaqnnZ05je_AZZgxqzZd6U-mvq5jNU3W1-Qk,841
93
- python_liquid-2.3.6.dist-info/METADATA,sha256=KvEELu7O5fCkBqFk8mCFfWr_xYRAeHX5OU_D_L9xGBc,6837
94
- python_liquid-2.3.6.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
95
- python_liquid-2.3.6.dist-info/licenses/LICENSE,sha256=yAFURzud5ERNHt1rZIPnTLJ92ep7q8y5yG9g5DUMR_E,1075
96
- python_liquid-2.3.6.dist-info/RECORD,,