Package epydoc :: Module apidoc :: Class DottedName
[hide private]
[frames] | no frames]

Class DottedName
source code

A sequence of identifiers, separated by periods, used to name a Python variable, value, or argument. The identifiers that make up a dotted name can be accessed using the indexing operator:
>>> name = DottedName('epydoc', 'api_doc', 'DottedName')
>>> print name
epydoc.apidoc.DottedName

>>> name[1]
'api_doc'


Nested Classes [hide private]
InvalidDottedName An exception raised by the DottedName constructor when one of its arguments is not a valid dotted name.

Instance Methods [hide private]
  __init__(self, *pieces)
Construct a new dotted name from the given sequence of pieces, each of which can be either a string or a DottedName.
  __repr__(self)
  __str__(self)
Return the dotted name as a string formed by joining its identifiers with periods:
  __add__(self, other)
Return a new DottedName whose identifier sequence is formed by adding other's identifier sequence to self's.
  __radd__(self, other)
Return a new DottedName whose identifier sequence is formed by adding self's identifier sequence to other's.
  __getitem__(self, i)
Return the ith identifier in this DottedName.
  __hash__(self)
  __cmp__(self, other)
Compare this dotted name to other.
  __len__(self)
Return the number of identifiers in this dotted name.
  container(self)
Return the DottedName formed by removing the last identifier from this dotted name's identifier sequence.
  dominates(self, name, strict=False)
Return true if this dotted name is equal to a prefix of name.
DottedName contextualize(self, context)
If self and context share a common ancestor, then return a name for self, relative to that ancestor.

Class Variables [hide private]
UNREACHABLE  
_IDENTIFIER_RE  

Method Details [hide private]

__init__(self, *pieces)
(Constructor)

source code 
call graph 
Construct a new dotted name from the given sequence of pieces, each of which can be either a string or a DottedName. Each piece is divided into a sequence of identifiers, and these sequences are combined together (in order) to form the identifier sequence for the new DottedName. If a piece contains a string, then it is divided into substrings by splitting on periods, and each substring is checked to see if it is a valid identifier.

__repr__(self)
(Representation operator)

source code 

__str__(self)
(Informal representation operator)

source code 
call graph 
Return the dotted name as a string formed by joining its identifiers with periods:
>>> print DottedName('epydoc', 'api_doc', DottedName')
epydoc.apidoc.DottedName

__add__(self, other)
(Addition operator)

source code 
call graph 
Return a new DottedName whose identifier sequence is formed by adding other's identifier sequence to self's.

__radd__(self, other)
(Right-side addition operator)

source code 
call graph 
Return a new DottedName whose identifier sequence is formed by adding self's identifier sequence to other's.

__getitem__(self, i)
(Indexing operator)

source code 
call graph 
Return the ith identifier in this DottedName. If i is a non-empty slice, then return a DottedName built from the identifiers selected by the slice. If i is an empty slice, return an empty list (since empty DottedNames are not valid).

__hash__(self)
(Hashing function)

source code 

__cmp__(self, other)
(Comparison operator)

source code 
call graph 
Compare this dotted name to other. Two dotted names are considered equal if their identifier subsequences are equal. Ordering between dotted names is lexicographic, in order of identifier from left to right.

__len__(self)
(Length operator)

source code 
call graph 
Return the number of identifiers in this dotted name.

container(self)

source code 
call graph 
Return the DottedName formed by removing the last identifier from this dotted name's identifier sequence. If this dotted name only has one name in its identifier sequence, return None instead.

dominates(self, name, strict=False)

source code 
call graph 
Return true if this dotted name is equal to a prefix of name. If strict is true, then also require that self!=name.
>>> DottedName('a.b').dominates(DottedName('a.b.c.d'))
True

contextualize(self, context)

source code 
call graph 

If self and context share a common ancestor, then return a name for self, relative to that ancestor. If they do not share a common ancestor (or if context is UNKNOWN), then simply return self.

This is used to generate shorter versions of dotted names in cases where users can infer the intended target from the context.
Returns: DottedName

Class Variable Details [hide private]

UNREACHABLE

Value:
'??'                                                                   
      

_IDENTIFIER_RE

Value:
(\?\?|(script-)?[a-zA-Z_]\w*'?)(-\d+)?$