def init(root_path: Path, show_console: bool = True, console_level: int = logging.INFO, file_level=logging.DEBUG) -> None: LOG_DIR = root_path.joinpath("logs") root = logging.getLogger() logger = logging.getLogger("Painted-Logger") if show_console: c_init(autoreset=True, strip=False) stream_logger = logging.StreamHandler() stream_logger.setLevel(console_level) stream_logger.setFormatter(ColouredFormatter()) root.addHandler(stream_logger) LOG_DIR.mkdir(exist_ok=True) file_logger = logging.FileHandler( filename=LOG_DIR.joinpath(f"{root_path.name}.log"), encoding="UTF-8") file_logger.setLevel(file_level) formatter = logging.Formatter( fmt= "[%(asctime)s] [%(levelname)-8s] {%(name)s:%(filename)s:%(lineno)d} | %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) file_logger.setFormatter(formatter) root.addHandler(file_logger) root.setLevel(logging.NOTSET) logger.log(logging.DEBUG, "DEBUG is Visible") logger.log(logging.INFO, "INFO is Visible") logger.log(logging.WARNING, "WARNING is Visible") logger.log(logging.ERROR, "ERROR is Visible") logger.log(logging.CRITICAL, "CRITICAL is Visible")
def read_config() -> None: """Создаёт файл конфигурации (если нету) и загружает его в память""" c_init() file_exists = False if not exists(Config._dir_name): makedirs(Config._dir_name) first = len(Config._config_dict) == 0 if isfile(Path(Config._dir_name + '/' + Config._config_name)): with open(file=Path(Config._dir_name + '/' + Config._config_name), mode="r", encoding="utf-8") as conf_file: Config._config_dict = load(conf_file) file_exists = True Config._set_up_config(file_exists, first)
#Nombres: Manuel Trigo y Luciano Larama from colorama import init as c_init, Fore as f import numpy as n import math as mt import ply.lex as lex import ply.yacc as yacc import sys import logging c_init(autoreset=True) variables = {} reserved = { #representacion : que palabra reservada representa 'if': 'if', 'print': 'print', 'sum': 'sum', 'begin': 'begin', 'end': 'end', 'matrix': 'matrix', 'scalar': 'scalar', 'then': 'then', } tokens = ( 'string', 'var', 'float', 'plus', 'minus',
def __init__(self): c_init(autoreset=True) return None
import sys import win10toast import argparse import json import pathlib import os from colorama import init as c_init from colorama import Fore, Style c_init() json_path = None data = None def main(): global json_path global data json_path = "\\".join( str(pathlib.Path(__file__).absolute()).split("\\")[:-2]) + "\\db.json" with open(json_path) as json_file: data = json.load(json_file) currentDir = str(pathlib.Path().absolute()) isInitialised = currentDir in [x["dir"] for x in data["projects"]] parser = argparse.ArgumentParser( description= "Pynotes is a terminal based app that lets you add notes to specific projects and directories" ) commands_parser = parser.add_subparsers(help='commands', dest="command")