Loaded a module :D

This commit is contained in:
Gnarwhal 2024-08-28 16:56:05 +00:00
parent c1a455d7a4
commit 72627995a7
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
2 changed files with 38 additions and 0 deletions

View file

@ -14,6 +14,8 @@
import argparse import argparse
import getpass import getpass
import importlib
import importlib.util
import os import os
import os.path import os.path
import pyclip import pyclip
@ -89,6 +91,17 @@ def rebase(number):
def main(): def main():
module_spec = importlib.util.spec_from_file_location(
"logger_cli",
"/home/gnarwhal/meine/projects/active/sshare/src/sshare/plugins/logger_cli.py"
)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
module.log("test?")
module.warn("test?")
module.error("test?")
arguments = parse_arguments() arguments = parse_arguments()
config = Config() config = Config()

View file

@ -0,0 +1,25 @@
# This file is part of SSHare.
#
# SSHare is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# SSHare is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# SSHare. If not, see <https://www.gnu.org/licenses/>.
def _print_with_color(color, message):
print(f"\033[{color}m{message}\033[0m")
def log(message):
_print_with_color(0, message)
def warn(message):
_print_with_color(93, message)
def error(message):
_print_with_color(91, message)