Esempio n. 1
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'dump country-related informations from the CIA World Factbook into JSON or Python file'
    )
    parser.add_argument('-j',
                        action='store_true',
                        help='produce a JSON file (with suffix .json)')
    parser.add_argument('-p',
                        action='store_true',
                        help='produce a Python file (with suffix .py)')
    args = parser.parse_args()
    try:
        D = parse_table_country_all()
    except Exception as err:
        print('> error occured: %s' % err)
        return 1
    #
    if args.j:
        generate_json(D, PATH_PRE + 'world_fb.json', [URL_FACTBOOK],
                      URL_LICENSE)
    if args.p:
        generate_python(D, PATH_PRE + 'world_fb.py', [URL_FACTBOOK],
                        URL_LICENSE)
    return 0
Esempio n. 2
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'dump csv files from the Egallic blog (distance between countries) and the txtNation website (list of MCC-MNC)'
    )
    parser.add_argument('-j',
                        action='store_true',
                        help='produce a JSON file (with suffix .json)')
    parser.add_argument('-p',
                        action='store_true',
                        help='produce a Python file (with suffix .py)')
    args = parser.parse_args()
    try:
        DE = get_egal_min_dist()
        DT = get_txtn_mnc()
    except Exception as err:
        print('> error occured: %s' % err)
        return 1
    #
    if args.j:
        generate_json(DE, PATH_PRE + 'csv_egal_min_dist.json', [URL_MIN_DIST],
                      URL_LICENSE_EGAL)
        generate_json(DT, PATH_PRE + 'csv_txtn_mccmnc.json', [URL_TXTN_MNC],
                      URL_LICENSE_TXTN)
    if args.p:
        generate_python(DE, PATH_PRE + 'csv_egal_min_dist.py', [URL_MIN_DIST],
                        URL_LICENSE_EGAL)
        generate_python(DT, PATH_PRE + 'csv_txtn_mccmnc.py', [URL_TXTN_MNC],
                        URL_LICENSE_TXTN)
    return 0
Esempio n. 3
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'download ITU-T operational bulletins, convert them to text, extract lists of MNC and SPC'
    )
    parser.add_argument(
        '-d',
        action='store_true',
        help='download and convert all ITU-T bulletins, starting from the 1111'
    )
    parser.add_argument(
        '-j',
        action='store_true',
        help='produce a JSON file listing all MNC and SPC (with suffix .json)')
    parser.add_argument(
        '-p',
        action='store_true',
        help='produce a Python file listing all MNC and SPC (with suffix .py)')
    args = parser.parse_args()
    #
    if args.d:
        try:
            dl_bull_all(dbg=False)
        except Exception as err:
            print('> error occured during downloading: %s' % err)
            return 1
    #
    try:
        MNC_1111 = parse_mnc_list(PATH_PRE + 'T-SP-OB.1111-2016-OAS-PDF-E.txt',
                                  dbg=False)
        MNC_1162 = parse_mnc_list(PATH_PRE + 'T-SP-OB.1162-2018-OAS-PDF-E.txt',
                                  dbg=False)
    except Exception as err:
        print('> error occured during MNC extraction: %s' % err)
        return 1
    try:
        SPC_1199 = parse_spc_list(PATH_PRE + 'T-SP-OB.1199-2020-OAS-PDF-E.txt',
                                  dbg=False)
    except Exception as err:
        print('> error occured during SPC extraction: %s' % err)
        return 1
    #
    if args.j:
        generate_json(MNC_1111, PATH_RAW + 'itut_mnc_1111.json',
                      [URL_LICENSE_ITUT], URL_LICENSE_ITUT)
        generate_json(MNC_1162, PATH_RAW + 'itut_mnc_1162.json',
                      [URL_LICENSE_ITUT], URL_LICENSE_ITUT)
        generate_json(SPC_1199, PATH_RAW + 'itut_spc_1199.json',
                      [URL_LICENSE_ITUT], URL_LICENSE_ITUT)
    if args.p:
        generate_python(MNC_1111, PATH_RAW + 'itut_mnc_1111.py',
                        [URL_LICENSE_ITUT], URL_LICENSE_ITUT)
        generate_python(MNC_1162, PATH_RAW + 'itut_mnc_1162.py',
                        [URL_LICENSE_ITUT], URL_LICENSE_ITUT)
        generate_python(SPC_1199, PATH_RAW + 'itut_spc_1199.py',
                        [URL_LICENSE_ITUT], URL_LICENSE_ITUT)
    return 0
Esempio n. 4
0
def main():
            
    URL_SRC = 'data aggregated from Wikipedia, The World Factbook, ITU-T, Egallic blog and txtNation'
    URL_LIC = 'produced by P1 Security, based on openly available data'

    generate_json(MNC, PATH_PRE + 'p1_mnc.json', [URL_SRC], URL_LIC)
    generate_python(MNC, PATH_PRE + 'p1_mnc.py', [URL_SRC], URL_LIC)
    generate_json(MCC, PATH_PRE + 'p1_mcc.json', [URL_SRC], URL_LIC)
    generate_python(MCC, PATH_PRE + 'p1_mcc.py', [URL_SRC], URL_LIC)
    generate_json(MSISDN, PATH_PRE + 'p1_msisdn.json', [URL_SRC], URL_LIC)
    generate_python(MSISDN, PATH_PRE + 'p1_msisdn.py', [URL_SRC], URL_LIC)
    generate_json(MSISDNEXT, PATH_PRE + 'p1_msisdnext.json', [URL_SRC], URL_LIC)
    generate_python(MSISDNEXT, PATH_PRE + 'p1_msisdnext.py', [URL_SRC], URL_LIC)
    generate_json(ISPC, PATH_PRE + 'p1_ispc.json', [URL_SRC], URL_LIC)
    generate_python(ISPC, PATH_PRE + 'p1_ispc.py', [URL_SRC], URL_LIC)
    generate_json(CC2, PATH_PRE + 'p1_cc2.json', [URL_SRC], URL_LIC)
    generate_python(CC2, PATH_PRE + 'p1_cc2.py', [URL_SRC], URL_LIC)
    generate_json(CNTR, PATH_PRE + 'p1_cntr.json', [URL_SRC], URL_LIC)
    generate_python(CNTR, PATH_PRE + 'p1_cntr.py', [URL_SRC], URL_LIC)
    generate_json(TERR, PATH_PRE + 'p1_terr.json', [URL_SRC], URL_LIC)
    generate_python(TERR, PATH_PRE + 'p1_terr.py', [URL_SRC], URL_LIC)
    
    return 0