Skip to content

Commit

Permalink
deprecation: Remove support for Files
Browse files Browse the repository at this point in the history
File support was complicating design and increased support load. Also it
is not used often. Focus on databases and data warehouses.
  • Loading branch information
vrajat committed Aug 13, 2021
1 parent 325d2d8 commit 7af00cb
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 361 deletions.
2 changes: 1 addition & 1 deletion piicatcher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa
__version__ = "0.13.0"

from piicatcher.api import scan_database, scan_file_object
from piicatcher.api import scan_database
24 changes: 1 addition & 23 deletions piicatcher/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from argparse import Namespace
from typing import Any, Dict, List, TextIO, Tuple
from typing import Any, Dict, Tuple

from piicatcher.explorer.aws import AthenaExplorer
from piicatcher.explorer.databases import (
Expand All @@ -9,29 +9,7 @@
RedshiftExplorer,
)
from piicatcher.explorer.explorer import Explorer
from piicatcher.explorer.files import IO, Tokenizer
from piicatcher.explorer.sqlite import SqliteExplorer
from piicatcher.scanner import NERScanner, RegexScanner


def scan_file_object(fd: TextIO) -> List[Any]:
"""
Args:
fd (file descriptor): A file descriptor open in text mode.
Returns: A list of PIITypes enum of all the PII types found in the file.
"""
scanner = IO("api file object", fd)
context = {
"tokenizer": Tokenizer(),
"regex": RegexScanner(),
"ner": NERScanner(),
}

scanner.scan(context)
return scanner.get_pii_types()


def _scan_db(scanner: Explorer, scan_type: str) -> Dict[Any, Any]:
Expand Down
2 changes: 0 additions & 2 deletions piicatcher/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from piicatcher import __version__
from piicatcher.explorer.aws import cli as aws_cli
from piicatcher.explorer.databases import cli as db_cli
from piicatcher.explorer.files import cli as files_cli
from piicatcher.explorer.metadata import data_logger, scan_logger
from piicatcher.explorer.snowflake import cli as snowflake_cli
from piicatcher.explorer.sqlite import cli as sqlite_cli
Expand Down Expand Up @@ -87,7 +86,6 @@ def cli(


cli.add_command(aws_cli)
cli.add_command(files_cli)
cli.add_command(sqlite_cli)
cli.add_command(db_cli)
cli.add_command(snowflake_cli)
154 changes: 0 additions & 154 deletions piicatcher/explorer/files.py

This file was deleted.

32 changes: 0 additions & 32 deletions tests/test_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,38 +108,6 @@ def test_sqlite(tmp_path, mocker, caplog):
)


def test_files(tmp_path, mocker, caplog):
caplog.set_level(logging.DEBUG)
config_file = tmp_path / "db_host.ini"
config_file.write_text(
"""
[files]
path="file path"
"""
)

logging.info("Config File: %s" % config_file)
explorer = mocker.patch("piicatcher.explorer.files.FileExplorer")
runner = CliRunner()
result = runner.invoke(cli, ["--config", str(config_file), "files"])
assert result.exception is None
assert "" == result.stdout
assert 0 == result.exit_code
explorer.dispatch.assert_called_once_with(
Namespace(
path="file path",
catalog={
"host": None,
"port": None,
"user": None,
"password": None,
"format": "ascii_table",
"file": None,
},
)
)


def test_aws(tmp_path, mocker, caplog):
caplog.set_level(logging.DEBUG)
config_file = tmp_path / "db_host.ini"
Expand Down
141 changes: 0 additions & 141 deletions tests/test_file_explorer.py

This file was deleted.

Loading

0 comments on commit 7af00cb

Please sign in to comment.