<s> USAGE = """<STR_LIT>""" <EOL> import sys <EOL> import re <EOL> from pyral import Rally , rallyWorkset <EOL> errout = sys . stderr . write <EOL> ATTRIBUTE_FIELDS = """<STR_LIT>""" . split ( "<STR_LIT:\n>" ) <EOL> def main ( args ) : <EOL> options = [ opt for opt in args if opt . startswith ( '<STR_LIT>' ) ] <EOL> args = [ arg for arg in args if arg not in options ] <EOL> if not args : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> query = "<STR_LIT>" <EOL> target = args [ <NUM_LIT:0> ] <EOL> if target in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> target = "<STR_LIT>" <EOL> if '<STR_LIT:/>' in target : <EOL> parent , entity = target . split ( '<STR_LIT:/>' , <NUM_LIT:1> ) <EOL> target = entity <EOL> query = '<STR_LIT>' % target <EOL> server , username , password , apikey , workspace , project = rallyWorkset ( options ) <EOL> try : <EOL> if apikey : <EOL> rally = Rally ( server , apikey = apikey , workspace = workspace , project = project ) <EOL> else : <EOL> rally = Rally ( server , user = username , password = password , workspace = workspace , project = project ) <EOL> except Exception as ex : <EOL> errout ( str ( ex . args [ <NUM_LIT:0> ] ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> typedef = rally . typedef ( target ) <EOL> showAttributes ( typedef . Attributes ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT:->" * <NUM_LIT:64> <EOL> print "<STR_LIT>" <EOL> for ix , ancestor in enumerate ( typedef . inheritanceChain ( ) ) : <EOL> print "<STR_LIT>" % ( "<STR_LIT:U+0020>" * ( ix * <NUM_LIT:4> ) , ancestor ) <EOL> def showAttributes ( attributes ) : <EOL> required = [ ] <EOL> optional = [ ] <EOL> av_limit = <NUM_LIT:20> <EOL> for attr in attributes : <EOL> name = '<STR_LIT:%s>' % attr . ElementName <EOL> a_type = '<STR_LIT:%s>' % attr . AttributeType <EOL> s_type = '<STR_LIT:%s>' % attr . SchemaType <EOL> s_type = s_type . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if s_type . upper ( ) == a_type : <EOL> s_type = '<STR_LIT>' <EOL> reqd = '<STR_LIT>' if attr . Required else '<STR_LIT>' <EOL> rdonly = '<STR_LIT>' if attr . ReadOnly else '<STR_LIT>' <EOL> custom = '<STR_LIT>' if attr . Custom else '<STR_LIT>' <EOL> hidden = '<STR_LIT>' if attr . Hidden else '<STR_LIT>' <EOL> allowedValues = attr . AllowedValues <EOL> tank = required if reqd == '<STR_LIT>' else optional <EOL> num_allowed_values = "<STR_LIT>" <EOL> if len ( allowedValues ) > <NUM_LIT:0> : <EOL> num_allowed_values = ( "<STR_LIT>" % len ( allowedValues ) ) <EOL> if len ( allowedValues ) == <NUM_LIT:1> : <EOL> num_allowed_values = num_allowed_values [ : - <NUM_LIT:1> ] <EOL> info = "<STR_LIT>" % ( name , a_type , s_type , reqd , rdonly , custom , hidden ) <EOL> tank . append ( info ) <EOL> if num_allowed_values : <EOL> tank . append ( "<STR_LIT>" % num_allowed_values ) <EOL> for av in allowedValues [ : av_limit ] : <EOL> av_info = "<STR_LIT>" % av . StringValue <EOL> tank . append ( av_info ) <EOL> if len ( allowedValues ) > av_limit : <EOL> tank . append ( "<STR_LIT>" % ( len ( allowedValues ) - av_limit ) ) <EOL> for item in required + optional : <EOL> print item . encode ( '<STR_LIT:utf-8>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
