Package intermine :: Module model :: Class Path
[hide private]
[frames] | no frames]

Class Path

source code

object --+
         |
        Path

A class representing a validated dotted string path

A path represents a connection between records and fields

SYNOPSIS

>>> service = Service("http://www.flymine.org/query/service")
    model = service.model
    path = model.make_path("Gene.organism.name")
    path.is_attribute()
... True
>>> path2 = model.make_path("Gene.proteins")
    path2.is_attribute()
... False
>>> path2.is_reference()
... True
>>> path2.get_class()
... <intermine.model.Class: gene>

OVERVIEW

This class is used for performing validation on dotted path strings. The simple act of parsing it into existence will validate the path to some extent, but there are additional methods for verifying certain relationships as well

Instance Methods [hide private]
 
__init__(self, path, model, subclasses={})
You will not need to use this constructor directly.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
prefix(self) source code
 
append(self, *elements)
This is the inverse of prefix.
source code
model.Class
get_class(self)
Return the class object for this path, if it refers to a class or a reference.
source code
boolean
is_reference(self)
Return true if the path is a reference, eg: Gene.organism or Gene.proteins Note: Collections are ALSO references
source code
boolean
is_class(self)
Return true if the path just refers to a class, eg: Gene
source code
boolean
is_attribute(self)
Return true if the path refers to an attribute, eg: Gene.length
source code
 
__eq__(self, other) source code
 
__hash__(self)
hash(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
intermine.model.Class root
The descriptor for the first part of the string.
model.Class or model.Field end
The descriptor for the last part of the string.
model.Class end_class
Return the class object for this path, if it refers to a class or a reference.

Inherited from object: __class__

Method Details [hide private]

__init__(self, path, model, subclasses={})
(Constructor)

source code 

Constructor

>>> path = Path("Gene.name", model)

You will not need to use this constructor directly. Instead, use the "make_path" method on the model to construct paths for you.

Parameters:
  • path (str) - the dotted path string (eg: Gene.proteins.name)
  • model (Model) - the model to validate the path against
  • subclasses (dict) - a dict which maps subclasses (defaults to an empty dict)
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

get_class(self)

source code 

Return the class object for this path, if it refers to a class or a reference. Attribute paths return None

Returns: model.Class

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)

Property Details [hide private]

root

The descriptor for the first part of the string. This should always a class descriptor.

Get Method:
unreachable.root(self) - The descriptor for the first part of the string.
Type:
intermine.model.Class

end

The descriptor for the last part of the string.

Get Method:
unreachable.end(self) - The descriptor for the last part of the string.
Type:
model.Class or model.Field

end_class

Return the class object for this path, if it refers to a class or a reference. Attribute paths return None

Get Method:
get_class(self) - Return the class object for this path, if it refers to a class or a reference.
Type:
model.Class