Skip to main content

Powerful Strings

Project description

Powerstring :zap::knot:

WARNING

Keep in mind that the documentation of this module is not finished yet. The same counts for the module itself. Avoid using the beta version!


The Powerstring module provides many features for working with strings.

Working with multiline strings in python can be very frustating. There's an option by using backslash n and spaces which can be very confusing for reading. Another option is creating multiline strings with three quotes. The problem with that option is, that you have problems with the indention and the code will look ugly. This module provides a feature where you can create multiline strings without destroying the overall look of the code. You can also style parts of the text, insert horizontal rules, create lists and add comments in the text itself.

This module also provides following features:

  • swapping substrings within a string
  • replacing substrings within a string
  • progress counter/bar
  • highlighted strings
  • ansi sequences

Contents

  1. Install the powerstring module
  2. The Powerstring class
    • Setting up a powerstring
    • Style text
    • Adding text to a powerstring
    • Remove ansi from a powerstring
    • Guidelines for setting a title and description

Install the powerstring module

pip install powerstring

Import the powerstring module:

import powerstring as ps

when only using the powerstring class

from powerstring import Powerstring

The Powerstring class

Setting up a powerstring

setup = Powerstring("""Setup -- General information for the setup
    username :: John Doe
    password :: pa0-@kB95$v-Z/~Ky
    email :: john.doe@email.com
""")
print(setup)
print()
print(setup.title)
print(setup.description)

Output:

username :: John Doe
password :: pa0-@kB95$v-Z/~Ky
email :: john.doe@email.com

Setup
General information for the setup

Notice that the print function automatically turns the arguments to string. If you want the powerstring in string format use the str() function.

print(type(setup))
print(type(str(setup)))

Output:

<class 'powerstring.Powerstring'>
<class 'str'>

Style text

The default syntax the Powerstring class uses is powerstring.Syntax.Default. You can use a different syntax by editing the syntax argument.

All syntaxes and their function can be looked up here.

Let's take a look at a few basic functions from the default syntax:

Titles

setup = ps.Powerstring("""
    [ Setup ]
    [username](u) :: [John Doe]i
    [password](u) :: [pa0-@kB95$v-Z/~Ky]i
    [email](u)    :: [john.doe@email.com]i

Keep in mind that the output won't be shown correctly in markdown. Check out the docs or copypaste the code.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

powerstring-0.0.1b1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file powerstring-0.0.1b1-py3-none-any.whl.

File metadata

  • Download URL: powerstring-0.0.1b1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for powerstring-0.0.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa364dde45711a16df0a9acd46f344128c93fb9cc605f313ba165df4d2fb1518
MD5 ba22e5343d74bb65eed7c97eb12976b7
BLAKE2b-256 4f3fc6890e51d6976d7167b25ad410387eac24ec19d678c41630ffdfa9c486b3

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