Changeset 54:2c1b85b6f457


Ignore:
Timestamp:
Sep 1, 2013, 4:46:05 PM (7 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Message:

Add .get_file() to resources.

Location:
nagslang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/level.py

    r53 r54  
    3434                print 'Expected: %d, got %d' % (num_points, len(polygon))
    3535
    36         levelfile = resources.get_resource_path(self.name)
    3736        inpoly = False
    3837        polygon = []
    3938        index = 0
    4039        num_points = 0
    41         with file(levelfile, 'rU') as f:
     40        with resources.get_file(self.name) as f:
    4241            for line in f:
    4342                if inpoly:
  • nagslang/resources.py

    r39 r54  
    3939            yield (module, path_fragments)
    4040
     41    def get_file(self, *path_fragments, **kw):
     42        mode = kw.get('mode', "rU")
     43        path = self.get_resource_path(*path_fragments)
     44        return file(path, mode)
     45
    4146    def get_image(self, *name_fragments, **kw):
    4247        transforms = kw.get('transforms', ())
Note: See TracChangeset for help on using the changeset viewer.