<s> '''<STR_LIT>''' <EOL> import sys <EOL> import inspect <EOL> from mando import Program <EOL> import radon . complexity as cc_mod <EOL> from radon . cli . colors import BRIGHT , RED , RESET <EOL> from radon . cli . harvest import CCHarvester , RawHarvester , MIHarvester <EOL> program = Program ( version = sys . modules [ '<STR_LIT>' ] . __version__ ) <EOL> @ program . command <EOL> @ program . arg ( '<STR_LIT>' , nargs = '<STR_LIT:+>' ) <EOL> def cc ( paths , min = '<STR_LIT:A>' , max = '<STR_LIT:F>' , show_complexity = False , average = False , <EOL> exclude = None , ignore = None , order = '<STR_LIT>' , json = False , no_assert = False , <EOL> show_closures = False , total_average = False , xml = False , codeclimate = False ) : <EOL> '''<STR_LIT>''' <EOL> config = Config ( <EOL> min = min . upper ( ) , <EOL> max = max . upper ( ) , <EOL> exclude = exclude , <EOL> ignore = ignore , <EOL> show_complexity = show_complexity , <EOL> average = average , <EOL> total_average = total_average , <EOL> order = getattr ( cc_mod , order . upper ( ) , getattr ( cc_mod , '<STR_LIT>' ) ) , <EOL> no_assert = no_assert , <EOL> show_closures = show_closures , <EOL> ) <EOL> harvester = CCHarvester ( paths , config ) <EOL> log_result ( harvester , json = json , xml = xml , codeclimate = codeclimate ) <EOL> @ program . command <EOL> @ program . arg ( '<STR_LIT>' , nargs = '<STR_LIT:+>' ) <EOL> def raw ( paths , exclude = None , ignore = None , summary = False , json = False ) : <EOL> '''<STR_LIT>''' <EOL> config = Config ( <EOL> exclude = exclude , <EOL> ignore = ignore , <EOL> summary = summary , <EOL> ) <EOL> harvester = RawHarvester ( paths , config ) <EOL> log_result ( harvester , json = json ) <EOL> @ program . command <EOL> @ program . arg ( '<STR_LIT>' , nargs = '<STR_LIT:+>' ) <EOL> def mi ( paths , min = '<STR_LIT:A>' , max = '<STR_LIT:C>' , multi = True , exclude = None , ignore = None , <EOL> show = False , json = False ) : <EOL> '''<STR_LIT>''' <EOL> config = Config ( <EOL> min = min . upper ( ) , <EOL> max = max . upper ( ) , <EOL> exclude = exclude , <EOL> ignore = ignore , <EOL> multi = multi , <EOL> show = show , <EOL> ) <EOL> harvester = MIHarvester ( paths , config ) <EOL> log_result ( harvester , json = json ) <EOL> class Config ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> self . config_values = kwargs <EOL> def __getattr__ ( self , attr ) : <EOL> '''<STR_LIT>''' <EOL> if attr in self . config_values : <EOL> return self . config_values [ attr ] <EOL> return self . __getattribute__ ( attr ) <EOL> def __repr__ ( self ) : <EOL> '''<STR_LIT>''' <EOL> return repr ( self . config_values ) <EOL> def __eq__ ( self , other ) : <EOL> '''<STR_LIT>''' <EOL> return self . config_values == other . config_values <EOL> @ classmethod <EOL> def from_function ( cls , func ) : <EOL> '''<STR_LIT>''' <EOL> kwonlydefaults = { } <EOL> try : <EOL> argspec = inspect . getfullargspec ( func ) <EOL> kwonlydefaults = argspec . kwonlydefaults or { } <EOL> except AttributeError : <EOL> argspec = inspect . getargspec ( func ) <EOL> args , _ , _ , defaults = argspec [ : <NUM_LIT:4> ] <EOL> values = dict ( zip ( reversed ( args ) , reversed ( defaults or [ ] ) ) ) <EOL> values . update ( kwonlydefaults ) <EOL> return cls ( ** values ) <EOL> def log_result ( harvester , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> log ( harvester . as_json ( ) , noformat = True ) <EOL> elif kwargs . get ( '<STR_LIT>' ) : <EOL> log ( harvester . as_xml ( ) , noformat = True ) <EOL> elif kwargs . get ( '<STR_LIT>' ) : <EOL> log_list ( harvester . as_codeclimate_issues ( ) , delimiter = '<STR_LIT>' , <EOL> noformat = True ) <EOL> else : <EOL> for msg , args , kwargs in harvester . to_terminal ( ) : <EOL> if kwargs . get ( '<STR_LIT:error>' , False ) : <EOL> log ( msg ) <EOL> log_error ( args [ <NUM_LIT:0> ] , indent = <NUM_LIT:1> ) <EOL> continue <EOL> msg = [ msg ] if not isinstance ( msg , ( list , tuple ) ) else msg <EOL> log_list ( msg , * args , ** kwargs ) <EOL> def log ( msg , * args , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> indent = <NUM_LIT:4> * kwargs . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> delimiter = kwargs . get ( '<STR_LIT>' , '<STR_LIT:\n>' ) <EOL> m = msg if kwargs . get ( '<STR_LIT>' , False ) else msg . format ( * args ) <EOL> sys . stdout . write ( '<STR_LIT:U+0020>' * indent + m + delimiter ) <EOL> def log_list ( lst , * args , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> for line in lst : <EOL> log ( line , * args , ** kwargs ) <EOL> def log_error ( msg , * args , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> log ( '<STR_LIT>' . format ( BRIGHT , RED , RESET , msg ) , * args , ** kwargs ) </s>
