commit stringlengths 40 40 | subject stringlengths 1 1.49k | old_file stringlengths 4 311 | new_file stringlengths 4 311 | new_contents stringlengths 1 29.8k | old_contents stringlengths 0 9.9k | lang stringclasses 3
values | proba float64 0 1 |
|---|---|---|---|---|---|---|---|
9f9955ff920d88cb0c9dd7ce4abeaac54a1c4977 | add tests for the migration command | corehq/motech/repeaters/tests/test_repeaters_migration.py | corehq/motech/repeaters/tests/test_repeaters_migration.py | from django.core.management import call_command
from django.test import TestCase
from corehq.motech.dhis2.repeaters import (
SQLDhis2EntityRepeater,
SQLDhis2Repeater,
)
from corehq.motech.fhir.repeaters import SQLFHIRRepeater
from corehq.motech.models import ConnectionSettings
from corehq.motech.repeaters.dbac... | Python | 0.000001 | |
f4bf1c83f55013051037b4380f1b579375bad3d7 | Add test for ContextAwareForm | backend/tests/api/test_forms.py | backend/tests/api/test_forms.py | import pytest
from api.forms import ContextAwareForm
from users.models import User
def test_cannot_use_form_context_if_its_not_passed():
class TestModelForm(ContextAwareForm):
class Meta:
model = User
fields = ('id',)
form = TestModelForm()
with pytest.raises(ValueError... | Python | 0 | |
3d40378e0e42f62615199daf97a48f24d5b9eb12 | add basic test for LIS | test_lis.py | test_lis.py | import unittest
import lis
class TestLis(unittest.TestCase):
def test_basic(self):
l = lis.Lis()
answer = [[0, 4, 6, 9, 13, 15], [0, 2, 6, 9, 13, 15], [0, 4, 6, 9, 11, 15], [0, 2, 6, 9, 11, 15]]
self.assertEquals(answer, l.lis([0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]))
if __n... | Python | 0.000001 | |
e12cbd29d6180b79eb408f8f34709af609256552 | add missing file | src/spectrum/transfer.py | src/spectrum/transfer.py | """Linear systems"""
#import numpy
#from levinson import *
#from linear_prediction import *
__all__ = ["tf2zp"]
"""to be done
latc2tf Convert lattice filter parameters to transfer function form
polyscale Scale roots of polynomial
polystab Stabilize polynomial
residuez z-transform partial-fraction expan... | Python | 0.000003 | |
71675f81214ea510c377abf23fe2a11dfb113717 | create module | pyAhocorasick/pyAhocorasick.py | pyAhocorasick/pyAhocorasick.py | #-*- encoding=utf-8 -*-
'''
Created on Mar 15, 2014
@author: tonyzhang
'''
| Python | 0.000001 | |
963866e795df42121f972ee2170ddeb890f7e5b7 | Create pytest test file | python-practice/test_arrays.py | python-practice/test_arrays.py | import arrays
# Reverse an array in place
def test_reverse_array():
input = [1, 2, 3]
assert arrays.reverse_array(input) == [3, 2, 1]
# Search a sorted list
def test_binary_search_no_list():
input_array = []
target = 1
assert arrays.binary_search(input_array, target) == -1
def test_binary_sea... | Python | 0.000001 | |
4932483b10876eddab39477063a9b8546e5e0f33 | Create a.py | a.py | a.py | a
| Python | 0.000489 | |
051bbd588e7ad20dd9a00918c437a86d46ba8f7e | Create transfer.py | transfer.py | transfer.py | #! /usr/bin/env python
#-*-coding:utf-8-*-
import MySQLdb
import psutil
import urllib
import time
import sys
import os
#########################################################################################################################
## MySQLdb : 在部署前需要确定系统安装了该python模块
## psutil : 在python中进行系统进程管理的模块
#########... | Python | 0.000001 | |
50e24b0445f259d975e5dd78dd34a8e760e4ed88 | Create SQLite database and table and insert data from CSV file | DB.py | DB.py | # Create a database
import sqlite3
import csv
from datetime import datetime
import sys
reload(sys)
sys.setdefaultencoding('utf8')
class createDB():
def readCSV(self, filename):
conn = sqlite3.connect('CIUK.db')
print 'DB Creation Successful!'
cur = conn.cursor()
# cur.execute(... | Python | 0 | |
874c01374397014e7c99afd67f5680ed32f1c5c6 | Build and revision number script | bn.py | bn.py | import sys
from time import gmtime
year, mon, mday, hour, min, sec, wday, yday, isdst = gmtime()
bld = ((year - 2000) * 12 + mon - 1) * 100 + mday
rev = hour * 100 + min
print 'Your build and revision number for today is %d.%d.' % (bld, rev)
| Python | 0 | |
480b0bd80f65646da52824403ade92880af1af2e | Add circle ci settings | project/circleci_settings.py | project/circleci_settings.py | # -*- coding: utf-8 -*-
DEBUG = True
LOCAL_DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'circle_test',
'USER': 'circleci',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '5432',
}
}
LOCALLY_INSTALLED_APPS = [
]
ENABLE_EMAILS = Fa... | Python | 0.000001 | |
0b01ef18535941618f833b29c7f27198e7db96dd | Create lastfm.py | apis/lastfm.py | apis/lastfm.py | """ Contains functions to fetch API information from last.fm API."""
import logging
import youtube
from utilities import web
log = logging.getLogger(__name__)
def get_lastfm_chart(chart_items=5):
"""
Finds the currently most played tunes on last.fm and turns them in to a youtube list of tracks.
:param c... | Python | 0.000004 | |
339798bbed673253358866bf083e7d974f79956c | Make sure proper_count is populated by metainfo_series | flexget/plugins/metainfo/series.py | flexget/plugins/metainfo/series.py | import logging
from string import capwords
from flexget.plugin import priority, register_plugin
from flexget.utils.titles import SeriesParser
from flexget.utils.titles.parser import ParseWarning
import re
log = logging.getLogger('metanfo_series')
class MetainfoSeries(object):
"""
Check if entry appears to be... | import logging
from string import capwords
from flexget.plugin import priority, register_plugin
from flexget.utils.titles import SeriesParser
from flexget.utils.titles.parser import ParseWarning
import re
log = logging.getLogger('metanfo_series')
class MetainfoSeries(object):
"""
Check if entry appears to be... | Python | 0.000017 |
780e4eb03420d75c18d0b21b5e616f2952aeda41 | Test sending headers with end stream. | test/test_basic_logic.py | test/test_basic_logic.py | # -*- coding: utf-8 -*-
"""
test_basic_logic
~~~~~~~~~~~~~~~~
Test the basic logic of the h2 state machines.
"""
import h2.connection
from hyperframe import frame
class TestBasicConnection(object):
"""
Basic connection tests.
"""
example_request_headers = [
(':authority', 'example.com'),
... | # -*- coding: utf-8 -*-
"""
test_basic_logic
~~~~~~~~~~~~~~~~
Test the basic logic of the h2 state machines.
"""
import h2.connection
from hyperframe import frame
class TestBasicConnection(object):
"""
Basic connection tests.
"""
example_request_headers = [
(':authority', 'example.com'),
... | Python | 0 |
8adac46cd59c562ec494508ad735843253adc1f2 | add frequencies benchmark | bench/test_frequencies.py | bench/test_frequencies.py | from toolz import frequencies, identity
data = range(1000)*1000
def test_frequencies():
frequencies(data)
| Python | 0.000001 | |
892740ce17c2906de996089f07f005c7812270ef | add init back | src/__init__.py | src/__init__.py | """ Source Files, and a location for Global Imports """
| Python | 0.000001 | |
94acf181f063808c2b6444dbc15ea40ee17bdee3 | print structure | bin/print_h5_structure.py | bin/print_h5_structure.py | import sys
file_name = sys.argv[1]
# python3 print_data_structure.py filename
import glob
import os
import numpy as n
import h5py # HDF5 support
f0 = h5py.File(file_name, "r")
def print_attr(h5item):
for attr in h5item:
print(attr, h5item[attr])
def print_all_key(h5item):
for key in h5item.keys():... | Python | 0.000004 | |
fea9e1e80d03b87c05eacd02b5440fc783eb456d | Fix buildfier | package_managers/apt_get/repos.bzl | package_managers/apt_get/repos.bzl | # 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 agre... | # 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 agre... | Python | 0.000001 |
05c103238d977fe8c5d6b614f21f581069373524 | Increase tidy column limit to 100 | src/etc/tidy.py | src/etc/tidy.py | #!/usr/bin/env python
# xfail-license
import sys, fileinput, subprocess, re
from licenseck import *
err=0
cols=100
# Be careful to support Python 2.4, 2.6, and 3.x here!
config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ],
stdout=subprocess.PIPE)
result=config_proc.communic... | #!/usr/bin/env python
# xfail-license
import sys, fileinput, subprocess, re
from licenseck import *
err=0
cols=78
# Be careful to support Python 2.4, 2.6, and 3.x here!
config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ],
stdout=subprocess.PIPE)
result=config_proc.communica... | Python | 0.000193 |
f5a561494ece69c32d4bbd3e23c435a0fe74788a | Add local enum capability (needed for contentwrapper) | processrunner/enum.py | processrunner/enum.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
# For use with deployment statuses
# https://stackoverflow.com/a/1695250
def enum(*sequential, **named):
"""An implementation of the Enum data type
Usage
myEnum= enum(
'Apple'
, 'Banana')
"""
enums = ... | Python | 0 | |
bb649f299538c76d555e30ac0d31e2560e0acd3e | Add test | tests/test_calculator.py | tests/test_calculator.py | import unittest
from app.calculator import Calculator
class TestCalculator(unittest.TestCase):
def setUp(self):
self.calc = Calculator()
def test_calculator_addition_method_returns_correct_result(self):
calc = Calculator()
result = calc.addition(2,2)
self.assertEqual(4, resu... | Python | 0.000005 | |
630309837989e79ba972358a3098df40892982f5 | Create rrd_ts_sync.py | rrd_ts_sync.py | rrd_ts_sync.py | #-------------------------------------------------------------------------------
#
# Controls shed weather station
#
# The MIT License (MIT)
#
# Copyright (c) 2015 William De Freitas
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (... | Python | 0.000005 | |
b20a6ccc211060644ff3e6f89428420fa59f5a5d | add a couple of tests for the build_scripts command | tests/test_build_scripts.py | tests/test_build_scripts.py | """Tests for distutils.command.build_scripts."""
import os
import unittest
from distutils.command.build_scripts import build_scripts
from distutils.core import Distribution
from distutils.tests import support
class BuildScriptsTestCase(support.TempdirManager, unittest.TestCase):
def test_default_settings(self... | Python | 0 | |
3cf30bac4d20dbebf6185351ba0c10426a489de9 | Add sanity linter to catch future use | tools/run_tests/sanity/check_channel_arg_usage.py | tools/run_tests/sanity/check_channel_arg_usage.py | #!/usr/bin/env python
# Copyright 2018 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | Python | 0 | |
51d0623da276aa60a0da4d48343f215f0c517a29 | Add module for ids2vecs | thinc/neural/ids2vecs.py | thinc/neural/ids2vecs.py | from ._classes.window_encode import MaxoutWindowEncode
| Python | 0 | |
16101618e41f136bf22d6c8c1c258ab42b0bb3ed | add ei algorithms | src/pymor/algorithms/ei.py | src/pymor/algorithms/ei.py | # This file is part of the pyMor project (http://www.pymor.org).
# Copyright Holders: Felix Albrecht, Rene Milk, Stephan Rave
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
from __future__ import absolute_import, division, print_function
from numbers import Number
import math as m
impo... | Python | 0.002161 | |
ada91bd1ed76d59b7ec41d765af188aed2f8fd62 | add a module for collecting Warnings | src/pymor/core/warnings.py | src/pymor/core/warnings.py | '''
Created on Nov 19, 2012
@author: r_milk01
'''
class CallOrderWarning(UserWarning):
'''I am raised when there's a preferred call order, but the user didn't follow it.
For an Example see pymor.discretizer.stationary.elliptic.cg
'''
pass | Python | 0 | |
03c1f7040cc971c6e05f79f537fc501c550edaa8 | Add back manage.py (doh). | manage.py | manage.py | #!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
conf = os.path.dirname(__file__)
wafer = os.path.join(conf, '..', 'wafer')
sys.path.append(wafer)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.core.management import execute_from_command_line
exe... | Python | 0 | |
0b88d652ddb23a385e79bfccb1db89c954d7d27f | Set up Restaurant class | get_a_lunch_spot.py | get_a_lunch_spot.py | import json
restaurants_string = """[{
"name" : "sweetgreen"
}]"""
print restaurants_string
restaurants_json = json.loads(restaurants_string)
print restaurants_json
class Restaurant:
name = ""
def __init__(self, data):
self.name = self.getName(data)
def getName(self, data):
for i in data:
ret... | Python | 0.000003 | |
6757f4b74f29142b0be7e32b8bdf210d109056ea | Create missing.py | missing.py | missing.py | import tensorflow as tf
import glob as glob
import getopt
import sys
import cPickle as pkl
import numpy as np
opts, _ = getopt.getopt(sys.argv[1:],"",["chunk_file_path=", "comp_file_path=", "means_file_path=", "output_dir=", "input_dir="])
chunk_file_path = "../video_level_feat_v1/train*.tfrecord"
comp_file_path = "..... | Python | 0.000063 | |
23e778c78c2d77a9eeb0904856429546e379f8b5 | change the version of openerp | bin/release.py | bin/release.py | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole re... | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole re... | Python | 0 |
23257c56b58c26694773fb12d3ba167de43bd43b | Add validate.py tool | validate.py | validate.py | import json
import sys
import urllib2
data=json.loads(open("bootstrap/{}.json".format(sys.argv[1])).read())
for f in data['storage']['files']:
if 'source' not in f['contents'] or 'http' not in f['contents']['source']:
continue
url = f['contents']['source']
digest = f['contents']['verification']['ha... | Python | 0.000001 | |
dd1c49eb12bf69580a8727353aa19741059df6d5 | add 102 | vol3/102.py | vol3/102.py | import urllib2
if __name__ == "__main__":
ans = 0
for line in urllib2.urlopen('https://projecteuler.net/project/resources/p102_triangles.txt'):
ax, ay, bx, by, cx, cy = map(int, line.split(','))
a = ax * by - ay * bx > 0
b = bx * cy - by * cx > 0
c = cx * ay - cy * ax > 0
... | Python | 0.999996 | |
feac5a01059a95910c76a0de5f83ad2473cf09c8 | Create app.py | app.py | app.py | import os
import sys
import tweepy
import requests
import numpy as np
import json
import os
from __future__ import print_function
from future.standard_library import install_aliases
install_aliases()
from urllib.parse import urlparse, urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTP... | Python | 0.000003 | |
1490f438693a5727c722d933a712c889d3c09556 | test where SSL proxying works | test/others/ProxyTest.py | test/others/ProxyTest.py | import urllib2
httpTarget = "http://www.collab.net"
httpsTargetTrusted = "https://ctf.open.collab.net/sf/sfmain/do/home"
httpsTargetUntrusted = "https://www.collab.net"
proxyHost = "cu182.cloud.sp.collab.net"
proxyPort = "80"
proxyUser = "proxyuser"
proxyPwd = "proxypass"
def main():
print "Testing p... | Python | 0.000002 | |
d15ba379ec48c2c5bc76eeb0f8a514625f5b9e2f | add unit test to test whether the parallel implementation is alright | tests/test_gp_algebra.py | tests/test_gp_algebra.py | import pytest
import pickle
import os
import json
import numpy as np
from pytest import raises
from flare.gp import GaussianProcess
from flare.env import AtomicEnvironment
from flare.struc import Structure
from flare import mc_simple
from flare.otf_parser import OtfAnalysis
from flare.env import AtomicEnvironment
fro... | Python | 0 | |
aa1808c9a13894751953c8a1c816c89861e514d1 | Create new package. (#6061) | var/spack/repos/builtin/packages/r-iso/package.py | var/spack/repos/builtin/packages/r-iso/package.py | ##############################################################################
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | Python | 0 | |
384033b6b5d7a3b207c1360b896f70bfbc064caf | Update __init__.py | tendrl/integrations/gluster/sds_sync/__init__.py | tendrl/integrations/gluster/sds_sync/__init__.py | import etcd
import time
from tendrl.commons.objects.job import Job
from tendrl.commons import sds_sync
from tendrl.commons.utils import log_utils as logger
import uuid
class GlusterIntegrtaionsSyncThread(sds_sync.StateSyncThread):
def run(self):
logger.log(
"debug",
NS.get("publi... | import etcd
import time
from tendrl.commons.objects.job import Job
from tendrl.commons import sds_sync
from tendrl.commons.utils import log_utils as logger
import uuid
class GlusterIntegrtaionsSyncThread(sds_sync.StateSyncThread):
def run(self):
logger.log(
"debug",
NS.get("publi... | Python | 0.000072 |
930274bb8ab10379f4c76618cccc604c9fe27996 | Update the test to match removed XLA:CPU device | tensorflow/python/eager/remote_cloud_tpu_test.py | tensorflow/python/eager/remote_cloud_tpu_test.py | # Copyright 2019 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 applicable ... | # Copyright 2019 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 applicable ... | Python | 0 |
4dd36d68225311e328cc4a909b3c56bf9b6e8e53 | Create picture.py | picture.py | picture.py | from ggame import App
myapp = App()
myapp.run()
| Python | 0.000002 | |
b3a3376e90d1eede9b2d33d0a4965c1f4920f20a | Add a memoizer | memoize.py | memoize.py |
# from http://code.activestate.com/recipes/578231-probably-the-fastest-memoization-decorator-in-the-/
__all__ = ["memoize"]
def memoize(f):
""" Memoization decorator for a function taking one or more arguments. """
class memodict(dict):
def __getitem__(self, *key):
return dict.__getitem__... | Python | 0.000022 | |
9a902049212ceea29b7b0e440acd33e3c63c7beb | Add timer tests script. | scripts/examples/02-Board-Control/timer_tests.py | scripts/examples/02-Board-Control/timer_tests.py | # Timer Test Example
#
# This example tests all the timers.
import time
from pyb import Pin, Timer, LED
blue_led = LED(3)
# Note: functions that allocate memory are Not allowed in callbacks
def tick(timer):
blue_led.toggle()
print("")
for i in range(1, 18):
try:
print("Testing TIM%d... "%(i), end="... | Python | 0 | |
11447d409756f2bcd459a6db9d51967358272780 | move flags to constant module | hotline/constant.py | hotline/constant.py | # -*- coding: utf-8 -*-
class flags(object):
DontHide = object()
Hide = object()
_list = [DontHide, Hide]
| Python | 0.000002 | |
1840239be19af9599094c44f7b502509a87065b2 | Commit the initial codes | lambda.py | lambda.py | #!/usr/bin/env python
import abc
import sys
# constants
KEYWORDS = {"\\", "."}
# classes
## error
class Error:
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
def append_message(self, message):
self.message = message + "\n" + self.message
## AST... | Python | 0.999635 | |
0295a1cbad1dfa2443e6b8e8d639b7d845adaebf | Add lc0225_implement_stack_using_queues.py | lc0225_implement_stack_using_queues.py | lc0225_implement_stack_using_queues.py | """Leetcode 225. Implement Stack using Queues
Easy
URL: https://leetcode.com/problems/implement-stack-using-queues/
Implement the following operations of a stack using queues.
- push(x) -- Push element x onto stack.
- pop() -- Removes the element on top of the stack.
- top() -- Get the top element.
- empty() -- Retur... | Python | 0.000002 | |
0a48d3dc2286db9cff5ec757d8b5f0b45f35ab7d | update : some minor fixes | ptop/interfaces/__init__.py | ptop/interfaces/__init__.py | from .GUI import PtopGUI | Python | 0 | |
261b2477cf6f086028a1028c7d8a02f1b1631018 | add solution for Jump Game | src/jumpGame.py | src/jumpGame.py | class Solution:
# @param A, a list of integers
# @return a boolean
def canJump(self, A):
if not A:
return False
max_dist = 0
for i in xrange(len(A)):
if i > max_dist:
return False
max_dist = max(max_dist, i+A[i])
return Tru... | Python | 0 | |
5c0805edd7d54a070b7ce1942eadfc0b3ff2874b | Update memory.py | src/collectors/memory/memory.py | src/collectors/memory/memory.py | # coding=utf-8
"""
This class collects data on memory utilization
Note that MemFree may report no memory free. This may not actually be the case,
as memory is allocated to Buffers and Cache as well. See
[this link](http://www.linuxatemyram.com/) for more details.
#### Dependencies
* /proc/meminfo or psutil
"""
im... | # coding=utf-8
"""
This class collects data on memory utilization
Note that MemFree may report no memory free. This may not actually be the case,
as memory is allocated to Buffers and Cache as well. See
[this link](http://www.linuxatemyram.com/) for more details.
#### Dependencies
* /proc/meminfo or psutil
"""
im... | Python | 0 |
99f9f14039749f8e3e4340d6bf0e0394e3483ca2 | add basic propfind test | protocol/test_protocol_propfind.py | protocol/test_protocol_propfind.py | from smashbox.utilities import *
from smashbox.utilities.hash_files import *
from smashbox.protocol import *
@add_worker
def main(step):
d = make_workdir()
reset_owncloud_account()
URL = oc_webdav_url()
ls_prop_desktop20(URL,depth=0)
logger.info("Passed 1")
ls_prop_desktop20(URL,depth=1)
... | Python | 0 | |
6a4f9568560608f1a1a1a78b0968b4968c4990c7 | add agent.builtin tests. | test/unit/agent/test_builtin.py | test/unit/agent/test_builtin.py |
# Copyright (c) 2014 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the imp... | Python | 0 | |
6bbdd1d9d60b03429dc2bc1ff3ba5d06353fad9a | Add a Bug class. | libzilla/bug.py | libzilla/bug.py | class Bug:
def __init__(self,
bug_number,
comment=None,
resolution=None,
status=None):
self.bug_number = bug_number
self.resolution = resolution
self.status = status
self.comment = comment
def __str__(self):
... | Python | 0 | |
2dad699b9281fea70c5e078166236f3175ef739a | add parse2.py file to take advantage of new patXML interface | parse2.py | parse2.py | #!/usr/bin/env python
import logging
# http://docs.python.org/howto/argparse.html
import argparse
import os
import datetime
import re
import mmap
import contextlib
import multiprocessing
import itertools
import sys
sys.path.append( '.' )
sys.path.append( './lib/' )
import shutil
from patXML import XMLPatent
from pat... | Python | 0 | |
17bd35df32dd68d1cbc0fe73fcda186d13a66db0 | Add run.py | run.py | run.py | #!/usr/bin/env python3
#
# Copyright (c) 2014 Mark Samman <https://github.com/marksamman/pylinkshortener>
#
# 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 with... | Python | 0.000009 | |
f1debd46a0d7d8442490f320602bbcb1702d529c | Create name_parser.py | name_parser.py | name_parser.py | #!/usr/bin/env python
def ParseFullName(full_name):
"""name_parser.ParseFullName
Purpose: Advanced name field Parseting that recognizes most multi-word last
names.
INPUTS:
full_name -- A string containing the name field to be parsed
OUTPUTS:
names -- A list of name dictionar... | Python | 0 | |
7613285ba24990d62cf2273387a143aa74ce8bb0 | add shortcut to send sms message | nexmo/utils.py | nexmo/utils.py | from .libpynexmo.nexmomessage import NexmoMessage
from django.conf import settings
def send_message(to, message):
"""Shortcut to send a sms using libnexmo api.
Usage:
>>> from nexmo import send_message
>>> send_message('+33612345678', 'My sms message body')
"""
params = {
'username':... | Python | 0.000001 | |
49b68f35bb6555eaad7cd5e3bfeb4e7fadb500ba | Add intermediate tower 4 | pythonwarrior/towers/intermediate/level_004.py | pythonwarrior/towers/intermediate/level_004.py | # ----
# |C s |
# | @ S|
# |C s>|
# ----
level.description("Your ears become more in tune with the surroundings. "
"Listen to find enemies and captives!")
level.tip("Use warrior.listen to find spaces with other units, "
"and warrior.direction_of to determine what direction they're in.")
l... | Python | 0.998117 | |
7662d0a0701381b37f60d42e7dbf04d7950c18ad | add management command to print out duplicate bihar tasks | custom/bihar/management/commands/bihar_cleanup_tasks.py | custom/bihar/management/commands/bihar_cleanup_tasks.py | import csv
from django.core.management.base import BaseCommand
from corehq.apps.hqcase.utils import get_cases_in_domain
from dimagi.utils.decorators.log_exception import log_exception
class Command(BaseCommand):
"""
Creates the backlog of repeat records that were dropped when bihar repeater
infrastructure... | Python | 0.000001 | |
7d4cdd3fbbf52143d0b1297a6695ce6b336b2b9d | Add a preprocessor script that does n-gram expansion based on either POS tags or words. For every expansion we start with a word unigram, and then try to extend to a part of speech tag or a word. | util/extend.py | util/extend.py | #!/usr/bin/python
#
# Word and part of speech expansion preprocessor script.
#
import math
import sys
def extractWordTags(line):
wordTags = []
return wordTags
def expansionFactor(badFreq):
return 1 + math.exp(-0.5 * float(badFreq))
def readCorpus(filename):
position = 0
words = dict()
tags ... | Python | 0.000004 | |
c9f5c9bf8fffe4f513fc8564eb92ca86a76f4087 | add cluster | mypy/cluster.py | mypy/cluster.py | import os
from os.path import split
import numpy as np
from scipy import sparse
from scipy.io import loadmat
# import matplotlib.pyplot as plt
from mne.stats.cluster_level import _find_clusters
base_dir = split(split(__file__)[0])[0]
chan_path = os.path.join(base_dir, 'data', 'chan')
# read channel connectivity
d... | Python | 0.000002 | |
245879ce699b275edc3ee17e4cba1146241f25de | Add GLib mainllop transport for xmlrpcserver | wizbit/xmlrpcdeferred.py | wizbit/xmlrpcdeferred.py | import gobject
import xmlrpclib
class XMLRPCDeferred (gobject.GObject):
"""Object representing the delayed result of an XML-RPC
request.
.is_ready: bool
True when the result is received; False before then.
.value : any
Once is_ready=True, this attribute contains the result of the
re... | Python | 0 | |
0880d067f478ba6474e433e620a1e48e23ed9c34 | Add nginx+uWSGI for 10% perf improvement over gunicorn | wsgi/setup_nginxuwsgi.py | wsgi/setup_nginxuwsgi.py | import subprocess
import multiprocessing
import os
bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
config_dir = os.path.expanduser('~/FrameworkBenchmarks/config')
NCPU = multiprocessing.cpu_count()
def start(args):
try:
subprocess.check_call('sudo /usr/local/nginx/sbin/nginx -c ' +
... | Python | 0 | |
8fe4b03d7944f2facf8f261d440e7220c4d1228b | add file | Python/mapexp.py | Python/mapexp.py | #!/usr/bin/env python
"""
map(fun, iterable,...)
Return a list of the results of applying the function to the items of
the argument sequence(s). If more than one sequence is given, the
function is called with an argument list consisting of the corresponding
item of each sequence, substituting None for mi... | Python | 0.000001 | |
6dd4b6ee9b9457d2362404aac71fd73e907bf535 | Add Timeline class. | source/vistas/ui/controls/timeline.py | source/vistas/ui/controls/timeline.py | import datetime
from bisect import insort
class TimelineFilter:
pass # Todo: implement
class Timeline:
_global_timeline = None
@classmethod
def app(cls):
""" Global timeline """
if cls._global_timeline is None:
cls._global_timeline = Timeline()
return cls._glob... | Python | 0 | |
560d82cd4b7de72a4fada77b0fe13bfb1caa9790 | package script | package.py | package.py | import os
import sys
for root, dirs, files in os.walk(os.path.dirname(os.path.abspath(__file__))):
for name in files:
if name.endswith((".java")):
file = open(name, "r")
lines = file.readlines()
file.close()
file = open(name, "w")
for line in lines... | Python | 0.000002 | |
cc9ce576a33c60acc9f60f12b42e56f474b760ac | Add json_jinja renderer | salt/renderers/json_jinja.py | salt/renderers/json_jinja.py | '''
The default rendering engine, yaml_jinja, this renderer will take a yaml file
with the jinja template and render it to a high data format for salt states.
'''
# Import python libs
import os
import json
# Import Third Party libs
from jinja2 import Template
def render(template):
'''
Render the data passing... | Python | 0.000668 | |
e35711d368faadaa017186200092297f264648fe | Add web ui | nodes/web_ui.py | nodes/web_ui.py | #!/usr/bin/env python
import roslib; roslib.load_manifest('rospilot')
import rospy
from pymavlink import mavutil
import rospilot.msg
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = 8085
armed = None
#This class will handles any incoming request from
#the browser
class HttpHandler(BaseHTT... | Python | 0.000001 | |
c8ede03a393ae1287a9a34e86af40cd6a8b3027b | add missing module (RBL-3757) | mint/targets.py | mint/targets.py | #
# Copyright (c) 2008 rPath, Inc.
#
# All Rights Reserved
#
from mint import database, mint_error
import simplejson
class TargetsTable(database.KeyedTable):
name = 'Targets'
key = 'targetId'
fields = ('targetId', 'targetType', 'targetName')
def addTarget(self, targetType, targetName):
cu = ... | Python | 0 | |
3709bcbd421d82f9404ab3b054989546d95c006f | Fix another broken sc2reader.plugins reference. | sc2reader/scripts/sc2json.py | sc2reader/scripts/sc2json.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
import sc2reader
from sc2reader.factories.plugins.replay import toJSON
def main():
import argparse
parser = argparse.ArgumentParser(description="Prints replay data to a json string... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
import sc2reader
from sc2reader.plugins.replay import toJSON
def main():
import argparse
parser = argparse.ArgumentParser(description="Prints replay data to a json string.")
pa... | Python | 0 |
c3c559f893e31e728a429cf446039781cea1f25d | Add unit tests for `%tensorflow_version` | tests/test_tensorflow_magics.py | tests/test_tensorflow_magics.py | # Copyright 2019 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 agreed to in writing, ... | Python | 0 | |
cca75f45b80b72fdd4db9c06544474a2f6a40aa0 | Add a hack for importing Item data from a postgresql dump. | kirppu/management/commands/import_old_item_data.py | kirppu/management/commands/import_old_item_data.py | from collections import defaultdict
from decimal import Decimal
import sys
import re
from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction
from django.utils.dateparse import parse_datetime
from django.core.management.base import BaseCommand
try:
from typing import Dict, List
exce... | Python | 0 | |
fe879d7f6f56db410eb5d3d9aeb5691d020661c7 | Create shackbullet.py | shackbullet.py | shackbullet.py | #Import the modules
import requests
import json
import uuid
#Edit these to your shacknews login credentials
shackname = 'Username'
shackpass = 'ShackPassword'
pushbulletkey = 'access token from https://www.pushbullet.com/account'
#Fun Bbegins
#generate uuid from namespace
uuid = uuid.uuid5(uuid.NAMESPACE_DNS, 'winch... | Python | 0.000109 | |
dc4a3ec9a8bb042cef115005d8ebf11dc2c5889e | Longest increasing subsequence in the list | longest_increasing_subsequence.py | longest_increasing_subsequence.py | l = [3,4,5,9,8,1,2,7,7,7,7,7,7,7,6,0,1]
empty = []
one = [1]
two = [2,1]
three = [1,0,2,3]
tricky = [1,2,3,0,-2,-1]
ring = [3,4,5,0,1,2]
internal = [9,1,2,3,4,5,0]
# consider your list as a ring, continuous and infinite
def longest_increasing_subsequence(l):
length = len(l)
if length == 0: return 0 # list is ... | Python | 1 | |
0b419a71a414e605af57029286b627e286c5df47 | add session | controller/addSession.py | controller/addSession.py | #!/usr/local/bin/python3
"""
created_by: Aninda Manocha
created_date: 3/5/2015
last_modified_by: Aninda Manocha
last_modified_date: 3/5/2015
"""
import constants
import utils
import json
from sql.session import Session
from sql.user import User
#Format of session
#requestType: addSession
#token: "str... | Python | 0 | |
d83e30cc2ec46eeb2f7c27c26e0fc3d2d3e6de90 | add an environment checker | scripts/check_environment.py | scripts/check_environment.py | """
Something to run to make sure our machine is up to snuff!
"""
import pg
import xlwt | Python | 0 | |
ef78460a3303216f424247203cf0b5e1ecc88197 | Add test for ticket #1074. | scipy/optimize/tests/test_regression.py | scipy/optimize/tests/test_regression.py | """Regression tests for optimize.
"""
from numpy.testing import *
import numpy as np
class TestRegression(TestCase):
def test_newton_x0_is_0(self):
"""Ticket #1074"""
import scipy.optimize
tgt = 1
res = scipy.optimize.newton(lambda x: x - 1, 0)
assert_almost_equal(res, tgt... | Python | 0.000005 | |
c654841595fd679c511d2d3b91c2edc9335c78cc | Create Quiz-Problem8.py | Quiz-Problem8.py | Quiz-Problem8.py | # PROBLEM 8
def satisfiesF(L):
"""
Assumes L is a list of strings
Assume function f is already defined for you and it maps a string to a Boolean
Mutates L such that it contains all of the strings, s, originally in L such
that f(s) returns True, and no other elements
Returns the length ... | Python | 0.000001 | |
aa3cf6a383c38a9f17172ae2a754a8e67243e318 | add new form to bulk import indicators from json file | corehq/apps/indicators/forms.py | corehq/apps/indicators/forms.py | from django import forms
from django.utils.translation import ugettext_noop, ugettext as _
from bootstrap3_crispy import bootstrap as twbs
from bootstrap3_crispy.helper import FormHelper
from bootstrap3_crispy import layout as crispy
from corehq.apps.style.crispy import FormActions
class ImportIndicatorsFromJsonFileF... | Python | 0 | |
42fbeda997d5c8f67231ee5c8f420a7140870c26 | Add gce_img module for utilizing GCE image resources | lib/ansible/modules/extras/cloud/google/gce_img.py | lib/ansible/modules/extras/cloud/google/gce_img.py | #!/usr/bin/python
# Copyright 2015 Google Inc. All Rights Reserved.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your o... | Python | 0 | |
04f851706b4384add01e6cd41f31305d587f7a36 | Create pushbullet.py | pushbullet.py | pushbullet.py | # Python unofficial Pushbullet client
# (C) 2015 Patrick Lambert - http://dendory.net - Provided under MIT License
import urllib.request
import sys
api_key = "XXXXXXXXX"
title = "My Title"
message = "My Body"
def notify(key, title, text):
post_params = {
'type': 'note',
'title': title,
'body': text
}
post_ar... | Python | 0.00003 | |
57b19c56b8be8c8131cc3d98cb9f30da3398412b | create a reporting helper for logging channel info | remoto/log.py | remoto/log.py |
def reporting(conn, result):
log_map = {'debug': conn.logger.debug, 'error': conn.logger.error}
while True:
try:
received = result.receive()
level_received, message = received.items()[0]
log_map[level_received](message.strip('\n'))
except EOFError:
... | Python | 0 | |
371df7c27fa1c4130214c58ececa83b0e0b6b165 | Create palindrome3.py | palindrome3.py | palindrome3.py | palindrome3 = lambda x: str(x) == str(x)[::-1]
| Python | 0.000034 | |
5129dd5de6f4a8c0451adbb5631940bb82b51a26 | Add a script to enact updates to positions & alternative names | mzalendo/kenya/management/commands/kenya_apply_updates.py | mzalendo/kenya/management/commands/kenya_apply_updates.py | from collections import defaultdict
import csv
import datetime
import errno
import hmac
import hashlib
import itertools
import json
import os
import re
import requests
import sys
from django.core.management.base import NoArgsCommand, CommandError
from django.template.defaultfilters import slugify
from django_date_ext... | Python | 0 | |
67e7d530b4b4ffa86c9f147751cf17828e024cba | add migration to create job table | migrations/versions/5706baf73b01_add_jobs_table.py | migrations/versions/5706baf73b01_add_jobs_table.py | """Add jobs table
Revision ID: 5706baf73b01
Revises: 6bd350cf4748
Create Date: 2016-09-14 15:53:50.394610
"""
# revision identifiers, used by Alembic.
revision = '5706baf73b01'
down_revision = '6bd350cf4748'
from alembic import op
import sqlalchemy as sa
import server
def upgrade():
### commands auto generate... | Python | 0.000001 | |
ec841c86348302dc67b48af93d2b3b5c8fb96b6e | add list | misc/list.py | misc/list.py | #!/usr/bin/env python
# Python 3: List comprehensions
fruits = ['Banana', 'Apple', 'Lime']
loud_fruits = [fruit.upper() for fruit in fruits]
print(loud_fruits)
# List and the enumerate function
print(list(enumerate(fruits)))
| Python | 0.000016 | |
427fa7f57776a73b5ec0e5045114d5ac330e6a57 | Create misc.py | misc/misc.py | misc/misc.py | Python | 0 | ||
a3da01a026018ae1c612fa16d2e382ac8bbd4f6b | Add pptxsanity.py and first binary release | pptxsanity.py | pptxsanity.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# With code by Eric Jang ericjang2004@gmail.com
TIMEOUT=6 # URL request timeout in seconds
SKIP200=1
from pptx import Presentation
import sys
import re
import os
import shutil
import glob
import tempfile
import urllib2
import signal
from zipfile import ZipFile
from xml.d... | Python | 0 | |
0612769b07e88eae9865a16f1ae8162502fe65f9 | Add senate evacuation | 2016/1c/senate_evacuation.py | 2016/1c/senate_evacuation.py | #!/usr/bin/env python
from __future__ import print_function
def parse_senates(senates_str):
return [int(_) for _ in senates_str.split(' ')]
def get_evacuation_plan(senates):
if not isinstance(senates, list):
raise TypeError
num_parties = len(senates)
remaining_senates = senates[:]
evacua... | Python | 0.000367 | |
aabb57148cced94b31109b46adf83a43ca23f7a3 | allow to apply std functions back | mosql/std.py | mosql/std.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''It applies the standard functions to :mod:`mosql.util`.
The usage:
::
import mosql.std
If you want to patch again:
::
mosql.std.patch()
It will replace the functions in :mod:`mosql.util` with original standard functions.
'''
import mosql.util
def patch(... | Python | 0 | |
69892066449a40322a34b3a7b8e60e3fa99eef41 | Create deobfuscator.py | ver.-0.1/deobfuscator.py | ver.-0.1/deobfuscator.py | Python | 0.000015 | ||
3c396700a52571d5aae2a12fac601f063a7af761 | Add missing add_master.py. | devops/deployment/add_master.py | devops/deployment/add_master.py | #!/usr/bin/env python
# script to add minion config
import yaml
import sys
import os
f=open("/etc/salt/minion", 'r')
settings=yaml.load(f)
f.close()
ip=os.environ["MASTER_IP"]
if settings["master"].__class__ == str:
settings["master"] = [settings["master"]]
settings["master"] = [ip]
#if not ip in settings["master"]:
... | Python | 0 | |
00a059f172e1d6214d858370829e1034c2742ce4 | add gevent run script | run_gevent.py | run_gevent.py | from gevent.monkey import patch_all; patch_all()
from gevent.wsgi import WSGIServer
from pypi_notifier import create_app
app = create_app('ProductionConfig')
http_server = WSGIServer(('0.0.0.0', 5001), app)
http_server.serve_forever()
| Python | 0 | |
916b7fe4ee4c3c5c55278927a7116a4d1e0ad6d1 | Add solarized256.py | solarized256.py | solarized256.py | # -*- coding: utf-8 -*-
"""
solarized256
------------
A Pygments style inspired by Solarized's 256 color mode.
:copyright: (c) 2011 by Hank Gay, (c) 2012 by John Mastro.
:license: BSD, see LICENSE for more details.
"""
from pygments.style import Style
from pygments.token import Token, Comment, N... | Python | 0 | |
6cab10d19386911f33aaca660a9e1a35751b18ee | broke github api url naming scheme. fixed | post_qr.py | post_qr.py | import praw
import OAuth2Util
import time
import requests
import json
import os
import humanize
# sweet mother of imports
def make_qr(repo):
"""
Takes a github url, uses the github api to get the direct download url and size, and uses google api to make a qr.
It returns the link to the qr (not on imgur) a... | import praw
import OAuth2Util
import time
import requests
import json
import os
import humanize
# sweet mother of imports
def make_qr(repo):
"""
Takes a github url, uses the github api to get the direct download url and size, and uses google api to make a qr.
It returns the link to the qr (not on imgur) a... | Python | 0.999656 |
07a122374abb60140e05b09f49ef942bd14c05f6 | add missed migration | measure_mate/migrations/0026_auto_20160531_0716.py | measure_mate/migrations/0026_auto_20160531_0716.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-05-31 07:16
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import re
class Migration(migrations.Migration):
dependencies = [
('measure_mate', '0025_auto_20160516_0046'),
]
... | Python | 0 | |
d3b4053c2ef39eda9246af2000bdf9460730b33b | convert json to git-versionable versions which current TinyDB user can live with. | prettifyjson.py | prettifyjson.py | #!/usr/bin/env python
from os import path
import sys
import json
if len(sys.argv) > 1:
print("usage:\n\t{} < your_json_file > your_prettified_json_file".format(
path.basename(sys.argv[0])))
sys.exit(1)
json.dump(json.load(sys.stdin), sys.stdout, indent=2)
| Python | 0 | |
caf0b00bc21208515d0ddded3cbb934735d45939 | add migration to create new model fields | coupons/migrations/0004_auto_20151105_1456.py | coupons/migrations/0004_auto_20151105_1456.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('coupons', '0003_auto_20150416_0617'),
... | Python | 0 | |
b181f2a57d57caaa6e53e193e88002a15e284fd0 | add the missing file. i are senior dvlpr | cryptography/hazmat/backends/openssl/utils.py | cryptography/hazmat/backends/openssl/utils.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
# distributed under the... | Python | 0.000523 | |
4a0e00574fc551dde74db1a817229eeb23c4e0a8 | Create prueba.py | prueba.py | prueba.py | from flask import Flask
from flask import request
import os
import xml.etree.ElementTree as ET
from threading import Thread
import email_lib
app = Flask(__name__)
xml = ""
def send_email(xml):
print "2"
email_lib.prueba()
print xml
email_lib.email_alert(customer_email,iccid, admin_details[1])
r... | from flask import Flask
from flask import request
import os
import xml.etree.ElementTree as ET
from threading import Thread
import email_lib
app = Flask(__name__)
xml = ""
def send_email(xml):
print "2"
email_lib.prueba()
print xml
return None
@app.route('/webhook', methods=['POST','GET'])
def... | Python | 0.000008 |
7e4fd6b92040788bda1760cb261730f627ca6a10 | Add example from listing 7.6 | ch7/profile_read.py | ch7/profile_read.py | '''
Listing 7.6: Profiling data transfer
'''
import numpy as np
import pyopencl as cl
import pyopencl.array
import utility
from time import sleep
NUM_VECTORS = 8192
NUM_ITERATIONS = 2000
kernel_src = '''
__kernel void profile_read(__global char16 *c, int num) {
for(int i=0; i<num; i++) {
c[i] = (char16)(5... | Python | 0 | |
8ecac8170a3f9323f76aa9252a9d3b2f57f7660c | Include duration in analysis output | ceam/analysis.py | ceam/analysis.py | # ~/ceam/ceam/analysis.py
import argparse
import pandas as pd
import numpy as np
def confidence(seq):
mean = np.mean(seq)
std = np.std(seq)
runs = len(seq)
interval = (1.96*std)/np.sqrt(runs)
return mean, mean-interval, mean+interval
def difference_with_confidence(a, b):
mean_diff = np.mean(... | # ~/ceam/ceam/analysis.py
import argparse
import pandas as pd
import numpy as np
def confidence(seq):
mean = np.mean(seq)
std = np.std(seq)
runs = len(seq)
interval = (1.96*std)/np.sqrt(runs)
return mean, mean-interval, mean+interval
def difference_with_confidence(a, b):
mean_diff = np.mean(... | Python | 0.000012 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.