Check if input is a free function (and not a class- or static method). Args: py_object: The the object in question. full_name: The full name of the object, like `tf.module.symbol`. index: The {full_name:py_object} dictionary for the public API. Returns: True if the obeject is a
(py_object, full_name, index)
| 36 | |
| 37 | |
| 38 | def is_free_function(py_object, full_name, index): |
| 39 | """Check if input is a free function (and not a class- or static method). |
| 40 | |
| 41 | Args: |
| 42 | py_object: The the object in question. |
| 43 | full_name: The full name of the object, like `tf.module.symbol`. |
| 44 | index: The {full_name:py_object} dictionary for the public API. |
| 45 | |
| 46 | Returns: |
| 47 | True if the obeject is a stand-alone function, and not part of a class |
| 48 | definition. |
| 49 | """ |
| 50 | if not tf_inspect.isfunction(py_object): |
| 51 | return False |
| 52 | |
| 53 | parent_name = full_name.rsplit('.', 1)[0] |
| 54 | if tf_inspect.isclass(index[parent_name]): |
| 55 | return False |
| 56 | |
| 57 | return True |
| 58 | |
| 59 | |
| 60 | # A regular expression capturing a python identifier. |