[PyMOL] Whitespacing?
During my editing of dynoplot.py, I noticed that there were some whitespace issues. Normally I consider whitespace a bikeshedding topic, but in python, it is significant, so it matters. When tabs and spaces are mixed, our own personal settings for how tabs are displayed in an editor makes a huge difference in whether the script is understandable. I checked out the git repo of pymol scripts ( http://github.com/jlec/Pymol-script-repo/ ) and did some analysis First, these files switch between some lines where all indenting is tabs to lines where all indenting is spaces: Objects_and_Selections/color_objects.py has 8 tab lines and 34 space lines ThirdParty_Scripts/WFMesh.py has 52 tab lines and 21 space lines biochemical_scripts/pucker.py has 167 tab lines and 5 space lines math_geo_cgo/modevectors.py has 160 tab lines and 2 space lines structural_biology_scripts/DynoPlot.py has 82 tab lines and 27 space lines structural_biology_scripts/Rotamers.py has 86 tab lines and 22 space lines structural_biology_scripts/kabsch.py has 51 tab lines and 4 space lines Second, there are files where the indenting inside a line switches back and forth (numbers are the counts of lines that have both tabs and spaces in indenting): Objects_and_Selections/color_objects.py: 19 ThirdParty_Scripts/WFMesh.py: 29 ThirdParty_Scripts/transform_odb.py: 6 math_geo_cgo/modevectors.py: 12 structural_biology_scripts/DynoPlot.py: 83 structural_biology_scripts/Rotamers.py: 86 structural_biology_scripts/kabsch.py: 1 I've tried using pindent.py ( http://svn.python.org/projects/python/trunk/Tools/scripts/pindent.py ) and PythonTidy ( http://pypi.python.org/pypi/PythonTidy/ ) to generally fix these, but they both run into problems. Is there a general solution out in the python world to automatically fix this? I don't care whether it produces tabs or spaces. I just want one or the other. If someone points me to something, I'm more than willing to run it on these scripts, push them back to github and copy them back onto the wiki. -David -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
Re: [PyMOL] Whitespacing?
David, Oh, the joys of open-source. Here's my solution for you: (1) load your file in your favorite editor (2) determine user-desired tab stop setting (3) convert all tabs to spaces in your editor (or search replace tabs with X-spaces) (4) save your file One warning though, I have seen some interpreters crash when they encounter spaces over tabs. -- Jason On Tue, Jan 26, 2010 at 9:12 AM, David Hall li...@cowsandmilk.net wrote: During my editing of dynoplot.py, I noticed that there were some whitespace issues. Normally I consider whitespace a bikeshedding topic, but in python, it is significant, so it matters. When tabs and spaces are mixed, our own personal settings for how tabs are displayed in an editor makes a huge difference in whether the script is understandable. I checked out the git repo of pymol scripts ( http://github.com/jlec/Pymol-script-repo/ ) and did some analysis First, these files switch between some lines where all indenting is tabs to lines where all indenting is spaces: Objects_and_Selections/color_objects.py has 8 tab lines and 34 space lines ThirdParty_Scripts/WFMesh.py has 52 tab lines and 21 space lines biochemical_scripts/pucker.py has 167 tab lines and 5 space lines math_geo_cgo/modevectors.py has 160 tab lines and 2 space lines structural_biology_scripts/DynoPlot.py has 82 tab lines and 27 space lines structural_biology_scripts/Rotamers.py has 86 tab lines and 22 space lines structural_biology_scripts/kabsch.py has 51 tab lines and 4 space lines Second, there are files where the indenting inside a line switches back and forth (numbers are the counts of lines that have both tabs and spaces in indenting): Objects_and_Selections/color_objects.py: 19 ThirdParty_Scripts/WFMesh.py: 29 ThirdParty_Scripts/transform_odb.py: 6 math_geo_cgo/modevectors.py: 12 structural_biology_scripts/DynoPlot.py: 83 structural_biology_scripts/Rotamers.py: 86 structural_biology_scripts/kabsch.py: 1 I've tried using pindent.py ( http://svn.python.org/projects/python/trunk/Tools/scripts/pindent.py ) and PythonTidy ( http://pypi.python.org/pypi/PythonTidy/ ) to generally fix these, but they both run into problems. Is there a general solution out in the python world to automatically fix this? I don't care whether it produces tabs or spaces. I just want one or the other. If someone points me to something, I'm more than willing to run it on these scripts, push them back to github and copy them back onto the wiki. -David -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
Re: [PyMOL] Whitespacing?
Not much of a help, but WingIDE Professional Edition has a very good indentation manager, which takes care of the mixed/space tab issues. If you are working in python frequently it is a worthwhile investment. Cheers, Carsten -Original Message- From: Jason Vertrees [mailto:jason.vertr...@schrodinger.com] Sent: Tuesday, January 26, 2010 10:10 AM To: David Hall Cc: pymol-users Subject: Re: [PyMOL] Whitespacing? David, Oh, the joys of open-source. Here's my solution for you: (1) load your file in your favorite editor (2) determine user-desired tab stop setting (3) convert all tabs to spaces in your editor (or search replace tabs with X-spaces) (4) save your file One warning though, I have seen some interpreters crash when they encounter spaces over tabs. -- Jason On Tue, Jan 26, 2010 at 9:12 AM, David Hall li...@cowsandmilk.net wrote: During my editing of dynoplot.py, I noticed that there were some whitespace issues. Normally I consider whitespace a bikeshedding topic, but in python, it is significant, so it matters. When tabs and spaces are mixed, our own personal settings for how tabs are displayed in an editor makes a huge difference in whether the script is understandable. I checked out the git repo of pymol scripts ( http://github.com/jlec/Pymol-script-repo/ ) and did some analysis First, these files switch between some lines where all indenting is tabs to lines where all indenting is spaces: Objects_and_Selections/color_objects.py has 8 tab lines and 34 space lines ThirdParty_Scripts/WFMesh.py has 52 tab lines and 21 space lines biochemical_scripts/pucker.py has 167 tab lines and 5 space lines math_geo_cgo/modevectors.py has 160 tab lines and 2 space lines structural_biology_scripts/DynoPlot.py has 82 tab lines and 27 space lines structural_biology_scripts/Rotamers.py has 86 tab lines and 22 space lines structural_biology_scripts/kabsch.py has 51 tab lines and 4 space lines Second, there are files where the indenting inside a line switches back and forth (numbers are the counts of lines that have both tabs and spaces in indenting): Objects_and_Selections/color_objects.py: 19 ThirdParty_Scripts/WFMesh.py: 29 ThirdParty_Scripts/transform_odb.py: 6 math_geo_cgo/modevectors.py: 12 structural_biology_scripts/DynoPlot.py: 83 structural_biology_scripts/Rotamers.py: 86 structural_biology_scripts/kabsch.py: 1 I've tried using pindent.py ( http://svn.python.org/projects/python/trunk/Tools/scripts/pindent.py ) and PythonTidy ( http://pypi.python.org/pypi/PythonTidy/ ) to generally fix these, but they both run into problems. Is there a general solution out in the python world to automatically fix this? I don't care whether it produces tabs or spaces. I just want one or the other. If someone points me to something, I'm more than willing to run it on these scripts, push them back to github and copy them back onto the wiki. -David - - The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol- us...@lists.sourceforge.net -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 --- --- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users
Re: [PyMOL] Whitespacing?
If you have a lot of files to do this to, I would suggest learning at least a little bit of perl. It might not be as nice an option as a python tab manager (depending on your point of view), though. Perl uses regular expressions. In case you'd like to see how to do your tab-space replacement, the following bit of code would convert tabs to 4 spaces. Take care, Mike Z #-- use strict; use warnings; my $file = $ARGV[0]; open(IN,$file) or die $!; open(OUT,.$file.notab) or die $!; while(IN){ $_ =~ s/\t//g; print OUT $_; } close(IN); close(OUT); exit; #-- On Tue, Jan 26, 2010 at 9:09 AM, Jason Vertrees jason.vertr...@schrodinger.com wrote: David, Oh, the joys of open-source. Here's my solution for you: (1) load your file in your favorite editor (2) determine user-desired tab stop setting (3) convert all tabs to spaces in your editor (or search replace tabs with X-spaces) (4) save your file One warning though, I have seen some interpreters crash when they encounter spaces over tabs. -- Jason On Tue, Jan 26, 2010 at 9:12 AM, David Hall li...@cowsandmilk.net wrote: During my editing of dynoplot.py, I noticed that there were some whitespace issues. Normally I consider whitespace a bikeshedding topic, but in python, it is significant, so it matters. When tabs and spaces are mixed, our own personal settings for how tabs are displayed in an editor makes a huge difference in whether the script is understandable. I checked out the git repo of pymol scripts ( http://github.com/jlec/Pymol-script-repo/ ) and did some analysis First, these files switch between some lines where all indenting is tabs to lines where all indenting is spaces: Objects_and_Selections/color_objects.py has 8 tab lines and 34 space lines ThirdParty_Scripts/WFMesh.py has 52 tab lines and 21 space lines biochemical_scripts/pucker.py has 167 tab lines and 5 space lines math_geo_cgo/modevectors.py has 160 tab lines and 2 space lines structural_biology_scripts/DynoPlot.py has 82 tab lines and 27 space lines structural_biology_scripts/Rotamers.py has 86 tab lines and 22 space lines structural_biology_scripts/kabsch.py has 51 tab lines and 4 space lines Second, there are files where the indenting inside a line switches back and forth (numbers are the counts of lines that have both tabs and spaces in indenting): Objects_and_Selections/color_objects.py: 19 ThirdParty_Scripts/WFMesh.py: 29 ThirdParty_Scripts/transform_odb.py: 6 math_geo_cgo/modevectors.py: 12 structural_biology_scripts/DynoPlot.py: 83 structural_biology_scripts/Rotamers.py: 86 structural_biology_scripts/kabsch.py: 1 I've tried using pindent.py ( http://svn.python.org/projects/python/trunk/Tools/scripts/pindent.py ) and PythonTidy ( http://pypi.python.org/pypi/PythonTidy/ ) to generally fix these, but they both run into problems. Is there a general solution out in the python world to automatically fix this? I don't care whether it produces tabs or spaces. I just want one or the other. If someone points me to something, I'm more than willing to run it on these scripts, push them back to github and copy them back onto the wiki. -David -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without
Re: [PyMOL] Whitespacing?
Try the expand command on linux or google for sed tab to space replacement. Marius On Tue, Jan 26, 2010 at 5:48 PM, Michael Zimmermann micha...@iastate.eduwrote: If you have a lot of files to do this to, I would suggest learning at least a little bit of perl. It might not be as nice an option as a python tab manager (depending on your point of view), though. Perl uses regular expressions. In case you'd like to see how to do your tab-space replacement, the following bit of code would convert tabs to 4 spaces. Take care, Mike Z #-- use strict; use warnings; my $file = $ARGV[0]; open(IN,$file) or die $!; open(OUT,.$file.notab) or die $!; while(IN){ $_ =~ s/\t//g; print OUT $_; } close(IN); close(OUT); exit; #-- On Tue, Jan 26, 2010 at 9:09 AM, Jason Vertrees jason.vertr...@schrodinger.com wrote: David, Oh, the joys of open-source. Here's my solution for you: (1) load your file in your favorite editor (2) determine user-desired tab stop setting (3) convert all tabs to spaces in your editor (or search replace tabs with X-spaces) (4) save your file One warning though, I have seen some interpreters crash when they encounter spaces over tabs. -- Jason On Tue, Jan 26, 2010 at 9:12 AM, David Hall li...@cowsandmilk.net wrote: During my editing of dynoplot.py, I noticed that there were some whitespace issues. Normally I consider whitespace a bikeshedding topic, but in python, it is significant, so it matters. When tabs and spaces are mixed, our own personal settings for how tabs are displayed in an editor makes a huge difference in whether the script is understandable. I checked out the git repo of pymol scripts ( http://github.com/jlec/Pymol-script-repo/ ) and did some analysis First, these files switch between some lines where all indenting is tabs to lines where all indenting is spaces: Objects_and_Selections/color_objects.py has 8 tab lines and 34 space lines ThirdParty_Scripts/WFMesh.py has 52 tab lines and 21 space lines biochemical_scripts/pucker.py has 167 tab lines and 5 space lines math_geo_cgo/modevectors.py has 160 tab lines and 2 space lines structural_biology_scripts/DynoPlot.py has 82 tab lines and 27 space lines structural_biology_scripts/Rotamers.py has 86 tab lines and 22 space lines structural_biology_scripts/kabsch.py has 51 tab lines and 4 space lines Second, there are files where the indenting inside a line switches back and forth (numbers are the counts of lines that have both tabs and spaces in indenting): Objects_and_Selections/color_objects.py: 19 ThirdParty_Scripts/WFMesh.py: 29 ThirdParty_Scripts/transform_odb.py: 6 math_geo_cgo/modevectors.py: 12 structural_biology_scripts/DynoPlot.py: 83 structural_biology_scripts/Rotamers.py: 86 structural_biology_scripts/kabsch.py: 1 I've tried using pindent.py ( http://svn.python.org/projects/python/trunk/Tools/scripts/pindent.py ) and PythonTidy ( http://pypi.python.org/pypi/PythonTidy/ ) to generally fix these, but they both run into problems. Is there a general solution out in the python world to automatically fix this? I don't care whether it produces tabs or spaces. I just want one or the other. If someone points me to something, I'm more than willing to run it on these scripts, push them back to github and copy them back onto the wiki. -David -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives:
Re: [PyMOL] Whitespacing?
Hi, On Tue, 26 Jan 2010 10:48:58 -0600 Michael Zimmermann micha...@iastate.edu wrote: If you have a lot of files to do this to, I would suggest learning at least a little bit of perl. It might not be as nice an option as a python tab manager (depending on your point of view), though. Or even better, try sed (the following is in a bash-type shell)! for file in *.py; sed 's/ / /g' $file ${file}.notab In order to type the tab key in the command line, type the key combination CTRL-V followed by the Tab key. I use vim as my editor and I have it set to always use spaces and not tabs using the expandtab setting, so when I hit the Tab key, it just inserts two spaces for me. Cheers, Rob -- Robert L. Campbell, Ph.D. Senior Research Associate/Adjunct Assistant Professor Botterell Hall Rm 644 Department of Biochemistry, Queen's University, Kingston, ON K7L 3N6 Canada Tel: 613-533-6821Fax: 613-533-2497 robert.campb...@queensu.cahttp://pldserver1.biochem.queensu.ca/~rlc -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net