Paths¶
Classes for different kinds of paths.
- class disseminate.paths.paths.SourcePath(project_root='', subpath='')¶
Bases:
object
A path for a file in the source directory that keeps track of the project_root and subpath.
- Parameters
- project_rootOptional[str]
The path for the project’s root directory.
- subpathOptional[str]
The relative path within the project’s root directory.
- use_name(name)¶
with_name(name) that returns a SourcePath.
A new method name is used since the flavor_cls method takes precedence.
Examples
>>> p = SourcePath(project_root='/media', subpath='tests/fig1.png') >>> p.use_name('fig2.png') SourcePath('/media/tests/fig2.png') >>> p.use_name('fig2.png').subpath SourcePath('tests/fig2.png')
- use_subpath(subpath)¶
Returns a SourcePath with the subpath replaced with the given string or path.
Examples
>>> p = SourcePath(project_root='/media', subpath='tests/fig1.png') >>> p.use_subpath('text.txt') SourcePath('/media/text.txt') >>> p.use_subpath('text.txt').subpath SourcePath('text.txt')
- use_suffix(suffix)¶
with_suffix(suffix) that returns a SourcePath.
A new method name is used since the flavor_cls method takes precedence.
Examples
>>> p = SourcePath(project_root='/media', subpath='tests/fig1.png') >>> p.use_suffix('.pdf') SourcePath('/media/tests/fig1.pdf') >>> p.use_name('fig1.pdf').subpath SourcePath('tests/fig1.pdf')
- class disseminate.paths.paths.TargetPath(target_root='', target='', subpath='')¶
Bases:
object
A path for a file in a target directory that keeps track of the target_root, target and subpath.
- Parameters
- target_rootOptional[str]
The path for the root directory for rendered files.
- targetOptional[str]
The sub-directory for the target type to render. ex: ‘html’ or ‘tex’
- subpathOptional[str]
The relative path within the target sub-directory.
- get_url(context=None, target=None)¶
Construct the url for the path.
- use_name(name)¶
with_name(name) that returns a TargetPath.
A new method name is used since the flavor_cls method takes precedence.
Examples
>>> p = TargetPath(target_root='/media', subpath='tests/fig1.png') >>> p.use_name('fig2.png') TargetPath('/media/tests/fig2.png') >>> p.use_name('fig2.png').subpath TargetPath('tests/fig2.png')
- use_subpath(subpath)¶
Returns a TargetPath with the subpath replaced with the given string or path.
Examples
>>> p = TargetPath(target_root='/media', subpath='tests/fig1.png') >>> p.use_subpath('text.txt') TargetPath('/media/text.txt') >>> p.use_subpath('text.txt').subpath TargetPath('text.txt')
- use_suffix(suffix)¶
with_suffix(suffix) that returns a TargetPath.
A new method name is used since the flavor_cls method takes precedence.
Examples
>>> p = TargetPath(target_root='/media', subpath='tests/fig1.png') >>> p.use_suffix('.pdf') TargetPath('/media/tests/fig1.pdf') >>> p.use_suffix('.pdf').subpath TargetPath('tests/fig1.pdf')