# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/04_strs.ipynb.

# %% auto 0
__all__ = ['isallstr', 'isprivate', 'ismangled', 'issunder', 'isdunder', 'isnilstr', 'isstar', 'iselps', 'ispunc', 'isupper',
           'islower', 'isquote']

# %% ../nbs/04_strs.ipynb 4
import string
from typing import Union, Literal, TypeGuard, Iterable

# %% ../nbs/04_strs.ipynb 5
from .core import isiter, isstr

# %% ../nbs/04_strs.ipynb 7
def isallstr(x) -> TypeGuard[Iterable[str]]:
    '''Check if `x` is an `Iterable[str]`.'''
    return isiter(x) and all(isstr(e) for e in x)

# %% ../nbs/04_strs.ipynb 9
def isprivate(s: str) -> TypeGuard[str]:
    '''Check if `s` is a private variable name e.g. `'_{anything}'`.'''
    return isstr(s) and s.startswith('_') and len(s) > 1

def ismangled(s: str) -> TypeGuard[str]:
    '''Check if `s` is an mangled variable name e.g. `'__{anything}'`.'''
    return isstr(s) and s.startswith('__') and len(s) > 2

def issunder(s: str) -> TypeGuard[str]:
    '''Check if `s` is a sunder e.g. `'_{anything}_'`.'''
    return isstr(s) and s.startswith('_') and s.endswith('_') and len(s) > 2

def isdunder(s: str) -> TypeGuard[str]:
    '''Check if `s` is an dunder e.g. `'__{anything}__'`.'''
    return isstr(s) and s.startswith('__') and s.endswith('__') and len(s) > 4

def isnilstr(s: str) -> TypeGuard[Literal['']]:
    '''Check if `s` is the nil string `''`.'''
    return isstr(s) and len(s) == 0

# %% ../nbs/04_strs.ipynb 10
def isstar(s: str) -> TypeGuard[Literal['*']]:
    '''Check if `s` is an asterick string `''`.'''
    return isstr(s) and s == '*'

def iselps(s: str) -> TypeGuard[Literal['...']]:
    '''Check if `s` is an ellipse string `''`.'''
    return isstr(s) and s == '...'

# %% ../nbs/04_strs.ipynb 11
def ispunc(s: str) -> TypeGuard[str]:
    return isstr(s) and s in string.punctuation

def isupper(s: str) -> TypeGuard[str]:
    return isstr(s) and s in string.ascii_uppercase

def islower(s: str) -> TypeGuard[str]:
    return isstr(s) and s in string.ascii_lowercase

# %% ../nbs/04_strs.ipynb 12
def isquote(s:str) -> TypeGuard[Literal['"', "'"]]:
    '''Check if `s` is a single or double quote string `'` or `"`.'''
    return isstr(s) and ispunc(s) and s in {'"', "'"}
