Module api :: Class DaApi
[frames] | no frames]

Class DaApi

source code

Static Methods
 
getApiRevision()
Returns revision number of the API
source code
 
getProperties(tree, userAgent, cookie=None, typedValues=False, sought=None, uaPropsNeeded=False)
Returns an array of known properties (as strings) for the UA
source code
 
getPropertiesAsTyped(tree, userAgent, cookie=None)
Returns an array of known properties (as typed) for the UA
source code
 
getProperty(tree, userAgent, prop, cookie=None)
Returns a value for the named property of this user agent
source code
 
getPropertyAsBoolean(tree, userAgent, prop, cookie=None)
Strongly-typed property accessor.
source code
 
getPropertyAsDate(tree, userAgent, prop, cookie=None)
Strongly-typed property accessor.
source code
 
getPropertyAsInteger(tree, userAgent, prop, cookie=None)
Strongly-typed property accessor.
source code
 
getPropertyAsString(tree, userAgent, prop, cookie=None)
Strongly-typed property accessor.
source code
 
getTreeFromFile(filep, includeChangeableUserAgentProperties=True)
Returns a tree from a JSON file.
source code
 
getTreeFromString(json, includeChangeableUserAgentProperties=True)
Returns a tree from a JSON string return array tree
source code
 
getTreeGeneration(tree)
Get the generation date for this tree
source code
 
getTreeGenerationAsTimestamp(tree)
Returns revision number of the tree
source code
 
getTreeRevision(tree)
Returns revision number of the tree
source code
 
listProperties(tree)
Returns array of known property names.
source code
 
propertyFromId(tree, pid)
Return the name for a property's coded id
source code
Class Variables
  API_ID = '6'
  CLIENT_PROPS_HANDLER = '_cprops'
  COMPILED_REGEX = 'creg'
  ID_TO_PROPERTIES_WITH_TYPE = 'p'
  ID_TO_PROPERTY_WITHOUT_TYPE = 'pnr'
  ID_TO_VALUES = 'v'
  MAIN_TREE_BRANCH = 't'
  PROPERTIES_WITHOUT_TYPE_TO_ID = 'pn'
  PROPERTIES_WITH_TYPE_TO_ID = 'pr'
  REGEX = 'r'
  UA_PROPS_HANDLER = '_uaprops'
Method Details

getApiRevision()
Static Method

source code 

Returns revision number of the API

Arguments: tree -- previously loaded tree

Returns: Integer revision number

getProperties(tree, userAgent, cookie=None, typedValues=False, sought=None, uaPropsNeeded=False)
Static Method

source code 

Returns an array of known properties (as strings) for the UA

Arguments: tree -- previously generated tree userAgent -- string from devices User-Agent header

Returns: Dictionary of properties

getPropertiesAsTyped(tree, userAgent, cookie=None)
Static Method

source code 

Returns an array of known properties (as typed) for the UA

Arguments: tree --- previously generated tree userAgent -- string from devices User-Agent header

Returns: String property

getProperty(tree, userAgent, prop, cookie=None)
Static Method

source code 

Returns a value for the named property of this user agent

Arguments: tree -- previously generated tree userAgent -- string from devices User-Agent header property -- the name of the property to return

Returns: String property

getPropertyAsBoolean(tree, userAgent, prop, cookie=None)
Static Method

source code 

Strongly-typed property accessor. Returns boolean property. Throws exception of property is actually a different type

Arguments: tree -- previously generated tree userAgent -- string from devices User-Agent header property -- the name of the property to return

Returns: Boolean property

getPropertyAsDate(tree, userAgent, prop, cookie=None)
Static Method

source code 

Strongly-typed property accessor. Returns date property. Throws exception of property is actually a different type

Arguments: tree is previously generated tree userAgent is string from devices User-Agent header property is the name of the property to return

Returns: String property

getPropertyAsInteger(tree, userAgent, prop, cookie=None)
Static Method

source code 

Strongly-typed property accessor. Returns integer property. Throws exception of property is actually a different type

Arguments: tree -- previously generated tree userAgent -- string from devices User-Agent header property -- the name of the property to return

Returns: Integer property

getPropertyAsString(tree, userAgent, prop, cookie=None)
Static Method

source code 

Strongly-typed property accessor. Returns string property. Throws exception of property is actually a different type

Arguments: tree -- previously generated tree userAgent -- string from devices User-Agent header property -- the name of the property to return

Returns: String property

getTreeFromFile(filep, includeChangeableUserAgentProperties=True)
Static Method

source code 

Returns a tree from a JSON file. Use absolute path name to be sure of success if the current working directory is not clear

Some properties cannot be known before runtime and can change from user-agent to user-agent. The most common of these are the OS Version and the Browser Version. This API is able to dynamically detect these changing properties but introduces a small overhead to do so.

Arguments: file -- the location of the file to read includeChangeableUserAgentProperties -- set to False to disable returning extra properties set

Returns: Hash tree

getTreeFromString(json, includeChangeableUserAgentProperties=True)
Static Method

source code 

Returns a tree from a JSON string return array tree

Some properties cannot be known before runtime and can change from user-agent to user-agent. The most common of these are the OS Version and the Browser Version. This API is able to dynamically detect these changing properties but introduces a small overhead to do so. To disable returning these extra properties set <i>includeChangeableUserAgentProperties</i> to <b>false</b>.

Arguments: json -- a string of json data includeChangeableUserAgentProperties -- also detect changeable user-agent properties

Returns: The loaded JSON Trr

Throws: RunTimeError

getTreeGeneration(tree)
Static Method

source code 

Get the generation date for this tree

Arguments: tree -- previously loaded tree

Returns: The date/time when the tree was generated

getTreeGenerationAsTimestamp(tree)
Static Method

source code 

Returns revision number of the tree

Arguments: tree -- previously loaded tree

Returns: Integer revision number

getTreeRevision(tree)
Static Method

source code 

Returns revision number of the tree

Arguments: tree -- previously loaded tree

Returns: Integer revision number

listProperties(tree)
Static Method

source code 

Returns array of known property names. Returns all properties available for all user agents in this tree, with their data type names

Arguments: tree -- previously generated tree

Returns: Dictionary of properties

propertyFromId(tree, pid)
Static Method

source code 

Return the name for a property's coded id

Arguments: tree -- previously generated tree