Minor tweaks & added FILENAME constant for each class
2 files changed, 13 insertions(+), 8 deletions(-)

M common.py
M fixed.py
M common.py +9 -8
@@ 6,10 6,11 @@ import struct
 
 class PlanetsData(object):
     """Base class for all Planets data objects"""
-    COUNT = None # Default number of objects in a data file
-    PACK_LENGTH = None # Length of binary data for single object
-    PACK_FORMAT = None # Format of binary data for single object
-    FIELDS = ()
+    FILENAME = None         # Default filename
+    COUNT = None            # Default number of objects in a data file
+    PACK_LENGTH = None      # Length of binary data for single object
+    PACK_FORMAT = None      # Format of binary data for single object
+    FIELDS = ()             # Fields for single object
 
     def __init__(self):
         for field in self.FIELDS:

          
@@ 60,10 61,10 @@ class PlanetsData(object):
         return result
     
     @classmethod
-    def read(cls, f, count=None, hasCount=False):
+    def read(cls, f, has_count=False, count=None):
         """Reads from file and loads contents in list of object instances"""
         # Data may be preceeded by a WORD indicating how much objects follow
-        if hasCount:
+        if has_count:
             count = struct.unpack('< h', f.read(2))
         # Load "count" objects or predetermined "COUNT" objects or whole file
         if count is not None:

          
@@ 75,9 76,9 @@ class PlanetsData(object):
         return cls.load(data)
     
     @classmethod
-    def open(cls, name, count=None, hasCount=False):
+    def open(cls, name, has_count=False, count=None):
         """Opens file and loads contents in list of object instances"""
         f = open(name,'rb')
-        result = cls.read(f, count, hasCount)
+        result = cls.read(f, has_count, count)
         f.close()
         return result
  No newline at end of file

          
M fixed.py +4 -0
@@ 7,6 7,7 @@ from common import PlanetsData
 
 class BeamSpec(PlanetsData):
     """List of starship beam weapons"""
+    FILENAME = 'BEAMSPEC.DAT'
     COUNT = 10
     PACK_LENGTH = 36
     PACK_FORMAT = '< 20s h h h h h h h h'

          
@@ 22,6 23,7 @@ class BeamSpec(PlanetsData):
     
 class EngSpec(PlanetsData):
     """List of starship engines"""
+    FILENAME = 'ENGSPEC.DAT'
     COUNT = 9
     PACK_LENGTH = 66
     PACK_FORMAT = '< 20s h h h h h i i i i i i i i i'

          
@@ 37,6 39,7 @@ class EngSpec(PlanetsData):
         
 class HullSpec(PlanetsData):
     """List of starship hulls"""
+    FILENAME = 'HULLSPEC.DAT'
     # No COUNT, but typically 105 objects in default HULLSPEC.DAT
     PACK_LENGTH = 60
     PACK_FORMAT = '< 30s h h h h h h h h h h h h h h h'

          
@@ 59,6 62,7 @@ class HullSpec(PlanetsData):
 
 class TorpSpec(PlanetsData):
     """List of starship torpedo weapons"""
+    FILENAME = 'TORPSPEC.DAT'
     COUNT = 10
     PACK_LENGTH = 38
     PACK_FORMAT = '< 20s h h h h h h h h h'