<s> import os <EOL> import json <EOL> import webbrowser <EOL> import urllib <EOL> keywords = { } <EOL> class WebKeyword : <EOL> def __init__ ( self , name , url , library_name , args , doc ) : <EOL> self . name = library_name + '<STR_LIT:.>' + name <EOL> self . url = url <EOL> self . description = [ args , doc , url ] <EOL> def show_definition ( self , view , views_to_center ) : <EOL> webbrowser . open ( self . url ) <EOL> def allow_unprompted_go_to ( self ) : <EOL> return False <EOL> def load ( plugin_dir ) : <EOL> keywords . clear ( ) <EOL> scan_dir = os . path . join ( plugin_dir , '<STR_LIT>' ) <EOL> for root , dirs , files in os . walk ( scan_dir ) : <EOL> for file_path in filter ( lambda f : f . endswith ( '<STR_LIT>' ) , files ) : <EOL> library_name = file_path [ : - <NUM_LIT:5> ] <EOL> file_path = os . path . join ( root , file_path ) <EOL> with open ( file_path , '<STR_LIT:rb>' ) as f : <EOL> json_dict = json . load ( f ) <EOL> url = json_dict [ '<STR_LIT:url>' ] <EOL> for keyword in json_dict [ '<STR_LIT>' ] : <EOL> name = keyword [ '<STR_LIT:name>' ] <EOL> args = keyword [ '<STR_LIT:args>' ] <EOL> doc = keyword [ '<STR_LIT>' ] <EOL> lower_name = name . lower ( ) <EOL> web_keyword = WebKeyword ( name , url + '<STR_LIT:#>' + urllib . quote ( name ) , library_name , args , doc ) <EOL> if not keywords . has_key ( lower_name ) : <EOL> keywords [ lower_name ] = [ ] <EOL> keywords [ lower_name ] . append ( web_keyword ) <EOL> def search_keywords ( name ) : <EOL> lower_name = name . lower ( ) <EOL> if not keywords . has_key ( lower_name ) : <EOL> return [ ] <EOL> return keywords [ lower_name ] </s>
