From 74a4c3190eb300981d5c578fe3105c7edaf8f122 Mon Sep 17 00:00:00 2001 From: eyeonus Date: Tue, 27 Dec 2022 15:51:12 -0700 Subject: [PATCH] refactor: use raw strings for regex Fixes #107 --- tradedangerous/commands/update_gui.py | 2 +- tradedangerous/gui.py | 5 ++++- tradedangerous/plugins/netlog_plug.py | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tradedangerous/commands/update_gui.py b/tradedangerous/commands/update_gui.py index fd51d8d6..6d838fa2 100644 --- a/tradedangerous/commands/update_gui.py +++ b/tradedangerous/commands/update_gui.py @@ -695,7 +695,7 @@ def getResults(self): supply = "-" elif not supply: supply = "?" - elif re.match('^\d+$', supply): + elif re.match(r"^\d+$", supply): if int(supply) != 0: supply += '?' diff --git a/tradedangerous/gui.py b/tradedangerous/gui.py index 3d695bd5..6d9120fe 100644 --- a/tradedangerous/gui.py +++ b/tradedangerous/gui.py @@ -36,6 +36,7 @@ from __future__ import print_function from __future__ import division from __future__ import unicode_literals +from pkg_resources import resource_filename import os import sys import traceback @@ -47,6 +48,8 @@ import appJar from tkinter import * +import tkinter.font as font +import tkinter.scrolledtext as scrolledtext from tkinter.ttk import * from . import commands @@ -960,7 +963,7 @@ def makeWidgets(name, arg, sticky = 'ew', label = True, **kwargs): buildArgDicts() window.title('Trade Dangerous GUI (Beta), TD v.%s' % (__version__,)) - window.iconbitmap('../tradedangerouscrest.ico') + window.iconbitmap(resource_filename(__name__, "../tradedangerouscrest.ico")) widgets['Command'] = addWidget('combo', window, 3, 0, values = Commands, bind = updateCommandBox, width = 10, state = 'readonly', height = len(Commands), default = Commands[0], columnspan = 4, diff --git a/tradedangerous/plugins/netlog_plug.py b/tradedangerous/plugins/netlog_plug.py index 36465d1f..a125dc41 100644 --- a/tradedangerous/plugins/netlog_plug.py +++ b/tradedangerous/plugins/netlog_plug.py @@ -82,11 +82,11 @@ def parseLogDirList(self): tdb, tdenv = self.tdb, self.tdenv optShow = self.getOption("show") - oldHeadRegEx = re.compile("^(?P\d\d-\d\d-\d\d-\d\d:\d\d)\s+(?P.*[^\s])\s+(?P\(.*GMT\))") - newHeadRegEx = re.compile("^(?P\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)\s+(?P.*[^\s])") + oldHeadRegEx = re.compile(r"^(?P\d\d-\d\d-\d\d-\d\d:\d\d)\s+(?P.*[^\s])\s+(?P\(.*GMT\))") + newHeadRegEx = re.compile(r"^(?P\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)\s+(?P.*[^\s])") - sysRegEx = re.compile('^\{[^\}]+\}\s+System:"(?P[^"]+)".*StarPos:\((?P[^)]+)\)ly') - dateRegEx = re.compile('^\{(?P\d\d:\d\d:\d\d)') + sysRegEx = re.compile(r'^\{[^\}]+\}\s+System:"(?P[^"]+)".*StarPos:\((?P[^)]+)\)ly') + dateRegEx = re.compile(r'^\{(?P\d\d:\d\d:\d\d)') def calcSeconds(h=0, m=0, s=0): return 3600*h + 60*m + s