@@ -92,6 +92,7 @@ def __init__(self, casemode=0, countpos=0, dirsonly=False, exclude="",
92
92
self .bracerx = re .compile ("(?<=\{)(.*?)(?=\})" )
93
93
94
94
def match_filter (self , target ):
95
+ """Match a file/directory name against a glob/regex pattern."""
95
96
if not self .filteredit :
96
97
return True
97
98
if "/" in self .filteredit :
@@ -112,6 +113,7 @@ def match_filter(self, target):
112
113
return False
113
114
114
115
def match_exclude (self , target ):
116
+ """Match a file/directory name against a glob/regex pattern."""
115
117
if not self .excludeedit :
116
118
return
117
119
if "/" in self .excludeedit :
@@ -132,7 +134,7 @@ def match_exclude(self, target):
132
134
133
135
def match (self , target ):
134
136
"""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 :
136
138
return False
137
139
if self .matchexcludecheck :
138
140
if self .match_exclude (target ) is False :
@@ -147,13 +149,13 @@ def match(self, target):
147
149
return True
148
150
149
151
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."""
151
153
return [(root , d .decode ("utf-8" ), u"" ) for d in dirs if self .match (d )]
152
154
153
155
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 )]
157
159
158
160
def get_targets (self , path = None ):
159
161
"""Return a list of files and/or dirs in path."""
@@ -178,6 +180,8 @@ def get_targets(self, path=None):
178
180
target = self .get_dirs (root , dirs ) + self .get_files (root , files )
179
181
180
182
targets .extend (target )
183
+
184
+ # Exit out of get_targets when "Stop" is pressed in the GUI.
181
185
if self .stopupdate :
182
186
return targets
183
187
@@ -206,7 +210,8 @@ def set_mediaoptions(self):
206
210
207
211
def commit (self , previews ):
208
212
# 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).
210
215
# This should minimize rename errors for recursive operations, for now.
211
216
actions = sorted ((("" .join (i [0 ]).encode ("utf-8" ), i [0 ][0 ].encode ("utf-8" )
212
217
+ i [1 ].encode ("utf-8" )) for i in previews ),
0 commit comments