# Path: pydal/helpers/regex.py
# REGEX_SEARCH_PATTERN = r"^{[^.]+\.[^.]+(\.(lt|gt|le|ge|eq|ne|contains|startswith|year|month|day|hour|minute|second))?(\.not)?}$"
# 
# REGEX_SQUARE_BRACKETS = r"^.+\[.+\]$"
# 
# Path: pydal/_compat.py
# PY2 = sys.version_info[0] == 2
#     def implements_bool(cls):
#     def implements_iterator(cls):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def to_unicode(obj, charset="utf-8", errors="strict"):
#     class metaclass(meta):


import re
from .regex import REGEX_SEARCH_PATTERN, REGEX_SQUARE_BRACKETS
from .._compat import long
                    REGEX_SQUARE_BRACKETS, tokens[-1]
                ):
                    new_patterns = self.auto_table(
                        tokens[-1][tokens[-1].find("[") + 1 : -1], "/".join(tokens[:-1])
                    )
                    patterns = patterns[:i] + new_patterns + patterns[i + 1 :]
                    i += len(new_patterns)
                else:
                    i += 1
        if "/".join(args) == "patterns":
            return self.db.Row(
                {"status": 200, "pattern": "list", "error": None, "response": patterns}
            )
        for pattern in patterns:
            basequery, exposedfields = None, []
            if isinstance(pattern, tuple):
                if len(pattern) == 2:
                    pattern, basequery = pattern
                elif len(pattern) > 2:
                    pattern, basequery, exposedfields = pattern[0:3]
            otable = table = None
            if not isinstance(queries, dict):
                dbset = self.db(queries)
                if basequery is not None:
                    dbset = dbset(basequery)
            i = 0
            tags = pattern[1:].split("/")
            if len(tags) != len(args):
                continue
            for tag in tags:

# Path: pydal/helpers/regex.py
# REGEX_SEARCH_PATTERN = r"^{[^.]+\.[^.]+(\.(lt|gt|le|ge|eq|ne|contains|startswith|year|month|day|hour|minute|second))?(\.not)?}$"
# 
# REGEX_SQUARE_BRACKETS = r"^.+\[.+\]$"
# 
# Path: pydal/_compat.py
# PY2 = sys.version_info[0] == 2
#     def implements_bool(cls):
#     def implements_iterator(cls):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def to_unicode(obj, charset="utf-8", errors="strict"):
#     class metaclass(meta):


# Path: pydal/helpers/rest.py
import re
from .regex import REGEX_SEARCH_PATTERN, REGEX_SQUARE_BRACKETS
from .._compat import long

                    REGEX_SQUARE_BRACKETS, tokens[-1]
                ):
                    new_patterns = self.auto_table(
                        tokens[-1][tokens[-1].find("[") + 1 : -1], "/".join(tokens[:-1])
                    )
                    patterns = patterns[:i] + new_patterns + patterns[i + 1 :]
                    i += len(new_patterns)
                else:
                    i += 1
        if "/".join(args) == "patterns":
            return self.db.Row(
                {"status": 200, "pattern": "list", "error": None, "response": patterns}
            )
        for pattern in patterns:
            basequery, exposedfields = None, []
            if isinstance(pattern, tuple):
                if len(pattern) == 2:
                    pattern, basequery = pattern
                elif len(pattern) > 2:
                    pattern, basequery, exposedfields = pattern[0:3]
            otable = table = None
            if not isinstance(queries, dict):
                dbset = self.db(queries)
                if basequery is not None:
                    dbset = dbset(basequery)
            i = 0
            tags = pattern[1:].split("/")
            if len(tags) != len(args):
                continue
            for tag in tags:

                if re.match(REGEX_SEARCH_PATTERN, tag):