~gpanders/pushbroom

f2517bb802b23b457dbf21cfc51e14231f845964 — Greg Anders 1 year, 8 months ago fef57b6 v0.3.2
Version 0.3.2

More bug fixes regarding incompatibility of Python 3.5 system calls with
pathlib
M CHANGELOG.md => CHANGELOG.md +7 -1
@@ 6,6 6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.2] - 2020-01-27
### Changes
- More bug fixes regarding incompatibility of Python 3.5 system calls with
  pathlib

## [0.3.1] - 2020-01-27
### Changes
- Use `Path.open()` instead of `open(Path)`, as the latter does not work in


@@ 64,7 69,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.1.0] - 2019-06-18
- Initial Python release

[Unreleased]: https://github.com/gpanders/pushbroom/compare/v0.3.1...HEAD
[Unreleased]: https://github.com/gpanders/pushbroom/compare/v0.3.2...HEAD
[0.3.2]: https://github.com/gpanders/pushbroom/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/gpanders/pushbroom/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/gpanders/pushbroom/compare/v0.2.1...v0.3.0
[0.2.1]: https://github.com/gpanders/pushbroom/compare/v0.2.0...v0.2.1

M pyproject.toml => pyproject.toml +1 -1
@@ 1,6 1,6 @@
[tool.poetry]
name = "pushbroom"
version = "0.3.1"
version = "0.3.2"
description = "Clean up your filesystem"
authors = ["Greg Anders <greg@gpanders.com>"]
license = "MIT"

M src/pushbroom/__init__.py => src/pushbroom/__init__.py +1 -1
@@ 1,3 1,3 @@
__version__ = "v0.3.1"
__version__ = "v0.3.2"

from .sweep import sweep

M src/pushbroom/console.py => src/pushbroom/console.py +1 -1
@@ 72,7 72,7 @@ def setup_logging(args: argparse.Namespace) -> None:
            .joinpath("pushbroom.log")
        )
        log_file.parent.mkdir(parents=True, exist_ok=True)
        file_handler = logging.FileHandler(log_file)
        file_handler = logging.FileHandler(str(log_file))
        fmt = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
        file_handler.setFormatter(fmt)
        file_handler.setLevel(logging.INFO)

M src/pushbroom/sweep.py => src/pushbroom/sweep.py +2 -2
@@ 14,7 14,7 @@ def delete(path: Path, shred: bool) -> None:
    If ``shred`` is True, first write over the file with random data before deleting.
    """
    if shred:
        with open(path, "ba+") as fil:
        with path.open("ba+") as fil:
            length = fil.tell()
            fil.seek(0)
            fil.write(os.urandom(length))


@@ 45,7 45,7 @@ def sweep(name: str, path: Path, opts: Dict, dry_run: bool) -> None:
    num_seconds = opts["num_days"] * SECONDS_PER_DAY
    thresh = time.time() - num_seconds
    match, ignore = opts["match"], opts["ignore"]
    for root, dirs, files in os.walk(path):
    for root, dirs, files in os.walk(str(path)):
        if opts["remove_empty"] and not dirs and not files:
            Path(root).rmdir()
            continue

M test/test_pushbroom.py => test/test_pushbroom.py +9 -9
@@ 15,7 15,7 @@ from pushbroom import console
TRASH_DIR = Path("~/.cache/pushbroom/trash").expanduser()


def get_config(name):
def get_config(name: str):
    """
    Read the given configuration file and return the configuration object
    """


@@ 31,7 31,7 @@ def get_config_path(config):
    return Path(config.get(section, "path")).expanduser().absolute()


def make_test_file(path, name=None):
def make_test_file(path: Path, name: str = None):
    """
    Create a file with the given ``name`` under the given ``path``. Set the file's
    mtime to two days ago.


@@ 43,7 43,7 @@ def make_test_file(path, name=None):
    test_file = path.joinpath(name)
    test_file.touch()
    mtime = (datetime.today() - timedelta(2)).timestamp()
    os.utime(test_file, (mtime, mtime))
    os.utime(str(test_file), (mtime, mtime))
    return test_file




@@ 55,7 55,7 @@ def trash_dir():
    """
    TRASH_DIR.mkdir(parents=True, exist_ok=True)
    yield TRASH_DIR
    shutil.rmtree(TRASH_DIR)
    shutil.rmtree(str(TRASH_DIR))


def test_tilde_home(monkeypatch):


@@ 158,7 158,7 @@ def test_match_with_ignore():
    path.rmdir()


def test_trash(trash_dir):
def test_trash(trash_dir: Path):
    """
    File should be moved to the Trash dir and not deleted
    """


@@ 173,7 173,7 @@ def test_trash(trash_dir):
    path.rmdir()


def test_shred_with_trash(trash_dir):
def test_shred_with_trash(trash_dir: Path):
    """
    When both Shred and Trash are specified, Shred should be ignored
    """


@@ 182,17 182,17 @@ def test_shred_with_trash(trash_dir):
    test_file = make_test_file(path, "shred_and_trash.txt")

    mtime = test_file.stat().st_mtime
    with open(test_file, "w", encoding="utf8") as fil:
    with test_file.open("w", encoding="utf8") as fil:
        fil.write("Hello, world!")

    # Force mtime back to what it was
    os.utime(test_file, (mtime, mtime))
    os.utime(str(test_file), (mtime, mtime))

    console.pushbroom(config)
    assert not test_file.exists()
    assert trash_dir.joinpath(test_file.name).exists()

    with open(trash_dir.joinpath(test_file.name), "r", encoding="utf8") as fil:
    with trash_dir.joinpath(test_file.name).open(encoding="utf8") as fil:
        assert "Hello, world!" in fil.readlines()

    path.rmdir()