Welcome to pandocwrapperapi’s documentation!¶
const¶
-
const.
allowed_file
(filename)¶ Check if a file is allowed to be uploaded. Allowed files are defined in
const.ALLOWED_UPLOADED_EXT
Parameters: filename – name of the file to be checked Returns: True/False if the files i allowed or not.
-
const.
create_dir
(parent=None)¶ Create a directory with a unique name.
If no parent is given, the parent directory will be the default upload folder:
const.ROOT
plusconst.UPLOAD_FOLDER
Parameters: parent – the directory in which the new directory shall be created (default is None) Returns: The path of the new directory.
-
const.
download
(file: str)¶ Download a file given by path relative to
const.ROOT
. Deletes the file after downloadingParameters: file – Relative path of the file to be downloaded Returns: The file.
-
const.
mkdir
(directory: str)¶ Create a directory if not already existing.
Parameters: directory – Path of the directory to be created. Returns: Nothing
-
const.
split_and_get_last_element
(split_chr: str, string_to_split: str)¶ Get last element of a given path.
Parameters: - split_chr – Character at which the string should be splitted
- string_to_split – Path to be splitted
Returns: Last element of path.
-
const.
split_path_and_get_all_but_last_element
(split_chr: str, string_to_split: str)¶ Get the path until a certain directory/file without the certain directory/file.
Parameters: - split_chr – Character at which the string should be splitted
- string_to_split – Path to be splitted
Returns: Path without the last element.
-
const.
upload
(file, path=None)¶ Uploads a file to an, optionally, given path.
If no path is given, a subdirectory will be created using
create_dir()
. If a path is given, a subdirectory inside theconst.ROOT
directory defined inconst.py
. Furthermore if the file is an image defined by its extension a “imgs” directory will be created nested.Only files defined in
const.ALLOWED_UPLOAD_EXT
are allowed to be uploaded.Parameters: - file – the file object to be uploaded
- path – Path to where the file should be saved (default is None)
Returns: JSON-Object with properties, indicating if file successfully was uploaded and where or an error message if a problem occurred.
converter¶
-
converter.
convert
(file, design, bib_file)¶ Converts a file (docx, odt or tex) into a PDF-file using the given design.
Parameters: - file – Name of the file to be converted
- design – Name of the design that should be used. Only supports htwberlin so far
- bib_file – Name of the bibliography file, if needed. (Default is None)
Returns: Dictionary with fields, indicating if file successfully was converted and path of the output file or an error message if a problem occurred.
markdown_presentation¶
-
markdown_presentation.
convert
(file_path, toc)¶ Uses the pandocwrapper module to convert a markdown-file to a PDf presentation.
Parameters: - file_path – Path of the markdown file to be converted
- toc – Boolean to indicate if an outline-slide should be created or not
Returns: Dictionary with fields, indicating if file successfully was converted and path of the output file or an error message if a problem occurred.
-
markdown_presentation.
create
(parameters)¶ Takes the raw slides and title slide, formats them and converts them into a PDf presentation
Parameters: parameters – Dictionary with slides, title_slides and outline. Returns: Dictionary with fields, indicating if file successfully was converted and path of the output file or an error message if a problem occurred.
-
markdown_presentation.
format_markdown
(slides, title_slides)¶ Formats slides and title_slide into a convertable markdown-string
Parameters: - slides – Dictionary of slides: each slide has two columns (col1 and col2)
- title_slides – Dictionary of title slides: each title slide has a title, subtitle, author and date
Returns: The formatted markdown string.
-
markdown_presentation.
write_to_file
(markdown, path)¶ Writes markdown to a file and saves it in a specific path.
Parameters: - markdown – Markdown as a string
- path – Path to the directory where the file should be saved.
Returns: Full path to the file.