@classmethod<EOL><INDENT>def from_file(cls, filename):<DEDENT>
with open(filename) as infp:<EOL><INDENT>if filename.endswith('<STR_LIT>') or filename.endswith('<STR_LIT>'):<EOL><INDENT>import yaml<EOL>data = yaml.safe_load(infp)<EOL><DEDENT>else:<EOL><INDENT>import json<EOL>data = json.load(infp)<EOL><DEDENT><DEDENT>return cls.from_data(data)<EOL>
Construct an APIDefinition by parsing the given `filename`.

If PyYAML is installed, YAML files are supported.
JSON files are always supported.

:param filename: The filename to read.
:rtype: APIDefinition