commit stringlengths 40 40 | old_file stringlengths 4 150 | new_file stringlengths 4 150 | old_contents stringlengths 0 3.26k | new_contents stringlengths 1 4.43k | subject stringlengths 15 501 | message stringlengths 15 4.06k | lang stringclasses 4
values | license stringclasses 13
values | repos stringlengths 5 91.5k | diff stringlengths 0 4.35k |
|---|---|---|---|---|---|---|---|---|---|---|
5e5e58b705d30df62423ec8bb6018c6807114580 | providers/io/osf/registrations/apps.py | providers/io/osf/registrations/apps.py | from share.provider import ProviderAppConfig
from .harvester import OSFRegistrationsHarvester
class AppConfig(ProviderAppConfig):
name = 'providers.io.osf.registrations'
version = '0.0.1'
title = 'osf_registrations'
long_title = 'Open Science Framework Registrations'
home_page = 'http://api.osf.io... | Add the app config for osf registrations | Add the app config for osf registrations
| Python | apache-2.0 | laurenbarker/SHARE,aaxelb/SHARE,aaxelb/SHARE,zamattiac/SHARE,zamattiac/SHARE,laurenbarker/SHARE,CenterForOpenScience/SHARE,laurenbarker/SHARE,aaxelb/SHARE,zamattiac/SHARE,CenterForOpenScience/SHARE,CenterForOpenScience/SHARE | ---
+++
@@ -0,0 +1,11 @@
+from share.provider import ProviderAppConfig
+from .harvester import OSFRegistrationsHarvester
+
+
+class AppConfig(ProviderAppConfig):
+ name = 'providers.io.osf.registrations'
+ version = '0.0.1'
+ title = 'osf_registrations'
+ long_title = 'Open Science Framework Registrations... | |
04fa680f4be4afc44dc0df3834b096d8fa7a05ac | nbgrader/tests/apps/test_nbgrader_update.py | nbgrader/tests/apps/test_nbgrader_update.py | from os.path import join
from .. import run_nbgrader
from .base import BaseTestApp
class TestNbGraderUpdate(BaseTestApp):
def test_help(self):
"""Does the help display without error?"""
run_nbgrader(["update", "--help-all"])
def test_no_args(self):
"""Is there an error if no argumen... | Add tests for nbgrader update | Add tests for nbgrader update
| Python | bsd-3-clause | jupyter/nbgrader,jhamrick/nbgrader,jupyter/nbgrader,jhamrick/nbgrader,jupyter/nbgrader,jupyter/nbgrader,jhamrick/nbgrader,jhamrick/nbgrader,jupyter/nbgrader | ---
+++
@@ -0,0 +1,39 @@
+from os.path import join
+
+from .. import run_nbgrader
+from .base import BaseTestApp
+
+
+class TestNbGraderUpdate(BaseTestApp):
+
+ def test_help(self):
+ """Does the help display without error?"""
+ run_nbgrader(["update", "--help-all"])
+
+ def test_no_args(self):
+ ... | |
5ef616d0563f9e4f29ef7eaa3c163d24cf3e131f | spyder_memory_profiler/widgets/tests/test_memoryprofiler.py | spyder_memory_profiler/widgets/tests/test_memoryprofiler.py | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) Spyder Project Developers
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Tests for m... | Add simple integration test for memory profiler | Add simple integration test for memory profiler
| Python | mit | jitseniesen/spyder-memory-profiler,jitseniesen/spyder-memory-profiler,spyder-ide/spyder.memory_profiler | ---
+++
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# -----------------------------------------------------------------------------
+# Copyright (c) Spyder Project Developers
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+# ----------------------------------------------------------... | |
efd3fbf51be25b46e3d5dd0cb76aaab60de7e4c8 | tryit.py | tryit.py | import json
from ranch import Address, InvalidAddressException
filename = input('Read data from: [data/export.json] ')
if filename == '':
filename = 'data/export.json'
with open(filename, 'r') as data:
specs = json.load(data)
a = Address(specs)
while not a.is_valid():
fields = a.get_field_types()
... | Add a file allowing you to try it manually | Add a file allowing you to try it manually
| Python | apache-2.0 | 3DHubs/Ranch | ---
+++
@@ -0,0 +1,30 @@
+import json
+from ranch import Address, InvalidAddressException
+
+
+filename = input('Read data from: [data/export.json] ')
+if filename == '':
+ filename = 'data/export.json'
+
+with open(filename, 'r') as data:
+ specs = json.load(data)
+ a = Address(specs)
+
+
+while not a.is_va... | |
d32414164552f48226842176e05229f6895e3c1d | wafer/tests/utils.py | wafer/tests/utils.py | """Utilities for testing wafer."""
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
def create_user(username, email=None, superuser=False, perms=()):
if superuser:
create = get_user_model().objects.create_superuser
else:
create = get_user_model(... | Add test utility for creating users. | Add test utility for creating users.
| Python | isc | CTPUG/wafer,CTPUG/wafer,CTPUG/wafer,CTPUG/wafer | ---
+++
@@ -0,0 +1,20 @@
+"""Utilities for testing wafer."""
+
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Permission
+
+
+def create_user(username, email=None, superuser=False, perms=()):
+ if superuser:
+ create = get_user_model().objects.create_superuser
+ e... | |
f30d459b8527074e50de504695491ad17bb18f0e | tests/pytests/unit/states/test_saltmod.py | tests/pytests/unit/states/test_saltmod.py | import pytest
import salt.modules.saltutil as saltutil
import salt.states.saltmod as saltmod
from tests.support.mock import create_autospec, patch
@pytest.fixture(autouse=True)
def setup_loader(request):
setup_loader_modules = {saltmod: {"__opts__": {"__role": "testsuite"}}}
with pytest.helpers.loader_mock(re... | Add tests for exclude passing | Add tests for exclude passing
| Python | apache-2.0 | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt | ---
+++
@@ -0,0 +1,56 @@
+import pytest
+import salt.modules.saltutil as saltutil
+import salt.states.saltmod as saltmod
+from tests.support.mock import create_autospec, patch
+
+
+@pytest.fixture(autouse=True)
+def setup_loader(request):
+ setup_loader_modules = {saltmod: {"__opts__": {"__role": "testsuite"}}}
+ ... | |
6143408507468c1718999bc2bc16d7e394741e29 | tests/unit/utils/test_timed_subprocess.py | tests/unit/utils/test_timed_subprocess.py | # -*- coding: utf-8 -*-
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Testing libs
from tests.support.unit import TestCase
# Import salt libs
import salt.utils.timed_subprocess as timed_subprocess
class TestTimedSubprocess(TestCase):
def test_timed... | Add unit test for TimedProc regression | Add unit test for TimedProc regression
| Python | apache-2.0 | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt | ---
+++
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+
+# Import python libs
+from __future__ import absolute_import, print_function, unicode_literals
+
+# Import Salt Testing libs
+from tests.support.unit import TestCase
+
+# Import salt libs
+import salt.utils.timed_subprocess as timed_subprocess
+
+
+class TestTimedS... | |
39fc0fe91ca4bf787ceeab9ff594168f70fe0dba | src/python2/dump_source.py | src/python2/dump_source.py | # Import the JModelica.org Python packages
import pymodelica
from pymodelica.compiler_wrappers import ModelicaCompiler
# Create a compiler and compiler target object
mc = ModelicaCompiler()
# Build trees as if for an FMU or Model Exchange v 1.0
#target = mc.create_target_object("me", "1.0")
source = mc.parse_model("C... | Add a new version of dump source that actually marches along the nodes | Add a new version of dump source that actually marches along the nodes
The content of the nodes need to better done. However, this example does show that we can access the elements of the source AST including annotations.
| Python | mit | michael-okeefe/soep-sandbox | ---
+++
@@ -0,0 +1,28 @@
+# Import the JModelica.org Python packages
+import pymodelica
+from pymodelica.compiler_wrappers import ModelicaCompiler
+
+# Create a compiler and compiler target object
+mc = ModelicaCompiler()
+
+# Build trees as if for an FMU or Model Exchange v 1.0
+#target = mc.create_target_object("me... | |
a50b96ece7db9b732a6dc96c6d981588a5760311 | test_builder.py | test_builder.py | import re
try:
import yaml
except:
print('PyYAML not installed')
from pathlib import Path
def mkdir(path):
try:
path.mkdir(parents=True)
except FileExistsError:
pass
def test_loop(path, c_path, cpp_path):
for file in path.glob('**/*.yaml'):
each_test(path, file, c_path, c... | Add script to convert tests from RethinkDB core. | Add script to convert tests from RethinkDB core.
| Python | apache-2.0 | grandquista/ReQL-Core,grandquista/ReQL-Core,grandquista/ReQL-Core,grandquista/ReQL-Core | ---
+++
@@ -0,0 +1,62 @@
+import re
+
+try:
+ import yaml
+except:
+ print('PyYAML not installed')
+
+from pathlib import Path
+
+def mkdir(path):
+ try:
+ path.mkdir(parents=True)
+ except FileExistsError:
+ pass
+
+def test_loop(path, c_path, cpp_path):
+ for file in path.glob('**/*.yam... | |
e5ad0f3029df610a308c107a640de438f62eb00b | tests/chainer_tests/training_tests/triggers_tests/test_early_stopping_trigger.py | tests/chainer_tests/training_tests/triggers_tests/test_early_stopping_trigger.py | import unittest
import chainer
import numpy
from chainer import testing
from chainer import training
from chainer.training import triggers
from chainer.training import util
class DummyUpdater(training.Updater):
def __init__(self):
self.iteration = 0
def finalize(self):
pass
def get_al... | Add test for early stopping trigger | Add test for early stopping trigger
| Python | mit | rezoo/chainer,keisuke-umezawa/chainer,keisuke-umezawa/chainer,aonotas/chainer,chainer/chainer,hvy/chainer,niboshi/chainer,ktnyt/chainer,tkerola/chainer,niboshi/chainer,chainer/chainer,niboshi/chainer,anaruse/chainer,wkentaro/chainer,okuta/chainer,ktnyt/chainer,ronekko/chainer,hvy/chainer,hvy/chainer,jnishi/chainer,okut... | ---
+++
@@ -0,0 +1,62 @@
+import unittest
+
+import chainer
+import numpy
+
+from chainer import testing
+from chainer import training
+from chainer.training import triggers
+from chainer.training import util
+
+
+class DummyUpdater(training.Updater):
+
+ def __init__(self):
+ self.iteration = 0
+
+ def ... | |
3644df1b645d4fd607f22b24c5e676644be4a9da | Lib/test/test_bsddb.py | Lib/test/test_bsddb.py | #! /usr/bin/env python
"""Test script for the bsddb C module
Roger E. Masse
"""
import bsddb
import tempfile
from test_support import verbose
def test(openmethod, what):
if verbose:
print '\nTesting: ', what
fname = tempfile.mktemp()
f = openmethod(fname, 'c')
if verbose:
print 'creation...'
... | Test script for the bsddb C extension module. | Test script for the bsddb C extension module.
| Python | mit | sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator | ---
+++
@@ -0,0 +1,69 @@
+#! /usr/bin/env python
+"""Test script for the bsddb C module
+ Roger E. Masse
+"""
+import bsddb
+import tempfile
+from test_support import verbose
+
+def test(openmethod, what):
+
+ if verbose:
+ print '\nTesting: ', what
+
+ fname = tempfile.mktemp()
+ f = openmethod(fname, 'c... | |
7cb4a7290b2af1983e1e291073c0a740d9e1334e | failure/tests/test_finders.py | failure/tests/test_finders.py | # -*- coding: utf-8 -*-
# Copyright (C) 2016 GoDaddy 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-... | Add some useful finder tests | Add some useful finder tests
| Python | apache-2.0 | harlowja/failure | ---
+++
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2016 GoDaddy 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
+#
+# htt... | |
0f5716b10afff9ccbc17fb595cd7cc2f85b45f8f | tools/perf/page_sets/service_worker.py | tools/perf/page_sets/service_worker.py | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page
from telemetry.page import page_set as page_set
archive_data_file_path = 'data/service_worker.json'
class Service... | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page
from telemetry.page import page_set as page_set
archive_data_file_path = 'data/service_worker.json'
class Service... | Add name attribute to each Page in ServiceWorkerPageSet | Telemetry: Add name attribute to each Page in ServiceWorkerPageSet
ServiceWorkerPerfTest loads the same page three times, but these should
have different characteristics because ServiceWorker works differently.
This patch gives each page load a name so we can track them separately.
BUG=
TEST=tools/perf/run_benchmark ... | Python | bsd-3-clause | Chilledheart/chromium,PeterWangIntel/chromium-crosswalk,Fireblend/chromium-crosswalk,axinging/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,Pluto-tv/chromium-crosswalk,Pluto-tv/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,chuan9/chromium-crosswalk,hgl888/chromium-crosswalk,Chilledheart/chromium,axinging/ch... | ---
+++
@@ -21,12 +21,12 @@
# 1st time: registration
self.AddUserStory(page.Page(
'https://jakearchibald.github.io/trained-to-thrill/', self,
- make_javascript_deterministic=False))
+ name='first_load', make_javascript_deterministic=False))
# 2st time: 1st onfetch with caching
... |
b2a0247746756cc86074754bc993a757d6702b12 | hw02/exercise-02-01.py | hw02/exercise-02-01.py | '''
For Homework 02, Exercieses 01-02. EdX Learning From Data course.
Jonathan Miller
'''
import random
# FUNCTIONS ###########################
def runTrial(numCoins, numFlips):
def flipCoin():
if random.random() > 0.5:
return head
else:
return tail
def findv1(vList... | Add coin flip simulator (hw02) | Add coin flip simulator (hw02)
| Python | apache-2.0 | JMill/edX-Learning-From-Data-Programming | ---
+++
@@ -0,0 +1,96 @@
+'''
+For Homework 02, Exercieses 01-02. EdX Learning From Data course.
+Jonathan Miller
+'''
+
+import random
+
+# FUNCTIONS ###########################
+
+def runTrial(numCoins, numFlips):
+
+ def flipCoin():
+ if random.random() > 0.5:
+ return head
+ else:
+ ... | |
c67dc16e73eea093befaa03790bd8d6f1b452c9a | form_designer/tests/test_cms_plugin.py | form_designer/tests/test_cms_plugin.py | import pytest
from cms import api
from cms.page_rendering import render_page
from django.contrib.auth.models import AnonymousUser
from django.utils.crypto import get_random_string
from form_designer.contrib.cms_plugins.form_designer_form.cms_plugins import FormDesignerPlugin
from form_designer.models import FormDefini... | Add simple test for FormDesignerPlugin | Add simple test for FormDesignerPlugin
| Python | bsd-3-clause | kcsry/django-form-designer,andersinno/django-form-designer,kcsry/django-form-designer,andersinno/django-form-designer,andersinno/django-form-designer-ai,andersinno/django-form-designer-ai | ---
+++
@@ -0,0 +1,33 @@
+import pytest
+from cms import api
+from cms.page_rendering import render_page
+from django.contrib.auth.models import AnonymousUser
+from django.utils.crypto import get_random_string
+
+from form_designer.contrib.cms_plugins.form_designer_form.cms_plugins import FormDesignerPlugin
+from for... | |
f908dd5fda528b4ce6ebaed082050348bf6f23a5 | i8c/tests/test_entry_point.py | i8c/tests/test_entry_point.py | from i8c.tests import TestCase
import i8c
import sys
class TestEntryPoint(TestCase):
"""Test the console scripts entry point."""
def setUp(self):
self.saved_argv = sys.argv
self.saved_stderr = sys.stderr
def tearDown(self):
sys.argv = self.saved_argv
sys.stderr = self.save... | Test the console scripts entry point | Test the console scripts entry point
| Python | lgpl-2.1 | gbenson/i8c | ---
+++
@@ -0,0 +1,25 @@
+from i8c.tests import TestCase
+import i8c
+import sys
+
+class TestEntryPoint(TestCase):
+ """Test the console scripts entry point."""
+
+ def setUp(self):
+ self.saved_argv = sys.argv
+ self.saved_stderr = sys.stderr
+
+ def tearDown(self):
+ sys.argv = self.s... | |
f7b875bb3d4b313e9c1e22297918d33e67633104 | geotrek/altimetry/tests/test_models.py | geotrek/altimetry/tests/test_models.py | import os
from django.test import TestCase
from django.conf import settings
from geotrek.trekking.factories import TrekFactory
from geotrek.trekking.models import Trek
class AltimetryMixinTest(TestCase):
def test_get_elevation_chart_none(self):
trek = TrekFactory.create(no_path=True)
trek.get_el... | Add test trek_dtail_pdf language none | Add test trek_dtail_pdf language none
| Python | bsd-2-clause | makinacorpus/Geotrek,GeotrekCE/Geotrek-admin,GeotrekCE/Geotrek-admin,GeotrekCE/Geotrek-admin,makinacorpus/Geotrek,makinacorpus/Geotrek,GeotrekCE/Geotrek-admin,makinacorpus/Geotrek | ---
+++
@@ -0,0 +1,17 @@
+import os
+
+from django.test import TestCase
+from django.conf import settings
+
+from geotrek.trekking.factories import TrekFactory
+from geotrek.trekking.models import Trek
+
+
+class AltimetryMixinTest(TestCase):
+ def test_get_elevation_chart_none(self):
+ trek = TrekFactory.c... | |
8a0d40f9874119084f5f7a1471cb565bb85d6938 | match_to_wd.py | match_to_wd.py | import csv
import pickle
import sys
def load_index():
with open('data/wd_issn.pkl') as inf:
data = pickle.load(inf)
return data
wd_idx = load_index()
def match(issn, eissn):
for isn in [issn, eissn]:
if issn != "":
wd = wd_idx.get(issn)
if wd is not None:
... | Add match to wd script. | Add match to wd script.
| Python | mit | lawlesst/c4l16-idhub | ---
+++
@@ -0,0 +1,49 @@
+import csv
+import pickle
+import sys
+
+
+def load_index():
+ with open('data/wd_issn.pkl') as inf:
+ data = pickle.load(inf)
+ return data
+
+wd_idx = load_index()
+
+def match(issn, eissn):
+ for isn in [issn, eissn]:
+ if issn != "":
+ wd = wd_idx.get(is... | |
7716818beb0dba581cd3536e321676d756e282d9 | course_discovery/apps/core/migrations/0011_remove_partner_lms_commerce_api_url.py | course_discovery/apps/core/migrations/0011_remove_partner_lms_commerce_api_url.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2019-04-12 17:31
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0010_partner_lms_coursemode_api_url'),
]
operations = [
migrations.RemoveF... | Remove the lms_comerce_api_url field from partners object | Remove the lms_comerce_api_url field from partners object
| Python | agpl-3.0 | edx/course-discovery,edx/course-discovery,edx/course-discovery,edx/course-discovery | ---
+++
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.15 on 2019-04-12 17:31
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0010_partner_lms_coursemode_api_url'),
+ ]
+
+ ... | |
bb1aafd72899d35bfcad5a84373281f732ad01ab | integration_tests/test_minerva_dump.py | integration_tests/test_minerva_dump.py | from contextlib import closing
import subprocess
import unittest
from nose.tools import eq_
from minerva.test import connect
class MinervaDump(unittest.TestCase):
"""
Use standard Python unittest TestCase here because of the assertMultiLineEqual
function.
"""
def test_run(self):
self.max... | Add integration test for minerva-dump script | Add integration test for minerva-dump script
| Python | agpl-3.0 | hendrikx-itc/minerva,hendrikx-itc/minerva | ---
+++
@@ -0,0 +1,68 @@
+from contextlib import closing
+import subprocess
+import unittest
+
+from nose.tools import eq_
+
+from minerva.test import connect
+
+
+class MinervaDump(unittest.TestCase):
+ """
+ Use standard Python unittest TestCase here because of the assertMultiLineEqual
+ function.
+ """... | |
186b231b7149b52dc95837aabd5f44b1c02c8e41 | samples/sample_pyqtgraph_no_datetime.py | samples/sample_pyqtgraph_no_datetime.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This example demonstrates a random walk with pyqtgraph.
"""
import sys
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
from numpy_buffer import RingBuffer # https://github.com/scls19fr/numpy-buffer
class RandomWalkPlot:
def __init... | Add PyQtGraph random walk without datetime | Add PyQtGraph random walk without datetime
| Python | bsd-3-clause | scls19fr/numpy-buffer | ---
+++
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+This example demonstrates a random walk with pyqtgraph.
+"""
+
+import sys
+import numpy as np
+import pyqtgraph as pg
+from pyqtgraph.Qt import QtGui, QtCore
+from numpy_buffer import RingBuffer # https://github.com/scls19fr/numpy-buffer... | |
fc5714951bac61f17509eacf8ec2413e14a79ddc | txircd/modules/core/sno_oper.py | txircd/modules/core/sno_oper.py | from twisted.plugin import IPlugin
from txircd.module_interface import IModuleData, ModuleData
from zope.interface import implements
class SnoOper(ModuleData):
implements(IPlugin, IModuleData)
name = "ServerNoticeOper"
core = True
def hookIRCd(self, ircd):
self.ircd = ircd
def actions(se... | Add a snomask for OPER attempts | Add a snomask for OPER attempts
| Python | bsd-3-clause | ElementalAlchemist/txircd,Heufneutje/txircd | ---
+++
@@ -0,0 +1,32 @@
+from twisted.plugin import IPlugin
+from txircd.module_interface import IModuleData, ModuleData
+from zope.interface import implements
+
+class SnoOper(ModuleData):
+ implements(IPlugin, IModuleData)
+
+ name = "ServerNoticeOper"
+ core = True
+
+ def hookIRCd(self, ircd):
+ ... | |
8f3c5dc924b0a8ad35d99d66eb809a51b49fc178 | zerver/management/commands/rename-stream.py | zerver/management/commands/rename-stream.py | from __future__ import absolute_import
from django.core.management.base import BaseCommand
from zerver.lib.actions import do_rename_stream
from zerver.models import Realm, get_realm
class Command(BaseCommand):
help = """Change the stream name for a realm.
Usage: python manage.py rename-stream <domain> <old name... | Add a management command to rename a stream. | Add a management command to rename a stream.
(imported from commit b3acadc09b289b48e2ac298e50a5427545b6a473)
| Python | apache-2.0 | eeshangarg/zulip,dhcrzf/zulip,wavelets/zulip,hengqujushi/zulip,praveenaki/zulip,armooo/zulip,JanzTam/zulip,glovebx/zulip,amanharitsh123/zulip,dxq-git/zulip,xuxiao/zulip,stamhe/zulip,pradiptad/zulip,akuseru/zulip,bitemyapp/zulip,JPJPJPOPOP/zulip,zorojean/zulip,kokoar/zulip,zwily/zulip,LAndreas/zulip,christi3k/zulip,nata... | ---
+++
@@ -0,0 +1,26 @@
+from __future__ import absolute_import
+
+from django.core.management.base import BaseCommand
+
+from zerver.lib.actions import do_rename_stream
+from zerver.models import Realm, get_realm
+
+class Command(BaseCommand):
+ help = """Change the stream name for a realm.
+
+Usage: python mana... | |
583155db6a85808c69fa25ba4959ebd370aa2fba | etc/config/check_modules.py | etc/config/check_modules.py | from subprocess import call
import os
modules = [
'backend.unichat.eu',
'realtime.unichat.eu',
'presence.unichat.eu',
'matchmaker.unichat.eu',
]
for m in modules:
with open(os.devnull, 'w') as devnull:
call(
['curl', '-m', '1', m],
stdout=devnull,
stderr... | Add script to check if modules up | Add script to check if modules up
| Python | mit | dimkarakostas/unimeet,dimkarakostas/unimeet,dimkarakostas/unimeet,dimkarakostas/unimeet | ---
+++
@@ -0,0 +1,17 @@
+from subprocess import call
+import os
+
+modules = [
+ 'backend.unichat.eu',
+ 'realtime.unichat.eu',
+ 'presence.unichat.eu',
+ 'matchmaker.unichat.eu',
+]
+
+for m in modules:
+ with open(os.devnull, 'w') as devnull:
+ call(
+ ['curl', '-m', '1', m],
+ ... | |
50db2fa37aab219c9273cf3f76269de11e2dc86b | src/ggrc_basic_permissions/migrations/versions/20131204014446_54b6efd65a93_add_mappings_to_audi.py | src/ggrc_basic_permissions/migrations/versions/20131204014446_54b6efd65a93_add_mappings_to_audi.py |
"""Add mappings to Auditor role
Revision ID: 54b6efd65a93
Revises: 13b49798db19
Create Date: 2013-12-04 01:44:46.023974
"""
# revision identifiers, used by Alembic.
revision = '54b6efd65a93'
down_revision = '13b49798db19'
import sqlalchemy as sa
from alembic import op
from datetime import datetime
from sqlalchemy.... | Add a migration to allow Auditor role to see mappings defined in the Audit context. | Add a migration to allow Auditor role to see mappings defined in the
Audit context.
| Python | apache-2.0 | andrei-karalionak/ggrc-core,andrei-karalionak/ggrc-core,selahssea/ggrc-core,prasannav7/ggrc-core,josthkko/ggrc-core,hyperNURb/ggrc-core,jmakov/ggrc-core,josthkko/ggrc-core,edofic/ggrc-core,selahssea/ggrc-core,hyperNURb/ggrc-core,kr41/ggrc-core,NejcZupec/ggrc-core,jmakov/ggrc-core,prasannav7/ggrc-core,edofic/ggrc-core,V... | ---
+++
@@ -0,0 +1,53 @@
+
+"""Add mappings to Auditor role
+
+Revision ID: 54b6efd65a93
+Revises: 13b49798db19
+Create Date: 2013-12-04 01:44:46.023974
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '54b6efd65a93'
+down_revision = '13b49798db19'
+
+import sqlalchemy as sa
+from alembic import op
+fro... | |
c74ce3d4561a7367903863aaabe1af113d43aa0c | mgnemu/models/BaseModel.py | mgnemu/models/BaseModel.py | # -*- coding: utf-8 -*-
"""
Base model of project.
Contains to basic methods:
dumps(object_data) - writes object into json.
loads(json_data) - converts json into model object.
"""
import json
class BaseModel():
def dumps(object_data):
return json.dumps(object_data)
def loads(json_data):
... | Add base model obect to project. | Add base model obect to project.
| Python | mit | 0xporky/mgnemu-python | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+"""
+Base model of project.
+Contains to basic methods:
+ dumps(object_data) - writes object into json.
+ loads(json_data) - converts json into model object.
+
+"""
+
+import json
+
+
+class BaseModel():
+
+ def dumps(object_data):
+ return json.dum... | |
17fe9d01b6771888a44d6a039b337a84c32e64e8 | tests/test_common_utils.py | tests/test_common_utils.py | from bart.common import Utils
import unittest
import pandas as pd
class TestCommonUtils(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(TestCommonUtils, self).__init__(*args, **kwargs)
def test_interval_sum(self):
"""Test Utils Function: interval_sum"""
array = [0, 0,... | Add test case for interval_sum | tests: Add test case for interval_sum
Signed-off-by: Kapileshwar Singh <d373e2b6407ea84be359ce4a11e8631121819e79@arm.com>
| Python | apache-2.0 | JaviMerino/bart,ARM-software/bart | ---
+++
@@ -0,0 +1,28 @@
+from bart.common import Utils
+import unittest
+import pandas as pd
+
+
+class TestCommonUtils(unittest.TestCase):
+
+ def __init__(self, *args, **kwargs):
+ super(TestCommonUtils, self).__init__(*args, **kwargs)
+
+ def test_interval_sum(self):
+ """Test Utils Function: ... | |
e6a3e2ac8267ae3a0f361138bd8cb25f82b12b9d | benchexec/tools/avr.py | benchexec/tools/avr.py | # This file is part of BenchExec, a framework for reliable benchmarking:
# https://github.com/sosy-lab/benchexec
#
# SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0
import benchexec.result as result
import benchexec.tools.template
class Tool(benchexec.t... | Create a tool-info module for AVR | Create a tool-info module for AVR
| Python | apache-2.0 | sosy-lab/benchexec,sosy-lab/benchexec,sosy-lab/benchexec,sosy-lab/benchexec,sosy-lab/benchexec,sosy-lab/benchexec | ---
+++
@@ -0,0 +1,41 @@
+# This file is part of BenchExec, a framework for reliable benchmarking:
+# https://github.com/sosy-lab/benchexec
+#
+# SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org>
+#
+# SPDX-License-Identifier: Apache-2.0
+
+import benchexec.result as result
+import benchexec.too... | |
b373eaab5918488292075c962f4374dc8815c395 | test/integration/generate_partitions.py | test/integration/generate_partitions.py | import sys
import random
if len(sys.argv) != 3:
print >> sys.stderr, "USAGE: python generate_partitions.py nodes partitions_per_node"
sys.exit()
FORMAT_WIDTH = 10
nodes = int(sys.argv[1])
partitions = int(sys.argv[2])
ids = range(nodes * partitions)
# use known seed so this is repeatable
random.seed(928734... | Add script to generate partition ids. | Add script to generate partition ids.
| Python | apache-2.0 | medallia/voldemort,HB-SI/voldemort,voldemort/voldemort,HB-SI/voldemort,cshaxu/voldemort,squarY/voldemort,medallia/voldemort,cshaxu/voldemort,stotch/voldemort,rickbw/voldemort,birendraa/voldemort,voldemort/voldemort,birendraa/voldemort,PratikDeshpande/voldemort,HB-SI/voldemort,null-exception/voldemort,mabh/voldemort,jal... | ---
+++
@@ -0,0 +1,32 @@
+import sys
+import random
+
+if len(sys.argv) != 3:
+ print >> sys.stderr, "USAGE: python generate_partitions.py nodes partitions_per_node"
+ sys.exit()
+
+FORMAT_WIDTH = 10
+
+nodes = int(sys.argv[1])
+partitions = int(sys.argv[2])
+
+ids = range(nodes * partitions)
+
+# use known see... | |
5caf67f27d82689babf5dcf0a234dfe3c261ff9c | zephyr/retention_policy.py | zephyr/retention_policy.py | """
Implements the per-domain data retention policy.
The goal is to have a single place where the policy is defined. This is
complicated by needing to apply this policy both to the database and to log
files. Additionally, we want to use an efficient query for the database,
rather than iterating through messages one ... | Implement a framework for data retention policies | Implement a framework for data retention policies
And add customer1.invalid to it.
(imported from commit 32b0293bc48abf5d9a3bd36f14f6b16d48ea6ff2)
| Python | apache-2.0 | akuseru/zulip,AZtheAsian/zulip,KJin99/zulip,EasonYi/zulip,rishig/zulip,seapasulli/zulip,gigawhitlocks/zulip,dotcool/zulip,wdaher/zulip,dattatreya303/zulip,arpith/zulip,aps-sids/zulip,natanovia/zulip,wangdeshui/zulip,fw1121/zulip,JanzTam/zulip,natanovia/zulip,mansilladev/zulip,littledogboy/zulip,bowlofstew/zulip,dhcrzf/... | ---
+++
@@ -0,0 +1,73 @@
+"""
+Implements the per-domain data retention policy.
+
+The goal is to have a single place where the policy is defined. This is
+complicated by needing to apply this policy both to the database and to log
+files. Additionally, we want to use an efficient query for the database,
+rather th... | |
8953b336dfcb8bd6c69b2af8e960a215a47838f8 | Problems/reverseStringInPlace.py | Problems/reverseStringInPlace.py | #!/Applications/anaconda/envs/Python3/bin
def main():
# Test suite
tests = [ None, [''], ['f','o','o',' ','b','a','r']]
for t in tests:
print('Testing: {}'.format(t))
print('Result: {}'.format(reverse_string_in_place(t)))
return 0
def reverse_string_in_place(chars):
''' Reverses... | Add reverse a list of characters in place | Add reverse a list of characters in place
| Python | mit | HKuz/Test_Code | ---
+++
@@ -0,0 +1,23 @@
+#!/Applications/anaconda/envs/Python3/bin
+
+
+def main():
+ # Test suite
+ tests = [ None, [''], ['f','o','o',' ','b','a','r']]
+ for t in tests:
+ print('Testing: {}'.format(t))
+ print('Result: {}'.format(reverse_string_in_place(t)))
+
+ return 0
+
+
+def reverse... | |
e8c8464d36e91c9a8d61db0531a2e73dcdee88b7 | utilities/tests/test_simulation_utils.py | utilities/tests/test_simulation_utils.py | from utilities.simulation_utilities import check_inputs
import pytest
import numpy as np
@pytest.mark.parametrize("input,expected", [
(None, np.ndarray([0])),
([0], np.array([0])),
(1, np.array([1])),
(range(5), np.array([0,1,2,3,4]))
])
def test_check_inputs(input, expected):
assert np.allclose(... | Add a test for check_inputs. | Add a test for check_inputs.
| Python | mit | jason-neal/companion_simulations,jason-neal/companion_simulations | ---
+++
@@ -0,0 +1,14 @@
+from utilities.simulation_utilities import check_inputs
+
+import pytest
+import numpy as np
+
+
+@pytest.mark.parametrize("input,expected", [
+ (None, np.ndarray([0])),
+ ([0], np.array([0])),
+ (1, np.array([1])),
+ (range(5), np.array([0,1,2,3,4]))
+])
+def test_check_inputs(i... | |
ecef0ea7743f25326183d09622949682ce6feb3c | test/ts.py | test/ts.py | #!/usr/bin/env python
'''
Module: test
Desc: Test to see how quickly I can parse TS es packets
Author: John O'Neil
Email: oneil.john@gmail.com
DATE: Thursday, October 20th 2016
'''
import os
import sys
import argparse
PACKET_SIZE = 188
SYNC_BYTE = 'G'
#generator
def next_packet(filename):
with open(filename, 'rb')... | Test traverses a TS file quickly | Test traverses a TS file quickly
| Python | apache-2.0 | johnoneil/arib,johnoneil/arib | ---
+++
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+'''
+Module: test
+Desc: Test to see how quickly I can parse TS es packets
+Author: John O'Neil
+Email: oneil.john@gmail.com
+DATE: Thursday, October 20th 2016
+
+'''
+import os
+import sys
+import argparse
+
+PACKET_SIZE = 188
+SYNC_BYTE = 'G'
+
+#generator
+def next_... | |
b5c6e37bdcb88545d187ad1e3adbbbe1d466f874 | py/knight-probability-in-chessboard.py | py/knight-probability-in-chessboard.py | from collections import Counter
from math import log, exp
class Solution(object):
def knightProbability(self, N, K, r, c):
"""
:type N: int
:type K: int
:type r: int
:type c: int
:rtype: float
"""
p = Counter()
p[r, c] += 1
ds = [(-1, -... | Add py solution for 688. Knight Probability in Chessboard | Add py solution for 688. Knight Probability in Chessboard
688. Knight Probability in Chessboard: https://leetcode.com/problems/knight-probability-in-chessboard/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,24 @@
+from collections import Counter
+from math import log, exp
+class Solution(object):
+ def knightProbability(self, N, K, r, c):
+ """
+ :type N: int
+ :type K: int
+ :type r: int
+ :type c: int
+ :rtype: float
+ """
+ p = Counter()
+ ... | |
f80acf05f7d492f3716be961b88c4e82d332500c | dbaas/util/update_instances_with_offering.py | dbaas/util/update_instances_with_offering.py | # coding: utf-8
class UpdateInstances(object):
@staticmethod
def do():
from dbaas_cloudstack.models import DatabaseInfraOffering
from dbaas_cloudstack.models import PlanAttr
from physical.models import Instance
infra_offerings = DatabaseInfraOffering.objects.all()
fo... | Create class to update instances with offering | Create class to update instances with offering
| Python | bsd-3-clause | globocom/database-as-a-service,globocom/database-as-a-service,globocom/database-as-a-service,globocom/database-as-a-service | ---
+++
@@ -0,0 +1,26 @@
+# coding: utf-8
+
+
+class UpdateInstances(object):
+
+ @staticmethod
+ def do():
+ from dbaas_cloudstack.models import DatabaseInfraOffering
+ from dbaas_cloudstack.models import PlanAttr
+ from physical.models import Instance
+
+ infra_offerings = Database... | |
112e3516d7c77f23edfed704651e8c5e7f7d75e4 | scripts/DEV/adm/heatmap.py | scripts/DEV/adm/heatmap.py | import numpy as np
import numpy.ma as ma
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from pyiem.plot import MapPlot
import sys
year = int(sys.argv[1])
x = []
y = []
for linenum, line in enumerate(open('visit_history_093013_st12.csv')):
if linenum == 0:
continue
tokens = line.split(",")
... | Add example heat map script for data | Add example heat map script for data | Python | mit | akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem | ---
+++
@@ -0,0 +1,39 @@
+import numpy as np
+import numpy.ma as ma
+import matplotlib.pyplot as plt
+import matplotlib.cm as cm
+from pyiem.plot import MapPlot
+import sys
+
+year = int(sys.argv[1])
+
+x = []
+y = []
+for linenum, line in enumerate(open('visit_history_093013_st12.csv')):
+ if linenum == 0:
+ ... | |
62a860112db8c263d26eb9e4cdb67d23ce61848a | python/opencv/opencv_2/write_image.py | python/opencv/opencv_2/write_image.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2015 Jérémie DECOCK (http://www.jdhp.org)
"""
OpenCV - Write image: write an image given in arguments
Required: opencv library (Debian: aptitude install python-opencv)
See: https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_i... | Add a snippet (Python OpenCV). | Add a snippet (Python OpenCV).
| Python | mit | jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets | ---
+++
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2015 Jérémie DECOCK (http://www.jdhp.org)
+
+"""
+OpenCV - Write image: write an image given in arguments
+
+Required: opencv library (Debian: aptitude install python-opencv)
+
+See: https://opencv-python-tutroals.readthedocs.... | |
dcf49377defe8ce3debadc8d0c09b683663f7b73 | space/migrations/0011_privateapikey.py | space/migrations/0011_privateapikey.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
import uuid
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('space', '0010_auto_20151129_2... | Add migration for the new PrivateAPIKey model (Bravo Nils !) | Add migration for the new PrivateAPIKey model (Bravo Nils !)
| Python | agpl-3.0 | UrLab/incubator,UrLab/incubator,UrLab/incubator,UrLab/incubator | ---
+++
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+from django.conf import settings
+import uuid
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
... | |
e78e56e38dfa7bfac79bc3a699ca76236d700e2a | tests/grammar_term-nonterm_test/TerminalAddWhenCreatingTest.py | tests/grammar_term-nonterm_test/TerminalAddWhenCreatingTest.py | #!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 23.06.2017 16:39
:Licence GNUv3
Part of grammpy
"""
from unittest import TestCase
from grammpy import Grammar
from grammpy.Terminal import Terminal
class TerminalAddWhenCreatingTest(TestCase):
def test_addOneInArray(self):
gr = Grammar(terminals=... | Add tests creation of grammar with terminals as parameters | Add tests creation of grammar with terminals as parameters
| Python | mit | PatrikValkovic/grammpy | ---
+++
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+"""
+:Author Patrik Valkovic
+:Created 23.06.2017 16:39
+:Licence GNUv3
+Part of grammpy
+
+"""
+from unittest import TestCase
+from grammpy import Grammar
+from grammpy.Terminal import Terminal
+
+
+class TerminalAddWhenCreatingTest(TestCase):
+ def test_addOneInAr... | |
629553ec992c59500ef64b04b8fc9fb0500bcaee | wqflask/tests/wqflask/test_user_session.py | wqflask/tests/wqflask/test_user_session.py | """Test cases for some methods in user_session.py"""
import unittest
from wqflask.user_session import verify_cookie
class TestUserSession(unittest.TestCase):
def test_verify_cookie(self):
"""
Test cookie verification
"""
self.assertEqual(
"3f4c1dbf-5b56-4260-87d6-f3544... | Add tests for cookie verification | Add tests for cookie verification
| Python | agpl-3.0 | pjotrp/genenetwork2,genenetwork/genenetwork2,genenetwork/genenetwork2,genenetwork/genenetwork2,zsloan/genenetwork2,pjotrp/genenetwork2,zsloan/genenetwork2,pjotrp/genenetwork2,zsloan/genenetwork2,zsloan/genenetwork2,genenetwork/genenetwork2,pjotrp/genenetwork2,pjotrp/genenetwork2 | ---
+++
@@ -0,0 +1,15 @@
+"""Test cases for some methods in user_session.py"""
+
+import unittest
+from wqflask.user_session import verify_cookie
+
+
+class TestUserSession(unittest.TestCase):
+ def test_verify_cookie(self):
+ """
+ Test cookie verification
+ """
+ self.assertEqual(
+ ... | |
a4f86e11bbdcf2f478fd9cfb8df33a150f8a086e | poolstatapi-example.py | poolstatapi-example.py | import requests
import hmac
import hashlib
import base64
PUBLIC_KEY = '##'
PRIVATE_KEY = '##'
URL = 'https://www.poolstat.net.au/restapi/v1/ladders'
digest = hmac.new(PRIVATE_KEY, URL, digestmod=hashlib.sha256).hexdigest()
# signature = base64.b64encode(digest).decode()
print digest
#print signature
headers = {
... | Add poolstat api example to project root. | Add poolstat api example to project root.
| Python | mit | benjiboi214/mmpl-wagtail,benjiboi214/mmpl-wagtail,benjiboi214/mmpl-wagtail | ---
+++
@@ -0,0 +1,26 @@
+import requests
+import hmac
+import hashlib
+import base64
+
+PUBLIC_KEY = '##'
+PRIVATE_KEY = '##'
+URL = 'https://www.poolstat.net.au/restapi/v1/ladders'
+
+digest = hmac.new(PRIVATE_KEY, URL, digestmod=hashlib.sha256).hexdigest()
+# signature = base64.b64encode(digest).decode()
+
+print ... | |
55ccaad47c2e3a1432b012218c72bca28fe06d73 | greetings.py | greetings.py | from fnexchange.core.plugins import AbstractPlugin
class GreetingsPlugin(AbstractPlugin):
"""
GreetingsPlugin provides an interface to generate greetings in different languages
for given users (provided their names and locales).
At this time, only the following locales are supported: "en-us", "hi-in"
... | Create a GreetingsPlugin as a sample plugin | Create a GreetingsPlugin as a sample plugin
| Python | apache-2.0 | dnif/fnExchange-sample-plugin | ---
+++
@@ -0,0 +1,57 @@
+from fnexchange.core.plugins import AbstractPlugin
+
+
+class GreetingsPlugin(AbstractPlugin):
+ """
+ GreetingsPlugin provides an interface to generate greetings in different languages
+ for given users (provided their names and locales).
+ At this time, only the following local... | |
be8b7c27b25b60540c2e53504ce42543724577df | napalm_logs/utils/__init__.py | napalm_logs/utils/__init__.py | # -*- coding: utf-8 -*-
'''
napalm-logs utilities
'''
from __future__ import absolute_import
from __future__ import unicode_literals
# Import pythond stdlib
import ssl
import socket
# Import python stdlib
import umsgpack
import nacl.secret
import nacl.signing
import nacl.encoding
from nacl.exceptions import CryptoErr... | Add utilities for the clients | Add utilities for the clients
| Python | apache-2.0 | napalm-automation/napalm-logs,napalm-automation/napalm-logs | ---
+++
@@ -0,0 +1,80 @@
+# -*- coding: utf-8 -*-
+'''
+napalm-logs utilities
+'''
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
+# Import pythond stdlib
+import ssl
+import socket
+
+# Import python stdlib
+import umsgpack
+import nacl.secret
+import nacl.signing
+import nacl.enc... | |
986ee0ffae416cf1dc833f581a89d718dc2ff2fe | bird/evaluate.py | bird/evaluate.py | from models.cuberun import CubeRun
import numpy as np
import utils
import loader
nb_classes = 19
input_shape = (257, 624, 1)
(cols, rows, chs) = input_shape
image_shape = (cols, rows)
batch_size=32
def evaluate(model, data_filepath, file2labels_filepath):
model.compile(loss='binary_crossentropy', optimizer='adam'... | Add a first draft of the evaluation module. | Add a first draft of the evaluation module.
| Python | mit | johnmartinsson/bird-species-classification,johnmartinsson/bird-species-classification | ---
+++
@@ -0,0 +1,40 @@
+from models.cuberun import CubeRun
+import numpy as np
+import utils
+import loader
+
+nb_classes = 19
+input_shape = (257, 624, 1)
+(cols, rows, chs) = input_shape
+image_shape = (cols, rows)
+batch_size=32
+
+def evaluate(model, data_filepath, file2labels_filepath):
+ model.compile(loss... | |
4b0221ca503be9450919e4ed4e6a75ce92cd2d63 | csdms/dakota/variables/continuous_design.py | csdms/dakota/variables/continuous_design.py | """Implementation of a Dakota continous design variable."""
from .base import VariableBase
classname = 'ContinuousDesign'
class ContinuousDesign(VariableBase):
"""Define attributes for Dakota continous design variables."""
def __init__(self,
variables=('x1', 'x2'),
initi... | Create new module for continuous design variables | Create new module for continuous design variables
| Python | mit | csdms/dakota,csdms/dakota | ---
+++
@@ -0,0 +1,112 @@
+"""Implementation of a Dakota continous design variable."""
+
+from .base import VariableBase
+
+
+classname = 'ContinuousDesign'
+
+
+class ContinuousDesign(VariableBase):
+
+ """Define attributes for Dakota continous design variables."""
+
+ def __init__(self,
+ vari... | |
74388ceaacb7eedf98eb03f1263ea2ec6db596e1 | python_scripts/media_export_through_api.py | python_scripts/media_export_through_api.py | # -*- coding: utf-8 -*-
import psycopg2
import psycopg2.extras
import requests
import json
import mc_database
import mediacloud
def get_download_from_api( mc_api_url, api_key, downloads_id ):
r = requests.get( mc_api_url +'/api/v2/downloads/single/' + str( downloads_id) ,
params = { 'k... | Add initial script to export feed downloads. | Add initial script to export feed downloads.
| Python | agpl-3.0 | AchyuthIIIT/mediacloud,AchyuthIIIT/mediacloud,AchyuthIIIT/mediacloud,AchyuthIIIT/mediacloud,AchyuthIIIT/mediacloud,AchyuthIIIT/mediacloud,AchyuthIIIT/mediacloud,AchyuthIIIT/mediacloud,berkmancenter/mediacloud,berkmancenter/mediacloud,AchyuthIIIT/mediacloud,berkmancenter/mediacloud,berkmancenter/mediacloud,berkmancenter... | ---
+++
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+
+import psycopg2
+import psycopg2.extras
+import requests
+import json
+
+import mc_database
+import mediacloud
+
+def get_download_from_api( mc_api_url, api_key, downloads_id ):
+
+ r = requests.get( mc_api_url +'/api/v2/downloads/single/' + str( downloads_i... | |
91396ed246166f610e9cfc4519862f061af4e6b2 | cat/admin.py | cat/admin.py | from django.contrib import admin
from models import MuseumObject,FunctionalCategory
class MOAdmin(admin.ModelAdmin):
fields = ('registration_number','country','description','comment')
list_display = ('registration_number','country','description','comment')
list_filter = ('country','functional_category')
... | Enable Django Admin for some of our data | Enable Django Admin for some of our data
| Python | bsd-3-clause | uq-eresearch/uqam,uq-eresearch/uqam,uq-eresearch/uqam,uq-eresearch/uqam | ---
+++
@@ -0,0 +1,17 @@
+from django.contrib import admin
+from models import MuseumObject,FunctionalCategory
+
+class MOAdmin(admin.ModelAdmin):
+ fields = ('registration_number','country','description','comment')
+
+ list_display = ('registration_number','country','description','comment')
+
+ list_filter ... | |
edc982bdfaece6aaf23b3e7f9c967de800eacbd6 | txircd/modules/extra/snotice_links.py | txircd/modules/extra/snotice_links.py | from twisted.plugin import IPlugin
from txircd.modbase import IModuleData, ModuleData
from zope.interface import implements
class SnoLinks(ModuleData):
implements(IPlugin, IModuleData)
name = "ServerNoticeLinks"
def actions(self):
return [ ("serverconnect", 1, self.announceConnect),
("serverquit", ... | Implement links server notice type | Implement links server notice type
| Python | bsd-3-clause | Heufneutje/txircd | ---
+++
@@ -0,0 +1,28 @@
+from twisted.plugin import IPlugin
+from txircd.modbase import IModuleData, ModuleData
+from zope.interface import implements
+
+class SnoLinks(ModuleData):
+ implements(IPlugin, IModuleData)
+
+ name = "ServerNoticeLinks"
+
+ def actions(self):
+ return [ ("serverconnect", 1, self.announ... | |
c65f59c6a6048807d29e5ce123447afd006ce05f | users/migrations/0007_username_length.py | users/migrations/0007_username_length.py | # -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-11-02 11:53
from __future__ import unicode_literals
import django.contrib.auth.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0006_auto_20160508_1407'),
]
operati... | Add missing migration for username length | Add missing migration for username length
The username length changed from 30 to 150 in commit f2a0c964 which
updated Django to 1.10, but there was no migration created. Add the
missing migration.
| Python | mit | mikkokeskinen/tunnistamo,mikkokeskinen/tunnistamo | ---
+++
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.2 on 2016-11-02 11:53
+from __future__ import unicode_literals
+
+import django.contrib.auth.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0006_a... | |
1ef84c24c60cf802aeb4bf6084f9b7fc7696f79a | scripts/album_times.py | scripts/album_times.py | #!/usr/bin/env python3
"""Radio scheduling program.
Usage:
album_times.py [--host=HOST] PORT
Options:
--host=HOST Hostname of MPD [default: localhost]
-h --help Show this text
Prints out the last scheduling time of every album.
"""
from datetime import datetime
from docopt import docopt
from mpd import M... | Add a script to print the scheduling times of albums | Add a script to print the scheduling times of albums
| Python | mit | barrucadu/lainonlife,barrucadu/lainonlife,barrucadu/lainonlife,barrucadu/lainonlife | ---
+++
@@ -0,0 +1,92 @@
+#!/usr/bin/env python3
+
+"""Radio scheduling program.
+
+Usage:
+ album_times.py [--host=HOST] PORT
+
+Options:
+ --host=HOST Hostname of MPD [default: localhost]
+ -h --help Show this text
+
+Prints out the last scheduling time of every album.
+"""
+
+from datetime import datetime
+... | |
bda42a4630e8b9e720443b6785ff2e3435bfdfa6 | pybaseball/team_results.py | pybaseball/team_results.py | import pandas as pd
import requests
from bs4 import BeautifulSoup
# TODO: raise error if year > current year or < first year of a team's existence
# TODO: team validation. return error if team does not exist.
# TODO: sanitize team inputs (force to all caps)
def get_soup(season, team):
# get most recent year's sched... | Add code for getting team schedule and game outcomes | Add code for getting team schedule and game outcomes
| Python | mit | jldbc/pybaseball | ---
+++
@@ -0,0 +1,59 @@
+import pandas as pd
+import requests
+from bs4 import BeautifulSoup
+
+# TODO: raise error if year > current year or < first year of a team's existence
+# TODO: team validation. return error if team does not exist.
+# TODO: sanitize team inputs (force to all caps)
+
+def get_soup(season, te... | |
30d0ca9fa2c76463569362eb0f640dbbe0079068 | buildGame.py | buildGame.py | #!/usr/bin/env python
import fnmatch
import os
from subprocess import call
rootPath = 'ludumdare26'
pattern = '*.coffee'
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
print( os.path.join(root, filename))
call( [ 'coffee', '-c', os.path.join(root, fi... | Add builder to compile coffeescript to javascript files | Add builder to compile coffeescript to javascript files
| Python | apache-2.0 | ZzCalvinzZ/ludumdare26,ZzCalvinzZ/ludumdare26 | ---
+++
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+import fnmatch
+import os
+from subprocess import call
+
+rootPath = 'ludumdare26'
+pattern = '*.coffee'
+
+for root, dirs, files in os.walk(rootPath):
+ for filename in fnmatch.filter(files, pattern):
+ print( os.path.join(root, filename))
+ call(... | |
df03481fd9b52e17bc637dacefd15bead4f07f23 | project/creditor/management/commands/update_membershipfees.py | project/creditor/management/commands/update_membershipfees.py | # -*- coding: utf-8 -*-
import datetime
import dateutil.parser
from creditor.models import RecurringTransaction, TransactionTag
from creditor.tests.fixtures.recurring import MembershipfeeFactory
from django.core.management.base import BaseCommand, CommandError
from members.models import Member
class Command(BaseComm... | Add initial version of membership fee updater | Add initial version of membership fee updater
| Python | mit | HelsinkiHacklab/asylum,HelsinkiHacklab/asylum,HelsinkiHacklab/asylum,HelsinkiHacklab/asylum | ---
+++
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+import datetime
+import dateutil.parser
+
+from creditor.models import RecurringTransaction, TransactionTag
+from creditor.tests.fixtures.recurring import MembershipfeeFactory
+from django.core.management.base import BaseCommand, CommandError
+from members.models imp... | |
4e8ff1f7e524d8dc843816c714e86d11e21a8562 | uploadtoCDB.py | uploadtoCDB.py | #uploadtoCDB.py
#Written By: Alejandro Morejon Cortina (Apr 2016)
#usage:python uploadtoCDB.py <username> <filecontainingkey.txt> <upload.csv>
import sys
import requests
import csv
import json
import time
#sys.argv[1] is the your cartodb user name
#sys.argv[2] is the text file containing your api key
#sys.argv[3] is ... | Add script to upload files to carto db | Add script to upload files to carto db | Python | mit | alejandro-mc/BDM-DDD,alejandro-mc/BDM-DDD | ---
+++
@@ -0,0 +1,45 @@
+#uploadtoCDB.py
+#Written By: Alejandro Morejon Cortina (Apr 2016)
+#usage:python uploadtoCDB.py <username> <filecontainingkey.txt> <upload.csv>
+
+import sys
+import requests
+import csv
+import json
+import time
+
+#sys.argv[1] is the your cartodb user name
+#sys.argv[2] is the text file c... | |
8955c00cdf3715b0f6403e9d049c0e221f77f7ac | client.py | client.py | #!/usr/bin/env python
import chess
import chess.pgn
import requests
import random
game = chess.pgn.Game()
node = game
board = game.board()
while not board.is_game_over(claim_draw=True):
move = random.choice(list(board.legal_moves))
node = node.add_variation(move)
board.push(move)
game.headers["Result"]... | Add helper script for testing | Add helper script for testing
| Python | agpl-3.0 | niklasf/lila-openingexplorer,niklasf/lila-openingexplorer | ---
+++
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import chess
+import chess.pgn
+import requests
+import random
+
+game = chess.pgn.Game()
+node = game
+
+board = game.board()
+
+while not board.is_game_over(claim_draw=True):
+ move = random.choice(list(board.legal_moves))
+ node = node.add_variation(move)
+ ... | |
80a1cc839abc23a80b511c99e6a6c03b044eaf35 | ext_download.py | ext_download.py | import argparse
import glob
import json
from kvd_utils import download_json, get_session
ext_url_template = 'https://vaalit.yle.fi/content/kv2017/{version}/electorates/{electorate}/municipalities/{municipality}/pollingDistricts/{district}/partyAndCandidateResults.json'
def download_ext_data(version):
sess = get... | Add downloader for per-polling-station data | Add downloader for per-polling-station data
| Python | mit | akx/yle-kuntavaalit-2017-data | ---
+++
@@ -0,0 +1,39 @@
+import argparse
+import glob
+import json
+
+from kvd_utils import download_json, get_session
+
+ext_url_template = 'https://vaalit.yle.fi/content/kv2017/{version}/electorates/{electorate}/municipalities/{municipality}/pollingDistricts/{district}/partyAndCandidateResults.json'
+
+
+def downl... | |
574b069363f74de35b75b6b28ca66976e6af45bb | corehq/apps/smsforms/management/commands/migrate_sms_sessions_to_sql.py | corehq/apps/smsforms/management/commands/migrate_sms_sessions_to_sql.py | import logging
from django.core.management.base import BaseCommand
from corehq.apps.smsforms.models import XFormsSession, sync_sql_session_from_couch_session, SQLXFormsSession
from dimagi.utils.couch.database import iter_docs
class Command(BaseCommand):
args = ""
help = ""
def handle(self, *args, **optio... | import logging
from django.core.management.base import BaseCommand
from corehq.apps.smsforms.models import XFormsSession, sync_sql_session_from_couch_session, SQLXFormsSession
from dimagi.utils.couch.database import iter_docs
class Command(BaseCommand):
args = ""
help = ""
def handle(self, *args, **optio... | Fix situation where session id is an int | Fix situation where session id is an int
| Python | bsd-3-clause | dimagi/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq | ---
+++
@@ -14,6 +14,12 @@
errors = []
for session_doc in iter_docs(db, session_ids):
try:
+ # Handle the old touchforms session id convention where it was
+ # always an int
+ session_id = session_doc.get("session_id", None)
+ ... |
23f626ddaabfa799da48ee35c29db05f95f8a732 | polling_stations/apps/data_collection/management/commands/import_rct.py | polling_stations/apps/data_collection/management/commands/import_rct.py | """
Import Rhondda Cynon Taf
note: this script takes quite a long time to run
"""
from time import sleep
from django.contrib.gis.geos import Point
from data_collection.management.commands import BaseAddressCsvImporter
from data_finder.helpers import geocode
from data_collection.google_geocoding_api_wrapper import (
... | Add import script for Rhondda Cynon Taff | Add import script for Rhondda Cynon Taff
| Python | bsd-3-clause | andylolz/UK-Polling-Stations,DemocracyClub/UK-Polling-Stations,DemocracyClub/UK-Polling-Stations,chris48s/UK-Polling-Stations,DemocracyClub/UK-Polling-Stations,andylolz/UK-Polling-Stations,chris48s/UK-Polling-Stations,andylolz/UK-Polling-Stations,chris48s/UK-Polling-Stations | ---
+++
@@ -0,0 +1,94 @@
+"""
+Import Rhondda Cynon Taf
+
+note: this script takes quite a long time to run
+"""
+from time import sleep
+from django.contrib.gis.geos import Point
+from data_collection.management.commands import BaseAddressCsvImporter
+from data_finder.helpers import geocode
+from data_collection.goo... | |
6a47701ea874e657475542809ac0f9320063cb9b | releasezip.py | releasezip.py | import os
import sys
import zipfile
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
def main(version) :
release = zipfile.ZipFile('release-{}.zip'.format(version), 'w')
zipd... | Add script to help create release zip | Add script to help create release zip
| Python | mit | james91b/ida_ipython,james91b/ida_ipython,tmr232/ida_ipython,james91b/ida_ipython | ---
+++
@@ -0,0 +1,25 @@
+import os
+import sys
+import zipfile
+
+def zipdir(path, ziph):
+ # ziph is zipfile handle
+ for root, dirs, files in os.walk(path):
+ for file in files:
+ ziph.write(os.path.join(root, file))
+
+def main(version) :
+ release = zipfile.ZipFile('release... | |
2dfc4fcc61c0f9d00860168d44da5e03db8e61eb | photobox/cheesefolder.py | photobox/cheesefolder.py | import random
class Cheesefolder():
def __init__(self, folder):
self.directory = folder
pass
def getrandomphoto(self):
files = self.directory.getfiles_fullpath()
filecount = len(files)
randomindex = random.randint(0, filecount - 1)
return files[randomindex]
| Add a class to get a random photo of a folder | Add a class to get a random photo of a folder
| Python | mit | MarkusAmshove/Photobox | ---
+++
@@ -0,0 +1,14 @@
+import random
+
+
+class Cheesefolder():
+
+ def __init__(self, folder):
+ self.directory = folder
+ pass
+
+ def getrandomphoto(self):
+ files = self.directory.getfiles_fullpath()
+ filecount = len(files)
+ randomindex = random.randint(0, filecount -... | |
0bef4682c6a81464fd6e72fddd6f0b5957f4d566 | tools/data/calculate_paired_bbox_mean_std.py | tools/data/calculate_paired_bbox_mean_std.py | #!/usr/bin/env python
import argparse
import scipy.io as sio
import sys
import os.path as osp
import numpy as np
import cPickle
this_dir = osp.dirname(__file__)
sys.path.insert(0, osp.join(this_dir, '../../external/py-faster-rcnn/lib'))
from fast_rcnn.bbox_transform import bbox_transform
if __name__ == '__main__':
... | Add a script to calculate paried roi bbox emean and std. | Add a script to calculate paried roi bbox emean and std.
| Python | mit | myfavouritekk/TPN | ---
+++
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+import argparse
+import scipy.io as sio
+import sys
+import os.path as osp
+import numpy as np
+import cPickle
+this_dir = osp.dirname(__file__)
+sys.path.insert(0, osp.join(this_dir, '../../external/py-faster-rcnn/lib'))
+from fast_rcnn.bbox_transform import bbox_tr... | |
c6951374eba137614744928c18fa4d34de5c5d89 | src/algorithms/sorting/dataset_generator.py | src/algorithms/sorting/dataset_generator.py | # Description: Script to Generate Data Sets For Sorting Algorithms
import random
import logging
# Global Configuration
TOTAL_ROWS = 10
SORTED = False # Overrides REVERSE_SORTED and RANDOM_NUMBERS
REVERSE_SORTED = False # Overrides RANDOM_NUMBERS
RANDOM_NUMBERS = True # Least Precedence
WRITE_TO_FILE... | Add a script to generate data sets for testing sorting algorithms. | Add a script to generate data sets for testing sorting algorithms.
| Python | mit | vikash-india/ProgrammingProblems,vikash-india/ProgrammingProblems | ---
+++
@@ -0,0 +1,67 @@
+# Description: Script to Generate Data Sets For Sorting Algorithms
+
+import random
+import logging
+
+# Global Configuration
+TOTAL_ROWS = 10
+SORTED = False # Overrides REVERSE_SORTED and RANDOM_NUMBERS
+REVERSE_SORTED = False # Overrides RANDOM_NUMBERS
+RANDOM_NUMBERS = True... | |
45917087377adef01a4d4ce829013a7958a3afe5 | test/pathtools_test.py | test/pathtools_test.py | import os
import pytest
import hetio.readwrite
from hetio.pathtools import paths_between, DWPC
directory = os.path.dirname(os.path.abspath(__file__))
def test_disease_gene_example_dwpc():
"""
Test the DWPC computation from
https://doi.org/10.1371/journal.pcbi.1004259.g002
"""
path = os.path.joi... | Add PC / DWPC test | Add PC / DWPC test
| Python | cc0-1.0 | dhimmel/hetio | ---
+++
@@ -0,0 +1,31 @@
+import os
+
+import pytest
+
+import hetio.readwrite
+from hetio.pathtools import paths_between, DWPC
+
+directory = os.path.dirname(os.path.abspath(__file__))
+
+
+def test_disease_gene_example_dwpc():
+ """
+ Test the DWPC computation from
+ https://doi.org/10.1371/journal.pcbi.10... | |
a8bded67a92632fd6d2d8791dd245dc82c773c8d | integration/basic_server.py | integration/basic_server.py | """
This is a basic test which allows you to setup a server and listen to it.
For example, running:
python integration/basic_server.py localhost 8040
Sets up a server.
Running curl against it generates the following reponse:
curl 'http://localhost:8040/'
<html><body><h1>ok</h1><br/>from 28330
And in server output... | Add an integration folder for tests that are beyond the unittest scope | Add an integration folder for tests that are beyond the unittest scope
| Python | bsd-3-clause | markrwilliams/tectonic | ---
+++
@@ -0,0 +1,69 @@
+"""
+This is a basic test which allows you to setup a server and listen to it.
+
+For example, running:
+
+python integration/basic_server.py localhost 8040
+
+Sets up a server.
+
+Running curl against it generates the following reponse:
+
+curl 'http://localhost:8040/'
+<html><body><h1>ok</... | |
c34eb62d19c4216aa54199a083a06c2c45318cea | feedthefox/devices/migrations/0006_auto_20151110_1355.py | feedthefox/devices/migrations/0006_auto_20151110_1355.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import feedthefox.devices.models
class Migration(migrations.Migration):
dependencies = [
('devices', '0005_auto_20151105_1048'),
]
operations = [
migrations.AlterField(
m... | Add missing migration for IMEI db validation. | Add missing migration for IMEI db validation.
| Python | mpl-2.0 | akatsoulas/feedthefox,akatsoulas/feedthefox,mozilla/feedthefox,mozilla/feedthefox,akatsoulas/feedthefox,mozilla/feedthefox,akatsoulas/feedthefox,mozilla/feedthefox | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import feedthefox.devices.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('devices', '0005_auto_20151105_1048'),
+ ]
+
+ operations = [
+ ... | |
b3b7e2fcbff5cd0ec2d2b4457b7a46d1846d55a8 | glue_vispy_viewers/common/vispy_viewer.py | glue_vispy_viewers/common/vispy_viewer.py | from __future__ import absolute_import, division, print_function
import sys
from vispy import scene
from glue.external.qt import QtGui, get_qapp
class VispyWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(VispyWidget, self).__init__(parent=parent)
# Prepare Vispy canvas
s... | Implement a generic Vispy widget | Implement a generic Vispy widget | Python | bsd-2-clause | PennyQ/glue-3d-viewer,PennyQ/astro-vispy,glue-viz/glue-vispy-viewers,glue-viz/glue-3d-viewer,astrofrog/glue-vispy-viewers,astrofrog/glue-3d-viewer | ---
+++
@@ -0,0 +1,64 @@
+from __future__ import absolute_import, division, print_function
+
+import sys
+
+from vispy import scene
+from glue.external.qt import QtGui, get_qapp
+
+
+class VispyWidget(QtGui.QWidget):
+
+ def __init__(self, parent=None):
+
+ super(VispyWidget, self).__init__(parent=parent)
+... | |
8994f69f23271aa93d83e81032542f17b38423fd | .ipython/profile_default/ipython_config.py | .ipython/profile_default/ipython_config.py | """
IPython configuration with custom prompt using gruvbox colors.
- https://github.com/reillysiemens/ipython-style-gruvbox
Thanks to @petobens for their excellent dotfiles.
- https://github.com/petobens/dotfiles
"""
from typing import List, Optional, Tuple
import IPython.terminal.prompts as prompts
from prompt_toolk... | Add custom IPython configuration ✨ | Add custom IPython configuration ✨
| Python | isc | reillysiemens/dotfiles,reillysiemens/dotfiles | ---
+++
@@ -0,0 +1,72 @@
+"""
+IPython configuration with custom prompt using gruvbox colors.
+- https://github.com/reillysiemens/ipython-style-gruvbox
+
+Thanks to @petobens for their excellent dotfiles.
+- https://github.com/petobens/dotfiles
+"""
+from typing import List, Optional, Tuple
+
+import IPython.terminal... | |
1c7f6a6c44af9c2de372fb2c07469da29bc11764 | tests/test_encoding.py | tests/test_encoding.py | from diana.encoding import encode, decode
from nose.tools import eq_
DECODE_TESTS = [ ('', (), ()),
('b', (0x00,), (0,)),
('BB', (0x12, 0xfe), (0x12, 0xfe)),
('bb', (0x12, 0xfe), (0x12, -2)),
('s', (0x12, 0x34), (0x3412,)),
('s', (0xf... | Add tests for encoding subsystem | Add tests for encoding subsystem
| Python | mit | prophile/libdiana | ---
+++
@@ -0,0 +1,42 @@
+from diana.encoding import encode, decode
+from nose.tools import eq_
+
+DECODE_TESTS = [ ('', (), ()),
+ ('b', (0x00,), (0,)),
+ ('BB', (0x12, 0xfe), (0x12, 0xfe)),
+ ('bb', (0x12, 0xfe), (0x12, -2)),
+ ('s', (0x12, 0x34), (0x3... | |
93a1ff67e62d0508744420cab8263a8cc893b119 | test/list_backup_counts.py | test/list_backup_counts.py | import urbackup_api
server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
clients = server.get_status()
for client in clients:
file_backups = server.get_clientbackups(client["id"])
incr_file = 0
full_file = 0
for file_backup in file_backups:
... | Add example listing backup counts | Add example listing backup counts
| Python | apache-2.0 | uroni/urbackup-server-python-web-api-wrapper | ---
+++
@@ -0,0 +1,42 @@
+import urbackup_api
+
+server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
+
+clients = server.get_status()
+
+for client in clients:
+
+ file_backups = server.get_clientbackups(client["id"])
+
+ incr_file = 0
+ full_file = 0
+
+ for file... | |
16f0ec2d0e5c33126ddb01604213c6a14115e605 | test/test_pocket_parser.py | test/test_pocket_parser.py | import unittest
import utils
import os
import sys
import re
import subprocess
TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(TOPDIR)
import pocket_parser
class Tests(unittest.TestCase):
def test_get_cnc(self):
"""Test get_cnc() function"""
res = pocket_par... | Add basic test of pocket_parser. | Add basic test of pocket_parser.
| Python | lgpl-2.1 | salilab/cryptosite,salilab/cryptosite,salilab/cryptosite | ---
+++
@@ -0,0 +1,23 @@
+import unittest
+import utils
+import os
+import sys
+import re
+import subprocess
+
+TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+sys.path.append(TOPDIR)
+import pocket_parser
+
+class Tests(unittest.TestCase):
+
+ def test_get_cnc(self):
+ """Test get_... | |
7021806e9e510286424dae696c2f4eee0a70b630 | src/forms.py | src/forms.py | #-*- coding: utf-8 -*-
from __future__ import unicode_literals
import crispy_forms.helper
class DefaultFormHelper(crispy_forms.helper.FormHelper):
def __init__(self, form=None):
super(DefaultFormHelper, self).__init__(form=form)
self.form_class = "form-horizontal"
self.html5_required = T... | Define default crispy form helper | Define default crispy form helper
| Python | mit | nigma/djutil | ---
+++
@@ -0,0 +1,13 @@
+#-*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
+
+import crispy_forms.helper
+
+
+class DefaultFormHelper(crispy_forms.helper.FormHelper):
+ def __init__(self, form=None):
+ super(DefaultFormHelper, self).__init__(form=form)
+ self.form_class = "form-horiz... | |
8919cf7171d7a659c0b90c41f2520029bab1423e | scripts/run_travis.py | scripts/run_travis.py | #!/usr/bin/env python3
import argparse
import sys
import pprint
import shlex
import yaml
from pathlib import Path
def gen_test_script(ty, job, output):
output.write('#!/usr/bin/env bash\n\n')
output.write('set -ex\n')
# extract environment variables
e_str = ty['env'][job]
for v_assign in shlex.... | Add tool to extract build process from .travis.yml | Add tool to extract build process from .travis.yml
Usage:
./scripts/run_travis.py -j JOB_ID -o run.sh
bash run.sh | ts "%F %H:%M:%.S"
| Python | mpl-2.0 | advancedtelematic/sota_client_cpp,advancedtelematic/aktualizr,advancedtelematic/aktualizr,advancedtelematic/aktualizr,advancedtelematic/aktualizr,advancedtelematic/sota_client_cpp | ---
+++
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+
+import argparse
+import sys
+import pprint
+import shlex
+import yaml
+
+from pathlib import Path
+
+
+def gen_test_script(ty, job, output):
+ output.write('#!/usr/bin/env bash\n\n')
+ output.write('set -ex\n')
+
+ # extract environment variables
+ e_str... | |
d186c80feb7dee875a1a7debfd115e100dc3fca1 | send_studentvoices.py | send_studentvoices.py | import os
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "studentportal.settings")
from django.core.urlresolvers import reverse
from django.conf import settings
from post_office import mail
from studentvoice.models import Voice
for voice in Voice.objects.filter(was_sent=False, parent... | Add a cronjob script for sending studentvoice notifications. | Add a cronjob script for sending studentvoice notifications.
| Python | agpl-3.0 | enjaz/enjaz,osamak/student-portal,osamak/student-portal,osamak/student-portal,enjaz/enjaz,enjaz/enjaz,enjaz/enjaz,osamak/student-portal,enjaz/enjaz,osamak/student-portal | ---
+++
@@ -0,0 +1,45 @@
+import os
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "studentportal.settings")
+
+from django.core.urlresolvers import reverse
+from django.conf import settings
+
+from post_office import mail
+from studentvoice.models import Voice
+
+for voice in Voic... | |
eb9ba88177ce23ef259b1731f02c38d0ccaa8318 | run_build.py | run_build.py | #!/usr/bin/python3
import re
import os
import string
import sys
import subprocess
import auto_merge
def compile_dogecoin():
path = os.getcwd()
subprocess.check_output([path + os.path.sep + 'autogen.sh'])
subprocess.check_output([path + os.path.sep + 'configure'])
subprocess.check_output(['make', 'clean'], std... | Add new script to build Dogecoin | Add new script to build Dogecoin
| Python | mit | rnicoll/robodoge | ---
+++
@@ -0,0 +1,32 @@
+#!/usr/bin/python3
+
+import re
+import os
+import string
+import sys
+import subprocess
+import auto_merge
+
+def compile_dogecoin():
+ path = os.getcwd()
+ subprocess.check_output([path + os.path.sep + 'autogen.sh'])
+ subprocess.check_output([path + os.path.sep + 'configure'])
+ subpr... | |
46eaacef6240a72089bda049214640c50ec353ec | backend/globaleaks/tests/handlers/test_robots.py | backend/globaleaks/tests/handlers/test_robots.py | # -*- coding: utf-8 -*-
import json
from twisted.internet.defer import inlineCallbacks
from globaleaks.handlers import robots
from globaleaks.models import config
from globaleaks.rest import requests
from globaleaks.settings import GLSettings
from globaleaks.tests import helpers
class TestRobotstxtHandlerHandler(hel... | Add tests for robots APIs | Add tests for robots APIs
| Python | agpl-3.0 | vodkina/GlobaLeaks,vodkina/GlobaLeaks,vodkina/GlobaLeaks,vodkina/GlobaLeaks | ---
+++
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+import json
+
+from twisted.internet.defer import inlineCallbacks
+from globaleaks.handlers import robots
+from globaleaks.models import config
+from globaleaks.rest import requests
+from globaleaks.settings import GLSettings
+from globaleaks.tests import helpers
+
+... | |
3e3e5bb92b1d9e0e1981a6deba41152826c3fce0 | scripts/popvsdistinct.py | scripts/popvsdistinct.py | """
Plot and calculate county population size to number of distinct hashtags.
"""
import matplotlib.pyplot as plt
import seaborn
import pandas
import twitterproj
import scipy.stats
import numpy as np
def populations():
# Grab demographic info
data = {}
df = pandas.read_csv('../census/county/PEP_2013_PEPAN... | Add script to plot population vs distinct hashtags. | Add script to plot population vs distinct hashtags.
| Python | unlicense | chebee7i/twitter,chebee7i/twitter,chebee7i/twitter | ---
+++
@@ -0,0 +1,42 @@
+"""
+Plot and calculate county population size to number of distinct hashtags.
+
+"""
+import matplotlib.pyplot as plt
+import seaborn
+import pandas
+import twitterproj
+import scipy.stats
+import numpy as np
+
+def populations():
+ # Grab demographic info
+ data = {}
+ df = pandas... | |
465a604547e1438e650c8b4142816e2330363767 | tests/cpydiff/types_list_store_noniter.py | tests/cpydiff/types_list_store_noniter.py | """
categories: Types,list
description: List slice-store with non-iterable on RHS is not implemented
cause: RHS is restricted to be a tuple or list
workaround: Use ``list(<iter>)`` on RHS to convert the iterable to a list
"""
l = [10, 20]
l[0:1] = range(4)
print(l)
| Add a test for storing iterable to a list slice. | tests/cpydiff: Add a test for storing iterable to a list slice.
| Python | mit | alex-robbins/micropython,adafruit/circuitpython,PappaPeppar/micropython,adafruit/micropython,SHA2017-badge/micropython-esp32,swegener/micropython,Timmenem/micropython,henriknelson/micropython,adafruit/micropython,TDAbboud/micropython,SHA2017-badge/micropython-esp32,deshipu/micropython,deshipu/micropython,deshipu/microp... | ---
+++
@@ -0,0 +1,9 @@
+"""
+categories: Types,list
+description: List slice-store with non-iterable on RHS is not implemented
+cause: RHS is restricted to be a tuple or list
+workaround: Use ``list(<iter>)`` on RHS to convert the iterable to a list
+"""
+l = [10, 20]
+l[0:1] = range(4)
+print(l) | |
d6d4f175330638f35d4eb0512ef14f82eab74f50 | show-adverts.py | show-adverts.py | # -*- coding: utf-8 -*-
import os, sys
print(sys.version_info)
import marshal
import select
import socket
import time
def _unpack(message):
return marshal.loads(message)
def _pack(message):
return marshal.dumps(message)
PORT = 9999
MESSAGE_SIZE = 256
#
# Set the socket up to broadcast datagrams over... | Add a debug tool to show advertising broadcasts | Add a debug tool to show advertising broadcasts
| Python | mit | tjguk/networkzero,tjguk/networkzero,tjguk/networkzero | ---
+++
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+import os, sys
+print(sys.version_info)
+import marshal
+import select
+import socket
+import time
+
+def _unpack(message):
+ return marshal.loads(message)
+
+def _pack(message):
+ return marshal.dumps(message)
+
+PORT = 9999
+MESSAGE_SIZE = 256
+
+#
+#... | |
4a70f9ed2f19cba08208fa9f2a3cafe38ee283b6 | corehq/apps/userreports/tests/test_columns.py | corehq/apps/userreports/tests/test_columns.py | from django.test import SimpleTestCase
from jsonobject.exceptions import BadValueError
from corehq.apps.userreports.reports.specs import ReportColumn
class TestReportColumn(SimpleTestCase):
def testBadAggregation(self):
with self.assertRaises(BadValueError):
ReportColumn.wrap({
... | from django.test import SimpleTestCase
from jsonobject.exceptions import BadValueError
from sqlagg import SumWhen
from corehq.apps.userreports.sql import _expand_column
from corehq.apps.userreports.reports.specs import ReportColumn
class TestReportColumn(SimpleTestCase):
def testBadAggregation(self):
wit... | Add simple test for column expansion | Add simple test for column expansion
| Python | bsd-3-clause | qedsoftware/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -1,5 +1,7 @@
from django.test import SimpleTestCase
from jsonobject.exceptions import BadValueError
+from sqlagg import SumWhen
+from corehq.apps.userreports.sql import _expand_column
from corehq.apps.userreports.reports.specs import ReportColumn
@@ -35,3 +37,21 @@
"format": "defaul... |
643456f6f1bb9f264dbe6d3ad48a84af4e4dd91c | temba/flows/migrations/0087_fix_open_ended_ruleset_with_timeout.py | temba/flows/migrations/0087_fix_open_ended_ruleset_with_timeout.py | # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-26 08:42
from __future__ import unicode_literals
import json
from django.db import migrations
def fix_ruleset_categories_open_ended(RuleSet):
rulesets = list(RuleSet.objects.all())
if not rulesets:
return
affected_flows = []
f... | Add data migrations for rulesets | Add data migrations for rulesets
| Python | agpl-3.0 | pulilab/rapidpro,pulilab/rapidpro,pulilab/rapidpro,tsotetsi/textily-web,tsotetsi/textily-web,tsotetsi/textily-web,tsotetsi/textily-web,tsotetsi/textily-web,pulilab/rapidpro,pulilab/rapidpro | ---
+++
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-01-26 08:42
+from __future__ import unicode_literals
+
+import json
+
+from django.db import migrations
+
+
+def fix_ruleset_categories_open_ended(RuleSet):
+ rulesets = list(RuleSet.objects.all())
+ if not rulesets:
+ ... | |
36fb0255a4037a9fe7b6d61868f8666325fea944 | tests/blueprints/user_message/test_address_formatting.py | tests/blueprints/user_message/test_address_formatting.py | """
:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""
from unittest.mock import patch
import pytest
from byceps.database import db
from byceps.services.email.models import EmailConfig
from byceps.services.user_message import service as user_message_service
from testfixt... | Test recipient address formatting in user message e-mails | Test recipient address formatting in user message e-mails
| Python | bsd-3-clause | m-ober/byceps,m-ober/byceps,m-ober/byceps,homeworkprod/byceps,homeworkprod/byceps,homeworkprod/byceps | ---
+++
@@ -0,0 +1,83 @@
+"""
+:Copyright: 2006-2018 Jochen Kupperschmidt
+:License: Modified BSD, see LICENSE for details.
+"""
+
+from unittest.mock import patch
+
+import pytest
+
+from byceps.database import db
+from byceps.services.email.models import EmailConfig
+from byceps.services.user_message import service... | |
f290dd020b2cb3e586c8de6c4e8e3c1bc80f3583 | evaluation/packages/colours.py | evaluation/packages/colours.py | """@package Colours
This module provides the colourmaps used in globOpt to display primitives
according to their gid
"""
import packages.primitive as primitive
import packages.orderedSet as orderedSet
class Colours(object):
def __init__(self):
self.colListMedium = ['#F15A60', '#7AC36A', '#5A9BD4', '#FA... | Add new class to compute the colourmap and the node filters accordingly to did | Add new class to compute the colourmap and the node filters accordingly to did
| Python | apache-2.0 | amonszpart/globOpt,amonszpart/globOpt,amonszpart/globOpt,amonszpart/globOpt,NUAAXXY/globOpt,NUAAXXY/globOpt,NUAAXXY/globOpt,NUAAXXY/globOpt,amonszpart/globOpt,NUAAXXY/globOpt,amonszpart/globOpt,NUAAXXY/globOpt | ---
+++
@@ -0,0 +1,38 @@
+"""@package Colours
+This module provides the colourmaps used in globOpt to display primitives
+according to their gid
+
+"""
+
+import packages.primitive as primitive
+import packages.orderedSet as orderedSet
+
+class Colours(object):
+
+ def __init__(self):
+ self.colListMedium ... | |
833d114bd1bc396dc7c6b0434782f9e326319e88 | readAptinaRAW.py | readAptinaRAW.py | import os
import numpy
import matplotlib.pyplot as plt
Directory = '/scratch/tmp/DevWareX/MT9M001/DSL949A-NIR/'
Folder = '1394629994_MT9M001_DSL949A-NIR_0.0_0.0f_040ms_090mm_to150mm'
File = 'MT9M001_1280x1024_DSL949A-NIR_0.0_0.0f_040ms_090mm_to150mm_090mm.raw'
Size = [int(File.split('_')[1].split('x')[1]),
int... | Add file to read .RAW images from Aptina | Add file to read .RAW images from Aptina
Reading the files via numpy.memmap can destroy the files if one performs
calculations like Image -= numpy.mean(Image), since those changes are
saved to disk immediately... Thus loading the .RAW files via
numpy.fromfile is a better idea.
This tiny script shows how to read the im... | Python | unlicense | habi/GlobalDiagnostiX,habi/GlobalDiagnostiX,habi/GlobalDiagnostiX | ---
+++
@@ -0,0 +1,32 @@
+import os
+import numpy
+import matplotlib.pyplot as plt
+
+Directory = '/scratch/tmp/DevWareX/MT9M001/DSL949A-NIR/'
+Folder = '1394629994_MT9M001_DSL949A-NIR_0.0_0.0f_040ms_090mm_to150mm'
+File = 'MT9M001_1280x1024_DSL949A-NIR_0.0_0.0f_040ms_090mm_to150mm_090mm.raw'
+Size = [int(File.split(... | |
56fd675e5bf0bd68a73e21c244807c39a87a3eee | heufybot/modules/util/commandhandler.py | heufybot/modules/util/commandhandler.py | from twisted.plugin import IPlugin
from heufybot.moduleinterface import BotModule, IBotModule
from zope.interface import implements
class CommandHandler(BotModule):
implements(IPlugin, IBotModule)
name = "CommandHandler"
def hookBot(self, bot):
self.bot = bot
def actions(self):
retu... | Implement the command handler framework | Implement the command handler framework
| Python | mit | Heufneutje/PyHeufyBot,Heufneutje/PyHeufyBot | ---
+++
@@ -0,0 +1,25 @@
+from twisted.plugin import IPlugin
+from heufybot.moduleinterface import BotModule, IBotModule
+from zope.interface import implements
+
+
+class CommandHandler(BotModule):
+ implements(IPlugin, IBotModule)
+
+ name = "CommandHandler"
+
+ def hookBot(self, bot):
+ self.bot = b... | |
26cad83ebb6466d66f1e9fd87e963af4b5247ecc | sort/heap_sort/python/heap_sort_ccsc.py | sort/heap_sort/python/heap_sort_ccsc.py | # Python program for implementation of heap Sort
# To heapify subtree rooted at index i.
# n is size of heap
def heapify(arr, n, i):
largest = i # Initialize largest as root
l = 2 * i + 1 # left = 2*i + 1
r = 2 * i + 2 # right = 2*i + 2
# See if left child of root exists and is
# greater than root
if l < n an... | Add Heap sort implemented in python | Add Heap sort implemented in python
| Python | cc0-1.0 | 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... | ---
+++
@@ -0,0 +1,48 @@
+# Python program for implementation of heap Sort
+
+# To heapify subtree rooted at index i.
+# n is size of heap
+def heapify(arr, n, i):
+ largest = i # Initialize largest as root
+ l = 2 * i + 1 # left = 2*i + 1
+ r = 2 * i + 2 # right = 2*i + 2
+
+ # See if left child of root exists and... | |
083957302452bdd966286bfd8d37d53dce8db7d3 | pykeg/contrib/facebook/fbutil.py | pykeg/contrib/facebook/fbutil.py | import facebook
def profile_for_user(user):
profile = user.facebookprofile_set.all()
if not profile:
return None
return profile[0]
def session_for_user(user):
profile = profile_for_user(user)
if not profile:
return None
session = profile.session.all()
if not session:
return None
return ses... | Add utility methods for facebook stuff. | Add utility methods for facebook stuff.
| Python | mit | Kegbot/kegbot-server,Kegbot/kegbot-server,Kegbot/kegbot-server,Kegbot/kegbot-server,Kegbot/kegbot-server | ---
+++
@@ -0,0 +1,26 @@
+import facebook
+
+def profile_for_user(user):
+ profile = user.facebookprofile_set.all()
+ if not profile:
+ return None
+ return profile[0]
+
+def session_for_user(user):
+ profile = profile_for_user(user)
+ if not profile:
+ return None
+ session = profile.session.all()
+ if ... | |
f0ac1914790e69fe786d6d3182cf15fd09302c28 | integration-test/912-missing-building-part.py | integration-test/912-missing-building-part.py | # http://www.openstreetmap.org/way/287494678
z = 18
x = 77193
y = 98529
while z >= 16:
assert_has_feature(
z, x, y, 'buildings',
{ 'kind': 'building',
'id': 287494678 })
z -= 1
x /= 2
y /= 2
| Add test for missing building part seen in production. | Add test for missing building part seen in production.
| Python | mit | mapzen/vector-datasource,mapzen/vector-datasource,mapzen/vector-datasource | ---
+++
@@ -0,0 +1,13 @@
+# http://www.openstreetmap.org/way/287494678
+z = 18
+x = 77193
+y = 98529
+while z >= 16:
+ assert_has_feature(
+ z, x, y, 'buildings',
+ { 'kind': 'building',
+ 'id': 287494678 })
+
+ z -= 1
+ x /= 2
+ y /= 2 | |
5e81fca928862b1c9574f1092a131337735b63f4 | tests/integration/iam/test_connection.py | tests/integration/iam/test_connection.py | # Copyright (c) 2014 Amazon.com, Inc. or its affiliates.
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the right... | Add basic IAM integration test | Add basic IAM integration test
| Python | mit | lra/boto,jotes/boto,Asana/boto,nexusz99/boto,serviceagility/boto,ekalosak/boto,shipci/boto,yangchaogit/boto,varunarya10/boto,kouk/boto,podhmo/boto,j-carl/boto,janslow/boto,disruptek/boto,nikhilraog/boto,bryx-inc/boto,khagler/boto,TiVoMaker/boto,s0enke/boto,stevenbrichards/boto,acourtney2015/boto,weka-io/boto,rayluo/bot... | ---
+++
@@ -0,0 +1,44 @@
+# Copyright (c) 2014 Amazon.com, Inc. or its affiliates.
+# All rights reserved.
+#
+# 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, includi... | |
c3d87e837c85284baa132104e4843c3fd8f429d3 | day-04-2.py | day-04-2.py | import hashlib
puzzle_input = b'iwrupvqb'
number = 100000
while True:
key = puzzle_input + str(number).encode()
if hashlib.md5(key).hexdigest()[:6] == '000000':
break
number += 1
print(number)
# Now that I think about it, starting with 100,000 was probably not the right
# thing to do. I could'v... | Complete day 4 part 2 | Complete day 4 part 2
| Python | mit | foxscotch/advent-of-code,foxscotch/advent-of-code | ---
+++
@@ -0,0 +1,20 @@
+import hashlib
+
+
+puzzle_input = b'iwrupvqb'
+number = 100000
+
+while True:
+ key = puzzle_input + str(number).encode()
+ if hashlib.md5(key).hexdigest()[:6] == '000000':
+ break
+ number += 1
+
+print(number)
+
+# Now that I think about it, starting with 100,000 was proba... | |
1dd1111bd1bab62ed900d74f347a7fe10d03eb03 | test/release.py | test/release.py | from __future__ import absolute_import
import user_agent
import re
def test_changelog():
"""
Parse changelog and ensure that it contains
* unreleased version younger than release date
* release version has a date
"""
re_date = re.compile(r'^\d{4}-\d{2}-\d{2}$')
ver_dates = {}
ver_hist... | Test that changelog is not outdated | Test that changelog is not outdated
| Python | mit | lorien/user_agent | ---
+++
@@ -0,0 +1,27 @@
+from __future__ import absolute_import
+
+import user_agent
+import re
+
+
+def test_changelog():
+ """
+ Parse changelog and ensure that it contains
+ * unreleased version younger than release date
+ * release version has a date
+ """
+ re_date = re.compile(r'^\d{4}-\d{2}-... | |
1b83a31090cd803d2eca0b9caed0f4cc9a149fbd | cubes/stores.py | cubes/stores.py | from .errors import *
from .browser import AggregationBrowser
from .extensions import get_namespace, initialize_namespace
__all__ = (
"open_store",
"Store"
)
def open_store(name, **options):
"""Gets a new instance of a model provider with name `name`."""
ns = get_namespace("s... | from .errors import *
from .browser import AggregationBrowser
from .extensions import get_namespace, initialize_namespace
__all__ = (
"open_store",
"Store"
)
def open_store(name, **options):
"""Gets a new instance of a model provider with name `name`."""
ns = get_namespace("s... | Raise ConfigurationError error that causes server to fail and dump whole stacktrace | Raise ConfigurationError error that causes server to fail and dump whole stacktrace
| Python | mit | noyeitan/cubes,jell0720/cubes,zejn/cubes,jell0720/cubes,she11c0de/cubes,cesarmarinhorj/cubes,jell0720/cubes,she11c0de/cubes,cesarmarinhorj/cubes,she11c0de/cubes,zejn/cubes,pombredanne/cubes,ubreddy/cubes,cesarmarinhorj/cubes,pombredanne/cubes,pombredanne/cubes,noyeitan/cubes,ubreddy/cubes,zejn/cubes,ubreddy/cubes,noyei... | ---
+++
@@ -19,7 +19,7 @@
try:
factory = ns[name]
except KeyError:
- raise CubesError("Unable to find store '%s'" % name)
+ raise ConfigurationError("Unknown store '%s'" % name)
return factory(**options)
@@ -35,7 +35,7 @@
try:
factory = ns[type_]
except Key... |
4046c743323a4357864afcac482a5625ed71c184 | euler006.py | euler006.py | #!/usr/bin/python
limit = 100
sum_sq = ((limit + 1) * limit) / 2
sum_sq *= sum_sq
sq_sum = (limit * (limit + 1) * ((limit * 2) + 1)) / 6
print (int (sum_sq - sq_sum))
| Add solution for problem 6 | Add solution for problem 6
| Python | mit | cifvts/PyEuler | ---
+++
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+
+limit = 100
+
+sum_sq = ((limit + 1) * limit) / 2
+sum_sq *= sum_sq
+sq_sum = (limit * (limit + 1) * ((limit * 2) + 1)) / 6
+
+print (int (sum_sq - sq_sum)) | |
337e60c3d63b56b1237e3d5b052a96f3824cc6c2 | corehq/apps/sms/management/commands/migrate_sms_to_sql.py | corehq/apps/sms/management/commands/migrate_sms_to_sql.py | from corehq.apps.sms.models import SMSLog, SMS
from custom.fri.models import FRISMSLog
from dimagi.utils.couch.database import iter_docs
from django.core.management.base import BaseCommand, CommandError
from optparse import make_option
class Command(BaseCommand):
args = ""
help = ("Migrates SMSLog to SMS")
... | Add command to migrate SMSLog to SQL | Add command to migrate SMSLog to SQL
| Python | bsd-3-clause | dimagi/commcare-hq,puttarajubr/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq | ---
+++
@@ -0,0 +1,50 @@
+from corehq.apps.sms.models import SMSLog, SMS
+from custom.fri.models import FRISMSLog
+from dimagi.utils.couch.database import iter_docs
+from django.core.management.base import BaseCommand, CommandError
+from optparse import make_option
+
+
+class Command(BaseCommand):
+ args = ""
+ ... | |
d1588bdf0a672de8d7d4f4f9cddcc236f5b9026e | examples/plotting/file/properties_alpha.py | examples/plotting/file/properties_alpha.py | import bokeh.plotting as plt
from itertools import product
plt.output_file('properties_alpha.html')
cats = ['RGB', 'RGBA', 'Alpha+RGB', 'Alpha+RGBA']
p = plt.figure(x_range=cats, y_range=cats,
title="Fill and Line Color Property Combinations")
alpha = 0.5
fill_color = (242, 44, 64)
fill_color_alpha = ... | Add plot for color property combinations to examples. | Add plot for color property combinations to examples.
| Python | bsd-3-clause | CrazyGuo/bokeh,ericdill/bokeh,saifrahmed/bokeh,stuart-knock/bokeh,schoolie/bokeh,PythonCharmers/bokeh,alan-unravel/bokeh,percyfal/bokeh,mindriot101/bokeh,satishgoda/bokeh,roxyboy/bokeh,daodaoliang/bokeh,ChristosChristofidis/bokeh,rs2/bokeh,Karel-van-de-Plassche/bokeh,aavanian/bokeh,ChristosChristofidis/bokeh,Karel-van-... | ---
+++
@@ -0,0 +1,40 @@
+import bokeh.plotting as plt
+from itertools import product
+
+plt.output_file('properties_alpha.html')
+
+cats = ['RGB', 'RGBA', 'Alpha+RGB', 'Alpha+RGBA']
+p = plt.figure(x_range=cats, y_range=cats,
+ title="Fill and Line Color Property Combinations")
+
+alpha = 0.5
+fill_col... | |
090c73c20e3a57f5b2710c270b0dfc139633d623 | test/test_gamenode.py | test/test_gamenode.py | """ Tests for the GameNode module """
from contextlib import contextmanager
from io import StringIO
import sys
import unittest
from src import gamenode
@contextmanager
def captured_output():
""" Redirects stdout to StringIO so we can inspect Print statements """
new_out = StringIO()
old_out = sys.stdout
... | Add tests for GameNode module | Add tests for GameNode module
| Python | mit | blairck/jaeger | ---
+++
@@ -0,0 +1,76 @@
+""" Tests for the GameNode module """
+
+from contextlib import contextmanager
+from io import StringIO
+import sys
+import unittest
+
+from src import gamenode
+
+@contextmanager
+def captured_output():
+ """ Redirects stdout to StringIO so we can inspect Print statements """
+ new_ou... | |
3063044995a14921fd0da2ebbbd57942bb5ca24d | hubblestack/extmods/modules/safecommand.py | hubblestack/extmods/modules/safecommand.py | # -*- encoding: utf-8 -*-
'''
Safe Command
============
The idea behind this module is to allow an arbitrary command to be executed
safely, with the arguments to the specified binary (optionally) coming from
the fileserver.
For example, you might have some internal license auditing application for
which you need the ... | Add the skeleton and docs | Add the skeleton and docs
| Python | apache-2.0 | basepi/hubble,basepi/hubble | ---
+++
@@ -0,0 +1,45 @@
+# -*- encoding: utf-8 -*-
+'''
+Safe Command
+============
+
+The idea behind this module is to allow an arbitrary command to be executed
+safely, with the arguments to the specified binary (optionally) coming from
+the fileserver.
+
+For example, you might have some internal license auditin... | |
53d0d5886670ba33a645fd8c82479fb4495d25d1 | website/migrations/0002_auto_20150118_2210.py | website/migrations/0002_auto_20150118_2210.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('website', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='query',
name='cacheable... | Add new migrations (use "" as default for hash) | Add new migrations (use "" as default for hash)
Fixes #22
| Python | mit | sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz,sqlviz/sqlviz | ---
+++
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('website', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model... | |
37b5531e2cc969e1ee73a46bf372d89871f922a7 | tools/gen_prime.py | tools/gen_prime.py | import argparse
import sys
# Sieve of Eratosthenes
# Code by David Eppstein, UC Irvine, 28 Feb 2002
# http://code.activestate.com/recipes/117119/
def gen_primes():
""" Generate an infinite sequence of prime numbers.
"""
# Maps composites to primes witnessing their compositeness.
# This is memory effic... | Add array of prime number generator code | Add array of prime number generator code
| Python | mit | everyevery/programming_study,everyevery/algorithm_code,everyevery/algorithm_code,everyevery/programming_study,everyevery/algorithm_code,everyevery/algorithm_code,everyevery/algorithm_code,everyevery/programming_study,everyevery/algorithm_code,everyevery/programming_study,everyevery/algorithm_code,everyevery/programming... | ---
+++
@@ -0,0 +1,65 @@
+import argparse
+import sys
+
+# Sieve of Eratosthenes
+# Code by David Eppstein, UC Irvine, 28 Feb 2002
+# http://code.activestate.com/recipes/117119/
+
+def gen_primes():
+ """ Generate an infinite sequence of prime numbers.
+ """
+ # Maps composites to primes witnessing their com... | |
47775471e2e8f0d88cb79d362114b5f49128a492 | factory/main.py | factory/main.py | import random
def get_digit():
return random.randint(1, 9)
from zope.component.factory import Factory
factory = Factory(get_digit, 'random_digit', 'Gives a random digit')
from zope.component import getGlobalSiteManager
from zope.component.interfaces import IFactory
gsm = getGlobalSiteManager()
gsm.registerUt... | Add example of factory usage | Add example of factory usage | Python | mit | duboviy/zca | ---
+++
@@ -0,0 +1,22 @@
+import random
+
+
+def get_digit():
+ return random.randint(1, 9)
+
+
+from zope.component.factory import Factory
+factory = Factory(get_digit, 'random_digit', 'Gives a random digit')
+
+
+from zope.component import getGlobalSiteManager
+from zope.component.interfaces import IFactory
+
+g... | |
b9d167cf1eba2d55ab7710e78f38c3fa010d21ef | axelrod/strategies/__init__.py | axelrod/strategies/__init__.py | from cooperator import *
from defector import *
from grudger import *
from rand import *
from titfortat import *
from gobymajority import *
from alternator import *
from averagecopier import *
from grumpy import *
strategies = [
Defector,
Cooperator,
TitForTat,
Grudger,
GoByMaj... | from cooperator import *
from defector import *
from grudger import *
from rand import *
from titfortat import *
from gobymajority import *
from alternator import *
from averagecopier import *
from grumpy import *
from inverse import *
strategies = [
Defector,
Cooperator,
TitForTat,
Gr... | Change init to add inverse strategy | Change init to add inverse strategy | Python | mit | marcharper/Axelrod,ranjinidas/Axelrod,ranjinidas/Axelrod,marcharper/Axelrod | ---
+++
@@ -7,6 +7,7 @@
from alternator import *
from averagecopier import *
from grumpy import *
+from inverse import *
strategies = [
@@ -19,4 +20,5 @@
Alternator,
AverageCopier,
Grumpy,
+ Inverse
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.