aridity 73__tar.gz → 74__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.
- {aridity-73 → aridity-74}/PKG-INFO +1 -1
- {aridity-73 → aridity-74}/aridity/functions.py +10 -0
- {aridity-73 → aridity-74}/aridity/scope.py +12 -3
- {aridity-73 → aridity-74}/aridity/search.py +14 -16
- {aridity-73 → aridity-74}/aridity.egg-info/PKG-INFO +1 -1
- {aridity-73 → aridity-74}/setup.py +1 -1
- {aridity-73 → aridity-74}/README.md +0 -0
- {aridity-73 → aridity-74}/aridity/__init__.py +0 -0
- {aridity-73 → aridity-74}/aridity/arid_config.py +0 -0
- {aridity-73 → aridity-74}/aridity/config.py +0 -0
- {aridity-73 → aridity-74}/aridity/directives.py +0 -0
- {aridity-73 → aridity-74}/aridity/grammar.py +0 -0
- {aridity-73 → aridity-74}/aridity/keyring.py +0 -0
- {aridity-73 → aridity-74}/aridity/model.py +0 -0
- {aridity-73 → aridity-74}/aridity/processtemplate.py +0 -0
- {aridity-73 → aridity-74}/aridity/repl.py +0 -0
- {aridity-73 → aridity-74}/aridity/stacks.py +0 -0
- {aridity-73 → aridity-74}/aridity/util.py +0 -0
- {aridity-73 → aridity-74}/aridity.egg-info/SOURCES.txt +0 -0
- {aridity-73 → aridity-74}/aridity.egg-info/dependency_links.txt +0 -0
- {aridity-73 → aridity-74}/aridity.egg-info/entry_points.txt +0 -0
- {aridity-73 → aridity-74}/aridity.egg-info/requires.txt +0 -0
- {aridity-73 → aridity-74}/aridity.egg-info/top_level.txt +0 -0
- {aridity-73 → aridity-74}/parabject.py +0 -0
- {aridity-73 → aridity-74}/setup.cfg +0 -0
|
@@ -236,6 +236,16 @@ class Functions:
|
|
|
236
236
|
def getfrom(scope, scoperesolvable, *resolvables):
|
|
237
237
|
return scoperesolvable.resolve(scope).resolved(*(r.resolve(scope).cat() for r in resolvables))
|
|
238
238
|
|
|
239
|
+
def rmeol(scope, resolvable):
|
|
240
|
+
text = resolvable.resolve(scope).cat()
|
|
241
|
+
if text.endswith('\r\n'):
|
|
242
|
+
n = 2
|
|
243
|
+
elif text.endswith(('\r', '\n')):
|
|
244
|
+
n = 1
|
|
245
|
+
else:
|
|
246
|
+
raise NoSuchPathException('No line terminator to remove.')
|
|
247
|
+
return Text(text[:-n])
|
|
248
|
+
|
|
239
249
|
def getimpl(scope, *resolvables):
|
|
240
250
|
return scope.resolved(*(r.resolve(scope).cat() for r in resolvables))
|
|
241
251
|
|
|
@@ -2,7 +2,7 @@ from . import directives
|
|
|
2
2
|
from .directives import Precedence
|
|
3
3
|
from .functions import getfunctions, OpaqueKey
|
|
4
4
|
from .model import CatNotSupportedException, Directive, Function, Resolvable, Scalar, star, Stream, Text
|
|
5
|
-
from .search import Query, resolvedscopeornone,
|
|
5
|
+
from .search import Query, resolvedscopeornone, slices
|
|
6
6
|
from .stacks import IndentStack, SimpleStack, ThreadLocalResolvable
|
|
7
7
|
from .util import CycleException, NoSuchPathException, OrderedDict, solo, TreeNoSuchPathException, UnsupportedEntryException
|
|
8
8
|
from itertools import chain
|
|
@@ -134,7 +134,7 @@ class AbstractScope(Resolvable): # TODO LATER: Some methods should probably be m
|
|
|
134
134
|
# TODO: Review this algo.
|
|
135
135
|
errors = []
|
|
136
136
|
for words in slices(path):
|
|
137
|
-
for s in (resolvedscopeornone(s, words) for s in chain.from_iterable(scopedepths(
|
|
137
|
+
for s in (resolvedscopeornone(s, words) for s in chain.from_iterable(self.scopedepths())):
|
|
138
138
|
if s is not None:
|
|
139
139
|
try:
|
|
140
140
|
return hit.resolvable.resolve(s, **kwargs)
|
|
@@ -147,12 +147,21 @@ class AbstractScope(Resolvable): # TODO LATER: Some methods should probably be m
|
|
|
147
147
|
def resolvableornone(self, key):
|
|
148
148
|
return self.resolvables.getornone(key)
|
|
149
149
|
|
|
150
|
+
def scopedepths(self):
|
|
151
|
+
scopes = [self]
|
|
152
|
+
while scopes:
|
|
153
|
+
nextscopes = []
|
|
154
|
+
for s in scopes:
|
|
155
|
+
nextscopes.extend(s.parents)
|
|
156
|
+
yield scopes
|
|
157
|
+
scopes = nextscopes
|
|
158
|
+
|
|
150
159
|
def unravel(self):
|
|
151
160
|
d = OrderedDict([k, o.unravel()] for k, o in self.resolveditems())
|
|
152
161
|
return list(d) if self.islist or (d and all(OpaqueKey.isopaque(k) for k in d.keys())) else d
|
|
153
162
|
|
|
154
163
|
def staticscope(self):
|
|
155
|
-
for s in chain.from_iterable(scopedepths(
|
|
164
|
+
for s in chain.from_iterable(self.scopedepths()):
|
|
156
165
|
pass
|
|
157
166
|
return s
|
|
158
167
|
|
|
@@ -3,15 +3,6 @@ from collections import namedtuple
|
|
|
3
3
|
from itertools import islice
|
|
4
4
|
import heapq
|
|
5
5
|
|
|
6
|
-
def scopedepths(scope):
|
|
7
|
-
scopes = [scope]
|
|
8
|
-
while scopes:
|
|
9
|
-
nextscopes = []
|
|
10
|
-
for s in scopes:
|
|
11
|
-
nextscopes.extend(s.parents)
|
|
12
|
-
yield scopes
|
|
13
|
-
scopes = nextscopes
|
|
14
|
-
|
|
15
6
|
def resolvedscopeornone(s, path):
|
|
16
7
|
for name in path:
|
|
17
8
|
r = s.resolvableornone(name)
|
|
@@ -22,15 +13,15 @@ def resolvedscopeornone(s, path):
|
|
|
22
13
|
return
|
|
23
14
|
return s
|
|
24
15
|
|
|
25
|
-
class Hit(namedtuple('BaseHit', '
|
|
16
|
+
class Hit(namedtuple('BaseHit', 'depths scope resolvable')):
|
|
26
17
|
|
|
27
18
|
def iterornone(self, word):
|
|
28
19
|
contextscope = self.resolvable.resolve(self.scope) # XXX: Wise?
|
|
29
20
|
if hasattr(contextscope, 'resolvableornone'):
|
|
30
|
-
return Iterator(self.
|
|
21
|
+
return Iterator(self.depths, contextscope, word)
|
|
31
22
|
|
|
32
23
|
def shortcut(self, zerocount):
|
|
33
|
-
return all(not d for d in islice(self.
|
|
24
|
+
return all(not d for d in islice(self.depths, len(self.depths) - zerocount, None))
|
|
34
25
|
|
|
35
26
|
class Iterable:
|
|
36
27
|
|
|
@@ -39,13 +30,13 @@ class Iterable:
|
|
|
39
30
|
|
|
40
31
|
class Iterator(Iterable):
|
|
41
32
|
|
|
42
|
-
def __init__(self,
|
|
33
|
+
def __init__(self, depths, contextscope, word):
|
|
43
34
|
def g():
|
|
44
|
-
for depth, scopes in enumerate(scopedepths(
|
|
35
|
+
for depth, scopes in enumerate(contextscope.scopedepths()):
|
|
45
36
|
for scope in scopes:
|
|
46
37
|
resolvable = scope.resolvableornone(word)
|
|
47
38
|
if resolvable is not None:
|
|
48
|
-
yield Hit([depth]
|
|
39
|
+
yield Hit(depths + [depth], scope, resolvable)
|
|
49
40
|
self.iterator = g()
|
|
50
41
|
|
|
51
42
|
def next(self):
|
|
@@ -65,6 +56,13 @@ class Merge(Iterable):
|
|
|
65
56
|
def popiterator(self):
|
|
66
57
|
return heapq.merge(*popattr(self, 'iterables'))
|
|
67
58
|
|
|
59
|
+
def _lt(*depthspair):
|
|
60
|
+
for d1, d2 in zip(*map(reversed, depthspair)):
|
|
61
|
+
if d1 < d2:
|
|
62
|
+
return True
|
|
63
|
+
if d1 > d2:
|
|
64
|
+
break
|
|
65
|
+
|
|
68
66
|
class Sump:
|
|
69
67
|
|
|
70
68
|
besthit = None
|
|
@@ -73,7 +71,7 @@ class Sump:
|
|
|
73
71
|
pass
|
|
74
72
|
|
|
75
73
|
def offer(self, hit):
|
|
76
|
-
if self.besthit is None or hit.
|
|
74
|
+
if self.besthit is None or _lt(hit.depths, self.besthit.depths):
|
|
77
75
|
self.besthit = hit
|
|
78
76
|
|
|
79
77
|
def __iter__(self):
|
|
@@ -6,7 +6,7 @@ def long_description():
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name = 'aridity',
|
|
9
|
-
version = '
|
|
9
|
+
version = '74',
|
|
10
10
|
description = 'DRY config and template system, easily extensible with Python',
|
|
11
11
|
long_description = long_description(),
|
|
12
12
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|