Skip to content

Commit

Permalink
move common function into __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
schorschii committed Jul 18, 2024
1 parent 08818e1 commit e84db9f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 8 additions & 0 deletions laps-client/laps_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '')
4 changes: 2 additions & 2 deletions laps-client/laps_client/laps_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions laps-client/laps_client/laps_common.py

This file was deleted.

4 changes: 2 additions & 2 deletions laps-client/laps_client/laps_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e84db9f

Please sign in to comment.