text stringlengths 6 947k | repo_name stringlengths 5 100 | path stringlengths 4 231 | language stringclasses 1
value | license stringclasses 15
values | size int64 6 947k | score float64 0 0.34 |
|---|---|---|---|---|---|---|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__init__
---------
Contains testing helpers.
"""
import os
import shutil
import stat
import sys
if sys.version_info[:2] < (2, 7):
import unittest2 as unittest
else:
import unittest
def force_delete(func, path, exc_info):
"""
Error handler for `shuti... | ericholscher/cookiecutter | tests/__init__.py | Python | bsd-3-clause | 3,893 | 0.003596 |
#!/usr/bin/env python3
# _*_ coding: utf-8 _*_
u""" One way of implementing default dictionary. """
class DefaultDict(dict):
def __missing__(self, key):
u""" Return default value as key if no value specified dictionary key. """
return key
if __name__ == "__main__":
d = DefaultDict()
pri... | sjh/python | default_dict.py | Python | apache-2.0 | 477 | 0.002096 |
###################################################################################################
#
# PySpice - A Spice Package for Python
# Copyright (C) 2014 Fabrice Salvaire
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published ... | thomaslima/PySpice | PySpice/Spice/Simulation.py | Python | gpl-3.0 | 14,801 | 0.004256 |
# Copyright 2018 The TensorFlow 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://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | derekjchow/models | research/slim/nets/mobilenet/conv_blocks.py | Python | apache-2.0 | 13,351 | 0.005243 |
class Solution(object):
def firstMissingPositive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
l = len(nums)
for i in range(0, l):
cur = nums[i]
while cur >= 1 and cur <= l and nums[cur - 1] != cur:
tmp = nums[cur - 1]
... | hawkphantomnet/leetcode | FirstMissingPositive/Solution.py | Python | mit | 495 | 0.00202 |
import copy
import datetime
import decimal
import math
import warnings
from itertools import tee
from django.db import connection
from django.db.models.query_utils import QueryWrapper
from django.conf import settings
from django import forms
from django.core import exceptions, validators
from django.utils.datastructur... | klnprj/testapp | django/db/models/fields/__init__.py | Python | bsd-3-clause | 47,219 | 0.000911 |
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
import jsonfield
from .hooks import hookset
from .utils import load_path_attr
class UserState(models.Model):
"""
this stores the overall state of a particular user.
"""
user = models.OneToOneFi... | pinax/pinax-lms-activities | pinax/lms/activities/models.py | Python | mit | 4,304 | 0.000465 |
"""
Fichier main qui lance le programme
"""
from Game import *
game = Game()
game.play()
| Vodak/SINS | src/main.py | Python | gpl-3.0 | 91 | 0 |
#
# 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, software
# ... | cwolferh/heat-scratch | heat/db/sqlalchemy/migrate_repo/versions/071_stack_owner_id_index.py | Python | apache-2.0 | 897 | 0 |
"""
The main QuerySet implementation. This provides the public API for the ORM.
"""
import copy
import itertools
import sys
from django.core import exceptions
from django.db import connections, router, transaction, IntegrityError
from django.db.models.fields import AutoField
from django.db.models.query_utils import (... | kennethlove/django | django/db/models/query.py | Python | bsd-3-clause | 70,273 | 0.001352 |
# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, absolute_import,
division, print_function)
import sys
import os
import pytest
from contextlib import contextmanager
import genpac
from genpac._compat import string_types, iterkeys, iteritems
parametrize = pytest.mark.parametrize... | JinnLynn/genpac | tests/util.py | Python | mit | 1,389 | 0.002185 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from module.plugins.Hoster import Hoster
from module.plugins.internal.CaptchaService import ReCaptcha
class FreakshareCom(Hoster):
__name__ = "FreakshareCom"
__type__ = "hoster"
__pattern__ = r"http://(?:www\.)?freakshare\.(net|com)/files/\S*?/"
... | wangjun/pyload | module/plugins/hoster/FreakshareCom.py | Python | gpl-3.0 | 6,038 | 0.004306 |
class TaskMappingSchemesFullyDyn:
TASKMAPPINGSCHEMESFULLYDYN_NONE = 0 # this will give error
TASKMAPPINGSCHEMESFULLYDYN_RANDOM = 1
TASKMAPPINGSCHEMESFULLYDYN_LOWESTUTIL_NEARESTPARENT = 2
| roshantha9/AbstractManycoreSim | src/libMappingAndScheduling/FullyDynamic/TaskMappingSchemesFullyDyn.py | Python | gpl-3.0 | 320 | 0.028125 |
################################################################################
## ##
## This file is a part of TADEK. ##
## ... | tadek-project/tadek-common | tadek/core/location.py | Python | gpl-3.0 | 9,460 | 0.008985 |
import numpy as np
from menpo.model import PCAModel
from menpo.visualize import print_progress
def prune(weights, n_retained=50):
w_norm = (weights[:, :n_retained] ** 2).sum(axis=1)
# High weights here suggest problematic samples
bad_to_good_index = np.argsort(w_norm)[::-1]
return w_norm, bad_to_good_... | menpo/lsfm | lsfm/model.py | Python | bsd-3-clause | 968 | 0 |
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
from django.views.generic import TemplateView
urlpatterns = patterns('',
# Examples:
url(r'^$', TemplateView.as_v... | fatrix/django-golive | project_examples/django_example/django_example/urls.py | Python | bsd-2-clause | 801 | 0.007491 |
import urllib
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
@register.tag
def query_string(parser, token):
"""
Allows to manipulate the query string of a page by adding and removing keywords.
If a given value is a context variable it will resolve... | DigitalCampus/django-nurhi-oppia | oppia/templatetags/query_string.py | Python | gpl-3.0 | 2,788 | 0.002511 |
class Invalid_IP_exception(Exception):
pass
| mikesligo/distributed-search | Exceptions/Invalid_IP_exception.py | Python | mit | 48 | 0 |
import os
from setuptools import setup
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.di... | eemiliosl/pyanno_voting | setup.py | Python | bsd-2-clause | 916 | 0.021834 |
'''
WikiLinks Extension for Python-Markdown
======================================
Converts [[WikiLinks]] to relative links.
See <https://pythonhosted.org/Markdown/extensions/wikilinks.html>
for documentation.
Original code Copyright [Waylan Limberg](http://achinghead.com/).
All changes Copyright The Python Markdo... | andela-bojengwa/talk | venv/lib/python2.7/site-packages/markdown/extensions/wikilinks.py | Python | mit | 2,901 | 0.005515 |
from flask import (Module, request, abort, current_app, session, flash,
redirect, render_template)
import re
mod = Module(__name__, name="auth")
def check_next(next):
"""return the value of next if next is a valid next param,
it returns None if the next param is invalid"""
# security ch... | ericmoritz/flask-auth | flaskext/auth/views.py | Python | bsd-2-clause | 2,020 | 0.00198 |
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | google-research/language | language/xsp/data_preprocessing/wikisql_preprocessing.py | Python | apache-2.0 | 5,129 | 0.008384 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
class MiClase:
@staticmethod
def metodo(entrada):
return entrada
objeto = MiClase
print objeto.metodo(5)
| psicobyte/ejemplos-python | ApendiceI/p202.py | Python | gpl-3.0 | 167 | 0.005988 |
# Copyright 2017 The TensorFlow 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://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | tensorflow/tensorboard | tensorboard/backend/event_processing/plugin_asset_util.py | Python | apache-2.0 | 3,555 | 0.000281 |
#!/usr/bin/python
#
# Copyright (c) 2011 The Chromium OS Authors.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# 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; eit... | renesas-rz/u-boot-2013.04 | tools/patman/patman.py | Python | gpl-2.0 | 6,763 | 0.001774 |
""" Django settings """
from django.core.urlresolvers import reverse_lazy
DEBUG = True
TEMPLATE_DEBUG = DEBUG
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
TEMPLATE_STRING_IF_INVALID = '**** INVALID EXPRESSION: %s ****'
ADMINS = (
('admin', 'code@pkimber.net'),
)
MANAGERS = ADMINS
# Local time zone... | pkimber/old_moderate | example/base.py | Python | apache-2.0 | 5,826 | 0.000515 |
from chainer.functions.activation import relu
from chainer import link
from chainer.links.connection import convolution_2d
class MLPConvolution2D(link.ChainList):
"""Two-dimensional MLP convolution layer of Network in Network.
This is an "mlpconv" layer from the Network in Network paper. This layer
is a... | benob/chainer | chainer/links/connection/mlp_convolution_2d.py | Python | mit | 3,009 | 0.000332 |
import pygame
from fish import Fish
from seaweed import Seaweed
class Water:
def __init__(self):
# color, pos_x, pos_y, width, height
self.mOrangeFish = Fish((255, 152, 0), 50, 175, 175, 100)
self.mGreyFish = Fish((96, 125, 139), 350, 130, 125, 200)
self.mRedFish = Fish((183, 28, 28), 200, 300, 175, 50... | joshl8n/school-projects | illustrate/water.py | Python | gpl-3.0 | 1,287 | 0.034188 |
"""
Tests for module recommendation.
"""
| hypermindr/barbante | barbante/recommendation/tests/__init__.py | Python | mit | 41 | 0 |
from pycket import values
from pycket.error import SchemeException
from pycket.hash.base import (
W_MutableHashTable,
W_ImmutableHashTable,
w_missing,
get_dict_item)
from pycket.hash.persistent_hash_map import make_persistent_hash_type
from rpy... | magnusmorton/pycket | pycket/hash/simple.py | Python | mit | 6,811 | 0.002496 |
import sys
if sys.version_info[0] == 2:
from urlparse import urljoin
string_types = basestring,
else:
from urllib.parse import urljoin
string_types = str,
def atoi(string, default=0):
if (isinstance(string, int)):
return string
try:
return int(string)
except (TypeError, ... | ZipFile/papi.py | papi/helpers.py | Python | bsd-2-clause | 356 | 0 |
import hmac
import config
from jinja2 import Environment, FileSystemLoader
jinja2_env = Environment(loader=FileSystemLoader(
config.TEMPLATE_DIRS), autoescape=True)
class BaseHandler(object):
def __init__(self):
self.request = None
self.response = None
def make_secure_value(self, value):... | xstrengthofonex/code-live-tutorials | python_web_development/database/handlers/base_handler.py | Python | mit | 1,866 | 0.000536 |
"""
Tests third_party_auth admin views
"""
import unittest
from django.contrib.admin.sites import AdminSite
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse
from django.forms import models
from student.tests.factories import UserFactory
from third_party_auth.a... | lduarte1991/edx-platform | common/djangoapps/third_party_auth/tests/test_admin.py | Python | agpl-3.0 | 3,696 | 0.001353 |
# Copyright (C) 2019-2021 Dmitry Marakasov <amdmi3@amdmi3.ru>
#
# This file is part of repology
#
# repology 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 optio... | repology/repology | repology/parsers/parsers/t2.py | Python | gpl-3.0 | 4,354 | 0.002067 |
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt
"""
# Integrating PayPal
### 1. Validate Currency Support
Example:
from frappe.integrations.utils import get_payment_gateway_controller
controller = get_payment_gateway_controller(... | ESS-LLP/frappe | frappe/integrations/doctype/paypal_settings/paypal_settings.py | Python | mit | 12,324 | 0.022558 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright: Ansible Project
# 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
ANSIBLE_METADATA = {'metadata_version': '1.1',
... | dataxu/ansible | lib/ansible/modules/cloud/vmware/vmware_guest_find.py | Python | gpl-3.0 | 4,032 | 0.002232 |
#coding=utf-8
from docker import Client
import time
import logging
from envir import config
import ast
import re
log = logging.getLogger(__name__)
class DockerOpt:
def __init__(self):
app_config = config.read_app_config()
self.app = app_config
self.url = app_config['docker']['url']
... | xyalan/build-interpreter | docker_tools/docker_opt.py | Python | apache-2.0 | 2,738 | 0.002191 |
#!python2
from random import randint
from boids import *
import sys,pygame,time,copy
screenx = 800
screeny = 600
ticktime = 0.01
fps = 80
clock = pygame.time.Clock()
size = screenx,screeny
pygame.init()
screen = pygame.display.set_mode(size)
time = 0
def gen_boids(x,y,low,upper):
nboids = randint(low,upper)
b... | jsfyfield/pyboids | gfx_boids.py | Python | gpl-2.0 | 1,867 | 0.024103 |
from datetime import datetime
from casexml.apps.stock.models import StockReport, StockTransaction
from corehq.apps.commtrack.const import RequisitionStatus
from corehq.apps.commtrack.models import RequisitionCase
from casexml.apps.case.models import CommCareCase
from corehq.apps.commtrack.tests.util import CommTrackTes... | gmimano/commcaretest | corehq/apps/commtrack/tests/test_sms_reporting.py | Python | bsd-3-clause | 9,297 | 0.003442 |
__author__ = 'Dominik Krupke, dserv01.de'
#
# While you want to listen to lossless music on your computer you may not be able to also listen to it mobile because
# it takes too much space. A 32GB-SDCard does not suffice for your full music library so you only have the options to
# either only hearing to a subset mobil... | dserv01/SyncLosslessToLossyMusicLibrary | SyncLosslessToLossyMusicLibrary.py | Python | gpl-2.0 | 6,785 | 0.005601 |
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import sys
import time
import numpy
import struct
import logging
import threading
# tango imports
import tango
from tango import GreenMod... | tiagocoutinho/bliss | bliss/tango/servers/nanobpm_ds.py | Python | lgpl-3.0 | 19,010 | 0.00526 |
import os
import re
from os import system, popen, path as os_path, listdir
from Screens.Screen import Screen
from Components.Harddisk import *
from Components.Sources.StaticText import StaticText
from Components.ActionMap import ActionMap, NumberActionMap
from FactoryTestPublic import *
import time
from enigma import ... | openpli-arm/enigma2-arm | lib/python/Plugins/Extensions/FactoryTest/NetworkTest.py | Python | gpl-2.0 | 16,179 | 0.033191 |
import os
path = os.path.dirname(os.path.realpath(__file__))
sbmlFilePath = os.path.join(path, 'BIOMD0000000370.xml')
with open(sbmlFilePath,'r') as f:
sbmlString = f.read()
def module_exists(module_name):
try:
__import__(module_name)
except ImportError:
return False
else:
ret... | biomodels/BIOMD0000000370 | BIOMD0000000370/model.py | Python | cc0-1.0 | 427 | 0.009368 |
#!/usr/bin/env python
"""
Regular Expression Matching
Implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
The function prototype should be:
bool isMatc... | weixsong/algorithm | leetcode/10.py | Python | mit | 1,638 | 0.002463 |
# nvprof --print-gpu-trace python examples/stream/thrust.py
import cupy
x = cupy.array([1, 3, 2])
expected = x.sort()
cupy.cuda.Device().synchronize()
stream = cupy.cuda.stream.Stream()
with stream:
y = x.sort()
stream.synchronize()
cupy.testing.assert_array_equal(y, expected)
stream = cupy.cuda.stream.Stream()
... | cupy/cupy | examples/stream/thrust.py | Python | mit | 412 | 0 |
import logging
import os
import site
import time
import typing
from argparse import ArgumentParser
import waitress
from flask import Flask
import cauldron as cd
from cauldron import environ
from cauldron import templating
from cauldron.render.encoding import ComplexFlaskJsonEncoder
from cauldron.session import writin... | sernst/cauldron | cauldron/cli/server/run.py | Python | mit | 4,787 | 0 |
"""User-friendly exception handler for swood."""
import http.client
import traceback
import sys
import os
__file__ = os.path.abspath(__file__)
class ComplainToUser(Exception):
"""When used with ComplaintFormatter, tells the user what error (of theirs) caused the failure and exits."""
pass
def can_submit():... | milkey-mouse/swood | swood/complain.py | Python | mit | 4,905 | 0.003262 |
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source
# & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 +
#pylint: disable=no-init,attribute-defined-ou... | mganeva/mantid | Testing/SystemTests/tests/analysis/EQSANSFlatTestAPIv2.py | Python | gpl-3.0 | 3,330 | 0.001201 |
"""Functions for workloads."""
from utils.conf import cfme_performance
def get_capacity_and_utilization_replication_scenarios():
if 'test_cap_and_util_rep' in cfme_performance.get('tests', {}).get('workloads', []):
if (cfme_performance['tests']['workloads']['test_cap_and_util_rep']['scenarios'] and
... | dajohnso/cfme_tests | utils/workloads.py | Python | gpl-2.0 | 3,720 | 0.008602 |
# -*- coding: utf-8 -*-
#
# This class was auto-generated from the API references found at
# https://epayments-api.developer-ingenico.com/s2sapi/v1/
#
from ingenico.connect.sdk.data_object import DataObject
from ingenico.connect.sdk.domain.payment.definitions.customer_account_authentication import CustomerAccountAuthen... | Ingenico-ePayments/connect-sdk-python2 | ingenico/connect/sdk/domain/payment/definitions/customer_account.py | Python | mit | 10,943 | 0.005209 |
from sympy import Basic
from sympy.printing.mathml import mathml
import tempfile
import os
def print_gtk(x, start_viewer=True):
"""Print to Gtkmathview, a gtk widget capable of rendering MathML.
Needs libgtkmathview-bin"""
from sympy.utilities.mathml import c2p
tmp = tempfile.mktemp() # create a temp ... | hazelnusse/sympy-old | sympy/printing/gtk.py | Python | bsd-3-clause | 498 | 0.008032 |
"""Add rtp_task_multiple_process_event table
Revision ID: 5feda4ca9935
Revises: 9d9af47e64c8
Create Date: 2021-09-30 16:22:30.118641+00:00
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "5feda4ca9935"
down_revision = "... | HERA-Team/hera_mc | alembic/versions/5feda4ca9935_add_rtp_task_multiple_process_event_table.py | Python | bsd-2-clause | 1,093 | 0.000915 |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may ... | Azure/azure-sdk-for-python | sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_08_01/operations/_azure_firewalls_operations.py | Python | mit | 26,909 | 0.004645 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from httpwookiee.config import ConfigFactory
from httpwookiee.core.tools import Tools, outmsg, inmsg
from httpwookiee.http.parser.responses import Responses
import socket
import ipaddress
import ssl
import six
class ClosedSocketError(Exception):
"""Raise this when... | regilero/HTTPWookiee | httpwookiee/http/client.py | Python | gpl-3.0 | 6,832 | 0.000146 |
from nose.tools import * # flake8: noqa
from api.base import settings
from tests.base import ApiTestCase
# The versions below are specifically for testing purposes and do not reflect the actual versioning of the API.
# If changes are made to this list, or to DEFAULT_VERSION, please reflect those changes in:
# api/... | acshi/osf.io | api_tests/base/test_versioning.py | Python | apache-2.0 | 6,291 | 0.003656 |
from django.conf import settings as dj_settings
from django.db import models, transaction
from django.core.signals import got_request_exception
from django.http import Http404
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
from djangodblog import settings
from d... | alvinkatojr/django-db-log | djangodblog/models.py | Python | bsd-3-clause | 5,442 | 0.006248 |
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
class PyNestAsyncio(PythonPackage):
"""Patch asyncio to allow nested event loops."""
homepage = "https://github.... | iulian787/spack | var/spack/repos/builtin/packages/py-nest-asyncio/package.py | Python | lgpl-2.1 | 633 | 0.004739 |
#! /usr/bin/env python
'''
Generates Inkscape SVG file containing box components needed to create several different
types of laser cut tabbed boxes.
Derived from original version authored by elliot white - elliot@twot.eu
This program is free software: you can redistribute it and/or modify
it under the terms of the GN... | zackurtz/box-maker | boxmaker.py | Python | gpl-3.0 | 10,763 | 0.047849 |
from __future__ import print_function, absolute_import
import cv2
import numpy as np
import sys, os
path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(path)
import visual_auxiliary as va
def is_center_blue_line(lbot):
frame = lbot.getImage()
if frame is not None:
rois = va.detect_blue_line(frame)
... | robocomp/learnbot | learnbot_dsl/functions/perceptual/camera/is_center_blue_line.py | Python | gpl-3.0 | 418 | 0.028708 |
# -*- coding: utf-8 -*-
"""
Internal function called by glmnet. See also glmnet, cvglmnet
"""
# import packages/methods
import scipy
import ctypes
from loadGlmLib import loadGlmLib
def elnet(x, is_sparse, irs, pcs, y, weights, offset, gtype, parm, lempty,
nvars, jd, vp, cl, ne, nx, nlam, flmin, ulam, ... | hanfang/glmnet_python | glmnet_python/elnet.py | Python | gpl-2.0 | 8,525 | 0.029795 |
from django.shortcuts import get_object_or_404
from django.views.generic import DetailView, ListView
from braces.views import OrderableListMixin
from .models import Post, Tag
ORDER_FIELD = {'title': 'title'}
class PermissionMixin(object):
def get_queryset(self, *args, **kwargs):
qs = super(PermissionMix... | ad-m/pru | pru/blog/views.py | Python | bsd-3-clause | 1,186 | 0 |
import random
import numpy as np
from tpg.learner import Learner
from tpg.action_object import ActionObject
from tpg.program import Program
from tpg.team import Team
dummy_init_params = {
'generation': 0,
'actionCodes':[
0,1,2,3,4,5,6,7,8,9,10,11
]
}
dummy_mutate_params = {
'pProgMut': 0.5,... | Ryan-Amaral/PyTPG | tpg_tests/test_utils.py | Python | mit | 2,999 | 0.015005 |
#
# Generated by the Open ERP module recorder !
#
| avanzosc/avanzosc6.1 | steel_quality_test/__init__.py | Python | agpl-3.0 | 50 | 0 |
"""Webhook handlers for mobile_app."""
import asyncio
from functools import wraps
import logging
import secrets
from aiohttp.web import HTTPBadRequest, Request, Response, json_response
from nacl.secret import SecretBox
import voluptuous as vol
from homeassistant.components import notify as hass_notify, tag
from homea... | tchellomello/home-assistant | homeassistant/components/mobile_app/webhook.py | Python | apache-2.0 | 18,676 | 0.00075 |
#!/usr/bin/python2.7
# -*- encoding=utf-8 -*-
from argparse import ArgumentParser, RawTextHelpFormatter
import codecs
import gevent
from gevent import monkey
import json
from types import UnicodeType
from crawlers import Crawler
from crawlers.local.static import get_election_type_name
from utils import check_dir
def... | teampopong/crawlers | election_commission/main.py | Python | agpl-3.0 | 4,602 | 0.007388 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This is a virtual module that is entirely implemented as an action plugin and runs on the controller
from __future__ import absolute_import, ... | Dhivyap/ansible | lib/ansible/modules/files/template.py | Python | gpl-3.0 | 2,564 | 0.00234 |
import os
def run(name='test1.py'):
filename = os.getcwd() + name
exec(compile(open(filename).read(), filename, 'exec'))
| karljakoblarsson/Rattan-Geometry | Utils.py | Python | mit | 130 | 0.007692 |
from selenium.webdriver.common.by import By
from SeleniumPythonFramework.src.main.Pages.CommonPage import CommonPage
# Production locations
TRY_TEXT = {"by": By.ID, "locator": "url-input"}
TRY_BUTTON = {"by": By.ID, "locator": "get-data"}
PATH = ""
class HomePage(CommonPage):
def __init__(self, **kwargs):
... | GinoGalotti/python-selenium-utils | SeleniumPythonFramework/src/main/Pages/HomePage.py | Python | apache-2.0 | 710 | 0 |
# Encas Sales Management Server
# Copyright 2013 - Hugo Caille
#
# This file is part of Encas.
#
# Encas 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
# (a... | hugoatease/encas | errors.py | Python | gpl-3.0 | 2,359 | 0.010598 |
from __future__ import print_function
import os
import sys
import subprocess
import pkg_resources
try:
import pkg_resources
_has_pkg_resources = True
except:
_has_pkg_resources = False
try:
import svn.local
_has_svn_local = True
except:
_has_svn_local = False
def test_helper():
return... | MetaPlot/MetaPlot | metaplot/helpers.py | Python | mit | 4,900 | 0.008776 |
"""
TAGME implementation
@author: Faegheh Hasibi (faegheh.hasibi@idi.ntnu.no)
"""
import argparse
import math
from nordlys.config import OUTPUT_DIR
from nordlys.tagme import config
from nordlys.tagme import test_coll
from nordlys.tagme.query import Query
from nordlys.tagme.mention import Mention
from nordlys.tagme.lu... | hasibi/TAGME-Reproducibility | nordlys/tagme/tagme.py | Python | mit | 11,198 | 0.001875 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# this is a windows documentation stub. actual code lives in the .ps1
# file of the same name
ANSIBLE_METADATA = {'metadata_version': '1.1',
... | alxgu/ansible | lib/ansible/modules/windows/win_xml.py | Python | gpl-3.0 | 2,841 | 0.00176 |
import functools
import re
import pytest
from autoray import do, lazy, to_numpy, infer_backend, get_dtype_name, astype
from numpy.testing import assert_allclose
from .test_autoray import BACKENDS, gen_rand
def test_manual_construct():
def foo(a, b, c):
a1, a2 = a
b1 = b['1']
c1, c2 = c... | jcmgray/autoray | tests/test_lazy.py | Python | apache-2.0 | 11,880 | 0 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
import curses
import cumodoro.config as config
import cumodoro.interface as interface
import cumodoro.globals as globals
from cumodoro.cursest import Refresher
import logging
log = logging.getLogger('cumodoro')
def set_title(msg):
print("\x1B]0;... | gisodal/cumodoro | cumodoro/main.py | Python | mit | 765 | 0.007843 |
"""
Stores application data.
"""
# standard libraries
import copy
import json
import pathlib
import threading
import typing
# third party libraries
from nion.swift.model import Utility
from nion.utils import Event
from nion.utils import StructuredModel
class ApplicationData:
"""Application data is a singleton t... | nion-software/nionswift | nion/swift/model/ApplicationData.py | Python | gpl-3.0 | 3,883 | 0.004378 |
beta = 5 # "beta" value in adiabatic correction to wind profile
Cd = 840.0 # heat capacity of mineral component of soil, J/kg/K
Co = 1920.0 # heat capacity of organic component of soil, J/kg/K
Cp = 1004.67 # specific heat of dry air at constant pressure, J/kg-K
Cpd = 1004.67 # specific heat of dry air a... | OzFlux/PyFluxPro | scripts/constants.py | Python | gpl-3.0 | 4,163 | 0.017535 |
#!/usr/bin/python
# Copyright (c) 2015 VMware, Inc. All Rights Reserved.
#
# This file is part of Ansible
#
# Ansible 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 ... | muffl0n/ansible-modules-extras | cloud/vmware/vca_fw.py | Python | gpl-3.0 | 14,207 | 0.011755 |
# ------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------
from nose.tools import with_setup
import subprocess
import requests
import os
from .. import util
import time
import json
# -------------------------------... | Verizon/hlx | tests/blackbox/examples/bb_test_basic.py | Python | apache-2.0 | 1,993 | 0.002509 |
import _plotly_utils.basevalidators
class TokenValidator(_plotly_utils.basevalidators.StringValidator):
def __init__(self, plotly_name="token", parent_name="histogram2d.stream", **kwargs):
super(TokenValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
... | plotly/plotly.py | packages/python/plotly/plotly/validators/histogram2d/stream/_token.py | Python | mit | 499 | 0.002004 |
"""New song class to work with a plain text song file format"""
import os
import re
chord_regex = re.compile("[A-G][1-9#bminajsugd]*[/]*[A-G]*[1-9#bminajsugd]*")
valid_chords = "ABCDEFGb#minajsugd123456789"
not_chords = "HJKLOPQRTVWXYZ\n"
class Chord(object):
"""Represents a single chord within a song file"""
... | brownjm/praisetex | song.py | Python | gpl-3.0 | 2,932 | 0.006139 |
# -*- coding: utf-8 -*-
"""
Django settings for pfa project.
For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""
from __future__ import absolute_import, unicode_literal... | fretscha/pfa | config/settings/common.py | Python | bsd-3-clause | 8,513 | 0.000822 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2014, Martín Gaitán
# Copyright (c) 2012-2013, Alexander Jung-Loddenkemper
# This file is part of Waliki (http://waliki.nqnwebs.com/)
# License: BSD (https://github.com/mgaitan/waliki/blob/master/LICENSE)
#============================================... | mgaitan/waliki_flask | waliki/extensions/uploads.py | Python | bsd-3-clause | 4,692 | 0.008316 |
no_inputs = int(raw_input())
for i in range (0, no_inputs):
n, k, t, f = map(int, raw_input().split())
answer = n + k*((f-n)/(k-1))
print answer | prabodhprakash/problemsolving | spoj/EBOXES.py | Python | mit | 148 | 0.033784 |
#! /usr/bin/env python
# coding:utf8
from argparse import ArgumentParser
import os
import sys
PATH_OF_THIS_SCRIPT = os.path.split(os.path.realpath(__file__))[0]
sys.path.insert(0, os.path.join(PATH_OF_THIS_SCRIPT, ".."))
import GetOrganelleLib
from GetOrganelleLib.pipe_control_func import *
from GetOrganelleLib.seq_pa... | Kinggerm/GetOrganelle | Utilities/evaluate_assembly_using_mapping.py | Python | gpl-3.0 | 29,914 | 0.005517 |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.1 on 2016-10-18 15:02
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("froide_campaign", "0007_campaign_subject_template"),
]
operations = [
migra... | okfde/froide-campaign | froide_campaign/migrations/0008_campaignpage.py | Python | mit | 1,181 | 0.000847 |
"""
Multiple stacked lstm implemeation on the lip movement data.
Akm Ashiquzzaman
13101002@uap-bd.edu
Fall 2016
"""
from __future__ import print_function
import numpy as np
np.random.seed(1337)
#random seed fixing for reproducibility
#data load & preprocessing
X_train = np.load('../data/videopart43.npy').astype('fl... | zamanashiq3/code-DNN | time_dis_cnn.py | Python | mit | 2,449 | 0.02205 |
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar)
# All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Pu... | smartforceplus/SmartForceplus | openerp/addons/project_stage/__openerp__.py | Python | agpl-3.0 | 1,603 | 0 |
from datetime import datetime
import csv
import pandas
import os
import sys
os.chdir(sys.argv[1])
ticker_f = open(sys.argv[2], "rb")
ticker_reader = csv.reader(ticker_f)
tickers = [r[0] for r in ticker_reader][1:]
ticker_f.close()
tln = len(tickers)
t_1 = datetime.now()
# build full data frame
res = None
for i, t i... | lbybee/NVLDA | code/build_dataset.py | Python | gpl-2.0 | 865 | 0.002312 |
#!/usr/bin/env python
#want to display file contents
#testing display code
import pyperclip
import re
import subprocess
import os,sys,time
counter=1
already_checked=''
def get_extension(file_name):
if file_name.find('.')!=-1:
ext = file_name.split('.')
return (ext[1])
else:
retu... | nikhilponnuru/codeCrumbs | code/code_display.py | Python | mit | 3,605 | 0.035229 |
import os,sys,django
sys.path.append(os.path.dirname(os.path.abspath('.')))
os.environ["DJANGO_SETTINGS_MODULE"] = 'skill_huddle.settings'
django.setup()
from sh_app.models import SH_User,League,Suggestion,Huddle
from django.contrib.auth.models import User
from django_countries import countries
from localflavor.us.us... | skill-huddle/skill-huddle | dummy_data/populatedb.py | Python | mit | 10,113 | 0.014734 |
##
# Copyright 2016 DECaF Project Group, University of Paderborn
# This file is part of the decaf orchestration framework
# All Rights Reserved.
#
# 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 htt... | CN-UPB/OpenBarista | utils/decaf-utils-protocol-stack/decaf_utils_protocol_stack/rpc/json_rpc_application.py | Python | mpl-2.0 | 7,693 | 0.0039 |
import pytest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
@pytest.fixture(scope='function')
def browser(request):
browser_ = webdriver.Firefox()
def fin():
browser_.quit()
request.addfinalizer(fin)
return browser_
def test_can_show_a_relevant_code_snippet... | jvanbrug/scout | functional_tests.py | Python | mit | 1,460 | 0 |
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2013, Numenta, Inc. Unless you have purchased from
# Numenta, Inc. a separate commercial license for this software code, the
# following terms and conditions apply:
#
# This pro... | tkaitchuck/nupic | examples/prediction/experiments/confidenceTest/2/description.py | Python | gpl-3.0 | 2,040 | 0.005392 |
from flask.ext.restplus import Namespace
from app.models.track import Track as TrackModel
from .helpers import custom_fields as fields
from .helpers.helpers import (
can_create,
can_update,
can_delete,
requires_auth
)
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \
... | gaeun/open-event-orga-server | app/api/tracks.py | Python | gpl-3.0 | 3,167 | 0.000316 |
from gpaw import GPAW
from gpaw.lrtddft import LrTDDFT
c = GPAW('Be_gs_8bands.gpw')
dE = 10 # maximal Kohn-Sham transition energy to consider in eV
lr = LrTDDFT(c, xc='LDA', energy_range=dE)
lr.write('lr_dE.dat.gz')
| robwarm/gpaw-symm | doc/documentation/tddft/Be_8bands_lrtddft_dE.py | Python | gpl-3.0 | 218 | 0.004587 |
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | EmreAtes/spack | lib/spack/spack/test/sbang.py | Python | lgpl-2.1 | 6,406 | 0.001405 |
# -*- coding: utf-8 -*-
import unittest
from khayyam import algorithms_c as alg_c
from khayyam import algorithms_pure as alg_p
__author__ = 'vahid'
# TODO: test with negative values
class TestCAlgorithms(unittest.TestCase):
def test_get_julian_day_from_gregorian(self):
self.assertRaises(ValueError, alg_p... | pylover/khayyam | khayyam/tests/test_algorithms.py | Python | gpl-3.0 | 4,401 | 0.002954 |
import pynamics
import numpy
import logging
logger = logging.getLogger('pynamics.integration')
def integrate(*args,**kwargs):
if pynamics.integrator==0:
return integrate_odeint(*args,**kwargs)
elif pynamics.integrator==1:
newargs = args[0],args[2][0],args[1],args[2][-1]
return... | idealabasu/code_pynamics | python/pynamics/integration.py | Python | mit | 1,030 | 0.017476 |
from .nes import Nes
from .bus.devices.cartridge import CartridgeFactory
| Hexadorsimal/pynes | nes/__init__.py | Python | mit | 73 | 0 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Flowroute LLC
# Written by Matthew Williams <matthew@flowroute.com>
# Based on yum module written by Seth Vidal <skvidal at fedoraproject.org>
#
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public Lic... | gptech/ansible | lib/ansible/modules/packaging/os/apt.py | Python | gpl-3.0 | 35,672 | 0.003644 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.