<commit_before>__author__ = 'foxcarlos'
from os import getcwd
from os.path import expanduser, join, isfile
import ConfigParser

dataFolderPath = expanduser('~')
currentPath = getcwd()
myFileConfig = 'ob.cfg'
finalFileConfig = join(currentPath, myFileConfig)
fc = ConfigParser.ConfigParser(allow_no_value=True)

# if file config found
if isfile(finalFileConfig):
    fc.read(finalFileConfig)
    # name of section in Config File ob.cfg
    mySection = 'CONSTANTS'

    # if exist the sections in file config
    if fc.has_section(mySection):
        data_f2 = ''
        nameOptionDF = 'DATA_FOLDER'

        # if exist option in file config
        if fc.has_option(mySection, nameOptionDF):
            optionDataFolder = fc.get(mySection, nameOptionDF)
            # if have a value
            if optionDataFolder:
                data_f1 = join(dataFolderPath, optionDataFolder)
                data_f2 = join(data_f1, '')  # is necesary for "/" the end
        else:
            print('No Found option "{0}"'.format(nameOptionDF))

        if ':' in fc.get(mySection, 'SEED_NODE'):
            seed_n = fc.get(mySection, 'SEED_NODE').split(':')[0]
            seed_n_p = int(fc.get(mySection, 'SEED_NODE').split(':')[1])

        if ':' in fc.get(mySection, 'SEED_NODE_TESTNET'):
            seed_n_t = fc.get(mySection, 'SEED_NODE_TESTNET').split(':')[0]
            seed_n_t_p = int(fc.get(mySection, 'SEED_NODE_TESTNET').split(':')[1])

        ks = fc.getint(mySection, 'KSIZE')
        alp = fc.getint(mySection, 'ALPHA')
        trans_f = fc.getint(mySection, 'TRANSACTION_FEE')

        DATA_FOLDER = data_f2
        SEED_NODE = (seed_n, seed_n_p)
        SEED_NODE_TESTNET = (seed_n_t, seed_n_t_p)
        KSIZE = ks
        ALPHA = alp
        TRANSACTION_FEE = trans_f
    else:
        message = 'No Section name "{0}" in file config:{1}'.format(mySection, myFileConfig)
        print(message)
else:
    message = 'The file Config "{0}" not found'.format(finalFileConfig)
    print(message)<commit_msg>ready issue that put seed_node  and port a same line, It validates that there is the option in ob.cfg<commit_after>__author__ = 'foxcarlos'
from os import getcwd
from os.path import expanduser, join, isfile
import ConfigParser

dataFolderPath = expanduser('~')
currentPath = getcwd()
myFileConfig = 'ob.cfg'
finalFileConfig = join(currentPath, myFileConfig)
fc = ConfigParser.ConfigParser(allow_no_value=True)

# if file config found
if isfile(finalFileConfig):
    fc.read(finalFileConfig)

    # name of section in Config File ob.cfg
    mySection = 'CONSTANTS'

    # if exist the sections in file config
    if fc.has_section(mySection):

        # Extract Config DATA_FOLDER
        data_f2 = ''
        nameOptionDF = 'DATA_FOLDER'

        # if exist option in file config
        if fc.has_option(mySection, nameOptionDF):
            optionDataFolder = fc.get(mySection, nameOptionDF)
            # if have a value
            if optionDataFolder:
                data_f1 = join(dataFolderPath, optionDataFolder)
                data_f2 = join(data_f1, '')  # is necesary for "/" the end
        else:
            print 'No Found option "{0}"'.format(nameOptionDF)

        # Extract Config SEED_NODE
        seed_n = ''
        seed_n_p = ''
        nameOptionSN = 'SEED_NODE'

        if fc.has_option(mySection, nameOptionSN):
            optionSeedNode = fc.get(mySection, nameOptionSN)
            # if have value
            if optionSeedNode:
                if ':' in fc.get(mySection, nameOptionSN):
                    seed_n = fc.get(mySection, nameOptionSN).split(':')[0]
                    seed_n_p = int(fc.get(mySection, nameOptionSN).split(':')[1])
        else:
            print 'No Found option "{0}"'.format(nameOptionSN)

        # Extract Config SEED_NODE_TESTNET
        seed_n_t = ''
        seed_n_t_p = ''
        nameOptionSNT = 'SEED_NODE_TESTNET'

        if fc.has_option(mySection, nameOptionSNT):
            optionSeeNodeTest = fc.get(mySection, nameOptionSNT)
            # if have value
            if optionSeeNodeTest:
                if ':' in fc.get(mySection, nameOptionSNT):
                    seed_n_t = fc.get(mySection, nameOptionSNT).split(':')[0]
                    seed_n_t_p = int(fc.get(mySection, nameOptionSNT).split(':')[1])
        else:
            print 'No Found option "{0}"'.format(nameOptionSNT)

        # Extract Config KSIZE
        ks = ''
        nameOptionKS = 'KSIZE'

        if fc.has_option(mySection, nameOptionKS):
            optionKSize = fc.getint(mySection, nameOptionKS)
            # if have value
            ks = '' if not optionKSize else optionKSize
        else:
            print 'No Found option "{0}"'.format(nameOptionKS)

        # extract Config APLHA
        alp = ''
        nameOptionAlpha = 'ALPHA'
        if fc.has_option(mySection, nameOptionAlpha):
            optionAlpha = fc.getint(mySection, nameOptionAlpha)
            # if have value
            alp = '' if not optionAlpha else optionAlpha
        else:
            print 'No Found option "{0}"'.format(nameOptionAlpha)

        # extract Config  TRANSACTION_FEE
        trans_f = ''
        nameOptionTrans_f = 'TRANSACTION_FEE'
        if fc.has_option(mySection, nameOptionTrans_f):
            optionTrans_f = fc.getint(mySection, nameOptionTrans_f)
            # if have value
            trans_f = '' if not optionTrans_f else optionTrans_f
        else:
            print 'No Found option "{0}"'.format(nameOptionTrans_f)

        DATA_FOLDER = data_f2
        SEED_NODE = (seed_n, seed_n_p)
        SEED_NODE_TESTNET = (seed_n_t, seed_n_t_p)
        KSIZE = ks
        ALPHA = alp
        TRANSACTION_FEE = trans_f
    else:
        message = 'No Section name "{0}" in file config:{1}'.format(mySection, myFileConfig)
        print message
else:
    message = 'The file Config "{0}" not found'.format(finalFileConfig)
    print message
{'fraction_non_alphanumeric': 0.10140037118272313, 'fraction_numerical': 0.005230302007761093, 'mean_word_length': 2.404939689833429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6145950', 'n_tokens_mistral': 1926, 'n_tokens_neox': 1877, 'n_words': 441}