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 |
|---|---|---|---|---|---|---|
# Copyright (c) 2012-2015 Netforce Co. Ltd.
#
# 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, modify, merge, publ... | sidzan/netforce | netforce_support/netforce_support/models/report_issue.py | Python | mit | 2,805 | 0.012834 |
#!/usr/bin/python
import os
path = os.path.join(os.path.dirname(__file__), "../")
path = os.path.abspath(path)
regex = '-regex ".*\.[cChH]\(pp\)?"'
exclude = '-not -path "*/external/*" -not -name "*#*"'
cmd = 'find {p} {r} {e} -print | xargs etags '.format(p=path, e=exclude, r=regex)
print cmd
os.system(cmd)
| bailey-lab/graphSourceCode | scripts/etags.py | Python | gpl-3.0 | 316 | 0.012658 |
# -*- coding: utf-8 -*-
"""
***************************************************************************
OTBTester.py
---------------------
Copyright : (C) 2013 by CS Systemes d'information (CS SI)
Email : otb at c-s dot fr (CS SI)
Contributors : Julien Malik (CS SI... | drnextgis/QGIS | python/plugins/processing/algs/otb/maintenance/OTBTester.py | Python | gpl-2.0 | 17,027 | 0.001879 |
# -*- coding: utf-8 -*-
""" Friendly Dates and Times """
# Disable pylint's invalid name warning. 'tz' is used in a few places and it
# should be the only thing causing pylint to include the warning.
# pylint: disable-msg=C0103
import calendar
import datetime
import locale
import os
import pytz
import random
# Some... | MVReddy/WhenPy | when.py | Python | bsd-3-clause | 22,733 | 0.000044 |
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to Mylar.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This sc... | bbsan2k/nzbToMedia | nzbToMylar.py | Python | gpl-3.0 | 3,087 | 0.011986 |
from __future__ import absolute_import, print_function, division
import unittest
from pony.orm.tests.testutils import raises_exception
from pony.orm import *
db = Database('sqlite', ':memory:')
class AbstractUser(db.Entity):
username = PrimaryKey(unicode)
class User(AbstractUser):
diagrams = Set... | compiteing/flask-ponypermission | venv/lib/python2.7/site-packages/pony/orm/tests/test_core_find_in_cache.py | Python | mit | 6,105 | 0.00475 |
from datetime import datetime
from google.appengine.ext import ndb
from models import Deletion
from utils import updates
def get_key(slug):
return ndb.Key("Deletion", slug)
def delete_entity(key):
slug = key.string_id()
kind = key.kind()
key.delete()
deletion_key = get_key(slug)
... | rockwotj/shiloh-ranch | backend/utils/deletions.py | Python | mit | 543 | 0.001842 |
# -*- 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 'Cloud'
db.create_table(u'cloudslave_cloud', (
('name', self.gf('django.db.models... | sorenh/python-django-cloudslave | cloudslave/migrations/0001_initial.py | Python | apache-2.0 | 6,224 | 0.007069 |
#!/usr/bin/python2.7
from __future__ import print_function
# -*- coding: utf-8 -*-
import wx
import threading
import lcm
import random
import Forseti
import configurator
BLUE = (24, 25, 141)
GOLD = (241, 169, 50)
class TeamPanel(wx.Panel):
def __init__(self, remote, letter, number, name, colour, *args, **kwargs... | pioneers/forseti | wxdash.py | Python | apache-2.0 | 10,763 | 0.00288 |
#!/bin/python2
"""
#####################################
# iSpike-like joint conversion #
#####################################
"""
class sensNetIn():
#TODO: explain XD
'''
This object gets as input
and returns as output:
'''
from sys import exit
def __init__(self,
... | nico202/pyNeMo | libs/pySpike.py | Python | gpl-2.0 | 5,430 | 0.005893 |
'''author@esilgard'''
#
# Copyright (c) 2015-2016 Fred Hutchinson Cancer Research Center
#
# Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
#
import re, os
import global_strings as gb
PATH = os.path.dirname(os.path.realpath(__file__)) + os.path.sep
class SecondaryField(obje... | LabKey/argos_nlp | fhcrc_pathology/SecondaryField.py | Python | apache-2.0 | 3,282 | 0.012492 |
import bpy
from .utils import MultiCamContext
class MultiCamFadeError(Exception):
def __init__(self, msg):
self.msg = msg
def __str__(self):
return repr(self.msg)
class BlendObj(object):
def __init__(self, **kwargs):
self.children = set()
p = self.parent = kwargs.g... | nocarryr/blender-scripts | multicam_tools/multicam.py | Python | gpl-2.0 | 11,734 | 0.006051 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-21 11:13
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('submission', '0011_auto_20170921_0937'),
('identifi... | BirkbeckCTP/janeway | src/identifiers/migrations/0004_auto_20170921_1113.py | Python | agpl-3.0 | 750 | 0.001333 |
# Copyright (c) 2013 New Dream Network, LLC (DreamHost)
#
# 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... | klmitch/pbr | pbr/tests/test_packaging.py | Python | apache-2.0 | 28,790 | 0.000278 |
from __future__ import absolute_import
import logging
import requests
from six.moves.urllib.parse import quote
from sentry import options
logger = logging.getLogger(__name__)
def sms_available():
return bool(options.get('sms.twilio-account'))
def send_sms(body, to, from_=None):
account = options.get('s... | JamesMura/sentry | src/sentry/utils/sms.py | Python | bsd-3-clause | 976 | 0.001025 |
# Foremast - Pipeline Tooling
#
# Copyright 2018 Gogo, LLC
#
# 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... | gogoair/foremast | src/foremast/awslambda/api_gateway_event/__init__.py | Python | apache-2.0 | 661 | 0 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-08-07 13:08
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('main', '0009_remove_item_last_modified'... | detialiaj/pro | SYS/main/migrations/0010_auto_20160807_1508.py | Python | mit | 771 | 0.001297 |
"""Test the Dyson air quality component."""
import json
from unittest import mock
import asynctest
from libpurecool.dyson_pure_cool import DysonPureCool
from libpurecool.dyson_pure_state_v2 import DysonEnvironmentalSensorV2State
import homeassistant.components.dyson.air_quality as dyson
from homeassistant.components ... | DavidLP/home-assistant | tests/components/dyson/test_air_quality.py | Python | apache-2.0 | 5,733 | 0 |
"""
Copyright 2017-present Airbnb, 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 writing, sof... | airbnb/streamalert | streamalert_cli/test/handler.py | Python | apache-2.0 | 22,898 | 0.002533 |
from twisted.plugin import IPlugin
from twisted.words.protocols import irc
from txircd.config import ConfigValidationError
from txircd.module_interface import Command, ICommand, IModuleData, ModuleData
from txircd.utils import durationToSeconds, ipAddressToShow, ircLower, now
from zope.interface import implementer
from... | Heufneutje/txircd | txircd/modules/rfc/cmd_whowas.py | Python | bsd-3-clause | 4,564 | 0.027607 |
##########################################################################
#
# Copyright (c) 2012, John Haddon. 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 so... | hradec/gaffer | python/GafferArnold/__init__.py | Python | bsd-3-clause | 2,708 | 0.011078 |
import re
from nxtools import *
from .common import *
def shorten(instr, nlen):
line = instr.split("\n")[0]
if len(line) < 100:
return line
return line[:nlen] + "..."
def filter_match(f, r):
"""OR"""
if type(f) in [list, tuple]:
res = False
for fl in f:
if re.m... | immstudios/nebula-core | nebulacore/meta_utils.py | Python | gpl-3.0 | 1,789 | 0.002236 |
import matplotlib.pyplot as plt
import numpy as np
import os
from inference import error_fn, infer_interactions, choose_J_from_general_form, solve_true_covariance_from_true_J
from pitchfork_langevin import jacobian_pitchfork, gen_multitraj, steadystate_pitchfork
from settings import DEFAULT_PARAMS, FOLDER_OUTPUT, TAU
... | mattsmart/biomodels | transcriptome_clustering/baseline_reconstruction_error.py | Python | mit | 7,422 | 0.004042 |
"""Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit."""
import logging
from pycomfoconnect import (
SENSOR_BYPASS_STATE,
SENSOR_DAYS_TO_REPLACE_FILTER,
SENSOR_FAN_EXHAUST_DUTY,
SENSOR_FAN_EXHAUST_FLOW,
SENSOR_FAN_EXHAUST_SPEED,
SENSOR_FAN_SUPPLY_DUTY,
SENSOR_FAN_SUPPLY_F... | tchellomello/home-assistant | homeassistant/components/comfoconnect/sensor.py | Python | apache-2.0 | 9,175 | 0.000109 |
#Minimal example for running location prediction
from keras.models import load_model
import pickle
from keras.preprocessing.sequence import pad_sequences
import numpy as np
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152
os.environ["CUDA_VISIBLE_DEVICES"] = ""
binaryPath= 'data/binaries/' ... | Erechtheus/geolocation | predictText.py | Python | gpl-3.0 | 1,245 | 0.013655 |
# Copyright (c) 2010-2012 OpenStack Foundation
#
# 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 agree... | bkolli/swift | test/unit/proxy/controllers/test_container.py | Python | apache-2.0 | 9,332 | 0 |
#! /usr/bin/env python3
def find_locations( sequence_file, pattern ):
"""
Find the most common kmers of a given size in a given text
"""
sequence = parse_sequence_file( sequence_file )
k = len(pattern)
for i in range(len(sequence)-k+1):
if sequence[i:i+k] == pattern:
yield i
def parse_sequence_file( sequen... | bnbowman/BifoAlgo | src/Chapter1/Sec3_PatternMatching.py | Python | gpl-2.0 | 627 | 0.041467 |
# Copyright 2015 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.
from optparse import OptionParser
import unittest
import six
from telemetry.page import shared_page_state
from contrib.cluster_telemetry import rasterize_... | scheib/chromium | tools/perf/contrib/cluster_telemetry/ct_benchmarks_unittest.py | Python | bsd-3-clause | 4,992 | 0.013021 |
EGA2RGB = [
(0x00, 0x00, 0x00),
(0x00, 0x00, 0xAA),
(0x00, 0xAA, 0x00),
(0x00, 0xAA, 0xAA),
(0xAA, 0x00, 0x00),
(0xAA, 0x00, 0xAA),
(0xAA, 0x55, 0x00),
(0xAA, 0xAA, 0xAA),
(0x55, 0x55, 0x55),
(0x55, 0x55, 0xFF),
(0x55, 0xFF, 0x55),
(0x55, 0xFF, 0xFF),
(0xFF, 0x55, 0x5... | jtauber/ultima4 | shapes.py | Python | mit | 800 | 0 |
# Jacqueline Kory Westlund
# May 2016
#
# The MIT License (MIT)
#
# Copyright (c) 2016 Personal Robots Group
#
# 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 w... | personal-robots/sar_social_stories | src/ss_script_handler.py | Python | mit | 43,375 | 0.00302 |
#!/usr/bin/env python3
# Copyright (c) 2018-2019 TurboCoin
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests some generic aspects of the RPC interface."""
from test_framework.authproxy import JSONRPCException
from test_fram... | Phonemetra/TurboCoin | test/functional/interface_rpc.py | Python | mit | 2,668 | 0.001124 |
# Authors:
# Jason Gerard DeRose <jderose@redhat.com>
#
# Copyright (C) 2008 Red Hat
# see file 'COPYING' for use and warranty information
#
# 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, ei... | pspacek/freeipa | ipatests/test_ipalib/test_frontend.py | Python | gpl-3.0 | 39,007 | 0.001077 |
from unittest import TestCase
from scrapy.http import Response, Request
from scrapy.spider import Spider
from scrapy.contrib.spidermiddleware.referer import RefererMiddleware
class TestRefererMiddleware(TestCase):
def setUp(self):
self.spider = Spider('foo')
self.mw = RefererMiddleware()
de... | hy-2013/scrapy | tests/test_spidermiddleware_referer.py | Python | bsd-3-clause | 639 | 0.001565 |
#coding: cp936
#³£Î¢·Ö·½³Ì(ordinary differential equation)Çó½âÖ®¸Ä½øµÄÅ·À·¨dy=f*dx
import numpy as np
def odeiem(f, y0, x): #for: f(x, y)
'''fÊÇ΢·Ö·½³Ì£¬y0ÊdzõÖµ£¬xÊǸø¶¨µÄÐòÁУ¬×¢Òâf(x,y)º¯ÊýµÄ²ÎÊý˳ÐòÊÇxÓëy'''
y = np.array([y0])
for i in xrange(len(x)-1):
h = x[i+1]-x[i]
yp = y[i,:]+h*f... | bravesnow/nurbspy | assistlib/ode.py | Python | gpl-2.0 | 937 | 0.029883 |
import unittest
from typing import List
import utils
# O(n) time. O(n) space. DFS, hash set.
class Solution:
def circularArrayLoop(self, nums: List[int]) -> bool:
n = len(nums)
for start, move in enumerate(nums):
if move == 0:
continue
forward = move > 0
... | chrisxue815/leetcode_python | problems/test_0457_dfs_hashset.py | Python | unlicense | 1,180 | 0 |
# Copyright (c) 2015, Max Fillinger <max@max-fillinger.net>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND... | mfil/getebook | getebook/epub.py | Python | isc | 25,314 | 0.003713 |
""" Django support. """
from __future__ import absolute_import
import datetime
from os import path
from types import GeneratorType
import decimal
from django import VERSION
if VERSION < (1, 8):
from django.contrib.contenttypes.generic import (
GenericForeignKey, GenericRelation)
else:
from django.cont... | mechaxl/mixer | mixer/backend/django.py | Python | bsd-3-clause | 12,824 | 0.000468 |
# -*- coding: utf8 -*-
#
# Copyright (C) 2017 NDP Systèmes (<http://www.ndp-systemes.fr>).
#
# 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 Software Foundation, either version 3 of the
# License,... | ndp-systemes/odoo-addons | stock_procurement_split/__init__.py | Python | agpl-3.0 | 822 | 0 |
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | juhalindfors/bazel-patches | tools/build_defs/pkg/make_rpm_test.py | Python | apache-2.0 | 3,259 | 0.006137 |
# -*- coding: utf-8 -*-
# Coh-Metrix-Dementia - Automatic text analysis and classification for dementia.
# Copyright (C) 2014 Andre Luiz Verucci da Cunha
#
# 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 F... | andrecunha/coh-metrix-dementia | coh/database.py | Python | gpl-3.0 | 9,555 | 0.000419 |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | zhouyao1994/incubator-superset | superset/utils/decorators.py | Python | apache-2.0 | 4,658 | 0.000859 |
"""Creates ACME accounts for server."""
import datetime
import hashlib
import logging
import os
import socket
from cryptography.hazmat.primitives import serialization
import pyrfc3339
import pytz
import zope.component
from acme import fields as acme_fields
from acme import jose
from acme import messages
from letsenc... | mitnk/letsencrypt | letsencrypt/account.py | Python | apache-2.0 | 7,359 | 0.000408 |
import os
import shutil
import csv
class Restorer:
def __init__(self, backupDir):
self.backupDir = backupDir
if not self.backupDir.endswith('/'):
self.backupDir += '/'
def Run(self, filenamesListFname, doDelete=False):
if not os.path.exists(self.backupDir + filenamesListFna... | mozafari/vprofiler | src/Restorer/Restorer.py | Python | apache-2.0 | 744 | 0.002688 |
import sublime, sublime_plugin
try:
# ST 3
from .app.sublime_command import SublimeCommand
from .app.settings import Settings
except ValueError:
# ST 2
from app.sublime_command import SublimeCommand
from app.settings import Settings
class CalculateHoursCommand(sublime_plugin.TextCommand):
... | ldgit/hours-calculator | calculator.py | Python | mit | 592 | 0.003378 |
# Copyright 2016 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... | Reinaesaya/OUIRL-ChatBot | chatterbot/imgcaption/im2txt/show_and_tell_model_test.py | Python | bsd-3-clause | 6,824 | 0.003957 |
"""A multiline string
"""
function('aeozrijz\
earzer', hop)
# XXX write test
x = [i for i in range(5)
if i % 4]
fonction(1,
2,
3,
4)
def definition(a,
b,
c):
return a + b + c
class debile(dict,
object):
pass
if aaaa: pass
else:
... | ruchee/vimrc | vimfiles/bundle/vim-python/submodules/astroid/tests/testdata/python3/data/format.py | Python | mit | 421 | 0.023753 |
# Copyright 2017 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 ag... | nkubala/runtimes-common | ftl/common/ftl_util.py | Python | apache-2.0 | 8,151 | 0 |
from math import factorial
def prob_034():
facts = [factorial(i) for i in range(10)]
ans = 0
limit = factorial(9) * 7
for num in range(10, limit):
temp_num = num
sums = 0
while temp_num:
sums += facts[temp_num % 10]
temp_num //= 10
if sums == nu... | anshbansal/general | Python3/project_euler/001_050/034.py | Python | mit | 474 | 0.004219 |
#!/usr/bin/python2.4
#
# Copyright 2009 Empeeric LTD. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unl... | zackster/HipHopGoblin | trunk/bitly.py | Python | bsd-3-clause | 7,778 | 0.015042 |
# -*- coding: utf-8 -*-
# Disable while we have Python 2.x compatability
# pylint: disable=useless-object-inheritance
"""This module contains classes and functionality relating to Sonos Groups."""
from __future__ import unicode_literals
class ZoneGroup(object):
"""
A class representing a Sonos Group. It l... | KennethNielsen/SoCo | soco/groups.py | Python | mit | 6,415 | 0 |
# Copyright (C) 2015 ycmd contributors
#
# This file is part of ycmd.
#
# ycmd 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 option) any later version.
#
# ycmd... | NorfairKing/sus-depot | shared/shared/vim/dotvim/bundle/YouCompleteMe/third_party/ycmd/ycmd/completers/rust/rust_completer.py | Python | gpl-2.0 | 12,458 | 0.031947 |
import etcd
import logging
import os
import signal
import time
import unittest
import patroni.config as config
from mock import Mock, PropertyMock, patch
from patroni.api import RestApiServer
from patroni.async_executor import AsyncExecutor
from patroni.dcs.etcd import AbstractEtcdClientWithFailover
from patroni.excep... | zalando/patroni | tests/test_patroni.py | Python | mit | 7,937 | 0.00126 |
#!/usr/bin/env python3
# Basic program to read csv file and spit it back out
import argparse
import csv
import sys
def read_worksheet(csv_file):
"""
Read contents of worksheet_csv and return (contents, dialect, fields)
"""
contents = {}
dialect = None
fields = None
with open(csv_file,... | asayler/moodle-offline-grading | moodle_grading_worksheet.py | Python | gpl-3.0 | 1,988 | 0.002012 |
"""Python STIX2 FileSystem Source/Sink"""
import errno
import io
import json
import os
import re
import stat
from stix2 import v20, v21
from stix2.base import _STIXBase
from stix2.datastore import (
DataSink, DataSource, DataSourceError, DataStoreMixin,
)
from stix2.datastore.filters import Filter, FilterSet, appl... | oasis-open/cti-python-stix2 | stix2/datastore/filesystem.py | Python | bsd-3-clause | 28,607 | 0.000699 |
# -*- coding: utf-8 -*-
##
## This file is part of Harvesting Kit.
## Copyright (C) 2014 CERN.
##
## Harvesting Kit 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 ... | kaplun/harvesting-kit | harvestingkit/jats_package.py | Python | gpl-2.0 | 11,580 | 0.001813 |
from __future__ import absolute_import
from typing import Any, Iterable, Dict, Tuple, Callable, Text, Mapping
import requests
import json
import sys
import inspect
import logging
from six.moves import urllib
from functools import reduce
from requests import Response
from django.utils.translation import ugettext as _
... | jrowan/zulip | zerver/lib/outgoing_webhook.py | Python | apache-2.0 | 6,862 | 0.00408 |
from django.contrib.auth import get_user, get_user_model
from django.contrib.auth.models import AnonymousUser, User
from django.core.exceptions import ImproperlyConfigured
from django.db import IntegrityError
from django.http import HttpRequest
from django.test import TestCase, override_settings
from django.utils impor... | edmorley/django | tests/auth_tests/test_basic.py | Python | bsd-3-clause | 5,627 | 0.000534 |
from rest_framework import serializers
from .models import User, Activity, Period
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email')
extra_kwargs = {
'url': {'view_name': 'timeperiod:user-detail'},
... | maurob/timeperiod | serializers.py | Python | mit | 1,063 | 0.001881 |
class Solution:
def postorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
if root is None:
return []
else:
return list(self.postorderTraversalGen(root))
def postorderTraversalGen(self, node):
i... | xiao0720/leetcode | 145/Solution.py | Python | mit | 597 | 0.0067 |
from formatter.AbstractFormatter import AbstractFormatter
import html
import os
class IndexElement:
anchor = 0
def __init__(self, content):
self.content = content
self.a = IndexElement.anchor
self.node_list = []
IndexElement.anchor += 1
def addNode(self, e):
self.... | vdjagilev/desefu-export | formatter/html/HtmlFormatter.py | Python | mit | 7,031 | 0.003413 |
import importlib
from flask import render_template
import lib.es as es
def get(p):
# get data source definiton
query = 'name:{}'.format(p['nav'][3])
p['ds'] = es.list(p['host'], 'core_data', 'datasource', query)[0]
# load service
path = "web.modules.dataservice.services.{}".format(p['ds']['type'])... | unkyulee/elastic-cms | src/web/modules/dataservice/controllers/json.py | Python | mit | 392 | 0.005102 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (c) The University of Strathclyde 2019
# Author: Leighton Pritchard
#
# Contact:
# leighton.pritchard@strath.ac.uk
#
# Leighton Pritchard,
# Strathclyde Institute of Pharmaceutical and Biomedical Sciences
# The University of Strathclyde
# Cathedral Street
# Glasgow
# G1 1... | widdowquinn/pyani | pyani/pyani_graphics/sns/__init__.py | Python | mit | 9,274 | 0.000647 |
"""Handy XML processing utility functions.
Various XML processing utilities, using minidom, that are used in
various places throughout the code.
"""
"""
============================== License ========================================
Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding
This ... | markgw/jazzparser | src/jazzparser/utils/domxml.py | Python | gpl-3.0 | 3,282 | 0.012492 |
#!/usr/bin/env python3
class Solution:
def maxPower(self, s):
p, cnt, ret = '', 1, 0
for c in s:
if c == p:
cnt += 1
else:
ret, cnt = max(ret, cnt), 1
p = c
return max(ret, cnt)
str_list = [
'cc',
'leetcode',
'... | eroicaleo/LearningPython | interview/leet/1446_Consecutive_Characters.py | Python | mit | 471 | 0.002123 |
def get_filename_from_pathname(pathnames):
# if arg is a not a list, make it so
# https://stackoverflow.com/a/922800/861745
if not isinstance(pathnames, (list, tuple)):
pathnames = [pathnames]
for pathname in pathnames:
# print( pathname )
print( pathname.replace('\\','/').... | jgstew/tools | Python/get_filename_from_pathname.py | Python | mit | 894 | 0.006711 |
#!/usr/local/bin/python
# Code Fights Digits Product Problem
def digitsProduct(product):
def get_single_dig_factors(product):
# Helper function to generate single-digit factors of product
n = product
factors = []
for i in range(9, 1, -1):
while n % i == 0 and n > 1:
... | HKuz/Test_Code | CodeFights/digitsProduct.py | Python | mit | 1,457 | 0 |
#Made by Kerb
import sys
from com.l2scoria import Config
from com.l2scoria.gameserver.model.quest import State
from com.l2scoria.gameserver.model.quest import QuestState
from com.l2scoria.gameserver.model.quest.jython import QuestJython as JQuest
qn = "644_GraveRobberAnnihilation"
#Drop rate
DROP_CHANCE = 75
#Npc
... | zenn1989/scoria-interlude | L2Jscoria-Game/data/scripts/quests/644_GraveRobberAnnihilation/__init__.py | Python | gpl-3.0 | 2,948 | 0.04749 |
from datetime import datetime
from channels.generic.websockets import JsonWebsocketConsumer
from channels import Group, Channel
from channels.message import Message
from ..models import Room
class ChatServer(JsonWebsocketConsumer):
# Set to True if you want them, else leave out
strict_ordering = False
sl... | k-pramod/channel.js | examples/chatter/chat/consumers/base.py | Python | mit | 1,649 | 0.001213 |
#!/usr/bin/env python
import messagebird
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--accessKey', help='access key for MessageBird API', type=str, required=True)
parser.add_argument('--webhookId', help='webhook that you want to read', type=str, required=True)
args = vars(parser.parse_args(... | messagebird/python-rest-api | examples/conversation_read_webhook.py | Python | bsd-2-clause | 878 | 0.002278 |
#!/usr/bin/python2.4
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | bdelliott/wordgame | web/djangoappengine/management/commands/runserver.py | Python | mit | 3,475 | 0.000576 |
#!/usr/bin/python
# *****************************************************************************
#
# Copyright (c) 2016, EPAM SYSTEMS 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
#
# ... | epam/DLab | infrastructure-provisioning/src/ssn/scripts/resource_status.py | Python | apache-2.0 | 2,004 | 0.002495 |
# encoding: utf-8
"""
Miscellaneous functions, which are useful for handling bodies.
"""
from yade.wrapper import *
import utils,math,numpy
try:
from minieigen import *
except ImportError:
from miniEigen import *
#spheresPackDimensions==================================================
def spheresPackDimensions(idS... | ThomasSweijen/TPF | py/bodiesHandling.py | Python | gpl-2.0 | 8,305 | 0.056713 |
"""
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
distri... | SethGreylyn/gwells | gwells/forms.py | Python | apache-2.0 | 53,558 | 0.003697 |
# This file is part of Invenio.
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2014 CERN.
#
# Invenio 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 option) any l... | ludmilamarian/invenio | invenio/legacy/bibdocfile/plugins/bom_textdoc.py | Python | gpl-2.0 | 5,427 | 0.003317 |
from django.http.response import HttpResponse
import requests
def get_statuses(request):
url = request.GET.get('path', 'http://www.kikar.org/api/v1/facebook_status/?limit=5')
url = url.replace("'", "").replace('"', "")
print(url)
kikar_res = requests.get(url)
res = HttpResponse(content=kikar_res.c... | noamelf/Open-Knesset | kikar/views.py | Python | bsd-3-clause | 376 | 0.005319 |
from yos.rt import BaseTasklet
from yos.ipc import Catalog
class CatalogExample(BaseTasklet):
def on_startup(self):
Catalog.store('test1', 'test2', catname='test3')
Catalog.get('test1', self.on_read, catname='test3')
def on_read(self, val):
if val == 'test2':
print... | piotrmaslanka/systemy | examples/catalogExample.py | Python | mit | 382 | 0.010471 |
#!/usr/local/bin/python
# check python version
import sys
ver_info = sys.version_info
# parse commandlines
if ver_info[0] < 3 and ver_info[1] < 7:
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename", help="input log file", metavar="LOG_FILE... | EmoryUniversity/PIAT | src/common/log-analysis/python-discard/LogDBIngester.py | Python | lgpl-3.0 | 2,170 | 0.007834 |
from multiprocessing import Process
import pytest
from .mock_server.server import start
server_process = None
@pytest.hookimpl
def pytest_sessionstart(session):
global server_process
server_process = Process(target=start)
server_process.start()
@pytest.hookimpl
def pytest_sessionfinish(session):
if ... | pirate/bookmark-archiver | tests/conftest.py | Python | mit | 417 | 0.009592 |
from __future__ import print_function, division
import numpy as np
from astropy import units as u
from astropy.table import Table
from ..utils.validator import validate_array
__all__ = ['Extinction']
class Extinction(object):
def __init__(self):
self.wav = None
self.chi = None
@property
... | astrofrog/sedfitter | sedfitter/extinction/extinction.py | Python | bsd-2-clause | 3,289 | 0.00152 |
from sys import argv
from xml.dom import minidom
import csv
stem = argv[1][:-4] if argv[1].endswith('.xml') else argv[1]
xmldoc = minidom.parse('%s.xml'%stem)
labellist = xmldoc.getElementsByTagName('label')
labels = [l.attributes['name'].value for l in labellist]
labelset = set(labels)
for split in 'train','test':
... | pmineiro/randembed | mulan/xmlcsv2xy.py | Python | unlicense | 829 | 0.014475 |
#!/usr/bin/python
# Copyright (c) 2013 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
import json
from urllib import urlopen
import requests
import getpass
from string import Template
import sys
i... | credits-currency/credits | qa/pull-tester/pull-tester.py | Python | mit | 8,944 | 0.007044 |
import fudge
from oedipus import S
from oedipus.tests import no_results, Biscuit, BaseSphinxMeta
import sphinxapi
class BiscuitWithGroupBy(object):
"""Biscuit with default groupby"""
class SphinxMeta(BaseSphinxMeta):
group_by = ('a', '@group')
@fudge.patch('sphinxapi.SphinxClient')
def test_group... | erikrose/oedipus | oedipus/tests/test_groupby.py | Python | bsd-3-clause | 2,566 | 0.00039 |
# 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
# distributed under t... | stackforge/python-openstacksdk | openstack/dns/v2/_base.py | Python | apache-2.0 | 4,338 | 0 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-07-31 15:53
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('sync', '0003_synctarget_lastrun'),
]
operations = [
migrations.RenameModel(
... | tdfischer/organizer | sync/migrations/0004_auto_20190731_1553.py | Python | agpl-3.0 | 403 | 0 |
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#Adds the virtual environment's executable path to json file
import json,sys
import os.path
jsonPath = sys.argv[1]
key = sys.argv[2]
if os.path.isfile(jsonPath):
with open(jsonPath, 'r') as read_file:
data = jso... | DonJayamanne/pythonVSCode | build/ci/addEnvPath.py | Python | mit | 739 | 0.00406 |
#!/usr/bin/env python
# Copyright (C) 2009-2015 Johannes Dewender
#
# 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 option) any later version.
#
#... | jesus2099/JonnyJD_musicbrainz-isrcsubmit | isrcsubmit.py | Python | gpl-3.0 | 41,557 | 0.002142 |
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth import authenticate, login
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
import time
from ControlUsuarios.forms import *
from ControlUsuarios.models import UserProfile
# Create your views her... | hugobarzano/DispositivosMovilesBackEnd | ControlUsuarios/views.py | Python | gpl-3.0 | 16,446 | 0.014958 |
# encoding: utf-8
"""
Creates geometry objects from facets.
"""
from yade.wrapper import *
import utils,math,numpy
from minieigen import *
#facetBox===============================================================
def facetBox(center,extents,orientation=Quaternion((0,1,0),0.0),wallMask=63,**kw):
"""
Create arbitrari... | bcharlas/mytrunk | py/geom.py | Python | gpl-2.0 | 24,154 | 0.056543 |
# encoding=utf8
"""
Module containing functions and methods related to sequences in number theory such as
the Fibonacci sequence, the 3n + 1 problem, and more.
"""
import numpy as np
from mathpy.numtheory.integers import iseven
from decimal import Decimal, localcontext
def catalan(n, prec=1000):... | aschleg/mathpy | mathpy/numtheory/sequences.py | Python | mit | 8,092 | 0.003089 |
# -*- coding: utf-8 -*-
from acq4.devices.OptomechDevice import OptomechDevice
from acq4.devices.DAQGeneric import DAQGeneric
class PMT(DAQGeneric, OptomechDevice):
def __init__(self, dm, config, name):
self.omConf = {}
for k in ['parentDevice', 'transform']:
if k in config:
... | acq4/acq4 | acq4/devices/PMT/PMT.py | Python | mit | 705 | 0.004255 |
__all__ = [ "InputInterface" ]
class InputInterface():
def get_move(self):
pass
| gynvael/stream | 006-xoxoxo-more-con/input_interface.py | Python | mit | 100 | 0.04 |
import pytest
from cobbler.cexceptions import CX
from cobbler import module_loader
from tests.conftest import does_not_raise
@pytest.fixture(scope="function")
def reset_modules():
module_loader.MODULE_CACHE = {}
module_loader.MODULES_BY_CATEGORY = {}
@pytest.fixture(scope="function")
def load_modules():
... | cobbler/cobbler | tests/module_loader_test.py | Python | gpl-2.0 | 5,203 | 0.004613 |
#!/usr/bin/env python3
# Copyright 2017 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 copy
import glob
import io
import itertools
import os
import unittest
import re
import shutil
import subprocess
import sys
impo... | chromium/chromium | tools/binary_size/libsupersize/integration_test.py | Python | bsd-3-clause | 24,004 | 0.006749 |
# Webhooks for external integrations.
from __future__ import absolute_import
from typing import Any, Dict, List, Optional, Text, Tuple
from django.utils.translation import ugettext as _
from django.db.models import Q
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from zerver.models... | j831/zulip | zerver/webhooks/jira/view.py | Python | apache-2.0 | 10,755 | 0.003533 |
import tests.model_control.test_ozone_custom_models_enabled as testmod
testmod.build_model( ['Difference'] , ['LinearTrend'] , ['Seasonal_Hour'] , ['NoAR'] ); | antoinecarme/pyaf | tests/model_control/detailed/transf_Difference/model_control_one_enabled_Difference_LinearTrend_Seasonal_Hour_NoAR.py | Python | bsd-3-clause | 160 | 0.05 |
# Nov 22, 2014
# This patch is to create all the prep/sample template files and link them in
# the database so they are present for download
from os.path import join
from time import strftime
from qiita_db.util import get_mountpoint
from qiita_db.sql_connection import SQLConnectionHandler
from qiita_db.metadata_templ... | RNAer/qiita | qiita_db/support_files/patches/python_patches/6.py | Python | bsd-3-clause | 1,165 | 0 |
# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*-
# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent:
# :mode=python:indentSize=4:tabSize=4:noTabs=true:
#-----------------------------------------------------... | luksan/kodos | modules/flags.py | Python | gpl-2.0 | 1,969 | 0.006094 |
# -*- coding: utf-8 -*-
# ***************************************************************************
# * Copyright (c) 2017 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This program is free software; you can redistribute it a... | sanguinariojoe/FreeCAD | src/Mod/Path/PathScripts/PathIconViewProvider.py | Python | lgpl-2.1 | 4,713 | 0.002758 |
import mymodel
reload(mymodel)
| Akagi201/akcode | python/test_model/usemodel.py | Python | gpl-2.0 | 33 | 0 |
from lxml import etree
from nxpy.interface import Interface
from nxpy.vlan import Vlan
from nxpy.flow import Flow
from util import tag_pattern
class Device(object):
# Singleton
_instance = None
def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = super(
... | Kent1/nxpy | nxpy/device.py | Python | apache-2.0 | 2,884 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.