@@ 12,7 12,7 @@ class InvalidResultFile(Exception):
def read(f, filesize):
"""Reads from file and parses RST data"""
result = {}
- pointers = get_sections(f, filesize)
+ pointers = _get_sections(f, filesize)
# Read standard sections (should always exist, even if 0 items in section)
f.seek(pointers['ships'])
result['ships'] = Ship.read(f, has_count=True)
@@ 22,7 22,7 @@ def read(f, filesize):
result['bases'] = Base.read(f, has_count=True)
return result
-def valid_pointer(pointer, filesize, datasize):
+def _valid_pointer(pointer, filesize, datasize):
"""Checks if pointer seek location is valid (smaller than filesize)"""
if not filesize:
raise InvalidResultFile('RST file size zero or not defined')
@@ 32,7 32,7 @@ def valid_pointer(pointer, filesize, dat
return True
return False
-def get_sections(f, filesize):
+def _get_sections(f, filesize):
"""Get pointers for various sections of the RST file"""
result = {}
f.seek(0) # Reset position
@@ 48,14 48,14 @@ def get_sections(f, filesize):
for key, pointer in result.items():
result[key] = int(pointer) - 1
# Check RST version: is WinPlan data present?
- (result['winplan'], result['extratargets'],) = get_version(f, filesize)
+ (result['winplan'], result['extratargets'],) = _get_version(f, filesize)
# Check if pointers are valid
for pointer in result.values():
- if pointer is not None and not valid_pointer(pointer, filesize, 2):
+ if pointer is not None and not _valid_pointer(pointer, filesize, 2):
raise InvalidResultFile('One or more pointers is invalid')
return result
-def get_version(f, filesize):
+def _get_version(f, filesize):
"""Analyses RST file to determine if it is DOS-style or WinPlan-style"""
SIGNATURE = 'VER3.5'
VERSIONS = ('00', '01',)
@@ 68,7 68,7 @@ def get_version(f, filesize):
# Fix BASIC style pointer
pointer = int(pointer) - 1
# Check if location of WinPlan data (and TARGETSIG) exists in file
- if not valid_pointer(pointer, filesize, 13282+4):
+ if not _valid_pointer(pointer, filesize, 13282+4):
return None, None
# Check second signature (TARGETSIG) at location +13282 of WinPlan data
f.seek(pointer + 13282)