Skip to main content

Parser for poems in CruscoPoetry format

Project description

This is cruscopoetry.core, the base package of the cruscopoetry libraries. This package handles the processing of poetic texts and their translations written in the CruscoPoetry syntax. cruscopoetry.core can be used both from commandline and programmatically in Python script.

Installation

Through pip:

pip install cruscopoetry.core

This will install the package in your Python (global or virtual) environment.

Accessing documentation about CruscoPoetry Syntax

Knowing CruscoPoetry syntax is a necessary step to use this library. To read the documentation relative to it, download the source code from https://pypi.org/project/cruscopoetry.core/ and extract the archive; go in the directory docs/cruscopoetry_syntax and find there the documentation in rst format.

Basic operations

Help command

cruscopoetry -h, cruscopoetry --help

Prints an outline of the basic operations.

Build command

cruscopoetry build

Parses a source text written in CruscoPoetry syntax and organises its content in a CruscoPoetry Json file.

Options:

-h, --help

Shows a help message about this operation

-i INPUT, --input INPUT

The path of the file containing the poem in CruscoPoetry syntax

-o OUTPUT, --output OUTPUT

The path where the new CruscoPoetry Json file shall be saved

-v, --verbose

Shows more information during the process.

Add Translations command

cruscopoetry add_translations

Parses a translation text written in CruscoPoetry syntax and loads its content on a CruscoPoetry Json file.

Options:

-h, --help

Shows a help message about this operation

-SOURCE, --source SOURCE

The Json file where the translation will be loaded

-t TRANSLATIONS, --translations TRANSLATIONS

one or more translation files writtern in CruscoPoetry syntax. More file names need to be separated by a space; space characters contained in file names must be escaped.

Delete Traslations command

cruscopoetry delete_translations

Deletes a translation from a CruscoPoetry Json file.

Options:

-h, --help

Shows a help message about this operation

-SOURCE, --source SOURCE

The Json file where the translation will be deleted

-t TRANSLATION_IDS, --translation_ids TRANSLATION_IDS

the id or ids of each translation to be deleted. More ids need to be separated by a space.

--indent INDENT

the indent string to be used in the txt file.

List Translations

cruscopoetry list_translations

List the languages and ids of the translations already loaded in a CruscoPoetry Json file.

Options:

-h, --help

Shows a help message about this operation

Positional arguments:
json_file:

The Json file where the translation will be deleted

Render

Rewrites the content of the poem from the Json File to a human-readable format. Besides the source text, also one translation can be included in the rendering. Two subcommands are available, for producing txt and html renderings. Some options are common to both commands:

-h, -help

Prints a help message

-i INPUT, --input INPUT

the JSON file to render as text

--tr_id TR_ID

the id of the translation to include in the text file

--tr_layout

the translation layout, represented by an integer from 0 to 4

--number_after NUMBER_AFTER

the number whose lines have one of its multiples as number will display their number

-o OUTPUT, --output OUTPUT

the file to save the rendering in. If not specified, it will be printed on stdout

The translation layout is indicated by an integer. Each integer corresponds to a different option:

0

NO TRANSLATION

Only the source text is rendered

1

AFTER_TEXT

The whole translation is rendered below the whole original text

2

AFTER_EACH_STANZA

Each stanza is rendered in its original version and immediately below in translation

3

AFTER_EACH_LINE

Each line is rendered in its original version and immediately below in translation

4

SIDE_BY_SIDE

Source text and translations are side by side, each line showing the source version and the translation on the same row

Txt rendering

cruscopoetry render txt

Besides the options listed above, there is:

--indent INDENT

the indent string to be used in the txt file.

Html rendering

cruscopoetry render html

Besides the options listed above, there is:

--pretty_print

pretty-print output option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cruscopoetry.core-0.0.3.tar.gz (57.5 kB view details)

Uploaded Source

Built Distribution

cruscopoetry.core-0.0.3-py3-none-any.whl (101.6 kB view details)

Uploaded Python 3

File details

Details for the file cruscopoetry.core-0.0.3.tar.gz.

File metadata

  • Download URL: cruscopoetry.core-0.0.3.tar.gz
  • Upload date:
  • Size: 57.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for cruscopoetry.core-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2e3700e37ca327955756c872f41156999ca323b47c45a68f0edd167dca9fcf1e
MD5 c67872dde45203c8dda423b51167fc9f
BLAKE2b-256 2aa14e8cd3c4e12acfcf3db1bd9465bc697b0c3fd8e9766964d6afc5c1eb6b21

See more details on using hashes here.

File details

Details for the file cruscopoetry.core-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cruscopoetry.core-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e137b9b78cdee8e353a7eb31b527cf6a19307e32a0cd71921934bb2e0546d388
MD5 8e3680fbfcbdea47796ff6585586d8d4
BLAKE2b-256 c281bb4ea25eabc8ae862237bed7cef7bee54afb8d2ff8e4777ef44ce5d1ff6b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page