Beispiel #1
0
    def pretty(self):
        """Pretty print."""
        dct = self.__dict__.copy()
        for key in dct:
            if key.startswith('_'):
                dct[key[1:]] = dct.pop(key)

        # pop state argument (not necessary to print)
        dct.pop('state')

        pprint(utils.dictionarize(dct))
Beispiel #2
0
    def test_dictionarize(self):
        """Test `utils.dictionarize` function."""
        sample_cve_path = 'data/cve-1.0-sample.json'

        with open(sample_cve_path) as f:
            data = json.loads(f.read())
            doc = Document.from_data(data)

        doc_dict = utils.dictionarize(doc)

        self.assertIsInstance(doc_dict, dict)
        self.assertIsInstance(doc_dict['cve'], dict)
        self.assertIsInstance(doc_dict['impact'], dict)
        self.assertIsInstance(doc_dict['configurations'], dict)
Beispiel #3
0
 def pretty(self):
     pprint(utils.dictionarize(self))
Beispiel #4
0
 def pretty(self):
     """Pretty print."""
     pprint(utils.dictionarize(self))