newformat format change

John A Meinel john at arbash-meinel.com
Tue Oct 4 15:58:28 BST 2005


Martin Pool wrote:
> On 04/10/05, David Allouche <david at allouche.net> wrote:
>
>
>>Is there any specific reason why a SAX sort of API cannot be used to
>>save building the intermediate structure?
>
>
> There's not.  expat might do the job or be faster.
>
> Or at least half the job.  Last time I looked there was no sax-like
> interface to produce XML.  Perhaps I missed it.

Just print it. XML is actually relatively easy to produce. Parsing it is
more complicated.

Doing something like:
to_file.write('<revision\n')
to_file.write('  committer="%s"\n' % rev.committer.encode('utf-8'))
...

Actually, you need slightly better than .encode('utf-8') because you
also have to worry about escaping some characters, but that is a simple:

.replace('&', '&amp;').replace('<', '&lt;')...
Or you could keep a table, and go once over the string, replacing what
was appropriate. There is also python's translate functionality, but I
don't know if it lets you replace a single character with more than 1
character.

John
=:->

>
> --
> Martin
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051004/8791a55a/attachment.pgp 


More information about the bazaar mailing list