@@ -137,8 +137,8 @@ def __init__(self, notify, collect_ignores=False):
137
137
self ._label_paths = []
138
138
self ._labels = {"TARGET" : [], "TOOLCHAIN" : [], "FEATURE" : []}
139
139
140
- # Should we convert all paths to unix-style?
141
- self ._win_to_unix = False
140
+ # Path seperator style (defaults to OS-specific seperator)
141
+ self ._sep = sep
142
142
143
143
# Ignore patterns from .mbedignore files and add_ignore_patters
144
144
self ._ignore_patterns = []
@@ -181,11 +181,12 @@ def detect_duplicates(self):
181
181
return count
182
182
183
183
def win_to_unix (self ):
184
- self ._win_to_unix = True
185
- for file_type in self .ALL_FILE_TYPES :
186
- v = [f ._replace (name = f .name .replace ('\\ ' , '/' )) for
187
- f in self .get_file_refs (file_type )]
188
- self ._file_refs [file_type ] = v
184
+ self ._sep = "/"
185
+ if self ._sep != sep :
186
+ for file_type in self .ALL_FILE_TYPES :
187
+ v = [f ._replace (name = f .name .replace (sep , self ._sep )) for
188
+ f in self .get_file_refs (file_type )]
189
+ self ._file_refs [file_type ] = v
189
190
190
191
def __str__ (self ):
191
192
s = []
@@ -262,8 +263,8 @@ def _not_current_label(self, dirname, label_type):
262
263
dirname [len (label_type ) + 1 :] not in self ._labels [label_type ])
263
264
264
265
def add_file_ref (self , file_type , file_name , file_path ):
265
- if self ._win_to_unix :
266
- ref = FileRef (file_name .replace (" \\ " , "/" ), file_path )
266
+ if sep != self ._sep :
267
+ ref = FileRef (file_name .replace (sep , self . _sep ), file_path )
267
268
else :
268
269
ref = FileRef (file_name , file_path )
269
270
self ._file_refs [file_type ].add (ref )
@@ -272,12 +273,11 @@ def get_file_refs(self, file_type):
272
273
"""Return a list of FileRef for every file of the given type"""
273
274
return list (self ._file_refs [file_type ])
274
275
275
- @staticmethod
276
- def _all_parents (files ):
276
+ def _all_parents (self , files ):
277
277
for name in files :
278
- components = name .split (sep )
278
+ components = name .split (self . _sep )
279
279
for n in range (1 , len (components )):
280
- parent = join (* components [:n ])
280
+ parent = self . _sep . join (components [:n ])
281
281
yield parent
282
282
283
283
def _get_from_refs (self , file_type , key ):
0 commit comments