diff --git a/.env b/.env new file mode 100644 index 0000000..d878548 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ + +ARANGO_PWD_ENV_MANAGER=jagskoterenv(Y) \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..802e415 --- /dev/null +++ b/__init__.py @@ -0,0 +1,7 @@ +try: + from colorprinter.colorprinter.print_color import * +except ImportError: + try: + from colorprinter.print_color import * + except ImportError: + print("Could not import colorprinter module") \ No newline at end of file diff --git a/__pycache__/__init__.cpython-310.pyc b/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..75e886d Binary files /dev/null and b/__pycache__/__init__.cpython-310.pyc differ diff --git a/build/lib/colorprinter/__init__.py b/build/lib/colorprinter/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/build/lib/colorprinter/print_color.py b/build/lib/colorprinter/print_color.py new file mode 100644 index 0000000..40c351e --- /dev/null +++ b/build/lib/colorprinter/print_color.py @@ -0,0 +1,102 @@ +def choose_color(last_color_index): + """ + Selects the next color in a predefined sequence of colors. + + Args: + last_color_index (int): The index of the last color used. + + Returns: + tuple: A tuple containing the ANSI escape code for the selected color (str) + and the index of the selected color (int). + """ + colors = { + "blue": "\033[94m", + "green": "\033[92m", + "yellow": "\033[93m", + "red": "\033[91m", + "purple": "\033[95m", + } + color_keys = list(colors.keys()) + color_index = (last_color_index + 1) % len(color_keys) + color = color_keys[color_index] + return colors[color], color_index + + +def print_green(*args): + """ + Prints the provided arguments in green. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[92m{text}\033[0m") + + +def print_red(*args): + """ + Prints the provided arguments in red. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[91m{text}\033[0m") + + +def print_yellow(*args): + """ + Prints the provided arguments in yellow. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[93m{text}\033[0m") + + +def print_blue(*args): + """ + Prints the provided arguments in blue. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[94m{text}\033[0m") + + +def print_purple(*args): + """ + Prints the provided arguments in purple. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[95m{text}\033[0m") + + +def print_rainbow(*args): + """ + Prints the provided arguments in a rainbow of colors. + + Args: + *args: Variable length argument list. Each argument can be a string, list, or dictionary. + - If the argument is a list, each element in the list will be printed in a different color. + - If the argument is a dictionary, each key-value pair will be printed in a different color. + - If the argument is a string or any other type, it will be printed in a different color. + + Returns: + None + """ + color_index = -1 + text = "" + for arg in args: + if isinstance(arg, list): + for i in arg: + color_code, color_index = choose_color(color_index) + text += f"{color_code}{i}\033[0m " + elif isinstance(arg, dict): + for k, v in arg.items(): + color_code, color_index = choose_color(color_index) + text += f"{color_code}{k}: {v}\033[0m " + else: + color_code, color_index = choose_color(color_index) + text += f"{color_code}{arg}\033[0m " + print(text) diff --git a/colorprinter.egg-info/PKG-INFO b/colorprinter.egg-info/PKG-INFO new file mode 100644 index 0000000..d013c45 --- /dev/null +++ b/colorprinter.egg-info/PKG-INFO @@ -0,0 +1,63 @@ +Metadata-Version: 2.4 +Name: colorprinter +Version: 0.1.0 +Summary: A simple utility for printing text in various colors to the terminal +Home-page: https://github.com/lasseedfast/colorprinter +Author: Lasse Edfast +Author-email: lasse@edfast.se +Classifier: Programming Language :: Python :: 3 +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Requires-Python: >=3.6 +Description-Content-Type: text/markdown +License-File: LICENSE +Dynamic: author +Dynamic: author-email +Dynamic: classifier +Dynamic: description +Dynamic: description-content-type +Dynamic: home-page +Dynamic: license-file +Dynamic: requires-python +Dynamic: summary + +# Colorful Print Utility + +This Python module provides a simple utility for printing text in various colors to the terminal. It supports printing in green, red, yellow, blue, and purple, as well as a special "rainbow" mode that cycles through colors for each argument. +Use it as as you normaly use ```print()```. + +## Functions + +- `print_green(*args)`: Prints the given arguments in green color. +- `print_red(*args)`: Prints the given arguments in red color. +- `print_yellow(*args)`: Prints the given arguments in yellow color. +- `print_blue(*args)`: Prints the given arguments in blue color. +- `print_purple(*args)`: Prints the given arguments in purple color. +- `print_rainbow(*args)`: Prints each argument in a different color, cycling through the available colors. Supports nested lists and dictionaries. + +## Usage + +To use this module, simply import it and call the desired function with the text you want to print as arguments. Here's an example: + +`git clone https://github.com/lasseedfast/colorprinter` + +This will clone this repo as a folder to your computer. When you want to use the colorprinter, make sure that folder is in the same folder as you're working. Then you can use it like: + +```python +from colorprinter.print_color import print_green, print_rainbow + +print_green("This is in green!") +print_rainbow("This", "will", "be", "in", "multiple", "colors!") +``` + +Alternatively, you can import all functions at once using from print_color import \*. However, be cautious when using this approach as it imports all public names defined in the module, which can lead to conflicts with other modules or variables in your namespace.* + +## Customization +The colors are defined using ANSI escape codes. You can modify the choose_color function or the color codes within each print function if you wish to customize the colors. + +## Requirements +This module uses standard Python libraries only and should work on any system that supports Python and ANSI escape codes for terminal colors. + +## License +This project is open-sourced under the MIT License. Feel free to use, modify, and distribute as you see fit. + diff --git a/colorprinter.egg-info/SOURCES.txt b/colorprinter.egg-info/SOURCES.txt new file mode 100644 index 0000000..550f195 --- /dev/null +++ b/colorprinter.egg-info/SOURCES.txt @@ -0,0 +1,9 @@ +LICENSE +README.md +setup.py +colorprinter/__init__.py +colorprinter/print_color.py +colorprinter.egg-info/PKG-INFO +colorprinter.egg-info/SOURCES.txt +colorprinter.egg-info/dependency_links.txt +colorprinter.egg-info/top_level.txt \ No newline at end of file diff --git a/colorprinter.egg-info/dependency_links.txt b/colorprinter.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/colorprinter.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/colorprinter.egg-info/top_level.txt b/colorprinter.egg-info/top_level.txt new file mode 100644 index 0000000..a370d53 --- /dev/null +++ b/colorprinter.egg-info/top_level.txt @@ -0,0 +1 @@ +colorprinter diff --git a/colorprinter/__pycache__/__init__.cpython-310.pyc b/colorprinter/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..70660d2 Binary files /dev/null and b/colorprinter/__pycache__/__init__.cpython-310.pyc differ diff --git a/colorprinter/__pycache__/print_color.cpython-310.pyc b/colorprinter/__pycache__/print_color.cpython-310.pyc new file mode 100644 index 0000000..dbcdc5f Binary files /dev/null and b/colorprinter/__pycache__/print_color.cpython-310.pyc differ