commit stringlengths 40 40 | subject stringlengths 4 1.73k | repos stringlengths 5 127k | old_file stringlengths 2 751 | new_file stringlengths 2 751 | new_contents stringlengths 1 8.98k | old_contents stringlengths 0 6.59k | license stringclasses 13
values | lang stringclasses 23
values |
|---|---|---|---|---|---|---|---|---|
4e0247dc81c26cbb792d9396151174ddb11dfb9a | Add OrderByField | ashleywaite/django-more | django_more/fields/orderbyfield.py | django_more/fields/orderbyfield.py | from django.db import models
from django.db.models import Max
from django.db.models import Subquery
from django.db.models.functions import Coalesce
from ..expressions import BypassExpression
from ..mixins import UniqueForFieldsMixin
class OrderByField(UniqueForFieldsMixin, models.IntegerField):
""" Integer that ... | bsd-3-clause | Python | |
182de357b8537a0057ddae5efa79bfe37cf038e4 | Add sort.py to keep a list of available sorting methods | joshua-stone/DerPyBooru | derpibooru/sort.py | derpibooru/sort.py |
creation_date = "creation_date"
score = "score"
relevance = "relevance"
width = "width"
height = "height"
comments = "comments"
random = "random"
| bsd-2-clause | Python | |
e16d678f0aed9430b79e3a5ad10a7e3e0f44196f | Create hello_world.py | samuelzq/Learn-Python-with-kids | part1/hello_world.py | part1/hello_world.py | print('hello world')
| apache-2.0 | Python | |
e914fae0a21709284431c7de22cdbc9c7259e053 | add public domain wsgi config | puttarajubr/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,gmimano/commcaretest,qedsoftware/commcare-hq,gmimano/commcaretest,qedsoftware/commcare-hq,SEL-Columbia/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,SEL-Columbia/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-h... | apache/commcarehq_public.wsgi | apache/commcarehq_public.wsgi | import os
import sys
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
os.environ['CUSTOMSETTINGS'] = 'demo'
# first set the root directory on the path
parent_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
if parent_dir not in sys.path:
sys.path.append(parent_d... | bsd-3-clause | Python | |
c1fe2080396d2166786ac6daaab65e642a030eca | Add alembic revision for added indices | moschlar/SAUCE,moschlar/SAUCE,moschlar/SAUCE,moschlar/SAUCE | migration/versions/39e593c6c3a0_add_indices.py | migration/versions/39e593c6c3a0_add_indices.py | """Add indices
Needed due to git commit 94e3bbc, between release versions 1.1 and 1.2
Revision ID: 39e593c6c3a0
Revises: 5894175a5dd9
Create Date: 2012-11-12 22:39:47.938656
"""
# revision identifiers, used by Alembic.
revision = '39e593c6c3a0'
down_revision = '5894175a5dd9'
from alembic import op
#from alembic.op... | agpl-3.0 | Python | |
540fd8c7f853dbd85f433c560b81d17b6acf3f3c | Bump to 0.11b2 | ftao/python-ifcfg | src/ifcfg/__init__.py | src/ifcfg/__init__.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import platform
from . import tools
from . import exc
from . import parser
__version__ = "0.11b2"
Log = tools.minimal_logger(__name__)
#: Module instance properties, can be mocked for testing
distro = platform.system()
def get_parser_class... | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import platform
from . import tools
from . import exc
from . import parser
__version__ = "0.11b1"
Log = tools.minimal_logger(__name__)
#: Module instance properties, can be mocked for testing
distro = platform.system()
def get_parser_class... | bsd-3-clause | Python |
487a4c070d37fc201c9863119d6b0cee405439e4 | Add upgrade script to fully rebuild indexes. | etalab/ckan-of-worms,etalab/ckan-of-worms | ckanofworms/upgrades/20130100501_drop_indexes.py | ckanofworms/upgrades/20130100501_drop_indexes.py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# CKAN-of-Worms -- A logger for errors found in CKAN datasets
# By: Emmanuel Raviart <emmanuel@raviart.com>
#
# Copyright (C) 2013 Etalab
# http://github.com/etalab/ckan-of-worms
#
# This file is part of CKAN-of-Worms.
#
# CKAN-of-Worms is free software; you can redistri... | agpl-3.0 | Python | |
22e4be8ce0e8a579ee733bf794b68cfbab7b1156 | Merge migrations | laurenbarker/SHARE,aaxelb/SHARE,CenterForOpenScience/SHARE,aaxelb/SHARE,laurenbarker/SHARE,CenterForOpenScience/SHARE,aaxelb/SHARE,laurenbarker/SHARE,CenterForOpenScience/SHARE | share/migrations/0017_merge.py | share/migrations/0017_merge.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2017-01-30 21:47
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('share', '0014_auto_20170112_2143'),
('share', '0016_merge'),
('share', '0016_auto_201... | apache-2.0 | Python | |
d879e96d9cc4c4151ff3059316c977e57a3caf17 | Create OddEvenLinkedList_001.py | Chasego/cod,Chasego/cod,Chasego/codirit,Chasego/codirit,Chasego/codi,Chasego/codirit,cc13ny/algo,cc13ny/Allin,Chasego/codi,Chasego/codi,Chasego/codirit,Chasego/cod,cc13ny/algo,cc13ny/algo,cc13ny/algo,Chasego/codi,Chasego/cod,cc13ny/Allin,cc13ny/algo,Chasego/codi,cc13ny/Allin,Chasego/cod,cc13ny/Allin,cc13ny/Allin,Chaseg... | leetcode/328-Odd-Even-Linked-List/OddEvenLinkedList_001.py | leetcode/328-Odd-Even-Linked-List/OddEvenLinkedList_001.py | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def oddEvenList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head or not head.next:
... | mit | Python | |
6346250fe7901666ae8c7d1045aa92a1f249d25b | Initialize Ch. 1: hello | JoseALermaIII/python-tutorials,JoseALermaIII/python-tutorials | books/AutomateTheBoringStuffWithPython/Chapter01/hello.py | books/AutomateTheBoringStuffWithPython/Chapter01/hello.py | # This program says hello and asks for my name.
print('Hello world!')
print('What is your name?') # ask for their name
myName = input()
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName))
print('What is your age?') # ask for their age
myAge = input()
print('You will be ... | mit | Python | |
112389636eb37821811bc8c95417a516edda8c84 | Create helloworld.py | illacceptanything/illacceptanything,illacceptanything/illacceptanything,illacceptanything/illacceptanything,illacceptanything/illacceptanything,illacceptanything/illacceptanything,illacceptanything/illacceptanything,illacceptanything/illacceptanything,illacceptanything/illacceptanything,illacceptanything/illacceptanyth... | code/helloworld.py | code/helloworld.py | ### python 2 :hello World
print "hello world!"
| mit | Python | |
e33fe4588c356b4af8cbce4617927d9f5a7dcf00 | add library for parsing configuration files | jamesmarva/myria,bsalimi/myria,uwescience/myria,uwescience/myria,jamesmarva/myria,bsalimi/myria,jamesmarva/myria,uwescience/myria,bsalimi/myria | myriadeploy/myriadeploy.py | myriadeploy/myriadeploy.py | #!/usr/bin/env python
"A library used to parse Myria deployment configuration files."
import ConfigParser
import getpass
import sys
def read_config_file(filename='deployment.cfg'):
"reads a Myria deployment configuration file."
# Return value is a dictionary of keys -> values
ret = dict()
# Ope... | bsd-3-clause | Python | |
a5940c2a5f78c9952928b0d07962c17b85164bf9 | Add aws_mfa_devices module for multi-factor authentication on AWS. (#1987) | thaim/ansible,thaim/ansible | lib/ansible/modules/extras/cloud/amazon/aws_mfa_devices.py | lib/ansible/modules/extras/cloud/amazon/aws_mfa_devices.py | #!/usr/bin/python
# 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 your option) any later version.
#
# Ansible is distributed... | mit | Python | |
fd18e2eebd678a0c2230593f28b4950474dadb5f | add host variable dash fix as a migration | wwitzel3/awx,wwitzel3/awx,snahelou/awx,snahelou/awx,snahelou/awx,wwitzel3/awx,wwitzel3/awx,snahelou/awx | awx/main/migrations/0033_v303_v245_host_variable_fix.py | awx/main/migrations/0033_v303_v245_host_variable_fix.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from awx.main.migrations import _migration_utils as migration_utils
def update_dashed_host_variables(apps, schema_editor):
Host = apps.get_model('main', 'Host')
for host in Host.objects.filter(variables='---'):
... | apache-2.0 | Python | |
64dd806f53073d3846f58eba29db10be8d9b3264 | Create communication_reconciliation_item.py | ShashaQin/frappe,ShashaQin/frappe,ShashaQin/frappe,ShashaQin/frappe | frappe/desk/doctype/communication_reconciliation_item/communication_reconciliation_item.py | frappe/desk/doctype/communication_reconciliation_item/communication_reconciliation_item.py | # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class CommunicationReconciliationitem(Document):
pass
| mit | Python | |
428e7059f986e33a10d1036a246ea980a340d09e | add Laue_peaks.py | structrans/Canon | canon/img/Laue_peaks.py | canon/img/Laue_peaks.py | import numpy as np
x0 = 539.689
y0 = 197.444
def read_peaks(filename):
f = open(filename,'r')
x = []
y = []
flag = 0
inten = []
for line in f:
flag+=1
words = line.split()
if flag == 2:
cap = [words.index('x'), words.index('y'), words.index('integr(obs)')]
... | mit | Python | |
7db8025cc2b6bfae8faa0534249bef9c137b0583 | use new idcommands | artefactual/archivematica,artefactual/archivematica,artefactual/archivematica,artefactual/archivematica | src/dashboard/src/main/migrations/0044_update_idtools.py | src/dashboard/src/main/migrations/0044_update_idtools.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
def data_migration(apps, schema_editor):
mscrd = apps.get_model('main', 'MicroServiceChoiceReplacementDic')
# Use new fido command introduced in fpr-admin v1.7.2
fido_idcommand_ids = [
'0db6372b-f507... | agpl-3.0 | Python | |
e42718a59d9c0bffed524f5764ee119cb616085e | Add py solution for 721. Accounts Merge | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | py/accounts-merge.py | py/accounts-merge.py | from collections import defaultdict
class Solution(object):
def accountsMerge(self, accounts):
"""
:type accounts: List[List[str]]
:rtype: List[List[str]]
"""
parent = dict()
def find_root(a):
if parent[a] != a:
parent[a] = find_root(parent... | apache-2.0 | Python | |
48a603ecb670d64bceb656ae0ac38e01c7b3f909 | Add rtpp_query.py, a simple shell command line interface to run one or more commands on local/remote rtpproxy. | hongbinz/rtpproxy,jevonearth/rtpproxy,dsanders11/rtpproxy,synety-jdebp/rtpproxy,jevonearth/rtpproxy,dsanders11/rtpproxy,sippy/rtpproxy,hongbinz/rtpproxy,jevonearth/rtpproxy,jevonearth/rtpproxy,dsanders11/rtpproxy,sippy/rtpproxy,synety-jdebp/rtpproxy,synety-jdebp/rtpproxy,hongbinz/rtpproxy,hongbinz/rtpproxy,synety-jdebp... | python/rtpp_query.py | python/rtpp_query.py | #!/usr/bin/env python2
#
# Copyright (c) 2015 Sippy Software, Inc. All rights reserved.
#
# 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 abov... | bsd-2-clause | Python | |
c723650f387d3e67a5fabfbaffe77d60c3ea17ca | use view names, make sure to comment out ID field | qedsoftware/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,gmimano/commcaretest,puttarajubr/commcare-hq,SEL-Columbia/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,SEL-Columbia/commcare-hq,qedsoftware/commcare-hq,SEL-Columbia/commcare-hq,gmimano/commcaretest,qedsoftware/commcare-hq,gm... | apps/intel/generate_schema.py | apps/intel/generate_schema.py | # generates schema_models from manage.py inspectdb output.
import os, re
MODELS = {
"IntelGrameenMotherRegistration" : "view_intel_grameen_safe_motherhood_registrations",
"IntelGrameenSafeMotherhoodFollowup" : "view_intel_grameen_safe_motherhood_followups"
}
cmd = "cd ../.. ; python manage.py inspe... | # generates schema_models from manage.py inspectdb output.
import os, re
models = {
"IntelGrameenMotherRegistration" : "schema_intel_grameen_safe_motherhood_registration_v0_3",
"IntelGrameenSafeMotherhoodFollowup" : "schema_intel_grameen_safe_motherhood_followup_v0_2"
}
cmd = "cd ../.. ; python manag... | bsd-3-clause | Python |
dd507ff045dc9ea43639e5a5242655d29e5b95af | add get_workflow_name.py | googleapis/google-cloud-node,googleapis/google-cloud-node,googleapis/google-cloud-node,googleapis/google-cloud-node | packages/google-cloud-redis/.circleci/get_workflow_name.py | packages/google-cloud-redis/.circleci/get_workflow_name.py | # Copyright 2018 Google 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 by applicable law or agreed to in writing, s... | apache-2.0 | Python | |
9b6f6539805deb3c8d3240bde84847e3a1fb49d1 | add a new test test_MultiprocessingDropbox_1.py | alphatwirl/alphatwirl,alphatwirl/alphatwirl,alphatwirl/alphatwirl,alphatwirl/alphatwirl | tests/unit/concurrently/test_MultiprocessingDropbox_1.py | tests/unit/concurrently/test_MultiprocessingDropbox_1.py | # Tai Sakuma <tai.sakuma@gmail.com>
import os
import time
import collections
import pytest
try:
import unittest.mock as mock
except ImportError:
import mock
from alphatwirl.concurrently import MultiprocessingDropbox
from alphatwirl.concurrently import TaskPackage
##__________________________________________... | bsd-3-clause | Python | |
9bd22c176fc347282814aa59f724b851230f3555 | Add __init__.py file for hitran subpackage | imbasimba/astroquery,ceb8/astroquery,imbasimba/astroquery,ceb8/astroquery | astroquery/hitran/__init__.py | astroquery/hitran/__init__.py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
HITRAN Catalog Query Tool
-------------------------
:Author: Adam Ginsburg (adam.g.ginsburg@gmail.com)
"""
from .reader import read_hitran_file
| bsd-3-clause | Python | |
1d6ee01dddea54f14955232669b663f895079f9f | Update getSparqlStatistic.py | Wikidata/QueryAnalysis,Wikidata/QueryAnalysis,Wikidata/QueryAnalysis,Wikidata/QueryAnalysis,Wikidata/QueryAnalysis | tools/postprocess/getSparqlStatistic.py | tools/postprocess/getSparqlStatistic.py | import argparse
from collections import defaultdict
import sys
import processdata as processdata
parser = argparse.ArgumentParser(description="Prints out the SPARQL statistic")
parser.add_argument("processedLogDataFolder", type=str, help="the folder in which the processed log files are in")
parser.add_argument("rawL... | apache-2.0 | Python | |
2f5f935d9fd19d2a1e5d99f4727f5a6e3ed7f2d1 | Add indexed mixin class | AleksNeStu/ggrc-core,AleksNeStu/ggrc-core,AleksNeStu/ggrc-core,AleksNeStu/ggrc-core | src/ggrc/fulltext/mixin.py | src/ggrc/fulltext/mixin.py | # Copyright (C) 2017 Google Inc.
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
"""Module contains Indexed mixin class"""
from collections import namedtuple
from . import get_indexed_model_names, get_indexer
ReindexRule = namedtuple("ReindexRule", ["model", "rule"])
# pylint: disab... | apache-2.0 | Python | |
df43e8698d9cffdbdb0dfd723a0ec65c8861c180 | add gaussian euclidean metric | blackjax-devs/blackjax | blackjax/inference/metrics.py | blackjax/inference/metrics.py | r"""Metric space in which the Hamiltonian dynamic is embedded.
An important particular case (and the most used in practice) of metric for the
position space in the Euclidean metric. It is defined by a definite positive
matrix :math:`M` with fixed value so that the kinetic energy of the hamiltonian
dynamic is independe... | apache-2.0 | Python | |
2089055d93abd6a28ca89ffa57e116e92537e8c7 | add code to generate incident from placeholder | bschmoker/mockingjay,bschmoker/mockingjay | create_incident.py | create_incident.py | #!/usr/bin/env python
import stix
from stix.core import STIXPackage, STIXHeader
from datetime import datetime
from cybox.common import Time
from stix.incident import Incident,AffectedAsset
from stix.incident import Time as incidentTime # is a different type of object
from stix.common import InformationSource
from s... | mit | Python | |
bbd07d4cd43eb9c6a5d60dca2b815d0286b2eda3 | Add script to produce a changelog | 11h42/gitlab-tools | list_issues_by_milestone.py | list_issues_by_milestone.py | from gitlab import Gitlab
from configparser import ConfigParser
import sys
__author__ = 'Cedric RICARD'
config = ConfigParser()
config.read_file(open('defaults.cfg'))
def connect_to_gitlab():
gl = Gitlab(config.get('gitlab', 'url'), config.get('gitlab', 'key'))
gl.auth()
return gl
def list_issues(gl, ... | agpl-3.0 | Python | |
7897a3803f91f891798151693532cc58cc62c5c4 | Create professional.py | carthage-college/django-djspace,carthagecollege/django-djspace,carthage-college/django-djspace,carthage-college/django-djspace,carthagecollege/django-djspace,carthagecollege/django-djspace,carthage-college/django-djspace | djspace/registration/form_models/professional.py | djspace/registration/form_models/professional.py | # -*- coding: utf-8 -*-
from django.conf import settings
from django.db import models, connection
from django.contrib.auth.models import User
from djspace.registration.base_models import *
from djtools.fields import BINARY_CHOICES, SALUTATION_TITLES, STATE_CHOICES
from djtools.fields import GENDER_CHOICES
INTEREST =... | mit | Python | |
49e667ebf036700e0f2a1c578c8e904d4436ffe6 | Create kvm_host.py | site24x7/plugins,site24x7/plugins,site24x7/plugins | kvm_host/kvm_host.py | kvm_host/kvm_host.py | #! /usr/bin/env python3
'''
Created on 02-Dec-2020
@author: anita-1372
'''
import argparse
import libvirt
import json
if __name__ == '__main__':
conn = None
data = {}
try:
parser = argparse.ArgumentParser()
parser.add_argument('--host', help='kvm host to connect', n... | bsd-2-clause | Python | |
ea5b293378f65f90168fa93ff922935bf43209f7 | Add back in rogue tests | personalrobotics/herbpy | tests/rogue_tests.py | tests/rogue_tests.py | #!/usr/bin/env python
import roslib
import numpy, unittest
import herbpy, prpy, openravepy
from nose.tools import nottest
class RogueTest(unittest.TestCase):
def setUp(self):
self.env, self.robot = herbpy.initialize(sim=True)
self.fuze = prpy.rave.add_object(self.env, 'fuze_bottle', 'objects/fuze_b... | bsd-3-clause | Python | |
cc6328793ff1f9c4682454ced01c5708c440f78b | Fix python 2,3 compatibility issue with six | openstack/python-muranoclient,openstack/python-muranoclient | tools/install_venv.py | tools/install_venv.py | # Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2010 OpenStack Foundation
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file ... | # Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2010 OpenStack Foundation
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file ... | apache-2.0 | Python |
c4db743bdb9bbfef2e39cc57e2be290d9f51bc10 | add tests.test_common | power12317/you-get,kzganesan/you-get,XiWenRen/you-get,Red54/you-get,xyuanmu/you-get,lilydjwg/you-get,smart-techs/you-get,fffonion/you-get,dream1986/you-get,FelixYin66/you-get,CzBiX/you-get,linhua55/you-get,zmwangx/you-get,jindaxia/you-get,zmwangx/you-get,j4s0nh4ck/you-get,tigerface/you-get,chares-zhang/you-get,pitatens... | tests/test_common.py | tests/test_common.py | #!/usr/bin/env python
import unittest
from you_get import *
class TestCommon(unittest.TestCase):
def test_match1(self):
self.assertEqual(match1('http://youtu.be/1234567890A', r'youtu.be/([^/]+)'), '1234567890A')
self.assertEqual(match1('http://youtu.be/1234567890A', r'youtu.be/([^/]+)', r'yo... | mit | Python | |
3de55f33218a33963a033ece185f761e5ea7971e | test compatibility for old imports | openstack/oslo.concurrency,JioCloud/oslo.concurrency,varunarya10/oslo.concurrency | tests/test_import.py | tests/test_import.py | # 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
# d... | apache-2.0 | Python | |
77448f99a519aa6d1a69ffaa379a2c2de24743fb | Create StockUtils.py | Soncrates/stock-study,Soncrates/stock-study | data/StockUtils.py | data/StockUtils.py | class MorningStar(object) :
@staticmethod
def get_cash_flow(exchange_code, ticker) :
url = 'http://financials.morningstar.com/ajax/ReportProcess4HtmlAjax.html?&t=%s:%s®ion=usa&culture=en-US&cur=USD&reportType=cf&period=12&dataType=A&order=asc&columnYear=5&rounding=3&view=raw&r=963470&callback=jsonp%d&... | lgpl-2.1 | Python | |
52cbe35e34edfa015678781cf942490da9ac6194 | Add user management functions | markbrough/maedi-projects,markbrough/maedi-projects,markbrough/maedi-projects | maediprojects/query/user.py | maediprojects/query/user.py | from maediprojects import db, models
from werkzeug.security import generate_password_hash, check_password_hash
import datetime, time
from flask.ext.login import current_user
def user(user_id=None):
if user_id:
user = models.User.query.filter_by(id=user_id
).first()
return user
... | agpl-3.0 | Python | |
c8d0a0951cd73bd9c4a10428b60f44ea92302bd0 | add solution for Power of Two | zhyu/leetcode,zhyu/leetcode | algorithms/powerOfTwo/powerOfTwo.py | algorithms/powerOfTwo/powerOfTwo.py | class Solution:
# @param {integer} n
# @return {boolean}
def isPowerOfTwo(self, n):
cnt = 0
while n:
if n & 1:
cnt += 1
if cnt > 1:
return False
n >>= 1
return cnt == 1
| mit | Python | |
b9c040d5aadd033a85d68364e5c61d0f5c9f2aed | add script to count browser usage percentage using video list | Ziggeo/ZiggeoPythonSdk,Ziggeo/ZiggeoPythonSdk | demos/_videos_index_browser.py | demos/_videos_index_browser.py | import sys
from Ziggeo import Ziggeo
if(len(sys.argv) < 3):
print ("Error\n")
print ("Usage: $>python _videos_index_browser.py YOUR_API_TOKEN YOUR_PRIVATE_KEY\n")
sys.exit()
api_token = sys.argv[1]
private_key = sys.argv[2]
browsers = {}
total_browser = 0.0
ziggeo = Ziggeo(api_token, private_key)
def indexVideos... | apache-2.0 | Python | |
ffbe2ec74fc05ed62bdedfdad3f39b201d504801 | Add beginning of MaskPainter | acq4/acq4,campagnola/acq4,mgraupe/acq4,meganbkratz/acq4,mgraupe/acq4,acq4/acq4,campagnola/acq4,campagnola/acq4,pbmanis/acq4,mgraupe/acq4,pbmanis/acq4,meganbkratz/acq4,meganbkratz/acq4,acq4/acq4,meganbkratz/acq4,acq4/acq4,pbmanis/acq4,mgraupe/acq4,campagnola/acq4,mgraupe/acq4,pbmanis/acq4 | acq4/util/maskpainter/maskpainter.py | acq4/util/maskpainter/maskpainter.py | import numpy as np
import acq4.pyqtgraph as pg
from acq4.pyqtgraph.Qt import QtGui, QtCore
class MaskPainter(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.layout = QtGui.QGridLayout()
self.setLayout(self.layout)
self.view = pg.I... | mit | Python | |
86c8f3311efaf6bc4f1ef5bda4213ec07f36a7fd | Add test and workaround for function.__module__ attr. | pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython | tests/cpydiff/core_function_moduleattr.py | tests/cpydiff/core_function_moduleattr.py | """
categories: Core,Functions
description: Function objects do not have the ``__module__`` attribute
cause: MicroPython is optimized for reduced code size and RAM usage.
workaround: Use ``sys.modules[function.__globals__['__name__']]`` for non-builtin modules.
"""
def f():
pass
print(f.__module__)
| mit | Python | |
bd5c3b692eca364467586869e8e811d8890033aa | Create InputNeuronGroup_multiple_inputs_2.py | ricardodeazambuja/BrianConnectUDP | examples/InputNeuronGroup_multiple_inputs_2.py | examples/InputNeuronGroup_multiple_inputs_2.py | '''
Example of a spike generator (only outputs spikes)
In this example spikes are generated and sent through UDP packages. At the end of the simulation a raster plot of the
spikes is created.
'''
from brian import *
import numpy
from brian_multiprocess_udp import BrianConnectUDP
number_of_neurons_total = 60
numbe... | cc0-1.0 | Python | |
f0384df7ce5d3a472f3bc4eacd8c7ed214ceb0c3 | Create smtp_receiver.py | stephenbradshaw/pentesting_stuff,stephenbradshaw/pentesting_stuff,stephenbradshaw/pentesting_stuff,stephenbradshaw/pentesting_stuff | smtp_receiver.py | smtp_receiver.py | #!/usr/bin/env python
'''SMTP server'''
from __future__ import print_function
from smtpd import SMTPServer
from optparse import OptionParser
import asyncore
import os
import sys
import time
import inspect
# shut up about constants pylint!
# pylint: disable-msg=C0103
class CustomSMTPServer(SMTPServer):
'''Custom ... | bsd-3-clause | Python | |
bf9fb9c76cda6ff4a80b6a7489e9a1aeb33a2490 | Create /tofu/plugins/AUG/ with empty __init__.py | Didou09/tofu,ToFuProject/tofu,ToFuProject/tofu | tofu/plugins/AUG/__init__.py | tofu/plugins/AUG/__init__.py | mit | Python | ||
95ccc58e780c3cdc09baac5a8295f9f422d2c25c | Add test_directory back | Machyne/pal,Machyne/pal,Machyne/pal,Machyne/pal | pal/test/test_directory.py | pal/test/test_directory.py | import sys
import os
sys.path.append(
os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
from pal.feature_extractor import FeatureExtractor
from pal.standard_nlp import StandardNLP
from pal.exceptions import MissingKeyException
from pal.services.directory_service import DirectoryService
def... | bsd-3-clause | Python | |
cd5131913fa95c75b17036d2e5ae9f99a9e33e55 | test that an invalid GETDATA doesn't prevent processing of future messages | Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc | test/functional/p2p_getdata.py | test/functional/p2p_getdata.py | #!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test GETDATA processing behavior"""
from collections import defaultdict
from test_framework.messages import... | mit | Python | |
00cdca6991f111448ebe519ba7ed244c6d13c188 | fix tornado lab | zhyq0826/test-lab,zhyq0826/test-lab | tornado-lab/main7.py | tornado-lab/main7.py |
from concurrent.futures import ThreadPoolExecutor
executor = ThreadPoolExecutor(max_workers=2)
def sleep_fun():
import time
print 'sleep start'
time.sleep(5)
print 'sleep end'
def no_sleep():
print 'no sleep'
if __name__ == '__main__':
executor.submit(sleep_fun)
no_sleep()
| mit | Python | |
001d410e6fce0e560fa0904b0cb8e1f92dd45a4f | Create import-users.py | Nik0l/UTemPro,Nik0l/UTemPro | db/import-users.py | db/import-users.py | # import xml into sqlite3 database
| mit | Python | |
c4311499281d83c80f86a4987e4a1792f0ac2ff3 | Add url_map module | chamakov/namebench,takuya/namebench,snailbob/namebench,rosemead/namebench,hitrust/namebench,Ritvik1512/namebench,Forgen/namebench,repomain/namebench,corruptnova/namebench,jevgen/namebench,etxc/namebench,nt1st/namebench,crocleco/namebench,llaera/namebench,AgentN/namebench,santoshsahoo/namebench,renatogames2/namebench,ra... | libnamebench/url_map.py | libnamebench/url_map.py | # Copyright 2009 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 ... | apache-2.0 | Python | |
69e7f0659ef9e2d243bc6f207a74fe76fad548e4 | structure again | fg-uulm/fusionkinectPy | library/KinectClient.py | library/KinectClient.py | '''
FusionKit Kinect Python Client
==============================
Allows access to Kinect (v2) data streams via Websocket when used with FusionKit
Prerequisites
- Running FusionKit SensorServer Instance, reachable over network
- Working Python environment with OpenCV (>= 3.0) and ws4py (>= 0.4.2) installed
Current Re... | bsd-3-clause | Python | |
1a519a768ba35e03f73ac0c2295ec1b6959201b6 | add merge sorting | livoras/py-algorithm | sorting/merge-sort.py | sorting/merge-sort.py | #-*- coding: utf-8 -*-
def merge_sort(to_sort_list):
if len(to_sort_list) == 1:
return to_sort_list
half = len(to_sort_list) / 2
to_sort_list[:] = merge(merge_sort(to_sort_list[:half]), merge_sort(to_sort_list[half:]))
return to_sort_list
def merge(left_list, right_list):
left_pos = rig... | mit | Python | |
5be6bdaadc75909da5b92c9895721415ffe9d613 | Create reapi.py | ArtiomL/tls-scan,ArtiomL/tls-scan | lib/reapi.py | lib/reapi.py | mit | Python | ||
741a2edeb2702129a4ff028b0b7b8594219e5424 | Add ordering to models | City-of-Helsinki/smbackend,City-of-Helsinki/smbackend | services/migrations/0037_add_ordering_to_ontologymodels.py | services/migrations/0037_add_ordering_to_ontologymodels.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-08-29 07:55
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('services', '0036_unit_contract_type'),
]
operations = [
migrations.AlterModelOption... | agpl-3.0 | Python | |
4e53ea6ea9e3f5f409014221c000486bc188769f | Add presubmit checks for suppressions. | meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-ux/meego-app-browser,meego-tablet-u... | tools/heapcheck/PRESUBMIT.py | tools/heapcheck/PRESUBMIT.py | # Copyright (c) 2010 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.
"""
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details on the presubmit API built into gcl.
"""
def CheckChang... | bsd-3-clause | Python | |
3131583796f950017a6489a45793f99439f5a5e2 | Add DB upgrade script | ddayguerrero/blogme,ddayguerrero/blogme,ddayguerrero/blogme,ddayguerrero/blogme,ddayguerrero/blogme | db_upgrade.py | db_upgrade.py | #!flask/bin/python
from migrate.versioning import api
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
print('Current databser version: ' + str(v))
| mit | Python | |
a30880ab8f1632d09d8483daf693279a49e5406b | add re06.py | devlights/try-python | trypython/stdlib/re_/re06.py | trypython/stdlib/re_/re06.py | """
正規表現のサンプルです
「ブラケット表現」について
"""
import re
from trypython.common.commoncls import SampleBase
from trypython.common.commonfunc import pr
from trypython.stdlib.re_ import util
class Sample(SampleBase):
def exec(self):
# -----------------------------------------------------------
# ブラケット表現
... | mit | Python | |
027d548300c6f3ec950d6f1d492305ab316d5545 | Add FPS test script. | openmv/openmv,iabdalkader/openmv,kwagyeman/openmv,kwagyeman/openmv,openmv/openmv,kwagyeman/openmv,openmv/openmv,iabdalkader/openmv,iabdalkader/openmv,openmv/openmv,kwagyeman/openmv,iabdalkader/openmv | usr/examples/15-Tests/fps.py | usr/examples/15-Tests/fps.py | # FPS Test Script.
import sensor, image, time
sensor.reset() # Initialize the camera sensor.
sensor.set_framesize(sensor.QQVGA) # or sensor.QQVGA (or others)
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_colorbar(True) # Enable colorbars output
clock = time.clock() # Tracks FPS.
for i in rang... | mit | Python | |
ec6b8de8cb513f34185348536dae55d294464bf8 | update array_partition_561.py | lanpong/LeetCode,lanpong/LeetCode | Python/array_partition_561.py | Python/array_partition_561.py | # Given an array of 2n integers, your task is to group these integers into n pairs of integer,
# say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible.
# Example 1:
# Input: [1,4,3,2]
# Output: 4
# Explanation: n is 2, and the maximum sum of pairs is 4 = min(... | mit | Python | |
9134f200199f0ae4cfe8384feec2690afb64f31b | Add PELT simulator | credp/lisa,ARM-software/lisa,ARM-software/lisa,ARM-software/lisa,ARM-software/lisa,credp/lisa,credp/lisa,credp/lisa | lisa/pelt.py | lisa/pelt.py | # SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2019, Arm Limited and contributors.
#
# 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
#
# ... | apache-2.0 | Python | |
6f0d214e300c7016d8bf2886b8ec3a7c6ebd9748 | add data queue | polltooh/CNN_LSTM | data_queue.py | data_queue.py | import numpy as np
import cv2
class DATA_QUEUE():
def __init__(self):
# self.data = np.load("mnist_test_seq.npy")
self.data = np.load("temp.npy")
print("after loading the data")
self.data_shape = self.data.shape
self.start_index = 0
self.data_num = self.data.shape[1]
def get_next_batch(self, batch_size... | mit | Python | |
03c37ec9def64bf7e71f95ce5d9fa618d2b37bcf | add some jsonrpc_objects tests | gonicus/gosa,gonicus/gosa,gonicus/gosa,gonicus/gosa | backend/src/tests/backend/components/test_jsonrpc_objects.py | backend/src/tests/backend/components/test_jsonrpc_objects.py | # This file is part of the GOsa framework.
#
# http://gosa-project.org
#
# Copyright:
# (C) 2016 GONICUS GmbH, Germany, http://www.gonicus.de
#
# See the LICENSE file in the project's top-level directory for details.
import pytest
from gosa.backend.components.jsonrpc_objects import JSONRPCObjectMapper, ObjectRegistr... | lgpl-2.1 | Python | |
7035644784c64bf166846872b93a815a55311fd7 | Create defaultmac.py | jgamblin/randommac | defaultmac.py | defaultmac.py | #!/usr/bin/env python
# Name: defaultmac.py
# Purpose: Set Mac Adress to Hardware Address.
# By: Jerry Gamblin
# Date: 27.07.15
# Modified 27.07.15
# Rev Level 0.1
# -----------------------------------------------
import os
import random
import fcntl
import socket
import struct
import subprocess
impor... | mit | Python | |
f0a721f2dbc4b8b9354e459d45325a08a646e09b | Add py solution for 329. Longest Increasing Path in a Matrix | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | py/longest-increasing-path-in-a-matrix.py | py/longest-increasing-path-in-a-matrix.py | from collections import Counter
class Solution(object):
def dfs(self, dp, matrix, x, y, w, h):
v = matrix[x][y]
if dp[x, y] == 0:
dp[x, y] = 1 + max(
0 if x == 0 or matrix[x - 1][y] <= v else self.dfs(dp, matrix, x - 1, y, w, h),
0 if y == 0 or matrix[x][y... | apache-2.0 | Python | |
3475770a1d6c40dde869152ba2111f2fd8f90f80 | Add missing base file. | nyu-mll/spinn,nyu-mll/spinn,nyu-mll/spinn | python/spinn/data/dual_arithmetic/base.py | python/spinn/data/dual_arithmetic/base.py | from spinn import util
NUMBERS = range(-10, 11)
FIXED_VOCABULARY = {str(x): i + 1 for i, x in enumerate(NUMBERS)}
FIXED_VOCABULARY.update({
util.PADDING_TOKEN: 0,
"+": len(FIXED_VOCABULARY) + 1,
"-": len(FIXED_VOCABULARY) + 2
})
assert len(set(FIXED_VOCABULARY.values())) == len(FIXED_VOCABULARY.values())
| mit | Python | |
95d022ab243dcd5049193b7d59bd2cdda97adc81 | Add tests for apply_patch | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | corehq/apps/app_manager/tests/views/test_apply_patch.py | corehq/apps/app_manager/tests/views/test_apply_patch.py | import difflib
from ...views.forms import apply_patch
def test_empty_patch():
diff(apply_patch("", ""), "")
def test_vellum_xml_patch():
# Form and patch generated by creating a simple form in stand-alone Vellum
# and then inspecting a save call in src/core.js with the debugger.
diff(apply_patch(PA... | bsd-3-clause | Python | |
1f3f8fe1eb5c27ed1c7c4ae3dd47e84d4342b17a | Fix missing disambiguation models | wikilinks/nel,wikilinks/nel | nel/model/disambiguation.py | nel/model/disambiguation.py | #!/usr/bin/env python
import math
import msgpack
import base64
from itertools import izip
from .data import ObjectStore
import logging
log = logging.getLogger()
def msgpack_deserialize(data):
return msgpack.loads(base64.b64decode(data))
class EntityCounts(object):
""" Entity count model """
def __init__... | mit | Python | |
b1be1e21c18ffe97a854d903fe74ee6e49a7e45c | Add tests for tilequeue.store.TileDirectory. | mapzen/tilequeue,tilezen/tilequeue | tests/store.py | tests/store.py | '''
Tests for `tilequeue.store`.
'''
import unittest
from tilequeue import store
from tilequeue import format
from ModestMaps.Core import Coordinate
import os
class TestTileDirectory(unittest.TestCase):
def test_write_tile(self):
dir_path = 'tests/fixtures/tiles_dir'
# Verify that the `TileDirec... | mit | Python | |
fe1db3cf3626da4b96f4e97031a8ed3522c8abde | test version 👀 | codl/forget,codl/forget,codl/forget,codl/forget | test/test_version.py | test/test_version.py | import re
import version
def test_version_looks_like_a_version():
assert re.match(
'v?[0-9]+.[0-9]+.[0-9]+(-[A-Za-z0-9\-.]+)?',
version.version)
def test_libversion_url():
import libforget.version
assert libforget.version.url_for_version(version.version)
| isc | Python | |
0fb710cd63496d8f57ccade50d4fae7dfc9017a7 | Create 3-29.py | mschruf/python | Algorithm_Design_Manual/3-29.py | Algorithm_Design_Manual/3-29.py | #!/usr/bin/python -tt
"""O(n) solution to problem 3-29 from /The Algorithm Design Manual/, 2nd ed.,
by Steven Skiena
"""
import sys
def get_word_pair_counts(filename):
"""Counts word pairs in file.
Args:
filename: input file path
Returns:
Dictionary mapping word pairs (as strings 'word1... | cc0-1.0 | Python | |
31bea4527b58c8e86ab1c5f46511b595c1114f1f | Remove the old built-in Heroku stuff | eskwire/evesrp,paxswill/evesrp,paxswill/evesrp,eskwire/evesrp,paxswill/evesrp,eskwire/evesrp,eskwire/evesrp | evesrp/__init__.py | evesrp/__init__.py | import importlib
import locale
import requests
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask.ext.principal import Principal
requests_session = requests.Session()
app = Flask('evesrp')
# SQLALCHEMY_DATABASE_URI gets set by the Heroku extension ... | import importlib
import locale
import requests
from flask import Flask
from flask.ext.heroku import Heroku
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask.ext.principal import Principal
requests_session = requests.Session()
app = Flask('evesrp')
# SQLALCHEMY_DATABASE_U... | bsd-2-clause | Python |
d3ced694aee9fbfe6536546ad56e6d2877621aba | Create LinkedListCycle2_002.py | cc13ny/algo,cc13ny/Allin,cc13ny/Allin,Chasego/codi,Chasego/cod,Chasego/cod,cc13ny/algo,Chasego/codi,Chasego/codi,cc13ny/algo,cc13ny/Allin,Chasego/codirit,Chasego/codi,Chasego/codirit,Chasego/cod,cc13ny/algo,cc13ny/Allin,Chasego/cod,Chasego/codirit,Chasego/codirit,Chasego/codi,cc13ny/Allin,Chasego/codirit,Chasego/cod,cc... | leetcode/142-Linked-List-Cycle-II/LinkedListCycle2_002.py | leetcode/142-Linked-List-Cycle-II/LinkedListCycle2_002.py | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param head, a ListNode
# @return a list node
def detectCycle(self, head):
if head == None or head.next == None:
return None
sl... | mit | Python | |
cf836bc510e0288dc941f038e8e0cd697eaf74bc | Create solution.py | lilsweetcaligula/Online-Judges,lilsweetcaligula/Online-Judges,lilsweetcaligula/Online-Judges | leetcode/easy/delete_node_in_a_linked_list/py/solution.py | leetcode/easy/delete_node_in_a_linked_list/py/solution.py | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def deleteNode(self, node):
"""
:type node: ListNode
:rtype: void Do not return anything, modify node in-place instead.
... | mit | Python | |
2c738edb8ed1a06146e6e0ad597cb010a7b1cc5e | add transcribe tool | xiaoxq/apollo,xiaoxq/apollo,jinghaomiao/apollo,jinghaomiao/apollo,wanglei828/apollo,ycool/apollo,ApolloAuto/apollo,jinghaomiao/apollo,xiaoxq/apollo,ApolloAuto/apollo,jinghaomiao/apollo,ApolloAuto/apollo,wanglei828/apollo,wanglei828/apollo,ApolloAuto/apollo,ycool/apollo,wanglei828/apollo,ycool/apollo,xiaoxq/apollo,wangl... | modules/tools/rosbag/transcribe.py | modules/tools/rosbag/transcribe.py | #!/usr/bin/env python
###############################################################################
# Copyright 2017 The Apollo 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 ... | apache-2.0 | Python | |
5c3cdc7a23fc1b0733b8b8bb9266c6d8c419dcd4 | Add py solution for 712. Minimum ASCII Delete Sum for Two Strings | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | py/minimum-ascii-delete-sum-for-two-strings.py | py/minimum-ascii-delete-sum-for-two-strings.py | class Solution(object):
def minimumDeleteSum(self, s1, s2):
"""
:type s1: str
:type s2: str
:rtype: int
"""
prev = [0]
for c in s2:
prev.append(prev[-1] + ord(c))
for i1, c1 in enumerate(s1, 1):
nxtRow = [0] * (len(s2) + 1)
... | apache-2.0 | Python | |
4c5795a6ed0d1710c5d874953b2bc8c48b635da9 | Add a set of undocumented quick add helpers | matthiask/towel,matthiask/towel,matthiask/towel,matthiask/towel | towel/quick.py | towel/quick.py | from datetime import date, timedelta
from django.utils import dateformat
from django.utils.datastructures import MultiValueDict
from django.utils.translation import ugettext as _
def parse_quickadd(quick, regexes):
data = {}
rest = []
while quick:
for r, p in regexes:
match = r.match... | bsd-3-clause | Python | |
379f64f528509713414069793e59b0bba4b711ec | add tests for coerce. | learntextvis/textkit | tests/test_coerce.py | tests/test_coerce.py |
from textkit.coerce import coerce_types
def test_coerce_types():
content = [
["happy", "9"],
["day", "8"],
["4", "7"],
["YOU!", "6"]
]
tokens = coerce_types(content)
assert len(tokens) == 4
assert tokens[0][0] == "happy"
assert tokens[0][1] == 9
assert tok... | mit | Python | |
d77cff9cc75b949b63d9497db54a5d86aabf9281 | Add a testcase for Manual | lilydjwg/nvchecker | tests/test_manual.py | tests/test_manual.py | from tests.helper import ExternalVersionTestCase
class ManualTest(ExternalVersionTestCase):
def test_manual(self):
self.assertEqual(self.sync_get_version("example", {"manual": "Meow"}), "Meow")
| mit | Python | |
d3731c0b3c15b6f321a91121300de4da7d47acca | Move module namespace test to a separate test script. | splunk/splunk-sdk-python,ww9rivers/splunk-sdk-python,kkirsche/splunk-sdk-python,lowtalker/splunk-sdk-python,sullivanmatt/splunk-sdk-python,kkirsche/splunk-sdk-python,kkirsche/splunk-sdk-python,kkirsche/splunk-sdk-python,splunk/splunk-sdk-python | tests/test_module.py | tests/test_module.py | #!/usr/bin/env python
#
# Copyright 2011-2012 Splunk, 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... | apache-2.0 | Python | |
a07123fe9faa34f99084ee7ce2c2b0f334be3deb | add a test | joshspeagle/dynesty | tests/test_resume.py | tests/test_resume.py | import dynesty
import dynesty.dynamicsampler as dds
import numpy as np
import multiprocessing as mp
import os
import time
import pytest
from utils import get_rstate
def like(x):
return -.5 * np.sum(x**2)
def ptform(x):
return 20 * x - 10
def interrupter(pid, dt):
time.sleep(dt)
os.kill(pid, 9)
d... | mit | Python | |
7e4aab6980519fd8124e36a6f8fd4415eaf8a4e7 | Add a single testcase for the tracer | schieb/angr,tyb0807/angr,tyb0807/angr,f-prettyland/angr,iamahuman/angr,angr/angr,angr/tracer,schieb/angr,iamahuman/angr,angr/angr,iamahuman/angr,schieb/angr,f-prettyland/angr,tyb0807/angr,f-prettyland/angr,angr/angr | tests/test_tracer.py | tests/test_tracer.py | import os
import nose
import tracer
import logging
l = logging.getLogger("tracer.tests.test_tracer")
bin_location = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../binaries'))
pov_location = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), "povs"))
test_data_location = str(os.path.di... | bsd-2-clause | Python | |
e3404cf70afe7585a2725762df69a62de45a9798 | print in format that can be used in epm.yaml | vaporry/btcrelay,ethereum/btcrelay,ethereum/btcrelay,ethers/btcrelay | script/abiRelayTx.py | script/abiRelayTx.py | from pyepm import api
headers = [
"0100000050120119172a610421a6c3011dd330d9df07b63616c2cc1f1cd00200000000006657a9252aacd5c0b2940996ecff952228c3067cc38d4885efb5a4ac4247e9f337221b4d4c86041b0f2b5710",
"0100000006e533fd1ada86391f3f6c343204b0d278d4aaec1c0b20aa27ba0300000000006abbb3eb3d733a9fe18967fd7d4c117e4ccbbac5... | from pyepm import api
headers = [
"0100000050120119172a610421a6c3011dd330d9df07b63616c2cc1f1cd00200000000006657a9252aacd5c0b2940996ecff952228c3067cc38d4885efb5a4ac4247e9f337221b4d4c86041b0f2b5710",
"0100000006e533fd1ada86391f3f6c343204b0d278d4aaec1c0b20aa27ba0300000000006abbb3eb3d733a9fe18967fd7d4c117e4ccbbac5... | mit | Python |
c108147bd1d421443010640ea4ed206d4d0131e5 | Add a tool to insepct filesystems. | vasilvv/mrtools,vasilvv/mrtools | mrfilesys.py | mrfilesys.py | #!/usr/bin/env python
#
## mrfilesys
##
## This program provides an interface to retrieve information about Moira filesystems.
## It could also provide the writing functions, but the developer of this software does
## not have access to test that functionality nor is insane enough to set up a test Moira
## server.
#
... | mit | Python | |
b6c1e7a961ca32178023593ad03bd1ab735553b2 | Add some utils in BasicBlockUtils.h | llvmpy/llvmpy,llvmpy/llvmpy,llvmpy/llvmpy,llvmpy/llvmpy,llvmpy/llvmpy,llvmpy/llvmpy | llvmpy/src/Transforms/Utils/BasicBlockUtils.py | llvmpy/src/Transforms/Utils/BasicBlockUtils.py | from binding import *
from src.namespace import llvm
from src.Value import MDNode
from src.Instruction import Instruction, TerminatorInst
llvm.includes.add('llvm/Transforms/Utils/BasicBlockUtils.h')
SplitBlockAndInsertIfThen = llvm.Function('SplitBlockAndInsertIfThen',
ptr(Ter... | bsd-3-clause | Python | |
c784dc8582a53f114e1c18fb718fba1555f03458 | Add BoxAtlas class. | fangohr/oommf-python,fangohr/oommf-python,fangohr/oommf-python | new/atlas.py | new/atlas.py | class BoxAtlas(object):
def __init__(self, cmin, cmax, atlasname='atlas',
regionname='regionname'):
if cmin[0] >= cmax[0] or cmin[1] >= cmax[1] or cmin[2] >= cmax[2]:
raise ValueError('Values in cmin should be smaller tha cmax.')
else:
self.cmin = cmin
... | bsd-2-clause | Python | |
a10880753410abcbb788843037474a14b109a3e5 | Add tests for WritableNestedSerializer | lampwins/netbox,digitalocean/netbox,lampwins/netbox,digitalocean/netbox,digitalocean/netbox,lampwins/netbox,digitalocean/netbox,lampwins/netbox | netbox/utilities/tests/test_api.py | netbox/utilities/tests/test_api.py | from django.urls import reverse
from rest_framework import status
from dcim.models import Region, Site
from ipam.models import VLAN
from utilities.testing import APITestCase
class WritableNestedSerializerTest(APITestCase):
"""
Test the operation of WritableNestedSerializer using VLANSerializer as our test su... | apache-2.0 | Python | |
28a0e384cd02ce7d7929d5ae4abb915b724e2961 | Add trivec example | EtienneCmb/tensorpac,EtienneCmb/tensorpac | dvp/trivec.py | dvp/trivec.py | from tensorpac import Pac
from tensorpac.utils import PacTriVec, PacSignals
import matplotlib.pyplot as plt
data, time = PacSignals(famp=120, noise=3, tmax=1, ndatasets=1, dpha=10, damp=10)
ampvec, ampidx = PacTriVec(fwidth=2, fend=200) #
p = Pac(idpac=(2, 4, 1), fpha=[9, 11], famp=ampvec,
dcomplex='hilbert... | bsd-3-clause | Python | |
0af27e9e03d220d12d035e1b6fb3ab94876e30b4 | Add fitsinfo script | spacetelescope/PyFITS,spacetelescope/PyFITS | pyfits/scripts/fitsinfo.py | pyfits/scripts/fitsinfo.py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import argparse
import logging
import pyfits as fits
log = logging.getLogger(__name__)
def fitsinfo(filename):
"""
Print a summary of th... | bsd-3-clause | Python | |
d5d522c0b645f9aba713d1d4d1184afc6c63922c | copy propagate test | stonebig/numba,stonebig/numba,sklam/numba,gmarkall/numba,stuartarchibald/numba,IntelLabs/numba,gmarkall/numba,sklam/numba,jriehl/numba,cpcloud/numba,jriehl/numba,IntelLabs/numba,numba/numba,jriehl/numba,numba/numba,seibert/numba,cpcloud/numba,sklam/numba,stonebig/numba,stuartarchibald/numba,seibert/numba,sklam/numba,nu... | numba/tests/test_copy_propagate.py | numba/tests/test_copy_propagate.py | from numba import compiler, typing
from numba.targets import cpu
from numba import types
from numba.targets.registry import cpu_target
from numba import config
from numba.annotations import type_annotations
from numba.ir_utils import copy_propagate, apply_copy_propagate, get_name_var_table
from numba import ir
from num... | bsd-2-clause | Python | |
d0741ef953fbc5f7e82b1fa8c0124a74f6f26049 | Make fields of ApiKeyInline readonly | Mariatta/pythondotorg,manhhomienbienthuy/pythondotorg,manhhomienbienthuy/pythondotorg,proevo/pythondotorg,manhhomienbienthuy/pythondotorg,python/pythondotorg,manhhomienbienthuy/pythondotorg,proevo/pythondotorg,Mariatta/pythondotorg,proevo/pythondotorg,Mariatta/pythondotorg,proevo/pythondotorg,Mariatta/pythondotorg,pyth... | users/admin.py | users/admin.py | from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import ugettext_lazy as _
from tastypie.admin import ApiKeyInline as TastypieApiKeyInline
from tastypie.models import ApiKey
from .actions import export_csv
from .models import User, Members... | from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import ugettext_lazy as _
from tastypie.admin import ApiKeyInline
from tastypie.models import ApiKey
from .actions import export_csv
from .models import User, Membership
class MembershipIn... | apache-2.0 | Python |
977434927f69e1c3488617b5efc163b89f048695 | Añade model para event | abertal/alpha,abertal/alpha,abertal/alpha,abertal/alpha,migonzalvar/alpha,migonzalvar/alpha,migonzalvar/alpha,migonzalvar/alpha | core/migrations/0018_event.py | core/migrations/0018_event.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-26 14:41
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0017_auto_20170426_1007'),
]
operations = [
migrations.CreateModel(
... | bsd-3-clause | Python | |
7a0a82ea85fa9f09af7dc63437744db5d199c902 | Add code for ridge prediction for solar energy | uwkejia/Clean-Energy-Outlook | Clean_Energy_Outlook/Ridge_pred_solar.py | Clean_Energy_Outlook/Ridge_pred_solar.py | # import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import linear_model
from sklearn.model_selection import train_test_split
# define the function to predict solar data in the future
def pred_nuclear(samplefile, filelist):
# read data
data = pd.read_csv(samplefile... | mit | Python | |
8dc001cb33cf27d940fbe472ab612d8a030bf660 | Add a Qt viewer for AVT camera through Vimba. | microy/PyStereoVisionToolkit,microy/VisionToolkit,microy/StereoVision,microy/PyStereoVisionToolkit,microy/StereoVision,microy/VisionToolkit | PyStereoVisionToolkit/Camera.py | PyStereoVisionToolkit/Camera.py | # -*- coding:utf-8 -*-
#
# Module to display live images from a camera
#
#
# External dependencies
#
import ctypes as ct
import sys
import numpy as np
from PySide import QtCore
from PySide import QtGui
import Vimba
#
# Qt Widget to display the images from a camera
#
class CameraWidget( QtGui.QLabel ) :
#
# Si... | mit | Python | |
b87c9002aeabde283f2cf5e37de311fb3469af2b | Add OpenStack Client Config module | thaim/ansible,thaim/ansible | lib/ansible/modules/cloud/openstack/os_client_config.py | lib/ansible/modules/cloud/openstack/os_client_config.py | #!/usr/bin/python
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# This module 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 late... | mit | Python | |
fc0d13b29dc9bc7148c590ab770b220e31bb243d | Create ConfigStatus which returns formatted texts for every known config value. Add ConfigStatusAction to send them. | alvarogzp/telegram-bot,alvarogzp/telegram-bot | bot/action/standard/config_status.py | bot/action/standard/config_status.py | from bot.action.core.action import Action
from bot.action.standard.userinfo import UserStorageHandler
from bot.action.util.format import ChatFormatter
from bot.action.util.textformat import FormattedText
from bot.storage import State, Config
class ConfigStatusAction(Action):
def process(self, event):
resp... | agpl-3.0 | Python | |
4f95d1765e7f08adfa05386856e0b403471e9abe | Test plebiscito | jvicu2001/alexis-bot | modules/plebiscito2020cl.py | modules/plebiscito2020cl.py | import json
from datetime import datetime
from json import JSONDecodeError
from discord import Embed, Forbidden, HTTPException
from bot import Command, categories
from bot.lib.guild_configuration import GuildConfiguration
class Plebiscito2020CL(Command):
__author__ = 'makzk'
__version__ = '0.0.1'
url = ... | mit | Python | |
09f1768b5b451d34d3d32aac4e76c2d21c7014a9 | Add tool | JonathanSalwan/Triton,JonathanSalwan/Triton,JonathanSalwan/Triton,JonathanSalwan/Triton,JonathanSalwan/Triton | src/tools/memory_tracer.py | src/tools/memory_tracer.py | #!/usr/bin/env python2
## -*- coding: utf-8 -*-
##
## Triton tool to trace memory access.
## Jonathan Salwan - 2015-04-30
##
## Description:
## ------------
##
## This tool is used to trace all memory access. With this tool, you know
## which instruction read or write in memory, where it reads/writes,
## the access' ... | apache-2.0 | Python | |
0da1480903e965597fd4450c8dea28a7d8bd6a44 | Add Kahn's algorithm in python | ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovs... | graph/Python/kahn_algorithm.py | graph/Python/kahn_algorithm.py |
from collections import defaultdict
#Class to represent a graph
class Graph:
def __init__(self,vertices):
self.graph = defaultdict(list) #dictionary containing adjacency List
self.V = vertices #No. of vertices
# function to add an edge to graph
def addEdge(self,u,v):
self.graph[... | cc0-1.0 | Python | |
67e1dab6da98b03b29c164dc86ee1ea183fcc12e | Create __init__.py | Dylan-halls/Theseus,Dylan-halls/Theseus,Dylan-halls/Theseus | src/proxy/__init__.py | src/proxy/__init__.py | pass
| mit | Python | |
fbe18ccb1604a25c919ba66cf955fb1720212a30 | Add oclPyObjGenerator.py, it's basically not implemented yet. It tends to utilize those generated ocl struct.h & kernel.c for the python object creator | kilikkuo/kernel-mapper,PyOCL/kernel-mapper | oclPyObjGenerator.py | oclPyObjGenerator.py | import os
from pprint import pprint
from utilityFunc import splitNameToWords, getStructFileName
def getClassDef(strName, inheritCls=[]):
strCls = 'class %s'%(strName)
for idx, cls in enumerate(inheritCls):
if idx == 0:
strCls += '('
strCls += cls
strCls += ')' if idx == (len... | apache-2.0 | Python | |
e3d3008c43d0e815c9710abd9e8f681735a0e7bf | load config | BindEmotions/M | downloader.py | downloader.py | # -*- coding: utf-8 -*-
import urllib2
try: import simplejson as json
except ImportError: import json
import os
import sys
# load URL
try:
loadConfig = open('url.json', 'r')
configURL = json.load(loadConfig)
loadConfig.close()
url = configURL['url']
name = configURL['name']
version = configURL[... | mit | Python | |
a0c5883d974f5c7285b941ec47e73f86d13a4f0e | add auto-generated data container description | simphony/simphony-common | simphony/io/data_container_description.py | simphony/io/data_container_description.py | # code auto-generated by the cuba-generate.py script.
import tables
class Data(tables.IsDescription):
name = tables.StringCol(pos=0, shape=(20,))
direction = tables.Float64Col(pos=1, shape=(3,))
status = tables.Int32Col(pos=2, shape=(1,))
label = tables.Int32Col(pos=3, shape=(1,))
material_id = t... | bsd-2-clause | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.