Created
January 20, 2012 11:57
-
-
Save mkorpela/1647044 to your computer and use it in GitHub Desktop.
Finding unused Robot Framework user keywords
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from robotide.controller.chiefcontroller import ChiefController | |
from robotide.controller.commands import NullObserver | |
from robotide.controller.filecontrollers import DirectoryController | |
from robotide.namespace import Namespace | |
from robotide.spec.iteminfo import LibraryKeywordInfo | |
from robotide.usages.commands import FindUsages | |
def construct_chief_controller(datapath): | |
namespace = Namespace() | |
chief = ChiefController(namespace) | |
chief.load_data(datapath, NullObserver()) | |
return chief, namespace | |
if __name__ == '__main__': | |
chief, namespace = construct_chief_controller(sys.argv[1]) | |
print 'finding unused User Keywords..' | |
for keyword_info in namespace.get_all_keywords([df.data for df in chief.datafiles \ | |
if not isinstance(df, DirectoryController)]): | |
if not isinstance(keyword_info, LibraryKeywordInfo) and keyword_info.name: | |
try: | |
chief.execute(FindUsages(keyword_info.name, keyword_info=keyword_info)).next() | |
except StopIteration: | |
print 'Source: %s Keyword: "%s"' % (keyword_info.item.source, keyword_info.name) | |
print 'find end' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RIDE should have this functionality for the past 8-10 years