Files
edx-platform/openedx/core/lib/rooted_paths.py
Feanil Patel 9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00

22 lines
534 B
Python

"""Provides rooted_glob, for finding relative glob paths in another director."""
import glob2
def rooted_glob(root, glob):
"""
Returns the results of running `glob` rooted in the directory `root`.
All returned paths are relative to `root`.
Uses glob2 globbing
"""
return remove_root(root, sorted(glob2.glob('{root}/{glob}'.format(root=root, glob=glob))))
def remove_root(root, paths):
"""
Returns `paths` made relative to `root`
"""
return [pth.replace(root + '/', '') for pth in paths]