grim/pyparser

c9cf091d55bd
dev requirements should install the normal requirements too
# vi:et:ts=4 sw=4 sts=4
"""
Some helper methods for unittesting
"""
import os
def get_filename(filename):
"""
Gets the full filename for a data reference file
"""
return os.path.join(os.path.dirname(__file__), 'data', filename)
def parse_file(parser, filename, *args, **kwargs):
"""
Given a parser and a filename, will open the file, create an instance of
parser, and parse the file with the parser and return the data.
"""
ifp = open(get_filename(filename))
data = parser(*args, **kwargs).parse(ifp)
ifp.close()
return data