LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-27-2010, 07:34 PM   #16
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,194

Rep: Reputation: 105Reputation: 105

So, now that we know it is python code and we want "pretty" formatting -- that becomes a useful google search. Way back when I was doing Dartmouth Basic (not the bas***dized versions that spawned out of MS Basic, etc.), we had a Basic program that would format Basic programs. That's an obvious thing for python, and here it is: http://svn.python.org/projects/pytho...pts/pindent.py

Then all you need to do is put together a shell script that finds the .PY files in your collection of directories and pipes them through this script, maybe with xargs.

find /path/to/top/directory -type f -name *.PY | xargs pindent.py

I don't know if that exact approach will work. Depends on looking at pindent.py and trying one or two to see if it will do them in place, etc. You'll have to figure out what parameters to give pindent.py as well.

Last edited by choogendyk; 04-27-2010 at 07:36 PM.
 
1 members found this post helpful.
Old 04-28-2010, 03:04 AM   #17
mythcat
Member
 
Registered: Dec 2007
Location: Fălticeni, Romania
Distribution: Debian;Fedora
Posts: 76

Original Poster
Rep: Reputation: 15
@catkin
Maybe is something wrong :
See output
sh testpy.sh
testpy.sh: line 5: syntax error near unexpected token `<'
testpy.sh: line 5: `done < <(find <testpy> -t file -iname '*.py')'
I don't know, i'm not so good with bash.
@choogendyk
Very good script pindent.py
I will read and i will try understanding how that working.

If we want to continue, I expect PM ...

Thank you all . I will close this tread.
 
Old 04-28-2010, 03:12 AM   #18
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,614

Rep: Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938Reputation: 2938
Quote:
testpy.sh: line 5: syntax error near unexpected token `<'
testpy.sh: line 5: `done < <(find <testpy> -t file -iname '*.py')'
It appears you have a backtick (`) prior to the word "done"
 
Old 04-28-2010, 03:32 AM   #19
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by mythcat View Post
@catkin
Maybe is something wrong :
See output
sh testpy.sh
testpy.sh: line 5: syntax error near unexpected token `<'
testpy.sh: line 5: `done < <(find <testpy> -t file -iname '*.py')'
In done < <(find <directory> -t file -name '*.PY'), the < > around "directory" conventionally means "use your own value here"; the < > should be removed. Try done < <(find testpy -t file -iname '*.py')
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script using sed or awk? houms Linux - Newbie 10 06-21-2009 09:14 AM
Help with BASH script and AWK and SED NickJH Linux - Newbie 11 03-07-2009 04:08 PM
bash - awk, sed, grep, ... advice schneidz Programming 13 08-25-2008 09:30 AM
N00b's bash, sed, or awk question petcherd Slackware 5 08-01-2007 06:42 AM
How to loop or sort in bash, awk or sed? j4r0d Programming 1 09-09-2004 03:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration