Skip to content

Commit b96691a

Browse files
author
max demian
committed
override "hidden" exclusion if target is in "include" list
1 parent 91cde1a commit b96691a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

demimove/fileops.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def __init__(self, casemode=0, countpos=0, dirsonly=False, exclude="",
9292
self.bracerx = re.compile("(?<=\{)(.*?)(?=\})")
9393

9494
def match_filter(self, target):
95+
"""Match a file/directory name against a glob/regex pattern."""
9596
if not self.filteredit:
9697
return True
9798
if "/" in self.filteredit:
@@ -112,6 +113,7 @@ def match_filter(self, target):
112113
return False
113114

114115
def match_exclude(self, target):
116+
"""Match a file/directory name against a glob/regex pattern."""
115117
if not self.excludeedit:
116118
return
117119
if "/" in self.excludeedit:
@@ -132,7 +134,7 @@ def match_exclude(self, target):
132134

133135
def match(self, target):
134136
"""Searches target for pattern and returns a bool."""
135-
if not self.hidden and target.startswith("."):
137+
if not self.hidden and target.startswith(".") and target not in self.includes:
136138
return False
137139
if self.matchexcludecheck:
138140
if self.match_exclude(target) is False:
@@ -147,13 +149,13 @@ def match(self, target):
147149
return True
148150

149151
def get_dirs(self, root, dirs):
150-
"""Sort, match and decode a list of dirs."""
152+
"""Match and decode (from utf-8 to unicode) a list of dirs."""
151153
return [(root, d.decode("utf-8"), u"") for d in dirs if self.match(d)]
152154

153155
def get_files(self, root, files):
154-
"""Sort, match and decode a list of files."""
155-
return [(root,) + os.path.splitext(f.decode("utf-8")) for f in
156-
files if self.match(f)]
156+
"""Match and decode (from utf-8 to unicode) a list of files."""
157+
return [(root,) + os.path.splitext(f.decode("utf-8")) for f in files
158+
if self.match(f)]
157159

158160
def get_targets(self, path=None):
159161
"""Return a list of files and/or dirs in path."""
@@ -178,6 +180,8 @@ def get_targets(self, path=None):
178180
target = self.get_dirs(root, dirs) + self.get_files(root, files)
179181

180182
targets.extend(target)
183+
184+
# Exit out of get_targets when "Stop" is pressed in the GUI.
181185
if self.stopupdate:
182186
return targets
183187

@@ -206,7 +210,8 @@ def set_mediaoptions(self):
206210

207211
def commit(self, previews):
208212
# The sorted generator comprehension of (unicode)doom:
209-
# Reverse sort the paths so that the longest paths are changed first.
213+
# Reverse sort the paths so that the longest paths are changed first
214+
# (by counting the amount of slashs in the path).
210215
# This should minimize rename errors for recursive operations, for now.
211216
actions = sorted((("".join(i[0]).encode("utf-8"), i[0][0].encode("utf-8")
212217
+ i[1].encode("utf-8")) for i in previews),

0 commit comments

Comments
 (0)