From 87ec1117432dd6ba8fdd325452d17534184ad5e0 2009-08-02 03:26:07 From: Fernando Perez Date: 2009-08-02 03:26:07 Subject: [PATCH] Cleanup check_sources and remove hard tabs from some files. Improved and documented the check_sources script, and after running it, used untabify to cleanup the files where it reported hard tabs. --- diff --git a/IPython/frontend/cocoa/plugin/setup.py b/IPython/frontend/cocoa/plugin/setup.py index 8393085..11fdd25 100644 --- a/IPython/frontend/cocoa/plugin/setup.py +++ b/IPython/frontend/cocoa/plugin/setup.py @@ -19,17 +19,17 @@ __docformat__ = "restructuredtext en" from setuptools import setup infoPlist = dict( - CFBundleDevelopmentRegion='English', - CFBundleIdentifier='org.scipy.ipython.cocoa_frontend', - NSPrincipalClass='IPythonCocoaController', + CFBundleDevelopmentRegion='English', + CFBundleIdentifier='org.scipy.ipython.cocoa_frontend', + NSPrincipalClass='IPythonCocoaController', ) setup( - plugin=['IPythonCocoaFrontendLoader.py'], + plugin=['IPythonCocoaFrontendLoader.py'], setup_requires=['py2app'], - options=dict(py2app=dict( - plist=infoPlist, - site_packages=True, - excludes=['IPython','twisted','PyObjCTools'] - )), + options=dict(py2app=dict( + plist=infoPlist, + site_packages=True, + excludes=['IPython','twisted','PyObjCTools'] + )), ) \ No newline at end of file diff --git a/IPython/gui/wx/ipshell_nonblocking.py b/IPython/gui/wx/ipshell_nonblocking.py index def47c5..63b8086 100644 --- a/IPython/gui/wx/ipshell_nonblocking.py +++ b/IPython/gui/wx/ipshell_nonblocking.py @@ -44,7 +44,7 @@ class _Helper(object): def __call__(self, *args, **kwds): class DummyWriter(object): - '''Dumy class to handle help output''' + '''Dumy class to handle help output''' def __init__(self, pager): self._pager = pager diff --git a/IPython/gui/wx/ipython_view.py b/IPython/gui/wx/ipython_view.py old mode 100755 new mode 100644 index 2319b28..2fc44c3 --- a/IPython/gui/wx/ipython_view.py +++ b/IPython/gui/wx/ipython_view.py @@ -76,12 +76,12 @@ class WxNonBlockingIPShell(NonBlockingIPShell): """ A replacement from python's raw_input. """ self.answer = None - if(self._threading == True): - wx.CallAfter(self._yesNoBox, prompt) - while self.answer is None: - time.sleep(.1) + if(self._threading == True): + wx.CallAfter(self._yesNoBox, prompt) + while self.answer is None: + time.sleep(.1) else: - self._yesNoBox(prompt) + self._yesNoBox(prompt) return self.answer def _yesNoBox(self, prompt): diff --git a/IPython/hooks.py b/IPython/hooks.py index a8481aa..6e07079 100644 --- a/IPython/hooks.py +++ b/IPython/hooks.py @@ -111,7 +111,7 @@ def fix_error_editor(self,filename,linenum,column,msg): # vds: >> def synchronize_with_editor(self, filename, linenum, column): - pass + pass # vds: << class CommandChainDispatcher: diff --git a/IPython/testing/decorators_numpy.py b/IPython/testing/decorators_numpy.py index 792dd00..540f3c7 100644 --- a/IPython/testing/decorators_numpy.py +++ b/IPython/testing/decorators_numpy.py @@ -45,10 +45,10 @@ def skipif(skip_condition=True, msg=None): Parameters ---------- skip_condition : bool or callable. - Flag to determine whether to skip test. If the condition is a - callable, it is used at runtime to dynamically make the decision. This - is useful for tests that may require costly imports, to delay the cost - until the test suite is actually executed. + Flag to determine whether to skip test. If the condition is a + callable, it is used at runtime to dynamically make the decision. This + is useful for tests that may require costly imports, to delay the cost + until the test suite is actually executed. msg : string Message to give on raising a SkipTest exception diff --git a/IPython/testing/util.py b/IPython/testing/util.py index 7036650..5c4253f 100644 --- a/IPython/testing/util.py +++ b/IPython/testing/util.py @@ -21,7 +21,7 @@ from twisted.internet import defer class DeferredTestCase(unittest.TestCase): def assertDeferredEquals(self, deferred, expectedResult, - chainDeferred=None): + chainDeferred=None): """Calls assertEquals on the result of the deferred and expectedResult. chainDeferred can be used to pass in previous Deferred objects that @@ -32,7 +32,7 @@ class DeferredTestCase(unittest.TestCase): if chainDeferred is None: chainDeferred = defer.succeed(None) - + def gotResult(actualResult): self.assertEquals(actualResult, expectedResult) @@ -41,7 +41,7 @@ class DeferredTestCase(unittest.TestCase): return chainDeferred.addCallback(lambda _: deferred) def assertDeferredRaises(self, deferred, expectedException, - chainDeferred=None): + chainDeferred=None): """Calls assertRaises on the Failure of the deferred and expectedException. chainDeferred can be used to pass in previous Deferred objects that diff --git a/tools/check_sources.py b/tools/check_sources.py index 5dcf861..5b64c6e 100755 --- a/tools/check_sources.py +++ b/tools/check_sources.py @@ -1,18 +1,32 @@ #!/usr/bin/env python """Utility to look for hard tabs and \r characters in all sources. + +Usage: + +./check_sources.py + +It prints summaries and if chosen, line-by-line info of where \\t or \\r +characters can be found in our source tree. """ -from IPython.external.path import path +# Config +# If true, all lines that have tabs are printed, with line number +full_report_tabs = True +# If true, all lines that have tabs are printed, with line number +full_report_rets = False -fs = path('..').walkfiles('*.py') +# Code begins +from IPython.external.path import path rets = [] +tabs = [] -for f in fs: +for f in path('..').walkfiles('*.py'): errs = '' cont = f.bytes() if '\t' in cont: errs+='t' + tabs.append(f) if '\r' in cont: errs+='r' @@ -20,13 +34,21 @@ for f in fs: if errs: print "%3s" % errs, f - if 't' in errs: - for ln,line in enumerate(f.lines()): - if '\t' in line: - print 'TAB:',ln,':',line, - if 'r' in errs: - for ln,line in enumerate(open(f.abspath(),'rb')): - if '\r' in line: - print 'RET:',ln,':',line, - -rr = rets[-1] + + if 't' in errs and full_report_tabs: + for ln,line in enumerate(f.lines()): + if '\t' in line: + print 'TAB:',ln,':',line, + + if 'r' in errs and full_report_rets: + for ln,line in enumerate(open(f.abspath(),'rb')): + if '\r' in line: + print 'RET:',ln,':',line, + +# Summary at the end, to call cleanup tools if necessary +if tabs: + print 'Hard tabs found. These can be cleaned with untabify:' + for f in tabs: print f, +if rets: + print 'Carriage returns (\\r) found in:' + for f in rets: print f,