MCPcopy Create free account
hub / github.com/numpy/numpy / _fix_paths

Function _fix_paths

numpy/distutils/misc_util.py:266–301  ·  view source on GitHub ↗
(paths, local_path, include_non_existing)

Source from the content-addressed store, hash-verified

264 return sorted(glob.glob(fileglob))
265
266def _fix_paths(paths, local_path, include_non_existing):
267 assert is_sequence(paths), repr(type(paths))
268 new_paths = []
269 assert not is_string(paths), repr(paths)
270 for n in paths:
271 if is_string(n):
272 if '*' in n or '?' in n:
273 p = sorted_glob(n)
274 p2 = sorted_glob(njoin(local_path, n))
275 if p2:
276 new_paths.extend(p2)
277 elif p:
278 new_paths.extend(p)
279 else:
280 if include_non_existing:
281 new_paths.append(n)
282 print('could not resolve pattern in %r: %r' %
283 (local_path, n))
284 else:
285 n2 = njoin(local_path, n)
286 if os.path.exists(n2):
287 new_paths.append(n2)
288 else:
289 if os.path.exists(n):
290 new_paths.append(n)
291 elif include_non_existing:
292 new_paths.append(n)
293 if not os.path.exists(n):
294 print('non-existing path in %r: %r' %
295 (local_path, n))
296
297 elif is_sequence(n):
298 new_paths.extend(_fix_paths(n, local_path, include_non_existing))
299 else:
300 new_paths.append(n)
301 return [minrelpath(p) for p in new_paths]
302
303def gpaths(paths, local_path='', include_non_existing=True):
304 """Apply glob to paths and prepend local_path if needed.

Callers 1

gpathsFunction · 0.85

Calls 7

is_sequenceFunction · 0.85
is_stringFunction · 0.85
sorted_globFunction · 0.85
njoinFunction · 0.85
printFunction · 0.85
minrelpathFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected