Skip to content

Commit b941e9e

Browse files
committed
Fix unused variables reported by pyflakes.
Delete or comment-out unused variables. If plausibly useful, add dummy assertions to silence pyflakes.
1 parent 113133c commit b941e9e

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

diffpy/pdfgui/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@
2020

2121
from diffpy.pdfgui.version import __version__
2222

23+
# silence the pyflakes syntax checker
24+
assert __version__
25+
2326
# End of file

diffpy/pdfgui/bugreport.py

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def submitBugReport(formfields):
9696
post_request = urllib2.Request(post_url, post_content, post_headers)
9797
post_handle = opener.open(post_request)
9898
# result can be obtained by post_handle.read(), but it is not needed
99+
# silence the pyflakes syntax checker
100+
assert post_handle or True
99101
return
100102

101103

diffpy/pdfgui/control/constraint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __setattr__(self, name, value):
130130
fncx = eval('lambda x:' +
131131
re.sub('@\d+', 'x', newformula), vars(math))
132132
# check if fncx(0.25) is float
133-
y = fncx(0.25) + 0.0
133+
fncx(0.25) + 0.0
134134
except (ValueError, SyntaxError, TypeError, NameError):
135135
message = "invalid constraint formula '%s'" % newformula
136136
raise ControlSyntaxError, message

diffpy/pdfgui/control/pdffitsandbox.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def setphase(self, ip):
639639
IndexError if phase ip does not exist
640640
"""
641641
# check if we have valid index
642-
curphase = self._fits[-1].strucs[ip - 1]
642+
self._fits[-1].strucs[ip - 1]
643643
# if we get here, it is OK
644644
self._curphase = ip - 1
645645
return
@@ -653,7 +653,7 @@ def setdata(self, iset):
653653
IndexError if dataset iset does not exist
654654
"""
655655
# check if we have valid index
656-
curdataset = self._fits[-1].datasets[iset - 1]
656+
self._fits[-1].datasets[iset - 1]
657657
# if we get here, it is OK
658658
self._curdataset = iset - 1
659659
return

diffpy/pdfgui/gui/aboutdialog.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,8 @@ def __init__(self, *args, **kwds):
133133
self.bitmap_button_columbia.SetBitmapLabel(logo)
134134

135135
# resize dialog window to fit version number nicely
136-
if wx.VERSION >= (2,7,2,0):
137-
size = [self.GetEffectiveMinSize()[0], self.GetSize()[1]]
138-
else:
139-
size = [self.GetBestFittingSize()[0], self.GetSize()[1]]
140-
141136
self.Fit()
142-
# self.SetSize(size)
143-
# self.FitInside()
137+
return
144138

145139

146140
def __set_properties(self):

diffpy/pdfgui/gui/mainframe.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,8 @@ def onBeginLabelEdit(self, event): # wxGlade: MainPanel.<event_handler>
11681168
* Editing any item in "addingdata", "addingphase", or "config" mode.
11691169
"""
11701170
nodetype = self.treeCtrlMain.GetNodeType(event.GetItem())
1171+
# silence the pyflakes syntax checker
1172+
assert nodetype or True
11711173
if self.mode != "fitting":
11721174
event.Veto()
11731175
return
@@ -1233,6 +1235,8 @@ def onRightClick(self, event): # wxGlade: MainPanel.<event_handler>
12331235
if selections:
12341236
node = self.treeCtrlMain.GetFitRoot(selections[0])
12351237
nodetype = self.treeCtrlMain.GetNodeType(node)
1238+
# silence the pyflakes syntax checker
1239+
assert nodetype or True
12361240
if node in self.runningDict.values():
12371241
return
12381242

@@ -1271,6 +1275,8 @@ def onRightClick(self, event): # wxGlade: MainPanel.<event_handler>
12711275
self.treeCtrlMain.SelectItem(node)
12721276
selections = [node]
12731277
itemtype = self.treeCtrlMain.GetNodeType(node)
1278+
# silence the pyflakes syntax checker
1279+
assert itemtype or True
12741280
# Enable/Disable certain entries based upon where we clicked.
12751281
self.disableSharedMenuItems(menu)
12761282

@@ -1967,7 +1973,7 @@ def _plotStruct(self, stype):
19671973
node = selections[0]
19681974
itemtype = self.treeCtrlMain.GetNodeType(node)
19691975
if itemtype == "phase":
1970-
panel = self.dynamicPanels['phase']
1976+
# panel = self.dynamicPanels['phase']
19711977
cdata = self.treeCtrlMain.GetControlData(node)
19721978
stru = getattr(cdata, stype)
19731979
viewer = structureviewer.getStructureViewer()
@@ -1983,7 +1989,7 @@ def onPrintBL(self, event):
19831989
node = selections[0]
19841990
itemtype = self.treeCtrlMain.GetNodeType(node)
19851991
if itemtype == "phase":
1986-
panel = self.dynamicPanels['phase']
1992+
# panel = self.dynamicPanels['phase']
19871993
cdata = self.treeCtrlMain.GetControlData(node)
19881994
S = cdata.refined
19891995
if not S: S = cdata.initial
@@ -2026,7 +2032,7 @@ def onPrintBA(self, event):
20262032
node = selections[0]
20272033
itemtype = self.treeCtrlMain.GetNodeType(node)
20282034
if itemtype == "phase":
2029-
panel = self.dynamicPanels['phase']
2035+
# panel = self.dynamicPanels['phase']
20302036
cdata = self.treeCtrlMain.GetControlData(node)
20312037
S = cdata.refined
20322038
if not S: S = cdata.initial
@@ -2296,7 +2302,7 @@ def onExportNewStruct(self, event):
22962302
nodetype = self.treeCtrlMain.GetNodeType(node)
22972303
if nodetype != 'phase': return
22982304
cdata = self.treeCtrlMain.GetControlData(node)
2299-
branchname = self.treeCtrlMain.GetBranchName(node)
2305+
# branchname = self.treeCtrlMain.GetBranchName(node)
23002306
name = self.treeCtrlMain.GetItemText(node)
23012307
basename = '.'.join(name.split('.')[:-1]) or name
23022308
matchstring = "PDFfit structure file (*.stru)|*.stru|Crystallographic Information File (*.cif)|*.cif|Protein Data Bank file (*.pdb)|*.pdb|Labeled coordinate file (*.xyz)|*.xyz|Raw corrdinate file (*.xyz)|*.xyz|AtomEye configuration file|*"
@@ -2328,7 +2334,7 @@ def onExportStruct(self, event):
23282334
nodetype = self.treeCtrlMain.GetNodeType(node)
23292335
if nodetype != 'phase': return
23302336
cdata = self.treeCtrlMain.GetControlData(node)
2331-
branchname = self.treeCtrlMain.GetBranchName(node)
2337+
# branchname = self.treeCtrlMain.GetBranchName(node)
23322338
name = self.treeCtrlMain.GetItemText(node)
23332339
basename = '.'.join(name.split('.')[:-1]) or name
23342340
matchstring = "PDFfit structure file (*.stru)|*.stru|Crystallographic Information File (*.cif)|*.cif|Protein Data Bank file (*.pdb)|*.pdb|Labeled coordinate file (*.xyz)|*.xyz|Raw corrdinate file (*.xyz)|*.xyz|AtomEye configuration file|*"
@@ -2358,7 +2364,7 @@ def onExportPDF(self, event):
23582364
nodetype = self.treeCtrlMain.GetNodeType(node)
23592365
if nodetype != 'dataset': return
23602366
cdata = self.treeCtrlMain.GetControlData(node)
2361-
branchname = self.treeCtrlMain.GetBranchName(node)
2367+
# branchname = self.treeCtrlMain.GetBranchName(node)
23622368
name = self.treeCtrlMain.GetItemText(node)
23632369
basename = '.'.join(name.split('.')[:-1]) or name
23642370
matchstring = "PDF fit data file (*.fgr)|*.fgr|All Files|*"

diffpy/pdfgui/gui/phasenotebookpanel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def refresh(self):
8989

9090
def onNotebookPageChanging(self, event):
9191
"""Called during the page selection change."""
92-
focusedId = event.GetOldSelection()
92+
# focusedId = event.GetOldSelection()
9393
panel = self.notebook_phase.GetPage(self.focusedId)
9494
panel._cache()
9595
return

0 commit comments

Comments
 (0)