Store export information for constants/string literals. Export information is stored in the module where constants/string literals are defined. e.g. ```python foo = 1 bar = 2 tf_export("consts.foo").export_constant(__name__, 'foo') tf_export("consts.bar").export_con
(self, module_name, name)
| 347 | setattr(func, api_names_attr, names) |
| 348 | |
| 349 | def export_constant(self, module_name, name): |
| 350 | """Store export information for constants/string literals. |
| 351 | |
| 352 | Export information is stored in the module where constants/string literals |
| 353 | are defined. |
| 354 | |
| 355 | e.g. |
| 356 | ```python |
| 357 | foo = 1 |
| 358 | bar = 2 |
| 359 | tf_export("consts.foo").export_constant(__name__, 'foo') |
| 360 | tf_export("consts.bar").export_constant(__name__, 'bar') |
| 361 | ``` |
| 362 | |
| 363 | Args: |
| 364 | module_name: (string) Name of the module to store constant at. |
| 365 | name: (string) Current constant name. |
| 366 | """ |
| 367 | module = sys.modules[module_name] |
| 368 | api_constants_attr = API_ATTRS[self._api_name].constants |
| 369 | api_constants_attr_v1 = API_ATTRS_V1[self._api_name].constants |
| 370 | |
| 371 | if not hasattr(module, api_constants_attr): |
| 372 | setattr(module, api_constants_attr, []) |
| 373 | # pylint: disable=protected-access |
| 374 | getattr(module, api_constants_attr).append( |
| 375 | (self._names, name)) |
| 376 | |
| 377 | if not hasattr(module, api_constants_attr_v1): |
| 378 | setattr(module, api_constants_attr_v1, []) |
| 379 | getattr(module, api_constants_attr_v1).append( |
| 380 | (self._names_v1, name)) |
| 381 | |
| 382 | |
| 383 | def kwarg_only(f): |