Commit 883adcb4 authored by Guillaume Seguin's avatar Guillaume Seguin

Code cleanup. No more if( !

parent 7abe770d
......@@ -266,7 +266,7 @@ class Plater(wx.Frame):
def export(self, event):
dlg = wx.FileDialog(self, _("Pick file to save to"), self.basedir, style = wx.FD_SAVE)
dlg.SetWildcard(self.save_wildcard)
if(dlg.ShowModal() == wx.ID_OK):
if dlg.ShowModal() == wx.ID_OK:
name = dlg.GetPath()
self.export_to(name)
dlg.Destroy()
......
......@@ -94,7 +94,7 @@ class showstl(wx.Window):
def move(self, event):
if event.ButtonUp(wx.MOUSE_BTN_LEFT):
if(self.initpos is not None):
if self.initpos is not None:
currentpos = event.GetPositionTuple()
delta = (0.5 * (currentpos[0] - self.initpos[0]),
-0.5 * (currentpos[1] - self.initpos[1])
......
......@@ -575,7 +575,7 @@ class SettingsFrame(wx.Frame):
def load_file(self, event):
dlg = wx.FileDialog(self, ("Open file to print"), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard(("Slic3r or Skeinforge svg files (;*.svg;*.SVG;);3DLP Zip (;*.3dlp.zip;)"))
if(dlg.ShowModal() == wx.ID_OK):
if dlg.ShowModal() == wx.ID_OK:
name = dlg.GetPath()
if not(os.path.exists(name)):
self.status.SetStatusText(("File not found!"))
......
......@@ -711,7 +711,7 @@ class pronsole(cmd.Cmd):
def complete_macro(self, text, line, begidx, endidx):
if (len(line.split()) == 2 and line[-1] != " ") or (len(line.split()) == 1 and line[-1] == " "):
return [i for i in self.macros.keys() if i.startswith(text)]
elif(len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " ")):
elif len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " "):
return [i for i in ["/D", "/S"] + self.completenames(text) if i.startswith(text)]
else:
return []
......@@ -883,7 +883,7 @@ class pronsole(cmd.Cmd):
def complete_set(self, text, line, begidx, endidx):
if (len(line.split()) == 2 and line[-1] != " ") or (len(line.split()) == 1 and line[-1] == " "):
return [i for i in dir(self.settings) if not i.startswith("_") and i.startswith(text)]
elif(len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " ")):
elif len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " "):
return [i for i in self.settings._tabcomplete(line.split()[1]) if i.startswith(text)]
else:
return []
......@@ -1071,7 +1071,7 @@ class pronsole(cmd.Cmd):
self.log("connect <port> <baudrate>")
self.log("If port and baudrate are not specified, connects to first detected port at 115200bps")
ports = self.scanserial()
if(len(ports)):
if ports:
self.log("Available ports: ", " ".join(ports))
else:
self.log("No serial ports were automatically found.")
......@@ -1079,7 +1079,7 @@ class pronsole(cmd.Cmd):
def complete_connect(self, text, line, begidx, endidx):
if (len(line.split()) == 2 and line[-1] != " ") or (len(line.split()) == 1 and line[-1] == " "):
return [i for i in self.scanserial() if i.startswith(text)]
elif(len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " ")):
elif len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " "):
return [i for i in ["2400", "9600", "19200", "38400", "57600", "115200"] if i.startswith(text)]
else:
return []
......@@ -1658,7 +1658,7 @@ class pronsole(cmd.Cmd):
self.log(_("Switches to the specified tool (e.g. doing tool 1 will emit a T1 G-Code)."))
def do_move(self, l):
if(len(l.split()) < 2):
if len(l.split()) < 2:
self.logError(_("No move specified."))
return
if self.p.printing:
......@@ -1668,16 +1668,16 @@ class pronsole(cmd.Cmd):
self.logError(_("Printer is not online. Unable to move."))
return
l = l.split()
if(l[0].lower() == "x"):
if l[0].lower() == "x":
feed = self.settings.xy_feedrate
axis = "X"
elif(l[0].lower() == "y"):
elif l[0].lower() == "y":
feed = self.settings.xy_feedrate
axis = "Y"
elif(l[0].lower() == "z"):
elif l[0].lower() == "z":
feed = self.settings.z_feedrate
axis = "Z"
elif(l[0].lower() == "e"):
elif l[0].lower() == "e":
feed = self.settings.e_feedrate
axis = "E"
else:
......@@ -1706,7 +1706,7 @@ class pronsole(cmd.Cmd):
def complete_move(self, text, line, begidx, endidx):
if (len(line.split()) == 2 and line[-1] != " ") or (len(line.split()) == 1 and line[-1] == " "):
return [i for i in ["X ", "Y ", "Z ", "E "] if i.lower().startswith(text)]
elif(len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " ")):
elif len(line.split()) == 3 or (len(line.split()) == 2 and line[-1] == " "):
base = line.split()[-1]
rlen = 0
if base.startswith("-"):
......
......@@ -1200,7 +1200,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
def filesloaded(self):
dlg = wx.SingleChoiceDialog(self, _("Select the file to print"), _("Pick SD file"), self.sdfiles)
if(dlg.ShowModal() == wx.ID_OK):
if dlg.ShowModal() == wx.ID_OK:
target = dlg.GetStringSelection()
if len(target):
self.recvlisteners.append(self.waitforsdresponse)
......
......@@ -232,12 +232,12 @@ if __name__ == "__main__":
for i in xrange(11, 11):
working = s.facets[:]
for j in reversed(sorted(s.facetsminz)):
if(j[0] > i):
if j[0] > i:
working.remove(j[1])
else:
break
for j in (sorted(s.facetsmaxz)):
if(j[0] < i):
if j[0] < i:
working.remove(j[1])
else:
break
......
......@@ -233,7 +233,7 @@ class StlViewPanel(wxGLPanel):
time.sleep(dt)
obj.offsets[2] -= v * dt
v += g * dt
if(obj.offsets[2] < 0):
if obj.offsets[2] < 0:
obj.scale[2] *= 1 - 3 * dt
#return
v = v / 4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment