Skip to content

Commit

Permalink
Using more descriptive entity_type instead of type_.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Sep 23, 2014
1 parent 0b8a08b commit 8350d54
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions gcloud/storage/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class Entity(object):
outside of using the factor methods on the :class:`ACL` object.
"""

def __init__(self, type_, identifier=None):
def __init__(self, entity_type, identifier=None):
"""
:type type_: string
:param type_: The type of entity (ie, 'group' or 'user').
:type entity_type: string
:param entity_type: The type of entity (ie, 'group' or 'user').
:type identifier: string
:param identifier: The ID or e-mail of the entity.
Expand All @@ -103,7 +103,7 @@ def __init__(self, type_, identifier=None):

self.identifier = identifier
self.roles = set([])
self.type = type_
self.type = entity_type

def __str__(self):
if not self.identifier:
Expand Down Expand Up @@ -218,8 +218,8 @@ def entity_from_dict(self, entity_dict):
entity = self.all_authenticated()

elif '-' in entity:
type_, identifier = entity.split('-', 1)
entity = self.entity(type_=type_, identifier=identifier)
entity_type, identifier = entity.split('-', 1)
entity = self.entity(entity_type=entity_type, identifier=identifier)

if not isinstance(entity, ACL.Entity):
raise ValueError('Invalid dictionary: %s' % entity_dict)
Expand Down Expand Up @@ -262,16 +262,17 @@ def add_entity(self, entity):

self.entities[str(entity)] = entity

def entity(self, type_, identifier=None):
def entity(self, entity_type, identifier=None):
"""Factory method for creating an Entity.
If an entity with the same type and identifier already exists,
this will return a reference to that entity.
If not, it will create a new one and add it to the list
of known entities for this ACL.
:type type_: string
:param type_: The type of entity to create (ie, ``user``, ``group``, etc)
:type entity_type: string
:param entity_type: The type of entity to create
(ie, ``user``, ``group``, etc)
:type identifier: string
:param identifier: The ID of the entity (if applicable).
Expand All @@ -281,7 +282,7 @@ def entity(self, type_, identifier=None):
:returns: A new Entity or a refernece to an existing identical entity.
"""

entity = ACL.Entity(type_=type_, identifier=identifier)
entity = ACL.Entity(entity_type=entity_type, identifier=identifier)
if self.has_entity(entity):
entity = self.get_entity(entity)
else:
Expand Down

0 comments on commit 8350d54

Please sign in to comment.