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 |
|---|---|---|---|---|---|
from solving import bellmansolving
import numpy as np
import pytest
from util import constants as cs
@pytest.fixture(scope='module')
def init_mock():
class Mock():
pass
mock = Mock()
mock.vep_stay = np.ones(10, dtype=np.float64)
mock.vfp_stay = np.ones(10, dtype=np.float64)/1.3
mock.vup =... | mishpat/human-capital-search | tests/bellmansolving_test.py | Python | mit | 2,285 |
# Copyright 2016 Thomas C. Hudson
# Governed by the license described in LICENSE.txt
import libtcodpy as libtcod
import log
import algebra
from components import *
import actions
import map
import spells
def dagger():
return Object(algebra.Location(0, 0), '-', 'dagger', libtcod.sky,
item=Item(de... | Naburimannu/libtcodpy-tutorial | miscellany.py | Python | bsd-3-clause | 2,299 |
try:
import json
except ImportError:
from django.utils import simplejson as json
from django import http
from django import template
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_4... | wwu-housing/django-wysiwyg-forms | wysiwyg_forms/views.py | Python | mit | 5,501 |
# This demo does the same as the dyndispatch demo, except that a
# custom dispatcher loop is used. This is how asynchronous parallel
# optimization algorithms like DE and PSADE are implemented.
# mpirun -n 4 python 05-asyncloop.py
from pyopus.parallel.cooperative import cOS
from pyopus.parallel.mpi import MPI
from ... | blorgon9000/pyopus | demo/parallel/cooperative/05-asyncloop.py | Python | gpl-3.0 | 2,431 |
from isochrones.dartmouth import Dartmouth_Isochrone
from isochrones.utils import addmags
import numpy as np
import pandas as pd
file = open('/tigress/np5/true_params.txt','a')
def get_index(n):
if n < 10:
return '000' + str(n)
elif n < 100:
return '00' + str(n)
elif n < 1000:
retu... | nonsk131/USRP2016 | generate_tests0000-0999.py | Python | mit | 3,341 |
import enum
from typing import Dict, Optional, Set
@enum.unique
class MediaTag(enum.IntEnum):
# ndb keys are based on these! Don't change!
CHAIRMANS_VIDEO = 0
CHAIRMANS_PRESENTATION = 1
CHAIRMANS_ESSAY = 2
MEDIA_TAGS: Set[MediaTag] = {t for t in MediaTag}
TAG_NAMES: Dict[MediaTag, str] = {
Medi... | the-blue-alliance/the-blue-alliance | src/backend/common/consts/media_tag.py | Python | mit | 1,026 |
#!/usr/bin/env python
import click
import salt.config
import salt.client
def salt_init():
opts = salt.config.apply_minion_config()
opts['file_client'] = 'local'
caller = salt.client.Caller(mopts=opts)
return caller
@click.command()
@click.option('-i', '--install',
help='Install new rel... | Abukamel/newrelic_ops | bin/new_relic_click.py | Python | mit | 1,728 |
#!/usr/bin/env python
#
# dnscan copyright (C) 2013-2014 rbsec
# Licensed under GPLv3, see LICENSE for details
#
from __future__ import print_function
import os
import re
import sys
import threading
import time
try: # Ugly hack because Python3 decided to rename Queue to queue
import Queue
except ImportError:
... | elationfoundation/dnscan | dnscan.py | Python | gpl-3.0 | 9,150 |
# -*- coding: utf-8 -*-
import codecs
import fnmatch
import json
import os
from pyquery import PyQuery
import logging
log = logging.getLogger(__name__)
def process_all_json_files(version, build_dir=True):
"""
Return a list of pages to index
"""
if build_dir:
full_path = version.project.full... | kdkeyser/readthedocs.org | readthedocs/search/parse_json.py | Python | mit | 3,901 |
#!/usr/bin/python3
from __future__ import division, print_function, absolute_import
import numpy as np
import mxnet as mx
from mxnet import nd, autograd, gluon
import os
os.system("taskset -a -p 0xFFFFFFFF %d" % os.getpid())
mx.random.seed(1)
ctx = mx.cpu()
data_ctx = ctx
model_ctx = ctx
batch_size = 200
width=40
nu... | aravindhv10/CPP_Wrappers | NewData/SRC/MXNET_CNN_Supervised_Simple/start.py | Python | gpl-2.0 | 5,411 |
# -*- coding: utf-8 -*-
#
# hl_api_nodes.py
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST 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, o... | Silmathoron/nest-simulator | pynest/nest/lib/hl_api_nodes.py | Python | gpl-2.0 | 5,988 |
from __future__ import unicode_literals
import glob
import gzip
import os
import warnings
import zipfile
from django.apps import apps
from django.conf import settings
from django.core import serializers
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, Comman... | Sonicbids/django | django/core/management/commands/loaddata.py | Python | bsd-3-clause | 12,444 |
""":mod:`wikidata.commonsmedia` --- `Wikimedia Commons`_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. _Wikimedia Commons: https://commons.wikimedia.org/
.. versionadded:: 0.3.0
"""
import collections.abc
from typing import Mapping, Optional, Tuple, cast
import urllib.parse
from .client import Client
... | dahlia/wikidata | wikidata/commonsmedia.py | Python | gpl-3.0 | 3,528 |
# pylint: disable=too-few-public-methods
from enkiblog import models
import os.path
from websauna.utils.time import now
from random import randint
from uuid import uuid4
import factory
from enkiblog.core.utils import slugify
from enkiblog.core.testing.fakefactory import BaseFactory, DB_SESSION_PROXY
class TagFactor... | enkidulan/enkiblog | src/enkiblog/tests/fakefactory.py | Python | apache-2.0 | 1,348 |
#! /usr/bin/env python
from setuptools import setup, find_packages
from basic_modeling_interface import __version__
setup(name='basic-modeling-interface',
version=__version__,
author='Eric Hutton',
author_email='eric.hutton@colorado.edu',
url='https://github.com/bmi-forum/bmi-python',
li... | bmi-forum/bmi-python | setup.py | Python | mit | 781 |
##############################################################################
#
# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __manifest__.py
#
#####################... | eicher31/compassion-switzerland | sponsorship_switzerland/models/account_banking_mandate.py | Python | agpl-3.0 | 1,630 |
# -*- coding: utf-8 -*-
import logging
import wx
import wx.adv
from outwiker.gui.guiconfig import PluginsConfig
from outwiker.core.system import getCurrentDir, getOS
from outwiker.gui.preferences.baseprefpanel import BasePrefPanel
logger = logging.getLogger('pluginspanel')
class PluginsPanel(BasePrefPanel):
"... | unreal666/outwiker | src/outwiker/gui/preferences/pluginspanel.py | Python | gpl-3.0 | 6,067 |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "urbansense.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| johnsonc/urbansense | manage.py | Python | gpl-2.0 | 253 |
#Builtin imports
import os
import logging
import json
import time
import threading
#External imports
import telegram
#from socketIO_client import SocketIO, LoggingNamespace, BaseNamespace
from telegram.ext import (
Updater, CommandHandler, MessageHandler, Filters
)
import requests
import dataset
CONF_FILE = "will-tel... | ironman5366/W.I.L.L | interfaces/W.I.L.L-Telegram/main.py | Python | mit | 5,460 |
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 07 01:31:25 2014
@author: Sifan
"""
x = 1515361
# x = 15
ans = 0
if x >= 0:
while ans*ans < x:
ans = ans + 1
if ans*ans == x:
print "The square root of %d is %d." % (x, ans)
else:
print "%d is not a perfect square." % (x)
else:
pr... | wnduan/IntroToComSci | lecture_.py | Python | mit | 341 |
# This file is part of Buildbot. Buildbot 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 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without eve... | zozo123/buildbot | master/buildbot/www/oauth2.py | Python | gpl-3.0 | 5,670 |
from django import forms
from django.conf import settings
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
import urllib2, urllib
VERIFY_SERVER="http://api-verify.recaptcha.net/verify"
class RecaptchaWidget(forms.Widget):
def render(self, name, value, attrs=None):
... | theju/django-comments-apps | recaptcha_comments/fields.py | Python | mit | 3,024 |
from sequence import *
from wait_actions import *
from keypress_actions import *
from sequence_step import *
| javihernandez/accerciser-mirror | macaroon/macaroon/playback/__init__.py | Python | bsd-3-clause | 109 |
from annoying.decorators import render_to
from django.contrib.auth.decorators import login_required
from games.views import game_request
@login_required
@game_request
@render_to('frontend/index.html')
def room(request):
return {'game': request.game}
| typeinference/lgt | frontend/views.py | Python | mit | 256 |
from collections import namedtuple
from graphql import graphql
from graphql.type import (
GraphQLSchema,
GraphQLObjectType,
GraphQLField,
GraphQLNonNull,
GraphQLInt,
GraphQLString,
GraphQLID,
)
from ..node import node_definitions, to_global_id, from_global_id
User = namedtuple('User', ['id... | miracle2k/graphql-relay-py | graphql_relay/node/tests/test_node.py | Python | mit | 7,306 |
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class IntMandate(models.Model):
_inherit = "int.mandate"
mandate_instance_id = fields.Many2one(
related="int_assembly_id.instance_id",
store="True",
index="T... | mozaik-association/mozaik | mozaik_membership_mandate/models/int_mandate.py | Python | agpl-3.0 | 477 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.core.files.storage
import products.models
class Migration(migrations.Migration):
dependencies = [
('products', '0002_auto_20150626_0657'),
]
operations = [
migrations.A... | codingforentrepreneurs/marketplace | src/products/migrations/0003_auto_20150626_0701.py | Python | apache-2.0 | 627 |
import wx
import listControl as lc
import getPlugins as gpi
from decimal import Decimal
import os
class Plugin():
def OnSize(self):
# Respond to size change
self.bPSize = self.bigPanel.GetSize()
self.list.SetSize((self.bPSize[0] - 118, self.bPSize[1] - 40))
self.ButtonShow(False)
... | fxb22/BioGUI | plugins/Views/BLASTView.py | Python | gpl-2.0 | 5,154 |
class Node:
# Constructor to create a new node
def __init__(self, data):
self.data = data
self.left = None
self.right = None
root = Node(100)
root.left = Node(120)
root.right = Node(50)
root.right.right = Node(70)
root.right.left = Node(160)
root.left.left = Node(140)
root.left.right = N... | saurabhkumar1989/programming_question_python | my_question/binary-tree-all-path-to-given-sum.py | Python | apache-2.0 | 743 |
"""
run mondrian with given parameters
"""
# !/usr/bin/env python
# coding=utf-8
from HIBL import
from utils.read_adult_data import read_data as read_adult
from utils.read_informs_data import read_data as read_informs
import sys, copy, random
DATA_SELECT = 'a'
TYPE = False
def get_result_one(data, k=10):
"""
... | qiyuangong/HILB_iDIST | anonymizer.py | Python | mit | 3,834 |
"""
Utility functions for setting "logged in" cookies used by subdomains.
"""
import json
import logging
import time
import six
from django.conf import settings
from django.contrib.auth.models import User
from django.dispatch import Signal
from django.urls import NoReverseMatch, reverse
from django.utils.http import... | edx-solutions/edx-platform | openedx/core/djangoapps/user_authn/cookies.py | Python | agpl-3.0 | 12,065 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# File: savemanager.py
# by Arzaroth Lekva
# lekva@arzaroth.com
#
from __future__ import print_function, absolute_import, unicode_literals
import zlib
import struct
import celestia.utility.xxtea as xxtea
class SaveError(Exception):
pass
def read_or_raise(file, siz... | Arzaroth/CelestiaSunrise | celestia/save/savemanager.py | Python | bsd-2-clause | 4,136 |
#! /usr/bin/env python
# -*- coding:Utf8 -*-
# Enregistrer les coordonnées des membres d'un club
def encodage():
"renvoie la liste des valeurs entrées, ou une liste vide"
print("*** Veuillez entrer les données (ou <Enter> pour terminer) :")
while 1:
nom = input("Nom : ")
if nom == "":
... | widowild/messcripts | exercice/python3/solutions_exercices/exercice_9_08.py | Python | gpl-3.0 | 1,176 |
#TODO; write tests when we activate algo for permissions.
| msabramo/kallithea | kallithea/tests/models/test_user_permissions_on_repos.py | Python | gpl-3.0 | 58 |
# Flipping bits
# Developer: Murillo Grubler
# https://www.hackerrank.com/challenges/flipping-bits/problem
# Reference: https://en.wikipedia.org/wiki/4,294,967,295
# Time complexity: O(1)
def flippingBits(N):
return N^4294967295
# Start algorithm
n = int(input().strip())
for a0 in range(n):
print(flippingBits... | Murillo/Hackerrank-Algorithms | Algorithms/Bit Manipulation/flipping-bits.py | Python | mit | 343 |
"""
TODO try to move these tests to the appropriate locations
"""
from __future__ import division, absolute_import
from __future__ import print_function, unicode_literals
import numpy as np
import theano
import treeano
import treeano.lasagne
from treeano.lasagne.inits import GlorotUniformInit
from treeano.nodes impo... | diogo149/treeano | treeano/lasagne/tests/multi_test.py | Python | apache-2.0 | 2,914 |
# -*- coding: utf-8 -*-
import time
from ..utils.purge import uniquify
class EventManager:
def __init__(self, core):
self.pyload = core
self._ = core._
self.clients = []
def new_client(self, uuid):
self.clients.append(Client(uuid))
def clean(self):
for n, client... | vuolter/pyload | src/pyload/core/managers/event_manager.py | Python | agpl-3.0 | 3,084 |
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import optparse
import os
import sys
import types
import unittest
from chromedriver_launcher import ChromeDriverLau... | aYukiSekiguchi/ACCESS-Chromium | chrome/test/webdriver/test/run_webdriver_tests.py | Python | bsd-3-clause | 9,476 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1)
#
# (1) Kamaelia Contributors are listed in the AUTHORS file and at
# http://www.kamaelia.org/AUTHORS - please extend this file,
# not this notice.
#
# Licensed under the Apache License,... | sparkslabs/kamaelia_ | Sketches/MH/OpenGL/Folding.py | Python | apache-2.0 | 6,204 |
#!/usr/bin/env python
__author__ = "Andrea L Halweg-Edwards"
__copyright__ = "Copyright 2015, The LASER Project"
__credits__ = ["Andrea L Halweg-Edwards"]
__license__ = "BSD"
__version__ = "0.1.0-dev"
__maintainer__ = "Andrea L Halweg-Edwards"
__email__ = "andrea.edwards@colorado.edu"
__status__ = "Development"
clas... | AndreaEdwards/dna_assembly_tools | config.py | Python | bsd-3-clause | 449 |
#!/usr/bin/env python3
# vim:fileencoding=utf-8
# Copyright (c) 2014 Masami HIRATA <msmhrt@gmail.com>
import re
import unittest
class TestYnbr(unittest.TestCase):
def test_ynbr(self):
from ynbr import yield_none_becomes_return
restr_type_error_1 = (r"\A" +
re.escap... | msmhrt/ynbr | tests/test_ynbr.py | Python | bsd-2-clause | 5,498 |
'''
In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.
Example:
high_and_low("1 2 3 4 5") # return "5 1"
high_and_low("1 2 -3 4 5") # return "5 -3"
high_and_low("1 9 3 4 -5") # return "9 -5"
'''
def high_and_low(numbers):
# We can use t... | SebastianLloret/CSCI-1310 | Misc/minMax.py | Python | gpl-3.0 | 648 |
#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2020, Anaconda, Inc., and Bokeh Contributors.
# All rights reserved.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-------------------------------------------------------------------... | ericmjl/bokeh | bokeh/util/serialization.py | Python | bsd-3-clause | 17,759 |
#
# Cython -- Things that don't belong
# anywhere else in particular
#
import os, sys, re, codecs
modification_time = os.path.getmtime
def cached_function(f):
cache = {}
uncomputed = object()
def wrapper(*args):
res = cache.get(args, uncomputed)
if res is uncomputed:
... | Teamxrtc/webrtc-streaming-node | third_party/webrtc/src/chromium/src/third_party/cython/src/Cython/Utils.py | Python | mit | 12,805 |
# Copyright (C) 2011 Google Inc. 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 the f... | klim-iv/phantomjs-qt5 | src/webkit/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py | Python | bsd-3-clause | 14,927 |
import unittest
import HW6
class TestHW6(unittest.TestCase):
def test_111(self):
self.assertEqual(HW6.solve([1,1,1,1,1,1]), 1)
def test_123(self):
self.assertEqual(HW6.solve([1,2,3]), 3)
def test_2(self):
self.assertEqual(HW6.solve([3,4,5,6]), 6)
def test_3(self):
sel... | cuixiongyi/XiongyiCui_WPI | HW6test.py | Python | bsd-2-clause | 417 |
"""
inspectors.py # Per-endpoint view introspection
See schemas.__init__.py for package overview.
"""
import re
import warnings
from collections import OrderedDict
from django.db import models
from django.utils.encoding import force_text, smart_text
from django.utils.six.moves.urllib import parse as urlparse
from d... | jpadilla/django-rest-framework | rest_framework/schemas/inspectors.py | Python | bsd-2-clause | 14,722 |
import networkx as nx
import numpy as np
import pandas as pd
def normalise(x):
x = x[:]#deepcopy error
x -= min(x)
x /= max(x)
return x
def jgraph(posjac):
'''
networkx graph object from posjac at timestep
'''
posjac = 1 - normalise(np.log10(posjac).replace([np.inf,-np.inf],np.nan... | wolfiex/DSMACC-testing | zgraph.py | Python | gpl-3.0 | 2,805 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------
# This file is part of WAPT Enterprise Edition
# Copyright (C) 2017 Tranquil IT Systems https://www.tranquil.it
# All Rights Reserved.
#
# WAPT aims to help Windows systems administrators... | tranquilit/WAPT | waptserver/tasks_common.py | Python | gpl-3.0 | 773 |
"""
The Plaid API
The Plaid REST API. Please see https://plaid.com/docs/api for more details. # noqa: E501
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
from plaid.model_utils import ( # noqa: F401
ApiTypeError,
ModelComposed,
ModelNormal... | plaid/plaid-python | plaid/model/sandbox_bank_transfer_fire_webhook_request.py | Python | mit | 7,108 |
import logging
import os
from pylons import request, tmpl_context as c
from pylons.controllers.util import redirect
from pylons.i18n import _
from openspending.model import meta as db
from openspending.model.badge import Badge
from openspending.ui.lib.base import require
from openspending.lib.jsonexport import to_json... | mxabierto/openspending | openspending/ui/controllers/badge.py | Python | agpl-3.0 | 4,060 |
"""
Django settings for kanq project.
Generated by 'django-admin startproject' using Django 1.10.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
im... | frostblooded/kanq | kanq/settings.py | Python | mit | 5,634 |
# Copyright (C) 2018 Collin Capano
# 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 3 of the License, or (at your
# self.option) any later version.
#
# This program is distributed ... | cmbiwer/pycbc | pycbc/inference/io/cpnest.py | Python | gpl-3.0 | 2,726 |
#!/usr/bin/python3
#
# Copyright 2015 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 b... | karkhaz/tuscan | toolchains/install_bootstrap/android/setup.py | Python | apache-2.0 | 2,742 |
from xml.etree import ElementTree
import requests
try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
class Translator(object):
AUTH_URL = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13"
API_ROOT = "http://api.microsofttranslator.com/v2/Http.svc"
... | icoxfog417/pyoxford | pyoxford/translator_api.py | Python | mit | 2,262 |
# -*- coding: utf-8 -*-
# Copyright 2012 splinter authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
import os
import unittest
from ssl import SSLError
from .fake_webapp import EXAMPLE_APP
from splinter.request_handler.request_handler ... | gjvis/splinter | tests/test_request_handler.py | Python | bsd-3-clause | 3,176 |
from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404
from stardate.models import Blog
from stardate.utils import get_post_model
Post = get_post_model()
class LatestPostsFeed(Feed):
def get_object(self, request, blog_slug):
return get_object_or_404(Blog, slug=b... | blturner/django-stardate | stardate/feeds.py | Python | bsd-3-clause | 811 |
from __future__ import print_function
import argparse
import os.path
import re
import sys
from typing import Optional
from typing import Sequence
def main(argv=None): # type: (Optional[Sequence[str]]) -> int
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
parser.add_argume... | Harwood/pre-commit-hooks | pre_commit_hooks/tests_should_end_in_test.py | Python | mit | 1,071 |
# Copyright (c) 2010 Aldo Cortesi
# Copyright (c) 2010, 2014 dequis
# Copyright (c) 2012 Randall Ma
# Copyright (c) 2012-2014 Tycho Andersen
# Copyright (c) 2012 Craig Barnes
# Copyright (c) 2013 horsik
# Copyright (c) 2013 Tao Sauvage
# Copyright (c) 2020 Mikel Ward
#
# Permission is hereby granted, free of charge, to... | mikelward/conf | config/qtile/config.py | Python | apache-2.0 | 8,878 |
from rest_framework import serializers
from mmkitarchive.models import Item, Category
# Category
class CategoryListSerializer(serializers.ModelSerializer):
class Meta:
model = Category
fields = ('url', 'id', 'name')
url = serializers.HyperlinkedIdentityField(
view_name=Category.get... | einsfr/mmkit2 | mmkitarchive/serializers.py | Python | mit | 1,495 |
# Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
"""
defines logger classes and few convinience methods, not related to the declarations
tree
"""
import os
import sys
import l... | daviddoria/itkHoughTransform | Wrapping/WrapITK/Languages/SwigInterface/pygccxml-1.0.0/pygccxml/utils/__init__.py | Python | apache-2.0 | 5,211 |
import os
import platform
from twisted.internet import defer
from .. import data, helper
from p2pool.util import pack
P2P_PREFIX = 'af4576ee'.decode('hex')
P2P_PORT = 10888
ADDRESS_VERSION = 50
RPC_PORT = 10889
RPC_CHECK = defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
'myriadcoinaddress' in ... | depboy/p2pool-depboy | p2pool/bitcoin/networks/myriad_groestl.py | Python | gpl-3.0 | 1,216 |
# Vetor de 5 posições
soma = 0
i = 1
vetor = []
while i <= 5:
n = int (input ("Digite um Número : "))
vetor.append (n)
i += 1
print ("Vetor : ", vetor)
| SANDEISON/Python | 03 - Atacando os tipos básicos/01 - Armazenando mais informações com as listas/02 - Vetor de 5 posicao.py | Python | gpl-2.0 | 178 |
#!/usr/bin/env python
'''
'''
import roslib; roslib.load_manifest('robbie')
import rospy
import time
import actionlib
from face_recognition.msg import *
from std_msgs.msg import String
from festival.srv import *
from datetime import datetime, timedelta
from time import localtime, strftime
class Greeting():
d... | peterheim1/robbie | bin/greeting_backup.py | Python | gpl-3.0 | 3,118 |
from __future__ import absolute_import
import responses
import mock
from sentry.testutils import TestCase
from sentry.models import Integration
class GitHubAppsClientTest(TestCase):
@mock.patch('sentry.integrations.github.client.get_jwt', return_value='jwt_token_1')
@responses.activate
def test_save_to... | looker/sentry | tests/sentry/integrations/github/test_client.py | Python | bsd-3-clause | 1,297 |
#!/usr/bin/python
# -*- coding: iso-8859-2 -*-
__version__ = (0, 0, 1, 2)
__author__ = "Lukasz Antczak"
__contact__ = "antczak.lukasz@hotmail.com"
__homepage__ = ""
__docformat__ = "restructuredtext"
#try:
# from django.conf import settings
# settings.INSTALLED_APPS.insert(0, 'cassango')
#except... | jabadabadu/cassango | cassango/__init__.py | Python | bsd-2-clause | 480 |
#!/usr/bin/env python
"""
Copyright (c) 2013-2018, Citrix Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of ... | xapi-project/message-switch | xapi-storage/python/xapi/__init__.py | Python | isc | 4,435 |
#!/usr/bin/env python
import os
import sys
import dotenv
dotenv.read_dotenv()
if __name__ == "__main__":
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'storageofknowledge.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Settings')
from configurations.management import execute_from_command_li... | ArtyomSliusar/StorageOfKnowledge | storageofknowledge/manage.py | Python | gpl-3.0 | 364 |
import caduc.timer
import caduc.image
import docker
import docker.utils
import docker.errors
import logging
import pytest
import sys
import time
import sure
import unittest
from caduc.cmd import create_watcher
from .. import mock
docker_error = None
no_docker = False
try:
docker.Client(**docker.utils.kwargs_from_... | tjamet/caduc | tests/integration/test_main.py | Python | gpl-3.0 | 6,652 |
#----------------------------------------------------------------------------
# Persistent element grouping support.
#
#----------------------------------------------------------------------------
# Copyright 2017, Martin Kolman
#
# This program is free software: you can redistribute it and/or modify
# it under the ter... | M4rtinK/tsubame | core/group.py | Python | gpl-3.0 | 3,816 |
from test_support import *
prove_all(steps=50000, prover=["cvc4", "altergo"])
| ptroja/spark2014 | testsuite/gnatprove/tests/P530-022__loopinv/test.py | Python | gpl-3.0 | 79 |
from sense_hat import SenseHat
import time, sys
sense = SenseHat()
sense.set_rotation(180)
red = [255,0,0]
orange = [255,127,0]
yellow = [255,255,0]
green = [0,255,0]
blue = [0,0,255]
indego = [75,0,130]
violet = [159,0,255]
black = [0,0,0]
x = [0,255,0]
o = [0,0,0]
r = [255,0,0]
frame_delay = 0.2
pause_delay = 2
r... | poslogic/Raspberry-Pi-Sense-Hat | invader.py | Python | gpl-3.0 | 2,399 |
import importlib
import logging
import sys
import textwrap
import unittest
from os.path import abspath, sep
from queue import Empty, Queue
from tempfile import mkdtemp
from threading import Thread
import pytest
from errbot.backends.base import ONLINE, Message, Person, Room, RoomOccupant
from errbot.bootstrap import s... | apophys/err | errbot/backends/test.py | Python | gpl-3.0 | 20,732 |
import pygame
WHITE = (255, 255, 255)
class Car(pygame.sprite.Sprite):
#This class represents a car. It derives from the "Sprite" class in Pygame.
def __init__(self, color, width, height):
# Call the parent class (Sprite) constructor
#super().__init__()
# Pass in the color... | stivosaurus/rpi-snippets | reference_scripts/car.py | Python | unlicense | 1,188 |
# Copyright (c) 2013 Mirantis 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 agreed to in writ... | sergmelikyan/murano | murano/engine/system/yaql_functions.py | Python | apache-2.0 | 9,663 |
#!/usr/bin/env python
# Time how long it takes to backup and recover the current ZAP session
# with a basic sanity check (counting the number of messages before and after recovery)
import datetime, time, sys, getopt
from pprint import pprint
from zapv2 import ZAPv2
def main(argv):
# -------------------------... | zapbot/zap-mgmt-scripts | zap-backup-test.py | Python | apache-2.0 | 2,576 |
#!/usr/bin/env python2.7
if __name__ == '__main__': print "Loading..."
######## IMPORTS ########
# system imports
import atexit, codecs, json, os, socket, subprocess, sys, time
# local imports
import database
from CloseableThread import CloseableThread
from AccountManager import AccountManager
from util import settin... | zaquestion/vendttp | server/server.py | Python | gpl-2.0 | 15,737 |
import os, re, subprocess, shlex, sys, yaml
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
from astropy.io import fits
import cosmics
#from pisco_lib import *
# edited 5/9/17
"""
pisco_combine: run pisco pipeline to reduce the raw data to clean data with correct WCS
The pip... | leogulus/pisco_pipeline | pisco_combine.py | Python | mit | 27,489 |
# convenience functions to skip over connecting the corpus
# from multi.celery_app import set_config
import multi.celery_app as celery_app
import db.corpora as cp
from proc.general_utils import getRootDir
def ez_connect(corpus="AAC", es_config=None):
"""
Simplifies connecting to the Corpus
:param corpus... | danieldmm/minerva | db/ez_connect.py | Python | gpl-3.0 | 957 |
"""
This file was generated with the custommenu management command, it contains
the classes for the admin menu, you can customize this class as you want.
To activate your custom menu add the following to your settings.py::
ADMIN_TOOLS_MENU = 'demo_admin_tools_zinnia.menu.CustomMenu'
"""
from django.core.urlresolv... | django-blog-zinnia/admin-tools-zinnia | demo_admin_tools_zinnia/menu.py | Python | bsd-3-clause | 1,323 |
#!/usr/bin/env python
#
# WebExtract v1.0
# A web-based utility to extract archive files for unix systems.
#
# @link http://github.com/farhadi/webextract
# @copyright Copyright 2010, Ali Farhadi (http://farhadi.ir/)
# @license GNU General Public License 3.0 (http://www.gnu.org/licenses/gpl.html)
#
import ... | farhadi/webextract | webextract.py | Python | gpl-3.0 | 6,622 |
from selenium.webdriver.support.select import Select
def get_selected_option(browser, css_selector):
# Takes a css selector for a <select> element and returns the value of
# the selected option
select = Select(browser.find_element_by_css_selector(css_selector))
return select.first_selected_option.get_a... | egineering-llc/egat_example_project | tests/test_helpers/selenium_helper.py | Python | mit | 338 |
#!/usr/bin/env python
import sys
import argparse
import subprocess
import ansi2html
import six
try:
import pexpect
except ImportError:
pexpect = None
class TeeFile:
def __init__(self, source, target, slow=True):
self.source = source
self.target = target
self.slow = slow
def __... | pyhedgehog/hook.io-sdk-python | helpers/colorlog.py | Python | unlicense | 3,259 |
# coding=utf-8
# Author: Dennis Lutter <lad1337@gmail.com>
#
# URL: https://sickrage.github.io
#
# This file is part of SickRage.
#
# SickRage 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 3 o... | b0ttl3z/SickRage | sickbeard/blackandwhitelist.py | Python | gpl-3.0 | 6,181 |
#####################################################################
# Example : kalman filtering based cam shift object track processing
# from a video file specified on the command line (e.g. python FILE.py
# video_file) or from an attached web camera
# N.B. u se mouse to select region
# Author : Toby Breckon, to... | tobybreckon/python-examples-cv | kalman_tracking_live.py | Python | lgpl-3.0 | 12,509 |
"""unique-property-association.py: compute properties that share the same (sub,obj)
Usage: unique-property-association.py prov-o-data.nt
"""
import os, os.path
import sys
import re
import unittest
import logging
import httplib
import urllib
import time
import StringIO
import codecs
from rdflib import Grap... | junszhao/ProvQ | src/analysis/unique-property-association.py | Python | apache-2.0 | 1,856 |
from . import statistics
from . import intervals | JelleAalbers/plunc | plunc/__init__.py | Python | mit | 48 |
"""Code ccollaborator review records."""
import csv
import subprocess
import tempfile
import urllib.parse
from ccollab2eeplatform.log import logger
from ccollab2eeplatform.ccollab.review_record import ReviewRecord
__all__ = ('fetch_review_records')
def _create_download_command(creation_date_lo, creation_date_hi):... | CVBDL/ccollab2eeplatform-python | ccollab2eeplatform/ccollab/review.py | Python | mit | 2,592 |
from __future__ import division
from six import with_metaclass
from abc import ABCMeta, abstractmethod
import numpy as np
from scipy import integrate
class BaseDiscretizer(with_metaclass(ABCMeta)):
"""
Base class for the discretizer classes in pgmpy. The discretizer
classes are used to discretize a cont... | sandeepkrjha/pgmpy | pgmpy/factors/continuous/discretize.py | Python | mit | 8,295 |
#!/usr/bin/env python
import os
import shutil
import sys
import ratemyflight
class ProjectException(Exception):
pass
def create_project():
"""
Copies the contents of the project_template directory to a new directory
specified as an argument to the command line.
"""
# Ensure a directory na... | stephenmcd/ratemyflight | ratemyflight/scripts/create_project.py | Python | bsd-2-clause | 1,581 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutClasses(Koan):
class Dog:
"Dogs need regular walkies. Never, ever let them drive."
def test_instances_of_classes_can_be_created_adding_parentheses(self):
# NOTE: The .__name__ attribute will convert the class
... | sourabhv/python-koans-solutions | python3/koans/about_classes.py | Python | mit | 4,953 |
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2018 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the h... | chipaca/snapcraft | snapcraft/internal/mountinfo.py | Python | gpl-3.0 | 3,392 |
class EventException(Exception):
"""
Event related Exception
"""
pass
class NotConcernedEvent(EventException):
"""
Exception raised when concerned ``SynergyObject`` is not concerned by Event.
"""
pass
class UselessMechanism(EventException):
"""
Exception raised when conce... | buxx/synergine | synergine/core/exceptions.py | Python | apache-2.0 | 483 |
from splicer import Splicer
from parser import Parser | Zephirot93/subs-audio-splicer | __init__.py | Python | mit | 53 |
#
# Unit tests for the multiprocessing package
#
import unittest
import queue as pyqueue
import time
import io
import itertools
import sys
import os
import gc
import errno
import signal
import array
import socket
import random
import logging
import struct
import operator
import test.support
import... | Orav/kbengine | kbe/src/lib/python/Lib/test/_test_multiprocessing.py | Python | lgpl-3.0 | 124,102 |
# encoding: utf-8
from __future__ import unicode_literals
import re
import itertools
from .common import InfoExtractor
from ..utils import (
compat_str,
compat_urlparse,
compat_urllib_parse,
ExtractorError,
int_or_none,
unified_strdate,
)
class SoundcloudIE(InfoExtractor):
"""Informatio... | raymondanthony/youtube-dl | youtube_dl/extractor/soundcloud.py | Python | unlicense | 14,108 |
import os
source = '../src/Stats.js'
output = '../build/stats.min.js'
os.system('java -jar compiler/compiler.jar --language_in=ECMASCRIPT5 --js ' + source + ' --js_output_file ' + output)
with open(output,'r') as f: text = f.read()
with open(output,'w') as f: f.write("// stats.js - http://github.com/mrdoob/stats.js\n" ... | HustLion/HustLionToolkit | linux/usage/closure.py | Python | mit | 328 |
import os
import logging
from thug.ThugAPI.ThugAPI import ThugAPI
log = logging.getLogger("Thug")
class TestMiscSamplesIE(object):
cwd_path = os.path.dirname(os.path.realpath(__file__))
misc_path = os.path.join(cwd_path, os.pardir, "samples/misc")
def do_perform_test(self, caplog, sample, expected):
... | buffer/thug | tests/functional/test_misc_ie110.py | Python | gpl-2.0 | 36,903 |
from model.contact import Contact
testdata = [
Contact(firstname="firstname1", middlename="middlename1", lastname="lastname1", nickname="nickname1", title="title1", company="company1",
address="address1", homephone="homephone1", mobilephone="mobilephone1", workphone="workphone1", fax="fax1", email1="em... | tucan21/python_zadania | data/contacts.py | Python | apache-2.0 | 782 |
class Fib(object):
@staticmethod
def fib(n):
if n <= 1:
return n
return Fib.fib(n - 1) + Fib.fib(n - 2)
| spark008/igor | test/fixtures/files/submission/slow_fib.py | Python | mit | 140 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.