mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Initial checkin.
This commit is contained in:
parent
b04f6166a3
commit
15e7c8915e
36
tools/find-strings.py
Executable file
36
tools/find-strings.py
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import symbol
|
||||||
|
import parser
|
||||||
|
|
||||||
|
import supybot.utils as utils
|
||||||
|
|
||||||
|
def strings(node):
|
||||||
|
if node[0] == 3:
|
||||||
|
yield (node[2], node[1])
|
||||||
|
for x in node:
|
||||||
|
if isinstance(x, list):
|
||||||
|
for t in strings(x):
|
||||||
|
yield t
|
||||||
|
|
||||||
|
def getText(filename):
|
||||||
|
try:
|
||||||
|
fd = file(filename)
|
||||||
|
return fd.read()
|
||||||
|
finally:
|
||||||
|
fd.close()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.mkdir('strings')
|
||||||
|
for filename in sys.argv[1:]:
|
||||||
|
s = getText(filename)
|
||||||
|
node = parser.ast2list(parser.suite(s), True)
|
||||||
|
fd = file(os.path.join('strings', os.path.basename(filename)), 'w')
|
||||||
|
for (lineno, string) in strings(node):
|
||||||
|
fd.write('%s: %s\n' % (lineno, string))
|
||||||
|
fd.close()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user