Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
secondfry committed Oct 2, 2021
1 parent 3195b58 commit b8d58ec
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ confidence=
disable=missing-function-docstring,
missing-module-docstring,
missing-class-docstring,
invalid-name,
C,
R

Expand Down
2 changes: 1 addition & 1 deletion src/db_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def main():
if system_class in [1, 2, 3, 4, 5, 6, 12, 13, 14, 15, 16, 17, 18]:
system_class = "C{}".format(system_class)
else:
if 0.45 <= security:
if security >= 0.45:
system_class = "HS"
elif 0 <= security < 0.45:
system_class = "LS"
Expand Down
22 changes: 6 additions & 16 deletions src/shortcircuit/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def migrate_settings_tripwire(self):
self.settings.remove('MainWindow/tripwire_user')
self.settings.remove('MainWindow/tripwire_pass')
self.settings.remove('MainWindow/evescout_enable')

def read_settings_tripwire(self):
self.global_proxy = self.settings.value('proxy')
self.settings.beginGroup('Tripwire')
Expand Down Expand Up @@ -234,9 +234,7 @@ def read_settings(self):
self.tableWidget_path.setColumnWidth(col_idx, int(column_width))

# Avoidance list
self.checkBox_avoid_enabled.setChecked(
True if self.settings.value("avoidance_enabled", "false") == "true" else False
)
self.checkBox_avoid_enabled.setChecked(self.settings.value("avoidance_enabled", "false") == "true")
for sys_name in self.settings.value("avoidance_list", "").split(','):
if sys_name != "":
self._avoid_system_name(sys_name)
Expand All @@ -245,23 +243,15 @@ def read_settings(self):
self.comboBox_size.setCurrentIndex(
int(self.settings.value("restrictions_whsize", "0"))
)
self.checkBox_eol.setChecked(
True if self.settings.value("restriction_eol", "false") == "true" else False
)
self.checkBox_masscrit.setChecked(
True if self.settings.value("restriction_masscrit", "false") == "true" else False
)
self.checkBox_ignore_old.setChecked(
True if self.settings.value("restriction_ignore_old", "false") == "true" else False
)
self.checkBox_eol.setChecked(self.settings.value("restriction_eol", "false") == "true")
self.checkBox_masscrit.setChecked(self.settings.value("restriction_masscrit", "false") == "true")
self.checkBox_ignore_old.setChecked(self.settings.value("restriction_ignore_old", "false") == "true")
self.doubleSpinBox_hours.setValue(
float(self.settings.value("restriction_hours", "16.0"))
)

# Security prioritization
self.checkBox_security_enabled.setChecked(
True if self.settings.value("security_enabled", "false") == "true" else False
)
self.checkBox_security_enabled.setChecked(self.settings.value("security_enabled", "false") == "true")
self.spinBox_prio_hs.setValue(int(self.settings.value("prio_hs", "1")))
self.spinBox_prio_ls.setValue(int(self.settings.value("prio_ls", "1")))
self.spinBox_prio_ns.setValue(int(self.settings.value("prio_ns", "1")))
Expand Down
11 changes: 9 additions & 2 deletions src/shortcircuit/model/esi/esi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class ESI:
ENDPOINT_ESI_UNIVERSE_NAMES = 'https://esi.evetech.net/latest/universe/names/'
ENDPOINT_ESI_UI_WAYPOINT = 'https://esi.evetech.net/latest/ui/autopilot/waypoint/'

ENDPOINT_EVE_AUTH_FORMAT = 'https://login.eveonline.com/oauth/authorize?response_type=token&redirect_uri={}&client_id={}&scope={}&state={}'
ENDPOINT_EVE_AUTH_FORMAT = 'https://login.eveonline.com/oauth/authorize' \
'?response_type=token&redirect_uri={}&client_id={}&scope={}&state={}'
CLIENT_CALLBACK = 'http://127.0.0.1:7444/callback/'
CLIENT_ID = 'd802bba44b7c4f6cbfa2944b0e5ea83f'
CLIENT_SCOPES = [
Expand Down Expand Up @@ -132,7 +133,13 @@ def set_char_destination(self, sys_id):
return False

success = False
r = requests.post('{}?add_to_beginning=false&clear_other_waypoints=true&destination_id={}'.format(ESI.ENDPOINT_ESI_UI_WAYPOINT, sys_id), headers=self._get_headers())
r = requests.post(
'{}?add_to_beginning=false&clear_other_waypoints=true&destination_id={}'.format(
ESI.ENDPOINT_ESI_UI_WAYPOINT,
sys_id
),
headers=self._get_headers()
)
if r.status_code == 204:
success = True

Expand Down
2 changes: 1 addition & 1 deletion src/shortcircuit/model/esi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def do_GET(self):
self.wfile.write(HTML.encode())
self.server.callback(parts)

def log_message(self, format, *args):
def log_message(self, fmt, *args):
return


Expand Down
6 changes: 3 additions & 3 deletions src/shortcircuit/model/evedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def resource_path(relative_path):


def get_dict_from_csv_qfile(file_path: str):
path = resource_path(file_path)
Logger.info(path)
f = open(path, 'r', encoding='utf-8')
result_path = resource_path(file_path)
Logger.info(result_path)
f = open(result_path, 'r', encoding='utf-8')
reader = csv.reader(f, delimiter=';')

return reader
Expand Down
11 changes: 9 additions & 2 deletions src/shortcircuit/model/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,14 @@ def route(
source: str,
destination: str
):
[size_restriction, ignore_eol, ignore_masscrit, age_threshold, security_prio, avoidance_list] = self.app_obj.get_restrictions()
[
size_restriction,
ignore_eol,
ignore_masscrit,
age_threshold,
security_prio,
avoidance_list
] = self.app_obj.get_restrictions()

source_id = self.eve_db.name2id(source)
dest_id = self.eve_db.name2id(destination)
Expand Down Expand Up @@ -154,7 +161,7 @@ def route(
route_step['path_data'] = weight
route.append(route_step)

if not len(route):
if route:
return [[], 'Path is not found']

# Construct short format
Expand Down
4 changes: 2 additions & 2 deletions src/shortcircuit/model/solarmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def shortest_path(
return [source]

queue = collections.deque()
visited = set([self.get_system(x) for x in avoidance_list])
visited = {self.get_system(x) for x in avoidance_list}
parent = {}

# starting point
Expand Down Expand Up @@ -195,7 +195,7 @@ def shortest_path_weighted(
return [source]

priority_queue = []
visited = set([self.get_system(x) for x in avoidance_list])
visited = {self.get_system(x) for x in avoidance_list}
distance = {}
parent = {}

Expand Down
3 changes: 1 addition & 2 deletions src/shortcircuit/model/tripwire.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def augment_map(self, solar_map: SolarMap):
connections = 0

# Process wormholes
for wormholeId, wormhole in self.chain['wormholes'].items():
for _, wormhole in self.chain['wormholes'].items():
try:
if wormhole['type'] == 'GATE':
continue
Expand Down Expand Up @@ -213,7 +213,6 @@ def augment_map(self, solar_map: SolarMap):
)
except Exception as e:
Logger.error('pepega', exc_info=e)
pass

return connections

Expand Down
3 changes: 0 additions & 3 deletions src/shortcircuit/model/versioncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class VersionCheck(QtCore.QObject):

finished = QtCore.Signal(str)

def __init__(self, parent=None):
super().__init__(parent)

def process(self):
"""
Emits latest version string
Expand Down

0 comments on commit b8d58ec

Please sign in to comment.