1 |
On 11/08/2015 11:07 AM, Michał Górny wrote: |
2 |
>> |
3 |
>> <project> |
4 |
>> <name>Foo</name> |
5 |
>> <email>foo@g.o</email> |
6 |
>> <subproject ref="foo@g.o"/> |
7 |
>> </project> |
8 |
> |
9 |
> I meant finding project by e-mail. You don't have to care about |
10 |
> subprojects at all to do this. Subprojects are a side info. |
11 |
> |
12 |
|
13 |
What exactly gets harder? Finding an email address is same in emacs/grep |
14 |
regardless of the nesting. If you wanted to write a script, it might get |
15 |
one line longer: |
16 |
|
17 |
#!/usr/bin/python |
18 |
|
19 |
import sys |
20 |
|
21 |
import xml.etree.ElementTree as ET |
22 |
tree = ET.parse('metadata.xml') |
23 |
for project in tree.findall('.//project'): |
24 |
if project.find('email').text == sys.argv[1]: |
25 |
print(project.find('name').text) |