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 |
|---|---|---|---|---|---|
import Adafruit_BBIO.ADC as ADC
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.PWM as PWM
import time
ADC.setup()
GPIO.setup("P8_7", GPIO.OUT)
GPIO.output("P8_7", GPIO.HIGH)
servo_pin = "P8_13"
duty_min = 3.5#3
duty_max = 14.5#14.5
duty_span = duty_max - duty_min
angle = 0
direction = "left"
PWM.start(se... | jordiguerrero/FresonCam | test_IR_servo.py | Python | gpl-3.0 | 1,050 |
"""
TabHighlight Demo
Make sure "Highlight \t tabs" is checked in the Options menu.
You will see tabs in this file highlighted as a checkered red rectangle.
TabNanny will complain if you press F5.
"""
if True:
print('A tab is highlighted before this line')
# more tabs
# mor... | jnvandermeer/PythonFeedback | idlex-1.11.2/demos/tabhighlight_demo.py | Python | gpl-2.0 | 441 |
from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
import requests
import json
from dateutil.relativedelta import *
from dateutil.parser import *
from datetime import *
import commands
import os
import random
import logging
import boto3
app = Flask(__name__)
app.config.fro... | crustyratfink/ask_trimet | echo_trimet.py | Python | apache-2.0 | 4,858 |
# -*- coding: utf-8 -*-
"""
Copyright (C) 2009 Canonical
Copyright (C) 2012 Fabio Erculiani
Authors:
Michael Vogt
Fabio Erculiani
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; version 3.
This... | Sabayon/entropy | rigo/rigo/ui/gtk3/utils.py | Python | gpl-2.0 | 4,893 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Based on AboutClassMethods in the Ruby Koans
#
from runner.koan import *
class AboutClassAttributes(Koan):
class Dog:
pass
def test_objects_are_objects(self):
fido = self.Dog()
self.assertEqual(True, isinstance(fido, object))
def... | ChristianAA/python_koans_solutions | python3/koans/about_class_attributes.py | Python | mit | 4,988 |
# -*- coding: utf-8 -*-
#
# (c) Copyright 2003-2009 Hewlett-Packard Development Company, L.P.
#
# 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 of the License, or
# (at your opt... | matrumz/RPi_Custom_Files | Printing/hplip-3.15.2/base/LedmWifi.py | Python | gpl-2.0 | 28,034 |
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'Vendeur'
db.create_table(u'encefal_vendeur', (
(u'id', self.gf('django.db.models... | nilovna/EnceFAL | project/encefal/migrations/0001_initial.py | Python | gpl-3.0 | 13,511 |
#!/usr/bin/env python
# Copyright(C) 2011-2016 Thomas Voegtlin
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, m... | pooler/electrum-ltc-server | src/utils.py | Python | mit | 6,761 |
#!/usr/bin/env python
# _*_ coding: utf-8 _*_
from operator import add
import add_package_path
import sys
from twisted.internet import defer
from twisted.internet.task import react
from twisted.python import log
from cooperative import batch_accumulate
def expensive(number):
log.msg("starting {}".format(number... | Nikita003/cooperative | examples/non_blocking.py | Python | apache-2.0 | 3,168 |
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.2'
# jupytext_version: 1.2.3
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %%
# %matplotlib in... | buzmakov/tomography_scripts | misc/2energy_tomo.py | Python | mit | 2,983 |
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.db.transaction import atomic
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.template import ... | rdonnelly/ultimate-league-app | src/ultimate/user/views.py | Python | bsd-3-clause | 4,712 |
import json
from django.core.urlresolvers import reverse
from rest_framework import serializers
import amo
from amo.helpers import absolutify
from files.models import FileUpload
class FileUploadSerializer(serializers.ModelSerializer):
active = serializers.SerializerMethodField('get_active')
url = serialize... | mdaif/olympia | apps/signing/serializers.py | Python | bsd-3-clause | 2,866 |
# Copyright (C) 2014 eNovance SAS <licensing@enovance.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 required by applicabl... | cloudbase/neutron-virtualbox | neutron/db/metering/metering_rpc.py | Python | apache-2.0 | 2,091 |
#!/usr/bin/python -OO
# This file is part of Archivematica.
#
# Copyright 2010-2012 Artefactual Systems Inc. <http://artefactual.com>
#
# Archivematica is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, e... | artefactual/archivematica-history | src/MCPClient/lib/clientScripts/extractBagTransfer.py | Python | agpl-3.0 | 2,795 |
from handlers import ViewHandler
from utility import validate
import json
import entities
# Handler for new comments
class NewCommentHandler(ViewHandler):
# This handler only accepts post requests and we make sure that post is
# valid and user is authenticated with the decorators and pass in the
# json p... | FatalTouch/BlogExample | handlers/comment/newcomment.py | Python | apache-2.0 | 1,683 |
with open('8.in') as f:
print(sum([len(line.strip()) - len(eval(line)) for line in f]))
| pedrotari7/advent_of_code | py/2015/8A.py | Python | mit | 94 |
from __future__ import division
import sys
import igraph
import numpy as np
import pandas as pd
from sklearn.cross_validation import train_test_split
from sklearn.ensemble import *
from sklearn.metrics import *
from sklearn.preprocessing import MinMaxScaler
from transform_funcs import *
from tradaboost import *
from u... | yfiua/TraNet | trust/trust-tradaboost.py | Python | gpl-3.0 | 5,064 |
# Copyright (C) 2012-2019 FreeIPA Contributors see COPYING for license
import logging
from collections import namedtuple
from textwrap import dedent
from ipalib import Registry, errors
from ipalib import Updater
from ipapython.dn import DN
from ipapython import ipautil
from ipaplatform.paths import paths
from ipaser... | encukou/freeipa | ipaserver/install/plugins/adtrust.py | Python | gpl-3.0 | 37,987 |
# Copyright 2015 Nicta
#
# 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 agreed to in writing, softwa... | sirca/clusterous | clusterous/clusterousmain.py | Python | apache-2.0 | 13,510 |
"""Runner for testing app and blueprint logging individually"""
import subprocess
from tests.samples import app
if __name__ == '__main__':
app.run()
subprocess.call(['rm', '-rf', 'logs'])
| pinntech/flask-logex | runner.py | Python | mit | 198 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Information Theory Exceptions
=============================
Exceptions related to information theory.
"""
__all__ = ['ditException',
'IncompatibleDistribution',
'InvalidBase',
'InvalidDistribution',
'InvalidNormalization',
... | chebee7i/dit | dit/exceptions.py | Python | bsd-3-clause | 4,115 |
'''
MinibatchIterator.py
Generic object for iterating over a single bnpy Data set
by considering one subset minibatch (often just called a batch) at a time
Usage
--------
Construct by providing the underlying full-dataset
>> MB = MinibatchIterator(Data, nBatch=10, nObsBatch=100)
Then call
has_next_batch() to te... | daeilkim/refinery | refinery/bnpy/bnpy-dev/bnpy/data/MinibatchIterator.py | Python | mit | 4,947 |
#!/usr/bin/env python3
from auto.utils import cat, cd, mkdir_if_needed, mpath, path, shell
import argparse
import re
import os
import sys
TOPDIR = os.environ["TOPDIR"]
DOCKER_DIR = path(TOPDIR, "docker")
#
# Helper
#
class Helper:
@staticmethod
def is_cygwin():
try:
shell(... | OpenISA/riscv-sbt | docker/build.py | Python | mit | 15,183 |
import socket
import threading
import Queue
from bitcoin.net import PROTO_VERSION
from bitcoin.messages import MsgSerializable
class PeerConn(threading.Thread):
def __init__(self, conn, protover=PROTO_VERSION):
"""Pass in an established connection."""
self.conn = conn
self.peername = conn... | bitcoinfees/talkbitcoin | _talkbitcoin.py | Python | mit | 2,510 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import subprocess
running = os.system("nc -u -l -p 5001 | mplayer -cache 1024 -")
#subprocess.check_call('/opt/vc/bin/raspivid -n -w 800 -h 600 -fps 24 -t 0 -o - | socat - udp-sendto:' + '129.16.194.248' + ':5001')
| twistedretard/LaserSimulatedSecurityTurret | src/streaming/server.py | Python | mit | 272 |
import confutil
from skitai.handlers import collectors
from atila import grpc_collector
from examples.services import route_guide_pb2
from atila import multipart_collector
import pytest
from skitai import testutil
@pytest.fixture
def handler (wasc):
return testutil.install_vhost_handler ()
@pytest.fixture
def post (... | hansroh/skitai | tests/level1/test_collectors.py | Python | mit | 1,310 |
# Copyright (c) 2013 LE GOFF Vincent
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and th... | v-legoff/pa-poc3 | src/display/table.py | Python | bsd-3-clause | 5,852 |
def palindrome2(x):
x = str(x)
return x == x[::-1]
| ultranaut/illacceptanything | code/palindrome2.py | Python | mit | 59 |
"""Modoboa compatibility matrix."""
COMPATIBILITY_MATRIX = {
"1.8.1": {
"modoboa-pdfcredentials": "<=1.1.0",
"modoboa-sievefilters": "<=1.1.0",
"modoboa-webmail": "<=1.1.5",
},
"1.8.2": {
"modoboa-pdfcredentials": ">=1.1.1",
"modoboa-sievefilters": ">=1.1.1",
... | modoboa/modoboa-installer | modoboa_installer/compatibility_matrix.py | Python | mit | 719 |
# -*- coding: utf-8 -*-
#
# OpenCraft -- tools to aid developing and hosting free software projects
# Copyright (C) 2015-2019 OpenCraft <xavier@opencraft.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free... | open-craft/opencraft | instance/models/openedx_instance.py | Python | agpl-3.0 | 28,216 |
USER_SETTINGS = {
'DEBUG': True,
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
... | capitalm-chen/weblate-docker-fig | build/weblate/settings_user_default.py | Python | gpl-2.0 | 1,248 |
# Copyright 2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
from zope.component import getUtility
from lp.services.worlddata.interfaces.language import ILanguageSet
from lp.testing import (
person_logged_in,
T... | abramhindle/UnnaturalCodeFork | python/testdata/launchpad/lib/lp/answers/model/tests/test_question.py | Python | agpl-3.0 | 4,271 |
# -*- coding: utf-8 -*-
#
# napalm documentation build configuration file, created by
# sphinx-quickstart on Tue Dec 16 13:17:14 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# Al... | mirceaulinic/pypluribus | docs/conf.py | Python | apache-2.0 | 8,555 |
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
import sys
from io import XPlaneOBJReader
# Initialize the script plug-in
def initializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject)
try:
mplugin.registerCommand( kPluginCmdName, cmdCreator )
except:
sys.st... | renderbox/xplane-maya | mayaXPlaneImporter.py | Python | mit | 2,851 |
"""
TODO: npy_void
"""
import numpy
from capi import sctypebits
scalar = dict(
c_char = dict(\
ctype = 'signed char',
init = ' = 0',
argument_format = 'b',
return_format = 'b',
argument_title = 'a python integer (converting to C signed char)',
return_title = 'a python integer (converting from ... | travellhyne/f2py | extgen/type_rules.py | Python | bsd-3-clause | 17,012 |
# -*- coding: utf-8 -*-
"""Operations for BEL graphs."""
from typing import Iterable
import networkx as nx
from tqdm.autonotebook import tqdm
from .utils import update_metadata
from ..dsl import BaseEntity
__all__ = [
"subgraph",
"left_full_join",
"left_outer_join",
"union",
"left_node_intersec... | pybel/pybel | src/pybel/struct/operations.py | Python | mit | 5,181 |
'''
Split incoming events in various ways.
'''
import libs.modifiers
class Copy(libs.modifiers.Modifier):
def __init__(self):
self.inputs = {
'main': None
}
self.outputs = {
'copy': []
}
| aj00200/midifire | src/libs/modifiers/splitters.py | Python | gpl-3.0 | 249 |
from geotrek.common.mixins import NoDeleteMixin
from mapentity.management.commands.prepare_map_images import Command as MapentityCommand
class Command(MapentityCommand):
"""Override mapentity command of the same name to exclude deleted objects."""
def get_instances(self, model):
if issubclass(model, ... | mabhub/Geotrek | geotrek/common/management/commands/prepare_map_images.py | Python | bsd-2-clause | 433 |
##########################################################
##########################################################
# description: class that handles pd communication
#
# important: based on Frank Barknecht script at:
# http://markmail.org/message/ohuwrz77hwo3bcwp#query:python%20pdsend+page:1+mid:ybdc6esbu7q53otu+sta... | husk00/pantaliQa | libs/pyata/src/communication.py | Python | gpl-2.0 | 4,921 |
import json
from pprint import pprint
import datetime
from datetime import date
import re
import itertools
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django.core.urlresolvers import reverse_lazy, reverse, resolve
from django.co... | unicef/polio | datapoints/views.py | Python | agpl-3.0 | 8,266 |
"""
Student Views
"""
import datetime
import logging
import uuid
import json
import warnings
from collections import defaultdict
from urlparse import urljoin, urlsplit, parse_qs, urlunsplit
from django.views.generic import TemplateView
from pytz import UTC
from requests import HTTPError
from ipware.ip import get_ip
i... | deepsrijit1105/edx-platform | common/djangoapps/student/views.py | Python | agpl-3.0 | 104,572 |
# -*- coding: utf-8 -*-
# Импортируем нужные нам библиотеки
# import urllib
# import urlparse
# import urllib2
# import time
# import sys
# import os
# try:
# import json
# except ImportError:
# import simplejson as json
import string
import random
from uuid import getnode as get_mac
# import xbmcaddon
impo... | Limeone/plugin.video.bonus | auth.py | Python | gpl-3.0 | 2,196 |
# AnalogClock's base classes
# E. A. Tacao <e.a.tacao |at| estadao.com.br>
# http://j.domaindlx.com/elements28/wxpython/
# 15 Fev 2006, 22:00 GMT-03:00
# Distributed under the wxWidgets license.
from time import strftime, localtime
import math
import wx
from styles import *
#-----------------------... | ktan2020/legacy-automation | win/Lib/site-packages/wx-3.0-msw/wx/lib/analogclock/helpers.py | Python | mit | 28,246 |
import os
import logging
import numpy as np
from torch.utils.data import Dataset
import cv2
from PIL import Image
import subprocess
import torchvision.transforms as tfs
np.random.seed(0)
def TransCommon(image):
image = cv2.equalizeHist(image)
image = cv2.GaussianBlur(image, (3, 3), 0)
return image
de... | google-research/understanding-transfer-learning | third_party/chexpert_data/chexpert.py | Python | apache-2.0 | 7,524 |
__author__ = 'Alex Baranov'
import unittest
from time import *
import numpy as np
from ..discrete.inequalities import chernikov as c
class TestFind_system_of_fundamental_solutions(unittest.TestCase):
def _test_pulp(self):
import pulp as p
prob = p.LpProblem("The Whiskas Problem", p.LpMinimize)
... | stonelake/pyoptimization | pyopt/tests/test_find_system_of_fundamental_solutions.py | Python | apache-2.0 | 2,808 |
# Copyright 2016 Google 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 applicable law or a... | GoogleCloudPlatform/repo-automation-playground | wizard-py/test_data/parser/nested_tags/nested_tags_test.py | Python | apache-2.0 | 754 |
"""Main Nvim interface."""
import os
from msgpack import ExtType
from .buffer import Buffer
from .common import (DecodeHook, Remote, RemoteMap, RemoteSequence,
SessionFilter, SessionHook, walk)
from .tabpage import Tabpage
from .window import Window
from ..compat import IS_PYTHON3
__all__ = ('N... | 0x90sled/python-client | neovim/api/nvim.py | Python | apache-2.0 | 9,543 |
"""
Copyright 2011 Jeff Garzik
AuthServiceProxy has the following improvements over python-jsonrpc's
ServiceProxy class:
- HTTP connections persist for the life of the AuthServiceProxy object
(if server supports HTTP/1.1)
- sends protocol 'version', per JSON-RPC 1.1
- sends proper, incrementing 'id'
... | TGDiamond/Diamond | qa/rpc-tests/python-diamondrpc/diamondrpc/authproxy.py | Python | mit | 5,784 |
#!/usr/bin/env ambari-python-wrap
"""
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... | splicemachine/spliceengine | assembly/hdp3.1.5/src/main/resources/common-services/SPLICEMACHINE/2.5.1/service_advisor.py | Python | agpl-3.0 | 16,650 |
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation
import time
import json
import pytest
import os
import... | gdestuynder/MozDef | tests/mozdef_util/test_elasticsearch_client.py | Python | mpl-2.0 | 19,095 |
import codecs
import re
UTF8_BOM_PATTERN = re.compile("\\A(\\xFE\\xFF|\\xFF\\xFE)".encode('utf-8'))
def read_unicode(filename,external_encoding='utf8'):
data = codecs.open(filename,encoding=external_encoding).read()
if UTF8_BOM_PATTERN.match(data):
return unicode(UTF8_BOM_PATTERN.sub('',data)).encode('utf8')
el... | OiNutter/rivets | rivets/utils.py | Python | mit | 481 |
""" Copyright (c) Microsoft. All rights reserved.
Licensed under the MIT license.
Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
Microsoft Cognitive Services (formerly Project Oxford) GitHub:
https://github.com/Microsoft/ProjectOxford-ClientSDK
Copyright (c) Micr... | Microsoft/ProjectOxford-ClientSDK | SpeakerRecognition/Python/Identification/PrintAllProfiles.py | Python | mit | 2,648 |
f = lambda x: x + 1
map(f, [1, 2, 3, 4]) | schmit/intro-python-course | lectures/code/mr_map.py | Python | mit | 41 |
#coding=utf-8
import re
import urllib
import requests
import Queue
import time
from bs4 import BeautifulSoup
class ver9000():
def get_cookie(self,url,headers,count):
ctest=0
while True:
if ctest == count:
return False
else:
if ctest != 0:
ctest+=1
print "Retry %s times" %ctest
else:
... | dc3l1ne/Weblogic_Automatical_Attacker | ver9000.py | Python | gpl-2.0 | 11,387 |
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.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/... | openstack/watcher | watcher/tests/decision_engine/model/ceilometer_metrics.py | Python | apache-2.0 | 9,723 |
"""
Various complex queries that have been problematic in the past.
"""
from __future__ import unicode_literals
import threading
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
class DumbCategory(models.Model):
pass
class ProxyCategory(Du... | benjaminrigaud/django | tests/queries/models.py | Python | bsd-3-clause | 15,849 |
from Domain.Exceptions import UserDead, GameFinished
hangman = "hangman"
class GameState():
def __init__(self, sentence):
"""
Class used to keep state of a game.
This theoretically allows several games to be ongoing at the same time, without affecting each other.
"""
... | Zephyrrus/ubb | YEAR 1/SEM1/FP/LAB/Examen/Controller/GameState.py | Python | mit | 2,082 |
#!/usr/bin/env python
# vim:ts=4:sw=4:et:
import os
watchman_src_dir = os.environ.get("CMAKE_CURRENT_SOURCE_DIR")
if watchman_src_dir is None:
watchman_src_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
# The python source dir.
# On Windows, this has to be relative to the cwd otherwise so... | wez/watchman | python/setup.py | Python | apache-2.0 | 2,218 |
from __future__ import absolute_import, unicode_literals
from django.core.management.base import BaseCommand
from wagtail.wagtailcore.models import Page
class Command(BaseCommand):
help = 'Resets url_path fields on each page recursively'
def set_subtree(self, root, parent=None):
root.set_url_path(... | chrxr/wagtail | wagtail/wagtailcore/management/commands/set_url_paths.py | Python | bsd-3-clause | 577 |
"""Component to interface with various sensors that can be monitored."""
from __future__ import annotations
from collections.abc import Mapping
from contextlib import suppress
from dataclasses import dataclass
from datetime import datetime, timedelta
import inspect
import logging
from typing import Any, Final, cast, f... | FreekingDean/home-assistant | homeassistant/components/sensor/__init__.py | Python | apache-2.0 | 11,968 |
#!/usr/bin/env python
# -*- mode: python; coding: utf-8 -*-
##################################################################
# Documentation
##################################################################
# Imports
from __future__ import absolute_import, unicode_literals, print_function
try:
from cPickle im... | WladimirSidorenko/CGSA | cgsa/dl/base.py | Python | mit | 20,205 |
#!/usr/bin/env python
#
# testing classes to test multiple inheritance.
# these are not meant to be run by trial, though they could be made to be so.
# i didn't know where to put them. --isis
import abc
from pprint import pprint
from inspect import classify_class_attrs
class PluginBase(object):
__metaclass__ = ab... | hackerberry/ooni-probe | tests/test-class-design.py | Python | bsd-2-clause | 2,996 |
#!/usr/bin/python
import argparse
import os
import sys
import LightsClient
parser = argparse.ArgumentParser()
parser.add_argument( 'sequenceName', metavar = 'sequence-name', type = str, nargs = 1, help = 'the new sequence name' )
args = parser.parse_args()
# re-open STDOUT so that it is un-buffered
sys.stdout = os.... | mattlyle/NeopixelXMasTree | server/backend/helper-scripts/run-sequence.py | Python | mit | 791 |
import math
from sqlalchemy.orm.exc import NoResultFound
from leaderboard.db import session_factory
from leaderboard.models.country_bounds import CountryBounds
from leaderboard.geo_util import coord_utils
from leaderboard.models.contributor import Contributor
from leaderboard.models.db import LeaderboardGlobals
from l... | garvankeeley/leaderboard_backend | tests/test_models.py | Python | mpl-2.0 | 3,003 |
# -*- coding: utf-8 -*-
# Copyright (C) 2009-2013, Luis Pedro Coelho <luis@luispedro.org>
# vim: set ts=4 sts=4 sw=4 expandtab smartindent:
# License: MIT. See COPYING.MIT file in the Waldo distribution
from __future__ import division
try:
import setuptools
except:
from sys import exit
print('''
setuptools... | luispedro/waldo | setup.py | Python | mit | 1,654 |
#Quiz Problem 4
def greedySum(L, s):
""" input: s, positive integer, what the sum should add up to
L, list of unique positive integers sorted in descending order
Use the greedy approach where you find the largest multiplier for
the largest value in L then for the second largest, and... | johntauber/MITx6.00.2x | Quiz/QuizProblem4.py | Python | mit | 1,048 |
# tubex-lib - Examples
# Contractors on tubes: temporal contractors
# Comparison between the Lohner & Picard temporal contractors
# ----------------------------------------------------------------------------
# Auguste Bourgois, 2020
from pyibex import *
from tubex_lib import *
import sys # only for checking if this ... | SimonRohou/tubex-lib | examples/basics/07_temporal_ctc/07_temporal_ctc.py | Python | lgpl-3.0 | 1,939 |
from pprint import pformat
class Model(object):
"""
Implements a generic object.
"""
def __init__(self, data, api):
self.temp_id = ''
self.data = data
self.api = api
def __setitem__(self, key, value):
self.data[key] = value
def __getitem__(self, key):
... | ajar98/todoist_bot | todoist/models.py | Python | mit | 6,334 |
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Accuvant, Inc. (bspengler@accuvant.com)
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
from lib.cuckoo.common.abstracts import Signature
class InjectionExtension(Signature):
name = "injection_n... | lixiangning888/whole_project | modules/signatures_merge_tmp/injection_needextension.py | Python | lgpl-3.0 | 1,136 |
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django import forms
class UserRegistrationForm(UserCreationForm):
class Meta:
model = User
fields = ('username', 'email',)
| cscanlin/munger-builder | munger_builder/forms.py | Python | mit | 269 |
# (C) British Crown Copyright 2017, Met Office
#
# This file is part of Iris.
#
# Iris 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 3 of the License, or
# (at your option) any later ve... | LukeC92/iris | lib/iris/tests/unit/lazy_data/test_as_concrete_data.py | Python | lgpl-3.0 | 3,347 |
# -*- coding: utf-8 -*-
import json
from unittest.mock import patch, Mock
from unittest import TestCase
from swiftclient import client
from storage.tests import fakes
from storage import views
from vault.tests.fakes import fake_request
class TestSwiftTrash(TestCase):
def setUp(self):
self.request = ... | globocom/vault | storage/tests/test_swift_trash.py | Python | apache-2.0 | 4,672 |
# -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Test for Video Xmodule functional logic.
These test data read from xml, not from mongo.
We have a ModuleStoreTestCase class defined in
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py.
You can search for usages of this in the cms and lms tests ... | Stanford-Online/edx-platform | lms/djangoapps/courseware/tests/test_video_xml.py | Python | agpl-3.0 | 3,114 |
#!/usr/bin/python
#
# Run multiple LDViews in parallel to make pictures faster. On my computer I can
# get about a 2x speed-up with this.
#
# Hazen 11/15
#
import os
import Queue
import signal
import subprocess
import sys
import thread
def batchLDView(file_pairs, width = 200, height = 200, default_zoom = 0.95, max_p... | HazenBabcock/opensdraw | opensdraw/partviewer/batchPictureGeneration.py | Python | mit | 4,421 |
# Core
from app.api import api
from flask import jsonify
from flask.ext.cors import cross_origin
# Models
from app.models.location import Location
@cross_origin()
@api.route('/locations', methods=['GET'])
def get_locations():
"""
:return: Return a list with all locations
"""
# Get all movies from DB
... | boltzj/movies-in-sf | app/api/locations.py | Python | mit | 492 |
#!/usr/bin/env python
#
# setup_setup.py for 'ucsql'
#
# This is the 'easy button' for installation of 'ucsql'
# Given the many dependencies, this script will optionally go an install everything it needs.
# If admins wish to install packages manually, then they can skip this.
# This script is assumed to be run from 'se... | ucsql/ucsql | setup_setup.py | Python | apache-2.0 | 5,477 |
import matplotlib
import matplotlib.pyplot as plt
from functools import wraps
def ensure_ax(func):
@wraps(func)
def inner(*args, **kwargs):
if 'ax' in kwargs:
ax = kwargs.pop('ax', None)
elif len(args) > 0 and isinstance(args[0], matplotlib.axes.Axes):
ax = args[0]
... | ericdill/xray-vision | xray_vision/utils/mpl_helpers.py | Python | bsd-3-clause | 861 |
"""
Support for Portage
.. important::
If you feel that Salt should be using this module to manage packages on a
minion, and it is using a different module (or gives an error similar to
*'pkg.install' is not available*), see :ref:`here
<module-provider-override>`.
:optdepends: - portage Python adap... | saltstack/salt | salt/modules/ebuildpkg.py | Python | apache-2.0 | 39,670 |
from __future__ import absolute_import, unicode_literals
from case import Mock, patch
from amqp.five import text_t
from amqp.utils import (NullHandler, bytes_to_str, coro, get_errno, get_logger,
str_to_bytes)
class test_get_errno:
def test_has_attr(self):
exc = KeyError('foo')
... | pexip/os-python-amqp | t/unit/test_utils.py | Python | lgpl-2.1 | 2,126 |
import logging
import random
import time
from calendar import timegm
from itertools import chain
from .actions import Attack, BeginTurn, Death, EndTurn, EventListener
from .card import Card, THE_COIN
from .entity import Entity
from .enums import CardType, PlayState, Step, Zone
from .managers import GameManager
from .ut... | butozerca/fireplace | fireplace/game.py | Python | agpl-3.0 | 9,162 |
# -*- coding: utf-8 -*-
import logging
import subprocess
import os.path
from django.http import HttpResponse, Http404
from django.views.generic import View
from django.conf import settings
from braces.views import JSONResponseMixin
from sunlumo_project.models import Project
from .renderer import Renderer
from .feat... | candela-it/sunlumo | django_project/sunlumo_mapserver/views.py | Python | mit | 7,606 |
import requests
_base_url = 'https://api.twitch.tv/kraken/'
class Query:
def __init__(self, action, url):
self.action = action.lower()
self.parameters = dict()
self.url = _base_url + url
# add parameters to the query
# parameter | dictionary of paramters and corresponding values
def add_parameters(self, ... | bm993a/ptwitch | query.py | Python | apache-2.0 | 1,199 |
'''
Rewindows tiles from 40000x1 pixels to 160x160 pixels for use in aggregate map creation.
Specifically, does tiles that are not model outputs but are used in aggregate map creation:
tree cover density, pixel area, Hansen gain, and mangrove biomass.
This must be done before the model is run so that the aggregate maps... | sgibbes/carbon-budget | data_prep/mp_rewindow_tiles.py | Python | apache-2.0 | 5,324 |
list_a = [3, 9, 17, 15, 19]
list_b = [2, 4, 8, 10, 30, 40, 50, 60, 70, 80, 90]
for a, b in zip(list_a, list_b):
if list_a[a] > list_b[b]:
print list_a[a]
else:
print list_b[b]
| talapus/Ophidian | Academia/Lists/list_a_and_list_b.py | Python | bsd-3-clause | 201 |
# -*- coding: utf-8 -*-
#
# File: eduCourses/events.py
#
# Copyright (c) 2007 Erik Rivera Morales <erik@ro75.com>
#
# GNU General Public License (GPL)
#
# 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 Found... | erikriver/eduIntelligent-cynin | src/eduintelligent.sco/eduintelligent/sco/events.py | Python | gpl-3.0 | 1,228 |
# Copyright 2019 NetApp, 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 ... | openstack/manila | manila/tests/api/views/test_share_network_subnets.py | Python | apache-2.0 | 2,945 |
"""SerializedDataConverter lib."""
| facelessuser/SerializedDataConverter | lib/__init__.py | Python | mit | 35 |
from nxtools import *
__all__ = ["get_output_profile"]
default_bitrates = {
"dnxhd" : "120M",
"mjpeg" : False,
"mpeg2video" : "50M",
"libx264" : "6M",
"libx265" : "4M",
"libfdk_aac" : "128k",
"mp2" : "128k"
}
default_audio_codecs = {
"dnxhd" : "pc... | martastain/themis | themis/output_profile.py | Python | gpl-3.0 | 1,936 |
"""
You can get information about which each train has by using this service. For test purposes, you can start a local service using this code. You can assume the real service will behave the same way, but be available on a different url.
You need [Python 3.3](http://python.org) and [CherryPy](http://www.cherrypy.org/... | emilybache/KataTrainReservation | train_data_service/train_data_service.py | Python | mit | 2,899 |
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
#
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
# All Rights Reserved.
# info Vauxoo (info@vauxoo.com)
####################################... | 3dfxsoftware/cbss-addons | partner_invoice_description/account_invoice.py | Python | gpl-2.0 | 4,416 |
#!/usr/bin/env python
# Standard packages
import sys
import argparse
# Third-party packages
from toil.job import Job
# Package methods
from ddb import configuration
from ddb_ngsflow import annotation
from ddb_ngsflow import pipeline
from ddb_ngsflow.coverage import sambamba
if __name__ == "__main__":
parser = ... | dgaston/ddb-ngsflow-scripts | workflow-merkel_coverage_annotation.py | Python | mit | 1,997 |
#
# Copyright: (c) 2018, Ansible Project
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
name: vm... | helldorado/ansible | lib/ansible/plugins/inventory/vmware_vm_inventory.py | Python | gpl-3.0 | 19,672 |
# -*- coding: utf-8 -*-
"""Assessment Open Service Interface Definitions
assessment version 3.0.0
Copyright (c) 2002-2004 Massachusetts Institute of Technology.
Copyright (c) 2008-2010 Ingenescus. All Rights Reserved.
This Work is being provided by the copyright holder(s) subject to the
following license. By obtaini... | birdland/dlkit-doc | dlkit/assessment/license.py | Python | mit | 1,842 |
import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 15.81
camera.units = 'MILLIMETERS'
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0
| Microvellum/Fluid-Designer | win64-vc/2.78/scripts/presets/tracking_camera/Blackmagic_Cinema_Camera.py | Python | gpl-3.0 | 193 |
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 26 16:43:46 2017
@author: DWyatt
"""
import pandas as pd
import seaborn as sns
import os
import matplotlib.pyplot as plt
df_train = pd.read_csv('train.csv')
target = 'SalePrice'
variables = [str(column) for column in df_train.columns if column!=target]
dir1 = os.getcwd(... | BenChehade/datasciences | chart - sales price vs variables/generate_charts.py | Python | mit | 724 |
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from typing import Any, Callable, Optional
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.test import TestCase
from zerver.models import (
get_client, get_realm_by_string_id, get_stream, get_user_profile... | calvinleenyc/zulip | zerver/tests/test_events.py | Python | apache-2.0 | 49,189 |
"""
Base debug settings for a project to include via execfile().
"""
from cinch import cinch_settings
g = globals()
S = g.setdefault
# Debugging and development modes
S('DEBUG', True)
S('TEMPLATE_DEBUG', g['DEBUG'])
S('TEMPLATE_STRING_IF_INVALID', 'INVALID_CONTEXT[%s]')
# Include our sibling base settings
g.updat... | hipikat/django-cinch | cinch/settings/debug.py | Python | bsd-2-clause | 810 |
"""
ApacheHTTPD Support
"""
import logging
import re
from newrelic_plugin_agent.plugins import base
LOGGER = logging.getLogger(__name__)
PATTERN = re.compile(r'^([\w\s{1}]+):\s([\d\.{1}]+)', re.M)
class ApacheHTTPD(base.HTTPStatsPlugin):
DEFAULT_QUERY = 'auto'
GUID = 'com.meetme.newrelic_apache_httpd_age... | notnmeyer/newrelic-plugin-agent | newrelic_plugin_agent/plugins/apache_httpd.py | Python | bsd-3-clause | 5,670 |
"""
Python Information Theoretic Inequality Prover
Usage:
pitip VARNAMES CHECK [-p]
Options:
-p, --prove Show proof
"""
import numpy as np
from .core.app import application
from .core.io import System, column_varname_labels
from .core.it import elemental_inequalities, elemental_forms
def _format_d... | coldfix/pystif | pystif/pitip.py | Python | gpl-3.0 | 2,067 |
from util.tipo import tipo
class S_PLAYER_CHANGE_EP(object):
def __init__(self, tracker, time, direction, opcode, data):
print(str(type(self)).split('.')[3]+'('+str(len(data))+'): '+ str(data.get_array_hex(1))[1:-1])
| jeff-alves/Tera | game/message/unused/S_PLAYER_CHANGE_EP.py | Python | mit | 230 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.