A small package containing simple, useful methods I regularly use and don't want to manually copy into several projects. Most methods are probably to be found in other modules.
Project description
mgpy ("Magpie")
A small package containing simple, useful methods I regularly use and don't want to manually copy into several projects.
Contains the following modules:
mgstr ("Magister")
Contains methods relating to strings.
function insert_line_into_string
insert_line_into_string(line: str, s: str, pos: int) → str
Takes two strings and inserts the first one into the second one as a new line at the given position.
Args:
line(str): The line to insert.s(str): The (potential multi-line) string in which to insertline.pos(int): The line number of the newly inserted line. Uses Python'sList.insert()position syntax—negative indices, e.g.-1, insertslinebefore the last element.
Returns:
str: A new string containing line at the given line number.
function join_strings
join_strings(*args: any, separator: str = ", ") → str
Takes multiple strings and an optional separator element and joins them to a single string. Each non-string argument will be ignored.
Args:
*args(any): Multiple arguments of any type. Only strings will be joined. Arguments of other types will be ignored.separator(str): The separator element which will be put between all arguments. Defaults to ", ".
Returns:
str: A combination of all originally given strings, separated by separator.
function log_print
log_print(s: str, level: Loglevel = Loglevel.INFO, time_format: str = "%Y-%m-%d %H:%M:%S")
Takes a string and outputs it with an additional prefix indicating importance.
Args:
s(str): The string which will be outputlevel(Loglevel, optional): The prefix indicating importance. Defaults toLoglevel.INFO.time_format(str, optional): A (C-time adherent) string to format the time. Defaults to%Y-%m-%d %H:%M:%S
function truncate_string
truncate_string(s: str, length: int, ellipsis: str = '...') → str
Takes a string, truncates it to the given length, adding a given ellipsis.
Args:
s(str): The string which will be shortened.length(int): The length of the shortened string including the length of the ellipsis.ellipsis(str, optional): An optional ellipsis which will be appended. Defaults to"...".
Returns:
str: A truncated version of the string with given length (and ellipsis)
class Loglevel
A string enum defining importance levels for usage in the 'log_print' method
Members:
INFO = "Information": Used to indicate an informational output.WARNING = "Warning": Used to indicate a warning.ERROR = "ERROR": Used to indicate an error.
mgcl ("Magical")
Contains methods to work with colors and convert between different representations.
tbd.
mgnet ("Magnet")
Contains network related methods.
tbd.
mgnum ("Magnum")
Contains methods relating to numbers and their representation.
function generate_human_readable_number
generate_human_readable_number(
number: int,
suffixes: list[str] = None,
decimal_separator: str = '.'
) → str
Takes a number and returns a 'human readable' string. E.g., 1500000 → 1.5M
Args:
number(int): The number to represent.suffixes(list[str], optional): A list of ascendingly sorted suffixes for each order of magnitude. Defaults to["k", "M", "G", "T"].decimal_separator(str, optional): The decimal separator. Defaults to".".
Returns:
str: The human readable string.
mgte ("Mogote")
Contains methods to work with time and date.
tbd.
mgmin ("Megumin")
Contains methods which don't fall into the other categories.
tbd.
Module descriptions were automatically generated via lazydocs.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mgpy-0.1.3.tar.gz.
File metadata
- Download URL: mgpy-0.1.3.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84ae17bad04f551f27c77bc681e068aa79e1db88f3e4c9aeb290ece774a7b0fe
|
|
| MD5 |
bb476285b23e22b1cd32dd8032516a0a
|
|
| BLAKE2b-256 |
a4061f7f662657dd827997814664e7e196b50a9e53483b38c8af6ee0445cb47e
|
Provenance
The following attestation bundles were made for mgpy-0.1.3.tar.gz:
Publisher:
package-and-release.yml on phistoh/mgpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgpy-0.1.3.tar.gz -
Subject digest:
84ae17bad04f551f27c77bc681e068aa79e1db88f3e4c9aeb290ece774a7b0fe - Sigstore transparency entry: 150519827
- Sigstore integration time:
-
Permalink:
phistoh/mgpy@a25fec8d1032e049047671808de242e5b8400c92 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/phistoh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package-and-release.yml@a25fec8d1032e049047671808de242e5b8400c92 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mgpy-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mgpy-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bd99ecd280ba0ae5965df567f49b631d9e0e5738402d5bdea5dbb86ba2af902
|
|
| MD5 |
56c6b9e69c09442c0e83125099eac1de
|
|
| BLAKE2b-256 |
dc59ae1f21ef3b5eed4a76118ebb916fb3621ff8945219f99d29ba03af693fa6
|
Provenance
The following attestation bundles were made for mgpy-0.1.3-py3-none-any.whl:
Publisher:
package-and-release.yml on phistoh/mgpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgpy-0.1.3-py3-none-any.whl -
Subject digest:
0bd99ecd280ba0ae5965df567f49b631d9e0e5738402d5bdea5dbb86ba2af902 - Sigstore transparency entry: 150519828
- Sigstore integration time:
-
Permalink:
phistoh/mgpy@a25fec8d1032e049047671808de242e5b8400c92 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/phistoh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package-and-release.yml@a25fec8d1032e049047671808de242e5b8400c92 -
Trigger Event:
push
-
Statement type: