Reorganize catalog modules
- Move the support modules inside python3-flightgear/flightgear/ and remove their shebang, if any. - Accordingly adapt the import statements. - Change shebangs from e.g. '#! /usr/bin/python' to '#! /usr/bin/env python3'. - Small changes to make Python 3 happy with all scripts. catalog/check_aircraft.py should be run under Python 3 from now on.
This commit is contained in:
+19
-16
@@ -1,8 +1,10 @@
|
||||
#!/usr/bin/python
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sgprops
|
||||
|
||||
from flightgear.meta import sgprops
|
||||
|
||||
|
||||
def check_meta_data(aircraft_dir, set_file, includes):
|
||||
base_file = os.path.basename(set_file)
|
||||
@@ -13,44 +15,46 @@ def check_meta_data(aircraft_dir, set_file, includes):
|
||||
root_node = sgprops.readProps(set_path, includePaths = includes)
|
||||
|
||||
if not root_node.hasChild("sim"):
|
||||
print "-set.xml has no <sim> node:", set_path
|
||||
print("-set.xml has no <sim> node:", set_path)
|
||||
return
|
||||
|
||||
sim_node = root_node.getChild("sim")
|
||||
if not sim_node.hasChild('description'):
|
||||
print "-set.xml missing <description>:", set_path
|
||||
print("-set.xml missing <description>:", set_path)
|
||||
|
||||
if not sim_node.hasChild('long-description'):
|
||||
print "-set.xml missing <long-description>:", set_path
|
||||
print("-set.xml missing <long-description>:", set_path)
|
||||
|
||||
if not sim_node.hasChild('authors'):
|
||||
print "-set.xml is missing structured <authors> data:", set_path
|
||||
print("-set.xml is missing structured <authors> data:", set_path)
|
||||
|
||||
if not sim_node.hasChild('tags'):
|
||||
print "-set.xml does not define any tags", set_path
|
||||
print("-set.xml does not define any tags", set_path)
|
||||
|
||||
# check for non-standard tags
|
||||
|
||||
if not sim_node.hasChild('thumbnail'):
|
||||
print "-set.xml does not define a thumbnail", set_path
|
||||
print("-set.xml does not define a thumbnail", set_path)
|
||||
|
||||
# check thumbnail size and format
|
||||
|
||||
if not sim_node.hasChild('rating'):
|
||||
print "-set.xml does not define any ratings", set_path
|
||||
print("-set.xml does not define any ratings", set_path)
|
||||
|
||||
if not sim_node.hasChild('minimum-fg-version'):
|
||||
print "-set.xml does not define a minimum FG version", set_path
|
||||
print("-set.xml does not define a minimum FG version", set_path)
|
||||
|
||||
# check all the -set.xml files in an aircraft directory.
|
||||
|
||||
# check all the -set.xml files in an aircraft directory.
|
||||
def check_aircraft_dir(d, includes):
|
||||
if not os.path.isdir(d):
|
||||
return
|
||||
|
||||
files = os.listdir(d)
|
||||
for file in sorted(files, key=lambda s: s.lower()):
|
||||
if file.endswith('-set.xml'):
|
||||
check_meta_data(d, file, includes)
|
||||
for f in sorted(files, key=lambda s: s.lower()):
|
||||
if f.endswith('-set.xml'):
|
||||
check_meta_data(d, f, includes)
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--include", help="Include directory to validate -set.xml parsing",
|
||||
@@ -60,7 +64,7 @@ args = parser.parse_args()
|
||||
|
||||
for d in args.dir:
|
||||
if not os.path.isdir(d):
|
||||
print "Skipping missing directory:", d
|
||||
print("Skipping missing directory:", d)
|
||||
|
||||
names = os.listdir(d)
|
||||
for name in sorted(names, key=lambda s: s.lower()):
|
||||
@@ -70,4 +74,3 @@ for d in args.dir:
|
||||
|
||||
acftDir = os.path.join(d, name)
|
||||
check_aircraft_dir(acftDir, args.include)
|
||||
|
||||
Reference in New Issue
Block a user