aridity 64__tar.gz → 66__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aridity
3
- Version: 64
3
+ Version: 66
4
4
  Summary: DRY config and template system, easily extensible with Python
5
5
  Home-page: https://github.com/combatopera/aridity
6
6
  Author: Andrzej Cichocki
@@ -148,10 +148,14 @@ home directory = $(~)
148
148
 
149
149
  : To get a literal dollar there is a special form for quoting:
150
150
  financial report = $'(We lost $100 on Friday.)
151
- : Be careful with nested brackets, the first matching bracket ends the special form:
151
+ : Unlike in older versions, nested brackets (if any) do not end the special form early:
152
152
  behaviour
153
- expected = $'[Lunch cost $20 (worth it though).]
154
- unexpected = $'(Lunch cost $20 (worth it though).)
153
+ expected = $'[Lunch cost $20 (worth it though).]
154
+ same = $'(Lunch cost $20 (worth it though).)
155
+ : Consequently, unbalanced brackets of the same kind as used by the special form must be avoided:
156
+ interval
157
+ lower = $'[The interval ][$'[0, 1) includes 0 but not 1.]
158
+ upper = $'(The interval )($'(0, 1] includes 1 but not 0.)
155
159
 
156
160
  : Another special form can be used to preserve leading/trailing whitespace:
157
161
  padded bars = $.( $(foo) $(foo) )
@@ -137,10 +137,14 @@ home directory = $(~)
137
137
 
138
138
  : To get a literal dollar there is a special form for quoting:
139
139
  financial report = $'(We lost $100 on Friday.)
140
- : Be careful with nested brackets, the first matching bracket ends the special form:
140
+ : Unlike in older versions, nested brackets (if any) do not end the special form early:
141
141
  behaviour
142
- expected = $'[Lunch cost $20 (worth it though).]
143
- unexpected = $'(Lunch cost $20 (worth it though).)
142
+ expected = $'[Lunch cost $20 (worth it though).]
143
+ same = $'(Lunch cost $20 (worth it though).)
144
+ : Consequently, unbalanced brackets of the same kind as used by the special form must be avoided:
145
+ interval
146
+ lower = $'[The interval ][$'[0, 1) includes 0 but not 1.]
147
+ upper = $'(The interval )($'(0, 1] includes 1 but not 0.)
144
148
 
145
149
  : Another special form can be used to preserve leading/trailing whitespace:
146
150
  padded bars = $.( $(foo) $(foo) )
@@ -17,13 +17,13 @@
17
17
 
18
18
  from .model import Blank, Boolean, Boundary, Call, Concat, Entry, nullmonitor, Number, Text
19
19
  from decimal import Decimal
20
- from functools import reduce
20
+ from functools import partial, reduce
21
21
  from pyparsing import Forward, Literal, MatchFirst, NoMatch, OneOrMore, Optional, Regex, Suppress, ZeroOrMore
22
22
  import operator, re
23
23
 
24
24
  class AnyScalar:
25
25
 
26
- numberpattern = re.compile('^-?(?:[0-9]+|[0-9]*[.][0-9]+)$')
26
+ numberpattern = re.compile('^-?(?:0|[1-9][0-9]*)([.][0-9]+)?$')
27
27
  booleans = {str(b).lower(): Boolean(b) for b in map(bool, range(2))}
28
28
 
29
29
  @classmethod
@@ -33,14 +33,33 @@ class AnyScalar:
33
33
  return cls.booleans[text]
34
34
  except KeyError:
35
35
  m = cls.numberpattern.search(text)
36
- return Text(text) if m is None else Number((Decimal if '.' in text else int)(text))
36
+ return Text(text) if m is None or '-0' == text else Number((int if m.group(1) is None else Decimal)(text))
37
+
38
+ def _gettext(notchars, pa):
39
+ return Regex(r"[^$\s%s]+" % re.escape(notchars)).leaveWhitespace().setParseAction(pa)
37
40
 
38
41
  def _getarg(callchain, scalarpa, boundarychars):
39
- def gettext(pa):
40
- return Regex(r"[^$\s%s]+" % re.escape(boundarychars)).leaveWhitespace().setParseAction(pa)
42
+ gettext = partial(_gettext, boundarychars)
41
43
  opttext = Optional(gettext(Text.pa))
42
44
  return (OneOrMore(opttext + callchain) + opttext | gettext(scalarpa)).setParseAction(Concat.smartpa)
43
45
 
46
+ def _bracketed(callchain, blankpa, scalarpa, o, c):
47
+ gettext = partial(_gettext, o + c)
48
+ bracketed = Forward()
49
+ chainorbrackets = callchain | (Literal(o).setParseAction(Text.pa) + bracketed + Literal(c).setParseAction(Text.pa)).leaveWhitespace()
50
+ opttext = Optional(gettext(Text.pa))
51
+ concat = OneOrMore(opttext + chainorbrackets) + opttext
52
+ optblank = _getoptblank(blankpa, '')
53
+ bracketed << ZeroOrMore(optblank + (concat | gettext(scalarpa)).setParseAction(Concat.smartpa)) + optblank
54
+ return bracketed
55
+
56
+ def _literalbracketed(o, c):
57
+ bracketed = Forward()
58
+ brackets = (Literal(o) + bracketed + Literal(c)).leaveWhitespace()
59
+ opttext = Regex("[^%s]*" % re.escape(o + c)).leaveWhitespace()
60
+ bracketed << ZeroOrMore(opttext + brackets) + opttext
61
+ return bracketed
62
+
44
63
  def _getoptblank(pa, boundarychars):
45
64
  return Optional(Regex(r"[^\S%s]+" % re.escape(boundarychars)).leaveWhitespace().setParseAction(pa))
46
65
 
@@ -82,10 +101,9 @@ class GFactory:
82
101
  def create(self, pa):
83
102
  def itercalls():
84
103
  def getbrackets(blankpa, scalarpa):
85
- optblank = _getoptblank(blankpa, '')
86
- return Literal(o) + ZeroOrMore(optblank + _getarg(callchain, scalarpa, c)) + optblank + Literal(c)
104
+ return Literal(o) + _bracketed(callchain, blankpa, scalarpa, o, c) + Literal(c)
87
105
  for o, c in self.bracketpairs:
88
- yield (Suppress(Regex("[$](?:lit|')")) + Suppress(o) + Regex("[^%s]*" % re.escape(c)) + Suppress(c)).setParseAction(Text.pa)
106
+ yield (Suppress(Regex("[$](?:lit|')")) + Suppress(o) + _literalbracketed(o, c) + Suppress(c)).setParseAction(Text.joinpa)
89
107
  yield (Suppress(Regex('[$](?:pass|[.])')) + getbrackets(Text.pa, Text.pa)).setParseAction(self._bracketspa)
90
108
  yield (Suppress('$') + self.identifier + getbrackets(Blank.pa, AnyScalar.pa)).setParseAction(_principalcallpa)
91
109
  yield (Suppress('$') + self.identifier + callchain).setParseAction(_additionalcallpa)
@@ -132,6 +132,10 @@ class Scalar(BaseScalar):
132
132
 
133
133
  class Text(Cat, BaseScalar):
134
134
 
135
+ @classmethod
136
+ def joinpa(cls, s, l, t):
137
+ return cls(''.join(t))
138
+
135
139
  @classmethod
136
140
  def _of(cls, textvalue):
137
141
  return cls(textvalue)
@@ -28,7 +28,7 @@ class MalformedEntryException(Exception): pass
28
28
 
29
29
  class Repl:
30
30
 
31
- quotablebysquare = re.compile('[$)]+')
31
+ quotablebysquare = re.compile('[$()]+')
32
32
 
33
33
  @classmethod
34
34
  def _quote(cls, obj): # TODO: Duplicates some wrap logic.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aridity
3
- Version: 64
3
+ Version: 66
4
4
  Summary: DRY config and template system, easily extensible with Python
5
5
  Home-page: https://github.com/combatopera/aridity
6
6
  Author: Andrzej Cichocki
@@ -148,10 +148,14 @@ home directory = $(~)
148
148
 
149
149
  : To get a literal dollar there is a special form for quoting:
150
150
  financial report = $'(We lost $100 on Friday.)
151
- : Be careful with nested brackets, the first matching bracket ends the special form:
151
+ : Unlike in older versions, nested brackets (if any) do not end the special form early:
152
152
  behaviour
153
- expected = $'[Lunch cost $20 (worth it though).]
154
- unexpected = $'(Lunch cost $20 (worth it though).)
153
+ expected = $'[Lunch cost $20 (worth it though).]
154
+ same = $'(Lunch cost $20 (worth it though).)
155
+ : Consequently, unbalanced brackets of the same kind as used by the special form must be avoided:
156
+ interval
157
+ lower = $'[The interval ][$'[0, 1) includes 0 but not 1.]
158
+ upper = $'(The interval )($'(0, 1] includes 1 but not 0.)
155
159
 
156
160
  : Another special form can be used to preserve leading/trailing whitespace:
157
161
  padded bars = $.( $(foo) $(foo) )
@@ -50,7 +50,7 @@ class SourceInfo:
50
50
 
51
51
  def buildrequires(self):
52
52
  if self.path.endswith('.pyx'):
53
- yield 'Cython'
53
+ yield 'Cython<3'
54
54
 
55
55
  def make_ext(self):
56
56
  g = {}
@@ -136,7 +136,7 @@ def ext_modules():
136
136
  sourceinfo = SourceInfo('.')
137
137
  setuptools.setup(
138
138
  name = 'aridity',
139
- version = '64',
139
+ version = '66',
140
140
  description = 'DRY config and template system, easily extensible with Python',
141
141
  long_description = long_description(),
142
142
  long_description_content_type = 'text/markdown',
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