PK!8C!''signalepy/__init__.py#!/usr/bin/env python """ author: Shardul Nalegave license: MIT License Copyright (c) 2018 Shardul Nalegave Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ __version__ = '0.1.0' import os import sys from sys import platform, stdout class Signale: def __init__(self, opts={"scope": None, "underlined": False}): self.options = opts try: self.custom_loggers_conf = opts["custom"] for conf in self.custom_loggers_conf: func = lambda text="", prefix="", suffix="": self.log(text, prefix, suffix, conf) setattr(self, conf["name"], func) except KeyError: pass try: self.underlined = opts["underlined"] except KeyError: self.underlined = False try: scope = opts["scope"] if scope != None: self.scope = scope if scope != "" else "global" else: self.scope = None except KeyError: self.scope = None if platform == "win32": self.figures = { "pause": "||", "tick": '√', "cross": '×', "star": '*', "squareSmallFilled": '[█]', "play": '►', "bullet": '*', "ellipsis": '...', "pointerSmall": '»', "info": 'i', "warning": '‼', "heart": '♥', "radioOn": '(*)', "radioOff": '( )' } else: self.figures = { "pause": "||", "tick": '✔', "cross": '✖', "star": '★', "squareSmallFilled": '◼', "play": '▶', "bullet": '●', "ellipsis": '…', "pointerSmall": '›', "info": 'ℹ', "warning": '⚠', "heart": '♥', "radioOn": '◉', "radioOff": '◯' } self.colors = { "green": "\u001b[32;1m", "grey": "\u001b[38;5;240m", "red": "\u001b[38;5;196m", "yellow": "\u001b[38;5;11m", "purple": "\u001b[38;5;127m", "dark blue": "\u001b[38;5;33m", "cyan": "\u001b[36;1m", "very light blue": "\u001b[38;5;39m", "pink": "\u001b[38;5;198m", "reset": "\u001b[0m" } def coloured(self, color, text): color = self.colors[color] reset = self.colors["reset"] return f"{color}{text}{reset}" def logger_label(self, color, icon, label): if self.underlined == True: label = f"\u001b[4m{label}\u001b[0m" label = f"\u001b[1m{label}\u001b[0m" label = self.coloured(color, "{} {}".format(icon, label)) return label def logger(self, text="", prefix="", suffix=""): message = "" if prefix != "": pointer = self.figures["pointerSmall"] message = f" \u001b[38;5;248m[{prefix}] {pointer}\u001b[0m {text}" else: message = f" {text}" if suffix != "": message += f" \u001b[38;5;245m-- {suffix}\u001b[0m" if self.scope != None: if isinstance(self.scope, list): message = " " + message scopes = "" for item in self.scope: scopes += f" \u001b[38;5;248m[{item}]\u001b[0m" if prefix == "": pointer = self.figures["pointerSmall"] message = f" \u001b[38;5;248m{scopes} \u001b[38;5;248m{pointer}\u001b[0m" + message else: message = f" \u001b[38;5;248m{scopes}\u001b[0m" + message else: if prefix == "": pointer = self.figures["pointerSmall"] message = f" \u001b[38;5;248m[{self.scope}] \u001b[38;5;248m{pointer}\u001b[0m" + message else: message = f" \u001b[38;5;248m[{self.scope}]\u001b[0m" + message # message = f" \u001b[38;5;248m[{self.scope}]\u001b[0m" + message return message def log(self, text="", prefix="", suffix="", conf={}): text = "{}: {}".format(self.logger_label(conf["color"], conf["badge"], "{}".format(conf["label"])), text) message = self.logger(text, prefix, suffix) print(message) def simple(self, text="", prefix="", suffix=""): print(self.logger(text, prefix, suffix)) def success(self, text="", prefix="", suffix=""): tick = self.figures["tick"] text = "{}: {}".format(self.logger_label("green", tick, "Success"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def start(self, text="", prefix="", suffix=""): icon = self.figures["play"] text = "{}: {}".format(self.logger_label("green", icon, "Start"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def error(self, text="", prefix="", suffix=""): cross = self.figures["cross"] text = "{}: {}".format(self.logger_label("red", cross, "Error"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def warning(self, text="", prefix="", suffix=""): icon = self.figures["warning"] text = "{}: {}".format(self.logger_label("yellow", icon, "Warning"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def watch(self, text="", prefix="", suffix=""): icon = self.figures["ellipsis"] text = "{}: {}".format(self.logger_label("yellow", icon, "Watching"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def stop(self, text="", prefix="", suffix=""): icon = self.figures["squareSmallFilled"] text = "{}: {}".format(self.logger_label("red", icon, "Stop"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def important(self, text="", prefix="", suffix=""): icon = self.figures["star"] text = "{}: {}".format(self.logger_label("yellow", icon, "Important"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def pending(self, text="", prefix="", suffix=""): icon = self.figures["radioOff"] text = "{}: {}".format(self.logger_label("purple", icon, "Pending"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def debug(self, text="", prefix="", suffix=""): icon = self.figures["squareSmallFilled"] text = "{}: {}".format(self.logger_label("dark blue", icon, "Debug"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def info(self, text="", prefix="", suffix=""): icon = self.figures["info"] text = "{}: {}".format(self.logger_label("cyan", icon, "Info"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def pause(self, text="", prefix="", suffix=""): icon = self.figures["pause"] text = "{}: {}".format(self.logger_label("yellow", icon, "Pause"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def complete(self, text="", prefix="", suffix=""): icon = self.figures["radioOn"] text = "{}: {}".format(self.logger_label("very light blue", icon, "Complete"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def like(self, text="", prefix="", suffix=""): icon = self.figures["heart"] text = "{}: {}".format(self.logger_label("pink", icon, "Like"), text) message = self.logger(text=text, prefix=prefix, suffix=suffix) print(message) def center(self, text="", prefix="", suffix=""): rows, cols = os.popen('stty size', 'r').read().split() rows, cols = int(rows), int(cols) text = "-" * 10 + " " + text + " " + "-" * 10 len_text = len(text) message = " " * ((cols - len_text) // 2) + text + " " * ((cols - len_text) // 2) print(message) def scoped(self, scope): opts = self.options if self.scope != None: if isinstance(self.scope, list): opts["scope"] = opts["scope"].append(scope) return Signale(opts) else: opts["scope"] = [self.scope, scope] return Signale(opts) return Signale() else: opts["scope"] = scope return Signale(opts) return Signale() # s = Signale({ # "underlined": False # }) # s.center("Testing Logger") # s.simple("ABC", prefix="Debugger", suffix="xyz") # s.info("Starting", prefix="Debugger") # s.success("Started Successfully", prefix="Debugger", suffix="xyz") # s.watch("Watching All Files", prefix="Debugger") # s.error("Something Went Wrong", prefix="Debugger") # s.warning("Deprecation Warning", prefix="Debugger") # s.pending("Postponed", prefix="Debugger") # s.debug("Found A Bug on L55", prefix="Debugger") # s.start("Started New Process", prefix="Debugger") # s.pause("Process Paused", prefix="Debugger") # s.complete("Task Completed", prefix="Debugger") # s.important("New Update Available. Please Update!", prefix="Debugger") # s.like("I Love Signale", prefix="Debugger") # s.stop("Stopping", prefix="Debugger") # print("\n") # logger = Signale({ # "scope": "" # }) # logger.success("Started Successfully", prefix="Debugger") # logger.warning("`a` function is deprecated", suffix="main.py") # logger.complete("Run Complete") # print("\n") # logger = Signale({"scope": "custom"}) # logger.success("Started Successfully", prefix="Debugger") # logger.warning("`a` function is deprecated", suffix="main.py") # logger.complete("Run Complete") # logger = Signale({ # "scope": "global scope", # "custom": [ # { # "badge": "!", # "label": "Attention", # "color": "red", # "name": "attention" # } # ], # "underlined": True # }) # logger2 = logger.scoped("inner") # logger.attention("It Works!") # logger2.attention("With Logger2")PK!00!signalepy-0.3.2.dist-info/LICENSEMIT License Copyright (c) 2018 Shardul Nalegave Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.PK!HlŃTTsignalepy-0.3.2.dist-info/WHEEL A н#J@Z|Jmqvh&#hڭw!Ѭ"J˫( } %PK!HSr> "signalepy-0.3.2.dist-info/METADATAYs6 }8cQhd)N2h"N&SB$D.>HJr]ݜX.~]-7,c~J YNq\ P-jH4~E0L4LZ^<犾%i Qr:*M!7|Td<΅Y8bTV 9!%.DK ޞ_xs'U'2BqQꄎ  B*Y hF|D1֎ӿ縀ʑP\&yh"~J X "t2xl%oyc=,om++و2k=:U2` nxiFWMٌ$7+ !LRVv'2\Ed0]?۝\NgHS|G Y-UT$AYQUG ΜD3T)=QNDk`?@KmXQ0āvG8<)+SHZ#bB[2&G]g.[Z/[9Ko&) T()&^ Cf)RUв153J(9wLUubi4yj ZqN '#2 zJ+9Cz+zuҍU)`y wRZݩҟJpL@ie]o*6Tz O RF5Յzhot. 'ur0YU]MtDX'+qCtv1Ua8lJѼ߁z9oU FkHvN=Wx;C"ԝz%BI!%|o{v+~ LFNڥӟ3h:8Oϔ8ײoT#(~%+lҵr>//-h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