#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from re import Pattern as REPattern
from re import compile as re_compile
from re import IGNORECASE as RE_IGNORE_CASE

class RE:
    KEY:REPattern = re_compile(r'^[a-z_][a-z0-9_]*$', RE_IGNORE_CASE)
    STRING_VARIABLES:REPattern = re_compile(r'\{([a-z_][a-z0-9_]*)\}', RE_IGNORE_CASE)
    LINE:REPattern = re_compile(r'^([^\r\n]*)')
    SLASHES:REPattern = re_compile(r'[\\/]+')
    EXCEPTION:REPattern = re_compile(r'^\s*File "([^"]+)", line ([0-9]+), in ([^\n]+)(.*|[\r\n]*)*$')
    BREAK_LINES:REPattern = re_compile(r'\r\n|[\r\n]')
    TO_SNAKE:REPattern = re_compile(r'[^a-zA-Z0-9]*([A-Z][A-Z0-9]*)|[^a-z0-9]+')
    FRAGMENT_PATTERN:REPattern = re_compile(r'\${3}([0-9]+)\${3}')
    FRAGMENT_VARIABLES:REPattern = re_compile(r'\{([^\{\}]+)\}')
    FORMAT_SPLIT:REPattern = re_compile(r'^([^,:]+)[,:](.*)$')
    FORMAT_PARTS:REPattern = re_compile(r'\{([^\{\}]+)\}|[^\{]+|\{')
    LIST_ITEM:REPattern = re_compile(r'^list:([a-z0-9_]+)$', RE_IGNORE_CASE)
    CAPITAL_CASE:REPattern = re_compile(r'^(.)')
    BASIC_MODE_SPLIT:REPattern = re_compile(r'^([^,]+),(.*)$')
    IS_SEPARATOR:REPattern = re_compile(r'^[a-z 0-9]+$', RE_IGNORE_CASE)
    ABSOLUTE_INTEGER:REPattern = re_compile(r'^[0-9]+$')
    SELECT_MODE_SPLIT:REPattern = re_compile(r'^([^,]+),([^,]+),(.*)$')
    ROUTE_ITEM:REPattern = re_compile(r'^(?:([^:]+):)([^\s]+)\s+(?:([^\@\s]+)\@([^\s]+)|([^\s]+))(?:\s+([^\s]+))?$')
    ROUTE_RE_FORMAT:REPattern = re_compile(r'(\(\[\^\\\/\]\+\))|([\/])')
    HTTP_BLOCKS:REPattern = re_compile(r'((?:(?!(?:(?:\r\n){2}|\n{2}|\r{2}))(?:.|[\r\n]+))+)(?:(?:\r\n){2}|\n{2}|\r{2}((?:.+|[\r\n]+)*))?')
    NEW_LINE:REPattern = re_compile(r'\r\n|[\n\r]')
    HTTP_REQUEST:REPattern = re_compile(r'^([^\s]+)\s([^\s\?\#]+)(?:\?([^#]+))?(?:\#[^\s]+)?\s([^\/]+)\/([0-9\.]+)$')
    URI_VARIABLES:REPattern = re_compile(r'&?([^=&]+)=([^&]*)')
    HEADER_LINE:REPattern = re_compile(r'^([^\:]+)\:(.+)$')
