Emscripten: Document failing getExceptionMessage
[LibreOffice.git] / bin / find-unused-sid-commands.py
blob7cdf0cd3be5daba07a14ffc24254f5077847e009
1 #!/usr/bin/python
3 # Find potentially unused UNO command entries in SDI files.
5 # Note that this is not foolproof, some extra checking is required because some command names might be
6 # constructed at runtime.
9 import subprocess
11 # search for entries in .sdi files that declare UNO/SID commands
12 a = subprocess.Popen(r"git grep -P '^\s*\w+Item\s+\w+\s+SID_\w+$' -- *.sdi", stdout=subprocess.PIPE, shell=True)
14 # parse out the UNO command names
15 commandSet = list()
16 with a.stdout as txt:
17 for line in txt:
18 line = line.strip()
19 idx1 = line.find(" ")
20 idx2 = line.find(" ", idx1 + 1)
21 commandName = line[idx1+1 : idx2].strip()
22 sidName = line[idx2+1:].strip()
23 commandSet.append((commandName,sidName))
25 # now check to see if that UNO command is called anywhere in the codebase.
26 for pair in commandSet:
27 commandName = pair[0]
28 sidName = pair[1]
30 # check to see if that UNO command is called anywhere in the codebase.
31 a = subprocess.Popen("git grep -wFn '.uno:" + commandName + "'", stdout=subprocess.PIPE, shell=True)
32 cnt = 0
33 with a.stdout as txt2:
34 for line2 in txt2:
35 cnt = cnt + 1
36 if cnt > 0: continue
38 # check to see if the SID is used programmatically
39 foundLines = ""
40 a = subprocess.Popen("git grep -wn " + sidName, stdout=subprocess.PIPE, shell=True)
41 with a.stdout as txt2:
42 for line2 in txt2:
43 foundLines = foundLines + line2
44 if foundLines.find("ExecuteList") != -1: continue
45 if foundLines.find("GetDispatcher()->Execute") != -1: continue
46 if foundLines.find("ExecuteScenarioSlot") != -1: continue
47 # TODO not sure about this, but let's tackle the easy ones first
48 if foundLines.find("Invalidate(") != -1: continue
50 # dump any lines that contain the SID, so we can eyeball the results
51 print("remove: " + commandName)
52 print(foundLines)
53 print("----------------------------------------------------------------------------")