def test_add_data_source(): fs = FileSystemSource(_STIX_DATA_PATH) add_data_source(fs) resp = tools() assert len(resp) == 3 resp_ids = [tool.id for tool in resp] assert constants.TOOL_ID in resp_ids assert 'tool--03342581-f790-4f03-ba41-e82e67392e23' in resp_ids assert 'tool--242f3da3-4425-4d11-8f5c-b842886da966' in resp_ids
def test_add_data_source(): fs_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "stix2_data") fs = FileSystemSource(fs_path) add_data_source(fs) resp = tools() assert len(resp) == 3 resp_ids = [tool.id for tool in resp] assert TOOL_ID in resp_ids assert 'tool--03342581-f790-4f03-ba41-e82e67392e23' in resp_ids assert 'tool--242f3da3-4425-4d11-8f5c-b842886da966' in resp_ids
print('ValueError parsing: ', twozero) print(e) print('\n') except Exception as e: print('Some other exception parsing:', o) print(e, '\n') if __name__ == '__main__': from stix2 import FileSystemSink store_path = pathlib.Path('/Users/priezm/repos/GTO/stix_worknench/') path = pathlib.Path('/Users/priezm/repos/GTO/working_stix_corpora') if not store_path.exists(): store_path.mkdir(parents=True) fs = workbench.FileSystemSource(str(store_path)) workbench.add_data_source(fs) sink = FileSystemSink('/Users/priezm/repos/GTO/stix_worknench/', allow_custom=True) if path.is_dir(): for p in tqdm(list(path.glob('**/*.json')), 'Files'): with open(p, 'r') as f: print( '\n\n***********************************************************' ) print('adding file: {}'.format(p)) try: irl = json.load(f) print('our irl: ', irl) print('our objects: ', irl['objects']) for o in tqdm(irl['objects'], 'Objects'):