<s> __author__ = """<STR_LIT>""" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from os import getcwd <EOL> from os import sys <EOL> sys . path . append ( getcwd ( ) ) <EOL> from MOAL . helpers . display import Section <EOL> DEBUG = True if __name__ == '<STR_LIT:__main__>' else False <EOL> class AbstractVehicle : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' . format ( self . name ) <EOL> class Automobile ( AbstractVehicle ) : <EOL> pass <EOL> class Plane ( AbstractVehicle ) : <EOL> pass <EOL> class Train ( AbstractVehicle ) : <EOL> pass <EOL> class ClassFactory : <EOL> @ staticmethod <EOL> def make ( name , instantiate = False ) : <EOL> newcls = None <EOL> if name is '<STR_LIT>' or name is '<STR_LIT>' : <EOL> newcls = Automobile <EOL> elif name is '<STR_LIT>' : <EOL> newcls = Plane <EOL> elif name is '<STR_LIT:train>' : <EOL> newcls = Train <EOL> if newcls is None : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if instantiate : <EOL> return newcls ( name ) <EOL> else : <EOL> return newcls <EOL> if DEBUG : <EOL> with Section ( '<STR_LIT>' ) : <EOL> clstypes = [ ( '<STR_LIT>' , Automobile ) , ( '<STR_LIT>' , Plane ) , ( '<STR_LIT:train>' , Train ) ] <EOL> for clstype in clstypes : <EOL> _cls , real_class = clstype <EOL> output = ClassFactory . make ( _cls ) <EOL> assert not isinstance ( output , real_class ) <EOL> _cls , real_class = clstype <EOL> output = ClassFactory . make ( _cls , instantiate = True ) <EOL> assert isinstance ( output , real_class ) <EOL> print ( '<STR_LIT>' . format ( _cls , real_class ) ) <EOL> print ( _cls ) </s>
