Package mobi :: Package mtld :: Package da :: Package carrier :: Module carrier_data :: Class CarrierData
[hide private]
[frames] | no frames]

Class CarrierData

source code

object --+
         |
        CarrierData

Instance Methods [hide private]
 
load_data_from_file(self, filePath) source code
 
_readHeader(self)
The header of the file contains the following data: 2B DA (US-ASCII) 1B File type ID (1: carrier data, 2:some other data....
source code
 
_checkFileTypeGetHeaderLength(self, startBytes)
Check the first few bytes to make sure we are opening a Carrier Identification file.
source code
 
_readBuckets(self)
Each bucket is comprised of the following.
source code
 
getProperties(self, key)
Selects a value for a given IPV4 address, traversing tree and choosing most specific value available for a given address.
source code
 
getPropertyNames(self)
Return a list of all the property names
source code
 
getPropertyNamesAsStrings(self)
Return a list of all the property names
source code
 
getCopyright(self)
Return the copyright
source code
 
getCreationDate(self)
Return the creation of date
source code
 
getVersion(self)
Return the version
source code

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

Class Variables [hide private]
  _MAGIC_NUMBER = 'DA'
  _FILE_ID = 1
  _START_BYTES_LEN = 5
  _CREATION_DATE_LEN = 24
  _BUCKET_START_BYTES_LEN = 10
  _copyright = ''
  _creationDate = ''
  _version = ''
  _NULL_PTR = -1
  _ROOT_PTR = 0
  _MAX_IPV4_BIT = 2147483648
  _treeLefts = []
  _treeRights = []
  _treeProperties = []
  _PROBLEM_READING_DATA_FILE = 'Problem reading data file.'
  _INVALID_DATA_FILE = 'Invalid data file.'
  _data = None
hash(x)
  _cursor = 0
  _propertyStringNames = None
hash(x)
  _property_names = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_readHeader(self)

source code 

The header of the file contains the following data:
     2B  DA (US-ASCII)
     1B  File type ID (1: carrier data, 2:some other data.... etc)
     2B  Header length - the total size of the header including the preceding bytes
     2B  Length of copyright text
     ?B  Copyright (US-ASCII) "(c) Copyright 2021 - DeviceAtlas Limited"
     24B Creation date (US-ASCII) "2013-08-07T15:36:44+0000"
     1B  Version, major
     1B  Version, minor
     4B  Licence ID
     4B  CRC-32 - all data after first bucket offset

_readBuckets(self)

source code 

Each bucket is comprised of the following. The BucketHandler is
responsible for actually parsing the data in each bucket. This method
keeps reading until either the end of the file or until all necessary
buckets have been read. It will skip buckets with IDs it does not
recognise to hopefully future proof the API against possible additions to
the data file

Bucket structure:

 2B  Bucket ID
 4B  CRC-32 checksum - NOTE: unsigned int!
 4B  Length of the data
 ?B  Data