Package: pyloader
Load python attributes from stringsJSON Formatpyloader uses a JSON-serializable format for the canonical
(serializable) form of python objects:{'foo': # (arbitrary) object name,
 {'args': ['positional', 'arguments'],
  'kwargs': {'keyword': 'arguments},
  'path': 'dotted.or.file.path:ObjectName'},
 'bar': ... } # etcObjects are instantiated like:ObjectName(*args, **kwargs)In the case that the object is not to be instantiated (e.g. a
standalone function,argsandkwargswill either not be
present or will be None (nullin JSON).INI Formatpyloader also features an INI format which is translated to the JSON
Format but adds a few convenience features.  A simple object is
expressed as:[foo:dotted.or.file.path:ObjectName]
. = positional, arguments
keyword = arguments.expresses positional arguments which is a comma-separated
list. The remaining (key, value) pairs become keyword arguments. The
section name contains the object name (e.g.foo) followed by a:followed by a loading path.  Like JSON, a dotted path or a file
path may be used. In addition, other (pluggable) loading paths are
available:override loader: you can use a section name like[foo:bar]to
override variables from thebarobject with variables fromfoo:[foo:bar]
. = cats, dogs
type = count

[bar:%(here)s/some/path.py:MyObject]
. = elephants
type = concatenateThe above results in a JSON blob for foo like:{'foo': {'args': ['elephants', 'cats', 'dogs'],
         'kwargs': {'type': 'concatenate'},
         'path': '/location/of/ini/file/some/path.py:MyObject'}}argsis extended.kwargswill be overridden.wrappers: in addition to the override pattern, you can also wrap an
object:[foo:bar:baz]This will create an object,foowhich wraps the objectbazin
by the pattern given bybar.  In this case,baris provided
a special variable,%(app)s.You can also do:[foo:bar:hi,hello,x=1,y=2:%(here)/objects.py:MyClass]In addition, .ini files may include other .ini files.  This allows for
encapsulation of intent of specific .ini files:[include:%(here)s/some/file.ini]INI files have a few convenience variables:%(here)s : the location of the directory the .ini file lives in%(object)s : used for wrappersAdditional variables may be provided by the consumer.Summary of .ini decorator syntax[foo:%(here)s/objects.py:MyClass]: create objectfooof typeMyClassusing arguments given from the section[foo:bar]: create objectfoousing the pattern from sectionbarbut overriding any arguments in thebarsection with
those from this section[foo:bar:%(here)s/objects.py:MyClass]: create objectfoowhich is an instance ofMyClasswrapped in the object created by
thebarpattern.baris passed a special argument,%(object)swhich is the instance of the wrapped object (theMyClassinstance). Internally, the wrapped object is known by
the whole section name (foo:bar:%(here)s/objects.py:MyClass). The
arguments in this section apply toMyClass(...)[foo:bar:app=%(object)s,value=1:%(here)s/objects.py:MyClass]:
the same as 3. but override the values in thebarsection withapp=%(object)sandvalue=1Section Name Syntax[name:resource]: create an object namedname, where resource
is either a section name or apathas described inJSON Format.
In the case whereresouceis another section name, the options
will overide the options given in theresourcesection and a new
object namednamewill be created.  In the case wheresectionis
a path, an object will be created as given by thepathwith the
given options.[name:decorator:resource]: create an object namednamewhere
the object given byresourceis passed todecorator. Overrides
and loading is as described for[name:reource]. An anonymous
object is created of the whole section name for the wrapped
object. So this form results in two sections for theJSON Format.decoratoris a section in the same namespace asname.[name:decorator:overrides:resource]: similar to[name:decorator:resource], but applyoveridesto thedecoratorsection.overridesis a string of the formatfoo,bar,fleem=5.Jeff Hammelhttp://k0s.org/