Skip to content

Commit

Permalink
Removing helper methods in storage.__init__.
Browse files Browse the repository at this point in the history
Towards removing storage._implicit_environ.
  • Loading branch information
dhermes committed Jul 20, 2015
1 parent 54bf64e commit 6a2ce86
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 221 deletions.
7 changes: 0 additions & 7 deletions docs/storage-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ Storage

.. include:: _components/storage-quickstart.rst

:mod:`gcloud.storage`
~~~~~~~~~~~~~~~~~~~~~

.. automodule:: gcloud.storage
:members: get_connection, get_default_connection, get_default_bucket,
set_default_connection, set_default_bucket, set_defaults

Connections
~~~~~~~~~~~

Expand Down
59 changes: 0 additions & 59 deletions gcloud/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,68 +38,9 @@
machine).
"""

import os

from gcloud import credentials
from gcloud._helpers import get_default_project
from gcloud._helpers import set_default_project
from gcloud.storage import _implicit_environ
from gcloud.storage._implicit_environ import get_connection
from gcloud.storage._implicit_environ import get_default_bucket
from gcloud.storage._implicit_environ import get_default_connection
from gcloud.storage._implicit_environ import set_default_connection
from gcloud.storage.batch import Batch
from gcloud.storage.blob import Blob
from gcloud.storage.bucket import Bucket
from gcloud.storage.client import Client
from gcloud.storage.connection import SCOPE
from gcloud.storage.connection import Connection


_BUCKET_ENV_VAR_NAME = 'GCLOUD_BUCKET_NAME'


def set_default_bucket(bucket=None):
"""Set default bucket either explicitly or implicitly as fall-back.
In implicit case, currently only supports enviroment variable but will
support App Engine, Compute Engine and other environments in the future.
In the implicit case, relies on an implicit connection in addition to the
implicit bucket name.
Local environment variable used is:
- GCLOUD_BUCKET_NAME
:type bucket: :class:`gcloud.storage.bucket.Bucket`
:param bucket: Optional. The bucket to use as default.
"""
if bucket is None:
bucket_name = os.getenv(_BUCKET_ENV_VAR_NAME)

if bucket_name is not None:
bucket = Bucket(None, name=bucket_name)

if bucket is not None:
_implicit_environ._DEFAULTS.bucket = bucket


def set_defaults(bucket=None, project=None, connection=None):
"""Set defaults either explicitly or implicitly as fall-back.
Uses the arguments to call the individual default methods.
:type bucket: :class:`gcloud.storage.bucket.Bucket`
:param bucket: Optional. The bucket to use as default.
:type project: string
:param project: Optional. The name of the project to connect to.
:type connection: :class:`gcloud.storage.connection.Connection`
:param connection: Optional. A connection provided to be the default.
"""
set_default_project(project=project)
set_default_connection(connection=connection)
# NOTE: `set_default_bucket` is called after `set_default_connection`
# since `set_default_bucket` falls back to implicit connection.
set_default_bucket(bucket=bucket)
155 changes: 0 additions & 155 deletions gcloud/storage/test___init__.py

This file was deleted.

0 comments on commit 6a2ce86

Please sign in to comment.