Projects¶
The Project object is used to represent a project.xml file. Example usage:
>>> from bkgen.project import Project
>>> fn = '/path/to/Project-Folder/project.xml'
>>> project = Project(fn=fn)
Now all of the methods of the project can be called.
-
class
bkgen.project.Project(**args)[source]¶ Bases:
bxml.xml.XML,bkgen.source.SourceEvery project has a project.xml file that holds information about the project. The root element is pub:project, where
pub:is the Publishing XML namespace (see publishingxml.org).-
OUTPUT_KINDS= {‘EPUB’: ‘.epub’, ‘Kindle’: ‘.mobi’}¶ The kinds of outputs that are currently supported.
-
ROOT_TAG= ‘{http://publishingxml.org/ns}project’¶ The tag for the root element of a project.
-
add_resource(href, resource_class, kind=None)[source]¶ add the given resource to the project file, if it isn’t already present
-
build_epub(clean=True, show_nav=False, zip=True, check=True, cleanup=False, before_compile=None, **image_args)[source]¶
-
build_outputs(kind=None, cleanup=True, before_compile=None)[source]¶ build the project outputs kind=None: which kind of output to build; if None, build all
-
content_path¶
-
cover_path¶
-
classmethod
create(parent_path, title, name=None, **project_params)[source]¶ - create a new project.
- parent_path = the filesystem path to the parent folder that this project is in title = the title for the project name = the name of the project, which becomes its folder name and URL slug project_params = parameters passed to the Project.__init__()
Returns the Project XML object.
-
image_path¶
-
import_documents(documents)[source]¶ import the given document collection. This includes (1) storing the document in the project.content_folder (2) adding sections of the document to the spine, if not present
-
import_image(fn, **params)[source]¶ import the image from a local file. Process through GraphicsMagick to ensure clean.
-
import_source(source, documents=True, images=True, stylesheet=True, metadata=False, **params)[source]¶ import a source into the project. source = a Source object that contains the content source documents = whether to import documents from the source images = whether to import images from the source stylesheet = whether to import a stylesheet from the source metadata = whether to import metadata from the source **params = passed to the Source.documents(**params) method
-
import_source_file(fn, **args)[source]¶ import the source fn. fn = the filesystem path to the file (such as a temporary file location) args = arguments that will be passed to Project.import_source()
-
interior_path¶
-
name¶
-
output_image(fn, output_path=None, outfn=None, format=’jpeg’, ext=’.jpg’, res=300, quality=80, maxwh=2048, maxpixels=4000000.0)[source]¶
-
output_kinds¶
-
output_path¶
-
output_spineitems(output_path=None, ext=’.xhtml’, resources=None, http_equiv_content_type=False, canonicalized=False, **image_args)[source]¶
-
path¶
-