Skip to content

Instantly share code, notes, and snippets.

@bfahr
bfahr / run_exceptions.py
Created November 9, 2022 21:14
Insights core exceptions
from insights import make_fail, rule, run, parser, Parser
from insights.core import dr
from insights.parsers import ParseException, SkipException, SkipComponent
from insights.specs import Specs
@parser(Specs.uname)
class ExcParser(Parser):
def parse_content(self, content):
self.data = content[0]
@bfahr
bfahr / arrow.py
Created May 20, 2019 22:16
Some simplified PyArrow access functions
import logging
import pandas as pd
import pyarrow.parquet as pq
import pyarrow.orc as orc
import pyarrow as pa
def read_parquet(filepath):
logging.debug('Reading parquet file: %s', filepath)
@bfahr
bfahr / stand_alone_missing.py
Created October 15, 2018 14:44
Insights Core sample code showing missing requirements
#!/usr/bin/env python
"""
This is sample code to show how you can run insights-core from a
stand alone Python script. It also demonstrates missing requirements.
Run from the command line::
`$ ./stand_alone_missing.py -m`
"""
from __future__ import print_function
@bfahr
bfahr / test_file_fixture.py
Last active March 28, 2018 15:50
Pytest File Input Fixture
import os
import pytest
import tempfile
# This is the data that will be the file contents
TEST_DATA = """
Some text in the test file
more text in the test file
# Stuff
still more stuff