Skip to main content

ConfPrint

Ukraine

GitHub License Python PyPI Downloads Codecov code coverage Github Contributors GitHub search hit counter GitHub issues GitHub last commit

CICD

Copyright 2021 Lewi Lie Uberg
Released under the MIT license

ConfPrint provides a simple way to make predefined printer configurations.

Contents

Citation

Please see CITATION.cff for the full citation information.

APA

Lie Uberg, L., & Hjelle, G. A. (2022). confprint (Version 0.5.1) [Computer software]. https://github.com/lewiuberg/confprint

BibTex

@software{Lie_Uberg_confprint_2022,
author = {Lie Uberg, Lewi and Hjelle, Geir Arne},
license = {MIT},
month = {10},
title = {{confprint}},
url = {https://github.com/lewiuberg/confprint},
version = {0.5.1},
year = {2022}
}

Prerequisites

Click

Please see pyproject.toml for the full citation information.

Installation

Using pip

python -m pip install confprint

Using Poetry

poetry add confprint

Usage

prefix_printer

from confprint import prefix_printer

p_test1 = prefix_printer(prefix="test1")
p_test1("Please read all the lines to understand the usage.\n")

p_test2 = prefix_printer(prefix="test2", whitespace=4)
p_test2("use whitespace to indent the output.\n")

p_test3 = prefix_printer(prefix="test3", upper=False)
p_test3("unaltered text, a.k.a .upper() not applied to the string.\n")

p_test4 = prefix_printer(prefix="test4", stderr=True)
p_test4("using sys.stderr.write as the print function\n")

p_test5 = prefix_printer(prefix="test5", click=True)
p_test5("using click.echo as the print function\n")

p_test6 = prefix_printer(prefix="test6", frame_left="( ", frame_right=" )")
p_test6("using custom frame characters\n")

p_test7 = prefix_printer(prefix="test7", counter_start=0)
p_test7("By defining a 'counter_start',")
p_test7("a counter number will be appended")
p_test7("to the prefix.\n")

p_test8 = prefix_printer(prefix="test8", counter_start=1)
p_test8("Different prefix printers can have different counters.")
p_test7("As you see in this example,")
p_test8("they have do not interfere with each other.\n")

p_test9 = prefix_printer(prefix="test9", counter_start=10, global_counter=True)
p_test9("Global counters can also be set.")
p_test9("However, if any prefix printers has already been defined,")
p_test8("you have to set global_redefine to True.")
p_test7("But as you can see here,")
p_test7("global counters still doesn't interfere with local counters.\n")

p_test10 = prefix_printer(prefix="test10", global_counter=True)
p_test10("New prefix_printers will pick up the last global count, which can")
p_test10("be handy with different prefixes should be used with sequential counting.\n")

p_test1(
    """With new lines in strings the text is converted
to multiline, then all but the first are
indented to line up with the rest.\n"""
)

p_test1(
    "The next example wil not be ending with a `:`, "
    "since it has no input.\nAnd as you can see, this is also a multiline text.\n"
)

p_done = prefix_printer(prefix="done")
p_done()

print() # adding a blank line.
p_bonus = prefix_printer(prefix="bonus")
variable_name = "Using a 'f-string' with an added '=' can be handy when debugging."
p_bonus(f"{variable_name = } ")
[TEST1]:  Please read all the lines to understand the usage.
          
[TEST2]:     use whitespace to indent the output.
             
[test3]:  unaltered text, a.k.a .upper() not applied to the string.
          
[TEST4]:  using sys.stderr.write as the print function
          
[TEST5]:  using click.echo as the print function
          
( TEST6 ):  using custom frame characters
            
[TEST7:0]: By defining a 'counter_start',
[TEST7:1]: a counter number will be appended
[TEST7:2]:  to the prefix.
            
[TEST8:1]: Different prefix printers can have different counters.
[TEST7:3]: As you see in this example,
[TEST8:2]:  they have do not interfere with each other.
            
[TEST9:10]: Global counters can also be set.
[TEST9:11]: However, if any prefix printers has already been defined,
[TEST8:3]: you have to set global_redefine to True.
[TEST7:4]: But as you can see here,
[TEST7:5]:  global counters still doesn't interfere with local counters.
            
[TEST10:12]: New prefix_printers will pick up the last global count, which can
[TEST10:13]:  be handy with different prefixes should be used with sequential counting.
              
[TEST1]:  With new lines in strings the text is converted
          to multiline, then all but the first are
          indented to line up with the rest.
          
[TEST1]:  The next example wil not be ending with a `:`, since it has no input.
          And as you can see, this is also a multiline text.
          
[DONE]

[BONUS]: variable_name = "Using a 'f-string' with an added '=' can be handy when debugging." 

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

Metadata

Release files for confprint 0.5.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 confprint 0.5.1
File Size Uploaded
confprint-0.5.1.tar.gz 10.1 kB Details

Built distribution (wheel)

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

Total release size: 18.1 kB

Release files / confprint-0.5.1.tar.gz

Download URL confprint-0.5.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b1564b3c1546d71de907f0ffced2b1bd0852526cc4b7b8d73e5260cd1a1dd872
BLAKE2b-256 checksum
How to use checksums
3d466fe7b03b6a62415f9e82e64a0a9cf7ea27ac44352b0645e1fb303514710d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.2 Linux/5.13.0-1017-azure

Release files / confprint-0.5.1-py3-none-any.whl

Download URL confprint-0.5.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffd1bb6d126f4dcc0047ce501e6b985db1c293476f5780d96f0a57581f426bee
BLAKE2b-256 checksum
How to use checksums
60e989946aceb028afec4d77642944c7c2018ca328c3edacb26852255ababfcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.2 Linux/5.13.0-1017-azure

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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