Feature keep file 1135 (#1139)

* Added gitignorefile

* Fixed gitignorefile for os.PathLike paths

* --keep now follows .gitignore rules

* Fixed ruff QA error

* Added support for .osxphotos_keep file

* Added reference to .osxphotos_keep

* Added tests for .osxphotos_keep

* Updated help text for --cleanup, --keep
This commit is contained in:
Rhet Turnbull
2023-08-02 06:37:29 -07:00
committed by GitHub
parent 284c272183
commit e937285a72
9 changed files with 2442 additions and 34 deletions

View File

@@ -0,0 +1,38 @@
import os
import unittest
import osxphotos.gitignorefile
class TestIgnored(unittest.TestCase):
def test_simple(self):
for is_dir in (None, False, True):
with self.subTest(i=is_dir):
self.assertFalse(
osxphotos.gitignorefile.ignored(__file__, is_dir=is_dir)
)
if is_dir is not True:
self.assertTrue(
osxphotos.gitignorefile.ignored(
f"{os.path.dirname(__file__)}/__pycache__/some.pyc",
is_dir=is_dir,
)
)
self.assertFalse(
osxphotos.gitignorefile.ignored(
os.path.dirname(__file__), is_dir=is_dir
)
)
if is_dir is not False:
self.assertTrue(
osxphotos.gitignorefile.ignored(
f"{os.path.dirname(__file__)}/__pycache__", is_dir=is_dir
)
)
else:
# Note: this test will fail if your .gitignore file does not contain __pycache__/
self.assertFalse(
osxphotos.gitignorefile.ignored(
f"{os.path.dirname(__file__)}/__pycache__", is_dir=is_dir
)
)