Skip to content

Commit

Permalink
Merge pull request #9 from transitland/fix-name-defaults
Browse files Browse the repository at this point in the history
Change base Entity name() and id() to return None instead of NotImplementedError
  • Loading branch information
irees committed May 26, 2015
2 parents fc235c2 + 2a89801 commit a13acf2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 5 additions & 2 deletions mzgtfs/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def __init__(self, **data):
self._children = set()
self._parents = set()

def __repr__(self):
return '<%s %s>'%(self.__class__.__name__, self.id())

# GTFS row data.
def __len__(self):
return len(self.data)
Expand Down Expand Up @@ -77,11 +80,11 @@ def items(self):
# Name methods.
def name(self):
"""A reasonable name for the entity."""
raise NotImplementedError
return None

def id(self):
"""An internal GTFS identifier, e.g. route_id."""
raise NotImplementedError
return None

def feedid(self, feedid):
"""A canonical Onestop-style ID for this entity."""
Expand Down
6 changes: 2 additions & 4 deletions mzgtfs/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ def test_setitem_ntconvert(self):

def test_name(self):
entity = entities.Entity(**self.expect)
with self.assertRaises(NotImplementedError):
entity.name()
assert entity.name() is None

def test_id(self):
entity = entities.Entity(**self.expect)
with self.assertRaises(NotImplementedError):
entity.id()
assert entity.id() is None

def test_point(self):
entity = entities.Entity(**self.expect)
Expand Down

0 comments on commit a13acf2

Please sign in to comment.