def _get_local_defs(self, strict=True):
version = parse_version(self.version)<EOL>for cache_dir in [<EOL>self.cache_dir,<EOL>os.path.join(os.path.expanduser('<STR_LIT>'), '<STR_LIT>'),<EOL>os.path.dirname(__file__)<EOL>]:<EOL><INDENT>defs_path = os.path.join(cache_dir, '<STR_LIT>')<EOL>files = glob.glob('<STR_LIT>' % (defs_path, self.api_version))<EOL>files_version = [<EOL>(fn, parse_version(os.path.basename(fn).rsplit('<STR_LIT:->', <NUM_LIT:1>)[<NUM_LIT:0>]))<EOL>for fn in files<EOL>]<EOL>last_major_match = None<EOL>for f_name, f_ver in sorted(files_version, key=lambda x: x[<NUM_LIT:1>]):<EOL><INDENT>if f_ver == version:<EOL><INDENT>logger.debug('<STR_LIT>' % f_name)<EOL>return json.loads(open(f_name).read())<EOL><DEDENT>if f_ver[:<NUM_LIT:2>] == version[:<NUM_LIT:2>]:<EOL><INDENT>last_major_match = f_name<EOL><DEDENT>if f_ver[<NUM_LIT:0>] > version[<NUM_LIT:0>]:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>if last_major_match:<EOL><INDENT>if strict:<EOL><INDENT>raise ForemanVersionException(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% (self.version, last_major_match))<EOL><DEDENT>else:<EOL><INDENT>logger.warn(<EOL>"<STR_LIT>",<EOL>last_major_match,<EOL>self.version,<EOL>)<EOL>return json.loads(open(last_major_match).read())<EOL><DEDENT><DEDENT>raise ForemanVersionException(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% (<EOL>self.version,<EOL>self.api_version,<EOL>strict,<EOL>'<STR_LIT>' + '<STR_LIT>'.join(files)<EOL>)<EOL>)<EOL>
Gets the cached definition or the any previous from the same major
version if not strict passed.

:param strict: Use any version that shared major version and has lower
     minor version if no total match found