aridity 95__tar.gz → 97__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,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aridity
3
- Version: 95
3
+ Version: 97
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
7
7
  Author-email: shrovis@foyono.com
8
8
  Description-Content-Type: text/markdown
9
+ Requires-Dist: foyndation>=14
9
10
  Requires-Dist: pyparsing>=3.0.2
10
11
 
11
12
  # aridity
@@ -515,67 +516,3 @@ As text, the platform slash. As function, join args using that slash, starting w
515
516
 
516
517
  ### aridity.util
517
518
 
518
- <a id="aridity.util.openresource"></a>
519
-
520
- ###### openresource
521
-
522
- ```python
523
- def openresource(package_or_name, resource_name, encoding='ascii')
524
- ```
525
-
526
- Like `pkg_resources.resource_stream` but text mode.
527
-
528
- <a id="aridity.util.solo"></a>
529
-
530
- ###### solo
531
-
532
- ```python
533
- def solo(v)
534
- ```
535
-
536
- Assert exactly one object in the given sequence and return it.
537
-
538
- <a id="parabject"></a>
539
-
540
- ### parabject
541
-
542
- <a id="parabject.register"></a>
543
-
544
- ###### register
545
-
546
- ```python
547
- def register(obj, paracls)
548
- ```
549
-
550
- Instantiate paracls, set `obj` to be the regular object associated with the new parabject, and return the parabject.
551
-
552
- <a id="parabject.dereference"></a>
553
-
554
- ###### dereference
555
-
556
- ```python
557
- def dereference(parabject)
558
- ```
559
-
560
- Get the regular object associated with `parabject` or raise UnknownParabjectException.
561
-
562
- <a id="parabject.Parabject"></a>
563
-
564
- #### Parabject Objects
565
-
566
- ```python
567
- class Parabject()
568
- ```
569
-
570
- Subclasses typically implement `__getattr__` for dynamic behaviour on attribute access.
571
-
572
- <a id="parabject.Parabject.__neg__"></a>
573
-
574
- ###### \_\_neg\_\_
575
-
576
- ```python
577
- def __neg__()
578
- ```
579
-
580
- Dereference this parabject.
581
-
@@ -505,67 +505,3 @@ As text, the platform slash. As function, join args using that slash, starting w
505
505
 
506
506
  ### aridity.util
507
507
 
508
- <a id="aridity.util.openresource"></a>
509
-
510
- ###### openresource
511
-
512
- ```python
513
- def openresource(package_or_name, resource_name, encoding='ascii')
514
- ```
515
-
516
- Like `pkg_resources.resource_stream` but text mode.
517
-
518
- <a id="aridity.util.solo"></a>
519
-
520
- ###### solo
521
-
522
- ```python
523
- def solo(v)
524
- ```
525
-
526
- Assert exactly one object in the given sequence and return it.
527
-
528
- <a id="parabject"></a>
529
-
530
- ### parabject
531
-
532
- <a id="parabject.register"></a>
533
-
534
- ###### register
535
-
536
- ```python
537
- def register(obj, paracls)
538
- ```
539
-
540
- Instantiate paracls, set `obj` to be the regular object associated with the new parabject, and return the parabject.
541
-
542
- <a id="parabject.dereference"></a>
543
-
544
- ###### dereference
545
-
546
- ```python
547
- def dereference(parabject)
548
- ```
549
-
550
- Get the regular object associated with `parabject` or raise UnknownParabjectException.
551
-
552
- <a id="parabject.Parabject"></a>
553
-
554
- #### Parabject Objects
555
-
556
- ```python
557
- class Parabject()
558
- ```
559
-
560
- Subclasses typically implement `__getattr__` for dynamic behaviour on attribute access.
561
-
562
- <a id="parabject.Parabject.__neg__"></a>
563
-
564
- ###### \_\_neg\_\_
565
-
566
- ```python
567
- def __neg__()
568
- ```
569
-
570
- Dereference this parabject.
571
-
@@ -2,7 +2,8 @@ from .functions import OpaqueKey
2
2
  from .model import Entry, Locator, Resource, Stream, Text, wrap
3
3
  from .scope import StaticScope
4
4
  from .search import resolvedscopeornone
5
- from .util import dotpy, Forkable, NoSuchPathException, qualname, selectentrypoints, solo
5
+ from .util import NoSuchPathException, selectentrypoints
6
+ from foyndation import dotpy, Forkable, rmsuffix, solo
6
7
  from io import StringIO
7
8
  from parabject import Parabject, register
8
9
  from pathlib import Path
@@ -13,17 +14,16 @@ log = logging.getLogger(__name__)
13
14
  def _processmainfunction(mainfunction):
14
15
  module = mainfunction.__module__
15
16
  if '__main__' == module:
16
- p = sys.argv[0]
17
- name = os.path.basename(p)
18
- if '__main__.py' == name:
19
- stem = os.path.basename(os.path.dirname(p))
17
+ p = Path(sys.argv[0])
18
+ name = p.name
19
+ if name in {'__init__.py', '__main__.py'}:
20
+ stem = p.parent.name
20
21
  else:
21
- assert name.endswith(dotpy)
22
- stem = name[:-len(dotpy)]
22
+ assert (stem := rmsuffix(name, dotpy)) is not None
23
23
  assert '-' not in stem
24
24
  appname = stem.replace('_', '-')
25
25
  else:
26
- attr = qualname(mainfunction)
26
+ attr = mainfunction.__qualname__
27
27
  # FIXME: Requires metadata e.g. egg-info in projects that have not been installed:
28
28
  appname, = (ep.name for ep in selectentrypoints('console_scripts') if ep.module == module and ep.attr == attr)
29
29
  return module, appname
@@ -183,3 +183,8 @@ class WConfig(Parabject):
183
183
  query = (-self).addname(OpaqueKey())
184
184
  query.basescope[tuple(query.prefix)] = wrap(value)
185
185
  return self
186
+
187
+ def __neg__(self):
188
+ query = super().__neg__()
189
+ query.basescope.getorcreatesubscope(query.prefix) # TODO: Too eager.
190
+ return query
@@ -1,6 +1,7 @@
1
1
  from .keyring import gpg, keyring
2
2
  from .model import Boolean, Hole, Indeterminate, Number, Resource, Text, wrap
3
- from .util import dotpy, NoSuchPathException
3
+ from .util import NoSuchPathException
4
+ from foyndation import dotpy
4
5
  from importlib import import_module
5
6
  from itertools import chain
6
7
  import json, re, shlex
@@ -1,5 +1,6 @@
1
- from .util import Burial, dotpy, Forkable
1
+ from .util import Burial
2
2
  from contextlib import contextmanager
3
+ from foyndation import dotpy, Forkable, rmsuffix
3
4
  from importlib import import_module
4
5
  from importlib.resources import files
5
6
  from io import TextIOWrapper
@@ -266,7 +267,7 @@ class Resource(Resolved, Openable, Forkable):
266
267
 
267
268
  def _packagename(self):
268
269
  m = import_module(self.package_or_requirement)
269
- package = m.__package__
270
+ package = m.__spec__.parent
270
271
  return (self.package_or_requirement if hasattr(m, '__path__') else self.package_or_requirement[:self.package_or_requirement.rindex('.')]) if package is None else package
271
272
 
272
273
  def _resource_words(self):
@@ -287,8 +288,8 @@ class Resource(Resolved, Openable, Forkable):
287
288
  return self._of(self.package_or_requirement, '/'.join(v) if v else None, self.encoding)
288
289
 
289
290
  def modulenameornone(self):
290
- if self.resource_name.endswith(dotpy):
291
- return f"{self._packagename()}.{self.resource_name[:-len(dotpy)].replace('/', '.')}"
291
+ if (stem := rmsuffix(self.resource_name, dotpy)) is not None:
292
+ return f"{self._packagename()}.{stem.replace('/', '.')}"
292
293
 
293
294
  class Binary(BaseScalar, Forkable):
294
295
 
@@ -1,44 +1,39 @@
1
1
  from .search import Query
2
- from .util import CycleException, Forkable, NoSuchPathException, TreeNoSuchPathException
2
+ from .util import CycleException, NoSuchPathException, TreeNoSuchPathException
3
+ from foyndation import Forkable
3
4
 
4
5
  class BaseResolveContext:
5
6
 
6
7
  @property
7
8
  def label(self):
8
- return self.leafscope().label
9
+ return self.resolved().label
9
10
 
10
11
  @property
11
12
  def parents(self):
12
- return self.leafscope().parents
13
+ return self.resolved().parents
13
14
 
14
15
  @property
15
16
  def resolvables(self):
16
- return self.leafscope().resolvables
17
+ return self.resolved().resolvables
17
18
 
18
19
  def createchild(self):
19
- return self.leafscope().createchild()
20
+ return self.resolved().createchild()
20
21
 
21
22
  def getresolvecontext(self):
22
23
  return self
23
24
 
24
25
  def resolvableornone(self, key):
25
- return self.leafscope().resolvableornone(key)
26
-
27
- def resolved(self, *path):
28
- return self.resolvedimpl(path) if path else self.leafscope()
26
+ return self.resolved().resolvableornone(key)
29
27
 
30
28
  def staticscope(self):
31
- return self.leafscope().staticscope()
29
+ return self.resolved().staticscope()
32
30
 
33
31
  class AnchorResolveContext(BaseResolveContext):
34
32
 
35
33
  def __init__(self, anchorscope):
36
34
  self.anchorscope = anchorscope
37
35
 
38
- def leafscope(self):
39
- return self.anchorscope
40
-
41
- def resolvedimpl(self, path):
36
+ def resolved(self, *path):
42
37
  hit = Query([], path).search(self.anchorscope)
43
38
  return hit.resolvable.resolve(ResolveContext(self.anchorscope, path, [hit.address]))
44
39
 
@@ -50,10 +45,7 @@ class ResolveContext(BaseResolveContext, Forkable):
50
45
  self.exprpath = exprpath
51
46
  self.addresses = addresses
52
47
 
53
- def leafscope(self):
54
- return Query([], self.scopepath).search(self.anchorscope).naiveresolve() if self.scopepath else self.anchorscope # XXX: Is naiveresolve correct here?
55
-
56
- def resolvedimpl(self, path):
48
+ def resolved(self, *path):
57
49
  try:
58
50
  hit = Query(self.scopepath, path).search(self.anchorscope)
59
51
  if hit.address in self.addresses: # XXX: Could it be valid to resolve the same address recursively with 2 different contexts?
@@ -4,7 +4,8 @@ from .model import Directive, Function, Hole, Resolvable, Scalar, star, Stream,
4
4
  from .resolve import AnchorResolveContext
5
5
  from .search import Query
6
6
  from .stacks import IndentStack, SimpleStack, ThreadLocalResolvable
7
- from .util import NoSuchPathException, solo, UnsupportedEntryException
7
+ from .util import NoSuchPathException, UnsupportedEntryException
8
+ from foyndation import solo
8
9
  from itertools import chain
9
10
  import os, sys, threading
10
11
 
@@ -111,4 +111,4 @@ class Query:
111
111
  return hit
112
112
  if besthit is None or _lt(hit.depths, besthit.depths):
113
113
  besthit = hit
114
- raise UnparseNoSuchPathException(self.path)
114
+ raise UnparseNoSuchPathException(scope, self.path[:self.prefixlen], self.path[self.prefixlen:])
@@ -1,8 +1,6 @@
1
1
  from contextlib import contextmanager
2
2
  from importlib.metadata import entry_points
3
- import sys
4
3
 
5
- dotpy = '.py'
6
4
  inf = float('inf')
7
5
  null_exc_info = None, None, None
8
6
 
@@ -10,9 +8,12 @@ class NoSuchPathException(Exception): pass
10
8
 
11
9
  class UnparseNoSuchPathException(NoSuchPathException):
12
10
 
11
+ @property
12
+ def path(self):
13
+ return self.args[-1]
14
+
13
15
  def __str__(self):
14
- path, = self.args
15
- return ' '.join(path)
16
+ return ' '.join(self.path)
16
17
 
17
18
  class TreeNoSuchPathException(NoSuchPathException):
18
19
 
@@ -36,25 +37,6 @@ class CycleException(UnparseNoSuchPathException): pass
36
37
 
37
38
  class UnsupportedEntryException(Exception): pass
38
39
 
39
- def openresource(package_or_name, resource_name, encoding = 'ascii'):
40
- 'Like `pkg_resources.resource_stream` but text mode.'
41
- from .model import Resource
42
- return Resource(package_or_name, resource_name, encoding).open(False)
43
-
44
- def solo(v):
45
- 'Assert exactly one object in the given sequence and return it.'
46
- x, = v
47
- return x
48
-
49
- def qualname(obj):
50
- try:
51
- return obj.__qualname__
52
- except AttributeError:
53
- name = obj.__name__
54
- if getattr(sys.modules[obj.__module__], name) is not obj:
55
- raise
56
- return name
57
-
58
40
  def selectentrypoints(group):
59
41
  obj = entry_points()
60
42
  try:
@@ -68,12 +50,6 @@ def popattr(obj, name):
68
50
  delattr(obj, name)
69
51
  return val
70
52
 
71
- class Forkable:
72
-
73
- @classmethod
74
- def _of(cls, *args, **kwargs):
75
- return cls(*args, **kwargs)
76
-
77
53
  class Burial:
78
54
 
79
55
  name = 'burial'
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aridity
3
- Version: 95
3
+ Version: 97
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
7
7
  Author-email: shrovis@foyono.com
8
8
  Description-Content-Type: text/markdown
9
+ Requires-Dist: foyndation>=14
9
10
  Requires-Dist: pyparsing>=3.0.2
10
11
 
11
12
  # aridity
@@ -515,67 +516,3 @@ As text, the platform slash. As function, join args using that slash, starting w
515
516
 
516
517
  ### aridity.util
517
518
 
518
- <a id="aridity.util.openresource"></a>
519
-
520
- ###### openresource
521
-
522
- ```python
523
- def openresource(package_or_name, resource_name, encoding='ascii')
524
- ```
525
-
526
- Like `pkg_resources.resource_stream` but text mode.
527
-
528
- <a id="aridity.util.solo"></a>
529
-
530
- ###### solo
531
-
532
- ```python
533
- def solo(v)
534
- ```
535
-
536
- Assert exactly one object in the given sequence and return it.
537
-
538
- <a id="parabject"></a>
539
-
540
- ### parabject
541
-
542
- <a id="parabject.register"></a>
543
-
544
- ###### register
545
-
546
- ```python
547
- def register(obj, paracls)
548
- ```
549
-
550
- Instantiate paracls, set `obj` to be the regular object associated with the new parabject, and return the parabject.
551
-
552
- <a id="parabject.dereference"></a>
553
-
554
- ###### dereference
555
-
556
- ```python
557
- def dereference(parabject)
558
- ```
559
-
560
- Get the regular object associated with `parabject` or raise UnknownParabjectException.
561
-
562
- <a id="parabject.Parabject"></a>
563
-
564
- #### Parabject Objects
565
-
566
- ```python
567
- class Parabject()
568
- ```
569
-
570
- Subclasses typically implement `__getattr__` for dynamic behaviour on attribute access.
571
-
572
- <a id="parabject.Parabject.__neg__"></a>
573
-
574
- ###### \_\_neg\_\_
575
-
576
- ```python
577
- def __neg__()
578
- ```
579
-
580
- Dereference this parabject.
581
-
@@ -1,5 +1,4 @@
1
1
  README.md
2
- parabject.py
3
2
  setup.py
4
3
  aridity/__init__.py
5
4
  aridity/arid_config.py
@@ -1 +1,2 @@
1
+ foyndation>=14
1
2
  pyparsing>=3.0.2
@@ -0,0 +1 @@
1
+ aridity
@@ -49,13 +49,13 @@ class SourceInfo:
49
49
  sourceinfo = SourceInfo('.')
50
50
  setup(
51
51
  name = 'aridity',
52
- version = '95',
52
+ version = '97',
53
53
  description = 'DRY config and template system, easily extensible with Python',
54
54
  url = 'https://pypi.org/project/aridity/',
55
55
  author = 'foyono',
56
56
  author_email = 'shrovis@foyono.com',
57
- py_modules = ['parabject'],
58
- install_requires = ['pyparsing>=3.0.2'],
57
+ py_modules = [],
58
+ install_requires = ['foyndation>=14', 'pyparsing>=3.0.2'],
59
59
  package_data = {'': ['*.pxd', '*.pyx', '*.pyxbld', '*.arid', '*.aridt']},
60
60
  entry_points = {'console_scripts': ['aridity=aridity.__init__:main', 'arid-config=aridity.arid_config:main', 'processtemplate=aridity.processtemplate:main']},
61
61
  **sourceinfo.setup_kwargs(),
@@ -1,2 +0,0 @@
1
- aridity
2
- parabject
aridity-95/parabject.py DELETED
@@ -1,25 +0,0 @@
1
- from weakref import WeakKeyDictionary
2
-
3
- lookup = WeakKeyDictionary()
4
-
5
- def register(obj, paracls):
6
- 'Instantiate paracls, set `obj` to be the regular object associated with the new parabject, and return the parabject.'
7
- parabject = paracls()
8
- lookup[parabject] = obj
9
- return parabject
10
-
11
- class UnknownParabjectException(Exception): pass
12
-
13
- def dereference(parabject):
14
- 'Get the regular object associated with `parabject` or raise UnknownParabjectException.'
15
- try:
16
- return lookup[parabject]
17
- except (KeyError, TypeError):
18
- raise UnknownParabjectException
19
-
20
- class Parabject:
21
- 'Subclasses typically implement `__getattr__` for dynamic behaviour on attribute access.'
22
-
23
- def __neg__(self):
24
- 'Dereference this parabject.'
25
- return dereference(self)
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