From a given key, construct a filepath. Filepath will be inside golden folder for api_version. Args: key: a string used to determine the file path api_version: a number indicating the tensorflow API version, e.g. 1 or 2. Returns: A string of file path to the pbtxt file which des
(key, api_version)
| 85 | |
| 86 | |
| 87 | def _KeyToFilePath(key, api_version): |
| 88 | """From a given key, construct a filepath. |
| 89 | |
| 90 | Filepath will be inside golden folder for api_version. |
| 91 | |
| 92 | Args: |
| 93 | key: a string used to determine the file path |
| 94 | api_version: a number indicating the tensorflow API version, e.g. 1 or 2. |
| 95 | |
| 96 | Returns: |
| 97 | A string of file path to the pbtxt file which describes the public API |
| 98 | """ |
| 99 | |
| 100 | def _ReplaceCapsWithDash(matchobj): |
| 101 | match = matchobj.group(0) |
| 102 | return '-%s' % (match.lower()) |
| 103 | |
| 104 | case_insensitive_key = re.sub('([A-Z]{1})', _ReplaceCapsWithDash, key) |
| 105 | api_folder = ( |
| 106 | _API_GOLDEN_FOLDER_V2 if api_version == 2 else _API_GOLDEN_FOLDER_V1) |
| 107 | return os.path.join(api_folder, '%s.pbtxt' % case_insensitive_key) |
| 108 | |
| 109 | |
| 110 | def _FileNameToKey(filename): |
no test coverage detected