473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

help in xml and python

i have a List

modifiedfiles= [['/home/moq/buc/2/mod2.py', '200607131001'],
['/home/moq/buc/1/mod2.py', '200607131000'],
['/home/moq/buc/1/mod3.py', '200607131001'],
['/home/moq/buc/1+mod1.py', '200607131001']]

i have to put them in am xml format like the follg.

<modified>
<directory>
<dirname>/home/moq/buc/2</dirname>
<file>
<name>mod2.py</name>
<time>200607131001</time>
</file>
</directory>
<directory>
<dirname>/home/moq/buc/1</dirname>
<file>
<name>mod1.py</name>
<time>200607131001</time>
</file>
<file>
<name>mod2.py</name>
<time>200607131001</time>
</file>
<file>
<name>mod3.py</name>
<time>200607131001</time>
</file>
</directory>
</modified>
can someone please with the code for this.

Jul 13 '06 #1
7 947
"Kirt" wrote:
>i have a List

modifiedfiles= [['/home/moq/buc/2/mod2.py', '200607131001'],
['/home/moq/buc/1/mod2.py', '200607131000'],
['/home/moq/buc/1/mod3.py', '200607131001'],
['/home/moq/buc/1+mod1.py', '200607131001']]

i have to put them in am xml format like the follg.
not very long ago, "Kepioo" wrote:
what i want to do :

i have entries, in a list format :[[key1,value],[key2,value],[
key3,value]], value]

example :
[["route","23"],["equip","jr2"],["time","3pm"]],"my first value"]
[["route","23"],["equip","jr1"],["time","3pm"]],"my second value"]
[["route","23"],["equip","jr2"],["time","3pm"]],"my third value"]
[["route","24"],["equip","jr2"],["time","3pm"]],"my fourth value"]
[["route","25"],["equip","jr2"],["time","3pm"]],'"my fifth value"]

the [XML] tree i want in the end would be :
which looks rather similar to your post, don't you think? check that thread
for some ideas:

http://groups.google.com/group/comp....b3b6cf3613d7b3

</F>

Jul 13 '06 #2
Le jeudi 13 juillet 2006 12:50, Kirt a écrit*:
* *<directory>
* * <dirname>/home/moq/buc/2</dirname>
* * <file>
* * *<name>mod2.py</name>
* * *<time>200607131001</time>
* * </file>
* *</directory>
In [109]: xmldir = """ <directory>
.....: <dirname>%(dir)s</dirname>
.....: <file>
.....: <name>%(file)s</name>
.....: <time>%(time)s</time>
.....: </file>
.....: </directory>"""
In [116]: xmloutput = '\n'.join(('<modified>',) + tuple(xmldir % {'dir':
path.rsplit('/', 1)[0], 'file':path.split('/')[-1], 'time':time} for path,
time in modifiedfiles) + ('</modified>',)) #turning this into a readable not
one-liner code is left as an exercise :)

In [117]: print xmloutput
<modified>
<directory>
<dirname>/home/moq/buc/2</dirname>
<file>
<name>mod2.py</name>
<time>200607131001</time>
</file>
</directory>
<directory>
<dirname>/home/moq/buc/1</dirname>
<file>
<name>mod2.py</name>
<time>200607131000</time>
</file>
</directory>
<directory>
<dirname>/home/moq/buc/1</dirname>
<file>
<name>mod3.py</name>
<time>200607131001</time>
</file>
</directory>
<directory>
<dirname>/home/moq/buc</dirname>
<file>
<name>1+mod1.py</name>
<time>200607131001</time>
</file>
</directory>
</modified>
--
_____________

Maric Michaud
_____________

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
Jul 13 '06 #3
can someone please with the code for this.

Show us your efforts, and we'd be glad to help you correcting/enhancing
them.

Or use PayPal and pay one of the guys here - my hourly fee is 50€, and
less than one hour work can't be booked.

Diez
Jul 13 '06 #4
Diez B. Roggisch wrote:
Or use PayPal and pay one of the guys here - my hourly fee is 50€, and
less than one hour work can't be booked.
He!

Don't tell people in public that you're working at 50€/hour! That's gonna
destruct the market. It's better if they believe there's nothing below 80€,
then they're more likely to ask for the people who know their real value.

Stefan
Jul 13 '06 #5
Diez B. Roggisch wrote:
>>can someone please with the code for this.


Show us your efforts, and we'd be glad to help you correcting/enhancing
them.

Or use PayPal and pay one of the guys here - my hourly fee is 50€, and
less than one hour work can't be booked.

Diez

I remember a few years ago, I posted something like this to the list,
and got flamed 6 ways from Sunday for having the audacity to propose
this. 50 Euros/hour is a very good rate by the way.. if more consultants
would offer their services this inexpensively, then perhaps it might even
be competitive with outsourcing.

John
Jul 13 '06 #6
John Draper wrote:
I remember a few years ago, I posted something like this to the list,
and got flamed 6 ways from Sunday for having the audacity to propose
this.
certain people think that the mere thought of getting paid for
contributing to freely available software is outrageously immoral...
50 Euros/hour is a very good rate by the way.. if more consultants
would offer their services this inexpensively, then perhaps it might even
be competitive with outsourcing.
not sure about that, though: increasingly, outsourcing means paying
someone to sign up for a hotmail account and keep sending increasingly
annoying mails to fredrik lundh until he gives up and points to some
ready-made code that might solve the customer's problem (if I had a
dollar for every such mail etc etc).

</F>

Jul 13 '06 #7
Fredrik Lundh wrote:
>
not very long ago, "Kepioo" wrote:
[...]
which looks rather similar to your post, don't you think?
Are you calling "homework assignment", Fredrik? ;-)

Paul

Jul 13 '06 #8

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

Similar topics

4
by: Guido van Rossum | last post by:
I'm pleased to announce that the Python Software Foundation (PSF) is now accepting donations from individuals and companies interested in supporting our mission to improve the Python programming...
10
by: Jacek Generowicz | last post by:
Where can I find concise, clear documentation describing what one has to do in order to enable Python's internal help to be able to provide descriptions of Python keywords ? I am in a situation...
0
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to...
3
by: stuart_white_ | last post by:
I've just upgraded from Python 2.3.3 to Python 2.4.2, and, although the new version of Python seems to be running correctly, I can't seem access the help from the interpreter. On Python 2.3.3...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
1
by: Paul Rubin | last post by:
In Windows if you click the Help dropdown, IDLE launches a help window as it should. The help contents are included in the installation. In Linux, clicking Help launches a web browser, which is...
0
by: Jack Wu | last post by:
Hi I've spent a good majority of my day trying to figure out how to have PIL 1.1.5 working on my OSX 10.3.9_PPC machine. I'm still stuck and I have not gotten anywhere. Could somebody please...
2
by: Scott Smith | last post by:
To all you vi/vim users out there..... I am just getting into python and am trying to learn how to use the python.vim script. I really like the fact that it autoindents for me while inserting...
0
by: Support Desk | last post by:
That’s it exactly..thx -----Original Message----- From: Reedick, Andrew Sent: Tuesday, June 03, 2008 9:26 AM To: Support Desk Subject: RE: regex help The regex will now skip anything with...
0
by: Ahmed, Shakir | last post by:
Thanks everyone who tried to help me to parse incoming email from an exchange server: Now, I am getting following error; I am not sure where I am doing wrong. I appreciate any help how to resolve...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.