def get_asn(self, asn): asn_obj = self.session.query(ASN).filter(ASN.asn == asn).first() if asn_obj: return asn_obj.json(depth=1) else: asn_info = get_asn_info(asn) if asn_info: asn_obj = ASN(asn=asn, name=asn_info['name'], reg=asn_info['reg'], country=asn_info['country']) self.session.add(asn_obj) return asn_obj.json(depth=1)
def _get_asn(self, asn_id): asn_obj = self.session.query(ASN).filter(ASN.asn == asn_id).first() if asn_obj: return asn_obj else: asn_info = additionalinfo.get_asn_info(asn_id) if asn_info: asn_obj = ASN(asn=asn_id, name=asn_info['name'], reg=asn_info['reg'], country=asn_info['country']) self.session.add(asn_obj) return asn_obj return None