code stringlengths 3 1.05M | repo_name stringlengths 5 104 | path stringlengths 4 251 | language stringclasses 1
value | license stringclasses 15
values | size int64 3 1.05M |
|---|---|---|---|---|---|
#!/usr/bin/python
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web
import conf
import neonsrv.interface
import neonsrv.tornadoapi
assert tornado.version_info > (2, 0, 0)
settings = {
"static_path": os.path.join(os.path.dirname(__file__), "static"),
"template_path": os.path.join(... | DDMAL/Neon.js | server.py | Python | mit | 5,133 |
def main():
n=int(raw_input())
f1=0
f2=1
print f1,f2,
for i in range(2,n):
temp=f1
f1=f2
f2=f1+temp
print f2,
main()
| kumarisneha/practice_repo | techgig/techgig_fibonacci_series.py | Python | mit | 186 |
from django_google_places.models import Place
from django_google_places.api import google_places
from django.views.generic import TemplateView
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
class PlaceView(TemplateView):
tem... | aaronsnig501/foreign-guides | apps/map/views.py | Python | mit | 1,447 |
#!/usr/bin/python3
'''
This example shows how to find if a file is in a certain folder.
'''
import sys # for stdin
for line in sys.stdin:
(file1, file2) = line.strip().split()
print(file1.startswith(file2))
| nonZero/demos-python | src/examples/short/filesystem/in_folder.py | Python | gpl-3.0 | 219 |
"""The tests for the Remote component, adapted from Light Test."""
# pylint: disable=protected-access
import unittest
from homeassistant.const import (
ATTR_ENTITY_ID, STATE_ON, STATE_OFF, CONF_PLATFORM,
SERVICE_TURN_ON, SERVICE_TURN_OFF)
import homeassistant.components.remote as remote
from tests.common imp... | jabesq/home-assistant | tests/components/remote/test_init.py | Python | apache-2.0 | 3,568 |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gamecraft.settings_heroku")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| micktwomey/gamecraft-mk-iii | manage.py | Python | mit | 259 |
# Copyright 2015 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... | paninetworks/neutron | neutron/tests/fullstack/config_fixtures.py | Python | apache-2.0 | 8,150 |
# Copyright (c) 2016 Huawei Technologies Co., Ltd.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | mahak/cinder | cinder/tests/unit/volume/drivers/huawei/test_huawei_drivers.py | Python | apache-2.0 | 221,715 |
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools.converters.mil.mil.passes.pass_registry import register_pa... | apple/coremltools | coremltools/converters/mil/mil/passes/conv_bias_fusion.py | Python | bsd-3-clause | 11,612 |
"""
Design a data structure that supports all following operations in average O(1) time.
insert(val): Inserts an item val to the set if not already present.
remove(val): Removes an item val from the set if present.
getRandom: Returns a random element from current set of elements. Each element must have the same probab... | dichen001/Go4Jobs | JackChen/Yelp/380. Insert Delete GetRandom O(1).py | Python | gpl-3.0 | 2,374 |
# tests are fairly 'live' (but safe to run)
# setup authorized_keys for logged in user such
# that the user can log in as themselves before running tests
import unittest
import getpass
import ansible.playbook
import ansible.utils as utils
import ansible.callbacks as ans_callbacks
import os
import shutil
import ansibl... | wincent/ansible | test/TestPlayBook.py | Python | gpl-3.0 | 17,261 |
"""Support for BMW car locks with BMW ConnectedDrive."""
import logging
from bimmer_connected.state import LockState
from homeassistant.components.lock import LockDevice
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
from . import DOMAIN as BMW_DOMAIN
_LOGGER = logging.getLogger(__name__)
def setup_... | leppa/home-assistant | homeassistant/components/bmw_connected_drive/lock.py | Python | apache-2.0 | 3,633 |
"""Nose Plugin that supports IPython doctests.
Limitations:
- When generating examples for use as doctests, make sure that you have
pretty-printing OFF. This can be done either by setting the
``PlainTextFormatter.pprint`` option in your configuration file to False, or
by interactively disabling it with %Ppri... | mattvonrocketstein/smash | smashlib/ipy3x/testing/plugin/ipdoctest.py | Python | mit | 31,398 |
# -*- coding: utf-8 -*-
"""
test_tv.py
~~~~~~~~~~
This test suite checks the methods of the Test class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_... | celiao/tmdbsimple | tests/test_tv.py | Python | gpl-3.0 | 10,859 |
from setuptools import setup, find_packages
try:
from EMpy import __version__
except ImportError:
__version__ = None
__author__ = 'Lorenzo Bolla'
with open('README.rst', 'r') as readme:
long_description = readme.read()
setup(
name='ElectroMagneticPython',
version=__version__,
author='Lorenzo ... | DanHickstein/EMpy | setup.py | Python | mit | 1,232 |
#!/usr/bin/env python3
import setuptools
setuptools.setup(
name = "route_distances",
version = "1.10.0",
license = "MIT",
description = "Classes for getting the distance of a route between two"
"places using various different services",
packages = ["route_distances"],
install... | ercas/route_distances | setup.py | Python | mit | 372 |
import libcontext
from libcontext.socketclasses import *
from libcontext.pluginclasses import *
from ..drone import drone
from .pinworker import pinworker
from .. import hivesubclass, hiveinstance, _hivesubclass
class create(drone):
def __call__(self, w, contextname):
if not hiveinstance(w, pinworker):
... | agoose77/hivesystem | bee/pin/create.py | Python | bsd-2-clause | 831 |
# Copyright (c) 2006-2007 Open Source Applications Foundation
# Copyright (c) 2008 Mikeal Rogers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lice... | Montecito/wsgi-xmlrpc | setup.py | Python | apache-2.0 | 1,619 |
"""
Django settings for playterminal project.
Generated by 'django-admin startproject' using Django 1.8.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build... | rev112/playterminal | playterminal/settings/base.py | Python | apache-2.0 | 3,453 |
# Lint as: python2, python3
# pylint: disable=g-direct-third-party-import
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:... | dslomov/bazel | tools/android/aar_resources_extractor.py | Python | apache-2.0 | 5,525 |
import pandas
import matplotlib.pyplot as plt
import numpy as np
import os
import random
import pickle
import datetime
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
from sklearn.decomposition import TruncatedSVD
import collections
def get_med(fpath2='./data/mimic/PRESCRIPTIONS.csv'):
... | thaihungle/deepexp | ntm-mann/mimic_prepare_seq.py | Python | mit | 38,598 |
"""
Computes PRMS field mapping probabilities.
@author: Faegheh Hasibi (faegheh.hasibi@idi.ntnu.no)
"""
from __future__ import division
from pprint import PrettyPrinter
from nordlys.retrieval.scorer import ScorerPRMS
from nordlys.elr.top_fields import TopFields
class FieldMapping(object):
DEBUG = 0
MAPPING... | hasibi/EntityLinkingRetrieval-ELR | nordlys/elr/field_mapping.py | Python | mit | 4,151 |
# ===============================================================================
# Copyright 2013 Jake Ross
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses... | UManPychron/pychron | pychron/canvas/tasks/designer.py | Python | apache-2.0 | 4,697 |
# +--------------------------------------------------------------------------+
# | Licensed Materials - Property of IBM |
# | |
# | (C) Copyright IBM Corporation 2008. |
... | zzzeek/ibm_db_sa_old | ibm_db_sa/__init__.py | Python | apache-2.0 | 1,948 |
#############################################################################
##
## Copyright (c) 2015 Riverbank Computing Limited <info@riverbankcomputing.com>
##
## This file is part of PyQt4.
##
## This file may be used under the terms of the GNU General Public License
## version 3.0 as published by the Free Softw... | martyngigg/pyqt-msvc | pyuic/uic/widget-plugins/phonon.py | Python | gpl-3.0 | 1,602 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
def add_legacy_name(apps, schema_editor):
ContentType = apps.get_model('contenttypes', 'ContentType')
for ct in ContentType.objects.all():
try:
ct.name = apps.get_model(ct.app_label, c... | BitWriters/Zenith_project | zango/lib/python3.5/site-packages/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py | Python | mit | 1,168 |
"""
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this ... | alexryndin/ambari | ambari-server/src/main/resources/stacks/ADH/1.0/hooks/before-ANY/scripts/shared_initialization.py | Python | apache-2.0 | 6,102 |
from django.conf.urls import url
from . import views
urlpatterns = [
]
| Cofn/cofn | cofn/apps/blog/urls.py | Python | mit | 75 |
#!/usr/bin/env python
'''Copyright (C) 2008 Citrix Systems Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This... | xenserver/xs-cim | test/pywbem-tests/BVTTest.py | Python | lgpl-2.1 | 29,420 |
from sqlalchemy import Column, Integer, String, ForeignKey
from inbox.models.backends.imap import ImapAccount
from inbox.models.backends.oauth import OAuthAccount
from inbox.log import get_logger
log = get_logger()
PROVIDER = 'gmail'
class GmailAccount(OAuthAccount, ImapAccount):
id = Column(Integer, ForeignKey... | EthanBlackburn/sync-engine | inbox/models/backends/gmail.py | Python | agpl-3.0 | 1,391 |
#!/usr/bin/python
import urllib
import httplib
import time
import datetime
id = '123456789012345'
server = 'localhost:5055'
points = [
('2017-01-01 00:00:00', 59.93211887, 30.33050537, 0.0),
('2017-01-01 00:05:00', 59.93266715, 30.33190012, 50.0),
('2017-01-01 00:10:00', 59.93329069, 30.33333778, 50.0),
... | tananaev/traccar | tools/test-trips.py | Python | apache-2.0 | 1,319 |
#! /usr/bin/env python
import random
import time
import template
TRIVIA_BOT = 'DICtrivia'
ANSWER = ':trivia answer'
NEXT = ':trivia next'
Q_A = {
'___________ is commonly referred to as politically motivated hacking.' : 'Hacktivism',
'In m-commerce, the hyped evolution of e-commerce, what does the M stand fo... | Motoma/bitgirl | scripts/trivia.py | Python | gpl-2.0 | 798 |
# Copyright 2014 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | hanlind/nova | nova/tests/unit/virt/ironic/utils.py | Python | apache-2.0 | 5,126 |
# encoding: utf8
# Norwegian bokmaål
from __future__ import unicode_literals
from ..symbols import *
from ..language_data import PRON_LEMMA
TOKENIZER_EXCEPTIONS = {
"jan.": [
{ORTH: "jan.", LEMMA: "januar"}
],
"feb.": [
{ORTH: "feb.", LEMMA: "februar"}
],
"jul.": [
... | Gregory-Howard/spaCy | spacy/nb/tokenizer_exceptions.py | Python | mit | 2,236 |
#!/usr/bin/env python
#
# Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | rbruyere/appengine-mapreduce | python/test/mapreduce gcs/pipeline/models.py | Python | apache-2.0 | 9,941 |
import sys
x = map(int,raw_input().strip().split(' '))
n=x[0]
d=x[1]
a = map(int,raw_input().strip().split(' '))
count=0
for i in xrange(n):
if a[i]+d in a and a[i]+2*d in a:
count+=1
print count
| shree-shubham/Unitype | Beautiful Triplets.py | Python | gpl-3.0 | 211 |
from pixie.vm.object import Object, affirm, WrappedException, Type, runtime_error
import pixie.vm.code as code
import pixie.vm.numbers as numbers
from pixie.vm.primitives import nil, true, false
from rpython.rlib.rarithmetic import r_uint, intmask
from rpython.rlib.jit import JitDriver, promote, elidable, elidable_prom... | heyLu/pixie | pixie/vm/interpreter.py | Python | gpl-3.0 | 11,288 |
# Copyright (c) 2005 Maxim Sobolev. All rights reserved.
# Copyright (c) 2006-2007 Sippy Software, Inc. All rights reserved.
#
# This file is part of SIPPY, a free RFC3261 SIP stack and B2BUA.
#
# SIPPY is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pub... | lemenkov/sippy | sippy/SipReplaces.py | Python | gpl-2.0 | 2,867 |
#!python
import sys
import time
import os.path
import xml.etree.ElementTree as xml
from threading import Thread
import xml.etree.ElementTree
from xml.etree.ElementTree import ElementTree, Element, SubElement, dump
from xml.etree.ElementTree import tostring
from xml.dom import minidom
sys.path.append('/opt/C3STEM/Middle... | shekharshank/c2sumo | src/C3STEM/Middleware/c3stemserver.py | Python | mit | 30,350 |
# http://rosalind.info/problems/pmch/
from math import factorial
def nbPerfectMatchings(rna):
return factorial(rna.count("A")) * factorial(rna.count("C"))
f = open("rosalind_pmch.txt", "r")
dnas = {}
currentKey = ''
for content in f:
# Beginning of a new sample
if '>' in content:
key = content.rs... | AntoineAugusti/katas | rosalind/pmch.py | Python | mit | 498 |
###############################################################################
# #
# HMMModelParser.py #
# #
... | minillinim/SimpleHMMER | simplehmmer/hmmmodelparser.py | Python | gpl-3.0 | 10,020 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='GRAuthor',
fields=[
... | solvire/ordo_electro | ordo_electro/social/migrations/0001_initial.py | Python | bsd-3-clause | 7,667 |
from yarg.config.location_factory import LocationFactory
from yarg.config.profile_factory import ProfileFactory
from yarg.config.loader import ConfigLoader
from yarg.config.saver import ConfigSaver
| ihrwein/yarg | yarg/config/__init__.py | Python | gpl-2.0 | 199 |
from datetime import date
import boundaries
boundaries.register('Districts',
last_updated=date(2000, 1, 1),
name_func=boundaries.attr('id'),
file='../../fixtures/foo.shp',
)
| opencorato/represent-boundaries | boundaries/tests/definitions/no_features/definition.py | Python | mit | 182 |
'''Doc build constants'''
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
DOCKER_SOCKET = getattr(settings, 'DOCKER_SOCKET', 'unix:///var/run/docker.sock')
DOCKER_VERSION = getattr(settings, 'DOCKER_VERSION', 'auto')
DOCKER_IMAGE = getattr(settings, 'DOCKER_IMAGE', 'rtfd-buil... | titiushko/readthedocs.org | readthedocs/doc_builder/constants.py | Python | mit | 491 |
import re
from django.core.validators import URLValidator
class CustomURLValidator(URLValidator):
regex = re.compile(
r'^[A-Z0-9]*://' # some_string://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
r'localhost|' #localhost...
r'\d... | mliu7/django-oauth2app | oauth2app/validators.py | Python | mit | 500 |
__version__ = '0.3.0'
class SchemaError(Exception):
"""Error during Schema validation."""
def __init__(self, autos, errors):
self.autos = autos if type(autos) is list else [autos]
self.errors = errors if type(errors) is list else [errors]
Exception.__init__(self, self.code)
@pro... | rsjohnco/rez | src/rez/vendor/schema/schema.py | Python | gpl-3.0 | 9,591 |
# This file is a part of MediaDrop (http://www.mediadrop.net),
# Copyright 2009-2014 MediaDrop contributors
# For the exact contribution history, see the git revision log.
# The source code contained in this file is licensed under the GPLv3 or
# (at your option) any later version.
# See LICENSE.txt in the main project ... | timohtey/mediadrop_copy | mediadrop/migrations/versions/008-4c9f4cfc6085-drop_sqlalchemy_migrate_table.py | Python | gpl-3.0 | 1,459 |
import random
import time
from django.test import TestCase
from example_app.testing_app.models import TestModel, ForeignTestModel
class StaleFieldsMixinTestCase(TestCase):
def test_nothing_changing(self):
tm = TestModel()
tm.boolean = False
tm.characters = 'testing'
tm.save()
... | zapier/django-stalefields | example_app/testing_app/tests.py | Python | bsd-3-clause | 4,250 |
# Copyright (c) 2013 Red Hat, Inc.
# Author: William Benton (willb@redhat.com)
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | willb/wallaroo | clients/python-wallaroo/wallaroo/client/constants.py | Python | apache-2.0 | 759 |
import os
import shutil
import argparse
import zipfile
import hermesclient
__author__ = 'bitpick'
def main():
TMP_DIRNAME = "/tmp/hermes/"
parser = argparse.ArgumentParser()
parser.add_argument("zip_file", help="the path to the zip file")
parser.add_argument("zip_pwd", help="Password for ZIP file")
... | internet-sicherheit/HermesClients | hermes_zip_upload.py | Python | lgpl-3.0 | 1,213 |
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | rednaxelafx/apache-spark | python/pyspark/sql/tests/test_arrow.py | Python | apache-2.0 | 23,411 |
from __future__ import (absolute_import, division, print_function)
from ranger.api.commands import Command
def select_file_by_command(self, command):
import subprocess
import os.path
comm = self.fm.execute_command(command, universal_newlines=True, stdout=subprocess.PIPE)
stdout, _stderr = comm.communic... | SicariusNoctis/dotfiles | ranger/.config/ranger/commands.py | Python | mit | 1,601 |
# -*- coding: utf-8 -*-
import pytest
from cfme import test_requirements
from cfme.utils.appliance.implementations.ui import navigate_to
pytestmark = [test_requirements.configuration]
@pytest.fixture(scope="module")
def configured_external_appliance(temp_appliance_preconfig, app_creds_modscope,
... | apagac/cfme_tests | cfme/tests/configure/test_remote_server_tabs.py | Python | gpl-2.0 | 1,865 |
if __name__ == '__main__':
A = int(input())
B = int(input())
print(A // B)
print(A / B)
| FireClaw/HackerRank | Python/python-division.py | Python | mit | 105 |
from Constants import constants as const
import math
deimos_m = 1.48e15 # kg
deimos_r = 6.2 * 1000 # km - m
deimos_g = const.g_const * deimos_m / deimos_r**2
print(deimos_g)
earth_g = const.g_const * const.earth_r / const.earth_r**2
deimos_depth = (const.g_const * deimos_m) / (earth_g * deimos_r)
print("Problem... | capravictoriae/Space-Mission-Design-and-Operations-EE585x-MOOC-Python- | Unit2/P2.2.5.py | Python | apache-2.0 | 949 |
import socket
from attack import Attack
from vulnerability import Vulnerability
from vulnerabilitiesdescriptions import VulnerabilitiesDescriptions as VulDescrip
from net.httplib2 import HTTPTimeout
# Wapiti SVN - A web application vulnerability scanner
# Wapiti Project (http://wapiti.sourceforge.net)
# Copyright (C) ... | teknolab/teknolab-wapiti | wapiti/attack/mod_file.py | Python | gpl-2.0 | 10,346 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
from collections import namedtuple
class Graph(object):
Edge = namedtuple('Edge', 'vertex, edge')
def __init__(self, vertices):
self.vertices = [[] for _ in range(vertices)]
self.edges = 0
def add_edge(self, first, second):
sel... | goldsborough/algs4 | graphs/python/graph.py | Python | mit | 745 |
from votai_utils.celery import app
from preguntales.models import Message
# import the logging library
import logging
# Get an instance of a logger
logger = logging.getLogger(__name__)
@app.task
def send_mails():
logger.info('Sending mails to the candidates')
Message.send_mails()
| ciudadanointeligente/votainteligente-portal-electoral | preguntales/tasks.py | Python | gpl-3.0 | 293 |
class Solution(object):
def findTargetSumWays(self, nums, S):
"""
:type nums: List[int]
:type S: int
:rtype: int
"""
res = 0
ma = sum(nums)
tmp = [0] * (2 * ma + 1)
cnt = tmp[:]
cnt[ma] = 1
for num in nums:
for i in ... | Chasego/codi | leetcode/494-Target-Sum/TargetSum.py | Python | mit | 588 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2013 Brocade Communications System, Inc.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# ... | vbannai/neutron | neutron/plugins/brocade/NeutronPlugin.py | Python | apache-2.0 | 20,927 |
# -*- coding: utf-8
import sys
import os
import pickle
import shutil
import commands
class PgInstance(object):
def __init__(self, path, clean_on_delete=False):
self.config = {
'path':os.path.abspath(path),
'port':None
}
self.clean_on_delete = clean_on_delete
try:
self.load_conf()
except IOError,e:... | habalux/pg_testenv | pgtestenv/instance.py | Python | bsd-2-clause | 4,464 |
import logging
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from .models import (IP, URI, Base, ContentType, Method, ReqRespInfo, Status,
UserAgent, get_or_create)
logger = logging.getLogger(__name__)
REQ_RESP_FORMAT = """
-----
REQUE... | dmuhs/falcon-stats | falconstats/middleware.py | Python | mit | 2,912 |
from datetime import datetime, timedelta
import json
import urllib
import urlparse
from couchdbkit.ext.django.schema import *
from couchdbkit.exceptions import ResourceNotFound
from django.core.cache import cache
import socket
import hashlib
from casexml.apps.case.models import CommCareCase
from casexml.apps.case.xml... | SEL-Columbia/commcare-hq | corehq/apps/receiverwrapper/models.py | Python | bsd-3-clause | 10,413 |
from PIL import Image, ImageDraw
import face_recognition
# Load the jpg file into a numpy array
image = face_recognition.load_image_file("biden.jpg")
# Find all facial features in all the faces in the image
face_landmarks_list = face_recognition.face_landmarks(image)
pil_image = Image.fromarray(image)
for face_landm... | ageitgey/face_recognition | examples/digital_makeup.py | Python | mit | 1,439 |
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# pylit.py
# ********
# Literate programming with reStructuredText
# ++++++++++++++++++++++++++++++++++++++++++
#
# :Date: $Date$
# :Revision: $Revision$
# :URL: $URL$
# :Copyright: © 2005, 2007 Günter Milde.
# Released without warranty under t... | live-clones/dolfin-adjoint | docs/bin/pylit.py | Python | lgpl-3.0 | 60,822 |
# Copyright (C) 2008-2010 Adam Olsen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that... | exaile/exaile | xlgui/widgets/smart_playlist_editor.py | Python | gpl-2.0 | 14,481 |
# -*- coding: utf-8 -*-
#########################################################################
#
# Copyright (C) 2012 OpenPlans
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either versio... | ROGUE-JCTD/geonode | geonode/layers/utils.py | Python | gpl-3.0 | 23,918 |
from annotation_based_analysis import AnnotationBasedAnalysis
from nativedroid_analysis import *
from resolver import *
from resolver.model import *
from source_and_sink_manager import SourceAndSinkManager
| arguslab/Argus-SAF | nativedroid/nativedroid/analyses/__init__.py | Python | apache-2.0 | 206 |
# polling_location/models.py
# Brought to you by We Vote. Be good.
# -*- coding: UTF-8 -*-
from config.base import get_environment_variable
from django.db import models
from django.db.models import Q
from exception.models import handle_record_found_more_than_one_exception
from geopy.geocoders import get_geocoder_for_s... | jainanisha90/WeVoteServer | polling_location/models.py | Python | mit | 24,858 |
#! python
# -*- coding: utf-8 -*-
# (c) 2006 Juergen Riegel
import template
import generateBase.generateModel_Module
import generateBase.generateTools
class TemplateCPPFile (template.ModelTemplate):
def Generate(self):
generateBase.generateTools.ensureDir(self.path)
print ("Generate() App Dir")
... | sanguinariojoe/FreeCAD | src/Tools/generateTemplates/templateCPPFile.py | Python | lgpl-2.1 | 2,013 |
#!/usr/bin/env python
from setuptools import setup, find_packages
import uc
setup(
name='django-uc',
version=".".join(map(str, uc.__version__)),
author='Rebecca Meritz',
author_email='rebecca@fundedbyme.com',
url='http://github.com/FundedByMe/django-uc',
install_requires=[
'Django>=1.4... | FundedByMe/django-uc | setup.py | Python | mit | 703 |
# This file is part of Scapy
# Scapy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# any later version.
#
# Scapy is distributed in the hope that it will be useful,
# but ... | gpotter2/scapy | scapy/contrib/igmp.py | Python | gpl-2.0 | 6,780 |
from . import settings, utils
class Config:
"""
The global config wrapper that handles the backend.
"""
def __init__(self):
super().__setattr__('_backend',
utils.import_module_attr(settings.BACKEND)())
def __getattr__(self, key):
try:
if not len(settings.CO... | jazzband/django-constance | constance/base.py | Python | bsd-3-clause | 894 |
import pymysql.cursors
from fixture.group import Group
from fixture.contact import Contact
class DBfixture():
def __init__(self, host, name, user, password):
self.host = host
self.name = name
self.user = user
self.password = password
self.connection = pymysql.connect(host=h... | OlgaKuratkina/python_training_qa | fixture/db.py | Python | apache-2.0 | 1,742 |
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
# Copyright (c) 2019 Nicolas Iooss
#
# 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
... | fishilico/shared | java/keystore/parse_jceks.py | Python | mit | 31,089 |
# Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Helpful routines for regression testing
#
# Add python-bitcoinrpc to module search path:
import os
import sys
sys.path.append(os.... | bankonme/MUE-Src | qa/rpc-tests/util.py | Python | mit | 12,460 |
# -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | ViaSat/luigi | test/rpc_test.py | Python | apache-2.0 | 2,185 |
class Point(object):
def __init__(self, x, y):
self.x = float(x)
self.y = float(y)
def __repr__(self):
return '({}, {})'.format(self.x, self.y)
def __eq__(self, other):
"""Override the default Equals behavior"""
if isinstance(other, self.__class__):
retur... | ivand58/points-in-rectange | models/poc.py | Python | bsd-2-clause | 6,193 |
"""
Handles setting up the server.
"""
import asyncio
import discord
from discord.ext import commands
from discord.ext.commands import Context
from dbansbot import consts
from dbansbot.bot import DBans
class Setup:
def __init__(self, bot: DBans):
self.bot = bot
# The bulk of the setup is in this co... | DiscordBans/Bot | dbansbot/cogs/setup.py | Python | mit | 8,307 |
"""
Question:
Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.
For example:
Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it.
Follow up:
Could you do it without any loop/recursion ... | mvj3/leetcode | 258-add-digits.py | Python | mit | 1,291 |
# Copyright 2021 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | matrix-org/synapse | synapse/handlers/federation_event.py | Python | apache-2.0 | 78,447 |
"""
.. inheritance-diagram:: pyopus.optimizer.base
:parts: 1
**Base classes for optimization algorithms and plugins
(PyOPUS subsystem name: OPT)**
Every optimization algorthm should be used in the following way.
1. Create the optimizer object.
2. Call the :meth:`reset` method of the object to set th... | blorgon9000/pyopus | pyopus/optimizer/base.py | Python | gpl-3.0 | 40,764 |
from __future__ import annotations
import asyncio
from typing import TYPE_CHECKING
from sanic.exceptions import SanicException
from sanic.log import deprecation
if TYPE_CHECKING:
from sanic import Sanic
class AsyncioServer:
"""
Wraps an asyncio server with functionality that might be useful to
a ... | ashleysommer/sanic | sanic/server/async_server.py | Python | mit | 3,616 |
'''
dsift.py: this function implements some basic functions that
does dense sift feature extraction.
The descriptors are defined in a similar way to the one used in
Svetlana Lazebnik's Matlab implementation, which could be found
at:
http://www.cs.unc.edu/~lazebnik/
Yangqing Jia, jiayq@eecs.berkeley.edu
'''
import num... | NicoRahm/CGvsPhoto | Textures/dsift.py | Python | mit | 7,772 |
import pp
from pp.components.grating_coupler.elliptical_trenches import grating_coupler_te
from pp.components.grating_coupler.elliptical_trenches import grating_coupler_tm
from pp.routing.get_input_labels import get_input_labels
from pp.container import container
@container
def add_grating_couplers(
component,
... | psiq/gdsfactory | pp/add_grating_couplers.py | Python | mit | 1,735 |
import random
import luigi
import luigi.format
import luigi.hdfs
from luigi.contrib.spark import SparkJob
class UserItemMatrix(luigi.Task):
# Make a sample data set of user, item, rating
data_size = luigi.IntParameter()
def run(self):
w = open(self.output(), 'w')
for user in xrange(self.... | Mappy/luigi | examples/spark_als.py | Python | apache-2.0 | 2,342 |
#!/usr/bin/env python
#
# This library is free software, distributed under the terms of
# the GNU Lesser General Public License Version 3, or any later version.
# See the COPYING file included in this archive
#
# The docstrings in this module contain epytext markup; API documentation
# may be created by processing this... | tjgillies/distributed-draw | entangled/kademlia/constants.py | Python | lgpl-3.0 | 1,820 |
###############################################################################
##
## Copyright (C) 2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http:/... | dbergan/AutobahnPython | examples/twisted/wamp/basic/pubsub/decorators/backend.py | Python | apache-2.0 | 1,478 |
# Copyright (c) 2013 Tom McLoughlin
import socket
# Configuration
myNick = "Bot"
myIdent = "Bot"
myReal = "Bot"
myIRC = "irc.kottnet.net"
myPort = 6667
myChan = "#TomM"
# Do not edit below this line
sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
sock.connect((myIRC, myPort))
sock.send('NICK ' + myNick... | TommehM/pybot | main.py | Python | mit | 695 |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def levelOrderBottom(self, root):
list = []
self.helper(list, root, 0)
return list[::-1]
d... | Jspsun/LEETCodePractice | Python/BinaryTreeLevelOrderTraversal2.py | Python | mit | 687 |
# Copyright 2016 United States Government as represented by the Administrator
# of the National Aeronautics and Space Administration. All Rights Reserved.
#
# Portion of this code is Copyright Geoscience Australia, Licensed under the
# Apache License, Version 2.0 (the "License"); you may not use this file
# except in c... | ceos-seo/Data_Cube_v2 | ui/django_site_v2/data_cube_ui/data_cube_ui/celery.py | Python | apache-2.0 | 1,576 |
# reasonably efficient
def create_panels_append(cls, panels):
""" return an append list of panels """
panels = [a for a in panels if a is not None]
# corner cases
if len(panels) == 0:
return None
elif len(panels) == 1:
return panels[0]
el... | linebp/pandas | bench/bench_join_panel.py | Python | bsd-3-clause | 3,788 |
from math import *
import thread
import random
import time
import pygtk
pygtk.require("2.0")
import gtk
import gtk.glade
import commands
import matplotlib.pyplot
class rodent:
def __init__(self):
self.time_from_last_childbirth=0
class felix:
def __init__(self):
self.si... | debsankha/bedtime-programming | ls222/new.py | Python | gpl-3.0 | 2,650 |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "osmapp.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| sirmmo/OsmApp | manage.py | Python | gpl-2.0 | 249 |
# Under MIT License, see LICENSE.txt
import logging
from multiprocessing import Queue
from queue import Empty
from typing import List, Dict
from Debug.debug_command_factory import DebugCommandFactory
from Util import Pose, Position, AICommand, EngineCommand, Path
from Util.role import Role
from ai.Algorithm.auto_pla... | RoboCupULaval/StrategyIA | ai/executors/play_executor.py | Python | mit | 5,839 |
# -*- encoding: utf-8 -*-
import sys
from .conf import settings
from .exceptions import NoRuleMatched
from .system import get_key
from . import logs, const
def read_actions():
"""Yields actions for pressed keys."""
while True:
key = get_key()
if key in (const.KEY_UP, 'k'):
yield ... | PLNech/thefuck | thefuck/ui.py | Python | mit | 2,570 |
from pymodbus.exceptions import ParameterException
from pymodbus.interfaces import IModbusSlaveContext
from pymodbus.datastore.store import ModbusSequentialDataBlock
from pymodbus.constants import Defaults
#---------------------------------------------------------------------------#
# Logging
#------------------------... | mjfarmer/scada_py | env/lib/python2.7/site-packages/pymodbus/datastore/context.py | Python | gpl-3.0 | 5,403 |
import json
import os
from pytest import mark
from test.integration.base import DBTIntegrationTest, use_profile
class BaseTestSimpleCopy(DBTIntegrationTest):
@property
def schema(self):
return "simple_copy_001"
@staticmethod
def dir(path):
return path.lstrip('/')
@property
d... | fishtown-analytics/dbt | test/integration/001_simple_copy_test/test_simple_copy.py | Python | apache-2.0 | 15,549 |
# Copyright (c) 2008, Aldo Cortesi. All rights reserved.
# Copyright (c) 2017 Dirk Hartmann
#
# 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... | soulchainer/qtile | libqtile/layout/base.py | Python | mit | 19,341 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.