<s> __version__ = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> import sys <EOL> import re <EOL> import types <EOL> from . restapi import hydrateAnInstance <EOL> from . restapi import getResourceByOID <EOL> from . restapi import getCollection <EOL> from . config import WEB_SERVICE , WS_API_VERSION <EOL> VERSION_ATTRIBUTES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> MINIMAL_ATTRIBUTES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> PORTFOLIO_ITEM_SUB_TYPES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> SLM_WS_VER = '<STR_LIT>' % ( WEB_SERVICE % WS_API_VERSION ) <EOL> _rally_schema = { } <EOL> _rally_entity_cache = { } <EOL> class UnreferenceableOIDError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class InvalidRallyTypeNameError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class UnrecognizedAllowedValuesReference ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class Persistable ( object ) : <EOL> def __init__ ( self , oid , name , resource_url , context ) : <EOL> """<STR_LIT>""" <EOL> self . oid = oid <EOL> self . Name = name <EOL> self . _ref = resource_url <EOL> self . _hydrated = False <EOL> self . _context = context <EOL> def attributes ( self ) : <EOL> """<STR_LIT>""" <EOL> attrs = sorted ( self . __dict__ . keys ( ) ) <EOL> attrs . remove ( '<STR_LIT>' ) <EOL> return attrs <EOL> def __getattr__ ( self , name ) : <EOL> """<STR_LIT>""" <EOL> global SLM_WS_VER <EOL> if name == "<STR_LIT>" : <EOL> entity_name , oid = self . _ref . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:2> : ] <EOL> return '<STR_LIT>' % ( entity_name , oid ) <EOL> if name == '<STR_LIT>' : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> rallyEntityTypeName = self . __class__ . __name__ <EOL> entity_path , oid = self . _ref . split ( SLM_WS_VER ) [ - <NUM_LIT:1> ] . rsplit ( '<STR_LIT:/>' , <NUM_LIT:1> ) <EOL> if entity_path . startswith ( '<STR_LIT>' ) : <EOL> rallyEntityTypeName = entity_path . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] . capitalize ( ) <EOL> faultTrigger = "<STR_LIT>" % ( rallyEntityTypeName , name , self . _hydrated ) <EOL> if not self . _hydrated : <EOL> entity_name , oid = self . _ref . split ( SLM_WS_VER ) [ - <NUM_LIT:1> ] . rsplit ( '<STR_LIT:/>' , <NUM_LIT:1> ) <EOL> response = getResourceByOID ( self . _context , entity_name , self . oid , unwrap = True ) <EOL> if not response : <EOL> raise UnreferenceableOIDError ( "<STR_LIT>" % ( rallyEntityTypeName , self . oid ) ) <EOL> if not isinstance ( response , object ) : <EOL> raise UnreferenceableOIDError ( "<STR_LIT>" % ( rallyEntityTypeName , self . oid ) ) <EOL> if response . status_code != <NUM_LIT:200> : <EOL> raise UnreferenceableOIDError ( "<STR_LIT>" % ( rallyEntityTypeName , self . oid ) ) <EOL> item = response . content [ rallyEntityTypeName ] <EOL> hydrateAnInstance ( self . _context , item , existingInstance = self ) <EOL> self . _hydrated = True <EOL> if name in self . attributes ( ) : <EOL> return self . __dict__ [ name ] <EOL> name_with_custom_prefix = "<STR_LIT>" % name . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) <EOL> if name_with_custom_prefix in self . attributes ( ) : <EOL> return self . __dict__ [ name_with_custom_prefix ] <EOL> coll_ref_field = '<STR_LIT>' % name <EOL> if coll_ref_field in self . __dict__ . keys ( ) : <EOL> collection_ref = self . __dict__ [ coll_ref_field ] <EOL> collection = getCollection ( self . _context , collection_ref , _disableAugments = False ) <EOL> if name != "<STR_LIT>" : <EOL> self . __dict__ [ name ] = [ item for item in collection ] <EOL> else : <EOL> self . __dict__ [ name ] = self . _hydrateRevisionHistory ( collection_ref , collection ) <EOL> del self . __dict__ [ coll_ref_field ] <EOL> return self . __dict__ [ name ] <EOL> else : <EOL> description = "<STR_LIT>" % ( rallyEntityTypeName , name ) <EOL> raise AttributeError ( description ) <EOL> def _hydrateRevisionHistory ( self , collection_ref , collection ) : <EOL> """<STR_LIT>""" <EOL> rev_hist_raw = collection . data [ u'<STR_LIT>' ] [ u'<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> rev_hist_oid = rev_hist_raw [ u'<STR_LIT>' ] <EOL> revs_ref = rev_hist_raw [ u'<STR_LIT>' ] [ u'<STR_LIT>' ] <EOL> rev_hist = RevisionHistory ( rev_hist_oid , '<STR_LIT>' , collection_ref , self . _context ) <EOL> revisions = getCollection ( self . _context , revs_ref , _disableAugments = False ) <EOL> rev_hist . Revisions = [ revision for revision in revisions ] <EOL> rev_hist . _hydrated = True <EOL> return rev_hist <EOL> class Subscription ( Persistable ) : pass <EOL> class AllowedAttributeValue ( Persistable ) : pass <EOL> class AllowedQueryOperator ( Persistable ) : pass <EOL> class DomainObject ( Persistable ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class User ( DomainObject ) : <EOL> USER_ATTRIBUTES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> def details ( self ) : <EOL> """<STR_LIT>""" <EOL> tank = [ '<STR_LIT:%s>' % self . _type ] <EOL> for attribute_name in self . USER_ATTRIBUTES [ <NUM_LIT:1> : ] : <EOL> try : <EOL> value = getattr ( self , attribute_name ) <EOL> except AttributeError : <EOL> continue <EOL> if value is None : <EOL> continue <EOL> if '<STR_LIT>' not in str ( type ( value ) ) : <EOL> anv = '<STR_LIT>' % ( attribute_name , value ) <EOL> else : <EOL> mo = re . search ( r'<STR_LIT>' , str ( type ( value ) ) ) <EOL> if mo : <EOL> cln = mo . group ( <NUM_LIT:1> ) <EOL> anv = "<STR_LIT>" % ( attribute_name , cln + '<STR_LIT>' , value . oid , value . Name ) <EOL> else : <EOL> anv = "<STR_LIT>" % value <EOL> tank . append ( anv ) <EOL> return "<STR_LIT:\n>" . join ( tank ) <EOL> class UserProfile ( DomainObject ) : <EOL> USER_PROFILE_ATTRIBUTES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> def details ( self ) : <EOL> """<STR_LIT>""" <EOL> tank = [ '<STR_LIT:%s>' % self . _type ] <EOL> for attribute_name in self . USER_PROFILE_ATTRIBUTES [ <NUM_LIT:1> : ] : <EOL> try : <EOL> value = getattr ( self , attribute_name ) <EOL> except AttributeError : <EOL> continue <EOL> if '<STR_LIT>' not in str ( type ( value ) ) : <EOL> anv = '<STR_LIT>' % ( attribute_name , value ) <EOL> else : <EOL> mo = re . search ( r'<STR_LIT>' , str ( type ( value ) ) ) <EOL> if mo : <EOL> cln = mo . group ( <NUM_LIT:1> ) <EOL> anv = "<STR_LIT>" % ( attribute_name , cln + '<STR_LIT>' , value . oid , value . Name ) <EOL> else : <EOL> anv = "<STR_LIT>" % value <EOL> tank . append ( anv ) <EOL> return "<STR_LIT:\n>" . join ( tank ) <EOL> class Workspace ( DomainObject ) : pass <EOL> class Blocker ( DomainObject ) : pass <EOL> class UserPermission ( DomainObject ) : pass <EOL> class WorkspacePermission ( UserPermission ) : pass <EOL> class ProjectPermission ( UserPermission ) : pass <EOL> class WorkspaceDomainObject ( DomainObject ) : <EOL> """<STR_LIT>""" <EOL> COMMON_ATTRIBUTES = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:Name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> def details ( self ) : <EOL> """<STR_LIT>""" <EOL> tank = [ '<STR_LIT:%s>' % self . _type ] <EOL> for attribute_name in self . COMMON_ATTRIBUTES [ <NUM_LIT:1> : ] : <EOL> try : <EOL> value = getattr ( self , attribute_name ) <EOL> except AttributeError : <EOL> continue <EOL> if value is None : <EOL> continue <EOL> if '<STR_LIT>' not in str ( type ( value ) ) : <EOL> anv = '<STR_LIT>' % ( attribute_name , value ) <EOL> else : <EOL> mo = re . search ( r'<STR_LIT>' , str ( type ( value ) ) ) <EOL> if mo : <EOL> cln = mo . group ( <NUM_LIT:1> ) <EOL> anv = "<STR_LIT>" % ( attribute_name , cln + '<STR_LIT>' , value . oid , value . Name ) <EOL> else : <EOL> anv = "<STR_LIT>" % ( attribute_name , value ) <EOL> tank . append ( anv ) <EOL> tank . append ( "<STR_LIT>" ) <EOL> other_attributes = set ( self . attributes ( ) ) - set ( self . COMMON_ATTRIBUTES ) <EOL> for attribute_name in sorted ( other_attributes ) : <EOL> try : <EOL> value = getattr ( self , attribute_name ) <EOL> except AttributeError : <EOL> continue <EOL> attr_name = attribute_name <EOL> if attribute_name . startswith ( '<STR_LIT>' ) : <EOL> attr_name = attribute_name [ <NUM_LIT:2> : ] <EOL> if not isinstance ( value , Persistable ) : <EOL> anv = "<STR_LIT>" % ( attr_name , value ) <EOL> else : <EOL> mo = re . search ( r'<STR_LIT>' , str ( type ( value ) ) ) <EOL> if not mo : <EOL> anv = "<STR_LIT>" % ( attr_name , value ) <EOL> continue <EOL> cln = mo . group ( <NUM_LIT:1> ) <EOL> anv = "<STR_LIT>" % ( attr_name , cln + '<STR_LIT>' ) <EOL> if isinstance ( value , Artifact ) : <EOL> anv = "<STR_LIT>" % ( anv , value . oid , value . FormattedID ) <EOL> elif isinstance ( value , User ) : <EOL> anv = "<STR_LIT>" % ( attr_name , cln , value . oid , value . UserName , value . DisplayName ) <EOL> else : <EOL> anv = "<STR_LIT>" % ( anv , value . oid , value . Name ) <EOL> tank . append ( anv ) <EOL> return "<STR_LIT:\n>" . join ( tank ) <EOL> class WorkspaceConfiguration ( WorkspaceDomainObject ) : pass <EOL> class Type ( WorkspaceDomainObject ) : pass <EOL> class Program ( WorkspaceDomainObject ) : pass <EOL> class Project ( WorkspaceDomainObject ) : pass <EOL> class Release ( WorkspaceDomainObject ) : pass <EOL> class Iteration ( WorkspaceDomainObject ) : pass <EOL> class ArtifactNotification ( WorkspaceDomainObject ) : pass <EOL> class AttributeDefinition ( WorkspaceDomainObject ) : pass <EOL> class TypeDefinition ( WorkspaceDomainObject ) : pass <EOL> class Attachment ( WorkspaceDomainObject ) : pass <EOL> class AttachmentContent ( WorkspaceDomainObject ) : pass <EOL> class Build ( WorkspaceDomainObject ) : pass <EOL> class BuildDefinition ( WorkspaceDomainObject ) : pass <EOL> class BuildMetric ( WorkspaceDomainObject ) : pass <EOL> class BuildMetricDefinition ( WorkspaceDomainObject ) : pass <EOL> class Change ( WorkspaceDomainObject ) : pass <EOL> class Changeset ( WorkspaceDomainObject ) : pass <EOL> class ConversationPost ( WorkspaceDomainObject ) : pass <EOL> class Milestone ( WorkspaceDomainObject ) : pass <EOL> class Preference ( WorkspaceDomainObject ) : pass <EOL> class PreliminaryEstimate ( WorkspaceDomainObject ) : pass <EOL> class SCMRepository ( WorkspaceDomainObject ) : pass <EOL> class State ( WorkspaceDomainObject ) : pass <EOL> class TestCaseStep ( WorkspaceDomainObject ) : pass <EOL> class TestCaseResult ( WorkspaceDomainObject ) : pass <EOL> class TestFolder ( WorkspaceDomainObject ) : pass <EOL> class Tag ( WorkspaceDomainObject ) : pass <EOL> class TimeEntryItem ( WorkspaceDomainObject ) : pass <EOL> class TimeEntryValue ( WorkspaceDomainObject ) : pass <EOL> class UserIterationCapacity ( WorkspaceDomainObject ) : pass <EOL> class RecycleBinEntry ( WorkspaceDomainObject ) : pass <EOL> class RevisionHistory ( WorkspaceDomainObject ) : pass <EOL> class Revision ( WorkspaceDomainObject ) : <EOL> INFO_ATTRS = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def info ( self ) : <EOL> rev_num = self . RevisionNumber <EOL> desc = self . Description <EOL> activity_timestamp = self . CreationDate <EOL> whodunit = self . User . Name <EOL> rev_blurb = "<STR_LIT>" % ( rev_num , activity_timestamp , whodunit , desc ) <EOL> return rev_blurb <EOL> class WebLinkDefinition ( AttributeDefinition ) : pass <EOL> class CumulativeFlowData ( WorkspaceDomainObject ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class ReleaseCumulativeFlowData ( CumulativeFlowData ) : pass <EOL> class IterationCumulativeFlowData ( CumulativeFlowData ) : pass <EOL> class Artifact ( WorkspaceDomainObject ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class SchedulableArtifact ( Artifact ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class Requirement ( SchedulableArtifact ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class HierarchicalRequirement ( Requirement ) : pass <EOL> UserStory = HierarchicalRequirement <EOL> Story = HierarchicalRequirement <EOL> class Task ( Artifact ) : pass <EOL> class Defect ( Artifact ) : pass <EOL> class TestCase ( Artifact ) : pass <EOL> class DefectSuite ( SchedulableArtifact ) : pass <EOL> class TestSet ( SchedulableArtifact ) : pass <EOL> class PortfolioItem ( Artifact ) : pass <EOL> class PortfolioItem_Strategy ( PortfolioItem ) : pass <EOL> class PortfolioItem_Initiative ( PortfolioItem ) : pass <EOL> class PortfolioItem_Theme ( PortfolioItem ) : pass <EOL> class PortfolioItem_Feature ( PortfolioItem ) : pass <EOL> class CustomField ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , oid , name , resource_url , context ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . oid = oid <EOL> self . Name = name <EOL> self . _ref = resource_url <EOL> self . _context = context <EOL> self . _hydrated = False <EOL> def so_element_text ( mo ) : <EOL> return mo . group ( '<STR_LIT>' ) + '<STR_LIT>' if mo else "<STR_LIT>" <EOL> def so_bolded_text ( mo ) : <EOL> return "<STR_LIT>" % mo . group ( '<STR_LIT>' ) if mo else "<STR_LIT>" <EOL> class SearchObject ( object ) : <EOL> """<STR_LIT>""" <EOL> tagged_field_name_pattern = re . compile ( r'<STR_LIT>' ) <EOL> bolding_pattern = re . compile ( r'<STR_LIT>' ) <EOL> def __init__ ( self , oid , name , resource_url , context ) : <EOL> """<STR_LIT>""" <EOL> self . oid = self . ObjectID = oid <EOL> self . Name = name <EOL> self . _ref = resource_url <EOL> self . _hydrated = True <EOL> self . _context = context <EOL> def __setattr__ ( self , item , value ) : <EOL> self . __dict__ [ item ] = value <EOL> if item == '<STR_LIT>' : <EOL> scrubbed = re . sub ( self . tagged_field_name_pattern , so_element_text , value ) <EOL> scrubbed = re . sub ( self . bolding_pattern , so_bolded_text , scrubbed ) <EOL> self . __dict__ [ item ] = scrubbed <EOL> return self . __dict__ [ item ] <EOL> classFor = { '<STR_LIT>' : Persistable , <EOL> '<STR_LIT>' : DomainObject , <EOL> '<STR_LIT>' : WorkspaceDomainObject , <EOL> '<STR_LIT>' : Subscription , <EOL> '<STR_LIT>' : User , <EOL> '<STR_LIT>' : UserProfile , <EOL> '<STR_LIT>' : UserPermission , <EOL> '<STR_LIT>' : Workspace , <EOL> '<STR_LIT>' : WorkspaceConfiguration , <EOL> '<STR_LIT>' : WorkspacePermission , <EOL> '<STR_LIT>' : Type , <EOL> '<STR_LIT>' : TypeDefinition , <EOL> '<STR_LIT>' : AttributeDefinition , <EOL> '<STR_LIT>' : Program , <EOL> '<STR_LIT>' : Project , <EOL> '<STR_LIT>' : ProjectPermission , <EOL> '<STR_LIT>' : Artifact , <EOL> '<STR_LIT>' : ArtifactNotification , <EOL> '<STR_LIT>' : Release , <EOL> '<STR_LIT>' : Iteration , <EOL> '<STR_LIT>' : Requirement , <EOL> '<STR_LIT>' : HierarchicalRequirement , <EOL> '<STR_LIT>' : UserStory , <EOL> '<STR_LIT>' : Story , <EOL> '<STR_LIT>' : Task , <EOL> '<STR_LIT>' : Tag , <EOL> '<STR_LIT>' : Preference , <EOL> '<STR_LIT>' : SCMRepository , <EOL> '<STR_LIT>' : RevisionHistory , <EOL> '<STR_LIT>' : Revision , <EOL> '<STR_LIT>' : Attachment , <EOL> '<STR_LIT>' : AttachmentContent , <EOL> '<STR_LIT>' : TestCase , <EOL> '<STR_LIT>' : TestCaseStep , <EOL> '<STR_LIT>' : TestCaseResult , <EOL> '<STR_LIT>' : TestSet , <EOL> '<STR_LIT>' : TestFolder , <EOL> '<STR_LIT>' : TimeEntryItem , <EOL> '<STR_LIT>' : TimeEntryValue , <EOL> '<STR_LIT>' : Build , <EOL> '<STR_LIT>' : BuildDefinition , <EOL> '<STR_LIT>' : BuildMetric , <EOL> '<STR_LIT>' : BuildMetricDefinition , <EOL> '<STR_LIT>' : Defect , <EOL> '<STR_LIT>' : DefectSuite , <EOL> '<STR_LIT>' : Change , <EOL> '<STR_LIT>' : Changeset , <EOL> '<STR_LIT>' : PortfolioItem , <EOL> '<STR_LIT>' : PortfolioItem_Strategy , <EOL> '<STR_LIT>' : PortfolioItem_Initiative , <EOL> '<STR_LIT>' : PortfolioItem_Theme , <EOL> '<STR_LIT>' : PortfolioItem_Feature , <EOL> '<STR_LIT>' : State , <EOL> '<STR_LIT>' : PreliminaryEstimate , <EOL> '<STR_LIT>' : WebLinkDefinition , <EOL> '<STR_LIT>' : Milestone , <EOL> '<STR_LIT>' : ConversationPost , <EOL> '<STR_LIT>' : Blocker , <EOL> '<STR_LIT>' : AllowedAttributeValue , <EOL> '<STR_LIT>' : AllowedQueryOperator , <EOL> '<STR_LIT>' : CustomField , <EOL> '<STR_LIT>' : UserIterationCapacity , <EOL> '<STR_LIT>' : CumulativeFlowData , <EOL> '<STR_LIT>' : ReleaseCumulativeFlowData , <EOL> '<STR_LIT>' : IterationCumulativeFlowData , <EOL> '<STR_LIT>' : RecycleBinEntry , <EOL> '<STR_LIT>' : SearchObject , <EOL> } <EOL> for entity_name , entity_class in classFor . items ( ) : <EOL> _rally_entity_cache [ entity_name ] = entity_name <EOL> entity_class = None <EOL> def pred ( c ) : <EOL> return inspect . isclass ( c ) and c . __module__ == pred . __module__ <EOL> import inspect <EOL> classes = inspect . getmembers ( sys . modules [ __name__ ] , pred ) <EOL> for cls_name , cls in classes : <EOL> if cls_name not in _rally_entity_cache and re . search ( "<STR_LIT>" , cls_name ) : <EOL> _rally_entity_cache [ cls_name ] = cls_name <EOL> class SchemaItem ( object ) : <EOL> def __init__ ( self , raw_info ) : <EOL> self . _type = '<STR_LIT>' <EOL> self . ref = "<STR_LIT:/>" . join ( raw_info [ u'<STR_LIT>' ] . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:2> : ] ) <EOL> self . ObjectName = str ( raw_info [ u'<STR_LIT>' ] ) <EOL> self . ElementName = str ( raw_info [ u'<STR_LIT>' ] ) <EOL> self . Name = str ( raw_info [ u'<STR_LIT:Name>' ] ) <EOL> self . DisplayName = str ( raw_info [ u'<STR_LIT>' ] ) <EOL> self . TypePath = str ( raw_info [ u'<STR_LIT>' ] ) <EOL> self . IDPrefix = str ( raw_info [ u'<STR_LIT>' ] ) <EOL> self . Abstract = raw_info [ u'<STR_LIT>' ] <EOL> self . Parent = raw_info [ u'<STR_LIT>' ] <EOL> if self . Parent : <EOL> self . Parent = str ( self . Parent [ u'<STR_LIT>' ] ) <EOL> self . Creatable = raw_info [ u'<STR_LIT>' ] <EOL> self . Queryable = raw_info [ u'<STR_LIT>' ] <EOL> self . ReadOnly = raw_info [ u'<STR_LIT>' ] <EOL> self . Deletable = raw_info [ u'<STR_LIT>' ] <EOL> self . Restorable = raw_info [ u'<STR_LIT>' ] <EOL> self . Ordinal = raw_info [ u'<STR_LIT>' ] <EOL> self . RevisionHistory = raw_info [ u'<STR_LIT>' ] <EOL> self . Attributes = [ ] <EOL> for attr in raw_info [ u'<STR_LIT>' ] : <EOL> self . Attributes . append ( SchemaItemAttribute ( attr ) ) <EOL> self . completed = False <EOL> def complete ( self , context , getCollection ) : <EOL> """<STR_LIT>""" <EOL> if self . completed : <EOL> return True <EOL> for attribute in self . Attributes : <EOL> attribute . resolveAllowedValues ( context , getCollection ) <EOL> self . completed = True <EOL> return self . completed <EOL> def inheritanceChain ( self ) : <EOL> """<STR_LIT>""" <EOL> klass = classFor [ self . Name . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) ] <EOL> ancestors = [ ] <EOL> for ancestor in klass . mro ( ) : <EOL> mo = re . search ( r"<STR_LIT>" , str ( ancestor ) ) <EOL> if mo : <EOL> ancestors . append ( mo . group ( <NUM_LIT:1> ) ) <EOL> ancestors . reverse ( ) <EOL> return ancestors <EOL> def __str__ ( self ) : <EOL> """<STR_LIT>""" <EOL> abstract = "<STR_LIT>" if self . Abstract else "<STR_LIT>" <EOL> parentage = "<STR_LIT>" % self . Parent if self . Parent != self . ElementName else "<STR_LIT>" <EOL> abs_par = "<STR_LIT>" % ( abstract , parentage ) <EOL> tp = "<STR_LIT>" % self . TypePath if '<STR_LIT:/>' in self . TypePath else "<STR_LIT>" <EOL> head_line = "<STR_LIT>" % ( self . ElementName , self . DisplayName , self . IDPrefix , tp ) <EOL> creatable = "<STR_LIT>" if self . Creatable else "<STR_LIT>" <EOL> read_only = "<STR_LIT>" if self . ReadOnly else "<STR_LIT>" <EOL> queryable = "<STR_LIT>" if self . Queryable else "<STR_LIT>" <EOL> deletable = "<STR_LIT>" if self . Deletable else "<STR_LIT>" <EOL> restorable = "<STR_LIT>" if self . Restorable else "<STR_LIT>" <EOL> ops_line = "<STR_LIT>" % ( creatable , read_only , queryable , deletable , restorable ) <EOL> attr_hdr = "<STR_LIT>" <EOL> attrs = [ str ( attr ) + "<STR_LIT:\n>" for attr in self . Attributes ] <EOL> general = "<STR_LIT:\n>" . join ( [ head_line , ops_line , "<STR_LIT>" , attr_hdr ] ) <EOL> return general + "<STR_LIT:\n>" + "<STR_LIT:\n>" . join ( attrs ) <EOL> class SchemaItemAttribute ( object ) : <EOL> def __init__ ( self , attr_info ) : <EOL> self . _type = "<STR_LIT>" <EOL> self . ref = "<STR_LIT:/>" . join ( attr_info [ u'<STR_LIT>' ] [ - <NUM_LIT:2> : ] ) <EOL> self . ObjectName = str ( attr_info [ u'<STR_LIT>' ] ) <EOL> self . ElementName = str ( attr_info [ u'<STR_LIT>' ] ) <EOL> self . Name = str ( attr_info [ u'<STR_LIT:Name>' ] ) <EOL> self . AttributeType = str ( attr_info [ u'<STR_LIT>' ] ) <EOL> self . Subscription = attr_info [ u'<STR_LIT>' ] <EOL> self . Workspace = attr_info [ u'<STR_LIT>' ] <EOL> self . Custom = attr_info [ u'<STR_LIT>' ] <EOL> self . Required = attr_info [ u'<STR_LIT>' ] <EOL> self . ReadOnly = attr_info [ u'<STR_LIT>' ] <EOL> self . Filterable = attr_info [ u'<STR_LIT>' ] <EOL> self . Hidden = attr_info [ u'<STR_LIT>' ] <EOL> self . SchemaType = attr_info [ u'<STR_LIT>' ] <EOL> self . Constrained = attr_info [ u'<STR_LIT>' ] <EOL> self . AllowedValueType = attr_info [ u'<STR_LIT>' ] <EOL> self . AllowedValues = attr_info [ u'<STR_LIT>' ] <EOL> self . MaxLength = attr_info [ u'<STR_LIT>' ] <EOL> self . MaxFractionalDigits = attr_info [ u'<STR_LIT>' ] <EOL> if self . AllowedValues and type ( self . AllowedValues ) == types . DictType : <EOL> self . AllowedValues = str ( self . AllowedValues [ u'<STR_LIT>' ] ) <EOL> self . _allowed_values = True <EOL> self . _allowed_values_resolved = False <EOL> elif self . AllowedValues and type ( self . AllowedValues ) == types . ListType : <EOL> buffer = [ ] <EOL> for item in self . AllowedValues : <EOL> aav = AllowedAttributeValue ( <NUM_LIT:0> , item [ u'<STR_LIT>' ] , None , None ) <EOL> aav . Name = item [ u'<STR_LIT>' ] <EOL> aav . StringValue = item [ u'<STR_LIT>' ] <EOL> aav . _hydrated = True <EOL> buffer . append ( aav ) <EOL> self . AllowedValues = buffer [ : ] <EOL> self . _allowed_values = True <EOL> self . _allowed_values_resolved = True <EOL> else : <EOL> self . _allowed_values = False <EOL> def resolveAllowedValues ( self , context , getCollection ) : <EOL> """<STR_LIT>""" <EOL> if not self . _allowed_values : <EOL> self . _allowed_values_resolved = True <EOL> return True <EOL> if self . _allowed_values_resolved : <EOL> return True <EOL> if type ( self . AllowedValues ) != types . StringType : <EOL> return True <EOL> std_av_ref_pattern = '<STR_LIT>' <EOL> mo = re . match ( std_av_ref_pattern , self . AllowedValues ) <EOL> if not mo : <EOL> anomaly = "<STR_LIT>" % ( std_av_ref_pattern , self . AllowedValues ) <EOL> raise UnrecognizedAllowedValuesReference ( anomaly ) <EOL> collection = getCollection ( context , self . AllowedValues ) <EOL> self . AllowedValues = [ value for value in collection ] <EOL> self . _allowed_values_resolved = True <EOL> return True <EOL> def __str__ ( self ) : <EOL> ident = self . ElementName <EOL> disp = "<STR_LIT>" % self . Name if self . Name != self . ElementName else "<STR_LIT>" <EOL> custom = "<STR_LIT>" if not self . Custom else "<STR_LIT>" <EOL> attr_type = self . AttributeType <EOL> required = "<STR_LIT>" if self . Required else "<STR_LIT>" <EOL> ident_line = "<STR_LIT>" % ( ident , custom , attr_type , required , disp ) <EOL> ro = "<STR_LIT>" if self . ReadOnly else "<STR_LIT>" <EOL> filt = "<STR_LIT>" if self . Filterable else "<STR_LIT>" <EOL> hidden = "<STR_LIT>" if self . Hidden else "<STR_LIT>" <EOL> constr = "<STR_LIT>" if self . Constrained else "<STR_LIT>" <EOL> misc_line = "<STR_LIT>" % ( ro , filt , hidden , constr ) <EOL> st_line = "<STR_LIT>" % self . SchemaType <EOL> output_lines = [ ident_line , misc_line ] <EOL> if self . AllowedValueType and not self . _allowed_values_resolved : <EOL> avt_ref = "<STR_LIT:/>" . join ( self . AllowedValueType [ u'<STR_LIT>' ] . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:2> : ] ) <EOL> avt_line = "<STR_LIT>" % avt_ref <EOL> avv_ref = "<STR_LIT:/>" . join ( self . AllowedValues . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:3> : ] ) <EOL> avv_line = "<STR_LIT>" % avv_ref <EOL> output_lines . append ( avv_line ) <EOL> elif self . _allowed_values_resolved : <EOL> if self . AllowedValues and type ( self . AllowedValues ) == types . ListType : <EOL> avs = [ ] <EOL> for ix , item in enumerate ( self . AllowedValues ) : <EOL> if type ( item ) == types . DictType : <EOL> avs . append ( str ( item [ u'<STR_LIT>' ] ) ) <EOL> else : <EOL> avs . append ( str ( item . __dict__ [ u'<STR_LIT>' ] ) ) <EOL> avv_line = "<STR_LIT>" % avs <EOL> output_lines . append ( avv_line ) <EOL> return "<STR_LIT:\n>" . join ( output_lines ) <EOL> def getEntityName ( candidate ) : <EOL> """<STR_LIT>""" <EOL> global _rally_entity_cache <EOL> official_name = candidate <EOL> hits = [ path for entity , path in _rally_entity_cache . items ( ) <EOL> if '<STR_LIT:/>' in path and path . split ( '<STR_LIT:/>' ) [ <NUM_LIT:1> ] == candidate ] <EOL> if hits : <EOL> official_name = hits . pop ( <NUM_LIT:0> ) <EOL> return official_name <EOL> def validRallyType ( candidate ) : <EOL> """<STR_LIT>""" <EOL> global _rally_entity_cache <EOL> if candidate in _rally_entity_cache : <EOL> return getEntityName ( candidate ) <EOL> if candidate in PORTFOLIO_ITEM_SUB_TYPES : <EOL> pi_candidate = '<STR_LIT>' % candidate <EOL> return getEntityName ( pi_candidate ) <EOL> raise InvalidRallyTypeNameError ( candidate ) <EOL> def processSchemaInfo ( workspace , schema_info ) : <EOL> """<STR_LIT>""" <EOL> wksp_name , wksp_ref = workspace <EOL> global _rally_schema <EOL> global _rally_entity_cache <EOL> _rally_schema [ wksp_ref ] = { } <EOL> for ix , raw_item_info in enumerate ( schema_info ) : <EOL> item = SchemaItem ( raw_item_info ) <EOL> _rally_schema [ wksp_ref ] [ item . ElementName ] = item <EOL> if item . Abstract : <EOL> continue <EOL> if not _rally_entity_cache . has_key ( item . ElementName ) : <EOL> _rally_entity_cache [ item . ElementName ] = item . ElementName <EOL> if item . TypePath != item . ElementName : <EOL> _rally_schema [ wksp_ref ] [ item . TypePath ] = item <EOL> if not _rally_entity_cache . has_key ( item . TypePath ) : <EOL> _rally_entity_cache [ item . TypePath ] = item . TypePath <EOL> _rally_schema [ wksp_ref ] [ '<STR_LIT>' ] = _rally_schema [ wksp_ref ] [ '<STR_LIT>' ] <EOL> _rally_schema [ wksp_ref ] [ '<STR_LIT>' ] = _rally_schema [ wksp_ref ] [ '<STR_LIT>' ] <EOL> unaccounted_for_entities = [ entity_name for entity_name in _rally_schema [ wksp_ref ] . keys ( ) <EOL> if not classFor . has_key ( entity_name ) <EOL> and not entity_name . startswith ( '<STR_LIT>' ) <EOL> ] <EOL> for entity_name in unaccounted_for_entities : <EOL> if entity_name in [ '<STR_LIT>' ] : <EOL> continue <EOL> entity = _rally_schema [ wksp_ref ] [ entity_name ] <EOL> typePath = entity . TypePath <EOL> pyralized_class_name = str ( typePath . replace ( '<STR_LIT:/>' , '<STR_LIT:_>' ) ) <EOL> if not classFor . has_key ( pyralized_class_name ) : <EOL> parentClass = WorkspaceDomainObject <EOL> if entity . Parent : <EOL> try : <EOL> parentClass = classFor [ entity . Parent ] <EOL> except : <EOL> pass <EOL> rally_entity_class = _createClass ( pyralized_class_name , parentClass ) <EOL> classFor [ typePath ] = rally_entity_class <EOL> def getSchemaItem ( workspace , entity_name ) : <EOL> wksp_name , wksp_ref = workspace <EOL> global _rally_schema <EOL> if wksp_ref not in _rally_schema : <EOL> raise Exception ( "<STR_LIT>" % wksp_ref ) <EOL> schema = _rally_schema [ wksp_ref ] <EOL> if not schema . has_key ( entity_name ) : <EOL> return None <EOL> return schema [ entity_name ] <EOL> def _createClass ( name , parentClass ) : <EOL> """<STR_LIT>""" <EOL> rally_entity_class = type ( name , ( parentClass , ) , { } ) <EOL> globals ( ) [ name ] = rally_entity_class <EOL> return rally_entity_class <EOL> __all__ = [ processSchemaInfo , classFor , validRallyType , getSchemaItem , <EOL> InvalidRallyTypeNameError , UnrecognizedAllowedValuesReference , <EOL> PORTFOLIO_ITEM_SUB_TYPES <EOL> ] </s>
