aridity 97__tar.gz → 98__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: 97
3
+ Version: 98
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,9 +1,9 @@
1
1
  from .functions import OpaqueKey
2
- from .model import Entry, Locator, Resource, Stream, Text, wrap
2
+ from .model import Entry, Locator, Resource, Stream, wrap
3
3
  from .scope import StaticScope
4
4
  from .search import resolvedscopeornone
5
5
  from .util import NoSuchPathException, selectentrypoints
6
- from foyndation import dotpy, Forkable, rmsuffix, solo
6
+ from foyndation import dotpy, Forkable, rmsuffix
7
7
  from io import StringIO
8
8
  from parabject import Parabject, register
9
9
  from pathlib import Path
@@ -74,19 +74,6 @@ class ConfigCtrl(Forkable):
74
74
  resource.source(self.basescope.getorcreatesubscope([*self.prefix, appname]), Entry([]))
75
75
  return getattr(self.node, appname)
76
76
 
77
- def reapplysettings(self, mainfunction):
78
- if hasattr(mainfunction, 'encode'):
79
- appname = mainfunction
80
- else:
81
- _, appname = _processmainfunction(mainfunction)
82
- s = self.scope.duplicate()
83
- s.label = Text(appname)
84
- p = solo(s.parents)
85
- p[appname,] = s
86
- parent = self._of(p)
87
- parent.loadsettings()
88
- return getattr(parent.node, appname)
89
-
90
77
  def load(self, pathorstream):
91
78
  'Execute config from the given path or stream.'
92
79
  _wrappathorstream(pathorstream).source(self.scope, Entry([]))
@@ -1,4 +1,4 @@
1
- from .keyring import gpg, keyring
1
+ from .keyring import gpg
2
2
  from .model import Boolean, Hole, Indeterminate, Number, Resource, Text, wrap
3
3
  from .util import NoSuchPathException
4
4
  from foyndation import dotpy
@@ -184,7 +184,7 @@ def processtemplate(scope, resolvable):
184
184
  def _lower(scope, resolvable):
185
185
  return Text(resolvable.resolve(scope).textvalue.lower())
186
186
 
187
- def pyref(scope, moduleresolvable, qualnameresolvable):
187
+ def pyref(scope, moduleresolvable, qualnameresolvable): # FIXME: Allow load from __init__.py in current dir.
188
188
  'Python object in given module with given qualified name. Module may be relative to current resource, in which case assignment with `:=` is normally necessary. Typically used to import functions.'
189
189
  def moduleobj():
190
190
  moduleref = moduleresolvable.resolve(scope).textvalue
@@ -253,7 +253,6 @@ def getimpl(scope, *resolvables):
253
253
 
254
254
  def corefunctions():
255
255
  yield 'gpg', gpg
256
- yield 'keyring', keyring
257
256
  yield 'screenstr', screenstr
258
257
  yield 'scstr', scstr
259
258
  yield 'hclstr', hclstr
@@ -0,0 +1,24 @@
1
+ from .model import Scalar
2
+ from base64 import b64decode
3
+ from subprocess import CalledProcessError, check_output
4
+ from tempfile import NamedTemporaryFile
5
+
6
+ class Password(str):
7
+
8
+ def __enter__(self):
9
+ return self
10
+
11
+ def __exit__(self, *exc_info):
12
+ pass
13
+
14
+ class DecryptionFailedException(Exception): pass
15
+
16
+ def gpg(scope, resolvable):
17
+ 'Use gpg to decrypt the given base64-encoded blob.'
18
+ with NamedTemporaryFile() as f:
19
+ f.write(b64decode(resolvable.resolve(scope).textvalue))
20
+ f.flush()
21
+ try:
22
+ return Scalar(Password(check_output(['gpg', '-d', f.name]).decode('ascii')))
23
+ except CalledProcessError:
24
+ raise DecryptionFailedException
@@ -245,8 +245,6 @@ class StaticScope(Scope):
245
245
  self[word,] = Directive(d)
246
246
  for name, f in corefunctions():
247
247
  self[name,] = Function(f)
248
- self['keyring_cron',] = Scalar(False)
249
- self['keyring_force',] = Scalar(False)
250
248
  self['~',] = Text(os.path.expanduser('~'))
251
249
  self['LF',] = Text('\n')
252
250
  self['EOL',] = Text(os.linesep)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aridity
3
- Version: 97
3
+ Version: 98
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 = '97',
52
+ version = '98',
53
53
  description = 'DRY config and template system, easily extensible with Python',
54
54
  url = 'https://pypi.org/project/aridity/',
55
55
  author = 'foyono',
@@ -1,51 +0,0 @@
1
- from .model import Scalar
2
- from .util import null_exc_info
3
- from base64 import b64decode
4
- from functools import partial
5
- from getpass import getpass
6
- from subprocess import CalledProcessError, check_output
7
- from tempfile import NamedTemporaryFile
8
- from threading import Semaphore
9
- import logging, os
10
-
11
- log = logging.getLogger(__name__)
12
- passwordbase = str
13
- setenvonce = Semaphore()
14
-
15
- class Password(passwordbase):
16
-
17
- def __new__(cls, password, setter):
18
- p = passwordbase.__new__(cls, password)
19
- p.setter = setter
20
- return p
21
-
22
- def __enter__(self):
23
- return self
24
-
25
- def __exit__(self, *exc_info):
26
- if self.setter is not None and null_exc_info == exc_info:
27
- self.setter(self)
28
-
29
- def keyring(scope, serviceres, usernameres):
30
- if scope.resolved('keyring_cron').scalar and setenvonce.acquire(False):
31
- key = 'DBUS_SESSION_BUS_ADDRESS'
32
- value = f"unix:path=/run/user/{os.geteuid()}/bus"
33
- log.debug("Set %s to: %s", key, value)
34
- os.environ[key] = value
35
- from keyring import get_password, set_password
36
- service = serviceres.resolve(scope).textvalue
37
- username = usernameres.resolve(scope).textvalue
38
- password = None if scope.resolved('keyring_force').scalar else get_password(service, username)
39
- return Scalar(Password(*[getpass(), partial(set_password, service, username)] if password is None else [password, None]))
40
-
41
- class DecryptionFailedException(Exception): pass
42
-
43
- def gpg(scope, resolvable):
44
- 'Use gpg to decrypt the given base64-encoded blob.'
45
- with NamedTemporaryFile() as f:
46
- f.write(b64decode(resolvable.resolve(scope).textvalue))
47
- f.flush()
48
- try:
49
- return Scalar(Password(check_output(['gpg', '-d', f.name]).decode('ascii'), None))
50
- except CalledProcessError:
51
- raise DecryptionFailedException
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