Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metelskiy Ivan #14

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
60f1f56
add project files
DanoryHub Apr 14, 2019
a47ee67
solved some little issues
DanoryHub Apr 14, 2019
f7871af
push to fork
DanoryHub Apr 14, 2019
ee72bda
solve parse issues
DanoryHub Apr 14, 2019
f192457
solve log10 issue
DanoryHub Apr 14, 2019
636907d
add some comments
DanoryHub Apr 14, 2019
ff28467
a little code refactoring
DanoryHub Apr 14, 2019
e5431e8
add recursive function to pack math functions' parameters into lists
DanoryHub Apr 21, 2019
390dca1
gitignore
DanoryHub Apr 21, 2019
054e50e
gitignore
DanoryHub Apr 21, 2019
6ed0fc0
remove ide configuration files
DanoryHub Apr 21, 2019
53f55ac
add recursive part into polish notatin func
DanoryHub Apr 21, 2019
d5104ad
change expression calculation func to recursive calculation
DanoryHub Apr 21, 2019
a76e83e
fix some mistakes form mentor's comments
DanoryHub Apr 27, 2019
c2d6bd1
add comments to new functions, kinda remove bugs
DanoryHub Apr 28, 2019
7895f07
add setuptools and argparse
DanoryHub Apr 28, 2019
57dd907
fight with setup tools
DanoryHub Apr 28, 2019
c6612a2
little issue with sci notation check
DanoryHub Apr 28, 2019
7549c7e
error handling
DanoryHub Apr 28, 2019
113131b
oops forgot to remove test thing
DanoryHub Apr 28, 2019
55014af
and forgot to remove thing i dont need
DanoryHub Apr 28, 2019
0af8efe
very final changes(i hope...)
DanoryHub Apr 28, 2019
5123adc
super very final changes(float dont have len)
DanoryHub Apr 28, 2019
270bb4b
super very final changes(float dont have len)
DanoryHub Apr 28, 2019
8c636d6
solve negative func problem
DanoryHub Apr 28, 2019
d587c8b
add error handling func
DanoryHub Apr 29, 2019
5f759b5
add some error cases to error handling func
DanoryHub Apr 29, 2019
3ee0740
remove test thing
DanoryHub Apr 29, 2019
fc64eba
remove test thing
DanoryHub Apr 29, 2019
0e5d8f6
remove test thing
DanoryHub Apr 29, 2019
6a70980
add constants to error handling
DanoryHub Apr 29, 2019
fadddfb
solve multiple operations error
DanoryHub Apr 29, 2019
d5300d1
remove test thing
DanoryHub Apr 29, 2019
115090c
add tests file
DanoryHub Apr 29, 2019
9c69bba
a little change tests
DanoryHub Apr 29, 2019
1b0cdbd
remove imports i dont need
DanoryHub Apr 29, 2019
3e5a015
remove imports i dont need
DanoryHub Apr 29, 2019
f3ab1ec
remove imports i dont need
DanoryHub Apr 29, 2019
058e12d
some refactoring
DanoryHub Apr 29, 2019
0013b8a
remove imports
DanoryHub Apr 29, 2019
4b8584d
refactoring names of variables
DanoryHub Apr 29, 2019
bcd7395
add some comments
DanoryHub Apr 29, 2019
ff2ef4f
add typing library
DanoryHub May 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

#pycharm
.idea/
65 changes: 65 additions & 0 deletions final_task/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""

module which contains base constant values which uses for calculating expressions

"""

import re
import operator

operators_methods_dict = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.truediv,
'%': operator.mod,
'^': operator.pow,
'//': operator.floordiv,
'==': operator.eq,
'<=': operator.le,
'>=': operator.ge,
'>': operator.gt,
'<': operator.lt,
'!=': operator.ne
}

operations_priority_dict = {
'(': 0,
'<': 1,
'==': 1,
'!=': 1,
'>=': 1,
'>': 1,
'+': 2,
'-': 2,
'*': 3,
'/': 3,
'%': 3,
'//': 3,
'^': 4
}

# regular expression which divides string by funcs operators constants and numeric values
RE_MAIN_PARSE_ARG = re.compile(r'\d+[.]\d+|\d+|[+,\-*^%]|[/=!<>]+|\w+|[()]')
RE_NEGATIVE_VALUES = re.compile(r'[^\w)][\-]\d+[.]\d+|[^\w)][\-]\d+')
RE_NEGATIVE_VALUES_ON_STR_BEG = re.compile(r'^-\d+[.]\d+|^-\w+')
RE_POSITIVE_VALUES = re.compile(r'[^\w)][+]\d+[.]\d+|[^\w)][+]\d+')
RE_POSITIVE_VALUES_ON_STR_BEG = re.compile(r'^[+]\d+[.]\d+|^[+]\w+')
RE_INTS = re.compile(r'\d+')
RE_FLOATS = re.compile(r'\d+[.]\d+')
RE_FUNCTIONS = re.compile(r'[a-zA-Z]+[0-9]+|[a-zA-Z]+')
RE_OPERATIONS = re.compile(r'[(<=!>+\-*/%^]+')
RE_NEGATIVE_FUNCS = re.compile(r'[^\w)]-[a-zA-Z]+[0-9]+|[^\w)]-[a-zA-Z]+')
RE_POSITIVE_FUNCS = re.compile(r'[^\w)]-[a-zA-Z]+[0-9]+|[^\w)]-[a-zA-Z]+')
RE_INCOMPLETE_FLOAT = re.compile(r'[^\d][.]\d')
RE_NEGATIVE_CONSTANTS = re.compile(r'[^\w)][\-][a-zA-Z]+[0-9]+|[^\w)][\-][a-zA-Z]+')

# list which extends by user import modules, and is used for import them
imports = ['math']

builtin_funcs_dict = {
'abs': abs,
'round': round,
'True': True,
'False': False
}
Loading