Skip to content

Commit ff5c3c1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0e1083a commit ff5c3c1

File tree

8 files changed

+1697
-1692
lines changed

8 files changed

+1697
-1692
lines changed

Slovenia3.cup

Lines changed: 825 additions & 825 deletions
Large diffs are not rendered by default.

Slovenia3.dat

Lines changed: 824 additions & 824 deletions
Large diffs are not rendered by default.

lib/xcsoar/mapgen/server/server.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
from xcsoar.mapgen.georect import GeoRect
1313
from xcsoar.mapgen.waypoints.parser import parse_waypoint_file
1414

15-
cherrypy.config.update({
16-
'log.screen': True, # Log to stdout
17-
'log.error_file': 'error.log', # Log errors to a file
18-
'log.access_file': 'access.log' # Log access to a file
19-
})
15+
cherrypy.config.update(
16+
{
17+
"log.screen": True, # Log to stdout
18+
"log.error_file": "error.log", # Log errors to a file
19+
"log.access_file": "access.log", # Log access to a file
20+
}
21+
)
22+
2023

2124
class Server(object):
2225
def __init__(self, dir_jobs):
@@ -85,13 +88,12 @@ def index(self, **params):
8588
# cherrypy.log('waypoint_file = %s, waypoint_filename = %s, selection = %s' % (waypoint_file.file, waypoint_file.filename, selection))
8689
# cherrypy.log('waypoint_file = %s' % waypoint_file.file)
8790

88-
#gfp added to determine 'waypoint_file' type
91+
# gfp added to determine 'waypoint_file' type
8992
# cherrypy.log('displaying lines from waypoint_file.file')
9093
# lines = waypoint_file.file.readlines()
9194
# for line in lines:
9295
# cherrypy.log(line)
9396

94-
9597
if selection in ["waypoint", "waypoint_bounds"]:
9698
if not waypoint_file.file or not waypoint_file.filename:
9799
return view.render(error="No waypoint file uploaded.") | HTMLFormFiller(
@@ -109,7 +111,7 @@ def index(self, **params):
109111
waypoint_file.filename
110112
)
111113
)
112-
114+
113115
# #241212 better way to write this boolean expression (filename already forced to lowercase)
114116
if not filename.endswith(".dat") and not filename.endswith(".cup"):
115117
raise RuntimeError(
@@ -125,8 +127,12 @@ def index(self, **params):
125127
"waypoints.cup" if filename.endswith(".cup") else "waypoints.dat"
126128
)
127129

128-
cherrypy.log(f'in server.py: {filename} bounds: left = {desc.bounds.left:.3f}, right: {desc.bounds.right:.3f}, top: {desc.bounds.top:.3f}, bot {desc.bounds.bottom:.3f}')
129-
return view.render(error=f"left: {desc.bounds.left:.3f}, right: {desc.bounds.right:.3f}, top: {desc.bounds.top:.3f}, bot {desc.bounds.bottom:.3f}")| HTMLFormFiller(data=params)
130+
cherrypy.log(
131+
f"in server.py: {filename} bounds: left = {desc.bounds.left:.3f}, right: {desc.bounds.right:.3f}, top: {desc.bounds.top:.3f}, bot {desc.bounds.bottom:.3f}"
132+
)
133+
return view.render(
134+
error=f"left: {desc.bounds.left:.3f}, right: {desc.bounds.right:.3f}, top: {desc.bounds.top:.3f}, bot {desc.bounds.bottom:.3f}"
135+
) | HTMLFormFiller(data=params)
130136

131137
except:
132138
return view.render(
@@ -198,5 +204,3 @@ def download(self, uuid):
198204
return cherrypy.lib.static.serve_download(
199205
job.map_file(), job.description.name + ".xcm"
200206
)
201-
202-

lib/xcsoar/mapgen/server/view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def render(*args, **kwargs):
4242
template = loader.load(args[0])
4343
else:
4444
template = cherrypy.thread_data.template
45-
45+
4646
ctxt = Context(url=cherrypy.url)
4747
ctxt.push(kwargs)
4848
return template.generate(ctxt)

lib/xcsoar/mapgen/waypoints/list.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from xcsoar.mapgen.georect import GeoRect
44
import cherrypy
55

6+
67
class WaypointList:
78
def __init__(self):
89
self.__list = []

lib/xcsoar/mapgen/waypoints/parser.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33
from xcsoar.mapgen.waypoints.winpilot_reader import parse_winpilot_waypoints
44
import cherrypy
55

6-
#cherrypy.log(data.decode('utf-8'))
6+
# cherrypy.log(data.decode('utf-8'))
7+
78

89
def parse_waypoint_file(filename, file=None):
910
# cherrypy.log('in parse_waypoint_file: filename = %s' % filename)
10-
lines = 0 #gfp added so 'lines' object stays in scope
11+
lines = 0 # gfp added so 'lines' object stays in scope
1112
if not file:
12-
cherrypy.log('in parse_waypoint_file: if not file block with filename = %s' % filename)
13+
cherrypy.log(
14+
"in parse_waypoint_file: if not file block with filename = %s" % filename
15+
)
1316

1417
else:
15-
# # #241207 gfp bugfix: parser fcns need 'lines' (list of lines) vs 'file'
18+
# # #241207 gfp bugfix: parser fcns need 'lines' (list of lines) vs 'file'
1619
lines = file.readlines()
1720

1821
# cherrypy.log('in parse_waypoint_file: %s lines read from %s' %(lines.count, filename))
19-
cherrypy.log('in parse_waypoint_file: %s lines read from %s' %(len(lines), filename))
22+
cherrypy.log(
23+
"in parse_waypoint_file: %s lines read from %s" % (len(lines), filename)
24+
)
2025
# wpnum = 0
2126
# for line in lines:
2227
# wpnum+=1
@@ -27,7 +32,7 @@ def parse_waypoint_file(filename, file=None):
2732
return parse_winpilot_waypoints(lines)
2833
elif filename.lower().endswith(".cup"):
2934
# cherrypy.log('in parse_waypoint_file filename.lower().endswith(".cup"): filename = %s' % filename)
30-
return parse_seeyou_waypoints(lines)#241207 gfp bugfix:
35+
return parse_seeyou_waypoints(lines) # 241207 gfp bugfix:
3136
else:
3237
raise RuntimeError(
3338
"Waypoint file {} has an unsupported format.".format(filename)

lib/xcsoar/mapgen/waypoints/seeyou_reader.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import cherrypy
55

66

7-
87
class __CSVLine:
98
def __init__(self, line):
109
self.__line = line
@@ -80,33 +79,35 @@ def parse_seeyou_waypoints(lines, bounds=None):
8079
waypoint_list = WaypointList()
8180
# cherrypy.log('in parse_seeyou_waypoints function:')
8281

83-
#gfp 241210: modified to wait for header line before processing
84-
#gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
82+
# gfp 241210: modified to wait for header line before processing
83+
# gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
8584

86-
#gfp 241208 added to print out all lines in selected .CUP file
85+
# gfp 241208 added to print out all lines in selected .CUP file
8786
# wpnum = 0
8887
# for byteline in lines:
8988
# wpnum = wpnum + 1
9089
# line = byteline.decode('ISO-8859-2')
9190

92-
header = 'name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc'
91+
header = "name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc"
9392

9493
wpnum = 0
9594
for byteline in lines:
9695
wpnum = wpnum + 1
97-
line = byteline.decode('ISO-8859-2') #gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
96+
line = byteline.decode(
97+
"ISO-8859-2"
98+
) # gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
9899
line = line.strip()
99100

100101
# cherrypy.log('in for loop: wpnum = %s line = %s' %(wpnum, line))
101-
# cherrypy.log(f'for loop row {wpnum}: {line}')
102+
# cherrypy.log(f'for loop row {wpnum}: {line}')
102103

103-
#check for blank lines or comments
104+
# check for blank lines or comments
104105
if line == "" or line.startswith("*"):
105106
continue
106107

107-
if header in line:
108+
if header in line:
108109
# cherrypy.log(f'header line found at row {wpnum}: {line}')
109-
continue #skip to next line (first waypoint line)
110+
continue # skip to next line (first waypoint line)
110111

111112
if line == "-----Related Tasks-----":
112113
break
@@ -120,15 +121,13 @@ def parse_seeyou_waypoints(lines, bounds=None):
120121
while CSVline.has_next():
121122
fields.append(next(CSVline))
122123

123-
124-
#display fields for this line
124+
# display fields for this line
125125
# cherrypy.log('extracted fields for line = %s' %wpnum)
126126
# idx = 0
127127
# for field in fields:
128128
# cherrypy.log(f' field[{idx}] = {field}')
129129
# idx += 1
130130

131-
132131
if len(fields) < 6:
133132
continue
134133

@@ -149,7 +148,6 @@ def parse_seeyou_waypoints(lines, bounds=None):
149148

150149
# cherrypy.log('waypoint %s: name = %s' %(wpnum, wp.name))
151150

152-
153151
if len(fields) > 6 and len(fields[6]) > 0:
154152
wp.cup_type = int(fields[6])
155153

@@ -167,13 +165,11 @@ def parse_seeyou_waypoints(lines, bounds=None):
167165

168166
# cherrypy.log(f'waypoint {wpnum}: {wp.name}, {wp.lat:.3f}, {wp.lon:.3f}')
169167

170-
#gfp print out current 'bounds' params
168+
# gfp print out current 'bounds' params
171169
# cherrypy.log(f'bounds = {bounds}')
172-
170+
173171
waypoint_list.append(wp)
174-
175172

176173
return waypoint_list
177-
178174

179175
return waypoint_list

lib/xcsoar/mapgen/waypoints/winpilot_reader.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from xcsoar.mapgen.waypoints.list import WaypointList
44
import cherrypy
55

6+
67
def __parse_altitude(str):
78
# cherrypy.log(f'parse_altitude({str})')
89
str = str.lower()
@@ -20,7 +21,7 @@ def __parse_altitude(str):
2021
return int(int_alt)
2122

2223

23-
#Winpilot .DAT file lat/lon formats
24+
# Winpilot .DAT file lat/lon formats
2425
# Latitude, Longitude: in one of the following formats (ss=seconds, dd = decimals):
2526
# dd:mm:ss (for example: 36:15:20N)
2627
# dd:mm.d (for example: 36:15.3N)
@@ -69,7 +70,9 @@ def parse_winpilot_waypoints(lines):
6970
wpnum += 1
7071
# cherrypy.log(f'winpilot line {wpnum}: {byteline}')
7172

72-
line = byteline.decode('ISO-8859-2') #gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
73+
line = byteline.decode(
74+
"ISO-8859-2"
75+
) # gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
7376
line = line.strip()
7477
if line == "" or line.startswith("*"):
7578
continue
@@ -81,8 +84,6 @@ def parse_winpilot_waypoints(lines):
8184
if len(fields) < 6:
8285
continue
8386

84-
85-
8687
# fieldnum = 0
8788
# for field in fields:
8889
# cherrypy.log(f'field {fieldnum} = {field}')
@@ -98,6 +99,4 @@ def parse_winpilot_waypoints(lines):
9899

99100
waypoint_list.append(wp)
100101

101-
102-
103102
return waypoint_list

0 commit comments

Comments
 (0)