def _expand_asn_spec(self, spec):

        if type(spec) is not dict:
            raise NipapInputError("asn specification must be a dict")

        allowed_values = ['asn', 'name']
        for a in spec:
            if a not in allowed_values:
                raise NipapExtraneousInputError("extraneous specification key %s" % a)

        if 'asn' in spec:
            if type(spec['asn']) not in (int, long):
                raise NipapValueError("asn specification key 'asn' must be an integer")
            if 'name' in spec:
                raise NipapExtraneousInputError("asn specification contain both 'asn' and 'name', specify asn or name")
        elif 'name' in spec:
            if type(spec['name']) != type(''):
                raise NipapValueError("asn specification key 'name' must be a string")
            if 'asn' in spec:
                raise NipapExtraneousInputError("asn specification contain both 'asn' and 'name', specify asn or name")

        where, params = self._sql_expand_where(spec, 'spec_')

        return where, params
Expand ASN specification to SQL.
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._expand_asn_spec