diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-09-15 08:49:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-09-15 08:51:14 +0200 |
commit | c3c4ae5fdac0341f01eeed8d5c633d203eed8b2a (patch) | |
tree | 8fee07cdabdb5fb8e1597a88983c79bd8512ae3c /compilerplugins/clang/mergeclasses.py | |
parent | 6df2c90c08b67b943022286e7152b51d52e0ef5e (diff) |
use split() to simplify loplugin python code
Change-Id: Ib6d7acf54ca6c12a3b096435f8a621244df88b4f
Diffstat (limited to 'compilerplugins/clang/mergeclasses.py')
-rwxr-xr-x | compilerplugins/clang/mergeclasses.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/compilerplugins/clang/mergeclasses.py b/compilerplugins/clang/mergeclasses.py index 23a15f62af66..fc2aaa25beca 100755 --- a/compilerplugins/clang/mergeclasses.py +++ b/compilerplugins/clang/mergeclasses.py @@ -9,10 +9,10 @@ definitionToFileDict = {} with open("loplugin.mergeclasses.log") as txt: for line in txt: + tokens = line.strip().split("\t") - if line.startswith("instantiated:\t"): - idx1 = line.find("\t") - clazzName = line[idx1+1 : len(line)-1] + if tokens[0] == "instantiated:": + clazzName = tokens[1] if (clazzName.startswith("const ")): clazzName = clazzName[6:] if (clazzName.startswith("class ")): @@ -21,20 +21,16 @@ with open("loplugin.mergeclasses.log") as txt: clazzName = clazzName[:len(clazzName)-3] instantiatedSet.add(clazzName) - elif line.startswith("definition:\t"): - idx1 = line.find("\t") - idx2 = line.find("\t", idx1+1) - clazzName = line[idx1+1 : idx2] - # the +2 is so we skip the leading / - fileName = line[idx2+2 : len(line)-1] + elif tokens[0] == "definition:": + clazzName = tokens[1] + # the 1.. is so we skip the leading / + fileName = tokens[1][1..] definitionSet.add(clazzName) definitionToFileDict[clazzName] = fileName - elif line.startswith("has-subclass:\t"): - idx1 = line.find("\t") - idx2 = line.find("\t", idx1+1) - child = line[idx1+1 : idx2] - parent = line[idx2+1 : len(line)-1] + elif tokens[0] == "has-subclass:": + child = tokens[1] + parent = tokens[2] if (parent.startswith("class ")): parent = parent[6:] elif (parent.startswith("struct ")): |