prometa package

Subpackages

Submodules

prometa.citation module

Citation file format (.cff) functions.

https://citation-file-format.github.io/ https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md

class prometa.citation.Citation(project)[source]

Bases: object

Citation data manager.

__init__(project)[source]
Parameters:

project – A Project instance.

static get_template()[source]

Get the cff file template as an object.

update()[source]

Update the citation file with data from codemeta.json and other sources.

Returns:

The citation file object.

prometa.common module

Common constants and functions.

prometa.common.choose(items, include_none=False)[source]

Prompt the user to choose an item from an iterable of items.

Parameters:
  • items – The iterable of items.

  • include_none – If True, allow the user to choose None even if it is not in the list.

Returns:

The chosen item.

prometa.config module

prometa.exception module

Exceptions.

exception prometa.exception.PrometaException[source]

Bases: Exception

Base class for custom exceptions.

prometa.file module

File operations.

prometa.file.diff(path_1, path_2, differ='vimdiff')[source]

Diff 2 paths.

prometa.file.update_content(content, path, encoding='utf-8', **kwargs)[source]

Interactively compare and merge new content. If the target path does not exist, the content will be written directly to it.

Parameters:
  • content – The new content to merge.

  • path – The target path.

  • encoding – The file encoding to use when writing the content. If None, the content is assumed to be bytes.

  • **kwargs – Keyword arguments passed through to diff().

prometa.insert module

Base class for inserting content into text files.

class prometa.insert.Inserter(regex)[source]

Bases: object

Insert updated content into a text file.

__init__(regex)[source]
Parameters:

regex – A compiled regular expression.

insert(match)[source]

Given a regular expression match, return the content to insert.

Parameters:

match – The Match object.

Returns:

The string to substitute for the match.

update(path, encoding='utf-8')[source]

Insert the configured content into the file.

class prometa.insert.MarkdownInserter[source]

Bases: Inserter

Inserter with custom regex for invisible comments in Markdown files.

In Markdown, a link label for a simple hash results in no output for most common Markdown processors: “[comment]: #”. Note that these must be proceeded by blank lines to be recognized in Markdown.

This class recognized blocks that begin with a comment prefixed with “insert: “ and end with a comment containing only “/insert”. Both comments must have the same indentation level and the inserted text will be indented to the same level.

__init__()[source]
Parameters:

regex – A compiled regular expression.

Get the Markdown link.

Parameters:
  • label – The label shown for the link.

  • url – The URL of the link.

Returns:

The Markdown link as a string.

get_output(label, content)[source]

Get output to replace the given label. Override this to insert custom content.

Parameters:
  • label – The label in the comment pair that was matched.

  • content – The content between the matched comments.

Returns:

The content to insert, or None if the label was not recognized.

insert(match)[source]

Given a regular expression match, return the content to insert.

Parameters:

match – The Match object.

Returns:

The string to substitute for the match.

prometa.main module

prometa.project module

prometa.readme module

Module contents

Package stub.