How to use the piicatcher.catalog.file.FileStore.save_schemas function in piicatcher

To help you get started, we’ve selected a few piicatcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tokern / piicatcher / tests / test_filestore.py View on Github external
def test_file(tmp_path):
    tmp_file = tmp_path / "schema.json"
    tmp_fh = open(tmp_file, "w")
    explorer = MockExplorer(
        Namespace(
            catalog={"file": tmp_fh, "format": "json"},
            include_schema=(),
            exclude_schema=(),
            include_table=(),
            exclude_table=(),
        )
    )
    explorer._load_catalog()
    FileStore.save_schemas(explorer)
    tmp_fh.close()
    obj = None
    with open(tmp_file, "r") as fh:
        obj = json.load(fh)
    assert len(obj) > 0
    assert obj[0]["name"] == "test_store"
    assert len(obj[0]["tables"]) == 3
github tokern / piicatcher / tests / test_filestore.py View on Github external
def test_stdout(capsys):
    explorer = MockExplorer(
        Namespace(
            catalog={"file": None, "format": "json"},
            include_schema=(),
            exclude_schema=(),
            include_table=(),
            exclude_table=(),
        )
    )

    explorer._load_catalog()

    FileStore.save_schemas(explorer)
    out, err = capsys.readouterr()

    obj = json.loads(out)
    assert len(obj) > 0
    assert obj[0]["name"] == "test_store"
    assert len(obj[0]["tables"]) == 3
github tokern / piicatcher / piicatcher / explorer / files.py View on Github external
def dispatch(cls, ns):
        logging.debug("File Dispatch entered")
        explorer = cls(ns)
        explorer.scan()

        if ns.catalog["format"] == "ascii_table":
            headers = ["Path", "Mime/Type", "pii"]
            tableprint.table(explorer.get_tabular(), headers)
        elif ns.catalog["format"] == "json":
            FileStore.save_schemas(explorer)
github tokern / piicatcher / piicatcher / explorer / explorer.py View on Github external
def output(cls, ns, explorer):
        if ns.catalog["format"] == "ascii_table":
            headers = ["schema", "table", "column", "has_pii"]
            tableprint.table(explorer.get_tabular(ns.list_all), headers)
        elif ns.catalog["format"] == "json":
            FileStore.save_schemas(explorer)
        elif ns.catalog["format"] == "db":
            DbStore.save_schemas(explorer)