<s> from texttable import Texttable <EOL> from ussclicore . argumentParser import ArgumentParser , ArgumentParserError <EOL> from ussclicore . cmd import Cmd , CoreGlobal <EOL> from ussclicore . utils import generics_utils , printer <EOL> from hammr . utils import * <EOL> from hammr . utils . hammr_utils import * <EOL> class Platform ( Cmd , CoreGlobal ) : <EOL> """<STR_LIT>""" <EOL> cmd_name = "<STR_LIT>" <EOL> def __init__ ( self ) : <EOL> super ( Platform , self ) . __init__ ( ) <EOL> def arg_list ( self ) : <EOL> doParser = ArgumentParser ( add_help = True , description = "<STR_LIT>" ) <EOL> return doParser <EOL> def do_list ( self , args ) : <EOL> try : <EOL> printer . out ( "<STR_LIT>" ) <EOL> targetPlatformsUser = self . api . Users ( self . login ) . Targetplatforms . Getall ( ) <EOL> if targetPlatformsUser is None or len ( targetPlatformsUser . targetPlatforms . targetPlatform ) == <NUM_LIT:0> : <EOL> printer . out ( "<STR_LIT>" ) <EOL> return <NUM_LIT:0> <EOL> else : <EOL> targetPlatformsUser = generics_utils . order_list_object_by ( <EOL> targetPlatformsUser . targetPlatforms . targetPlatform , "<STR_LIT:name>" ) <EOL> printer . out ( "<STR_LIT>" ) <EOL> table = Texttable ( <NUM_LIT:200> ) <EOL> table . set_cols_align ( [ "<STR_LIT:c>" , "<STR_LIT:c>" , "<STR_LIT:c>" , "<STR_LIT:c>" ] ) <EOL> table . header ( [ "<STR_LIT>" , "<STR_LIT:Name>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> for item in targetPlatformsUser : <EOL> if item . access : <EOL> access = "<STR_LIT:X>" <EOL> else : <EOL> access = "<STR_LIT>" <EOL> table . add_row ( [ item . dbId , item . name , item . type , access ] ) <EOL> print table . draw ( ) + "<STR_LIT:\n>" <EOL> return <NUM_LIT:0> <EOL> except ArgumentParserError as e : <EOL> printer . out ( "<STR_LIT>" + str ( e ) , printer . ERROR ) <EOL> self . help_list ( ) <EOL> except Exception as e : <EOL> return handle_uforge_exception ( e ) <EOL> def help_list ( self ) : <EOL> doParser = self . arg_list ( ) <EOL> doParser . print_help ( ) </s>
