블로그 (Blog)/개발로그 (Devlogs)
Python에서 ctags 분석
ihmin
2024. 3. 18. 19:41
아래와 같이 ctags로 코드를 분석하고..
ctags --languages=tcl --fields=afmikKlnsStz -R
생성된 ctags 파일을 python에서 아래의 모듈을 아용하여 분석.https://code.google.com/p/python-ctags/
https://github.com/sbraz/python-ctags
SET VS90COMNTOOLS=%VS100COMNTOOLS%
python setup.py install
아래는 파이썬 3에 대한 지원을 추가한 python-ctags의 포크..
https://github.com/universal-ctags/python-ctags3
테스트..
import ctags
from ctags import CTags, TagEntry
import sys
tagFile = CTags('tags')
entry = TagEntry()
if tagFile.find(entry, 'legend', ctags.TAG_PARTIALMATCH | ctags.TAG_IGNORECASE):
print entry['lineNumber']
print entry['file']
print entry['pattern']
print entry['name']
print entry['kind']
# Find the next tag matching the name and options supplied to the
# most recent call to tagFile.find(). (replace the entry if found)
while tagFile.findNext(entry):
print entry['lineNumber']
print entry['file']
print entry['pattern']
print entry['name']
print entry['kind']