示例#1
0
文件: script.py 项目: pratz/Code
def set_country_code() :
    """ Function to set country code """


    # get args ( element two )
    status, country_code_file = args_two(sys.argv)
    if not status :
        LOGGER.info("Please provide Country Code file.")
        LOGGER.info("Usage : python execute set_country_code <CountryCodeFile>.")
        sys.exit(1)


    # open the given file
    status, file = open_file(country_code_file)
    if not status :
        LOGGER.info('Please check file location.')
        sys.exit(1)

    # read content
    country_list = file.read()

    # load json format
    country_list = json.loads(country_list)

    # get country code list
    country_code_list = [ k for k in country_list ]

    # add country code to CountryModel
    add_country_code(code_list=country_code_list)

    LOGGER.info('Congratulations! Country Code added successfully.')
示例#2
0
文件: script.py 项目: pratz/Code
def set_country():
    """ Function used to set country """


    # get args ( element two )
    status, language_code = args_two(sys.argv)
    if not status :
        LOGGER.info("Please provide Language Code.")
        LOGGER.info("Usage : python execute set_country <LanguageCode> <CountryCodeFile>.")
        sys.exit(1)

    # get args ( element three )
    status, country_file = args_three(sys.argv)
    if not status :
        LOGGER.info("Please provide Country file.")
        LOGGER.info("Usage : python execute set_country <LanguageCode> <CountryCodeFile>.")
        sys.exit(1)


    # get language
    language = get_language(code=language_code)

    # open the given file
    status, file = open_file(country_file)
    if not status :
        LOGGER.info('Please check file location.')
        sys.exit(1)

    # read content
    country_list = file.read()

    # load json format
    country_list = json.loads(country_list)

    # add country to CountryTranslationModel
    add_country(language=language,country_dict=country_list)

    LOGGER.info('Congratulations! Countries added successfully.')