Skip to content

Commit 2d36b00

Browse files
committed
global reformat
1 parent f204f29 commit 2d36b00

File tree

8 files changed

+33
-27
lines changed

8 files changed

+33
-27
lines changed

src/algo/stmts/GFuncStmt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def __init__(self, var: str, expr: AstNode, start: AstNode, end: AstNode, step:
2121
self.color = color
2222

2323
def __str__(self):
24-
return "[Func (%s) -> (%s) [%s; %s] / %s - %s]" % (self.var, self.expr, self.start, self.end, self.step, self.color)
24+
return "[Func (%s) -> (%s) [%s; %s] / %s - %s]" % (
25+
self.var, self.expr, self.start, self.end, self.step, self.color)
2526

2627
def __repr__(self):
2728
return "GFuncStmt(%r, %r, %r, %r, %r, %r)" % (self.var, self.expr, self.start, self.end, self.step, self.color)
@@ -30,7 +31,8 @@ def get_function(self) -> LambdaNode:
3031
return LambdaNode([self.var], self.expr)
3132

3233
def python(self) -> List[str]:
33-
return ["g_func(%s)" % ", ".join(x.python() for x in (self.get_function(), self.start, self.end, self.step, self.color))]
34+
return ["g_func(%s)" % ", ".join(
35+
x.python() for x in (self.get_function(), self.start, self.end, self.step, self.color))]
3436

3537
def get_children(self) -> List[AstNode]:
3638
return [x for c in (self.expr, self.start, self.end, self.step, self.color) for x in c.flatten()]

src/algo/worker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# -*- coding: utf-8 -*-
2+
import time
23
import typing
34
from collections import Iterable
45
from typing import Union
56

6-
import time
7-
87
from algo.stmts import *
98
from maths.evaluator import Evaluator
109
from maths.nodes import *

src/forms/alg_gfunc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
from forms.inline_code_dialog import InlineCodeDialog
77
from forms.ui_alg_gfunc import Ui_AlgoGFuncStmt
8-
from maths.parser import quick_parse as parse
98
from maths.nodes import *
9+
from maths.parser import quick_parse as parse
1010
from util.code import try_parse
1111
from util.widgets import center_widget, get_themed_box
1212

src/main.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
settings: QSettings = None
106106
recent_actions = None
107107

108+
108109
def sleep(duration):
109110
duration *= 1000
110111
begin = datetime.datetime.now()
@@ -575,6 +576,7 @@ def breakpoint_message(message=""):
575576
"red"))
576577
update_output()
577578

579+
578580
def python_breakpoint(message=""):
579581
global after_output
580582
breakpoint_message(message)
@@ -902,7 +904,8 @@ def handler_New():
902904
msg.setIcon(QMessageBox.Question)
903905
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
904906
msg.setDefaultButton(QMessageBox.No)
905-
msg.setText(translate("MainWindow", "Do you really want to create a new file?\nAll unsaved changes will be lost."))
907+
msg.setText(
908+
translate("MainWindow", "Do you really want to create a new file?\nAll unsaved changes will be lost."))
906909
msg.adjustSize()
907910
center_widget(msg, window)
908911
if msg.exec_() != QMessageBox.Yes:
@@ -916,10 +919,10 @@ def handler_New():
916919

917920

918921
def handler_ZoomIn():
919-
if mode_python:
920-
code_editor.zoom_in()
921-
else:
922-
set_algo_size(ui.treeWidget.font().pointSize() + 1)
922+
if mode_python:
923+
code_editor.zoom_in()
924+
else:
925+
set_algo_size(ui.treeWidget.font().pointSize() + 1)
923926

924927

925928
def handler_ZoomOut():
@@ -962,7 +965,6 @@ def copy_action(source: QAction, target: QAction):
962965
target.triggered.connect(source.trigger)
963966

964967

965-
966968
def change_language(language: str):
967969
available = [x.statusTip() for x in ui.menuLanguage.actions()]
968970
if language not in available and util.get_short_lang(language) not in available:
@@ -1249,8 +1251,8 @@ def add_gwindow():
12491251
dlg = alg_gwindow.AlgoGWindowStmt(window)
12501252
if dlg.run():
12511253
append_line(GWindowStmt(dlg.f_x_min, dlg.f_x_max, dlg.f_y_min, dlg.f_y_max, dlg.f_x_grad, dlg.f_y_grad))
1252-
1253-
1254+
1255+
12541256
def add_gfunc():
12551257
from forms import alg_gfunc
12561258
dlg = alg_gfunc.AlgoGFuncStmt(window)
@@ -1271,8 +1273,8 @@ def add_stop_stmt():
12711273
dlg = alg_stop.AlgoStopStmt(window)
12721274
if dlg.run():
12731275
append_line(StopStmt(dlg.expr))
1274-
1275-
1276+
1277+
12761278
def add_sleep_stmt():
12771279
from forms import alg_sleep
12781280
dlg = alg_sleep.AlgoSleepStmt(window)
@@ -1342,13 +1344,13 @@ def btn_edit_line():
13421344
dlg = alg_return.AlgoReturnStmt(window, stmt.value.code() if stmt.value is not None else None)
13431345
if dlg.run():
13441346
stmt.value = dlg.expr
1345-
1347+
13461348
elif isinstance(stmt, StopStmt):
13471349
from forms import alg_stop
13481350
dlg = alg_stop.AlgoStopStmt(window, stmt.message.code() if stmt.message is not None else None)
13491351
if dlg.run():
13501352
stmt.message = dlg.expr
1351-
1353+
13521354
elif isinstance(stmt, SleepStmt):
13531355
from forms import alg_sleep
13541356
dlg = alg_sleep.AlgoSleepStmt(window, stmt.duration.code())
@@ -1432,7 +1434,8 @@ def btn_edit_line():
14321434

14331435
elif isinstance(stmt, GFuncStmt):
14341436
from forms import alg_gfunc
1435-
dlg = alg_gfunc.AlgoGFuncStmt(window, (stmt.var, stmt.expr.code(), stmt.start.code(), stmt.end.code(), stmt.step.code(), stmt.color.code()))
1437+
dlg = alg_gfunc.AlgoGFuncStmt(window, (
1438+
stmt.var, stmt.expr.code(), stmt.start.code(), stmt.end.code(), stmt.step.code(), stmt.color.code()))
14361439
if dlg.run():
14371440
stmt.var = dlg.f_variable
14381441
stmt.expr = dlg.f_function
@@ -1711,7 +1714,8 @@ def str_stmt(stmt):
17111714
)
17121715

17131716
elif isinstance(stmt, GFuncStmt):
1714-
ret = translate("Algo", "[k]PLOT FUNCTION[/k] [c]{color}[/c] [i]f[/i]({var}) = [c]{expr}[/c] [k]FROM[/k] [c]{begin}[/c] [k]TO[/k] [c]{end}[/c] [k]STEP[/k] [c]{step}[/c]").format(
1717+
ret = translate("Algo",
1718+
"[k]PLOT FUNCTION[/k] [c]{color}[/c] [i]f[/i]({var}) = [c]{expr}[/c] [k]FROM[/k] [c]{begin}[/c] [k]TO[/k] [c]{end}[/c] [k]STEP[/k] [c]{step}[/c]").format(
17151719
color=code(stmt.color),
17161720
var=stmt.var,
17171721
expr=code(stmt.expr),
@@ -1865,7 +1869,8 @@ def algo_sel_changed():
18651869
for p in current:
18661870
parent_stack.append(parent_stack[-1].children[p])
18671871

1868-
existing_else = current[-1] + 1 < len(parent_stack[-2].children) and isinstance(parent_stack[-2].children[current[-1] + 1], ElseStmt)
1872+
existing_else = current[-1] + 1 < len(parent_stack[-2].children) and isinstance(
1873+
parent_stack[-2].children[current[-1] + 1], ElseStmt)
18691874

18701875
ui.btnAlgo_Else.setEnabled(isinstance(current_stmt, IfStmt) and not existing_else)
18711876

@@ -2062,7 +2067,7 @@ def version_check():
20622067
if __name__ == "__main__":
20632068
sys.excepthook = except_hook
20642069
setup_thread_excepthook()
2065-
#global app, settings
2070+
# global app, settings
20662071
app = QApplication(sys.argv)
20672072
app.setApplicationName("Turing")
20682073
app.setApplicationVersion(__version__)
@@ -2078,7 +2083,6 @@ def version_check():
20782083
font = QFont("Segoe UI", 9)
20792084
app.setFont(font)
20802085

2081-
import turing_rc
20822086
splash = QSplashScreen(QPixmap(":/icon/media/icon_128.png"), Qt.WindowStaysOnTopHint)
20832087
splash.show()
20842088
app.processEvents()

src/maths/lib/trig.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import cmath
4-
53
from maths.lib import basic
64
from util import translate
75
from util.math import mod, mods

src/util/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def flatten(lst: Iterable) -> List:
2828
def get_short_lang(lang):
2929
if "_" not in lang:
3030
return lang
31-
return lang[0:lang.index("_")]
31+
return lang[0:lang.index("_")]

src/util/math.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,17 @@ def check_type(obj: Any, typ: str) -> bool:
218218

219219
raise ValueError("unknown type %s" % typ)
220220

221+
221222
def mod(x):
222223
import cmath, math
223224
return cmath if type(x) == complex else math
224225

226+
225227
def modn(x):
226228
import cmath, math
227229
return cmath if type(x) == complex or x < 0 else math
228230

231+
229232
def mods(x, b):
230233
import cmath, math
231-
return cmath if type(x) == complex or abs(x) > b else math
234+
return cmath if type(x) == complex or abs(x) > b else math

src/util/widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ def set_font_size(wgt, size, index=None):
5050
if index is None:
5151
wgt.setFont(result)
5252
else:
53-
wgt.setFont(index, result)
53+
wgt.setFont(index, result)

0 commit comments

Comments
 (0)