Skip to content

Commit 8df6649

Browse files
committed
Format, white-space .py files
1 parent f41cf63 commit 8df6649

32 files changed

+584
-1120
lines changed

demo/helloform.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
# ===========================================================================
2-
# This software is subject to the provisions of the Zope Public License,
3-
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
# FOR A PARTICULAR PURPOSE.
8-
# ===========================================================================
9-
101
import clr
2+
113
SWF = clr.AddReference("System.Windows.Forms")
124
print (SWF.Location)
135
import System.Windows.Forms as WinForms
@@ -31,7 +23,7 @@ def __init__(self):
3123
self.button.Size = Size(820, 20)
3224
self.button.TabIndex = 2
3325
self.button.Text = "Click Me!"
34-
26+
3527
# Register the event handler
3628
self.button.Click += self.button_Click
3729

@@ -41,7 +33,7 @@ def __init__(self):
4133
self.textbox.TabIndex = 1
4234
self.textbox.Size = Size(1260, 40)
4335
self.textbox.Location = Point(160, 24)
44-
36+
4537
# Add the controls to the form
4638
self.AcceptButton = self.button
4739
self.Controls.Add(self.button);
@@ -66,4 +58,3 @@ def main():
6658

6759
if __name__ == '__main__':
6860
main()
69-

demo/splitter.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# ===========================================================================
2-
# This software is subject to the provisions of the Zope Public License,
3-
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
# FOR A PARTICULAR PURPOSE.
8-
# ===========================================================================
9-
101
import clr
112
import System.Windows.Forms as WinForms
123
from System.Drawing import Color, Size, Point
@@ -28,7 +19,6 @@ def __init__(self):
2819
self.splitter2 = WinForms.Splitter()
2920
self.panel1 = WinForms.Panel()
3021

31-
3222
# Set properties of TreeView control.
3323
self.treeView1.Dock = WinForms.DockStyle.Left
3424
self.treeView1.Width = self.ClientSize.Width / 3
@@ -48,14 +38,14 @@ def __init__(self):
4838

4939
# Set properties of Panel's Splitter control.
5040
self.splitter2.Dock = WinForms.DockStyle.Top
51-
41+
5242
# Width is irrelevant if splitter is docked to Top.
5343
self.splitter2.Height = 3
54-
44+
5545
# Use a different color to distinguish the two splitters.
5646
self.splitter2.BackColor = Color.Blue
5747
self.splitter2.TabIndex = 1
58-
48+
5949
# Set TabStop to false for ease of use when negotiating UI.
6050
self.splitter2.TabStop = 0
6151

@@ -67,7 +57,7 @@ def __init__(self):
6757

6858
# Set TabStop to false for ease of use when negotiating UI.
6959
self.splitter1.TabStop = 0
70-
60+
7161
# Add the appropriate controls to the Panel.
7262
for item in (self.richTextBox1, self.splitter2, self.listView1):
7363
self.panel1.Controls.Add(item)
@@ -87,12 +77,11 @@ def Dispose(self):
8777
WinForms.Form.Dispose(self)
8878

8979

90-
9180
def main():
9281
app = Splitter()
9382
WinForms.Application.Run(app)
9483
app.Dispose()
9584

85+
9686
if __name__ == '__main__':
9787
main()
98-

demo/wordpad.py

+12-36
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# ===========================================================================
2-
# This software is subject to the provisions of the Zope Public License,
3-
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
# FOR A PARTICULAR PURPOSE.
8-
# ===========================================================================
9-
101
import clr
112
import System.Windows.Forms as WinForms
123
from System.Threading import Thread, ThreadStart, ApartmentState
@@ -60,18 +51,16 @@ def InitializeComponent(self):
6051
self.aboutMenu = WinForms.MenuItem()
6152
self.menuHelpAbout = WinForms.MenuItem()
6253

63-
6454
self.richTextBox = WinForms.RichTextBox()
6555
self.statusBarPanel1 = WinForms.StatusBarPanel()
6656
self.statusBar = WinForms.StatusBar()
6757
self.fontDialog = WinForms.FontDialog()
6858
self.statusBarPanel1.BeginInit()
6959

70-
7160
# ===================================================================
7261
# File Menu
7362
# ===================================================================
74-
63+
7564
self.menuFileNew.Text = "&New"
7665
self.menuFileNew.Shortcut = WinForms.Shortcut.CtrlN
7766
self.menuFileNew.ShowShortcut = False
@@ -83,7 +72,7 @@ def InitializeComponent(self):
8372
self.menuFileOpen.ShowShortcut = False
8473
self.menuFileOpen.Index = 1
8574
self.menuFileOpen.Click += self.OnClickFileOpen
86-
75+
8776
self.menuFileSave.Text = "&Save"
8877
self.menuFileSave.Shortcut = WinForms.Shortcut.CtrlS
8978
self.menuFileSave.ShowShortcut = False
@@ -112,7 +101,6 @@ def InitializeComponent(self):
112101

113102
self.fileMenu.MenuItems.AddRange(items)
114103

115-
116104
# ===================================================================
117105
# Edit menu
118106
# ===================================================================
@@ -134,7 +122,7 @@ def InitializeComponent(self):
134122
self.menuEditCut.Shortcut = WinForms.Shortcut.CtrlX
135123
self.menuEditCut.Index = 3
136124
self.menuEditCut.Click += self.OnClickEditCut
137-
125+
138126
self.menuEditCopy.Text = "Copy"
139127
self.menuEditCopy.Shortcut = WinForms.Shortcut.CtrlC
140128
self.menuEditCopy.Index = 4
@@ -163,7 +151,6 @@ def InitializeComponent(self):
163151

164152
self.editMenu.MenuItems.AddRange(items)
165153

166-
167154
# ===================================================================
168155
# Format Menu
169156
# ===================================================================
@@ -184,11 +171,10 @@ def InitializeComponent(self):
184171

185172
self.formatMenu.MenuItems.AddRange(items)
186173

187-
188174
# ===================================================================
189175
# About menu
190176
# ===================================================================
191-
177+
192178
self.menuHelpAbout.Text = "&About"
193179
self.menuHelpAbout.Index = 0
194180
self.menuHelpAbout.Click += self.OnClickHelpAbout
@@ -210,19 +196,16 @@ def InitializeComponent(self):
210196
self.richTextBox.AcceptsTab = 1
211197
self.richTextBox.Location = System.Drawing.Point(0, 0)
212198

213-
214199
self.statusBar.BackColor = System.Drawing.SystemColors.Control
215200
self.statusBar.Location = System.Drawing.Point(0, 518)
216201
self.statusBar.Size = System.Drawing.Size(775, 19)
217202
self.statusBar.TabIndex = 1
218203
self.statusBar.ShowPanels = True
219204
self.statusBar.Panels.Add(self.statusBarPanel1)
220205

221-
222206
items = (self.fileMenu, self.editMenu, self.formatMenu, self.aboutMenu)
223207
self.mainMenu.MenuItems.AddRange(items)
224208

225-
226209
self.openFileDialog.Filter = "Text documents|*.txt|RTF document|*.rtf"
227210
self.openFileDialog.Title = "Open document"
228211

@@ -231,7 +214,6 @@ def InitializeComponent(self):
231214
self.saveFileDialog.Title = "Save document"
232215
self.saveFileDialog.FileName = "Untitled"
233216

234-
235217
self.AutoScaleBaseSize = System.Drawing.Size(5, 13)
236218
self.ClientSize = System.Drawing.Size(775, 537)
237219
self.Menu = self.mainMenu
@@ -244,7 +226,6 @@ def InitializeComponent(self):
244226
def Dispose(self):
245227
self.components.Dispose()
246228
WinForms.Form.Dispose(self)
247-
248229

249230
def OnClickFileNew(self, sender, args):
250231
self.SaveChangesDialog()
@@ -265,7 +246,6 @@ def OnClickFileExit(self, sender, args):
265246
self.SaveChangesDialog()
266247
self.Close()
267248

268-
269249
def OnClickEditUndo(self, sender, args):
270250
self.richTextBox.Undo()
271251

@@ -284,7 +264,6 @@ def OnClickEditPaste(self, sender, args):
284264
def OnClickEditSelectAll(self, sender, args):
285265
self.richTextBox.SelectAll()
286266

287-
288267
def OnClickFormatWordWrap(self, sender, args):
289268
value = not self.word_wrap
290269
self.richTextBox.WordWrap = value
@@ -298,7 +277,6 @@ def OnClickFormatFont(self, sender, args):
298277
def OnClickHelpAbout(self, sender, args):
299278
AboutForm().ShowDialog(self)
300279

301-
302280
def NewDocument(self):
303281
self.doctype = 1
304282
self.richTextBox.Rtf = ''
@@ -327,7 +305,7 @@ def OpenDocument(self):
327305
stream.Close()
328306

329307
filename = self.filename = filename.lower()
330-
308+
331309
if filename.endswith('.rtf'):
332310
self.richTextBox.Rtf = data
333311
self.doctype = 2
@@ -345,10 +323,10 @@ def SaveDocument(self):
345323
if self.saveFileDialog.ShowDialog() != WinForms.DialogResult.OK:
346324
return
347325
filename = self.saveFileDialog.FileName
348-
326+
349327
filename = self.filename = filename.lower()
350328
self.Text = 'Python Wordpad - %s' % filename
351-
329+
352330
self.richTextBox.Select(0, 0)
353331

354332
stream = File.OpenWrite(filename)
@@ -366,17 +344,16 @@ def SaveDocument(self):
366344
def SaveChangesDialog(self):
367345
if self.richTextBox.Modified:
368346
if WinForms.MessageBox.Show(
369-
"Save changes?", "Word Pad",
370-
WinForms.MessageBoxButtons.OK |
371-
WinForms.MessageBoxButtons.YesNo
372-
) == WinForms.DialogResult.Yes:
347+
"Save changes?", "Word Pad",
348+
WinForms.MessageBoxButtons.OK |
349+
WinForms.MessageBoxButtons.YesNo
350+
) == WinForms.DialogResult.Yes:
373351
self.SaveDocument()
374352
return 1
375353
return 0
376354

377355

378356
class AboutForm(WinForms.Form):
379-
380357
def __init__(self):
381358
self.InitializeComponent()
382359

@@ -406,7 +383,7 @@ def InitializeComponent(self):
406383
self.ClientSize = System.Drawing.Size(300, 150)
407384

408385
self.Controls.AddRange((self.label1, self.btnClose))
409-
386+
410387
self.FormBorderStyle = WinForms.FormBorderStyle.FixedDialog
411388
self.MaximizeBox = 0
412389
self.MinimizeBox = 0
@@ -435,4 +412,3 @@ def main():
435412

436413
if __name__ == '__main__':
437414
main()
438-

setup.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False):
110110

111111

112112
class PythonNET_BuildExt(build_ext):
113-
114113
def build_extension(self, ext):
115114
"""
116115
Builds the .pyd file using msbuild or xbuild.
@@ -191,7 +190,7 @@ def build_extension(self, ext):
191190
self._build_monoclr(ext)
192191

193192
def _get_manifest(self, build_dir):
194-
if DEVTOOLS == "MsDev" and sys.version_info[:2] > (2,5):
193+
if DEVTOOLS == "MsDev" and sys.version_info[:2] > (2, 5):
195194
mt = _find_msbuild_tool("mt.exe", use_windows_sdk=True)
196195
manifest = os.path.abspath(os.path.join(build_dir, "app.manifest"))
197196
cmd = [mt, '-inputresource:"%s"' % sys.executable, '-out:"%s"' % manifest]
@@ -209,12 +208,12 @@ def _build_monoclr(self, ext):
209208

210209
# build the clr python module
211210
clr_ext = Extension("clr",
212-
sources=[
213-
"src/monoclr/pynetinit.c",
214-
"src/monoclr/clrmod.c"
215-
],
216-
extra_compile_args=cflags.split(" "),
217-
extra_link_args=libs.split(" "))
211+
sources=[
212+
"src/monoclr/pynetinit.c",
213+
"src/monoclr/clrmod.c"
214+
],
215+
extra_compile_args=cflags.split(" "),
216+
extra_link_args=libs.split(" "))
218217

219218
build_ext.build_extension(self, clr_ext)
220219

@@ -232,11 +231,10 @@ def _install_packages(self):
232231

233232

234233
class PythonNET_InstallLib(install_lib):
235-
236234
def install(self):
237235
if not os.path.isdir(self.build_dir):
238236
self.warn("'%s' does not exist -- no Python modules to install" %
239-
self.build_dir)
237+
self.build_dir)
240238
return
241239

242240
if not os.path.exists(self.install_dir):
@@ -249,7 +247,6 @@ def install(self):
249247

250248

251249
class PythonNET_InstallData(install_data):
252-
253250
def run(self):
254251
build_cmd = self.get_finalized_command("build_ext")
255252
install_cmd = self.get_finalized_command("install")
@@ -350,10 +347,9 @@ def _get_interop_filename():
350347
],
351348
zip_safe=False,
352349
cmdclass={
353-
"build_ext" : PythonNET_BuildExt,
354-
"install_lib" : PythonNET_InstallLib,
350+
"build_ext": PythonNET_BuildExt,
351+
"install_lib": PythonNET_InstallLib,
355352
"install_data": PythonNET_InstallData,
356353
},
357354
setup_requires=setup_requires
358355
)
359-

0 commit comments

Comments
 (0)