Package mobi :: Package mtld :: Package da :: Package device :: Module tree :: Class Tree
[frames] | no frames]

Class Tree

object --+
         |
        Tree

This class parses the DeviceAtlas JSON data file and represents the data.


Copyright: Copyright (c) Afilias Technologies Limited 2021. All Rights Reserved.

Author: Afilias Technologies Limited

Instance Methods
 
__init__(self, json, config)
Load the JSON tree into a dictionary.
 
set_config(self, config)
Applies a new configuration object to the tree instance.
 
property_names(self)
Get a list of all possible property names.
 
data_version(self)
Returns the device data (JSON file) version.
 
data_creation_timestamp(self)
Returns the device data (JSON file) creation timestamp.
 
put_properties(self, user_agent, stock_user_agents, client_side_properties, properties)
Get properties from tree walk, User-Agent and client side and put them in the Tree properties.
 
put_tree_walk_properties(self, user_agent, stock_user_agents, properties)
Get properties from tree walk and User-Agent and put them in the Tree properties.
 
property_name_by_id(self, property_id)
 
property_value_by_id(self, value_id)

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

Class Variables
  MIN_JSON_VERSION = 0.7
  MAP_INITIAL_CAPACITY = 100
  KEY_DEVICE_ID = u'iid'
  KEY_META = u'$'
  KEY_META_VERSION = u'Ver'
  KEY_GOTO = u'g'
  KEY_META_REVISION = u'Rev'
  KEY_META_TIMESTAMP = u'Utc'
  KEY_PROPERTY_NAMES = u'p'
  KEY_VALUES = u'v'
  KEY_REGEX = u'r'
  KEY_COMPILED_REGEX = u'creg'
  KEY_HEADERS = u'h'
  KEY_UA_STOCK_HEADERS = u'sl'
  KEY_MAIN = u't'
  KEY_DATA = u'd'
  EXCLUSION_KEY_DATA = u's'
  KEY_CHILDREN = u'c'
  KEY_MASKED = u'm'
  tree = None
hash(x)
  data_revision = None
hash(x)
  stock_ua_headers = []
Properties

Inherited from object: __class__

Method Details

__init__(self, json, config)
(Constructor)

 

Load the JSON tree into a dictionary.

Overrides: object.__init__

set_config(self, config)

 

Applies a new configuration object to the tree instance.

Parameters:
  • config - An instance of Config.

property_names(self)

 

Get a list of all possible property names. Note that the client side properties are not included in this list.

Returns:
A list of all possible device property names as PropertyName objects. A PropertyName object holds a property-name and its data-type.

data_version(self)

 

Returns the device data (JSON file) version.

Returns:
The version of the data file.

data_creation_timestamp(self)

 

Returns the device data (JSON file) creation timestamp.

Returns:
The creation date.

put_properties(self, user_agent, stock_user_agents, client_side_properties, properties)

 

Get properties from tree walk, User-Agent and client side and put them in the Tree properties.

Parameters:
  • user_agent - The User-Agent string (from the original User-Agent header) to be used for detecting User-Agent properties.
  • stock_user_agents - The list of candidate User-Agent strings to be used for tree walk.
  • client_side_properties - The optional client side properties.
  • properties

put_tree_walk_properties(self, user_agent, stock_user_agents, properties)

 

Get properties from tree walk and User-Agent and put them in the Tree properties.

if stock_user_agents is not None:

  • iterate over stock_user_agents
    • for each item: tree-walk and stop iteration if result has deviceId
  • use user_agent for detecting the ua-props

if stock_user_agents is None:

  • use user_agent for tree walk
  • use user_agent for detecting the ua-props
Parameters:
  • user_agent - The User-Agent string (from the original User-Agent header).
  • stock_user_agents - The list of candidate User-Agent strings to be used for tree walk.