Ejemplo n.º 1
0
def initiation(form):
    '''
    this function is called to initiate the programme to process all settings
    '''
    # retrieve settings
    # =================
    pyorator_str = 'pyorator'
    form.settings = _read_setup_file(pyorator_str)
    form.settings['exe_path'] = 'C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE'
    form.settings['studies'] = []

    set_up_logging(form, pyorator_str)

    return
        state_to_update = match.group(1)
        choice_to_expand = choice_to_expand[:match.start(
        )] + choice_to_expand[match.end():]
        logging.debug(f'Found state {state_to_update} to store value in.')
        return choice_to_expand, state_to_update
    else:
        # logging.debug(f'No match')
        return choice_to_expand, None


def clause_list_from_raw_clause(raw_clause):
    return ['%' + clause + '%' for clause in raw_clause.split('|')]


if __name__ == '__main__':
    args = set_up_logging.set_up_logging(['--dump_regexes'])

    if args.dump_regexes:
        for type, regex in STATE_REGEXES.items():
            print(f'{type} regex: "{regex}"')
        exit()

    state = defaultdict(
        int, {
            'wealth': 10,
            'money': 256,
            'dogs': 1,
            'cats': 3,
            'fish': 12,
            'name': 'Gabe'
        })
Ejemplo n.º 3
0
        # Is string
        pass
    logging.debug(f'Calculated value of {result} for clause {clause}.')
    return result


def try_int_conversion(maybe_num):
    try:
        return math.floor(maybe_num)
    except TypeError:
        # It's a string
        return maybe_num


if __name__ == '__main__':
    set_up_logging.set_up_logging()

    print(
        calculate('10-(10+thousand*wealth)', {
            'wealth': 10,
            'thousand': 1000
        }))  # -10000
    print(
        calculate('1+1*2+(2*(3/3+3))/thousand', {
            'wealth': 10,
            'thousand': 1000
        }))  # 3
    print(calculate('(((((((2^5)))))))', {
        'wealth': 10,
        'thousand': 1000
    }))  #32