入力:-
<manifest>
<default revision="jb_2.5.4" remote="quic"/>
<project name="platform/vendor/google/proprietary/widevine"
path="vendor/widevine"
revision="refs/heads/jb_2.6"
x-grease-customer="none"
x-quic-dist="none"
x-ship="none" />
<project path="vendor/widevine" name="platform/vendor/google/proprietary/bluetooth" x-ship="none" x-quic-dist="none" x-grease-customer="none"/>
</manifest>
リビジョン タグが存在する場合は、上記の入力からリビジョン値を取得しようとしています。存在しない場合は、デフォルト タグのリビジョン値を使用します。次のコードがあり、次のエラーが発生します。誰でも入力を提供できますかここで何が問題なのですか?
import shlex
import os
import sys
import json
import fileinput
import pwd
import itertools
import subprocess
from subprocess import Popen, PIPE, STDOUT
import xml.etree.ElementTree as ET
import re
def manifest_data (name):
pattern = re.compile('refs/heads/(.*)')
tree = ET.parse('.repo/manifests/default.xml')
root = tree.getroot()
project = root.find("./project[@name='%s']" % name)
revision = project.get('revision')
res = pattern.match(revision)
return res.group(1)
def main ():
branch_name = "jb_2.5.4"
print "branch_name"
print branch_name
projects = ['platform/vendor/google/proprietary/widevine','platform/vendor/google/proprietary/bluetooth']
for project in projects :
branch = manifest_data(project)
print branch
if __name__ == '__main__':
main()
エラー:-
File "branch_manifest.py", line 35, in <module>
main()
File "branch_manifest.py", line 32, in main
branch = manifest_data(project)
File "branch_manifest.py", line 18, in manifest_data
project = root.find("./project[@name='%s']" % name)
File "/usr/lib/python2.6/xml/etree/ElementTree.py", line 330, in find
return ElementPath.find(self, path)
File "/usr/lib/python2.6/xml/etree/ElementPath.py", line 186, in find
return _compile(path).find(element)
File "/usr/lib/python2.6/xml/etree/ElementPath.py", line 176, in _compile
p = Path(path)
File "/usr/lib/python2.6/xml/etree/ElementPath.py", line 93, in __init__
"expected path separator (%s)" % (op or tag)
SyntaxError: expected path separator ([)