Skip to main content

Description

This package provides functionality for handling text indented/aligned with elastic tabstops. If you have an editor which uses elastic tabstops but work on a project that uses spaces, you might use this to convert a file from using spaces to using elastic tabstops, edit it in an elastic tabstops enabled editor and then convert it back to using spaces before saving to disk.

Alternatively, it can be a nice way to create text from tables of data.

Usage

Instantiate a Text object with the string one wants to convert, and then call one of the from_* methods to create a Table object. Table objects have to_* methods which can be called to create new Text objects.

Text methods are from_spaces, from_elastic_tabstops and from_fixed_tabstops, while Table methods are to_spaces, to_elastic_tabstops and to_fixed_tabstops.

So, to convert text from using spaces to using tabs with elastic tabstops one might use the following:

from elastictabstops import Text
elastic_text = Text(spaces_text).from_spaces().to_elastic_tabstops()

Whereas to convert text from using tabs with elastic tabstops to using spaces the following might be used:

from elastictabstops import Text
spaces_text = Text(elastic_text).from_elastic_tabstops().to_spaces()
# or alternatively
spaces_text = Text(elastic_text).from_elastic_tabstops().to_spaces(multiples_of_tab_width=True)

If you want to use this package to print a table of strings you can use something like this:

from elastictabstops import Table
my_table = [
    ['Title', 'Author', 'Publisher', 'Year'],
    ['Generation X', 'Douglas Coupland', 'Abacus', '1995'],
    ['Informagic', 'Jean-Pierre Petit', 'John Murray Ltd', '1982'],
    ['The Cyberiad', 'Stanislaw Lem', 'Harcourt Publishers Ltd', '1985'],
    ['The Selfish Gene', 'Richard Dawkins', 'Oxford University Press', '2006'],
]
spaces_text = Table(my_table).to_spaces()
# or if you're displaying the text in a widget which understands elastic tabstops
elastic_text = Table(my_table).to_elastic_tabstops()

If you have aligned text which you'd like to get a table from you can do things like this:

from elastictabstops import Text
table = Text(elastic_text).from_elastic_tabstops()
table = Text(fixed_text).from_fixed_tabstops()
table = Text(spaces_text).from_spaces()

Author and licence

This package is by Nick Gravgaard and is licensed under an MIT/X11 licence.

Release files for ElasticTabstops 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ElasticTabstops 1.0.1
File Size Uploaded
ElasticTabstops-1.0.1.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ElasticTabstops 1.0.1
File Interpreter ABI Platform
ElasticTabstops-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / ElasticTabstops-1.0.1.tar.gz

Download URL ElasticTabstops-1.0.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
22dd7cfcafeb7bdbf8cfd03aab8e71e3866006dd2372830a0e7c54d78491bc42
BLAKE2b-256 checksum
How to use checksums
5efd20e7f05fbcbd1ad68e0bc68c653265ca08eaa135768d6dccc86c7d9010fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / ElasticTabstops-1.0.1-py3-none-any.whl

Download URL ElasticTabstops-1.0.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34cf2c4b933e5e6a9fcb14b1453764dfc8a897b2634bae5d3c468fad253d70dc
BLAKE2b-256 checksum
How to use checksums
3eab3a8c8384a41ac9144bb207eef7b8672648ac017e99ca1dd8a92900b2c297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page