It seems like these 4 lines (that also exist in component.py) should exist in some reusable location.