aridity 88__tar.gz → 90__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: 88
3
+ Version: 90
4
4
  Summary: DRY config and template system, easily extensible with Python
5
5
  Home-page: https://pypi.org/project/aridity/
6
6
  Author: foyono
@@ -1,5 +1,6 @@
1
1
  from .model import Stream
2
2
  from .search import resolvedscopeornone
3
+ from itertools import chain
3
4
  import os, sys, unicodedata
4
5
 
5
6
  def acceptdirectivename(word):
@@ -27,13 +28,27 @@ def _write(prefix, suffix, scope):
27
28
  def source(prefix, suffix, scope):
28
29
  'Include path or resource at prefix.'
29
30
  # XXX: Use full algo to get phrasescope?
31
+ def rootscopes():
32
+ for s in chain.from_iterable(phrasescope.scopedepths()):
33
+ if [staticscope] == s.parents:
34
+ yield s
35
+ staticscope = scope.staticscope()
30
36
  phrasescope = scope
31
- for word in prefix.topath(scope):
32
- s = resolvedscopeornone(phrasescope, [word])
37
+ wordresolvables = prefix.words()
38
+ k = 0
39
+ n = len(wordresolvables)
40
+ for i, r in enumerate(wordresolvables):
41
+ wordobj = r.resolve(scope)
42
+ if staticscope.rootscopekey is wordobj.scalar:
43
+ scope, = rootscopes()
44
+ phrasescope = scope
45
+ k = i + 1
46
+ continue
47
+ s = resolvedscopeornone(phrasescope, [wordobj.totext().textvalue])
33
48
  if s is None:
34
49
  break
35
50
  phrasescope = s
36
- suffix.tophrase().resolve(phrasescope).openable(phrasescope).source(scope, prefix)
51
+ suffix.tophrase().resolve(phrasescope).openable(phrasescope).source(scope, prefix.subentry(k, n))
37
52
 
38
53
  @prime
39
54
  def _cd(prefix, suffix, scope):
@@ -108,6 +108,12 @@ def map_(scope, objsresolvable, *args):
108
108
  result.resolvables.put(k, resolvable.resolve(context(k, v)))
109
109
  return result
110
110
 
111
+ def map1(scope, contextresolvable, resultresolvable):
112
+ from .scope import ScalarScope, Scope
113
+ context = contextresolvable.resolve(scope)
114
+ # FIXME: In scalar context case we need to propagate its resolve context.
115
+ return resultresolvable.resolve(Scope([context, scope]) if hasattr(context, 'resolvables') else ScalarScope([scope], context))
116
+
111
117
  def _flat(scope, listsresolvable):
112
118
  from .scope import Scope
113
119
  s = Scope(islist = True) # XXX: Really no parent?
@@ -211,9 +217,6 @@ def pyres(scope, packageresolvable, nameresolvable, encoding = Text('ascii')):
211
217
  def _not(scope, resolvable):
212
218
  return Boolean(not resolvable.resolve(scope).truth())
213
219
 
214
- def _getfrom(scope, scoperesolvable, *resolvables):
215
- return scoperesolvable.resolve(scope).resolved(*(r.resolve(scope).textvalue for r in resolvables))
216
-
217
220
  def _indentmorelines(scope, resolvable):
218
221
  indent = scope.resolved('indent').textvalue
219
222
  lines = resolvable.resolve(scope).textvalue.splitlines(True)
@@ -265,6 +268,7 @@ def corefunctions():
265
268
  yield 'tomlquote', tomlquote
266
269
  yield 'urlquote', urlquote
267
270
  yield 'map', map_
271
+ yield 'map1', map1
268
272
  yield 'flat', _flat
269
273
  yield 'label', _label
270
274
  yield 'join', join
@@ -283,7 +287,6 @@ def corefunctions():
283
287
  yield 'pyref', pyref
284
288
  yield 'pyres', pyres
285
289
  yield '\N{NOT SIGN}', _not
286
- yield 'getfrom', _getfrom
287
290
  yield 'indentmorelines', _indentmorelines
288
291
  yield 'hole', _hole
289
292
  yield '', getimpl # TODO: Refer to the other one.
@@ -206,6 +206,7 @@ class AbstractScope(Resolvable): # TODO LATER: Some methods should probably be m
206
206
 
207
207
  class StaticScope(AbstractScope):
208
208
 
209
+ rootscopekey = OpaqueKey()
209
210
  stacktypes = dict(here = SimpleStack, indent = IndentStack)
210
211
 
211
212
  def __init__(self):
@@ -224,6 +225,7 @@ class StaticScope(AbstractScope):
224
225
  self['*',] = Star()
225
226
  self['None',] = Scalar(None)
226
227
  self['eolhole',] = Hole(Text(''), '\n')
228
+ self['^',] = Scalar(self.rootscopekey)
227
229
  for name in self.stacktypes:
228
230
  self[name,] = ThreadLocalResolvable(self.threadlocals, name)
229
231
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aridity
3
- Version: 88
3
+ Version: 90
4
4
  Summary: DRY config and template system, easily extensible with Python
5
5
  Home-page: https://pypi.org/project/aridity/
6
6
  Author: foyono
@@ -49,7 +49,7 @@ class SourceInfo:
49
49
  sourceinfo = SourceInfo('.')
50
50
  setup(
51
51
  name = 'aridity',
52
- version = '88',
52
+ version = '90',
53
53
  description = 'DRY config and template system, easily extensible with Python',
54
54
  url = 'https://pypi.org/project/aridity/',
55
55
  author = 'foyono',
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