mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-23 12:20:30 +03:00
[Minor] Simplify if-else statements
This commit is contained in:
parent
336c627c07
commit
4c334835f2
@ -258,10 +258,7 @@ def get_plugin_logger(plugin_name: str, loglevel: int = _default_loglevel) -> 'L
|
||||
:param loglevel: Optional logLevel for this Logger.
|
||||
:return: logging.Logger instance, all set up.
|
||||
"""
|
||||
if not os.getenv('EDMC_NO_UI'):
|
||||
base_logger_name = appname
|
||||
else:
|
||||
base_logger_name = appcmdname
|
||||
base_logger_name = appcmdname if os.getenv('EDMC_NO_UI') else appname
|
||||
|
||||
plugin_logger = logging.getLogger(f'{base_logger_name}.{plugin_name}')
|
||||
plugin_logger.setLevel(loglevel)
|
||||
@ -537,10 +534,7 @@ loglevel: str | int = config.get_str('loglevel')
|
||||
if not loglevel:
|
||||
loglevel = logging.INFO
|
||||
|
||||
if not os.getenv('EDMC_NO_UI'):
|
||||
base_logger_name = appname
|
||||
else:
|
||||
base_logger_name = appcmdname
|
||||
base_logger_name = appcmdname if os.getenv('EDMC_NO_UI') else appname
|
||||
|
||||
edmclogger = Logger(base_logger_name, loglevel=loglevel)
|
||||
logger: 'LoggerMixin' = edmclogger.get_logger()
|
||||
|
@ -748,10 +748,7 @@ class AppWindow:
|
||||
self.toggle_suit_row(visible=False)
|
||||
if args.start_min:
|
||||
logger.warning("Trying to start minimized")
|
||||
if root.overrideredirect():
|
||||
self.oniconify()
|
||||
else:
|
||||
self.w.wm_iconify()
|
||||
self.oniconify() if root.overrideredirect() else self.w.wm_iconify()
|
||||
|
||||
def update_suit_text(self) -> None:
|
||||
"""Update the suit text for current type and loadout."""
|
||||
|
18
collate.py
18
collate.py
@ -234,20 +234,8 @@ if __name__ == "__main__":
|
||||
print('No starport!')
|
||||
continue
|
||||
|
||||
if data['lastStarport'].get('commodities'):
|
||||
addcommodities(data)
|
||||
addcommodities(data) if data['lastStarport'].get('commodities') else print('No market')
|
||||
|
||||
else:
|
||||
print('No market')
|
||||
addmodules(data) if data['lastStarport'].get('modules') else print('No outfitting')
|
||||
|
||||
if data['lastStarport'].get('modules'):
|
||||
addmodules(data)
|
||||
|
||||
else:
|
||||
print('No outfitting')
|
||||
|
||||
if data['lastStarport'].get('ships'):
|
||||
addships(data)
|
||||
|
||||
else:
|
||||
print('No shipyard')
|
||||
addships(data) if data['lastStarport'].get('ships') else print('No shipyard')
|
||||
|
17
companion.py
17
companion.py
@ -110,11 +110,8 @@ class CAPIData(UserDict):
|
||||
logger.debug('modules was None. FC or Damaged Station?')
|
||||
|
||||
elif isinstance(modules, list):
|
||||
if not modules:
|
||||
logger.debug('modules is empty list. Damaged Station?')
|
||||
|
||||
else:
|
||||
logger.error(f'modules is non-empty list: {modules!r}')
|
||||
logger.debug('modules is empty list. Damaged Station?') if not modules \
|
||||
else logger.error(f'modules is non-empty list: {modules!r}')
|
||||
|
||||
else:
|
||||
logger.error(f'modules was not None, a list, or a dict! type: {type(modules)}, content: {modules}')
|
||||
@ -543,11 +540,11 @@ class Auth:
|
||||
# noinspection PyMethodMayBeStatic
|
||||
def dump(self, r: requests.Response) -> None:
|
||||
"""Dump details of HTTP failure from oAuth attempt."""
|
||||
if r:
|
||||
logger.debug(f'Frontier CAPI Auth: {r.url} {r.status_code} {r.reason if r.reason else "None"} {r.text}')
|
||||
|
||||
else:
|
||||
logger.debug(f'Frontier CAPI Auth: failed with `r` False: {r!r}')
|
||||
logger.debug(
|
||||
f'Frontier CAPI Auth: {r.url} {r.status_code} {r.reason or "None"} {r.text}'
|
||||
if r else
|
||||
f'Frontier CAPI Auth: failed with `r` False: {r!r}'
|
||||
)
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
def base64_url_encode(self, text: bytes) -> str:
|
||||
|
6
plug.py
6
plug.py
@ -414,11 +414,7 @@ def notify_capidata(data: companion.CAPIData, is_beta: bool) -> str | None:
|
||||
error = None
|
||||
for plugin in PLUGINS:
|
||||
# TODO: Handle it being Legacy data
|
||||
if data.source_host == companion.SERVER_LEGACY:
|
||||
cmdr_data = plugin._get_func('cmdr_data_legacy')
|
||||
|
||||
else:
|
||||
cmdr_data = plugin._get_func('cmdr_data')
|
||||
cmdr_data = plugin._get_func('cmdr_data_legacy' if data.source_host == companion.SERVER_LEGACY else 'cmdr_data')
|
||||
|
||||
if cmdr_data:
|
||||
try:
|
||||
|
8
prefs.py
8
prefs.py
@ -965,11 +965,9 @@ class PreferencesDialog(tk.Toplevel):
|
||||
).grid(padx=self.PADX, pady=self.PADY, sticky=tk.W, row=row.get())
|
||||
|
||||
for plugin in enabled_plugins:
|
||||
if plugin.name == plugin.folder:
|
||||
label = nb.Label(plugins_frame, text=plugin.name)
|
||||
|
||||
else:
|
||||
label = nb.Label(plugins_frame, text=f'{plugin.folder} ({plugin.name})')
|
||||
label = nb.Label(plugins_frame,
|
||||
text=plugin.name if plugin.name == plugin.folder
|
||||
else f'{plugin.folder} ({plugin.name})')
|
||||
|
||||
label.grid(columnspan=2, padx=self.LISTX, pady=self.PADY, sticky=tk.W, row=row.get())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user