Skip to main content

DRY config and template system, easily extensible with Python

Project description

aridity

DRY config and template system, easily extensible with Python.

This README is auto-generated, see project wiki for details.

Commands

arid-config

Print given config (with optional path in config) as shell snippet.

aridity

Interactive REPL.

processtemplate

Process the given template to stdout using config from stdin.

API

aridity.config

ConfigCtrl Objects

class ConfigCtrl()

High level scope API.

r
@property
def r()

Get config object for reading, i.e. missing scopes will error.

w
@property
def w()

Get config object for writing, i.e. missing scopes will be created.

loadappconfig
def loadappconfig(mainfunction,
                  moduleresource,
                  encoding='ascii',
                  settingsoptional=False)

Using app name as prefix load config from the given resource, apply user settings, and return config object for app. Context module for loading resource and the app name are deduced from mainfunction, or these can be provided as a tuple. Set settingsoptional to suppress the usual error if ~/.settings.arid does not exist.

load
def load(pathorstream)

Execute config from the given path or stream.

execute
def execute(text)

Execute given config text.

__iter__
def __iter__()

Yield keys and values.

processtemplate
def processtemplate(frompathorstream, topathorstream)

Evaluate expression from path/stream and write result to path/stream.

RConfig Objects

class RConfig(Parabject)

__iter__
def __iter__()

Yield values only. Iterate over -self for keys and values.

aridity.directives

colon
def colon(prefix, suffix, scope)

Ignore rest of logical line.

source
@prime
def source(prefix, suffix, scope)

Include path or resource at prefix.

equals
@prime
def equals(prefix, suffix, scope)

Assign expression to path.

colonequals
@prime
def colonequals(prefix, suffix, scope)

Evaluate expression and assign result to path.

plusequals
@prime
def plusequals(prefix, suffix, scope)

Assign expression to prefix plus an opaque key, i.e. add to list.

aridity.functions

screenstr
def screenstr(scope, resolvable)

GNU Screen string literal.

scstr
def scstr(scope, resolvable)

SuperCollider string literal.

hclstr
def hclstr(scope, resolvable)

HashiCorp configuration language string literal.

groovystr
def groovystr(scope, resolvable)

Groovy string literal.

pystr
def pystr(scope, resolvable)

Python literal.

shstr
def shstr(scope, resolvable)

Shell string literal.

jsonquote
def jsonquote(scope, resolvable)

JSON literal, also suitable for YAML.

xmlattr
def xmlattr(scope, resolvable)

XML attribute literal (including quotes).

xmltext
def xmltext(scope, resolvable)

XML content, suggest assigning this to & with xmlattr assigned to " as is convention.

tomlquote
def tomlquote(scope, resolvable)

TOML string literal.

urlquote
def urlquote(scope, resolvable)

Percent-encode all reserved characters.

map_
def map_(scope, objsresolvable, *args)

If given 1 arg, evaluate it against every scope in objsresolvable and return that list. If given 2 args, the first is a variable name to which each scope is temporarily assigned. If given 3 args, the first two are variable names for scope key and scope respectively.

join
def join(scope, partsresolvable, sepresolvable=None)

Concatenate the given list, using optional separator. Frequently used with map.

str_
def str_(scope, resolvable)

Coerce to string.

list_
def list_(scope, *resolvables)

Create a list.

try_
def try_(scope, *resolvables)

Attempt to evaluate each resolvable, returning the first that succeeds.

hereslash
def hereslash(scope, *resolvables)

Join the given path components with the directory of the current resource.

readfile
def readfile(scope, resolvable)

Include the content of the given path.

processtemplate
def processtemplate(scope, resolvable)

Evaluate the content of the given path as an expression.

pyref
def pyref(scope, moduleresolvable, qualnameresolvable)

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.

pyres
def pyres(scope, packageresolvable, nameresolvable, encoding=Text('ascii'))

Python resource for inclusion with . directive.

aridity.grammar

aridity.keyring

gpg
def gpg(scope, resolvable)

Use gpg to decrypt the given base64-encoded blob.

aridity.model

Resolvable Objects

class Resolvable(Struct)

resolve
def resolve(scope)

Evaluate this expression against the given scope.

wrap
def wrap(value)

Attempt to wrap the given value in a model object of the most specific type.

aridity.scope

AbstractScope Objects

class AbstractScope(Resolvable)

resolved
def resolved(*path, **kwargs)

Follow the given path to get an expression, evaluate it (resolving any paths it requires, recursively), and return the resulting model object.

Slash Objects

class Slash(Text, Function)

As text, the platform slash. As function, join args using that slash, starting with the last absolute path (or using all args if all relative).

aridity.util

openresource
def openresource(package_or_name, resource_name, encoding='ascii')

Like pkg_resources.resource_stream but text mode.

solo
def solo(v)

Assert exactly one object in the given sequence and return it.

parabject

register
def register(obj, paracls)

Instantiate paracls, set obj to be the regular object associated with the new parabject, and return the parabject.

dereference
def dereference(parabject)

Get the regular object associated with parabject or raise UnknownParabjectException.

Parabject Objects

class Parabject()

Subclasses typically implement __getattr__ for dynamic behaviour on attribute access.

__neg__
def __neg__()

Dereference this parabject.

Project details


Release history Release notifications | RSS feed

This version

91

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aridity-91.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aridity-91-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file aridity-91.tar.gz.

File metadata

  • Download URL: aridity-91.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for aridity-91.tar.gz
Algorithm Hash digest
SHA256 cedd17370007126cfceaec9d05cd844f0bab79123526b352bdcf6128c908c3da
MD5 db2708c80f4bb84289cd09384d398dde
BLAKE2b-256 859691ca720c68dc6b2871f2669e77f04f798caaef8eb06c21d083e0a8a79c0e

See more details on using hashes here.

File details

Details for the file aridity-91-py3-none-any.whl.

File metadata

  • Download URL: aridity-91-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for aridity-91-py3-none-any.whl
Algorithm Hash digest
SHA256 c0f7a9a1f5a75bdc2d33460a68cc3e7ff0644ab209c06f07d358804b197d4d64
MD5 52cc82c3d2889136de4602c705125677
BLAKE2b-256 78e4e29c186abe3e8d4b4b749d7c3df45b648b18f2204a8931991ca8bdb056ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page