This file contains hidden or 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 | |
from socket import timeout | |
import aiohttp | |
import json | |
import uuid | |
import click | |
from functools import wraps | |
def coro(f): |
This file contains hidden or 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 collections import UserList | |
class DivList(UserList): | |
def __truediv__(self, num): | |
list_len = len(self.data) | |
start = 0 | |
step, rem = divmod(list_len, num) | |
stop = start + step + bool(rem) | |
outlist = [] |
This file contains hidden or 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 argparse | |
import sys | |
from configparser import ConfigParser | |
from pathlib import Path | |
import yaml | |
def convert_data(data): | |
if isinstance(data, dict): | |
for key, value in data.items(): |
This file contains hidden or 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 collections import UserDict | |
class DictToObj(UserDict): | |
"""Converts dictionaries into dot accessible objects, great with nesting""" | |
def __init__(self, in_dict): | |
"""Initialize the class and all nested dictionaries""" | |
for key, value in in_dict.items(): | |
if isinstance(value, dict): | |
setattr(self, key, DictToObj(value)) |
This file contains hidden or 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 collections import UserDict | |
class Stub(UserDict): | |
def __getattr__(self, name): | |
return self | |
def __getitem__(self, key): | |
item = getattr(self, key, self) | |
try: |
This file contains hidden or 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 | |
class Dummy: | |
def __init__(self, name): | |
self.name = name | |
def print_name(self): | |
print(f"My name is {self.name}") | |
def call_meth(self, meth): |
This file contains hidden or 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 | |
import os | |
import yaml | |
from pathlib import Path | |
CONFIG = None | |
class MiniConf: | |
def __init__(self, **kwargs): |
This file contains hidden or 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 collections import defaultdict | |
from functools import lru_cache | |
CACHE = Cache() | |
class Cache: | |
_free = defaultdict(lambda: defaultdict(list)) | |
_active = defaultdict(lambda: defaultdict(list)) |
This file contains hidden or 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 os | |
import socket | |
from ssh2.session import Session as ssh2_Session | |
from ssh2 import sftp as ssh2_sftp | |
SFTP_MODE = ( | |
ssh2_sftp.LIBSSH2_SFTP_S_IRUSR | |
| ssh2_sftp.LIBSSH2_SFTP_S_IWUSR | |
| ssh2_sftp.LIBSSH2_SFTP_S_IRGRP | |
| ssh2_sftp.LIBSSH2_SFTP_S_IROTH |
This file contains hidden or 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 aiohttp | |
import asyncio | |
import async_timeout | |
import click | |
from logzero import logger | |
from pathlib import path | |
class AsyncRunner: | |
"""A general class to perform async requests and process data""" |