StringF (version 0.1.0)
index
StringF.html

This package implements tools to build python package and tools.
 
>>> string_lengthformat("azerty")
'azerty       ,'
>>> string_lengthformat("azertyazertyazerty")
'azertyazer...,'
>>> print(strings_tableformat([(0, 1), ("a" * 50, "b" * 50)]))
|0            |1            |
|aaaaaaaaaa...|bbbbbbbbbb...|
>>> print(strings_tableformat([(0, 1), ("a" * 50, "b" * 50)], length=[13, 26]))
|0            |1                         |
|aaaaaaaaaa...|bbbbbbbbbbbbbbbbbbbbbbb...|
>>> print(strings_tableformat([["a" * 5, "b" * 25]] * 2, length=[5, 25], columns=["1" * 5, "2" * 25]))
|11111|2222222222222222222222222|
|-----|-------------------------|
|aaaaa|bbbbbbbbbbbbbbbbbbbbbbbbb|
|aaaaa|bbbbbbbbbbbbbbbbbbbbbbbbb|
>>> class A:
...     def __init__(self):
...             self.a = "a"
...             self.b = "b"
...             self.azerty = 1.1
...
>>> a = A()
>>> print(str(Object_StringF(a)))
A(a='a', b='b', azerty=1.1)
>>> print(str(Object_StringF(a, table_mode=True)))
A
|Attribut     |Value        |
|-------------|-------------|
|a            |a            |
|b            |b            |
|azerty       |1.1          |
>>>
 
Run tests:
 ~# python -m doctest StringF.py
 ~# python StringF.py            # Verbose mode
 
3 items passed all tests:
   9 tests in __main__
   2 tests in __main__.string_lengthformat
   3 tests in __main__.strings_tableformat
14 tests in 6 items.
14 passed and 0 failed.
Test passed.
 
~# coverage run StringF.py
~# coverage report
Name         Stmts   Miss  Cover
--------------------------------
StringF.py      67      0   100%
--------------------------------
TOTAL           67      0   100%
~#

 
Classes
       
builtins.object
Object_StringF

 
class Object_StringF(builtins.object)
    Object_StringF(object_: object, *args, table_mode: bool = False, **kwargs)
 
This class implements a generic __str__ methods.
 
  Methods defined here:
__init__(self, object_: object, *args, table_mode: bool = False, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
__str__(self)
Return str(self).

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
string_lengthformat(string: str, length: int = 13, end: str = '...', separator: str = ',') -> str
This function formats string length.
 
>>> string_lengthformat("azerty")
'azerty       ,'
>>> string_lengthformat("azertyazertyazerty")
'azertyazer...,'
>>>
strings_tableformat(strings: collections.abc.Iterator[collections.abc.Iterator[str]], length: Union[collections.abc.Sequence[int], int] = 13, end: str = '...', separator: str = '|', columns: collections.abc.Iterator[str] = None) -> str
This function returns a formatted table of strings.
 
>>> print(strings_tableformat([(0, 1), ("a" * 50, "b" * 50)]))
|0            |1            |
|aaaaaaaaaa...|bbbbbbbbbb...|
>>> print(strings_tableformat([(0, 1), ("a" * 50, "b" * 50)], length=[13, 26]))
|0            |1                         |
|aaaaaaaaaa...|bbbbbbbbbbbbbbbbbbbbbbb...|
>>> print(strings_tableformat([["a" * 5, "b" * 25]] * 2, length=[5, 25], columns=["1" * 5, "2" * 25]))
|11111|2222222222222222222222222|
|-----|-------------------------|
|aaaaa|bbbbbbbbbbbbbbbbbbbbbbbbb|
|aaaaa|bbbbbbbbbbbbbbbbbbbbbbbbb|
>>>

 
Data
        __all__ = ['string_lengthformat', 'strings_tableformat', 'Object_StringF']
__author_email__ = 'mauricelambert434@gmail.com'
__copyright__ = '\nPythonToolsKit Copyright (C) 2022 Maurice Lam...ome to redistribute it\nunder certain conditions.\n'
__description__ = '\nThis package implements tools to build python package and tools.\n'
__license__ = 'GPL-3.0 License'
__maintainer__ = 'Maurice Lambert'
__maintainer_email__ = 'mauricelambert434@gmail.com'
__url__ = 'https://github.com/mauricelambert/PythonToolsKit'

 
Author
        Maurice Lambert