Formatting¶
- class dependency_comb.formatting.BaseFormatter(now_date=None, printer=None, printer_kwargs=None)[source]¶
Bases:
objectBase formatter abstract.
This is not a useful formatter since finally it will write computed data as JSON with its
write()method.Concrete formatters would commonly prefer to inherit from
BaseStringFormatter.- Parameters:
now_date (datetime) – A datetime to set instead of default
datetime.now(). This datetime is used to compute the delta time between release and current date.printer (callable)
printer_kwargs (dict)
- serialize_output(content)[source]¶
Serialize output to be written in a file.
Formatters should commonly override it because the default implementation here serializes content with JSON because internally the content is a list but this is rarely the case with other formatters.
- get_required_release(item)[source]¶
Return a release labels for a requirement.
- Parameters:
item (dict) – The requirement dictionnary.
- Returns:
- Respectively the version label and resolved age delta
computed from release publish date against date now. If
resolved_versionis empty, the version label will just beLatestand resolved delta will be null.
- Return type:
tuple
- build_analyzed_table(items)[source]¶
Build the information table for properly analyzed requirements.
- Parameters:
items (list) – List of requirement dict as returned from Analyzer. Only items with status
analyzedare processed here and all other status items are ignored.- Returns:
A list of dictionnaries for each processed items.
- Return type:
list
- build_errors_table(items)[source]¶
Build the information table for failed requirements analyze.
- Parameters:
items (list) – List of requirement dict as returned from Analyzer. All items are processed except the ones with status
analyzed.- Returns:
A list of dictionnaries for each processed items.
- Return type:
list
- output(content)[source]¶
Parse given content and returns it as a Python list.
- Parameters:
content (Path or string or list) –
JSON content as built from Analyzer. It can be either:
A string assumed as JSON to be parsed;
A file Path that will be readed and parsed as JSON;
A list that is expected to be directly the list of (dict) analyzed requirements, no parsing will be involved.
- Returns:
The list of all (dict) requirements from given content.
- Return type:
list
- class dependency_comb.formatting.CSVFormatter(now_date=None, printer=None, printer_kwargs=None)[source]¶
Bases:
BaseStringFormatterFormat a requirements analyze to a report made with Rich library.
- build_analyzed_table(items)[source]¶
Build the information table for properly analyzed requirements.
- Parameters:
items (list) – List of requirement dict as returned from Analyzer. All given items should have a status “analyzed” else it would lead to unexpected results or even errors.
- Return type:
string
- class dependency_comb.formatting.JSONFormatter(now_date=None, printer=None, printer_kwargs=None)[source]¶
Bases:
BaseFormatterFormat a requirements analyze to a JSON report.
- class dependency_comb.formatting.RestructuredTextFormatter(now_date=None, printer=None, printer_kwargs=None)[source]¶
Bases:
BaseStringFormatterFormat a requirements analyze to a RestructuredText report.
- build_analyzed_table(items)[source]¶
Build the information table for properly analyzed requirements.
- Parameters:
items (list) – List of requirement dict as returned from Analyzer. All given items should have a status “analyzed” else it would lead to unexpected results or even errors.
- Returns:
An ASCII table built from given items.
- Return type:
string
- build_errors_table(items)[source]¶
Build the information table for failed requirements analyze.
- Parameters:
items (list) – List of requirement dict as returned from Analyzer. Given items could have any status despite not very useful for properly analyzed items.
- Returns:
An ASCII table built from given items.
- Return type:
string