Skip to content

Commit 4534d9a

Browse files
committed
Restoring most services as non-namespace packages.
For now, logging and pubsub will remain due to collision with the GAX generated names.
1 parent c2c9f4d commit 4534d9a

13 files changed

Lines changed: 105 additions & 86 deletions

File tree

google/cloud/bigquery/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@
2222
- :class:`~google.cloud.bigquery.table.Table` represents a single "relation".
2323
"""
2424

25-
try:
26-
import pkg_resources
27-
pkg_resources.declare_namespace(__name__)
28-
except ImportError:
29-
import pkgutil
30-
__path__ = pkgutil.extend_path(__path__, __name__)
25+
26+
from google.cloud.bigquery.client import Client
27+
from google.cloud.bigquery.connection import Connection
28+
from google.cloud.bigquery.dataset import AccessGrant
29+
from google.cloud.bigquery.dataset import Dataset
30+
from google.cloud.bigquery.schema import SchemaField
31+
from google.cloud.bigquery.table import Table
32+
33+
34+
SCOPE = Connection.SCOPE

google/cloud/bigtable/__init__.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,24 @@
1515
"""Google Cloud Bigtable API package."""
1616

1717

18+
from google.cloud.bigtable.client import Client
19+
20+
21+
_ERR_MSG = """\
22+
gRPC is required for using the Cloud Bigtable API, but
23+
importing the gRPC library (grpcio in PyPI) has failed.
24+
25+
As of June 2016, grpcio is only supported in Python 2.7,
26+
which unfortunately means the Cloud Bigtable API isn't
27+
available if you're using Python 3 or Python < 2.7.
28+
29+
If you're using Python 2.7 and importing / installing
30+
grpcio has failed, this likely means you have a non-standard version
31+
of Python installed. Check http://grpc.io if you're
32+
having trouble installing the grpcio package.
33+
"""
34+
1835
try:
19-
import pkg_resources
20-
pkg_resources.declare_namespace(__name__)
21-
except ImportError:
22-
import pkgutil
23-
__path__ = pkgutil.extend_path(__path__, __name__)
36+
import grpc
37+
except ImportError as exc: # pragma: NO COVER
38+
raise ImportError(_ERR_MSG, exc)

google/cloud/datastore/__init__.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@
5050
when race conditions may occur.
5151
"""
5252

53-
try:
54-
import pkg_resources
55-
pkg_resources.declare_namespace(__name__)
56-
except ImportError:
57-
import pkgutil
58-
__path__ = pkgutil.extend_path(__path__, __name__)
53+
54+
from google.cloud.datastore.batch import Batch
55+
from google.cloud.datastore.connection import Connection
56+
from google.cloud.datastore.client import Client
57+
from google.cloud.datastore.entity import Entity
58+
from google.cloud.datastore.key import Key
59+
from google.cloud.datastore.query import Query
60+
from google.cloud.datastore.transaction import Transaction
61+
62+
63+
SCOPE = Connection.SCOPE

google/cloud/dns/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
(adding/deleting resource record sets) to a zone.
2525
"""
2626

27-
try:
28-
import pkg_resources
29-
pkg_resources.declare_namespace(__name__)
30-
except ImportError:
31-
import pkgutil
32-
__path__ = pkgutil.extend_path(__path__, __name__)
27+
28+
from google.cloud.dns.zone import Changes
29+
from google.cloud.dns.client import Client
30+
from google.cloud.dns.connection import Connection
31+
from google.cloud.dns.zone import ManagedZone
32+
from google.cloud.dns.resource_record_set import ResourceRecordSet
33+
34+
35+
SCOPE = Connection.SCOPE

google/cloud/error_reporting/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,5 @@
1414

1515
"""Client library for Stackdriver Error Reporting"""
1616

17-
try:
18-
import pkg_resources
19-
pkg_resources.declare_namespace(__name__)
20-
except ImportError:
21-
import pkgutil
22-
__path__ = pkgutil.extend_path(__path__, __name__)
17+
18+
from google.cloud.error_reporting.client import Client

google/cloud/language/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
"""Client library for Google Cloud Natural Language API."""
1616

17-
try:
18-
import pkg_resources
19-
pkg_resources.declare_namespace(__name__)
20-
except ImportError:
21-
import pkgutil
22-
__path__ = pkgutil.extend_path(__path__, __name__)
17+
18+
from google.cloud.language.client import Client
19+
from google.cloud.language.document import Document
20+
from google.cloud.language.document import Encoding

google/cloud/monitoring/__init__.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,34 @@
1414

1515
"""Google Stackdriver Monitoring API wrapper."""
1616

17-
try:
18-
import pkg_resources
19-
pkg_resources.declare_namespace(__name__)
20-
except ImportError:
21-
import pkgutil
22-
__path__ = pkgutil.extend_path(__path__, __name__)
17+
from google.cloud.monitoring.client import Client
18+
from google.cloud.monitoring.connection import Connection
19+
from google.cloud.monitoring.group import Group
20+
from google.cloud.monitoring.label import LabelDescriptor
21+
from google.cloud.monitoring.label import LabelValueType
22+
from google.cloud.monitoring.metric import Metric
23+
from google.cloud.monitoring.metric import MetricDescriptor
24+
from google.cloud.monitoring.metric import MetricKind
25+
from google.cloud.monitoring.metric import ValueType
26+
from google.cloud.monitoring.query import Aligner
27+
from google.cloud.monitoring.query import Query
28+
from google.cloud.monitoring.query import Reducer
29+
from google.cloud.monitoring.resource import Resource
30+
from google.cloud.monitoring.resource import ResourceDescriptor
31+
from google.cloud.monitoring.timeseries import Point
32+
from google.cloud.monitoring.timeseries import TimeSeries
33+
34+
__all__ = (
35+
'Client',
36+
'Connection',
37+
'Group',
38+
'LabelDescriptor', 'LabelValueType',
39+
'Metric', 'MetricDescriptor', 'MetricKind', 'ValueType',
40+
'Aligner', 'Query', 'Reducer',
41+
'Resource', 'ResourceDescriptor',
42+
'Point', 'TimeSeries',
43+
'SCOPE',
44+
)
45+
46+
47+
SCOPE = Connection.SCOPE

google/cloud/resource_manager/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
"""Google Cloud Resource Manager API wrapper."""
1616

17-
try:
18-
import pkg_resources
19-
pkg_resources.declare_namespace(__name__)
20-
except ImportError:
21-
import pkgutil
22-
__path__ = pkgutil.extend_path(__path__, __name__)
17+
18+
from google.cloud.resource_manager.client import Client
19+
from google.cloud.resource_manager.connection import Connection
20+
from google.cloud.resource_manager.project import Project
21+
22+
23+
SCOPE = Connection.SCOPE

google/cloud/storage/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
machine).
4040
"""
4141

42-
try:
43-
import pkg_resources
44-
pkg_resources.declare_namespace(__name__)
45-
except ImportError:
46-
import pkgutil
47-
__path__ = pkgutil.extend_path(__path__, __name__)
42+
from google.cloud.storage.batch import Batch
43+
from google.cloud.storage.blob import Blob
44+
from google.cloud.storage.bucket import Bucket
45+
from google.cloud.storage.client import Client
46+
from google.cloud.storage.connection import Connection
47+
48+
49+
SCOPE = Connection.SCOPE

google/cloud/streaming/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,4 @@
1414

1515
# Vendored-in from google-apitools 0.4.11
1616

17-
"""Base ``google.cloud.streaming`` namespace package."""
18-
19-
try:
20-
import pkg_resources
21-
pkg_resources.declare_namespace(__name__)
22-
except ImportError:
23-
import pkgutil
24-
__path__ = pkgutil.extend_path(__path__, __name__)
17+
"""Base ``google.cloud.streaming`` package."""

0 commit comments

Comments
 (0)