Skip to content

Commit

Permalink
Merge pull request #368 from tseaver/annotate_pylintrc_w_defaults_and…
Browse files Browse the repository at this point in the history
…_rationale

Annotate pylintrc w defaults and rationale
  • Loading branch information
tseaver committed Nov 11, 2014
2 parents 8aeff0b + 1a79f4c commit 95e80e1
Show file tree
Hide file tree
Showing 4 changed files with 397 additions and 31 deletions.
8 changes: 4 additions & 4 deletions gcloud/datastore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def key_from_protobuf(pb):
return Key(path, namespace, dataset_id)


def _get_protobuf_attribute_and_value(val):
def _pb_attr_value(val):
"""Given a value, return the protobuf attribute name and proper value.
The Protobuf API uses different attribute names
Expand All @@ -96,9 +96,9 @@ def _get_protobuf_attribute_and_value(val):
For example:
>>> _get_protobuf_attribute_and_value(1234)
>>> _pb_attr_value(1234)
('integer_value', 1234)
>>> _get_protobuf_attribute_and_value('my_string')
>>> _pb_attr_value('my_string')
('string_value', 'my_string')
:type val: `datetime.datetime`, :class:`gcloud.datastore.key.Key`,
Expand Down Expand Up @@ -230,7 +230,7 @@ def _set_protobuf_value(value_pb, val):
value_pb.Clear()
return

attr, val = _get_protobuf_attribute_and_value(val)
attr, val = _pb_attr_value(val)
if attr == 'key_value':
value_pb.key_value.CopyFrom(val)
elif attr == 'entity_value':
Expand Down
6 changes: 3 additions & 3 deletions gcloud/datastore/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ def test_w_path_in_pb(self):
self.assertEqual(key.path(), _PATH)


class Test__get_protobuf_attribute_and_value(unittest2.TestCase):
class Test__pb_attr_value(unittest2.TestCase):

def _callFUT(self, val):
from gcloud.datastore.helpers import _get_protobuf_attribute_and_value
from gcloud.datastore.helpers import _pb_attr_value

return _get_protobuf_attribute_and_value(val)
return _pb_attr_value(val)

def test_datetime_naive(self):
import calendar
Expand Down
11 changes: 8 additions & 3 deletions gcloud/storage/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ def public_url(self):
:rtype: `string`
:returns: The public URL for this key.
"""
return '{storage_base_url}/{self.bucket.name}/{self.name}'.format(
return '{storage_base_url}/{bucket_name}/{key_name}'.format(
storage_base_url='http://commondatastorage.googleapis.com',
self=self)
key_name=self.name,
bucket_name=self.bucket.name,
)

def generate_signed_url(self, expiration, method='GET'):
"""Generates a signed URL for this key.
Expand All @@ -151,7 +153,10 @@ def generate_signed_url(self, expiration, method='GET'):
:returns: A signed URL you can use to access the resource
until expiration.
"""
resource = '/{self.bucket.name}/{self.name}'.format(self=self)
resource = '/{bucket_name}/{key_name}'.format(
key_name=self.name,
bucket_name=self.bucket.name,
)
return self.connection.generate_signed_url(resource=resource,
expiration=expiration,
method=method)
Expand Down
Loading

0 comments on commit 95e80e1

Please sign in to comment.