pypage 2.1.0__py3-none-any.whl → 2.2.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.
- {pypage-2.1.0.dist-info → pypage-2.2.0.dist-info}/METADATA +14 -4
- pypage-2.2.0.dist-info/RECORD +7 -0
- {pypage-2.1.0.dist-info → pypage-2.2.0.dist-info}/WHEEL +1 -1
- pypage.py +55 -1
- pypage-2.1.0.dist-info/RECORD +0 -7
- {pypage-2.1.0.dist-info → pypage-2.2.0.dist-info}/entry_points.txt +0 -0
- {pypage-2.1.0.dist-info → pypage-2.2.0.dist-info/licenses}/LICENSE.txt +0 -0
- {pypage-2.1.0.dist-info → pypage-2.2.0.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,9 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: pypage
|
3
|
-
Version: 2.
|
4
|
-
Summary:
|
3
|
+
Version: 2.2.0
|
4
|
+
Summary: Light-weight Python Templating Engine
|
5
5
|
Home-page: https://github.com/arjun-menon/pypage
|
6
|
-
Download-URL: https://github.com/arjun-menon/pypage/archive/v2.
|
6
|
+
Download-URL: https://github.com/arjun-menon/pypage/archive/v2.2.0.tar.gz
|
7
7
|
Author: Arjun G. Menon
|
8
8
|
Author-email: contact@arjungmenon.com
|
9
9
|
License: Apache-2.0
|
@@ -24,6 +24,16 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
24
24
|
Classifier: Programming Language :: Python :: 2
|
25
25
|
Classifier: Programming Language :: Python :: 3
|
26
26
|
License-File: LICENSE.txt
|
27
|
+
Dynamic: author
|
28
|
+
Dynamic: author-email
|
29
|
+
Dynamic: classifier
|
30
|
+
Dynamic: description
|
31
|
+
Dynamic: download-url
|
32
|
+
Dynamic: home-page
|
33
|
+
Dynamic: keywords
|
34
|
+
Dynamic: license
|
35
|
+
Dynamic: license-file
|
36
|
+
Dynamic: summary
|
27
37
|
|
28
38
|
PyPage |pypi| |docs| |test|
|
29
39
|
===========================
|
@@ -0,0 +1,7 @@
|
|
1
|
+
pypage.py,sha256=s6OuUUo_nZjpS9aZFaXMBXlUvBUDSiF_3DzIoaE2uW4,30890
|
2
|
+
pypage-2.2.0.dist-info/licenses/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
3
|
+
pypage-2.2.0.dist-info/METADATA,sha256=GDhXXdpQcCAnSziU-5_Z9P1QujNlnSFUAY9sXggefWU,18347
|
4
|
+
pypage-2.2.0.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
5
|
+
pypage-2.2.0.dist-info/entry_points.txt,sha256=iHPN6EfIUdv-njh8GV04yDTzkcCLGNcXvdbA43s_8mo,39
|
6
|
+
pypage-2.2.0.dist-info/top_level.txt,sha256=8AAB15dVQEt9xcwH_eLcVUZEbFlc__81RA5mOrYtJiQ,7
|
7
|
+
pypage-2.2.0.dist-info/RECORD,,
|
pypage.py
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
from __future__ import print_function
|
19
19
|
import string, sys, time, os, json
|
20
20
|
|
21
|
-
pypage_version = '2.
|
21
|
+
pypage_version = '2.2.0'
|
22
22
|
|
23
23
|
class RootNode(object):
|
24
24
|
"""
|
@@ -303,6 +303,51 @@ class WhileBlock(BlockTag):
|
|
303
303
|
|
304
304
|
return output
|
305
305
|
|
306
|
+
class DefBlock(BlockTag):
|
307
|
+
"""
|
308
|
+
The function tag. {% def foo a b c %}
|
309
|
+
"""
|
310
|
+
tag_startswith = 'def '
|
311
|
+
|
312
|
+
@staticmethod
|
313
|
+
def identify(src):
|
314
|
+
return src.strip().startswith(DefBlock.tag_startswith)
|
315
|
+
|
316
|
+
def __init__(self, node):
|
317
|
+
super(DefBlock, self).__init__(node.loc)
|
318
|
+
self.src = node.src.strip()
|
319
|
+
|
320
|
+
name_and_args = self.src[len(self.tag_startswith):].strip().split()
|
321
|
+
for name in name_and_args:
|
322
|
+
if not isidentifier(name):
|
323
|
+
raise InvalidDefBlockFunctionOrArgName(name)
|
324
|
+
|
325
|
+
self.funcname = name_and_args[0]
|
326
|
+
self.argnames = name_and_args[1:]
|
327
|
+
|
328
|
+
def run(self, pe):
|
329
|
+
def invoke(args):
|
330
|
+
if len(args) != len(self.argnames):
|
331
|
+
raise InvalidDefBlockMismatchingArgCount(self.argnames, args)
|
332
|
+
|
333
|
+
conflicting = set(pe.env.keys()) & set(self.argnames)
|
334
|
+
backup = { x : pe.env[x] for x in conflicting }
|
335
|
+
|
336
|
+
local_vars = dict(zip(self.argnames, args))
|
337
|
+
pe.env.update(local_vars)
|
338
|
+
|
339
|
+
output = exec_tree(self, pe)
|
340
|
+
|
341
|
+
for argname in self.argnames:
|
342
|
+
if argname in pe.env:
|
343
|
+
del pe.env[argname]
|
344
|
+
|
345
|
+
pe.env.update(backup)
|
346
|
+
return output
|
347
|
+
|
348
|
+
pe.env[self.funcname] = lambda *args: invoke(args)
|
349
|
+
return ""
|
350
|
+
|
306
351
|
class CaptureBlock(BlockTag):
|
307
352
|
"""
|
308
353
|
Capture all content within this tag, and bind it to a variable.
|
@@ -449,6 +494,15 @@ class InvalidCaptureBlockVariableName(PypageSyntaxError):
|
|
449
494
|
def __init__(self, varname):
|
450
495
|
self.description = "Incorrect CaptureBlock: '%s' is not a valid Python variable name." % varname
|
451
496
|
|
497
|
+
class InvalidDefBlockFunctionOrArgName(PypageSyntaxError):
|
498
|
+
def __init__(self, varname):
|
499
|
+
self.description = "Incorrect DefBlock: '%s' is not a valid function or argument name." % varname
|
500
|
+
|
501
|
+
class InvalidDefBlockMismatchingArgCount(PypageSyntaxError):
|
502
|
+
def __init__(self, argnames, args):
|
503
|
+
self.description = "Incorrect DefBlock function call: expected %d arguments (%s) but received %d arguments (%s) instead." % (
|
504
|
+
len(argnames), ', '.join(argnames), len(args), ', '.join(map(repr, args)))
|
505
|
+
|
452
506
|
class UnknownTag(PypageSyntaxError):
|
453
507
|
def __init__(self, node):
|
454
508
|
self.description = "Unknown tag '%s%s%s' at line %d, column %d." % (
|
pypage-2.1.0.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
pypage.py,sha256=oEEr3pCIbKbDoAIYL8vANUtRb4Wbll9IvYMWID0xEng,29037
|
2
|
-
pypage-2.1.0.dist-info/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
3
|
-
pypage-2.1.0.dist-info/METADATA,sha256=TvOBibltTKqFxxy_4-sZ0Y8lHIrZVPo2wX0do03nVF4,18152
|
4
|
-
pypage-2.1.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
5
|
-
pypage-2.1.0.dist-info/entry_points.txt,sha256=iHPN6EfIUdv-njh8GV04yDTzkcCLGNcXvdbA43s_8mo,39
|
6
|
-
pypage-2.1.0.dist-info/top_level.txt,sha256=8AAB15dVQEt9xcwH_eLcVUZEbFlc__81RA5mOrYtJiQ,7
|
7
|
-
pypage-2.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|