Skip to content

Commit

Permalink
Fix flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-korniakov committed Oct 19, 2020
1 parent 86f1b30 commit a68a319
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ language: python
# - "2.7"
# - "3.5"

# install dependencies
# Install dependencies
install:
- pip install -r requirements.txt

# run tests
# Run checks
script:
- nosetests -x --with-coverage code/*
- flake8 --max-line-length=110 code

# submit coverage report
# Submit coverage report
after_success:
- coveralls
32 changes: 15 additions & 17 deletions code/fraction/src/cliview/cli_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,24 @@ def left_text(self, string):

def print_main_window(self):
os.system('cls')
print self.center_text('')
print self.center_text('Welcome to fractions calculator')
print self.left_text('First fraction: %s ' % self.first_fraction)
print self.left_text('Operation: %s ' % self.operation)
print(self.center_text(''))
print(self.center_text('Welcome to fractions calculator'))
print(self.left_text('First fraction: %s ' % self.first_fraction))
print(self.left_text('Operation: %s ' % self.operation))
if self.is_second_fraction_enabled:
print self.left_text('Second fraction: %s ' %
self.second_fraction)
print(self.left_text('Second fraction: %s ' % self.second_fraction))
if self.result:
print self.center_text('Calculation result: %s' % self.result)
print self.center_text('Possible commands:')
print self.left_text('"SetFirst,x", where x is '
'fraction value, to set first fraction')
print(self.center_text('Calculation result: %s' % self.result))
print(self.center_text('Possible commands:'))
print(self.left_text('"SetFirst,x", where x is fraction value, to set first fraction'))
if self.is_second_fraction_enabled:
print self.left_text('"SetSecond,x", where x is fraction '
'value, to set second fraction')
print self.left_text('"SetOp,x", where x is '
'one of +-*/ or "Convert to continuous"')
print(self.left_text('"SetSecond,x", where x is fraction '
'value, to set second fraction'))
print(self.left_text('"SetOp,x", where x is '
'one of +-*/ or "Convert to continuous"'))
if self.is_calc_enabled:
print self.left_text('"Calc" to get a result')
print self.left_text('"Exit" to exit')
print(self.left_text('"Calc" to get a result'))
print(self.left_text('"Exit" to exit'))

def mvvm_bind(self):
self.view_model.set_first_fraction(self.first_fraction)
Expand Down Expand Up @@ -84,7 +82,7 @@ def operation_changed(self):
def mainloop(self):
while True:
self.print_main_window()
raw_command = raw_input('Enter your choice: ')
raw_command = input('Enter your choice: ')
if ',' not in raw_command:
command = raw_command
value = None
Expand Down
2 changes: 1 addition & 1 deletion code/fraction/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def parse_args():
elif args.gui:
gui_view.GUIView().mainloop()
else:
print 'Option is required'
print('Option is required')
2 changes: 2 additions & 0 deletions code/fraction/src/model/rational_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ def euclidean_algorithm(a, b):
a, b = b, remainder
yield quotient, remainder


def gcd(p, q):
previous_remainder = q
for quotient, remainder in euclidean_algorithm(p, q):
if remainder != 0:
previous_remainder = remainder
return previous_remainder


def lcm(p, q):
return p / gcd(p, q) * q
4 changes: 2 additions & 2 deletions docs/developer-notes.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# TODO

## Next step
-

- Fix issues with `flake8 --max-line-length=110 code`

## Code

* migrate to newer version of Python
- add to requirements: numpy 1.19.1
* test GUI
- optional
- remove log files in the end of the test (or create them in folder)
- implement one more topic as an excersize
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ coverage==4.5.4
coveralls==1.0
pep8==1.7.1
pep8-naming==0.3.3
#numpy==1.19.2
numpy==1.19.2

0 comments on commit a68a319

Please sign in to comment.