Skip to main content

A custom made python 3 file that adds some features that aim to streamline the coding process. This was made primarily for a python coding class, apologies it is a little out of the blue.

Project description

SuperUtilities-Python3

A custom-made python 3 file that adds some features that aim to streamline the coding process.

This was made primarily for a python coding class, apologies it is a little out of the blue.

Installation:

pip install superutilities

Functions:

  • SInput: A beefed up version of input(), has built in error handling, allows for automatic type conversion and retries, along with gui support.

    • prompt:str - The prompt you wish to ask the user.
    • IsInt:bool - Should the user's input be a returned as an integer?
    • IsBool:bool - Should the user's input be a returned as a bool?
    • IsFloat:bool - Should the user's input be a returned as a float?
    • acceptedAnswers:list - List of accepted answers. If list is not empty it will ask the user to retry if input is not in this list.
    • AACaseSensitive:bool - If accepted answers should be case-sensitive.
    • UseRegularExpression:bool - Use regex to determine if the input is valid or not. (See RegularExpression variable to set regex.)
    • RegularExpression - The regex to use if the input is valid. r''
    • ReturnREListOnly:bool - Bypasses ALL other arguments and returns a list of accepted inputs found by regex.
    • printBypass:bool - Disables the print function.
    • inputBypass - The user's input given by a separate function (For use in GUI environments).
    • useInputBypass:bool - Should the function use the input given from the inputBypass argument.
  • SanitizeString: A function that removes, strips, and detects certain combinations of strings or regex within other strings. Built with the idea of being used to prevent inputs that could lead to unintended outputs.

    • string:str - The string to sanitize.
    • TestFor:bool - Returns true if it finds a 'banned character' in the string.
    • PrintFound:bool - Makes TestFor return the characters found in the string. (Must have TestFor set to true for it to have any effect)
    • bannedCharacters:list - A list of strings of banned characters to remove from the string.
    • replaceWith: - A string to replace sanitized characters with. Default is nothing.
  • PermutationCalculator: A small function that returns the number of possible combinations of certain points and values.

    • NumOfPoints:int - Number of points/spots for a value to be.
    • NumOfValues:int - Number of values that a point/spot could have.
  • CombinationsCalculator: Just a shortcut for calculating combinations.

    • NumOfPoints:int - Number of points/spots for a value to be.
    • NumOfValues:int - Number of values that a point/spot could have.
  • GetMedian: Returns the middle of a list, with a bool to automatically sort it for you.

    • inputList:list - The list to get the median of.
    • sortList:bool - Should python sort the list automatically?
    • IsNotOnlyNumbers:bool - If the list contains more than just numbers, set to true.
  • saveJsonToFile: Saves a dictionary or list variable as a '.json' file.

    • file_path:str - The file's path to write/save to.
    • data - A dictionary or list to save as JSON data
  • getJsonFromFile: Reads and returns a '.json' file as a dictionary or list.

    • file_path:str - The file's path to read from.

Classes:

  • ConflictingInputsDetected: An error class that is fired when using conflicting arguments in a function.

  • Logger: A class that is designed to streamline the process of saving logs to a .txt file.

    • log_directory:str - The directory name / path to store the log files in.
    • file_date_format:str - The datetime to_str() format to use when naming the .txt files.
    • timestamp_format:str - The datetime to_str() format to use when timestamping individual logs.
    • log():
      • text:str - The text to log.
      • tag:str - A tag that will be put before the text. Meant for INFO, WARN, and ERROR tags.
      • print_to_console:bool - Whether to print the log to the console.

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

superutilities-0.2.4.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

superutilities-0.2.4-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file superutilities-0.2.4.tar.gz.

File metadata

  • Download URL: superutilities-0.2.4.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for superutilities-0.2.4.tar.gz
Algorithm Hash digest
SHA256 4de90d498016406e882e6b2f477b5cd8686bd3da33d8107990216e52dfdddcf7
MD5 51c1a3a084023c95267f3296d79bfb0f
BLAKE2b-256 d20e97be2715848c91f2142f8d7db4e87d682a204f94d1f8f10032032c8d4952

See more details on using hashes here.

File details

Details for the file superutilities-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: superutilities-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for superutilities-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 95797480d5b6a4f55f7b666ab6cd4b17cc3ac67af668e67cf719bef6ec5a17dc
MD5 d5dc721154fb815bc3f7da9ed532b858
BLAKE2b-256 93a130e2b3f7a04d4d677480b7d1fa3c935b018b2cbb21f35d6493e9a0a69243

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page