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_string, 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
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

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

Properties [hide private]
model.Class or model.Field end
The descriptor for the last part of the string.

Inherited from object: __class__

Method Details [hide private]

__init__(self, path_string, 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_string (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

Property Details [hide private]

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