This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
def metamethod(cls, name): | |
"""Get a method owned by a metaclass | |
The method is retrieved from the instantiating metaclass. | |
Parameters | |
---------- | |
cls: class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import six | |
import inspect | |
class MetaEngine(type): | |
def __init__(cls, name, bases, classdict): | |
cls._cycle = [] | |
rotation = cls.next_rotation(None) | |
while rotation is not None: | |
cls._cycle.append(rotation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from schema import Schema, _priority, DICT, Optional | |
def compose(*schemas, **kwargs): | |
"""Compose two or more schemas into one. | |
See https://github.com/keleshev/schema/pull/169 for details. | |
""" | |
reduce = kwargs.pop("reduce", lambda schemas: schemas[0]) | |
if not callable(reduce): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
from weakref import finalize | |
class Component: | |
def _prepare(self): | |
pass | |
def _require(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2019 by Cisco Systems, Inc. | |
from voluptuous import Schema, All | |
from collections import Mapping | |
from abc import ABCMeta | |
from typing import Dict, Any | |
class MetaModel(ABCMeta): | |
def __init__(self, name, bases, attrs): | |
attr_validators = self._attribute_validators.copy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import idom | |
import enum | |
import time | |
import random | |
import asyncio | |
class WASD(enum.Enum): | |
w = (-1, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import idom | |
import enum | |
import time | |
import random | |
import asyncio | |
class WASD(enum.Enum): | |
w = (-1, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import enum | |
import random | |
import time | |
from dataclasses import dataclass, replace | |
import idom | |
class GameState(enum.Enum): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# activate Python venv in present dir | |
function cd() { | |
if [[ -d ./.venv ]] && [[ $(which python) = $PWD* ]]; then | |
deactivate | |
fi | |
builtin cd $1 | |
if [[ -d ./.venv ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from inspect import signature, Signature, Parameter, BoundArguments, cleandoc | |
from argparse import ArgumentParser, RawTextHelpFormatter | |
from typing import TypeVar, Callable | |
F = TypeVar("F", bound=Callable[..., None]) | |
class Commands: |
OlderNewer