본문으로 바로가기

Python에서 ctags 분석

category Devlogs 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']




Korea Tcl/Tk Community
블로그 이미지 ihmin 님의 블로그
VISITOR 오늘 / 전체