Source code for pytw.product

import json
import copy

from . import constants as Constants

[docs]class Product(object): """ Product object Consists of {name, version, vendor} fields """ def __init__(self, product_json): self.__product_json = product_json self.__name = self.__product_json[Constants.VULN_PRODUCT_NAME] self.__vendor = self.__product_json[Constants.VULN_PRODUCT_VENDOR] self.__version = self.__product_json[Constants.VULN_PRODUCT_VERSION]
[docs] def get_name(self): """ :Returns the name of the product """ return self.__name
[docs] def get_vendor(self): """ :Returns the name of the vendor for the product """ return self.__vendor
[docs] def get_version(self): """ :Returns the version of the product """ return self.__version
[docs] def to_json(self): """ :Returns JSON representation of the object """ return copy.deepcopy(self.__product_json)
def __str__(self): return json.dumps(self.__product_json) def __repr__(self): return json.dumps(self.__product_json)
def json2products(products_json): products = [] for p in products_json: products.append(Product(p)) return products