The above snippet will always delete the last character, so it should at least be:
if name_pattern.endswith(os.sep):
name_pattern = name_pattern.rstrip(os.sep)
But I'm not convinced this is the right approach, one may want to add os.sep for another platform where it isn't (perhaps far fetched). Would it have value to normalize patterns ending on os.sep to end on '/' and check in matching against such a pattern if we are dealing with a directory or not, or would that be too confusing?
The above snippet will always delete the last character, so it should at least be:
if name_pattern. endswith( os.sep) : rstrip( os.sep)
name_pattern = name_pattern.
But I'm not convinced this is the right approach, one may want to add os.sep for another platform where it isn't (perhaps far fetched). Would it have value to normalize patterns ending on os.sep to end on '/' and check in matching against such a pattern if we are dealing with a directory or not, or would that be too confusing?