text stringlengths 0 1.05M | meta dict |
|---|---|
"""API for creating a contract and configuring the mock service."""
from __future__ import unicode_literals
import os
import platform
from subprocess import Popen
import psutil
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3 import Retry
from .broker import Broker
from .const... | {
"repo_name": "pact-foundation/pact-python",
"path": "pact/pact.py",
"copies": "1",
"size": "16407",
"license": "mit",
"hash": -1332257370136846000,
"line_mean": 35.6227678571,
"line_max": 88,
"alpha_frac": 0.6024867435,
"autogenerated": false,
"ratio": 4.404563758389262,
"config_test": false,
... |
"""API for email verifications"""
from urllib.parse import quote_plus
from django.urls import reverse
from mail import api
from authentication.models import BlockedEmailRegex
VERIFICATION_TEMPLATE_NAME = "verification"
def send_verification_email(
strategy, backend, code, partial_token
): # pylint: disable=un... | {
"repo_name": "mitodl/open-discussions",
"path": "mail/verification_api.py",
"copies": "1",
"size": "1546",
"license": "bsd-3-clause",
"hash": 3537016259906707500,
"line_mean": 31.8936170213,
"line_max": 97,
"alpha_frac": 0.5692108668,
"autogenerated": false,
"ratio": 4.742331288343558,
"config... |
"""API for email verifications"""
from urllib.parse import quote_plus
from django.urls import reverse
from mail.v2 import api
from mail.v2.constants import EMAIL_VERIFICATION, EMAIL_CHANGE_EMAIL
def send_verification_email(
strategy, backend, code, partial_token
): # pylint: disable=unused-argument
"""
... | {
"repo_name": "mitodl/bootcamp-ecommerce",
"path": "mail/v2/verification_api.py",
"copies": "1",
"size": "2013",
"license": "bsd-3-clause",
"hash": 7293972439432969000,
"line_mean": 31.4677419355,
"line_max": 97,
"alpha_frac": 0.6204669647,
"autogenerated": false,
"ratio": 4.319742489270387,
"c... |
'''API for FHEM homeautomation server, supporting telnet or HTTP/HTTPS connections with authentication and CSRF-token support.'''
import datetime
import json
import logging
import re
import socket
import errno
import ssl
import threading
import time
try:
# Python 3.x
from urllib.parse import quote
from url... | {
"repo_name": "domschl/python-fhem",
"path": "fhem/fhem/__init__.py",
"copies": "1",
"size": "37891",
"license": "mit",
"hash": -775439594242331900,
"line_mean": 43.0081300813,
"line_max": 272,
"alpha_frac": 0.5155577842,
"autogenerated": false,
"ratio": 4.451480263157895,
"config_test": false,... |
"""API for general search-related functionality"""
from base64 import urlsafe_b64encode
from collections import Counter, defaultdict
from elasticsearch_dsl import Q, Search
from elasticsearch_dsl.query import MoreLikeThis
from django.conf import settings
from channels.constants import (
CHANNEL_TYPE_PUBLIC,
C... | {
"repo_name": "mitodl/open-discussions",
"path": "search/api.py",
"copies": "1",
"size": "18625",
"license": "bsd-3-clause",
"hash": 1460504026180602600,
"line_mean": 31.3350694444,
"line_max": 101,
"alpha_frac": 0.6097181208,
"autogenerated": false,
"ratio": 4.027027027027027,
"config_test": f... |
"""API for Google Nest Device Access bound to Home Assistant OAuth."""
import datetime
from aiohttp import ClientSession
from google.oauth2.credentials import Credentials
from google_nest_sdm.auth import AbstractAuth
from homeassistant.helpers import config_entry_oauth2_flow
from .const import API_URL, OAUTH2_TOKEN... | {
"repo_name": "partofthething/home-assistant",
"path": "homeassistant/components/nest/api.py",
"copies": "6",
"size": "2192",
"license": "mit",
"hash": 7637580668833042000,
"line_mean": 38.1428571429,
"line_max": 96,
"alpha_frac": 0.6665145985,
"autogenerated": false,
"ratio": 4.199233716475096,
... |
""" API for heatcontrol """
import datetime, time
from tastypie import fields
from tastypie import resources
from tastypie.utils import timezone
from tastypie.authorization import ReadOnlyAuthorization, Authorization
from center.restapi import THSensorResource, THSensorResourceInstance
from application import restapi
... | {
"repo_name": "rkojedzinszky/thermo-center",
"path": "heatcontrol/restapi.py",
"copies": "1",
"size": "4774",
"license": "bsd-3-clause",
"hash": 6001425139055942000,
"line_mean": 34.1029411765,
"line_max": 128,
"alpha_frac": 0.7119815668,
"autogenerated": false,
"ratio": 4.258697591436218,
"con... |
"""API for Home Connect bound to HASS OAuth."""
from asyncio import run_coroutine_threadsafe
import logging
import homeconnect
from homeconnect.api import HomeConnectError
from homeassistant import config_entries, core
from homeassistant.const import DEVICE_CLASS_TIMESTAMP, PERCENTAGE, TIME_SECONDS
from homeassistan... | {
"repo_name": "tboyce021/home-assistant",
"path": "homeassistant/components/home_connect/api.py",
"copies": "2",
"size": "15203",
"license": "apache-2.0",
"hash": -5196381825392821000,
"line_mean": 36.8184079602,
"line_max": 93,
"alpha_frac": 0.6186936789,
"autogenerated": false,
"ratio": 3.62062... |
"""API for Honeywell Lyric bound to Home Assistant OAuth."""
import logging
from typing import cast
from aiohttp import BasicAuth, ClientSession
from aiolyric.client import LyricClient
from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.helpers.aiohttp_client import async_get_clientsession
... | {
"repo_name": "w1ll1am23/home-assistant",
"path": "homeassistant/components/lyric/api.py",
"copies": "5",
"size": "1784",
"license": "apache-2.0",
"hash": 8183852116710474000,
"line_mean": 31.4363636364,
"line_max": 86,
"alpha_frac": 0.673206278,
"autogenerated": false,
"ratio": 3.991051454138702... |
"""API for latubot
- sport (latu, luistelu)
- area (OULU, SYOTE)
- group (oulu, haukipudas) (previously city)
- name ("Iinatti 8km"...) (previously place)
"""
import logging
from datetime import datetime
from dateutil.tz import tzutc
from latubot.source import kunto
from latubot import time_utils
logger = logging... | {
"repo_name": "suola/latubot",
"path": "latubot/source/api.py",
"copies": "1",
"size": "1646",
"license": "mit",
"hash": 4482847999241289000,
"line_mean": 21.8611111111,
"line_max": 74,
"alpha_frac": 0.6342648846,
"autogenerated": false,
"ratio": 3.318548387096774,
"config_test": false,
"has_... |
"""API for Lokalise."""
from __future__ import annotations
from pprint import pprint
import requests
from .util import get_lokalise_token
def get_api(project_id, debug=False) -> Lokalise:
"""Get Lokalise API."""
return Lokalise(project_id, get_lokalise_token(), debug)
class Lokalise:
"""Lokalise API.... | {
"repo_name": "home-assistant/home-assistant",
"path": "script/translations/lokalise.py",
"copies": "7",
"size": "2569",
"license": "apache-2.0",
"hash": -8701533837666798000,
"line_mean": 27.5444444444,
"line_max": 86,
"alpha_frac": 0.5811599844,
"autogenerated": false,
"ratio": 3.75584795321637... |
"""API for Lokalise."""
from pprint import pprint
import requests
from .util import get_lokalise_token
def get_api(project_id, debug=False) -> "Lokalise":
"""Get Lokalise API."""
return Lokalise(project_id, get_lokalise_token(), debug)
class Lokalise:
"""Lokalise API."""
def __init__(self, projec... | {
"repo_name": "tboyce021/home-assistant",
"path": "script/translations/lokalise.py",
"copies": "14",
"size": "2535",
"license": "apache-2.0",
"hash": -4848184431465085000,
"line_mean": 27.8068181818,
"line_max": 86,
"alpha_frac": 0.5783037475,
"autogenerated": false,
"ratio": 3.7444608567208273,
... |
"""API for managing channel memberships"""
import logging
import operator
from functools import reduce
from django.contrib.auth import get_user_model
from channels.api import get_admin_api
from channels.models import Channel
from profiles.filters import UserFilter
from profiles.models import Profile
log = logging.ge... | {
"repo_name": "mitodl/open-discussions",
"path": "channels/membership_api.py",
"copies": "1",
"size": "3588",
"license": "bsd-3-clause",
"hash": -1267214863484069600,
"line_mean": 34.5247524752,
"line_max": 123,
"alpha_frac": 0.6596989967,
"autogenerated": false,
"ratio": 4.3125,
"config_test":... |
"""API for Neato Botvac bound to Home Assistant OAuth."""
from asyncio import run_coroutine_threadsafe
import pybotvac
from homeassistant import config_entries, core
from homeassistant.helpers import config_entry_oauth2_flow
class ConfigEntryAuth(pybotvac.OAuthSession):
"""Provide Neato Botvac authentication ti... | {
"repo_name": "turbokongen/home-assistant",
"path": "homeassistant/components/neato/api.py",
"copies": "5",
"size": "1890",
"license": "apache-2.0",
"hash": -488377590062082800,
"line_mean": 35.3461538462,
"line_max": 99,
"alpha_frac": 0.6846560847,
"autogenerated": false,
"ratio": 4.2,
"config... |
"""API for Ondilo ICO bound to Home Assistant OAuth."""
from asyncio import run_coroutine_threadsafe
import logging
from ondilo import Ondilo
from homeassistant import config_entries, core
from homeassistant.helpers import config_entry_oauth2_flow
_LOGGER = logging.getLogger(__name__)
class OndiloClient(Ondilo):
... | {
"repo_name": "kennedyshead/home-assistant",
"path": "homeassistant/components/ondilo_ico/api.py",
"copies": "2",
"size": "1719",
"license": "apache-2.0",
"hash": 9131152548661264000,
"line_mean": 33.38,
"line_max": 91,
"alpha_frac": 0.6335078534,
"autogenerated": false,
"ratio": 3.96997690531177... |
"""API for open discussions integration"""
import logging
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import transaction
from open_discussions_api.client import OpenDiscussionsApi
from open_discussions_api.constants import ROLE_STAFF
from requests.exceptions ... | {
"repo_name": "mitodl/micromasters",
"path": "discussions/api.py",
"copies": "1",
"size": "16514",
"license": "bsd-3-clause",
"hash": -8962814243801495000,
"line_mean": 34.2863247863,
"line_max": 109,
"alpha_frac": 0.6681603488,
"autogenerated": false,
"ratio": 4.232188621219887,
"config_test":... |
"""API for performing and verifying device authentication."""
import binascii
import logging
import plistlib
from typing import Dict
from pyatv import exceptions
from pyatv.airplay.srp import LegacyCredentials, SRPAuthHandler
from pyatv.exceptions import AuthenticationError
from pyatv.support.http import HttpConnecti... | {
"repo_name": "postlund/pyatv",
"path": "pyatv/airplay/auth.py",
"copies": "1",
"size": "3449",
"license": "mit",
"hash": 7954700564257851000,
"line_mean": 34.193877551,
"line_max": 86,
"alpha_frac": 0.6436648304,
"autogenerated": false,
"ratio": 3.769398907103825,
"config_test": false,
"has_... |
"""API for persistent storage for the frontend."""
from functools import wraps
import voluptuous as vol
from homeassistant.components import websocket_api
DATA_STORAGE = 'frontend_storage'
STORAGE_VERSION_USER_DATA = 1
STORAGE_KEY_USER_DATA = 'frontend.user_data_{}'
async def async_setup_frontend_storage(hass):
... | {
"repo_name": "HydrelioxGitHub/home-assistant",
"path": "homeassistant/components/frontend/storage.py",
"copies": "10",
"size": "2368",
"license": "apache-2.0",
"hash": -6972776977316450000,
"line_mean": 27.5301204819,
"line_max": 76,
"alpha_frac": 0.6321790541,
"autogenerated": false,
"ratio": 3... |
"""API for persistent storage for the frontend."""
from functools import wraps
import voluptuous as vol
from homeassistant.components import websocket_api
DATA_STORAGE = "frontend_storage"
STORAGE_VERSION_USER_DATA = 1
STORAGE_KEY_USER_DATA = "frontend.user_data_{}"
async def async_setup_frontend_storage(hass):
... | {
"repo_name": "fbradyirl/home-assistant",
"path": "homeassistant/components/frontend/storage.py",
"copies": "1",
"size": "2298",
"license": "apache-2.0",
"hash": -8548808680167196000,
"line_mean": 29.2368421053,
"line_max": 81,
"alpha_frac": 0.6514360313,
"autogenerated": false,
"ratio": 3.618897... |
"""API for persistent storage for the frontend."""
from functools import wraps
import voluptuous as vol
from homeassistant.components import websocket_api
# mypy: allow-untyped-calls, allow-untyped-defs
DATA_STORAGE = "frontend_storage"
STORAGE_VERSION_USER_DATA = 1
STORAGE_KEY_USER_DATA = "frontend.user_data_{}"
... | {
"repo_name": "joopert/home-assistant",
"path": "homeassistant/components/frontend/storage.py",
"copies": "3",
"size": "2348",
"license": "apache-2.0",
"hash": -7974227940992741000,
"line_mean": 28.7215189873,
"line_max": 81,
"alpha_frac": 0.6533219761,
"autogenerated": false,
"ratio": 3.59021406... |
"""API for persistent storage for the frontend."""
from functools import wraps
import voluptuous as vol
from homeassistant.components import websocket_api
# mypy: allow-untyped-calls, allow-untyped-defs
DATA_STORAGE = "frontend_storage"
STORAGE_VERSION_USER_DATA = 1
async def async_setup_frontend_storage(hass):
... | {
"repo_name": "home-assistant/home-assistant",
"path": "homeassistant/components/frontend/storage.py",
"copies": "21",
"size": "2277",
"license": "apache-2.0",
"hash": 5892880078299762000,
"line_mean": 28.5714285714,
"line_max": 85,
"alpha_frac": 0.6556873079,
"autogenerated": false,
"ratio": 3.5... |
"""API for plugin writers to adhere to.
Engine shall instantiate the drawingboard module.
"""
version = "1.0"
import os
plugSourcesPath = "C:\\Amit\\dev\\cpp\\of_v0.7.4_vs2010_release\\of_v0.7.4_vs2010_release\\apps\\myApps\\alpha-goldDust\\bin\\plug\\py\\sources" ##os.path.join("..", "sources")
####################... | {
"repo_name": "decebel/dataAtom_alpha",
"path": "bin/plug/py/api/drawingboard.py",
"copies": "1",
"size": "9016",
"license": "apache-2.0",
"hash": -3267209283881317400,
"line_mean": 21.0980392157,
"line_max": 176,
"alpha_frac": 0.6937666371,
"autogenerated": false,
"ratio": 3.131642931573463,
"... |
"""API for Python Jeeves libary.
:synopsis: Functions for creating sensitive values, labels, and policies.
.. moduleauthor:: Travis Hance <tjhance7@gmail.com>
.. moduleauthor:: Jean Yang <jeanyang@csail.mit.edu>
"""
from env.ConcreteCache import ConcreteCache
from env.VarEnv import VarEnv
from env.PolicyEnv imp... | {
"repo_name": "jonathanmarvens/jeeves",
"path": "JeevesLib.py",
"copies": "2",
"size": "17374",
"license": "mit",
"hash": 9138850045440676000,
"line_mean": 35.1958333333,
"line_max": 176,
"alpha_frac": 0.5386784851,
"autogenerated": false,
"ratio": 3.7810663764961916,
"config_test": false,
"h... |
"""API for reading notebooks.
Authors:
* Jonathan Frederic
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of th... | {
"repo_name": "EricCline/CEM_inc",
"path": "env/lib/python2.7/site-packages/IPython/nbformat/reader.py",
"copies": "4",
"size": "2709",
"license": "mit",
"hash": 6114249196295753000,
"line_mean": 24.3177570093,
"line_max": 88,
"alpha_frac": 0.5145810262,
"autogenerated": false,
"ratio": 4.5915254... |
"""API for reading notebooks of different versions"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import json
class NotJSONError(ValueError):
pass
def parse_json(s, **kwargs):
"""Parse a JSON string into a dict."""
try:
nb_dict = json.load... | {
"repo_name": "nitin-cherian/LifeLongLearning",
"path": "Python/PythonProgrammingLanguage/Encapsulation/encap_env/lib/python3.5/site-packages/nbformat/reader.py",
"copies": "17",
"size": "2060",
"license": "mit",
"hash": -7127258372401524000,
"line_mean": 24.1219512195,
"line_max": 88,
"alpha_frac": ... |
"""API for reading notebooks of different versions"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import json
class NotJSONError(ValueError):
pass
def parse_json(s, **kwargs):
"""Parse a JSON string into a dict."""
try:
nb_dict = json.lo... | {
"repo_name": "mattvonrocketstein/smash",
"path": "smashlib/ipy3x/nbformat/reader.py",
"copies": "1",
"size": "2082",
"license": "mit",
"hash": 4237860362427194000,
"line_mean": 22.9310344828,
"line_max": 79,
"alpha_frac": 0.6219980788,
"autogenerated": false,
"ratio": 4.164,
"config_test": fal... |
# API for the TI eQEP hardware driver I wrote
# We need OS operations for this
import os
import select
class eQEP(object):
# Modes
MODE_ABSOLUTE = 0
MODE_RELATIVE = 1
# eQEP Controller Locations
eQEP0 = "/sys/devices/ocp.2/48300000.epwmss/48300180.eqep"
eQEP1 = "/sys/devices/ocp.2/4830200... | {
"repo_name": "ValRose/Rose_Bone",
"path": "PythonLibraries/eqep.py",
"copies": "1",
"size": "3612",
"license": "mit",
"hash": -4257724933076015600,
"line_mean": 27.4409448819,
"line_max": 98,
"alpha_frac": 0.5631229236,
"autogenerated": false,
"ratio": 4.128,
"config_test": false,
"has_no_ke... |
# API for the TI eQEP hardware driver I wrote
# We need OS operations for this
import os, select
class eQEP(object):
# Modes
MODE_ABSOLUTE = 0
MODE_RELATIVE = 1
# eQEP Controller Locations
eQEP0 = "/sys/devices/ocp.2/48300000.epwmss/48300180.eqep"
eQEP1 = "/sys/devices/ocp.2/48302000.epwm... | {
"repo_name": "mcdeoliveira/pyctrl",
"path": "pyctrl/bbb/eqep.py",
"copies": "3",
"size": "3588",
"license": "apache-2.0",
"hash": 7913465065470100000,
"line_mean": 27.935483871,
"line_max": 98,
"alpha_frac": 0.5652173913,
"autogenerated": false,
"ratio": 4.109965635738831,
"config_test": false... |
"""API for the Universal Device's ISY
This is a Work in progress
Supporting a Simple and OO interface for ISY home automation netapp
see also : http://www.universal-devices.com/residential/
http://wiki.universal-devices.com/index.php?title=Main_Page
NOTE: This Libaray is not written my or supported by u... | {
"repo_name": "evilpete/ISYlib-python",
"path": "ISY/__init__.py",
"copies": "1",
"size": "3385",
"license": "bsd-2-clause",
"hash": 4461183024855848000,
"line_mean": 25.8650793651,
"line_max": 110,
"alpha_frac": 0.6980797637,
"autogenerated": false,
"ratio": 3.334975369458128,
"config_test": f... |
"""API for the Universal Device's ISY
This is a Work in progress
Supporting a Simple and OO interface for ISY home automation netapp
see also : http://www.universal-devices.com/residential/
http://wiki.universal-devices.com/index.php?title=Main_Page
NOTE: This Libaray is not written my or supported by ... | {
"repo_name": "fxstein/ISYlib-python",
"path": "ISY/__init__.py",
"copies": "1",
"size": "3305",
"license": "bsd-2-clause",
"hash": 7753496546243822000,
"line_mean": 26.7731092437,
"line_max": 107,
"alpha_frac": 0.7074130106,
"autogenerated": false,
"ratio": 3.282025819265144,
"config_test": fa... |
"""api for totals"""
from flask import Flask, jsonify, request
import finds
app = Flask(__name__)
mongohandle = finds.connect()
@app.route('/corporation/<int:corporationid>', methods=['GET'])
def get_by_corporation(corporationid):
"""get totals of all losses for a corporation over specified time period"""
if ... | {
"repo_name": "namrak/fpapi",
"path": "server.py",
"copies": "1",
"size": "5404",
"license": "mit",
"hash": -6847418402877151000,
"line_mean": 62.5764705882,
"line_max": 106,
"alpha_frac": 0.4420799408,
"autogenerated": false,
"ratio": 4.908265213442325,
"config_test": false,
"has_no_keywords... |
"""API for traversing the AST nodes. Implemented by the compiler and
meta introspection.
"""
from .nodes import Node
class NodeVisitor:
"""Walks the abstract syntax tree and call visitor functions for every
node found. The visitor functions may return values which will be
forwarded by the `visit` method.... | {
"repo_name": "pallets/jinja2",
"path": "src/jinja2/visitor.py",
"copies": "3",
"size": "3184",
"license": "bsd-3-clause",
"hash": -8247278693582226000,
"line_mean": 39.3037974684,
"line_max": 76,
"alpha_frac": 0.5926507538,
"autogenerated": false,
"ratio": 4.465638148667602,
"config_test": fal... |
"""API for traversing the AST nodes. Implemented by the compiler and
meta introspection.
"""
import typing as t
from .nodes import Node
if t.TYPE_CHECKING:
import typing_extensions as te
class VisitCallable(te.Protocol):
def __call__(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any:
... | {
"repo_name": "pallets/jinja",
"path": "src/jinja2/visitor.py",
"copies": "1",
"size": "3572",
"license": "bsd-3-clause",
"hash": 4126757494746424300,
"line_mean": 37.8260869565,
"line_max": 84,
"alpha_frac": 0.5935050392,
"autogenerated": false,
"ratio": 4.18757327080891,
"config_test": false,... |
"""API for USB radio receiver for initializing device and data I/O"""
import usb.core
import usb.util
MICROCHIP_VID = 0x04D8
EXAMPLE_PID = 0x003F
INTERFACE = 0
# Read / Write / Reply
READ = 0x00
WRITE = 0x01
REPLY = 0x02
# Message Types
ERROR = 0x00
CONFIG = 0x01
DATA = 0x02
RESETDEVICE = 0x03
RTC = 0x04
MESSAGETYP... | {
"repo_name": "surfmikko/weatherstation",
"path": "weatherstation/receiver.py",
"copies": "1",
"size": "4206",
"license": "mit",
"hash": -7179288121762727000,
"line_mean": 20.90625,
"line_max": 72,
"alpha_frac": 0.5706134094,
"autogenerated": false,
"ratio": 4.1114369501466275,
"config_test": t... |
"""API for user module."""
import requests
from flask import Blueprint, render_template, request, flash, url_for, redirect
from flask import current_app
from flask_security.utils import login_user
from tagio.models.user import User
from tagio.utils import string_generator
blueprint = Blueprint('slack',
... | {
"repo_name": "makerhanoi/tagio",
"path": "tagio/views/slack.py",
"copies": "1",
"size": "2535",
"license": "bsd-3-clause",
"hash": 3029470987435965000,
"line_mean": 29.1785714286,
"line_max": 84,
"alpha_frac": 0.617357002,
"autogenerated": false,
"ratio": 3.7007299270072993,
"config_test": fal... |
"""API for working with a Nvim Buffer."""
from .common import Remote
from ..compat import IS_PYTHON3, check_async
__all__ = ('Buffer')
if IS_PYTHON3:
basestring = str
def adjust_index(idx, default=None):
"""Convert from python indexing convention to nvim indexing convention."""
if idx is None:
... | {
"repo_name": "zchee/python-client",
"path": "pynvim/api/buffer.py",
"copies": "2",
"size": "7024",
"license": "apache-2.0",
"hash": 3680403572262321000,
"line_mean": 32.4476190476,
"line_max": 79,
"alpha_frac": 0.5727505695,
"autogenerated": false,
"ratio": 3.9931779420125073,
"config_test": f... |
"""API for working with a Nvim Buffer."""
from .common import Remote
from ..compat import IS_PYTHON3
__all__ = ('Buffer')
if IS_PYTHON3:
basestring = str
def adjust_index(idx, default=None):
"""Convert from python indexing convention to nvim indexing convention."""
if idx is None:
return defau... | {
"repo_name": "brcolow/python-client",
"path": "neovim/api/buffer.py",
"copies": "1",
"size": "5788",
"license": "apache-2.0",
"hash": 5721764985224044000,
"line_mean": 30.2864864865,
"line_max": 78,
"alpha_frac": 0.5668624741,
"autogenerated": false,
"ratio": 3.9643835616438357,
"config_test":... |
"""API for working with a Nvim Buffer."""
from pynvim.api.common import Remote
from pynvim.compat import IS_PYTHON3, check_async
__all__ = ('Buffer')
if IS_PYTHON3:
basestring = str
def adjust_index(idx, default=None):
"""Convert from python indexing convention to nvim indexing convention."""
if idx i... | {
"repo_name": "Shougo/python-client",
"path": "pynvim/api/buffer.py",
"copies": "2",
"size": "7205",
"license": "apache-2.0",
"hash": 6590644328629005000,
"line_mean": 32.202764977,
"line_max": 79,
"alpha_frac": 0.572796669,
"autogenerated": false,
"ratio": 3.9916897506925206,
"config_test": fa... |
"""API for working with Nvim buffers."""
from .common import Remote
from ..compat import IS_PYTHON3
__all__ = ('Buffer')
if IS_PYTHON3:
basestring = str
class Buffer(Remote):
"""A remote Nvim buffer."""
_api_prefix = "buffer_"
def __len__(self):
"""Return the number of lines contained i... | {
"repo_name": "timeyyy/python-client",
"path": "neovim/api/buffer.py",
"copies": "1",
"size": "6609",
"license": "apache-2.0",
"hash": -2438271176882659300,
"line_mean": 31.3970588235,
"line_max": 79,
"alpha_frac": 0.548645786,
"autogenerated": false,
"ratio": 4.2041984732824424,
"config_test":... |
"""API for working with Nvim buffers."""
from .common import Remote, RemoteMap
from ..compat import IS_PYTHON3
__all__ = ('Buffer')
if IS_PYTHON3:
basestring = str
class Buffer(Remote):
"""A remote Nvim buffer."""
def __init__(self, session, code_data):
"""Initialize from session and code_da... | {
"repo_name": "0x90sled/python-client",
"path": "neovim/api/buffer.py",
"copies": "4",
"size": "6645",
"license": "apache-2.0",
"hash": 624168714945834000,
"line_mean": 31.896039604,
"line_max": 79,
"alpha_frac": 0.5550037622,
"autogenerated": false,
"ratio": 4.300970873786408,
"config_test": f... |
"""API for working with Nvim tabpages."""
from .common import Remote, RemoteMap, RemoteSequence
__all__ = ('Tabpage')
class Tabpage(Remote):
"""A remote Nvim tabpage."""
def __init__(self, session, code_data):
"""Initialize from session and code_data immutable object.
The `code_data` cont... | {
"repo_name": "starcraftman/python-client",
"path": "neovim/api/tabpage.py",
"copies": "5",
"size": "1031",
"license": "apache-2.0",
"hash": 6166943724153261000,
"line_mean": 31.21875,
"line_max": 77,
"alpha_frac": 0.6285160039,
"autogenerated": false,
"ratio": 4.124,
"config_test": false,
"h... |
"""API for working with Nvim windows."""
from .common import Remote, RemoteMap
__all__ = ('Window')
class Window(Remote):
"""A remote Nvim window."""
def __init__(self, session, code_data):
"""Initialize from session and code_data immutable object.
The `code_data` contains serialization i... | {
"repo_name": "starcraftman/python-client",
"path": "neovim/api/window.py",
"copies": "5",
"size": "2549",
"license": "apache-2.0",
"hash": 2235249087990921500,
"line_mean": 31.6794871795,
"line_max": 76,
"alpha_frac": 0.6112200863,
"autogenerated": false,
"ratio": 4.192434210526316,
"config_te... |
"""API for xbox bound to Home Assistant OAuth."""
from aiohttp import ClientSession
from xbox.webapi.authentication.manager import AuthenticationManager
from xbox.webapi.authentication.models import OAuth2TokenResponse
from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.util.dt import utc_fro... | {
"repo_name": "GenericStudent/home-assistant",
"path": "homeassistant/components/xbox/api.py",
"copies": "12",
"size": "1572",
"license": "apache-2.0",
"hash": 1841012023460980000,
"line_mean": 39.3076923077,
"line_max": 80,
"alpha_frac": 0.6806615776,
"autogenerated": false,
"ratio": 4.214477211... |
"""API functionality for integrating with NovoEd"""
from urllib.parse import urljoin
import logging
import operator
import requests
from django.conf import settings
from djangosaml2idp.processors import BaseProcessor
from rest_framework import status
from klasses.models import BootcampRunEnrollment
from main.utils im... | {
"repo_name": "mitodl/bootcamp-ecommerce",
"path": "novoed/api.py",
"copies": "1",
"size": "4260",
"license": "bsd-3-clause",
"hash": 6557026964378166000,
"line_mean": 34.7983193277,
"line_max": 117,
"alpha_frac": 0.6455399061,
"autogenerated": false,
"ratio": 3.6724137931034484,
"config_test":... |
'''API functions for adding data to CKAN.'''
import logging
import random
import re
from pylons import config
import paste.deploy.converters
import ckan.lib.plugins as lib_plugins
import ckan.logic as logic
import ckan.rating as ratings
import ckan.plugins as plugins
import ckan.lib.dictization
import ckan.logic.act... | {
"repo_name": "WilJoey/tn_ckan",
"path": "ckan/logic/action/create.py",
"copies": "1",
"size": "47148",
"license": "mit",
"hash": -320518789178124800,
"line_mean": 34.3168539326,
"line_max": 111,
"alpha_frac": 0.6464325104,
"autogenerated": false,
"ratio": 4,
"config_test": false,
"has_no_key... |
'''API functions for deleting data from CKAN.'''
from sqlalchemy import or_
import ckan.logic
import ckan.logic.action
import ckan.plugins as plugins
import ckan.lib.dictization.model_dictize as model_dictize
from ckan.common import _
validate = ckan.lib.navl.dictization_functions.validate
# Define some shortcuts
... | {
"repo_name": "WilJoey/tn_ckan",
"path": "ckan/logic/action/delete.py",
"copies": "1",
"size": "17234",
"license": "mit",
"hash": -5513542143168684000,
"line_mean": 27.5804311774,
"line_max": 89,
"alpha_frac": 0.6423349193,
"autogenerated": false,
"ratio": 3.6959039245121166,
"config_test": fal... |
'''API functions for searching for and getting data from CKAN.'''
import uuid
import logging
import json
import datetime
import socket
from pylons import config
import sqlalchemy
import ckan.lib.dictization
import ckan.logic as logic
import ckan.logic.action
import ckan.logic.schema
import ckan.lib.dictization.model... | {
"repo_name": "WilJoey/tn_ckan",
"path": "ckan/logic/action/get.py",
"copies": "1",
"size": "100246",
"license": "mit",
"hash": -1072922379604111500,
"line_mean": 32.5945040214,
"line_max": 95,
"alpha_frac": 0.6365441015,
"autogenerated": false,
"ratio": 3.9170834635823697,
"config_test": false... |
"""API functions to update heartbeats.
This module exists to keep external code decoupled from our model-based
implementation. This allows extending the functionality later to support
different mechanisms for tracking heartbeats (e.g. external services).
"""
from functools import wraps
from django.utils.timezone impo... | {
"repo_name": "mvantellingen/django-healthchecks",
"path": "src/django_healthchecks/heartbeats.py",
"copies": "1",
"size": "2133",
"license": "mit",
"hash": -6579686351624049000,
"line_mean": 28.2191780822,
"line_max": 84,
"alpha_frac": 0.6877637131,
"autogenerated": false,
"ratio": 4.14174757281... |
"""ApiGatewayLambdaSetupFunction
Performs necessary API Gateway / Lambda setup.
* Adds Lambda execution permissions to API Gateway endpoints
* Adds necessary stage variables so function name mappings (from Swagger
for CORS) will work
* Adds necessary stage variables so necessary CORS headers can be resolved
... | {
"repo_name": "moduspwnens/boa-chat",
"path": "boa-nimbus/lambda/ApiGatewayLambdaSetupFunction/index.py",
"copies": "1",
"size": "11319",
"license": "mit",
"hash": 4530461941589525500,
"line_mean": 41.3970037453,
"line_max": 124,
"alpha_frac": 0.5018111141,
"autogenerated": false,
"ratio": 4.9710... |
import string
import inspect
import os
import sys
import pkgutil
import shutil
def _obj_name(obj):
if hasattr(obj, '__name__'):
return obj.__name__
def docstring_to_markdown(docstring):
"""Convert a Python object's docstring to markdown
Parameters
----------
docstring : str
Th... | {
"repo_name": "rasbt/biopandas",
"path": "docs/make_api.py",
"copies": "1",
"size": "13363",
"license": "bsd-3-clause",
"hash": -3116583341007039500,
"line_mean": 31.4344660194,
"line_max": 79,
"alpha_frac": 0.513058445,
"autogenerated": false,
"ratio": 4.269329073482428,
"config_test": false,
... |
"""API Handler Class"""
# standard library
import gzip
import os
import shutil
from logging.handlers import RotatingFileHandler
from typing import Optional
class RotatingFileHandlerCustom(RotatingFileHandler):
"""Logger handler for ThreatConnect Exchange File logging."""
def __init__(
self,
f... | {
"repo_name": "kstilwell/tcex",
"path": "tcex/logger/rotating_file_handler_custom.py",
"copies": "2",
"size": "3432",
"license": "apache-2.0",
"hash": 1982358539146169300,
"line_mean": 32.6470588235,
"line_max": 99,
"alpha_frac": 0.5818764569,
"autogenerated": false,
"ratio": 3.953917050691244,
... |
"""API Handler Class"""
# standard library
import logging
import threading
import time
class ApiHandler(logging.Handler):
"""Logger handler for ThreatConnect Exchange API logging."""
def __init__(self, session, flush_limit=100):
"""Initialize Class properties.
Args:
session (Requ... | {
"repo_name": "kstilwell/tcex",
"path": "tcex/logger/api_handler.py",
"copies": "1",
"size": "2614",
"license": "apache-2.0",
"hash": -6659380453747026000,
"line_mean": 28.7045454545,
"line_max": 99,
"alpha_frac": 0.5623565417,
"autogenerated": false,
"ratio": 4.4683760683760685,
"config_test":... |
"""API Handlers.
"""
# third-party imports
from google.appengine.api import mail
# local imports
from app.base.handlers import BaseAjaxHandler
from app import config
from app.forms.contacts import ContactForm
class ContactHandler(BaseAjaxHandler):
"""Handles the form submission from the frontend contact page.
... | {
"repo_name": "mjmcconnell/sra",
"path": "src-server/app/handlers/apis/mail.py",
"copies": "1",
"size": "1529",
"license": "apache-2.0",
"hash": 746518695700519300,
"line_mean": 32.2391304348,
"line_max": 77,
"alpha_frac": 0.5905820798,
"autogenerated": false,
"ratio": 4.356125356125356,
"confi... |
"""API harvester for DataOne - for the SHARE project
Example query: https://cn.dataone.org/cn/v1/query/solr/?q=dateModified:[NOW-5DAY%20TO%20*]&rows=10
"""
from __future__ import unicode_literals
import logging
from datetime import timedelta, date
from lxml import etree
from functools import partial
from dateutil.p... | {
"repo_name": "fabianvf/scrapi",
"path": "scrapi/harvesters/dataone.py",
"copies": "1",
"size": "7555",
"license": "apache-2.0",
"hash": 4731498114516477000,
"line_mean": 39.4010695187,
"line_max": 184,
"alpha_frac": 0.5759099934,
"autogenerated": false,
"ratio": 4.066200215285253,
"config_test... |
"""API harvester for DataOne - for the SHARE project
Example query: https://cn.dataone.org/cn/v1/query/solr/?q=dateModified:[NOW-5DAY%20TO%20*]&rows=10
"""
## harvester for DataONE SOLR search API
from __future__ import unicode_literals
import re
import logging
from datetime import timedelta, date
from lxml impor... | {
"repo_name": "icereval/scrapi",
"path": "scrapi/harvesters/dataone.py",
"copies": "1",
"size": "7978",
"license": "apache-2.0",
"hash": -5343840664655323000,
"line_mean": 38.3004926108,
"line_max": 185,
"alpha_frac": 0.5688142392,
"autogenerated": false,
"ratio": 3.9455984174085064,
"config_te... |
# API host url to make the call against
HOST_URL = ''
PORT = 443
# Represents WS1 _numeric_ organization group-ID
TENANT_GROUP_ID = ''
# The WS1 REST API tenant code
AW_TENANT_CODE = ''
# Username and Password to access WS1 REST APIs
API_USERNAME = ''
API_PASSWORD = ''
# # 1024 * 1024 = 1 MB default. Modify as required... | {
"repo_name": "vmwaresamples/AirWatch-samples",
"path": "Mobile apps CICD script/config/config.py",
"copies": "1",
"size": "2025",
"license": "bsd-3-clause",
"hash": 2491613008707397600,
"line_mean": 47.2142857143,
"line_max": 120,
"alpha_frac": 0.6335802469,
"autogenerated": false,
"ratio": 4.5,... |
""" API implementation for course grade-policy """
from rest_framework import generics
from api import *
from serializers import CourseGradeSerializer
from rest_framework.permissions import IsAuthenticated
from django.http import Http404
from rest_framework.authentication import SessionAuthentication, BasicAuthenticat... | {
"repo_name": "jaygoswami2303/course_dashboard_api",
"path": "v2/GradePolicyAPI/views.py",
"copies": "1",
"size": "4691",
"license": "mit",
"hash": 3809723215747540500,
"line_mean": 35.0923076923,
"line_max": 126,
"alpha_frac": 0.5924109998,
"autogenerated": false,
"ratio": 5.282657657657658,
"... |
# API information
# http://myanimelist.net/modules.php?go=api
from logging import debug, info, warning, error
import re
from .. import AbstractInfoHandler
from data.models import UnprocessedShow, ShowType
class InfoHandler(AbstractInfoHandler):
_show_link_base = "http://myanimelist.net/anime/{id}/"
_show_link_mat... | {
"repo_name": "TheEnigmaBlade/holo",
"path": "src/services/info/myanimelist.py",
"copies": "2",
"size": "5405",
"license": "mit",
"hash": 6806540905714169000,
"line_mean": 30.0632183908,
"line_max": 113,
"alpha_frac": 0.670120259,
"autogenerated": false,
"ratio": 3.0640589569161,
"config_test":... |
# API information
# http://wiki.anidb.net/w/HTTP_API_Definition
# Limits
# - 1 page every 2 seconds
# - Avoid calling same function multiple times per day
#
# Season page
# http://anidb.net/perl-bin/animedb.pl?tvseries=1&show=calendar
# - Based on year and month, defaults to current month
from logging import debug... | {
"repo_name": "andrewhillcode/holo",
"path": "src/services/info/anidb.py",
"copies": "2",
"size": "3784",
"license": "mit",
"hash": 7516533145852217000,
"line_mean": 31.9043478261,
"line_max": 124,
"alpha_frac": 0.6649048626,
"autogenerated": false,
"ratio": 2.7905604719764012,
"config_test": f... |
# api/__init__.py
from flask import Flask, request
from flask_sqlalchemy import SQLAlchemy
from config import config
db = SQLAlchemy()
def add_cors_headers(response, ):
response.headers.add('Access-Control-Allow-Origin', '*')
if request.method == 'OPTIONS':
response.headers['Access-Control-Allow-Meth... | {
"repo_name": "Mbarak-Mbigo/cp2_bucketlist",
"path": "api/__init__.py",
"copies": "1",
"size": "1046",
"license": "mit",
"hash": -4063555159342365000,
"line_mean": 29.7647058824,
"line_max": 83,
"alpha_frac": 0.6711281071,
"autogenerated": false,
"ratio": 3.762589928057554,
"config_test": true,... |
""" API integration for osu!
Adds Mods enums with raw value calculations and some
request functions.
"""
from collections import namedtuple
from enum import Enum
import re
from pcbot import utils
api_url = "https://osu.ppy.sh/api/"
api_key = ""
requests_sent = 0
ripple_url = "https://ripple.moe/api/"
ripp... | {
"repo_name": "PcBoy111/PCBOT",
"path": "plugins/osulib/api.py",
"copies": "1",
"size": "10082",
"license": "mit",
"hash": 3258670899188709400,
"line_mean": 31.0955414013,
"line_max": 135,
"alpha_frac": 0.6085532844,
"autogenerated": false,
"ratio": 3.3909825033647376,
"config_test": false,
"... |
""" API integration for osu!
Adds Mods enums with raw value calculations and some
request functions.
"""
import logging
import re
from collections import namedtuple
from enum import Enum
from pcbot import utils
api_url = "https://osu.ppy.sh/api/"
api_key = ""
requests_sent = 0
ripple_url = "https://ripple... | {
"repo_name": "PcBoy111/PC-BOT-V2",
"path": "plugins/osulib/api.py",
"copies": "2",
"size": "10277",
"license": "mit",
"hash": 6150155475992589000,
"line_mean": 31.2037617555,
"line_max": 135,
"alpha_frac": 0.6057626789,
"autogenerated": false,
"ratio": 3.4140910601528747,
"config_test": false,... |
"""API interactions with community.lsst.org API."""
import os
import csv
import json
import requests
BASE_URL = 'https://community.lsst.org'
KEY = os.getenv('DISCOURSE_KEY')
USER = os.getenv('DISCOURSE_USER')
if KEY is None or USER is None:
print('Please set $DISCOURSE_KEY and $DISCOURSE_USER environment '
... | {
"repo_name": "lsst-sqre/community_api_notebooks",
"path": "community/api.py",
"copies": "1",
"size": "6518",
"license": "mit",
"hash": -811355343041001100,
"line_mean": 27.8407079646,
"line_max": 79,
"alpha_frac": 0.5599877263,
"autogenerated": false,
"ratio": 3.623123957754308,
"config_test":... |
"""API interface."""
from http import HTTPStatus
import logging
import requests
from flask_forecaster.tracker.models import ProjectSnapshot
logger = logging.getLogger(__name__)
class Tracker(object):
"""Represents the API and exposes appropriate methods."""
BASE_URL = 'https://www.pivotaltracker.com/serv... | {
"repo_name": "textbook/flask-forecaster",
"path": "flask_forecaster/tracker/api.py",
"copies": "1",
"size": "3461",
"license": "isc",
"hash": -6131895690925394000,
"line_mean": 28.5811965812,
"line_max": 80,
"alpha_frac": 0.5827795435,
"autogenerated": false,
"ratio": 4.420178799489144,
"confi... |
# api_internal_cache/models.py
# Brought to you by We Vote. Be good.
# -*- coding: UTF-8 -*-
from django.db import models
from django.utils.timezone import now
from django.db.models import Q
from datetime import timedelta
import json
from wevote_functions.functions import positive_value_exists
class ApiInternalCache... | {
"repo_name": "wevote/WeVoteServer",
"path": "api_internal_cache/models.py",
"copies": "1",
"size": "15958",
"license": "mit",
"hash": -6409071588054139000,
"line_mean": 40.4493506494,
"line_max": 119,
"alpha_frac": 0.5511968918,
"autogenerated": false,
"ratio": 4.324661246612466,
"config_test"... |
#API KEY
#AIzaSyBTK9GUrd7sMxjt6EUlHyN9TXPkqb6R0VA
########################
## IMPORT ##
########################
from flask import Flask, jsonify, render_template, request, url_for
from flask_jsglue import JSGlue
import time, os, requests, sqlite3, sys, re
from math import radians, cos, sin, asin, sqrt
fr... | {
"repo_name": "sabidhasan/VATSee",
"path": "application.py",
"copies": "1",
"size": "38439",
"license": "mit",
"hash": 4196643161280457000,
"line_mean": 43.4895833333,
"line_max": 216,
"alpha_frac": 0.5856031635,
"autogenerated": false,
"ratio": 3.5113729788983283,
"config_test": false,
"has_... |
api_key = ""
headers = {}
prev_response = {}
_base = 'http://api.football-data.org'
endpoints = {
'fixture': _base + '/v1/fixtures/{}',
'all_fixtures': _base + '/v1/fixtures/',
'competition': _base + '/v1/competitions/{}',
'all_competitions': _base + '/v1/competitions/',
'comp_teams': _base + '/v1/... | {
"repo_name": "xozzo/pyfootball",
"path": "pyfootball/globals.py",
"copies": "1",
"size": "1116",
"license": "mit",
"hash": 8902392602932061000,
"line_mean": 33.875,
"line_max": 72,
"alpha_frac": 0.6155913978,
"autogenerated": false,
"ratio": 3.455108359133127,
"config_test": false,
"has_no_k... |
APIKEY = '' # Set Google Vision API KEY
OUTPUT_VIDEO = '.avi' # Output as AVI file
INPUT_VIDEO = '' # Input video (mov, avi, mp4, etc)
##
# Process video
##
import cv2
import io
import os
import requests
import base64
import json
import sys
# Function to make output text more readable
def makeLikelyTex... | {
"repo_name": "tzmartin/google-vision",
"path": "sentiment.py",
"copies": "1",
"size": "9307",
"license": "mit",
"hash": -2190967862008114700,
"line_mean": 47.2227979275,
"line_max": 248,
"alpha_frac": 0.5193940045,
"autogenerated": false,
"ratio": 3.941973739940703,
"config_test": false,
"ha... |
#--- API LICENSE CONFIGURATION -----------------------------------------------------------------------
# Default license keys used by pattern.web.SearchEngine to contact different API's.
# Google and Yahoo are paid services for which you need a personal license + payment method.
# The default Google license is for test... | {
"repo_name": "decebel/dataAtom_alpha",
"path": "bin/plug/py/external/pattern/web/api.py",
"copies": "1",
"size": "1207",
"license": "apache-2.0",
"hash": -291462509342432830,
"line_mean": 62.5263157895,
"line_max": 102,
"alpha_frac": 0.6818558409,
"autogenerated": false,
"ratio": 2.8004640371229... |
#--- API LICENSE CONFIGURATION -------------------------------------------
# Default license keys used by pattern.web.SearchEngine to contact different API's.
# Google and Yahoo are paid services for which you need a personal license + payment method.
# The default Google license is for testing purposes (= 100 daily qu... | {
"repo_name": "hayd/pattern",
"path": "pattern/web/api.py",
"copies": "3",
"size": "1187",
"license": "bsd-3-clause",
"hash": 1263896320851274500,
"line_mean": 31.0810810811,
"line_max": 92,
"alpha_frac": 0.700084246,
"autogenerated": false,
"ratio": 2.5637149028077753,
"config_test": false,
... |
# API-like access to St Andrews MMS.
# Useful for things like grade scrapers and so on.
# I realised my old code was dated, unpythonic, and according to Lenary "horrible",
# so it was probably best to start again.
# Also, interesting to get my head out of functional-land every once in a while :)
from bs4 import Beautif... | {
"repo_name": "SimonJF/mmslib",
"path": "src/mmslib.py",
"copies": "1",
"size": "17093",
"license": "bsd-2-clause",
"hash": -5808651350153146000,
"line_mean": 36.3209606987,
"line_max": 88,
"alpha_frac": 0.5962674779,
"autogenerated": false,
"ratio": 3.6539119281744337,
"config_test": false,
... |
# API location info
API_SERVER = 'http://services.phila.gov/'
API_BASE = 'PhillyApi/Data/v0.7/Service.svc/'
# Default parameters applied to queries
# The API wants the parameters to start with
# a '$'. This library accepts them without the
# '$' (to make things simpler), then adds the
# '$' when creating the query str... | {
"repo_name": "AxisPhilly/py-li",
"path": "li/settings.py",
"copies": "1",
"size": "1288",
"license": "mit",
"hash": 8608375845709719000,
"line_mean": 25.2857142857,
"line_max": 79,
"alpha_frac": 0.6708074534,
"autogenerated": false,
"ratio": 3.5095367847411443,
"config_test": false,
"has_no_... |
"""API management class and base class for the different end points."""
import logging
from pprint import pformat
from typing import (
Any,
Callable,
ItemsView,
Iterator,
KeysView,
List,
Optional,
ValuesView,
)
import attr
LOGGER = logging.getLogger(__name__)
CONTEXT = "Axis library"... | {
"repo_name": "Kane610/axis",
"path": "axis/api.py",
"copies": "1",
"size": "3831",
"license": "mit",
"hash": 319395384258110800,
"line_mean": 25.0612244898,
"line_max": 77,
"alpha_frac": 0.5632993996,
"autogenerated": false,
"ratio": 3.994786235662148,
"config_test": false,
"has_no_keywords"... |
""" API manager implementation.
Responsible for routing and resource registration.
.. code-block:: python
# resources.py
from jsonapi.api import API
from jsonapi.resource import Resource
api = API()
@api.register
class AuthorResource(Resource):
class Meta:
model = 'testa... | {
"repo_name": "pavlov99/jsonapi",
"path": "jsonapi/api.py",
"copies": "1",
"size": "9893",
"license": "mit",
"hash": -6584571974677727000,
"line_mean": 30.7083333333,
"line_max": 79,
"alpha_frac": 0.5708076418,
"autogenerated": false,
"ratio": 4.450292397660819,
"config_test": false,
"has_no_... |
"""apimocker URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-b... | {
"repo_name": "paveu/api_mocker",
"path": "apimocker/urls.py",
"copies": "1",
"size": "1112",
"license": "mit",
"hash": 4009398518024500700,
"line_mean": 43.48,
"line_max": 99,
"alpha_frac": 0.7059352518,
"autogenerated": false,
"ratio": 3.411042944785276,
"config_test": false,
"has_no_keywor... |
# api/models/user.py
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from itsdangerous import BadSignature, SignatureExpired
from sqlalchemy import or_, and_, desc, asc
from datetime import datetime
from ..core.setup import db, config
from .tag import Tag
from .mark import Mark
from .apikey impo... | {
"repo_name": "plastboks/Flaskmarks-API",
"path": "api/models/user.py",
"copies": "1",
"size": "6614",
"license": "mit",
"hash": -760498909283658500,
"line_mean": 29.9065420561,
"line_max": 80,
"alpha_frac": 0.5621409132,
"autogenerated": false,
"ratio": 3.766514806378132,
"config_test": false,... |
"""api module.
This module contains the entities needed to work with Telegram Bot API.
"""
import re
import sys
import json
from io import BytesIO
from functools import wraps
import requests
from twisted.internet import reactor, threads, task, _sslverify
from twisted.internet.error import ConnectionDone
from twist... | {
"repo_name": "artcom-net/pytgram",
"path": "pytgram/api.py",
"copies": "1",
"size": "64747",
"license": "mit",
"hash": -3873275472338315300,
"line_mean": 41.9263925729,
"line_max": 79,
"alpha_frac": 0.6205181283,
"autogenerated": false,
"ratio": 4.545537532476652,
"config_test": false,
"has_... |
"""APi-mongo.
Infracoders meetup example
"""
from flask import Flask, request
from flask.ext.pymongo import PyMongo
from bson.json_util import dumps
from bson.objectid import ObjectId
import os
app = Flask(__name__)
# connect to another MongoDB server altogether
app.config['MONGO_HOST'] = os.getenv('MONGO_HOST')
a... | {
"repo_name": "ipedrazas/infracoders-meetup",
"path": "api-mongo/api-mongo.py",
"copies": "1",
"size": "1718",
"license": "mit",
"hash": -7909922486783555000,
"line_mean": 22.2162162162,
"line_max": 70,
"alpha_frac": 0.6327124563,
"autogenerated": false,
"ratio": 3.2172284644194757,
"config_tes... |
# API
from csp.impl.buffers import FixedBuffer, DroppingBuffer, SlidingBuffer
from csp.impl.channels import ManyToManyChannel as Channel, CLOSED
from csp.impl.channels import put_then_callback, take_then_callback
from csp.impl.process import put, take, sleep, alts, stop
from csp.impl.timers import timeout
from csp.impl... | {
"repo_name": "ubolonton/twisted-csp",
"path": "csp/__init__.py",
"copies": "1",
"size": "1848",
"license": "epl-1.0",
"hash": -1197618474047451600,
"line_mean": 26.1764705882,
"line_max": 73,
"alpha_frac": 0.66504329,
"autogenerated": false,
"ratio": 3.681274900398406,
"config_test": false,
... |
# API:
# getSettingsManager()
# SettingsManager.setValue(name, value)
# SettingsManager.getValue(name)
# SettingsManager.registerListener(callbackFunction)
# FIXME:
# 1. Use dictionary or hash table instead of list
# DONE 2. Get rid of pyinotify?
import os
settingsManager = None
class SettingsManager:
def __init__... | {
"repo_name": "fredmorcos/attic",
"path": "projects/opengrafik/opengrafik_20090719_python_gtk/SettingsManager.py",
"copies": "1",
"size": "1800",
"license": "isc",
"hash": -3519997813803878000,
"line_mean": 18.7802197802,
"line_max": 52,
"alpha_frac": 0.6627777778,
"autogenerated": false,
"ratio"... |
import csv, json
import sqlite3
import os
# Functions
def clean_units(units_text):
if units_text == 'incidents per year' or units_text.lower() == 'count' or units_text == 'persons per square km':
return 'count'
if '%' in units_text or units_text == 'percentage' or 'per 100' in units_text:
return '%'
if '$' in ... | {
"repo_name": "xyfeng/ocha-subnational",
"path": "ALL/unify.py",
"copies": "1",
"size": "3044",
"license": "mit",
"hash": 5727683421614516000,
"line_mean": 25.2413793103,
"line_max": 159,
"alpha_frac": 0.664586071,
"autogenerated": false,
"ratio": 2.767272727272727,
"config_test": false,
"has... |
import csv, json, operator
Scheme = {
".POP.": "Population",
".ECO.": "Economic",
".HTH.": "Health",
".FOS.": "Food Security",
".NUT.": "Nutrition",
".EDU.": "Education",
".PRO.": "Protection",
".HLP.": "Housing, Land and Property",
".MIN.": "Mine Action",
".CDT.": "Coordination",
".WSH.": "Water, Sanitati... | {
"repo_name": "xyfeng/ocha-subnational",
"path": "ALL/create_topic.py",
"copies": "1",
"size": "1449",
"license": "mit",
"hash": 2758767299692768000,
"line_mean": 20,
"line_max": 59,
"alpha_frac": 0.5990338164,
"autogenerated": false,
"ratio": 2.5691489361702127,
"config_test": false,
"has_no... |
"""API
This module contains functions to interact with different system entities
"""
import os
from base64 import b64decode, b64encode
from hashlib import sha256
from librekpi.model import *
def get_salt(self):
"""Generates a cryptographically random salt and sets its Base64 encoded
version to the salt col... | {
"repo_name": "LibreKPI/librekpi",
"path": "src/librekpi/api.py",
"copies": "1",
"size": "3493",
"license": "mit",
"hash": 4915429001104848000,
"line_mean": 23.95,
"line_max": 79,
"alpha_frac": 0.6097910106,
"autogenerated": false,
"ratio": 4.296432964329643,
"config_test": false,
"has_no_key... |
"""API
This module contains functions to interact with different system entities
"""
import os
from base64 import b64decode, b64encode
from hashlib import sha256
from scheduler.model import *
def get_salt(self):
"""Generates a cryptographically random salt and sets its Base64 encoded
version to the salt co... | {
"repo_name": "kyiv-team-hacktbilisi/web-app",
"path": "src/scheduler/api.py",
"copies": "1",
"size": "3493",
"license": "mit",
"hash": 2298353069493485300,
"line_mean": 23.95,
"line_max": 79,
"alpha_frac": 0.6100772975,
"autogenerated": false,
"ratio": 4.3176761433868975,
"config_test": false,... |
import csv, json
import sqlite3
import os
# Create the database
connection = sqlite3.connect('wfp_data.sqlite')
connection.text_factory = str
cursor = connection.cursor()
# Create the table
cursor.execute('DROP TABLE IF EXISTS wfp')
cursor.execute('CREATE TABLE wfp ( indicator_name text, region_name text, admin1_nam... | {
"repo_name": "xyfeng/ocha-subnational",
"path": "WFP/create_db.py",
"copies": "1",
"size": "3969",
"license": "mit",
"hash": 8882535707084702000,
"line_mean": 28.4,
"line_max": 200,
"alpha_frac": 0.6409674981,
"autogenerated": false,
"ratio": 2.8451612903225807,
"config_test": false,
"has_no... |
Api = object # Base API class
Event = object # A simple event/signal system
############
# LONG FORM: Separate classes for definition & implementation allow
# putting definitions in a common python package available
# across all apps
############
# client.py
class AuthApi(Api):
user_regi... | {
"repo_name": "adamcharnock/lightbus",
"path": "lightbus_experiments/potential_api_oo.py",
"copies": "1",
"size": "2488",
"license": "apache-2.0",
"hash": -1530005384090367700,
"line_mean": 26.0434782609,
"line_max": 89,
"alpha_frac": 0.6551446945,
"autogenerated": false,
"ratio": 3.7926829268292... |
"""API package."""
from __future__ import absolute_import
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
def _empty(value):
"""Check if value is empty and need to be removed."""
return (value is None or
value is False or
value == {} or
value == [])
d... | {
"repo_name": "toenuff/treadmill",
"path": "lib/python/treadmill/api/__init__.py",
"copies": "1",
"size": "1030",
"license": "apache-2.0",
"hash": 3566220777943222000,
"line_mean": 22.9534883721,
"line_max": 79,
"alpha_frac": 0.6087378641,
"autogenerated": false,
"ratio": 4.17004048582996,
"con... |
"""API package.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
def _empty(value):
"""Check if value is empty and need to be removed."""
... | {
"repo_name": "captiosus/treadmill",
"path": "treadmill/api/__init__.py",
"copies": "1",
"size": "1134",
"license": "apache-2.0",
"hash": -7909260669956667000,
"line_mean": 22.625,
"line_max": 75,
"alpha_frac": 0.6199294533,
"autogenerated": false,
"ratio": 4.123636363636364,
"config_test": fal... |
"""API package.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six
from treadmill import authz as authz_mod
from treadmill.journal import plugin as jplugin
from treadmill import journal
def _empty(value... | {
"repo_name": "ceache/treadmill",
"path": "lib/python/treadmill/api/__init__.py",
"copies": "2",
"size": "1904",
"license": "apache-2.0",
"hash": 4243037307308888600,
"line_mean": 23.1012658228,
"line_max": 65,
"alpha_frac": 0.5850840336,
"autogenerated": false,
"ratio": 4.166301969365427,
"con... |
''' API planning for a hypothetical auto-fixturing library.
Some thoughts:
+ What about defining the interfaces somewhere as an ABC-esque metaclass
or something? That would let us define the public API somewhere
standardized.
+ What about bidirectional interface spec? As in, for test generation,
how do you make ... | {
"repo_name": "Badg/py_hypergolix",
"path": "docs/hypothetical_scratchpad.py",
"copies": "2",
"size": "3811",
"license": "unlicense",
"hash": -6264513762986390000,
"line_mean": 32.7256637168,
"line_max": 79,
"alpha_frac": 0.6775124639,
"autogenerated": false,
"ratio": 4.243875278396437,
"config... |
"""API properties.
"""
from __future__ import print_function
from __future__ import unicode_literals
from tabulate import tabulate, tabulate_formats, simple_separated_format
from platform import python_version_tuple
from common import SkipTest
try:
if python_version_tuple() >= ('3','3','0'):
from inspec... | {
"repo_name": "kyokley/tabulate",
"path": "test/test_api.py",
"copies": "1",
"size": "1802",
"license": "mit",
"hash": -2111069642404786000,
"line_mean": 30.6140350877,
"line_max": 77,
"alpha_frac": 0.6254162042,
"autogenerated": false,
"ratio": 3.9431072210065645,
"config_test": false,
"has_... |
""" ApiProperties """
#
# g_properties
#
def g_properties(group_uri):
""" """
properties = {
'add': {
'http_method': 'POST',
'owner_allowed': True,
'pagination': False,
'uri': '/v2/groups/' + group_uri,
},
'association_groups': {
... | {
"repo_name": "percipient/threatconnect-python",
"path": "threatconnect/ApiProperties.py",
"copies": "1",
"size": "26867",
"license": "apache-2.0",
"hash": -7127784903395945000,
"line_mean": 30.0242494226,
"line_max": 118,
"alpha_frac": 0.4667435888,
"autogenerated": false,
"ratio": 3.65985560550... |
"""API properties.
"""
from __future__ import print_function
from __future__ import unicode_literals
from tabulate import tabulate, tabulate_formats, simple_separated_format
from platform import python_version_tuple
from common import skip
try:
if python_version_tuple() >= ("3", "3", "0"):
... | {
"repo_name": "kawamon/hue",
"path": "desktop/core/ext-py/tabulate-0.8.9/test/test_api.py",
"copies": "2",
"size": "1825",
"license": "apache-2.0",
"hash": 5212414391985718000,
"line_mean": 28.4166666667,
"line_max": 77,
"alpha_frac": 0.6131506849,
"autogenerated": false,
"ratio": 3.8179916317991... |
""" api.py: Contains all API-paths. """
#TODO: Make API client-agnostic
from flaskpost import app, login_manager, db
from flaskpost.model import Blogpost, Metadata, User
from flaskpost.additional import ssl_required, ConfigSingleton
from flask import request, redirect
from flask_login import login_required, login_user... | {
"repo_name": "oscarnyl/flaskpost",
"path": "flaskpost/api.py",
"copies": "1",
"size": "2760",
"license": "mit",
"hash": 6504305291468561000,
"line_mean": 30.3636363636,
"line_max": 107,
"alpha_frac": 0.6873188406,
"autogenerated": false,
"ratio": 3.6702127659574466,
"config_test": true,
"has... |
"""api.py: Implemente rfc5766-turn-server HTTP server """
from django.http import HttpResponse
from django.utils import simplejson
import time
import hmac
from hashlib import sha1 as hash_alg
import base64
from turnapi import settings
import redis
import logging
# REST API or dynamic Long term credentials
if set... | {
"repo_name": "pmarques/django-turnapi",
"path": "turnapi/api.py",
"copies": "1",
"size": "2611",
"license": "mit",
"hash": -2059403035577988600,
"line_mean": 25.11,
"line_max": 93,
"alpha_frac": 0.690157028,
"autogenerated": false,
"ratio": 3.3821243523316062,
"config_test": false,
"has_no_k... |
# api.py - library user interface
"""Main interface for the library user."""
from . import backend
from . import models
from . import oauth2
from . import tools
from . import urls
__all__ = ['Sheets']
# TODO: get worksheet
class Sheets(object):
"""Collection of spreadsheets available from given OAuth 2.0 cred... | {
"repo_name": "xflr6/gsheets",
"path": "gsheets/api.py",
"copies": "1",
"size": "6774",
"license": "mit",
"hash": 1476651048067758300,
"line_mean": 32.043902439,
"line_max": 85,
"alpha_frac": 0.5823737821,
"autogenerated": false,
"ratio": 4.54936198791135,
"config_test": false,
"has_no_keywor... |
# api.py
# -*- coding: utf-8 -*-
import getpass
import os
import pandas as pd
import requests
from .utils import *
gh_api = 'https://api.github.com/'
class Admin:
'''
Class for primary GitHub Classrom management functions
'''
def __init__(self, ghid = None, token_file = None, token = None,
... | {
"repo_name": "btskinner/grm",
"path": "grm/api.py",
"copies": "1",
"size": "12908",
"license": "mit",
"hash": -7293024985385688000,
"line_mean": 31.5138539043,
"line_max": 83,
"alpha_frac": 0.4973659746,
"autogenerated": false,
"ratio": 3.837098692033294,
"config_test": false,
"has_no_keywor... |
import requests
import os
import sys
import appdirs
import pkg_resources
import json
from .api_exceptions import (AudioFileError,
AudioFileFormatError)
from .utils import (abstract_http_method,
perform_voice_output,
get_audio_file_mime)
# GET /
def get... | {
"repo_name": "frnmst/kalliope-rest",
"path": "kalliope_rest/api.py",
"copies": "1",
"size": "4559",
"license": "mit",
"hash": 6882366179813051000,
"line_mean": 35.1825396825,
"line_max": 81,
"alpha_frac": 0.6317174819,
"autogenerated": false,
"ratio": 4.066904549509367,
"config_test": false,
... |
# api.py
from flask import Flask, request
from flask_restful import Resource, Api, fields, marshal_with
from flask_sqlalchemy import SQLAlchemy
from config import BaseConfig
from deepdiff import DeepDiff
import base64
app = Flask(__name__)
app.config.from_object(BaseConfig)
api = Api(app)
db = SQLAlchemy(app)
from ... | {
"repo_name": "IAPOLINARIO/python-diff",
"path": "app/api.py",
"copies": "1",
"size": "2522",
"license": "mit",
"hash": -3859035844772961000,
"line_mean": 32.64,
"line_max": 77,
"alpha_frac": 0.6149881047,
"autogenerated": false,
"ratio": 3.671033478893741,
"config_test": false,
"has_no_keywo... |
# api.py
import web
from libweasyl.models.meta import Base
from libweasyl.models.api import APIToken
from libweasyl import security
from weasyl import define as d
def is_api_user():
return 'HTTP_X_WEASYL_API_KEY' in web.ctx.env or 'HTTP_AUTHORIZATION' in web.ctx.env
def get_api_keys(userid):
with Base.dbs... | {
"repo_name": "dzamie/weasyl",
"path": "weasyl/api.py",
"copies": "1",
"size": "1454",
"license": "apache-2.0",
"hash": -3302818784132411400,
"line_mean": 26.9615384615,
"line_max": 96,
"alpha_frac": 0.6581843191,
"autogenerated": false,
"ratio": 3.3579676674364896,
"config_test": false,
"has... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.