Class DaApi
object --+
         |
        DaApi
Used to load the recognition tree and perform lookups of all 
  properties, or get individual properties. Typical usage is as 
  follows:
>>> deviceAtlas = DaApi()
>>> path = 'data_file/sample.json'
>>> tree = mobi.mtld.da.getTreeFromFile(path)
>>> properties = mobi.mtld.da.getProperties(tree, "Nokia6680...")
>>> property = mobi.mtld.da.getProperty(tree, "Nokia6680...", "displayWidth")
  Note that you should normally use the user-agent that was received in 
  the device's HTTP request. In a BaseHTTPServer environment, you would do 
  this as follows:
>>> userAgent = self.headers['user-agent']
>>> displayWidth = mobi.mtld.da.getPropertyAsInteger(tree, userAgent,
>>>  "displayWidth")
  Third-party Browsers:
  In some contexts, the user-agent you want to recognise may have been 
  provided in a different header. Opera's mobile browser, for example, 
  makes requests via an HTTP proxy, which rewrites the headers. in that 
  case, the original device's user-agent is in the 
  "X-OperaMini-Phone-UA" header, and the following code could be 
  used:
>>> operaHeader = "X-OperaMini-Phone-UA"
>>> if operaHeader in request.headers:
>>>  userAgent = self.headers[operaHeader]
>>> else:
>>>  userAgent = self.headers['user-agent']
>>> displayWidth = mobi.mtld.da.getPropertyAsInteger(tree, userAgent,
>>>  "displayWidth")
  See here for more information: 
  https://mobi.mtld.da.com/resources/side-loaded-browser-handling
  Client side properties:
  Client side properties can be collected and merged into the results by
  using the DeviceAtlas Javascript detection file. The results from the 
  client side are sent to the server inside a cookie. The contents of this 
  cookie can be passed to the DeviceAtlas getProperty and getProperties 
  methods. The client side properties over-ride any data file properties 
  and also serve as an input into additional logic to determine other 
  properties such as the iPhone models that are otherwise not detectable. 
  The following code shows how this can be done in BaseHTTPServer:
>>> userAgent = self.headers['user-agent']
>>> cookieContents = 
>>> properties = mobi.mtld.da.getPropertiesAsTyped(tree, userAgent,
>>>  cookieContents)
      Deprecated:
        Please use the new interface with DeviceApi instead.
      
 
  
    | 
     Inherited from object:
      __delattr__,
      __format__,
      __getattribute__,
      __hash__,
      __init__,
      __new__,
      __reduce__,
      __reduce_ex__,
      __repr__,
      __setattr__,
      __sizeof__,
      __str__,
      __subclasshook__
       
     | 
  
    | 
       
     | 
      
        
          getTreeFromFile(filename,
        includeChangeableUserAgentProperties=True) 
      Return a tree from a JSON file. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          getTreeFromString(json,
        includeChangeableUserAgentProperties=True) 
      Return a loaded JSON tree from a string of JSON data. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
      
     | 
  
    | 
       
     | 
      
      
     | 
  
    | 
       
     | 
      
      
     | 
  
    | 
       
     | 
      
        
          getApiRevision() 
      Return the revision number of the API. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          listProperties(tree) 
      Return an associative array of all property names available for all 
      user agents in this tree, with their data type names. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          getProperties(tree,
        userAgent,
        cookie=None,
        typedValues=False,
        sought=None,
        uaPropsNeeded=True) 
      Return a associative array of known properties merged with properties
      from the client side JavaScript. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          getPropertiesAsTyped(tree,
        userAgent,
        cookie=None) 
      Return an associative array of known properties merged with 
      properties from the client side JavaScript. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          getProperty(tree,
        userAgent,
        property,
        cookie=None,
        typedValue=False) 
      Return a value for the named property for this user agent. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
      
     | 
  
    | 
       
     | 
      
        
          getPropertyAsDate(tree,
        userAgent,
        property,
        cookie=None) 
      Strongly typed property access. | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
      
     | 
  
    | 
       
     | 
      
      
     | 
  
    | 
       
     | 
      
        
          | __get_props_as_hash(properties) | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          | __get_property_type_as_string(property_type_id) | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          | __get_property_object(tree,
        user_agent,
        property_name,
        client_side_properties) | 
          
            
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          | __get_revision_from_keyword(keyword) | 
          
            
            
           | 
         
       
      
     | 
  
  
    | 
     Inherited from object:
      __class__
       
     | 
  
  
  
  getTreeFromFile(filename,
        includeChangeableUserAgentProperties=True)
     Static Method
  
   |  
     | 
    
  
  Return a tree from a JSON file. The loaded tree is stored in a static 
  cache to avoid multiple reloads if this method is repeatedly called. To 
  reload from the JSON file set "reload" to true. 
  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 
  "includeChangeableUserAgentProperties" to false. 
  
    - Parameters:
 
    
        filename - is the location of the file to read in. Use an absolute path name
          to be sure of success if the current working directory is not 
          clear. 
        includeChangeableUserAgentProperties - is to detect changeable user-agent properties. 
      
   
      Deprecated:
        Please use DeviceApi.load_data_from_file() instead.
       
  | 
 
  
  
  getTreeFromString(json,
        includeChangeableUserAgentProperties=True)
     Static Method
  
   |  
     | 
    
  
  Return a loaded JSON tree from a string of JSON data. 
  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 
  "includeChangeableUserAgentProperties" to false. 
  This method does not use the built in static cache. 
  
    - Parameters:
 
    
        json - is the string of json data. 
        includeChangeableUserAgentProperties - Also detect changeable user-agent properties. 
      
   
      Deprecated:
        Please use DeviceApi.load_data_from_string() instead.
       
  | 
 
  
  
  getTreeGeneration(tree)
     Static Method
  
   |  
     | 
    
  
  Get the generation date for this tree. 
  
    - Parameters:
 
    
        tree - is a dict object with the tree. It returns the date and time the 
          tree was generated. 
      
   
      Deprecated:
        Please use DeviceApi.get_data_creation_timestamp() instead.
       
  | 
 
  
  
  getTreeGenerationAsTimestamp(tree)
     Static Method
  
   |  
     | 
    
  
  Get the generation date for this tree as a UNIX timestamp. 
  
    - Parameters:
 
    
        tree - is a dict object with the tree. It returns a timestamp the tree 
          was generated. 
      
   
      Deprecated:
        Please use DeviceApi.get_data_creation_timestamp() instead.
       
  | 
 
  
  
  getTreeRevision(tree)
     Static Method
  
   |  
     | 
    
  
  Return the revision number of the tree. 
  
   
      Deprecated:
        Please use DeviceApi.get_data_revision() instead.
       
  | 
 
  
  
  listProperties(tree)
     Static Method
  
   |  
     | 
    
  
  Return an associative array of all property names available for all 
  user agents in this tree, with their data type names. 
  
   
      Deprecated:
        Please use DeviceApi.get_property_names() instead.
       
  | 
 
  
  
  getProperties(tree,
        userAgent,
        cookie=None,
        typedValues=False,
        sought=None,
        uaPropsNeeded=True)
     Static Method
  
   |  
     | 
    
  
  Return a associative array of known properties merged with properties 
  from the client side JavaScript. The client side JavaScript sets a cookie
  with collected properties. The contents of this cookie must be passed to 
  this method for it to work. The client properties over-ride any 
  properties discovered from the main JSON data file. 
  
    - Parameters:
 
    
        tree - is the previously generated associative array tree. 
        userAgent - is the device's User-Agent header string. 
        cookie - is the content of the cookie containing the client side 
          properties. 
        typedValues - whether values in the results are typed. 
        sought - is a set of properties to return values for. 
        uaPropsNeeded - whether the extra properties from the UA String are needed. 
      
   
      Deprecated:
        Please use DeviceApi.get_properties() instead.
       
  | 
 
  
  
  getPropertiesAsTyped(tree,
        userAgent,
        cookie=None)
     Static Method
  
   |  
     | 
    
  
  Return an associative array of known properties merged with properties
  from the client side JavaScript. The client side JavaScript sets a cookie
  with collected properties. The contents of this cookie must be passed to 
  this method for it to work. The client properties over-ride any 
  properties discovered from the main JSON data file. 
  
    - Parameters:
 
    
        tree - is the previously generated associative array tree. 
        userAgent - is the device's User-Agent header string. 
        cookie - is the content of the cookie containing the client side 
          properties. 
      
   
      Deprecated:
        Please use DeviceApi.get_properties() instead.
       
  | 
 
  
  
  getProperty(tree,
        userAgent,
        property,
        cookie=None,
        typedValue=False)
     Static Method
  
   |  
     | 
    
  
  Return a value for the named property for this user agent. 
  
    - Parameters:
 
    
        tree - Previously generated associative array tree. 
        userAgent - The device's User-Agent header string. 
        property - The name of the property to return. 
        cookie - The contents of the cookie containing the client side properties. 
        typedValue - Whether value in the associative array are typed. 
      
   
      Deprecated:
        Please use DeviceApi.get_properties instead.
       
  | 
 
  
  
  getPropertyAsBoolean(tree,
        userAgent,
        property,
        cookie=None)
     Static Method
  
   |  
     | 
    
  
  Strongly typed property access. Return a boolean property (or throws 
  an exception if the property is actually of another type). 
  
    - Parameters:
 
    
        tree - Previously generated associative array tree. 
        userAgent - The device's User-Agent header string. 
        property - The name of the property to return. 
      
   
      Deprecated:
        Please use DeviceApi.get_properties() and bool(Property) instead.
       
  | 
 
  
  
  getPropertyAsDate(tree,
        userAgent,
        property,
        cookie=None)
     Static Method
  
   |  
     | 
    
  
  Strongly typed property access. Returns a date property (or throws an 
  exception if the property is actually of another type). 
  
    - Parameters:
 
    
        tree - Previously generated associative array tree. 
        userAgent - The device's User-Agent header string. 
        property - The name of the property to return. 
      
   
      Deprecated:
        Date data type is not supported anymore.
       
  | 
 
  
  
  getPropertyAsInteger(tree,
        userAgent,
        property,
        cookie=None)
     Static Method
  
   |  
     | 
    
  
  Strongly typed property access. Return an integer property (or throws 
  an exception if the property is actually of another type). 
  
    - Parameters:
 
    
        tree - Previously generated associative array tree. 
        userAgent - The device's User-Agent header string. 
        property - The name of the property to return. 
      
   
      Deprecated:
        Please use DeviceApi.get_properties() and int(Property) instead.
       
  | 
 
  
  
  getPropertyAsString(tree,
        userAgent,
        property,
        cookie=None)
     Static Method
  
   |  
     | 
    
  
  Strongly typed property access. Return a string property (or throws an
  exception if the property is actually of another type). 
  
    - Parameters:
 
    
        tree - Previously generated associative array tree. 
        userAgent - The device's User-Agent header string. 
        property - The name of the property to return. 
      
   
      Deprecated:
        Please use DeviceApi.get_properties() and str(Property) instead.
       
  |