repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
prashg008/chatify
apps/chat/urls.py
<filename>apps/chat/urls.py<gh_stars>1-10 from rest_framework.routers import SimpleRouter from .views import RoomsViewSet, MessageViewSet chat_router = SimpleRouter() chat_router.register(r'rooms', RoomsViewSet) chat_router.register(r'message', MessageViewSet)
prashg008/chatify
apps/accounts/views.py
<reponame>prashg008/chatify from django.contrib.auth import get_user_model from rest_framework import status from rest_framework.permissions import IsAuthenticated, AllowAny from rest_framework.decorators import action from rest_framework.mixins import RetrieveModelMixin, CreateModelMixin from rest_framework.response i...
prashg008/chatify
apps/chat/views.py
from rest_framework import status from rest_framework.decorators import action from rest_framework.mixins import CreateModelMixin, ListModelMixin, RetrieveModelMixin, UpdateModelMixin from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.viewsets import ...
prashg008/chatify
apps/chat/serializers.py
<reponame>prashg008/chatify from django.contrib.auth import get_user_model from rest_framework import serializers from .models import Rooms, Messages User = get_user_model() class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['id', 'username', 'picture'] class ...
prashg008/chatify
apps/accounts/models.py
from django.db import models from django.contrib.auth.models import AbstractUser # Create your models here. class User(AbstractUser): picture = models.ImageField(upload_to="profile_pics/", null=True, blank=True) status = models.CharField(max_length=280, blank=True, null=True)
prashg008/chatify
apps/accounts/urls.py
<reponame>prashg008/chatify from rest_framework.routers import SimpleRouter from .views import UserViewSet user_router = SimpleRouter() user_router.register(r'users', UserViewSet)
prashg008/chatify
apps/chat/models.py
<gh_stars>1-10 from django.db import models from django.contrib.auth import get_user_model # Create your models here. User = get_user_model() class Rooms(models.Model): name = models.CharField(max_length=20, unique=True) members = models.ManyToManyField(User) created_at = models.DateTimeField(auto_now_a...
open-metadata/PyHive
pyhive/tests/test_trino.py
<gh_stars>0 """Trino integration tests. These rely on having a Trino+Hadoop cluster set up. They also require a tables created by make_test_tables.sh. """ from __future__ import absolute_import from __future__ import unicode_literals from pyhive import trino from pyhive.tests.dbapi_test_case import with_cursor, with...
dannluciano/django-mini-system-monitor
mini_system_monitor/migrations/0004_auto_20210716_2353.py
# Generated by Django 3.1.5 on 2021-07-16 23:53 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('mini_system_monitor', '0003_settings'), ] operations = [ migrations.AlterModelOptions( name='overview', options={'verbose_na...
dannluciano/django-mini-system-monitor
mini_system_monitor/models.py
from django.db import models class Settings(models.Model): class Meta: verbose_name = "Setting" verbose_name_plural = "Settings" class Env(models.Model): class Meta: verbose_name = "Env" verbose_name_plural = "Envs" class Overview(models.Model): class Meta: verb...
dannluciano/django-mini-system-monitor
mini_system_monitor/__init__.py
default_app_config = 'mini_system_monitor.apps.MiniSystemMonitorConfig'
dannluciano/django-mini-system-monitor
runserver.py
#!/usr/bin/env python # runserver.py from django.core.management import call_command from boot_django import boot_django boot_django() call_command("runserver",)
dannluciano/django-mini-system-monitor
mini_system_monitor/admin.py
<reponame>dannluciano/django-mini-system-monitor import os import psutil import datetime import platform from django.contrib import admin from django.shortcuts import render from django.http import JsonResponse from django.urls import path from django.conf import settings from django.template.defaultfilters import fil...
dannluciano/django-mini-system-monitor
mini_system_monitor/apps.py
from django.apps import AppConfig class MiniSystemMonitorConfig(AppConfig): name = 'mini_system_monitor' verbose_name = 'System Monitor' default_auto_field = 'django.db.models.AutoField'
dannluciano/django-mini-system-monitor
migrate.py
#!/usr/bin/env python # migrate.py from django.core.management import call_command from boot_django import boot_django boot_django() call_command("migrate", "mini_system_monitor")
TailorDev/crick
api/scripts/watson_push.py
<filename>api/scripts/watson_push.py<gh_stars>100-1000 #!/usr/bin/env python """ Watson push: A watson-free implementation of Watson's push command used to load your frames to a crick api server instance. """ import argparse import http.client import json import logging import os import uuid from os.path import expan...
ggandhi27/Emotions-Recognition-using-IOT-and-Machine-Learning
Python Scripts/filehandling.py
import os def fileExists(filepath): exists = os.path.isfile(filepath) return exists def createCsv(filepath): if fileExists(filepath) == False: f = open(filepath,"w") f.close()
ggandhi27/Emotions-Recognition-using-IOT-and-Machine-Learning
Python Scripts/knn.py
import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.neighbors import KNeighborsClassifier classifier=None def generateClassifier() : global classifier url = "/tmp/mood.csv" # Assign colum names to the ...
ggandhi27/Emotions-Recognition-using-IOT-and-Machine-Learning
Python Scripts/read_serial.py
<gh_stars>1-10 import serial import server import thread import filehandling import knn filePath = "/tmp/mood.csv"; filehandling.createCsv(filePath) thread.start_new_thread(server.server_program,()) serial_port = '/dev/ttyACM0'; baud_rate = 9600; #In arduino, Serial.begin(baud_rate) ser = serial.Serial(serial_port, ...
ggandhi27/Emotions-Recognition-using-IOT-and-Machine-Learning
Python Scripts/server.py
import thread import socket import random MOOD = "Happy" RESULT = "Happy" flag = "" def receive_program(conn,address) : global MOOD while True: data = conn.recv(1024).decode() if not data: # if data is not received break break data = data[2:] data = dat...
ggandhi27/Emotions-Recognition-using-IOT-and-Machine-Learning
venv/lib/python2.7/site-packages/wc/socket/__init__.py
"""Fake socket""" import sys def write(msg): sys.stdout.write("wc-socket:\n----------\n>>> %s\n\n" % msg)
Afroefras/shoppers_churn
scripts/shoppers/models.py
<filename>scripts/shoppers/models.py # Clase madre from .base import BaseClass # Control de datos from typing import Dict from IPython.display import display # Ingeniería de variables from numpy import nan from datetime import datetime, date from pandas import read_csv, to_datetime class ShoppersChurn(BaseClass): ...
Afroefras/shoppers_churn
scripts/shoppers/base.py
# Control de datos from typing import Dict from pathlib import Path from IPython.display import display # Ingeniería de variables from re import sub, UNICODE from unicodedata import normalize from difflib import get_close_matches from numpy import nan, array, asarray, unique from pandas import DataFrame, qcut # Model...
lizberg-slalom/AIforEarth-API-Development
Examples/cntk-python-sample/my_api/runserver.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. from flask import Flask from flask_restful import Resource, Api import os print("Creating Application") app = Flask(__name__) api = Api(app) blob_mapped_dir = "/mnt/input" class ReadBlob(Resource): def read_blob_file(sel...
pytaunay/physics-of-cathodes
article/plots/pressure_ratio_plhc_example.py
# MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pu...
pytaunay/physics-of-cathodes
article/plots/lem_Te_salhi_example.py
<reponame>pytaunay/physics-of-cathodes<filename>article/plots/lem_Te_salhi_example.py<gh_stars>0 # MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Softwa...
pytaunay/physics-of-cathodes
article/plots/pressure_plhc_example.py
<reponame>pytaunay/physics-of-cathodes # MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the r...
pytaunay/physics-of-cathodes
article/plots/pressure_ratio_salhi-ar_example.py
<gh_stars>0 # MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modif...
pytaunay/physics-of-cathodes
article/salhi_ar.py
# MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pu...
pytaunay/physics-of-cathodes
article/plots/pressure_nstar_example.py
<reponame>pytaunay/physics-of-cathodes<gh_stars>0 # MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limit...
pytaunay/physics-of-cathodes
article/plots/twall_salhi_example.py
<reponame>pytaunay/physics-of-cathodes<filename>article/plots/twall_salhi_example.py # MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without r...
pytaunay/physics-of-cathodes
article/plots/pressure_ratio_friedly_example.py
# MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pu...
pytaunay/physics-of-cathodes
article/plots/twall_nstar_example.py
# MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pu...
pytaunay/physics-of-cathodes
article/plots/lem_Te_correlation_jpl_example.py
# MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pu...
pytaunay/physics-of-cathodes
article/plots/lem_Te_jpl_example.py
# MIT License # # Copyright (c) 2021 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pu...
sjuvonen/tessa
setup.py
import os from setuptools import setup def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( name="tessa", version="1.0.0", author="<NAME>", author_email="<EMAIL>", description="Simple btrfs snapshot utility with support for send/receive.", license="B...
sjuvonen/tessa
run.py
#!/usr/bin/python3 import argparse from tessa import core, main, remote class Command: def run(self): pass class ProfileWizardCommand(Command): def __init__(self): self.cmdparser = argparse.ArgumentParser(description="Setup a new profile") self.cmdparser.add_argument("--name", meta...
sjuvonen/tessa
tessa/core.py
<gh_stars>0 from configparser import ConfigParser from datetime import datetime from subprocess import run import os PROFILES_DIR = "/etc/tessa/profiles" class Profile: def __init__(self, name, directory, destination=None): # Human-readable name of this profile. self.name = name # Btrfs ...
sjuvonen/tessa
tessa/main.py
from os import listdir, path from .core import create_snapshot, read_snapshot_meta, PROFILES_DIR from .remote import send_snapshot def read_profile(name): from .core import read_profile_meta return read_profile_meta(path.join(PROFILES_DIR, name)) def _write_profile(profile): from .core import write_prof...
sjuvonen/tessa
tessa/__init__.py
<gh_stars>0 from .core import init_profile, read_profile_meta, read_snapshot_meta from .main import create_snapshot from .remote import send_snapshot_local, send_snapshot_ssh
sjuvonen/tessa
tessa/remote.py
<reponame>sjuvonen/tessa<filename>tessa/remote.py import subprocess def send_snapshot(snapshot, remote_profile, parent=None): methods = { remote_profile.TYPE_LOCAL: send_snapshot_local, remote_profile.TYPE_SSH: send_snapshot_ssh } func = methods[remote_profile.type] func(snapshot, rem...
Honot0/TelegramBotWithDBAndSubscription
Code/parsers.py
<gh_stars>0 '''' пост про регулярки https://habr.com/ru/post/349860/ тестер регулярок https://regex101.com/r/aGn8QC/2 документация бс https://www.crummy.com/software/BeautifulSoup/bs4/doc/ ''' import urllib.request import re def get_html(url): if bool(re.search('[а-яА-Я]', url)): respo...
Honot0/TelegramBotWithDBAndSubscription
Code/db.py
<filename>Code/db.py import sqlite3 import random import time def waitUsersGet(): con = sqlite3.connect('teleBot.db') myCursor = con.cursor() users = [] for each in myCursor.execute(f"SELECT * FROM KeyWaitUsers"): # print(each[0]) # print(each) users.append(each) ...
Honot0/TelegramBotWithDBAndSubscription
Code/mainer.py
def runnn(): import time import re bot = telebot.TeleBot(constants.token) listOfSubs = functions.getUsers() listOfDeadSubs = functions.getDeadUsers() KeyWaitUsers1= functions.waitUsersGet() KeyWaitUsers =[] waitForPost = functions.waitForPostRead() replyToSubers = functions....
Honot0/TelegramBotWithDBAndSubscription
Code/timer.py
<filename>Code/timer.py import time import ast import os def updator(lisst): file = open("raspisanie_otpravok.txt", "w") file.write(str(lisst)) file.close() # процесс с ботом телеги. тут осуществляется проверка на наличие ошибки соединения, так как она ловится только тут. в main она за ошибку...
Honot0/TelegramBotWithDBAndSubscription
Code/tryer.py
import sqlite3 import random import time # # def unsubscribeONE(id): # con = sqlite3.connect('teleBot.db') # myCursor = con.cursor() # # myCursor.execute(f"DELETE FROM subscribers WHERE id ='{id}' ") # # myCursor.execute(f"DELETE * FROM subscribers WHERE id ='{id}' ") # # myCursor.execute...
Honot0/TelegramBotWithDBAndSubscription
constants.py
# #отладка # token = "" # owner = '32' #рабочи token = owner =
Honot0/TelegramBotWithDBAndSubscription
Code/kernell.py
import asyncio import re import time import telebot import time import ast import os import constants # import functions import telebot import constants import time from multiprocessing import Process import subprocess import os import asyncio if __name__ =='__main__': prev_time = 21 ...
tippesi/Image-Manager
src/main.py
import tkinter as tk import tkinter.ttk as ttk import re import tkinter.filedialog import tkinter.simpledialog import os import shutil import random import math import PIL.Image as PILImage import PIL.ImageTk as PILImageTk from PIL.ExifTags import TAGS class Image(): def __init__(self, filename): image = P...
rmcavalcante/mit_ai_labs_6034
lab0/algebra_test.py
# # Debugging code: # import algebra import tools tools.cls() expr = algebra.Sum([1, algebra.Sum([2, 3])]) simplified = expr.simplify() assert (list(simplified) == [1,2,3]), "Sum([1, Sum([2, 3])]) :: Unexpected simplified result." expr2 = algebra.Product([algebra.Product(['a', 'b']),'c']) simplified = expr2.simplify()...
rmcavalcante/mit_ai_labs_6034
lab0/wu.py
<reponame>rmcavalcante/mit_ai_labs_6034 # -*- coding: utf-8 -*- __author__ = "<NAME>, Roberto" __copyright__ = "Copyright 2020, <NAME>" __credits__ = ["<NAME>", "<NAME>", "<NAME>"] __license__ = "MIT" __version__ = "1.0.0" __maintainer__ = "Roberto" __email__ = "" __status__ = "Production" from collections import I...
rmcavalcante/mit_ai_labs_6034
lab1/backchain.py
from production import AND, OR, NOT, PASS, FAIL, IF, THEN, \ match, populate, simplify, variables from zookeeper import ZOOKEEPER_RULES # This function, which you need to write, takes in a hypothesis # that can be determined using a set of rules, and outputs a goal # tree of which statements it would need to test...
rmcavalcante/mit_ai_labs_6034
lab0/tools.py
import os def cls(): #print "\n" * 100 os.system('clear')
slow-query/detawane
detawane/chat/handler/base_handler.py
class BaseHandler: def __init__(self, video): self.video = video
slow-query/detawane
detawane/chat/filter/base_filter.py
class BaseFilter: def __init__(self, video): self.video = video def __call__(self, messages): return [message for message in messages if self._is_selected(message)] def _is_selected(self, message): pass
slow-query/detawane
detawane/chat/__init__.py
<gh_stars>0 from .filter.channel_owner_filter import ChannelOwnerFilter from .filter.post_per_hour_filter import PostPerHourFilter from .handler.stdout_handler import StdoutHandler from .handler.twitter_handler import TwitterHandler from .processor import Processor def build_processor(video, adapter): processor =...
slow-query/detawane
tool/upcoming_videos/main.py
#!/usr/bin/env python # NOTE: Youtube Data API v3の1日のリクエスト上限値が小さいため100件程度で上限に達する。 import argparse import json import upcoming_video parser = argparse.ArgumentParser() parser.add_argument("file_path", type=str, help="channel list file") args = parser.parse_args() fp = open(args.file_path, "r") channels = json.load(f...
slow-query/detawane
detawane/__main__.py
from .chat import build_processor from .chat.sentry_processor import SentryProcessor from .cli.config import Config from .cli.runner import Runner config = Config() processors = [SentryProcessor()] for video in config.videos: processors.append(build_processor(video, config.adapter)) runner = Runner() runner.run(...
slow-query/detawane
test/cli/test_config.py
<gh_stars>0 from unittest import TestCase from unittest.mock import mock_open, patch from detawane.channel import Channel from detawane.chat.adapter.pychat import Pychat from detawane.chat.adapter.youtube_api import YoutubeAPI from detawane.cli.config import Config from detawane.video import Video class ConfigTestCa...
slow-query/detawane
test/cli/test_runner.py
<gh_stars>0 from threading import Timer from unittest import TestCase from unittest.mock import Mock from detawane.cli.runner import Runner class RunnnerTestCase(TestCase): def setUp(self): self.runner = Runner() self.runner.MAX_PROCESSING_TIME = 0 def stop_running(self): self.runner...
slow-query/detawane
detawane/chat/adapter/youtube_api.py
<gh_stars>0 import os import queue from concurrent.futures import ThreadPoolExecutor from googleapiclient.discovery import build from ...time_keeper import keep_time from .parser.youtube_parser import YoutubeParser class YoutubeAPI: def __init__(self, video, parser=YoutubeParser): self._is_active = True...
slow-query/detawane
test/chat/filter/test_post_per_hour_filter.py
from datetime import datetime from unittest import TestCase from unittest.mock import Mock from detawane.chat.filter.post_per_hour_filter import PostPerHourFilter class PostPerHourFilterTestCase(TestCase): def build_message(self, channel_id, published_at): message = Mock() message.channel_id = ch...
slow-query/detawane
detawane/chat/adapter/pychat.py
<gh_stars>0 from pytchat import CompatibleProcessor, LiveChat from .parser.youtube_parser import YoutubeParser class Pychat: def __init__(self, video, parser=YoutubeParser()): self.live_chat = LiveChat(video_id=video.id, processor=CompatibleProcessor()) self._parser = parser def terminate(se...
slow-query/detawane
detawane/channel.py
<filename>detawane/channel.py class Channel: def __init__(self, id, owner_name): self.id = id self.owner_name = owner_name self.url = "https://www.youtube.com/channel/" + id
slow-query/detawane
detawane/chat/filter/post_per_hour_filter.py
<reponame>slow-query/detawane from datetime import datetime, timedelta from .base_filter import BaseFilter class PostPerHourFilter(BaseFilter): def __init__(self, video): super().__init__(video) self.store = {} def _is_selected(self, message): last_post_at = self.store.get(message.ch...
slow-query/detawane
detawane/chat/sentry_processor.py
from ..logger import get_local_logger class SentryProcessor: def __init__(self, logger=get_local_logger(__name__)): self._logger = logger def initialize(self): self._logger.info("番兵プロセス開始") def finalize(self): self._logger.info("番兵プロセス終了") def add_filter(self, filter_class):...
slow-query/detawane
detawane/chat/filter/channel_owner_filter.py
<filename>detawane/chat/filter/channel_owner_filter.py from .base_filter import BaseFilter class ChannelOwnerFilter(BaseFilter): def _is_selected(self, message): return self.video.channel.id == message.channel_id
slow-query/detawane
test/chat/adapter/parser/test_youtube_parser.py
<filename>test/chat/adapter/parser/test_youtube_parser.py import json from datetime import datetime from unittest import TestCase from detawane.chat.adapter.parser.youtube_parser import YoutubeParser class YoutubeParserTestCase(TestCase): DATA = """ { "kind": "youtube#liveChatMessageListResponse", "etag": "c...
slow-query/detawane
detawane/cli/runner.py
import signal from ..time_keeper import keep_time class Runner: MAX_PROCESSING_TIME = 5 def __init__(self): self._is_running = True signal.signal(signal.SIGINT, self._terminate) signal.signal(signal.SIGTERM, self._terminate) def _terminate(self, num, frame): self._is_ru...
slow-query/detawane
detawane/video.py
<filename>detawane/video.py class Video: def __init__(self, channel, id, title, chat_id, start_at): self.channel = channel self.id = id self.title = title self.chat_id = chat_id self.url = "https://www.youtube.com/watch?v=" + id self.start_at = start_at
slow-query/detawane
detawane/chat/message.py
<filename>detawane/chat/message.py from pytz import timezone, utc class Message: def __init__(self, name, channel_id, text, published_at, is_owner, is_sponsor): self.name = name self.channel_id = channel_id self.text = text self.published_at = published_at self.is_owner = i...
slow-query/detawane
test/chat/test_processor.py
from datetime import datetime from unittest import TestCase, skip from unittest.mock import Mock from detawane.chat.processor import Processor class ProcessorTestCase(TestCase): def to_time(self, str): return datetime.strptime(str, "%Y-%m-%d %H:%M:%S") def setUp(self): video = Mock() ...
slow-query/detawane
detawane/chat/processor.py
from datetime import datetime from ..logger import get_local_logger class Processor: def __init__(self, video, adapter, logger=get_local_logger(__name__)): self.video = video self.adapter = adapter(video) self.filters = [] self.handlers = [] self._logger = logger def ...
slow-query/detawane
tool/upcoming_videos/upcoming_video.py
<filename>tool/upcoming_videos/upcoming_video.py #!/usr/bin/env python import argparse import json import os from datetime import datetime from googleapiclient.discovery import build YOUTUBE_API_KEY = os.environ["YOUTUBE_API_KEY"] class Channel: def __init__(self, id, title): self.id = id self....
slow-query/detawane
detawane/time_keeper.py
<filename>detawane/time_keeper.py import time def keep_time(second=0): return TimeKeeper(second) class TimeKeeper: def __init__(self, waiting_second): self.waiting_second = waiting_second def __enter__(self): self.start_time = time.time() return self def __exit__(self, exc_...
slow-query/detawane
detawane/logger.py
from logging import INFO, StreamHandler, getLogger def get_local_logger(module_name, log_level=INFO): logger = getLogger(module_name) logger.setLevel(log_level) logger.addHandler(StreamHandler()) return logger
slow-query/detawane
tool/2434_channel_list/main.py
<gh_stars>0 #!/usr/bin/env python # coding: utf-8 import json from pyquery import PyQuery query = PyQuery("https://nijisanji.ichikara.co.jp/member/") member_urls = [element.get("href") for element in list(query("#liver_list a"))] member_list = [] for member_url in member_urls: query = PyQuery(member_url) m...
slow-query/detawane
detawane/chat/handler/stdout_handler.py
<filename>detawane/chat/handler/stdout_handler.py<gh_stars>0 from .base_handler import BaseHandler class StdoutHandler(BaseHandler): def __call__(self, message): print( "[{}][{}] {}".format( self.video.channel.owner_name, message.name, message.text ), fl...
slow-query/detawane
detawane/chat/adapter/parser/youtube_parser.py
from datetime import datetime from ...message import Message class YoutubeParser: def __call__(self, chat_data): messages = [] chat_data_size = len(chat_data["items"]) if chat_data_size == 0: return messages for raw_message in chat_data["items"]: snippet =...
slow-query/detawane
detawane/cli/config.py
<gh_stars>0 import json from argparse import ArgumentParser from datetime import datetime from ..channel import Channel from ..chat.adapter.pychat import Pychat from ..chat.adapter.youtube_api import YoutubeAPI from ..video import Video class Config: ADAPTER_TABLES = {"pychat": Pychat, "api": YoutubeAPI} de...
slow-query/detawane
test/chat/filter/test_channel_owner_filter.py
<filename>test/chat/filter/test_channel_owner_filter.py<gh_stars>0 from unittest import TestCase from unittest.mock import Mock from detawane.chat.filter.channel_owner_filter import ChannelOwnerFilter class ChannelOwnerFilterTestCase(TestCase): def build_message(self, channel_id): message = Mock() ...
slow-query/detawane
detawane/chat/handler/twitter_handler.py
import os import tweepy from ...logger import get_local_logger from .base_handler import BaseHandler class Client: def __init__(self, logger=get_local_logger(__name__)): auth = tweepy.OAuthHandler( os.environ["TWITTER_CONSUMER_KEY"], os.environ["TWITTER_CONSUMER_SECRET"] ) au...
kalyons11/kevin
kevin/leet/can_form_array.py
# https://leetcode.com/explore/featured/card/january-leetcoding-challenge-2021/579/week-1-january-1st-january-7th/3589/ from typing import List class Solution: def can_form_array(self, arr: List[int], pieces: List[List[int]]) \ -> bool: # idea: start searching from beginning of arr ...
kalyons11/kevin
kevin/utils/link.py
from typing import Any, List class ListNode: def __init__(self, val: Any = 0, next=None): self.val = val self.next = next class LinkedList: def __init__(self, head: ListNode): self.head = head @staticmethod def init_from_list(vals: List[Any]) -> 'LinkedList': assert...
kalyons11/kevin
kevin/leet/product_except_self.py
<gh_stars>1-10 """ https://leetcode.com/explore/interview/card/top-interview-questions-hard/116/array-and-strings/827/ """ from typing import List # refrenced solution to arrive at this result class Solution: def product_except_self(self, nums: List[int]) -> List[int]: """ no division O(n)...
kalyons11/kevin
kevin/tests/leet/test_spiral_matrix.py
""" https://leetcode.com/explore/interview/card/top-interview-questions-hard/116/array-and-strings/828/ """ from typing import List from unittest import TestCase from kevin.leet.spiral_matrix import Solution class TestSpiralMatrix(TestCase): def _base_test_spiral_matrix(self, matrix: List[List[int]], \ ...
kalyons11/kevin
kevin/tests/utils/test_general.py
""" General utils test script. """ from unittest import TestCase import numpy as np from kevin.utils import general class TestUtils(TestCase): def test_string_method(self): x = 'Test-string123__:' y = general.strip_str(x) assert y == 'teststring123' def test_iter_method(self): ...
kalyons11/kevin
kevin/utils/bst.py
<gh_stars>1-10 """ BST utils. """ class TreeNode: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def __repr__(self): return f'val={self.val}, left=({self.left}), right=({self.right})' class BST: def __init__(self, roo...
kalyons11/kevin
kevin/leet/arithmetic_slices.py
<gh_stars>1-10 """ https://leetcode.com/explore/featured/card/february-leetcoding-challenge-2021/586/week-3-february-15th-february-21st/3644/ """ from typing import List # improved solutions use recurison/dynamic programming - TODO later class Solution: def number_of_arithmetic_slices(self, A: List[int]) -> int:...
kalyons11/kevin
kevin/leet/add_two_numbers.py
<gh_stars>1-10 """ https://leetcode.com/problems/add-two-numbers/description/ """ class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode, carry: int = 0) \ -> ListNode: ...
kalyons11/kevin
kevin/leet/add_one_row.py
""" https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/589/week-2-march-8th-march-14th/3666/ """ from collections import deque from kevin.utils.bst import TreeNode class Solution: def add_one_row(self, root: TreeNode, v: int, d: int) -> TreeNode: # do BFS until we hit the proper...
kalyons11/kevin
kevin/tests/leet/test_swap_nodes.py
""" https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/589/week-2-march-8th-march-14th/3671/ """ from typing import List from unittest import TestCase from kevin.leet.swap_nodes import Solution, SolutionOptimized from kevin.utils.link import LinkedList class TestSwapNodes(TestCase): def...
kalyons11/kevin
kevin/leet/max_sum_bst.py
<gh_stars>1-10 """ https://leetcode.com/problems/maximum-sum-bst-in-binary-tree/ """ from kevin.utils.bst import TreeNode # inspired by: # https://leetcode.com/problems/maximum-sum-bst-in-binary-tree/discuss/533254/python-easy-to-understand-divide-and-conquer # this is a tough one! class Solution: def max_sum_bs...
kalyons11/kevin
kevin/tests/leet/test_k_weakest_rows.py
""" https://leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/586/week-3-february-15th-february-21st/3641/ """ from typing import List from unittest import TestCase from kevin.leet.k_weakest_rows import Solution, SolutionOptimized class TestKWeakestRows(TestCase): def _base_test_k_weakest_r...
kalyons11/kevin
kevin/tests/leet/test_restore_the_array.py
<reponame>kalyons11/kevin<gh_stars>1-10 """ https://leetcode.com/problems/restore-the-array/ """ from unittest import TestCase from kevin.leet.restore_the_array import Solution class TestRestoreTheArray(TestCase): def _base_test_restore_the_array(self, s: str, k: int, expected: int): sol = Solution() ...
kalyons11/kevin
kevin/tests/leet/test_reduce_array_size_half.py
<reponame>kalyons11/kevin """ https://leetcode.com/explore/featured/card/july-leetcoding-challenge-2021/608/week-1-july-1st-july-7th/3804/ """ from typing import List from unittest import TestCase from kevin.leet.reduce_array_size_half import Solution class TestReduceArraySizeHalf(TestCase): def _base_test_redu...
kalyons11/kevin
kevin/tests/leet/test_max_sum_bst.py
""" https://leetcode.com/problems/maximum-sum-bst-in-binary-tree/ """ from typing import List from unittest import TestCase from kevin.leet.max_sum_bst import Solution from kevin.utils.bst import BST class TestMaxSumBST(TestCase): def _base_test_max_sum_bst(self, inp_vals: List[int], expected: int): sol...
kalyons11/kevin
kevin/tests/leet/test_can_form_array.py
<reponame>kalyons11/kevin<gh_stars>1-10 """ LeetCode can form array test script. https://leetcode.com/explore/featured/card/january-leetcoding-challenge-2021/579/week-1-january-1st-january-7th/3589/ """ from unittest import TestCase from kevin.leet import can_form_array class TestCanFormArray(TestCase): def ass...
kalyons11/kevin
kevin/leet/two_sum.py
""" https://leetcode.com/problems/two-sum/description/ """ class Solution(): def two_sum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] Using hashing to solve. """ # Simple cases if len(nums) < 2: retu...
kalyons11/kevin
kevin/tests/leet/test_add_one_row.py
<reponame>kalyons11/kevin<filename>kevin/tests/leet/test_add_one_row.py """ https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/589/week-2-march-8th-march-14th/3666/ """ from typing import List from unittest import TestCase from kevin.leet.add_one_row import Solution from kevin.utils.bst impor...