Skip to content

Commit 2fbf722

Browse files
committed
Removing pubsub and logging as namespace packages.
Fixes googleapis#2258.
1 parent 2e47d81 commit 2fbf722

File tree

11 files changed

+34
-30
lines changed

11 files changed

+34
-30
lines changed

google/cloud/logging/__init__.py

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

1515
"""Google Stackdriver Logging 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.logging.client import Client
19+
from google.cloud.logging.connection import Connection
20+
21+
22+
SCOPE = Connection.SCOPE
23+
ASCENDING = 'timestamp asc'
24+
"""Query string to order by ascending timestamps."""
25+
DESCENDING = 'timestamp desc'
26+
"""Query string to order by decending timestamps."""

google/cloud/logging/_gax.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def list_entries(self, projects, filter_='', order_by='',
5858
https://cloud.google.com/logging/docs/view/advanced_filters
5959
6060
:type order_by: str
61-
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
62-
or :data:`~google.cloud.logging.client.DESCENDING`.
61+
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
62+
or :data:`~google.cloud.logging.DESCENDING`.
6363
6464
:type page_size: int
6565
:param page_size: maximum number of entries to return, If not passed,

google/cloud/logging/client.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050

5151
_DISABLE_GAX = os.getenv(DISABLE_GRPC, False)
5252
_USE_GAX = _HAVE_GAX and not _DISABLE_GAX
53-
ASCENDING = 'timestamp asc'
54-
"""Query string to order by ascending timestamps."""
55-
DESCENDING = 'timestamp desc'
56-
"""Query string to order by decending timestamps."""
5753

5854

5955
class Client(JSONClient):
@@ -177,8 +173,8 @@ def list_entries(self, projects=None, filter_=None, order_by=None,
177173
https://cloud.google.com/logging/docs/view/advanced_filters
178174
179175
:type order_by: str
180-
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
181-
or :data:`~google.cloud.logging.client.DESCENDING`.
176+
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
177+
or :data:`~google.cloud.logging.DESCENDING`.
182178
183179
:type page_size: int
184180
:param page_size: maximum number of entries to return, If not passed,

google/cloud/logging/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def list_entries(self, projects, filter_=None, order_by=None,
7777
https://cloud.google.com/logging/docs/view/advanced_filters
7878
7979
:type order_by: str
80-
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
81-
or :data:`~google.cloud.logging.client.DESCENDING`.
80+
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
81+
or :data:`~google.cloud.logging.DESCENDING`.
8282
8383
:type page_size: int
8484
:param page_size: maximum number of entries to return, If not passed,

google/cloud/logging/logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ def list_entries(self, projects=None, filter_=None, order_by=None,
289289
https://cloud.google.com/logging/docs/view/advanced_filters
290290
291291
:type order_by: string
292-
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
293-
or :data:`~google.cloud.logging.client.DESCENDING`.
292+
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
293+
or :data:`~google.cloud.logging.DESCENDING`.
294294
295295
:type page_size: int
296296
:param page_size: maximum number of entries to return, If not passed,

google/cloud/pubsub/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
subscription (either pull or push) to a topic.
2424
"""
2525

26-
try:
27-
import pkg_resources
28-
pkg_resources.declare_namespace(__name__)
29-
except ImportError:
30-
import pkgutil
31-
__path__ = pkgutil.extend_path(__path__, __name__)
26+
27+
from google.cloud.pubsub.client import Client
28+
from google.cloud.pubsub.connection import Connection
29+
from google.cloud.pubsub.subscription import Subscription
30+
from google.cloud.pubsub.topic import Topic
31+
32+
33+
SCOPE = Connection.SCOPE

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
namespace_packages=[
4545
'google',
4646
'google.cloud',
47-
'google.cloud.logging',
48-
'google.cloud.pubsub',
4947
],
5048
packages=find_packages(),
5149
license='Apache 2.0',

unit_tests/logging/test__gax.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def test_ctor(self):
5151

5252
def test_list_entries_no_paging(self):
5353
from google.gax import INITIAL_PAGE
54-
from google.cloud.logging.client import DESCENDING
54+
from google.cloud.logging import DESCENDING
5555
from unit_tests._testing import _GAXPageIterator
56+
5657
TOKEN = 'TOKEN'
5758
TEXT = 'TEXT'
5859
response = _GAXPageIterator(

unit_tests/logging/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,11 @@ def test_list_entries_defaults(self):
234234
([self.PROJECT], None, None, None, None))
235235

236236
def test_list_entries_explicit(self):
237-
from google.cloud.logging.client import DESCENDING
237+
from google.cloud.logging import DESCENDING
238238
from google.cloud.logging.entries import ProtobufEntry
239239
from google.cloud.logging.entries import StructEntry
240240
from google.cloud.logging.logger import Logger
241+
241242
PROJECT1 = 'PROJECT1'
242243
PROJECT2 = 'PROJECT2'
243244
FILTER = 'logName:LOGNAME'

unit_tests/logging/test_connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def test_list_entries_no_paging(self):
9797
self.assertEqual(conn._called_with['data'], SENT)
9898

9999
def test_list_entries_w_paging(self):
100-
from google.cloud.logging.client import DESCENDING
100+
from google.cloud.logging import DESCENDING
101+
101102
PROJECT1 = 'PROJECT1'
102103
PROJECT2 = 'PROJECT2'
103104
TIMESTAMP = self._make_timestamp()

0 commit comments

Comments
 (0)