Example #1
0
def seed_mcc_codes():
    for code in ('404', '405'):
        for network in operators(code):
            state = network[3]
            telco = network[2]
            mnc = network[1]
            mcc = code

            for lookup in STATE_LOOKUPS:
                if re.search(lookup[0], state, flags=re.IGNORECASE):
                    state = lookup[1]
                    break

            # Known UNINOR
            # http://mcclist.com/mobile-network-codes-country-codes.asp
            if mcc == '405' and telco == 'Uninor' and len(state) != 2:
                lookup = {
                    '813': 'HA',
                    '814': 'HP',
                    '815': 'JK',
                    '816': 'PB',
                    '817': 'RJ',
                    '818': 'UT',
                    '819': 'AP',
                    '820': 'KA',
                    '821': 'KE',
                    '822': 'WB',
                    '875': 'AS',
                    '876': 'BI',
                    '877': 'NE',
                    '878': 'OR',
                    '879': 'UPE',
                    '880': 'UP',
                    '844': 'DE'
                }
                state = lookup[mnc]

            for lookup in CODE_LOOKUPS:
                if re.search(lookup[0], telco, flags=re.IGNORECASE):
                    telco = lookup[1]
                    break

            current = NetworkModel.objects(
                db.Q(region=state) & db.Q(isp=telco)
                & db.Q(mobile=True)).first()

            if current == None:
                mccmnc = mcc + mnc
                entity = NetworkModel(region=state,
                                      isp=telco,
                                      mobile=True,
                                      mccmnc=mccmnc)
                entity.save()
                print("saved")
def get_operator_choices(cnt_code):
    """
    Get list of operators matching MCC(s)
    @param cnt_code: country code(s). May contain multiple values, separated by commas
    @type cnt_code: unicode
    @return: operators
    @rtype: dict
    """
    # noinspection PyProtectedMember
    from mobile_codes import operators

    ol = operators(cnt_code)
    r = []
    for e in ol:
        if e[0] == cnt_code:
            opname = e[2] if e[2] else e[3]
            r.append((e[0] + e[1], u"{0} ({1})".format(opname, e[1])))
    r.sort(key=lambda tup: tup[1])
    return r
Example #3
0
def get_operator_choices(cnt_code):
    """
    Get list of operators matching MCC(s)
    @param cnt_code: country code(s). May contain multiple values, separated by commas
    @type cnt_code: unicode
    @return: operators
    @rtype: dict
    """
    # noinspection PyProtectedMember
    from mobile_codes import operators

    mcc = cnt_code.split(',')
    ol = operators()
    r = []
    for e in ol:
        if e[0] in mcc:
            opname = e[2] if e[2] else e[3]
            r.append((e[0] + e[1], "{0} ({1})".format(opname, e[1])))
    r.sort(key=lambda tup: tup[1])
    return r
Example #4
0
 def test_sid_operators_fail(self):
     operators = mobile_codes.operators(u'000')
     self.assertEqual(len(operators), 0)
Example #5
0
 def test_mcc(self):
     operators = mobile_codes.operators(u'302')
     mccs = set([o.mcc for o in operators])
     self.assertEqual(mccs, set([u'302']))
Example #6
0
 def test_sid_operators_fail(self):
     operators = mobile_codes.operators("000")
     assert len(operators) == 0
Example #7
0
 def test_mcc(self):
     operators = mobile_codes.operators("302")
     mccs = set([o.mcc for o in operators])
     assert mccs == {"302"}
Example #8
0
 def test_sid_operators_fail(self):
     operators = mobile_codes.operators(u'000')
     self.assertEqual(len(operators), 0)
Example #9
0
 def test_mcc(self):
     operators = mobile_codes.operators(u'302')
     mccs = set([o.mcc for o in operators])
     self.assertEqual(mccs, set([u'302']))