474,047 Members | 42,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pretty Printing Like Tidy for HTML

All,

Is there a pretty printing utility for Python, something like Tidy for
HTML?

That will change:

xp=self.uleft[0]+percentx*(self .xwidth)

To:

xp = self.uleft[0] + percentx * (self.xwidth)

And other formatting issues.

Jul 7 '07 #1
5 2097
On Sat, 07 Jul 2007 21:35:40 +0300, David <dw********@sud denlink.net
wrote:
>
All,

Is there a pretty printing utility for Python, something like Tidy for
HTML?

That will change:

xp=self.uleft[0]+percentx*(self .xwidth)

To:

xp = self.uleft[0] + percentx * (self.xwidth)

And other formatting issues.
Why not just write python as it should be written?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 7 '07 #2
Daniel:
On Sat, 07 Jul 2007 21:35:40 +0300, David <dw********@sud denlink.net>
wrote:
>Is there a pretty printing utility for Python, something like Tidy for
HTML?

Why not just write python as it should be written?
Oh, you write all the code you use yourself?
It's relatively common that you have some "legacy" code (e.g. from
(ex-)colleages) that doesn't conform to your style preferences/your
companys coding guidelines.
In such a case those tools can be very helpful.

--
Thomas Wittek
http://gedankenkonstrukt.de/
Jabber: st*********@jab ber.i-pobox.net
Jul 7 '07 #3
David <dw********@sud denlink.netwrit es:
Is there a pretty printing utility for Python, something like Tidy for
HTML?

That will change:

xp=self.uleft[0]+percentx*(self .xwidth)

To:

xp = self.uleft[0] + percentx * (self.xwidth)

And other formatting issues.
Googled and found these; no idea if they're any good (latter is
commercial):

http://cheeseshop.python.org/pypi/PythonTidy/1.11

http://python.softalizer.com/
See also:

http://svn.python.org/view/python/tr...nt.py?view=log
John
Jul 8 '07 #4
On Jul 8, 10:59 am, j...@pobox.com (John J. Lee) wrote:
David <dwarnol...@sud denlink.netwrit es:
Is there a pretty printing utility for Python, something like Tidy for
HTML?
That will change:
xp=self.uleft[0]+percentx*(self .xwidth)
To:
xp = self.uleft[0] + percentx * (self.xwidth)
And other formatting issues.

Googled and found these; no idea if they're any good (latter is
commercial):

http://cheeseshop.python.org/pypi/PythonTidy/1.11

http://python.softalizer.com/

See also:

http://svn.python.org/view/python/tr...eindent.py?vie...

John
I did this useing the BeautifulSoup module.
Used it on XML created by msWord which had no formating was
all on one line.
>>import BeautifulSoup
soupStr = open('c:/data/quotes.xml').re ad()
soup = BeautifulSoup.B eautifulSoup(so upStr)
pSoup = soup.prettify()
outFile = open('c:/data/quotesTidy.xml' ,'w')
outFile.write (pSoup)
outFile.close ()
Jul 8 '07 #5
On Jul 8, 1:53 pm, bsneddon <bsned...@yahoo .comwrote:
On Jul 8, 10:59 am, j...@pobox.com (John J. Lee) wrote:
David <dwarnol...@sud denlink.netwrit es:
Is there a pretty printing utility for Python, something like Tidy for
HTML?
That will change:
xp=self.uleft[0]+percentx*(self .xwidth)
To:
xp = self.uleft[0] + percentx * (self.xwidth)
And other formatting issues.
Googled and found these; no idea if they're any good (latter is
commercial):
http://cheeseshop.python.org/pypi/PythonTidy/1.11
http://python.softalizer.com/
See also:
http://svn.python.org/view/python/tr...eindent.py?vie...
John

I did this useing the BeautifulSoup module.
Used it on XML created by msWord which had no formating was
all on one line.
>import BeautifulSoup
soupStr = open('c:/data/quotes.xml').re ad()
soup = BeautifulSoup.B eautifulSoup(so upStr)
pSoup = soup.prettify()
outFile = open('c:/data/quotesTidy.xml' ,'w')
outFile.write( pSoup)
outFile.close( )
Sorry, I answered the wrong question.
You wanted to format code not HTML.

Jul 8 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
20154
by: Guenther Schmidt | last post by:
Hi, is it possible to have PHP pretty print the HTML output? Günther
4
3896
by: Anthony | last post by:
I love the HTML Cleaner-upper Tidy... http://tidy.sourceforge.net and I use it ALL the time after running my .asp's... however (As you can imagine).. this is a longer process then I want... : For example : Run .asp save source, run tidy, examine html source determine where the error is (IN what line) go to my .asp and find where the html is generated from... fix it.. run again
3
2789
by: Mike | last post by:
Greetings, I just used Tidy HTML for the first time. The address below contains the files need to check on Tidy's corrections. I would appreciate any feedback on the Tidy report and the necessity and validity of the changes Tidy has made or recommended. The following is obvious to me: line 194 column 98 - Warning: discarding unexpected </font>
0
1864
by: Christoph Schneegans | last post by:
Hi! I'd like to present an easy, yet powerful approach to use the HTML Tidy program from <http://tidy.sourceforge.net/> in ASP.NET. It is similiar to <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/tchVSAddinEnablingHTMLTidy.asp>. However, it is not implemented as a Visual Studio Add-in, but as a response filter. This way, the complete HTML source is tidied, including the output of web controls.
40
5668
by: VK | last post by:
Hi, After the response on my request from W3C I'm still unclear about Tidy vs. Validator discrepansies. That started with <IFRAME> issue, but there is more as I know. Anyway, this very basic HTML page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html401/strict.dtd"> <html> <head>
2
2050
by: Sebastian Gohres | last post by:
Hi! First: sorry for my bad english :) If I parse template files, html tidy remove all tags beginning with { for example: before: <select name="country" size="1">
0
1897
by: BG Mahesh | last post by:
hi I have installed Tidy on Fedore Core 4.0 using RPM. I have a very simple script that uses tidy, ------------tidy.php------------------ <html>a html document</html> <? $html = ob_get_clean(); // Specify configuration
1
3150
by: Carmen Sei | last post by:
I need to parse HTML page and extract data should I use HTML Tidy DLL http://dev.int64.org/tidy.html or it's easier to use library with source code like http://users.rcn.com/creitzel/tidy.html#cplusplus which HTML Tidy C++ version (easiest) should I use for C++ project?
0
1259
by: tobycraftse | last post by:
any example shows how to use HTML Tidy in VC++ project? I need to parse HTML page and extract data should I use HTML Tidy DLL http://dev.int64.org/tidy.html or it's easier to use library with source code like http://users.rcn.com/creitzel/tidy.html#cplusplus
0
10548
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11604
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
11145
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
5423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4947
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.