From e84db9f85353bc5bce882ddb5bfb6bded61c0b28 Mon Sep 17 00:00:00 2001 From: Georg Sieber Date: Thu, 18 Jul 2024 10:54:52 +0200 Subject: [PATCH] move common function into __init__ --- laps-client/laps_client/__init__.py | 8 ++++++++ laps-client/laps_client/laps_cli.py | 4 ++-- laps-client/laps_client/laps_common.py | 8 -------- laps-client/laps_client/laps_gui.py | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 laps-client/laps_client/laps_common.py diff --git a/laps-client/laps_client/__init__.py b/laps-client/laps_client/__init__.py index a228b7b..e865d0b 100644 --- a/laps-client/laps_client/__init__.py +++ b/laps-client/laps_client/__init__.py @@ -6,3 +6,11 @@ __website__ = 'https://github.com/schorschii/LAPS4LINUX' __all__ = [__author__, __license__, __version__] + + + +import getpass + + +def proposeUsername(domain): + return getpass.getuser() + ('@'+domain if domain else '') diff --git a/laps-client/laps_client/laps_cli.py b/laps-client/laps_client/laps_cli.py index c2493f7..b1c73e7 100755 --- a/laps-client/laps_client/laps_cli.py +++ b/laps-client/laps_client/laps_cli.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from .__init__ import __title__, __version__, __website__, __author__, __copyright__ +from .__init__ import proposeUsername from .filetime import dt_to_filetime, filetime_to_dt -from . import laps_common from pathlib import Path from os import path, makedirs, rename @@ -332,7 +332,7 @@ def checkCredentialsAndConnect(self): # ask for username and password for SIMPLE bind if self.cfgUsername == '': - defaultUsername = laps_common.proposeUsername(self.cfgDomain) + defaultUsername = proposeUsername(self.cfgDomain) item = input('👤 Username ['+defaultUsername+']: ') or defaultUsername if item and item.strip() != '': self.cfgUsername = item diff --git a/laps-client/laps_client/laps_common.py b/laps-client/laps_client/laps_common.py deleted file mode 100644 index a064a8f..0000000 --- a/laps-client/laps_client/laps_common.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import getpass - - -def proposeUsername(domain): - return getpass.getuser() + ('@'+domain if domain else '') diff --git a/laps-client/laps_client/laps_gui.py b/laps-client/laps_client/laps_gui.py index ef6118a..67da955 100755 --- a/laps-client/laps_client/laps_gui.py +++ b/laps-client/laps_client/laps_gui.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from .__init__ import __title__, __version__, __website__, __author__, __copyright__ +from .__init__ import proposeUsername from .filetime import dt_to_filetime, filetime_to_dt -from . import laps_common from PyQt5.QtWidgets import * from PyQt5.QtGui import * @@ -722,7 +722,7 @@ def checkCredentialsAndConnect(self): '👤 Username', 'Please enter the username which should be used to connect to:\n'+str(self.cfgServer), QLineEdit.Normal, - laps_common.proposeUsername(self.cfgDomain) + proposeUsername(self.cfgDomain) ) if ok and item: self.cfgUsername = item