<s> import fnmatch <EOL> import os <EOL> import os . path <EOL> import re <EOL> import sys <EOL> try : <EOL> import json <EOL> except : <EOL> import simplejson as json <EOL> def dump_sorted_json_string ( input , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return json . dumps ( input , sort_keys = True , separators = ( '<STR_LIT:U+002C>' , '<STR_LIT>' ) , ** kwargs ) <EOL> def load_extra_plugins ( pathspec ) : <EOL> """<STR_LIT>""" <EOL> loaded_plugins = [ ] <EOL> paths = pathspec . split ( '<STR_LIT::>' ) <EOL> for path in paths : <EOL> loaded_plugins . extend ( _load_plugins_from_dir ( path ) ) <EOL> return loaded_plugins <EOL> def _load_plugins_from_dir ( path ) : <EOL> """<STR_LIT>""" <EOL> plugins = [ ] <EOL> loaded_plugins = [ ] <EOL> full_path = os . path . expanduser ( path ) <EOL> try : <EOL> filtered = fnmatch . filter ( os . listdir ( path ) , '<STR_LIT>' ) <EOL> plugins . extend ( filtered ) <EOL> except OSError : <EOL> pass <EOL> else : <EOL> sys . path . insert ( <NUM_LIT:1> , path ) <EOL> for plugin in plugins : <EOL> match = re . search ( '<STR_LIT>' , plugin ) <EOL> if match : <EOL> try : <EOL> __import__ ( match . group ( '<STR_LIT:name>' ) , globals ( ) , locals ( ) , [ ] , - <NUM_LIT:1> ) <EOL> except : <EOL> pass <EOL> else : <EOL> loaded_plugins . append ( match . group ( '<STR_LIT:name>' ) ) <EOL> return loaded_plugins </s>
