Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def expand_braces(patterns, flags):
"""Expand braces."""
if flags & BRACE:
for p in ([patterns] if isinstance(patterns, (str, bytes)) else patterns):
try:
# Turn off limit as we are handling it ourselves.
yield from bracex.iexpand(p, keep_escapes=True, limit=0)
except Exception: # pragma: no cover
# We will probably never hit this as `bracex`
# doesn't throw any specific exceptions and
# should normally always parse, but just in case.
yield p
else:
for p in ([patterns] if isinstance(patterns, (str, bytes)) else patterns):
yield p