Fix an issue caused by (#18183)
authorYong Tang <yong.tang.github@outlook.com>
Thu, 5 Apr 2018 23:52:07 +0000 (16:52 -0700)
committerAndrew Harp <andrewharp@users.noreply.github.com>
Thu, 5 Apr 2018 23:52:07 +0000 (19:52 -0400)
commit73f25fc34c69878c83ee2eeb8f030cb79a76472f
tree0d06e99f3f027b6bd21f4716d880c3ea49e383fb
parentd5fc41a8ca69d37696c7c324e19a3a724b70192b
Fix an issue caused by (#18183)

While trying to run on my machine (Ubuntu 16.04 Python 2.7)
```
bazel test -s --config=opt --cache_test_results=no //tensorflow/tools/api/tests:api_compatibility_test
```

The following error was encountered:
```
  ......
  File "/home/ubuntu/.cache/bazel/_bazel_ubuntu/ad1e09741bb4109fbc70ef8216b59ee2/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/tools/api/generator/create_python_api.runfiles/org_tensorflow/tensorflow/tools/api/generator/create_python_api.py", line 125, in get_api_imports
    if not module or 'tensorflow.' not in module.__name__:
  File "/usr/lib/python2.7/dist-packages/py/_apipkg.py", line 171, in __getattribute__
    return getattr(getmod(), name)
  File "/usr/lib/python2.7/dist-packages/py/_error.py", line 43, in __getattr__
    raise AttributeError(name)
AttributeError: __name__
```

The issue is that `<AliasModule 'py.error' for 'py._error.error'>` does not
have a `__name__` attribute (See similiar issue in https://github.com/pytest-dev/py/issues/73).

This fix tries to address the issue by adding an `hasattr()` check so
that AttributeError is not thrown.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
tensorflow/tools/api/generator/create_python_api.py