The Firmant application.
Orchestrates the high process of parsing, transforming, and writing content.
Setup the test cases.
Actions taken:
- Create a temporary directory.
Cleanup the test cases.
Actions taken:
- Remove the temporary directory.
The string representation of a class’s name.
For example if we define the class Foo, the full name of the class is firmant.utils.Foo. class_name() will return this as a string.
>>> class Foo(object): pass
...
>>> class_name(Foo)
'firmant.utils.Foo'
If an object that is not a class is passed to class_name(), then a TypeError will be raised.
>>> class_name('Foo')
Traceback (most recent call last):
TypeError: `cls` does not name a type.
Bases: object
An AbstractChunk defines the interface for all chunks.
scheduling_order is a positive integer that determines chunk execution order.
scheduling_order uses normal integer comparison. Chunks of the same priority will be executed in arbitrary order.
Bases: firmant.chunks.AbstractChunk
A chunk that warns of writers with conflicting URLs.
Bases: firmant.chunks.AbstractChunk
For objects that declare attributes, add a permalink.
Pre-existing permalinks will not be overwritten.
Bases: firmant.chunks.AbstractChunk
A chunk that cross-references posts/tags/feeds.
Bases: object
Perform a complete run from parsing through writing.
>>> from pysettings.loaders import mod_to_settings
>>> s = mod_to_settings('firmant.settings')
>>> s.OUTPUT_DIR = outdir
>>> f = Firmant(s)
>>> f.log = Mock('log')
>>> f()
>>> pprint(f.objs) #doctest: +ELLIPSIS
{'feed': [Feed(bar), Feed(baz), Feed(foo), Feed(quux)],
'post': [Post(2009-12-31-party),
Post(2010-01-01-newyear),
Post(2010-02-01-newmonth),
Post(2010-02-02-newday),
Post(2010-02-02-newday2)],
'static': [static_obj<testdata/pristine/static/images/88x31.png>],
'staticrst': [staticrst_obj<about>,
staticrst_obj<empty>,
staticrst_obj<links>],
'tag': [Tag(bar), Tag(baz), Tag(foo), Tag(quux)]}
Bases: object
Find the url or filesystem path that correlate with a set of attributes.
The distinction between urls and paths is best described by example. Let’s declare the attributes slug='foo' and type='object'. The path on the filesystem, where the output would be written could be /path/to/output/directory/objects/foo/index.html while the URL where the document is accessible would be http://permanent.url/objects/foo/.
Having the URLMapper handle the logic of both paths and URLs makes sense. Consider a case where the user wishes to have the above URL be http://permanent.url/objects/foo.html. The local filesystem path would need to adapt to /path/to/output/directory/objects/foo.html
Creating a URLMapper is simple:
>>> from firmant.routing.components import *
>>> um = URLMapper('/path/to/output/directory', 'http://permanent.url/')
>>> um.add( TYPE('post')/YEAR/MONTH/DAY/SLUG )
>>> um.add( TYPE('post')/YEAR/MONTH/DAY )
>>> um.add( TYPE('post')/YEAR/MONTH )
>>> um.add( TYPE('post')/YEAR )
Mapping a set of attributes to a path or URL is a matter of specifying the extension of the document (e.g. ‘html’ or ‘css’) and a set of key-value attributes.
>>> um.path('html', type='post', slug='foo', day=15, month=3, year=2010)
'/path/to/output/directory/2010/03/15/foo/index.html'
>>> um.url('html', type='post', slug='foo', day=15, month=3, year=2010)
'http://permanent.url/2010/03/15/foo/'
If the attributes do not correspond to any path definition, then the value None is returned:
>>> um.path('html', non_existent_attribute=True)
>>> um.url('html', non_existent_attribute=True)
If the extension is None, then the path() and url() methods will not add any information to account for an extension.
>>> um.path(None, type='post', slug='foo', day=15, month=3, year=2010)
'/path/to/output/directory/2010/03/15/foo'
>>> um.url(None, type='post', slug='foo', day=15, month=3, year=2010)
'http://permanent.url/2010/03/15/foo'
As a special corner case, the url() method will return the permalink root if it is asked for extension=None with no arguments.
>>> um.url(None)
'http://permanent.url/'
This is useful when it is known that the attributes specified promise to resolve to a path. Example uses include static files that are simply copied into the output directory.