1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 04:10:41 +00:00

add regex

This commit is contained in:
user
2025-05-19 22:00:43 +02:00
parent cc1ef5c001
commit fc96a94613
3 changed files with 28 additions and 14 deletions

View File

@@ -18,12 +18,11 @@ class FTreeDir:
directory tree for comparison
"""
def __init__(self, path, ignores=None,
debug=False, dir_as_block=False):
def __init__(self, path, ignores=None, debug=False, dir_as_block=None):
self.path = path
self.ignores = ignores
self.debug = debug
self.dir_as_block = dir_as_block
self.dir_as_block = dir_as_block or []
self.entries = []
self.log = Logger(debug=self.debug)
if os.path.exists(path) and os.path.isdir(path):
@@ -35,13 +34,12 @@ class FTreeDir:
ignore empty directory
test for ignore pattern
"""
# if directory should be handled as a block
# just add the directory itself
if self.dir_as_block:
self.log.dbg(
f'handle as block: {self.path}')
self.entries.append(self.path)
return
import fnmatch
for pattern in self.dir_as_block:
if fnmatch.fnmatch(self.path, pattern):
self.log.dbg(f'dir_as_block match: {pattern} for {self.path}')
self.entries.append(self.path)
return
for root, dirs, files in os.walk(self.path, followlinks=True):
for file in files: