Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 21, 2024
1 parent 0e1083a commit ff5c3c1
Show file tree
Hide file tree
Showing 8 changed files with 1,697 additions and 1,692 deletions.
1,650 changes: 825 additions & 825 deletions Slovenia3.cup

Large diffs are not rendered by default.

1,648 changes: 824 additions & 824 deletions Slovenia3.dat

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions lib/xcsoar/mapgen/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
from xcsoar.mapgen.georect import GeoRect
from xcsoar.mapgen.waypoints.parser import parse_waypoint_file

cherrypy.config.update({
'log.screen': True, # Log to stdout
'log.error_file': 'error.log', # Log errors to a file
'log.access_file': 'access.log' # Log access to a file
})
cherrypy.config.update(
{
"log.screen": True, # Log to stdout
"log.error_file": "error.log", # Log errors to a file
"log.access_file": "access.log", # Log access to a file
}
)


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

#gfp added to determine 'waypoint_file' type
# gfp added to determine 'waypoint_file' type
# cherrypy.log('displaying lines from waypoint_file.file')
# lines = waypoint_file.file.readlines()
# for line in lines:
# cherrypy.log(line)


if selection in ["waypoint", "waypoint_bounds"]:
if not waypoint_file.file or not waypoint_file.filename:
return view.render(error="No waypoint file uploaded.") | HTMLFormFiller(
Expand All @@ -109,7 +111,7 @@ def index(self, **params):
waypoint_file.filename
)
)

# #241212 better way to write this boolean expression (filename already forced to lowercase)
if not filename.endswith(".dat") and not filename.endswith(".cup"):
raise RuntimeError(
Expand All @@ -125,8 +127,12 @@ def index(self, **params):
"waypoints.cup" if filename.endswith(".cup") else "waypoints.dat"
)

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}')
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)
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}"
)
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)

except:
return view.render(
Expand Down Expand Up @@ -198,5 +204,3 @@ def download(self, uuid):
return cherrypy.lib.static.serve_download(
job.map_file(), job.description.name + ".xcm"
)


2 changes: 1 addition & 1 deletion lib/xcsoar/mapgen/server/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def render(*args, **kwargs):
template = loader.load(args[0])
else:
template = cherrypy.thread_data.template

ctxt = Context(url=cherrypy.url)
ctxt.push(kwargs)
return template.generate(ctxt)
1 change: 1 addition & 0 deletions lib/xcsoar/mapgen/waypoints/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from xcsoar.mapgen.georect import GeoRect
import cherrypy


class WaypointList:
def __init__(self):
self.__list = []
Expand Down
17 changes: 11 additions & 6 deletions lib/xcsoar/mapgen/waypoints/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
from xcsoar.mapgen.waypoints.winpilot_reader import parse_winpilot_waypoints
import cherrypy

#cherrypy.log(data.decode('utf-8'))
# cherrypy.log(data.decode('utf-8'))


def parse_waypoint_file(filename, file=None):
# cherrypy.log('in parse_waypoint_file: filename = %s' % filename)
lines = 0 #gfp added so 'lines' object stays in scope
lines = 0 # gfp added so 'lines' object stays in scope
if not file:
cherrypy.log('in parse_waypoint_file: if not file block with filename = %s' % filename)
cherrypy.log(
"in parse_waypoint_file: if not file block with filename = %s" % filename
)

else:
# # #241207 gfp bugfix: parser fcns need 'lines' (list of lines) vs 'file'
# # #241207 gfp bugfix: parser fcns need 'lines' (list of lines) vs 'file'
lines = file.readlines()

# cherrypy.log('in parse_waypoint_file: %s lines read from %s' %(lines.count, filename))
cherrypy.log('in parse_waypoint_file: %s lines read from %s' %(len(lines), filename))
cherrypy.log(
"in parse_waypoint_file: %s lines read from %s" % (len(lines), filename)
)
# wpnum = 0
# for line in lines:
# wpnum+=1
Expand All @@ -27,7 +32,7 @@ def parse_waypoint_file(filename, file=None):
return parse_winpilot_waypoints(lines)
elif filename.lower().endswith(".cup"):
# cherrypy.log('in parse_waypoint_file filename.lower().endswith(".cup"): filename = %s' % filename)
return parse_seeyou_waypoints(lines)#241207 gfp bugfix:
return parse_seeyou_waypoints(lines) # 241207 gfp bugfix:
else:
raise RuntimeError(
"Waypoint file {} has an unsupported format.".format(filename)
Expand Down
32 changes: 14 additions & 18 deletions lib/xcsoar/mapgen/waypoints/seeyou_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import cherrypy



class __CSVLine:
def __init__(self, line):
self.__line = line
Expand Down Expand Up @@ -80,33 +79,35 @@ def parse_seeyou_waypoints(lines, bounds=None):
waypoint_list = WaypointList()
# cherrypy.log('in parse_seeyou_waypoints function:')

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

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

header = 'name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc'
header = "name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc"

wpnum = 0
for byteline in lines:
wpnum = wpnum + 1
line = byteline.decode('ISO-8859-2') #gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
line = byteline.decode(
"ISO-8859-2"
) # gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
line = line.strip()

# cherrypy.log('in for loop: wpnum = %s line = %s' %(wpnum, line))
# cherrypy.log(f'for loop row {wpnum}: {line}')
# cherrypy.log(f'for loop row {wpnum}: {line}')

#check for blank lines or comments
# check for blank lines or comments
if line == "" or line.startswith("*"):
continue

if header in line:
if header in line:
# cherrypy.log(f'header line found at row {wpnum}: {line}')
continue #skip to next line (first waypoint line)
continue # skip to next line (first waypoint line)

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


#display fields for this line
# display fields for this line
# cherrypy.log('extracted fields for line = %s' %wpnum)
# idx = 0
# for field in fields:
# cherrypy.log(f' field[{idx}] = {field}')
# idx += 1


if len(fields) < 6:
continue

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

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


if len(fields) > 6 and len(fields[6]) > 0:
wp.cup_type = int(fields[6])

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

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

#gfp print out current 'bounds' params
# gfp print out current 'bounds' params
# cherrypy.log(f'bounds = {bounds}')

waypoint_list.append(wp)


return waypoint_list


return waypoint_list
11 changes: 5 additions & 6 deletions lib/xcsoar/mapgen/waypoints/winpilot_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from xcsoar.mapgen.waypoints.list import WaypointList
import cherrypy


def __parse_altitude(str):
# cherrypy.log(f'parse_altitude({str})')
str = str.lower()
Expand All @@ -20,7 +21,7 @@ def __parse_altitude(str):
return int(int_alt)


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

line = byteline.decode('ISO-8859-2') #gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
line = byteline.decode(
"ISO-8859-2"
) # gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
line = line.strip()
if line == "" or line.startswith("*"):
continue
Expand All @@ -81,8 +84,6 @@ def parse_winpilot_waypoints(lines):
if len(fields) < 6:
continue



# fieldnum = 0
# for field in fields:
# cherrypy.log(f'field {fieldnum} = {field}')
Expand All @@ -98,6 +99,4 @@ def parse_winpilot_waypoints(lines):

waypoint_list.append(wp)



return waypoint_list

0 comments on commit ff5c3c1

Please sign in to comment.