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:
parent
d259ec0b76
commit
1c2d17d869
9 changed files with 48 additions and 33 deletions
|
@ -22,6 +22,9 @@ The script can be run directly from this directory, or the script and its
|
|||
modules can be copied together and run from any location. The steps to use
|
||||
these are:
|
||||
|
||||
* Have something like `export PYTHONPATH="/path/to/fgmeta/python3-flightgear"`
|
||||
in your shell setup or use a .pth file (see `python3-flightgear/README.md`
|
||||
for more details).
|
||||
* Create an output directory where the catalog and zip files will be located.
|
||||
* Copy the configuration files `catalog.config.xml`, `template.xml`, and
|
||||
`zip-excludes.lst` from one of the `*catalog*` example directories into the
|
||||
|
|
|
@ -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)
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import unittest
|
||||
import sgprops
|
||||
import os
|
||||
from os.path import join
|
||||
import catalog
|
||||
import lxml.etree as ET
|
||||
from shutil import rmtree
|
||||
from tempfile import mkdtemp
|
||||
import zipfile
|
||||
|
||||
from flightgear.meta import sgprops
|
||||
from flightgear.meta.aircraft_catalogs import catalog
|
||||
|
||||
|
||||
catalog.quiet = True
|
||||
|
||||
|
@ -247,7 +248,7 @@ class ZipTests(unittest.TestCase):
|
|||
"""General checks for the zip file."""
|
||||
|
||||
# Check for file existence.
|
||||
self.assert_(os.access(file_name, os.F_OK))
|
||||
self.assertTrue(os.access(file_name, os.F_OK))
|
||||
|
||||
# Check the contents.
|
||||
file = zipfile.ZipFile(file_name)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
import unittest
|
||||
|
||||
import types
|
||||
import sgprops
|
||||
from flightgear.meta import sgprops
|
||||
|
||||
|
||||
class SGProps(unittest.TestCase):
|
||||
|
||||
|
@ -9,14 +11,14 @@ class SGProps(unittest.TestCase):
|
|||
parsed = sgprops.readProps("testData/props1.xml")
|
||||
|
||||
self.assertEqual(parsed.getValue("value"), 42)
|
||||
self.assertEqual(type(parsed.getValue("value")), types.IntType)
|
||||
self.assertEqual(type(parsed.getValue("value")), int)
|
||||
|
||||
valNode = parsed.getChild("value")
|
||||
self.assertEqual(valNode.parent, parsed)
|
||||
self.assertEqual(valNode.name, "value")
|
||||
|
||||
self.assertEqual(valNode.value, 42)
|
||||
self.assertEqual(type(valNode.value), types.IntType)
|
||||
self.assertEqual(type(valNode.value), int)
|
||||
|
||||
with self.assertRaises(IndexError):
|
||||
missingNode = parsed.getChild("missing")
|
||||
|
|
|
@ -8,12 +8,14 @@ import os
|
|||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
import sgprops
|
||||
import sys
|
||||
import catalogTags
|
||||
import catalog
|
||||
from catalog import make_aircraft_node, make_aircraft_zip, parse_config_file, parse_template_file
|
||||
import time
|
||||
|
||||
from flightgear.meta import sgprops
|
||||
from flightgear.meta.aircraft_catalogs import catalogTags
|
||||
from flightgear.meta.aircraft_catalogs import catalog
|
||||
from flightgear.meta.aircraft_catalogs.catalog import make_aircraft_node, \
|
||||
make_aircraft_zip, parse_config_file, parse_template_file
|
||||
|
||||
|
||||
CATALOG_VERSION = 4
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
|
@ -8,11 +8,12 @@ import os
|
|||
from os.path import exists, join, relpath
|
||||
from os import F_OK, access, walk
|
||||
import re
|
||||
import sgprops
|
||||
import sys
|
||||
import catalogTags
|
||||
import zipfile
|
||||
|
||||
from flightgear.meta import sgprops
|
||||
from . import catalogTags
|
||||
|
||||
CATALOG_VERSION = 4
|
||||
quiet = False
|
||||
verbose = False
|
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
aircraftTypeTags = [
|
||||
"aerobatic",
|
||||
"airship",
|
||||
|
@ -176,7 +178,8 @@ simFeatureTags = [
|
|||
"wildfire"
|
||||
]
|
||||
|
||||
tags = aircraftTypeTags + manufacturerTags + eraTags + simFeatureTags + propulsionTags + featureTags
|
||||
tags = (aircraftTypeTags + manufacturerTags + eraTags + simFeatureTags +
|
||||
propulsionTags + featureTags)
|
||||
|
||||
def isValidTag(maybeTag):
|
||||
return maybeTag in tags
|
Loading…
Reference in a new issue