Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

from Map import Map 

import os 

 

class MapReader(object): 

loaded = False 

file_found = False 

 

def __init__(self): 

""" 

Initialize MapReader class 

""" 

super(MapReader, self).__init__() 

 

def load(self, file_name): 

""" 

Set flags and test if the file given exists. Throws IOError 

on file not existing. 

 

@type file_name: string 

@param file_name: Name of the file that contains definition of  

the map. 

""" 

self.file_name = file_name 

self.loaded = False 

self.file_found = False 

 

if not os.path.exists(self.file_name): 

raise IOError(self.file_name + " not found.") 

else: 

self.file_found = True 

 

def get(self): 

""" 

Read the file and return the string inside 

 

@rtype: string 

@return: string inside of the specified file 

""" 

return open(self.file_name, 'r').read()