Next / Previous / Contents / NM Tech homepage

6.16. CBCData.getNation()

pycbc.py
# - - -   C B C D a t a . g e t N a t i o n

    def getNation(self, nationCode):
        '''Look up a nation_code.
        '''
        try:
            result = self.s.query(self.Nation).one()
            return result
        except exc.SQLAlchemyError, detail:
            raise KeyError("No such nation code, '%s': %s" %
                           (nationCode, detail))

FIXME: The current SQLAlchemy exception raised in this case is exc.NoResultFound. However, on infohost, an older version is there that does not have that exception, so we use the more generic exc.SQLAlchemyError, which is less specific. Fix this also in Section 6.18, “CBCData.getRegion() and Section 6.20, “CBCData.getPhysio().