Skip to content

Commit

Permalink
Removing pubsub and logging as namespace packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Sep 16, 2016
1 parent ca4f024 commit f109b0e
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 30 deletions.
16 changes: 10 additions & 6 deletions google/cloud/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

"""Google Stackdriver Logging API wrapper."""

try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)

from google.cloud.logging.client import Client
from google.cloud.logging.connection import Connection


SCOPE = Connection.SCOPE
ASCENDING = 'timestamp asc'
"""Query string to order by ascending timestamps."""
DESCENDING = 'timestamp desc'
"""Query string to order by decending timestamps."""
4 changes: 2 additions & 2 deletions google/cloud/logging/_gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def list_entries(self, projects, filter_='', order_by='',
https://cloud.google.com/logging/docs/view/advanced_filters
:type order_by: str
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
or :data:`~google.cloud.logging.client.DESCENDING`.
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
or :data:`~google.cloud.logging.DESCENDING`.
:type page_size: int
:param page_size: maximum number of entries to return, If not passed,
Expand Down
8 changes: 2 additions & 6 deletions google/cloud/logging/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@

_DISABLE_GAX = os.getenv(DISABLE_GRPC, False)
_USE_GAX = _HAVE_GAX and not _DISABLE_GAX
ASCENDING = 'timestamp asc'
"""Query string to order by ascending timestamps."""
DESCENDING = 'timestamp desc'
"""Query string to order by decending timestamps."""


class Client(JSONClient):
Expand Down Expand Up @@ -177,8 +173,8 @@ def list_entries(self, projects=None, filter_=None, order_by=None,
https://cloud.google.com/logging/docs/view/advanced_filters
:type order_by: str
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
or :data:`~google.cloud.logging.client.DESCENDING`.
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
or :data:`~google.cloud.logging.DESCENDING`.
:type page_size: int
:param page_size: maximum number of entries to return, If not passed,
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/logging/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def list_entries(self, projects, filter_=None, order_by=None,
https://cloud.google.com/logging/docs/view/advanced_filters
:type order_by: str
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
or :data:`~google.cloud.logging.client.DESCENDING`.
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
or :data:`~google.cloud.logging.DESCENDING`.
:type page_size: int
:param page_size: maximum number of entries to return, If not passed,
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/logging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ def list_entries(self, projects=None, filter_=None, order_by=None,
https://cloud.google.com/logging/docs/view/advanced_filters
:type order_by: string
:param order_by: One of :data:`~google.cloud.logging.client.ASCENDING`
or :data:`~google.cloud.logging.client.DESCENDING`.
:param order_by: One of :data:`~google.cloud.logging.ASCENDING`
or :data:`~google.cloud.logging.DESCENDING`.
:type page_size: int
:param page_size: maximum number of entries to return, If not passed,
Expand Down
14 changes: 8 additions & 6 deletions google/cloud/pubsub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
subscription (either pull or push) to a topic.
"""

try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)

from google.cloud.pubsub.client import Client
from google.cloud.pubsub.connection import Connection
from google.cloud.pubsub.subscription import Subscription
from google.cloud.pubsub.topic import Topic


SCOPE = Connection.SCOPE
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
namespace_packages=[
'google',
'google.cloud',
'google.cloud.logging',
'google.cloud.pubsub',
],
packages=find_packages(),
license='Apache 2.0',
Expand Down
3 changes: 2 additions & 1 deletion unit_tests/logging/test__gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def test_ctor(self):

def test_list_entries_no_paging(self):
from google.gax import INITIAL_PAGE
from google.cloud.logging.client import DESCENDING
from google.cloud.logging import DESCENDING
from unit_tests._testing import _GAXPageIterator

TOKEN = 'TOKEN'
TEXT = 'TEXT'
response = _GAXPageIterator(
Expand Down
3 changes: 2 additions & 1 deletion unit_tests/logging/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ def test_list_entries_defaults(self):
([self.PROJECT], None, None, None, None))

def test_list_entries_explicit(self):
from google.cloud.logging.client import DESCENDING
from google.cloud.logging import DESCENDING
from google.cloud.logging.entries import ProtobufEntry
from google.cloud.logging.entries import StructEntry
from google.cloud.logging.logger import Logger

PROJECT1 = 'PROJECT1'
PROJECT2 = 'PROJECT2'
FILTER = 'logName:LOGNAME'
Expand Down
3 changes: 2 additions & 1 deletion unit_tests/logging/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def test_list_entries_no_paging(self):
self.assertEqual(conn._called_with['data'], SENT)

def test_list_entries_w_paging(self):
from google.cloud.logging.client import DESCENDING
from google.cloud.logging import DESCENDING

PROJECT1 = 'PROJECT1'
PROJECT2 = 'PROJECT2'
TIMESTAMP = self._make_timestamp()
Expand Down
3 changes: 2 additions & 1 deletion unit_tests/logging/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ def test_list_entries_defaults(self):
self.assertEqual(client._listed, LISTED)

def test_list_entries_explicit(self):
from google.cloud.logging.client import DESCENDING
from google.cloud.logging import DESCENDING

PROJECT1 = 'PROJECT1'
PROJECT2 = 'PROJECT2'
FILTER = 'resource.type:global'
Expand Down

0 comments on commit f109b0e

Please sign in to comment.