Package mobi :: Package mtld :: Package da :: Package device :: Module ua_props :: Class UaProps
[frames] | no frames]

Class UaProps

                   object --+    
                            |    
post_walk_rules.PostWalkRules --+
                                |
                               UaProps

This class is used by the main API class and should not be used directly. This class tries to extract properties from the User-Agent string itself. This is a completely separate step to the main JSON tree walk but uses the results of the tree walk to optimise the property extraction.

The property extraction is done in two steps:

   1. Try and identify the type of User-Agent and thus the set of
      property extraction rules to run. This is optimised by the
      properties from the tree walk.

   2. Run the rules found in step 1 to try and extract the properties.

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

Author: Afilias Technologies Limited

Nested Classes

Inherited from post_walk_rules.PostWalkRules: PostWalkRulesException

Instance Methods
 
__init__(self, tree_provider)
x.__init__(...) initializes x; see help(type(x)) for signature
 
put_properties(self, user_agent, props_to_vals, properties)
Merge the tree walk properties with the User-Agent string properties using the User-Agent rules.

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

Class Variables
  API_ID = 5
  KEY_UA_RULES = u'uar'
  KEY_SKIP_IDS = u'sk'
  KEY_DEFAULT_REGEX_SET = u'd'
  KEY_RULE_GROUPS = 'rg'
  KEY_RULE_REGEX_ID = u'r'
  KEY_REGEXES = u'reg'
  KEY_REGEX_MATCH_POS = u'm'
  KEY_REFINE_REGEX_ID = u'f'
  KEY_SEARCH_REGEX_ID = u's'

Inherited from post_walk_rules.PostWalkRules: KEY_MATCHER_PROP_IDS_IN_USE, KEY_OPERATOR, KEY_PROPERTY_MATCHER, KEY_PROPERTY_VALUE, KEY_RULE_ARR, KEY_RULE_PROP_IDS_IN_USE, KEY_RULE_SET, KEY_RULE_SET_COUNT, branch, tree_provider

Properties

Inherited from object: __class__

Method Details

__init__(self, tree_provider)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

put_properties(self, user_agent, props_to_vals, properties)

 

Merge the tree walk properties with the User-Agent string properties using the User-Agent rules.

Parameters:
  • user_agent - The User-Agent to find properties for.
  • props_to_vals - The result of the tree walk, a dictionary of property_id:value_id.
  • properties - The result of the tree walk, a dictionary of properties (Property objects) wrapped in a Properties object.