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 |
|---|---|---|---|---|---|---|---|---|---|---|
4fb4603522c3693ef6ca1f7e258f9aaf3cccc7d1 | all-domains/data-structures/linked-lists/print-the-elements-of-a-linked-list/solution.py | all-domains/data-structures/linked-lists/print-the-elements-of-a-linked-list/solution.py | # https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list
# Python 2
"""
Print elements of a linked list on console
head input could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next =... | Print all the elements of a linked list | Print all the elements of a linked list
| Python | mit | arvinsim/hackerrank-solutions | ---
+++
@@ -0,0 +1,25 @@
+# https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list
+# Python 2
+
+"""
+ Print elements of a linked list on console
+ head input could be None as well for empty list
+ Node is defined as
+
+ class Node(object):
+
+ def __init__(self, data=None, next_node=None):
+ ... | |
5bdc9a7834c67ac7e39c9674b328a68e42467efc | yggdrasil/yggdrasil_tests.py | yggdrasil/yggdrasil_tests.py | from unittest import TestCase
from intent.igt.references import raw_tier, cleaned_tier, normalized_tier
from intent.igt.rgxigt import Igt
from yggdrasil.igt_operations import add_raw_tier, add_clean_tier, add_normal_tier
class ConstructIGTTests(TestCase):
def setUp(self):
self.lines = [{'text':'This is ... | Move testcases here from INTENT. | Move testcases here from INTENT.
| Python | mit | xigt/yggdrasil,xigt/yggdrasil,xigt/yggdrasil | ---
+++
@@ -0,0 +1,27 @@
+from unittest import TestCase
+
+from intent.igt.references import raw_tier, cleaned_tier, normalized_tier
+from intent.igt.rgxigt import Igt
+from yggdrasil.igt_operations import add_raw_tier, add_clean_tier, add_normal_tier
+
+
+class ConstructIGTTests(TestCase):
+
+ def setUp(self):
+ ... | |
e783c0381208326f79db411a39d008701d57ad89 | librisxl-tools/scripts/normalize_jsonlines.py | librisxl-tools/scripts/normalize_jsonlines.py | #!/usr/bin/env python
from __future__ import unicode_literals, print_function
import unicodedata
import json
import sys
for l in sys.stdin:
l = json.loads(l)
l = json.dumps(l, ensure_ascii=False)
l = unicodedata.normalize('NFC', l)
print(l.encode('utf-8'))
| Add script for normalizing unicode in json line dumps | Add script for normalizing unicode in json line dumps
| Python | apache-2.0 | libris/librisxl,libris/librisxl,libris/librisxl | ---
+++
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+from __future__ import unicode_literals, print_function
+import unicodedata
+import json
+import sys
+for l in sys.stdin:
+ l = json.loads(l)
+ l = json.dumps(l, ensure_ascii=False)
+ l = unicodedata.normalize('NFC', l)
+ print(l.encode('utf-8')) | |
40f8190029cf1431a14cd74dfab515d7bb106dd4 | pyscores/api_wrapper.py | pyscores/api_wrapper.py | import json
import os
import requests
class APIWrapper(object):
def __init__(self, base_url=None, auth_token=None):
if base_url:
self.base_url = base_url
else:
self.base_url = "http://api.football-data.org/v1"
if auth_token:
self.headers = {
... | Add the start of an api wrapper | Add the start of an api wrapper
| Python | mit | conormag94/pyscores | ---
+++
@@ -0,0 +1,43 @@
+import json
+import os
+
+import requests
+
+
+class APIWrapper(object):
+
+ def __init__(self, base_url=None, auth_token=None):
+
+ if base_url:
+ self.base_url = base_url
+ else:
+ self.base_url = "http://api.football-data.org/v1"
+
+ if auth_t... | |
822fdaa409322a41eb83797da76d021e97e34949 | hassio_api/hassio/version.py | hassio_api/hassio/version.py | """Bootstrap HassIO."""
import asyncio
import json
import logging
import os
from colorlog import ColoredFormatter
from .const import (
FILE_HASSIO_VERSION, CONF_SUPERVISOR_TAG, CONF_SUPERVISOR_IMAGE,
CONF_HOMEASSISTANT_TAG, CONF_HOMEASSISTANT_IMAGE)
_LOGGER = logging.getLogger(__name__)
class Version(Objec... | Update HassIO API -> new files | Update HassIO API -> new files
| Python | bsd-3-clause | pvizeli/hassio,pvizeli/hassio | ---
+++
@@ -0,0 +1,79 @@
+"""Bootstrap HassIO."""
+import asyncio
+import json
+import logging
+import os
+
+from colorlog import ColoredFormatter
+
+from .const import (
+ FILE_HASSIO_VERSION, CONF_SUPERVISOR_TAG, CONF_SUPERVISOR_IMAGE,
+ CONF_HOMEASSISTANT_TAG, CONF_HOMEASSISTANT_IMAGE)
+
+_LOGGER = logging.g... | |
b9349f7bfa19904dee140743ccf9f0198e958516 | scripts/load_results.py | scripts/load_results.py | from random import randint
from dakis.core.models import Experiment
def load_results(exp_pk, func_cls, calls50, calls100, callsavg):
tasks = Experiment.objects.get(pk=exp_pk).tasks.filter(func_cls=func_cls)
l = sorted([randint(0, int(callsavg*2)) for i in range(tasks.count())])
for i in range(tasks.count(... | Implement script to add exp results from article | Implement script to add exp results from article
| Python | agpl-3.0 | niekas/dakis,niekas/dakis,niekas/dakis | ---
+++
@@ -0,0 +1,31 @@
+from random import randint
+from dakis.core.models import Experiment
+
+
+def load_results(exp_pk, func_cls, calls50, calls100, callsavg):
+ tasks = Experiment.objects.get(pk=exp_pk).tasks.filter(func_cls=func_cls)
+ l = sorted([randint(0, int(callsavg*2)) for i in range(tasks.count())... | |
12f51ce0d5e6c67e15ba3d60c21523a28d29b964 | polygraph/types/tests/test_type_map.py | polygraph/types/tests/test_type_map.py | from unittest import TestCase
from polygraph.types.decorators import field
from polygraph.types.object_type import ObjectType
from polygraph.types.scalar import ID, Boolean, Float, Int, String
from polygraph.types.schema import Schema
from polygraph.types.type_builder import List, NonNull, Union
class Person(ObjectT... | Add tests for the type map builder | Add tests for the type map builder
| Python | mit | polygraph-python/polygraph | ---
+++
@@ -0,0 +1,41 @@
+from unittest import TestCase
+
+from polygraph.types.decorators import field
+from polygraph.types.object_type import ObjectType
+from polygraph.types.scalar import ID, Boolean, Float, Int, String
+from polygraph.types.schema import Schema
+from polygraph.types.type_builder import List, Non... | |
aa1c6dbede3cbee67d1b2b0a1064fd7cc5662251 | discovery-diff/discovery-diff.py | discovery-diff/discovery-diff.py | import json
from subprocess import Popen, PIPE
import os
import sys
def hardware_data(hw_id):
'''Read the discoverd data about the given node from Swift'''
# OS_TENANT_NAME=service swift download --output - ironic-discoverd <ID>
p = Popen(('swift', 'download', '--output', '-', 'ironic-discoverd', hw_id),
... | Add a script for diffing the hw discovery data | Add a script for diffing the hw discovery data
This will let us spot-check things that should be identical but aren't.
| Python | apache-2.0 | rthallisey/clapper,larsks/clapper,larsks/clapper,coolsvap/clapper,rthallisey/clapper,coolsvap/clapper,coolsvap/clapper | ---
+++
@@ -0,0 +1,63 @@
+import json
+from subprocess import Popen, PIPE
+import os
+import sys
+
+
+def hardware_data(hw_id):
+ '''Read the discoverd data about the given node from Swift'''
+ # OS_TENANT_NAME=service swift download --output - ironic-discoverd <ID>
+ p = Popen(('swift', 'download', '--outpu... | |
c18519b4f5f7cbac24e053df422d83733d6963f6 | examples/test_pdf_asserts.py | examples/test_pdf_asserts.py | from seleniumbase import BaseCase
class PdfTestClass(BaseCase):
def test_assert_pdf_text(self):
# Assert PDF contains the expected text on Page 1
self.assert_pdf_text(
"https://nostarch.com/download/Automate_the_Boring_Stuff_dTOC.pdf",
"Programming Is a Creative Activity"... | Add a test for asserting text in a PDF file | Add a test for asserting text in a PDF file
| Python | mit | seleniumbase/SeleniumBase,seleniumbase/SeleniumBase,seleniumbase/SeleniumBase,mdmintz/SeleniumBase,mdmintz/SeleniumBase,mdmintz/SeleniumBase,mdmintz/SeleniumBase,seleniumbase/SeleniumBase | ---
+++
@@ -0,0 +1,16 @@
+from seleniumbase import BaseCase
+
+
+class PdfTestClass(BaseCase):
+
+ def test_assert_pdf_text(self):
+
+ # Assert PDF contains the expected text on Page 1
+ self.assert_pdf_text(
+ "https://nostarch.com/download/Automate_the_Boring_Stuff_dTOC.pdf",
+ ... | |
1f6c7b33a150096dad4c856516b6dd23dd1571ae | read-coverage.py | read-coverage.py | """Translate coverage.py data files to JSON."""
import argparse
import json
import pathlib
import sys
from coverage import coverage as Coverage
def parse_args(argv=None):
"""Parse command-line argument."""
parser = argparse.ArgumentParser()
parser.add_argument(
"coverage",
nargs=1,
... | Add Python script to read coverage data files | Add Python script to read coverage data files
| Python | mit | Holiverh/atom-coverage-python | ---
+++
@@ -0,0 +1,58 @@
+"""Translate coverage.py data files to JSON."""
+
+
+import argparse
+import json
+import pathlib
+import sys
+
+from coverage import coverage as Coverage
+
+
+def parse_args(argv=None):
+ """Parse command-line argument."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument(... | |
597938ad9fd4117fd5bd43f492983a0364cdf276 | tests/cupy_tests/sparse_tests/test_construct.py | tests/cupy_tests/sparse_tests/test_construct.py | import unittest
import numpy
from cupy import testing
@testing.parameterize(*testing.product({
'dtype': [numpy.float32, numpy.float64],
'format': ['csr', 'csc', 'coo'],
'm': [3],
'n': [None, 3],
}))
@testing.with_requires('scipy')
class TestEye(unittest.TestCase):
@testing.numpy_cupy_allclose(s... | Add test for eye and identity | Add test for eye and identity
| Python | mit | cupy/cupy,cupy/cupy,cupy/cupy,cupy/cupy | ---
+++
@@ -0,0 +1,37 @@
+import unittest
+
+import numpy
+
+from cupy import testing
+
+
+@testing.parameterize(*testing.product({
+ 'dtype': [numpy.float32, numpy.float64],
+ 'format': ['csr', 'csc', 'coo'],
+ 'm': [3],
+ 'n': [None, 3],
+}))
+@testing.with_requires('scipy')
+class TestEye(unittest.Test... | |
038bd9745cda294491589bbca60b1b3431ce39cc | llvmlite/tests/test_setup.py | llvmlite/tests/test_setup.py | """
Tests for setup.py behavior
"""
import distutils.core
try:
import setuptools
except ImportError:
setuptools = None
import sys
import unittest
from collections import namedtuple
from importlib.util import spec_from_file_location, module_from_spec
from pathlib import Path
from . import TestCase
setup_path ... | Add test for setup.py's _guard_py_ver | Add test for setup.py's _guard_py_ver
| Python | bsd-2-clause | numba/llvmlite,numba/llvmlite,numba/llvmlite,numba/llvmlite | ---
+++
@@ -0,0 +1,71 @@
+"""
+Tests for setup.py behavior
+"""
+
+import distutils.core
+try:
+ import setuptools
+except ImportError:
+ setuptools = None
+import sys
+import unittest
+from collections import namedtuple
+from importlib.util import spec_from_file_location, module_from_spec
+from pathlib import ... | |
a4aaa91209d8ab3e819bbf22e45f22e62af99426 | pymatgen/symmetry/tests/test_spacegroup.py | pymatgen/symmetry/tests/test_spacegroup.py | #!/usr/bin/env python
'''
Created on Mar 12, 2012
'''
from __future__ import division
__author__="Shyue Ping Ong"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyue@mit.edu"
__date__ = "Mar 12, 2012"
import unittest
import os
from pymatg... | Add a unittest for spacegroup. Still very basic. | Add a unittest for spacegroup. Still very basic.
Former-commit-id: 1a63abe5e2a85b220d8b4fd5fa4cd25a1c739e49 [formerly 5f925f837f4ae3ba136f0d6e271848b06467ea8b]
Former-commit-id: 3112d8f3738a35c4572c9384f8860a6de69a9b6a | Python | mit | mbkumar/pymatgen,davidwaroquiers/pymatgen,Bismarrck/pymatgen,Bismarrck/pymatgen,blondegeek/pymatgen,gpetretto/pymatgen,tschaume/pymatgen,xhqu1981/pymatgen,ndardenne/pymatgen,dongsenfo/pymatgen,ndardenne/pymatgen,Bismarrck/pymatgen,davidwaroquiers/pymatgen,matk86/pymatgen,montoyjh/pymatgen,nisse3000/pymatgen,johnson1228... | ---
+++
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+'''
+Created on Mar 12, 2012
+'''
+
+from __future__ import division
+
+__author__="Shyue Ping Ong"
+__copyright__ = "Copyright 2012, The Materials Project"
+__version__ = "0.1"
+__maintainer__ = "Shyue Ping Ong"
+__email__ = "shyue@mit.edu"
+__date__ = "Mar 12, 2012... | |
4f6fde8329b0873f3568ce7153dc64017f5bc0cb | boto/beanstalk/__init__.py | boto/beanstalk/__init__.py | # Copyright (c) 2013 Mitch Garnaat http://garnaat.org/
# Copyright (c) 2013 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... | Add connect_to_region to beanstalk module. | Add connect_to_region to beanstalk module.
| Python | mit | jamesls/boto,appneta/boto,rjschwei/boto,SaranyaKarthikeyan/boto,drbild/boto,lra/boto,weebygames/boto,revmischa/boto,s0enke/boto,pfhayes/boto,drbild/boto,khagler/boto,dimdung/boto,Timus1712/boto,trademob/boto,alex/boto,nishigori/boto,jindongh/boto,janslow/boto,garnaat/boto,alfredodeza/boto,jameslegg/boto,disruptek/boto,... | ---
+++
@@ -0,0 +1,69 @@
+# Copyright (c) 2013 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2013 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"... | |
915b3f3ca7008faa22bbe9ef32cd652d371dbe4a | bongo/apps/bongo/tests/cache_tests.py | bongo/apps/bongo/tests/cache_tests.py | from django.test import TestCase
from django.core.cache import cache
class CacheTestCase(TestCase):
def test_cache_task(self):
""" Test memcached or LocMemCache, just so we know it's working """
cached = cache.get("cache_key")
if not cached:
cache.set("cache_key", "cache_value"... | Add a test to test the cache is working | Add a test to test the cache is working
| Python | mit | BowdoinOrient/bongo,BowdoinOrient/bongo,BowdoinOrient/bongo,BowdoinOrient/bongo | ---
+++
@@ -0,0 +1,12 @@
+from django.test import TestCase
+from django.core.cache import cache
+
+class CacheTestCase(TestCase):
+ def test_cache_task(self):
+ """ Test memcached or LocMemCache, just so we know it's working """
+ cached = cache.get("cache_key")
+
+ if not cached:
+ ... | |
8e19937489f4481c860487a8f06440cfe5c7bea2 | switchy/apps/routers.py | switchy/apps/routers.py | # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Routing apps
"""
from collections import Counter
from ..marks import event_callback
from ..utils import get_logger
... | Add a generic bridging app - `Bridger` | Add a generic bridging app - `Bridger`
Allows for defining bridge args per profile entry count.
By default 'proxy' routing is implemented as described in the docs.
| Python | mpl-2.0 | wwezhuimeng/switch,sangoma/switchy | ---
+++
@@ -0,0 +1,39 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+"""
+Routing apps
+"""
+from collections import Counter
+from ..marks import event_callbac... | |
9b38539c1828af1c45ac736fccda907cded65c24 | examples/vds_simple.py | examples/vds_simple.py | '''A simple example of building a virtual dataset.
This makes four 'source' HDF5 files, each with a 1D dataset of 100 numbers.
Then it makes a single 4x100 virtual dataset in a separate file, exposing
the four sources as one dataset.
'''
import h5py
from h5py._hl.vds import vmlist_to_kwawrgs
import numpy as np
# Cre... | Add simple example of using VDS | Add simple example of using VDS
| Python | bsd-3-clause | h5py/h5py,h5py/h5py,h5py/h5py | ---
+++
@@ -0,0 +1,32 @@
+'''A simple example of building a virtual dataset.
+
+This makes four 'source' HDF5 files, each with a 1D dataset of 100 numbers.
+Then it makes a single 4x100 virtual dataset in a separate file, exposing
+the four sources as one dataset.
+'''
+
+import h5py
+from h5py._hl.vds import vmlist_... | |
9e8bce87c10e14a1961cab1a6a0275d8008b590e | djangae/contrib/auth/backends.py | djangae/contrib/auth/backends.py | from django.contrib.auth.models import User, UserPermissionStorage
class AppEngineUserAPI(object):
"""
A custom Django authentication backend, which lets us authenticate against the Google
users API
"""
supports_anonymous_user = True
def authenticate(self, **credentials):
"""
... | Add an appengine users API auth backend | Add an appengine users API auth backend
| Python | bsd-3-clause | armirusco/djangae,jscissr/djangae,stucox/djangae,stucox/djangae,leekchan/djangae,jscissr/djangae,pablorecio/djangae,asendecka/djangae,kirberich/djangae,martinogden/djangae,pablorecio/djangae,potatolondon/djangae,jscissr/djangae,chargrizzle/djangae,pablorecio/djangae,chargrizzle/djangae,trik/djangae,leekchan/djangae,grz... | ---
+++
@@ -0,0 +1,75 @@
+from django.contrib.auth.models import User, UserPermissionStorage
+
+class AppEngineUserAPI(object):
+ """
+ A custom Django authentication backend, which lets us authenticate against the Google
+ users API
+ """
+
+ supports_anonymous_user = True
+
+ def authentic... | |
58c55d65cc32f673a378a65772e7ae447907994e | test/MSVC/pch-basics.py | test/MSVC/pch-basics.py | #!/usr/bin/env python
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
... | Add a test on basic PCH behavior: bulid a simple executable and a simple shared lib | Add a test on basic PCH behavior: bulid a simple executable and a simple shared lib
| Python | mit | timj/scons,timj/scons,timj/scons,andrewyoung1991/scons,andrewyoung1991/scons,timj/scons,timj/scons,timj/scons,timj/scons,andrewyoung1991/scons,andrewyoung1991/scons,timj/scons,andrewyoung1991/scons,andrewyoung1991/scons,timj/scons,andrewyoung1991/scons,andrewyoung1991/scons,andrewyoung1991/scons | ---
+++
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to ... | |
27d975bf84122ec62f96ddae4777e177d562bf7e | thinc/extra/load_nlp.py | thinc/extra/load_nlp.py | import spacy
SPACY_MODELS = {}
def get_spacy(lang, parser=False, tagger=False, entity=False):
global SPACY_MODELS
if spacy is None:
raise ImportError("Could not import spacy. Is it installed?")
if lang not in SPACY_MODELS:
SPACY_MODELS[lang] = spacy.load(
lang, parser=parser, t... | Add loader for spaCy, with singleton | Add loader for spaCy, with singleton
| Python | mit | spacy-io/thinc,explosion/thinc,spacy-io/thinc,explosion/thinc,explosion/thinc,spacy-io/thinc,explosion/thinc | ---
+++
@@ -0,0 +1,12 @@
+import spacy
+
+SPACY_MODELS = {}
+
+def get_spacy(lang, parser=False, tagger=False, entity=False):
+ global SPACY_MODELS
+ if spacy is None:
+ raise ImportError("Could not import spacy. Is it installed?")
+ if lang not in SPACY_MODELS:
+ SPACY_MODELS[lang] = spacy.loa... | |
31a42391445846cf2c8c4ace5319df92df8e5e96 | plugins/vars/default_vars.py | plugins/vars/default_vars.py | # -*- coding: utf-8 -*-
# (c) 2014, Craig Tracey <craigtracey@gmail.com>
#
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version... | Add a default variable plugin | Add a default variable plugin
As it stands right now, there are a number of scenarios where we would
like to be more DRY. We have multiple environments that we support and
copying and pasting variables from one environment to the next is a
recipe for disaster. Therefore provide an optional group_vars wrapper
plugin.
| Python | mit | nirajdp76/ursula,narengan/ursula,pbannister/ursula,nirajdp76/ursula,pgraziano/ursula,davidcusatis/ursula,edtubillara/ursula,j2sol/ursula,MaheshIBM/ursula,masteinhauser/ursula,knandya/ursula,blueboxjesse/ursula,twaldrop/ursula,sivakom/ursula,nirajdp76/ursula,blueboxgroup/ursula,greghaynes/ursula,rongzhus/ursula,blueboxj... | ---
+++
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+# (c) 2014, Craig Tracey <craigtracey@gmail.com>
+#
+# This module is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# ... | |
79dc92f7089e26f7751fdd8ef53543922750e41d | jarn/mkrelease/tests/test_scp.py | jarn/mkrelease/tests/test_scp.py | import unittest
from jarn.mkrelease.scp import SCP
class HasHostTests(unittest.TestCase):
def test_simple(self):
scp = SCP()
self.assertEqual(scp.has_host('foo:bar'), True)
def test_slash(self):
scp = SCP()
self.assertEqual(scp.has_host('foo:bar/baz'), True)
def test_no... | Add tests for SCP operations. | Add tests for SCP operations.
| Python | bsd-2-clause | Jarn/jarn.mkrelease | ---
+++
@@ -0,0 +1,42 @@
+import unittest
+
+from jarn.mkrelease.scp import SCP
+
+
+class HasHostTests(unittest.TestCase):
+
+ def test_simple(self):
+ scp = SCP()
+ self.assertEqual(scp.has_host('foo:bar'), True)
+
+ def test_slash(self):
+ scp = SCP()
+ self.assertEqual(scp.has_ho... | |
da1a7ceb0dafdeb14b366139e0ec13fe95c55c00 | scripts/generate_manifest.py | scripts/generate_manifest.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import json
import yaml
def merge_dicts(a, b):
if not (isinstance(a, dict) and isinstance(b, dict)):
raise ValueError("Error merging variables: '{}' and '{}'".format(
type(a).__name__, type(b).__name__
))
result ... | Add a script to generate PaaS manifest with environment variables | Add a script to generate PaaS manifest with environment variables
`./scripts/generate_manifest.py` takes a path to a PaaS manifest file
and a list of variable files and prints a single CloudFoundry manifest.
The generated manifest replaces all `inherit` keys by loading the data
from parent manifests. This allows us t... | Python | mit | alphagov/notifications-api,alphagov/notifications-api | ---
+++
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+
+import json
+import yaml
+
+
+def merge_dicts(a, b):
+ if not (isinstance(a, dict) and isinstance(b, dict)):
+ raise ValueError("Error merging variables: '{}' and '{}'".format(
+ type(a).__name__,... | |
b1af7e4d1a6ee0b954406af5a65936a011db3269 | openstack/common/fixture/mockpatch.py | openstack/common/fixture/mockpatch.py | # vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "Li... | Add a fixture for dealing with mock patching. | Add a fixture for dealing with mock patching.
Quantum uses a pattern all over their test base, which can be
collapsed down into a simple re-usable fixture.
Change-Id: I5944505ce44ce8b79a685c3ea392f001307b5319
| Python | apache-2.0 | openstack/oslotest,openstack/oslotest | ---
+++
@@ -0,0 +1,51 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+# Licensed under the A... | |
d70f973b8b77ad30f6c6d893adda90d2a084d7bb | scripts/mc_monitor_correlator.py | scripts/mc_monitor_correlator.py | #! /usr/bin/env python
# -*- mode: python; coding: utf-8 -*-
# Copyright 2018 the HERA Collaboration
# Licensed under the 2-clause BSD license.
"""Gather correlator status info and log them into M&C
"""
from __future__ import absolute_import, division, print_function
import sqlalchemy.exc
import sys
import time
impo... | Add monitoring daemon for correlator control state | Add monitoring daemon for correlator control state
| Python | bsd-2-clause | HERA-Team/hera_mc,HERA-Team/Monitor_and_Control,HERA-Team/hera_mc | ---
+++
@@ -0,0 +1,50 @@
+#! /usr/bin/env python
+# -*- mode: python; coding: utf-8 -*-
+# Copyright 2018 the HERA Collaboration
+# Licensed under the 2-clause BSD license.
+
+"""Gather correlator status info and log them into M&C
+
+"""
+from __future__ import absolute_import, division, print_function
+
+import sqla... | |
2d88b2ffaa3c6348fcc246185e48abc52ee8804d | backends.py | backends.py | from django.contrib.auth.backends import ModelBackend
from .decorators import monitor_login
class MonitoredModelBackend(ModelBackend):
@monitor_login
def authenticate(self, **credentials):
super(MonitoredModelBackend, self).authenticate(**credentials)
| Add monitored model auth backend | Add monitored model auth backend
| Python | bsd-3-clause | mysociety/django-failedloginblocker | ---
+++
@@ -0,0 +1,10 @@
+from django.contrib.auth.backends import ModelBackend
+
+from .decorators import monitor_login
+
+
+class MonitoredModelBackend(ModelBackend):
+
+ @monitor_login
+ def authenticate(self, **credentials):
+ super(MonitoredModelBackend, self).authenticate(**credentials) | |
f665fd7c8e3100427d589c9f82c847526aa41c86 | test_aversion.py | test_aversion.py | # Copyright 2013 Rackspace
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... | Set up test file and add tests on quoted_split(). | Set up test file and add tests on quoted_split().
| Python | apache-2.0 | klmitch/aversion | ---
+++
@@ -0,0 +1,53 @@
+# Copyright 2013 Rackspace
+# 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/LICENS... | |
cc7ea8b4e51e1f5d8e580dea89141dcca7032c32 | ureport/polls/migrations/0052_auto_20180327_2024.py | ureport/polls/migrations/0052_auto_20180327_2024.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-03-27 20:24
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('polls', '0051_auto_20180316_0912'),
]
operations = [
migrations.AlterField... | Add default value and constraints migrations | Add default value and constraints migrations
| Python | agpl-3.0 | Ilhasoft/ureport,rapidpro/ureport,rapidpro/ureport,rapidpro/ureport,Ilhasoft/ureport,Ilhasoft/ureport,Ilhasoft/ureport,rapidpro/ureport | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.11 on 2018-03-27 20:24
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('polls', '0051_auto_20180316_0912'),
+ ]
+
+ ope... | |
c466242d652683f8d22164f7b322399100961bcc | anytownlib/maps.py | anytownlib/maps.py | """Functions to retrieve images for the maps."""
def _retrieve_google_maps_image_url(coords, zoom_level):
lat, lng = coords
return (
'http://maps.googleapis.com/maps/api/staticmap?center={0},{1}&zoom={2}'
'&scale=false&size=600x300&maptype=roadmap&format=png'
'&markers=size:small%7Ccol... | Add Anytown Maps utils library | Add Anytown Maps utils library
| Python | mit | andrewyang96/AnytownMapper,andrewyang96/AnytownMapper,andrewyang96/AnytownMapper | ---
+++
@@ -0,0 +1,20 @@
+"""Functions to retrieve images for the maps."""
+
+
+def _retrieve_google_maps_image_url(coords, zoom_level):
+ lat, lng = coords
+ return (
+ 'http://maps.googleapis.com/maps/api/staticmap?center={0},{1}&zoom={2}'
+ '&scale=false&size=600x300&maptype=roadmap&format=png'... | |
b9a28ad7358b64211905957ef854026cf03764c8 | keras_tf_atrous_bug.py | keras_tf_atrous_bug.py | import numpy as np
from keras.models import Model
from keras.layers import Input, AtrousConvolution1D
inp = Input((100, 1))
M = AtrousConvolution1D(1, 2, atrous_rate=25, border_mode='same')(inp)
M = Model(inp, M)
M.compile('sgd', 'mse')
M.train_on_batch(np.random.rand(1, 100, 1), np.random.rand(1, 100, 1)) | Introduce Keras TF atrous bug | Introduce Keras TF atrous bug
| Python | apache-2.0 | israelg99/eva | ---
+++
@@ -0,0 +1,10 @@
+import numpy as np
+from keras.models import Model
+from keras.layers import Input, AtrousConvolution1D
+
+inp = Input((100, 1))
+M = AtrousConvolution1D(1, 2, atrous_rate=25, border_mode='same')(inp)
+M = Model(inp, M)
+M.compile('sgd', 'mse')
+
+M.train_on_batch(np.random.rand(1, 100, 1), ... | |
d9f60cba7af74dd724306111b366dda78b363236 | common/djangoapps/django_comment_common/migrations/0008_role_user_index.py | common/djangoapps/django_comment_common/migrations/0008_role_user_index.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('django_comment_common', '0007_discussionsidmapping'),
]
operations = [
migrations.RunSQL(
'CREATE INDEX dcc_role_users_u... | Add a (user_id, role_id) index to dcc_role_users table. | Add a (user_id, role_id) index to dcc_role_users table.
| Python | agpl-3.0 | ESOedX/edx-platform,philanthropy-u/edx-platform,EDUlib/edx-platform,eduNEXT/edunext-platform,ESOedX/edx-platform,msegado/edx-platform,philanthropy-u/edx-platform,ahmedaljazzar/edx-platform,eduNEXT/edx-platform,ESOedX/edx-platform,ahmedaljazzar/edx-platform,edx-solutions/edx-platform,edx-solutions/edx-platform,EDUlib/ed... | ---
+++
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('django_comment_common', '0007_discussionsidmapping'),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+... | |
86de63f819a67aafd71e1565266e1bec09bc62c2 | corehq/apps/accounting/management/commands/find_inactive_custom_modules.py | corehq/apps/accounting/management/commands/find_inactive_custom_modules.py | from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
import csv
from collections import defaultdict
from django.apps import apps
from django.core.management import BaseCommand
from django.conf import settings
from importlib import import_module
from cor... | Add management command to identify stale custom modules | Add management command to identify stale custom modules
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,85 @@
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
+import csv
+from collections import defaultdict
+
+from django.apps import apps
+from django.core.management import BaseCommand
+from django.conf import settings
+from im... | |
b47bf6a862075af25d7dbfa022f403997474414d | dragonflow/common/utils.py | dragonflow/common/utils.py | # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the... | Add Dargonflow DFDaemon base class | Add Dargonflow DFDaemon base class
Change-Id: Ie84681792cdc13b3127a95a18121d4b9a8ff8dba
| Python | apache-2.0 | FrankDuan/df_code,openstack/dragonflow,openstack/dragonflow,FrankDuan/df_code,FrankDuan/df_code,openstack/dragonflow | ---
+++
@@ -0,0 +1,46 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing... | |
551f3de948b6b0a7338dbb2e1783a407b724fc04 | tests/v6/test_spawn_primitive_generators.py | tests/v6/test_spawn_primitive_generators.py | import pytest
from .exemplar_generators import EXEMPLAR_PRIMITIVE_GENERATORS
@pytest.mark.parametrize("g", EXEMPLAR_PRIMITIVE_GENERATORS)
def test_spawn_primitive_generators(g):
"""
Test that primitive generators can be spawned and the spawned versions produce the same elements.
"""
num_items = 50
... | Add test that spawns of primitive generators produce the same elements as the original | Add test that spawns of primitive generators produce the same elements as the original
| Python | mit | maxalbert/tohu | ---
+++
@@ -0,0 +1,29 @@
+import pytest
+from .exemplar_generators import EXEMPLAR_PRIMITIVE_GENERATORS
+
+
+@pytest.mark.parametrize("g", EXEMPLAR_PRIMITIVE_GENERATORS)
+def test_spawn_primitive_generators(g):
+ """
+ Test that primitive generators can be spawned and the spawned versions produce the same eleme... | |
b39d03cf5e4ca514da6e8d0f20e0d5e8960c191c | server/src/weblab/db/upgrade/regular/versions/3fab9480c190_professor_instructor.py | server/src/weblab/db/upgrade/regular/versions/3fab9480c190_professor_instructor.py | """professor => instructor
Revision ID: 3fab9480c190
Revises: 31ded1f6ad6
Create Date: 2014-02-17 00:56:12.566690
"""
# revision identifiers, used by Alembic.
revision = '3fab9480c190'
down_revision = '31ded1f6ad6'
from alembic import op
import sqlalchemy as sa
metadata = sa.MetaData()
role = sa.Table('Role', meta... | Use instructor instead of professor | Use instructor instead of professor
| Python | bsd-2-clause | morelab/weblabdeusto,zstars/weblabdeusto,weblabdeusto/weblabdeusto,porduna/weblabdeusto,weblabdeusto/weblabdeusto,morelab/weblabdeusto,weblabdeusto/weblabdeusto,zstars/weblabdeusto,morelab/weblabdeusto,morelab/weblabdeusto,morelab/weblabdeusto,porduna/weblabdeusto,zstars/weblabdeusto,weblabdeusto/weblabdeusto,porduna/w... | ---
+++
@@ -0,0 +1,30 @@
+"""professor => instructor
+
+Revision ID: 3fab9480c190
+Revises: 31ded1f6ad6
+Create Date: 2014-02-17 00:56:12.566690
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '3fab9480c190'
+down_revision = '31ded1f6ad6'
+
+from alembic import op
+import sqlalchemy as sa
+
+metadata =... | |
2192cf4caa93a2b9c2a4332ba59c40175e8f977b | gscripts/ipython_imports.py | gscripts/ipython_imports.py | import numpy as np
import pandas as pd
import matplotlib_venn
import matplotlib.pyplot as plt
import brewer2mpl
set1 = brewer2mpl.get_map('Set1', 'qualitative', 9).mpl_colors
red = set1[0]
blue = set1[1]
green = set1[2]
purple = set1[3]
orange = set1[4]
yellow = set1[5]
brown = set1[6]
pink = set1[7]
grey = set1[8] | Add file for easy ipython imports | Add file for easy ipython imports
| Python | mit | YeoLab/gscripts,YeoLab/gscripts,YeoLab/gscripts,YeoLab/gscripts | ---
+++
@@ -0,0 +1,16 @@
+import numpy as np
+import pandas as pd
+import matplotlib_venn
+import matplotlib.pyplot as plt
+import brewer2mpl
+
+set1 = brewer2mpl.get_map('Set1', 'qualitative', 9).mpl_colors
+red = set1[0]
+blue = set1[1]
+green = set1[2]
+purple = set1[3]
+orange = set1[4]
+yellow = set1[5]
+brown =... | |
55755871c240289238072602eefd9eed14d7e70e | bin/combine-examples.py | bin/combine-examples.py | #!/usr/bin/python
import re
import sys
def main(argv):
examples = {}
requires = set()
for filename in argv[1:]:
lines = open(filename, 'rU').readlines()
if len(lines) > 0 and lines[0].startswith('// NOCOMPILE'):
continue
requires.update(line for line in lines if line.s... | #!/usr/bin/python
import re
import sys
def main(argv):
examples = {}
requires = set()
for filename in argv[1:]:
lines = open(filename, 'rU').readlines()
if len(lines) > 0 and lines[0].startswith('// NOCOMPILE'):
continue
requires.update(line for line in lines if line.s... | Use write to avoid newline problems | Use write to avoid newline problems
| Python | bsd-2-clause | elemoine/ol3,gingerik/ol3,itayod/ol3,stweil/ol3,bill-chadwick/ol3,epointal/ol3,adube/ol3,denilsonsa/ol3,fblackburn/ol3,xiaoqqchen/ol3,bogdanvaduva/ol3,landonb/ol3,tsauerwein/ol3,klokantech/ol3,landonb/ol3,bjornharrtell/ol3,llambanna/ol3,gingerik/ol3,gingerik/ol3,Distem/ol3,bjornharrtell/ol3,Distem/ol3,richstoner/ol3,kl... | ---
+++
@@ -14,13 +14,13 @@
requires.update(line for line in lines if line.startswith('goog.require'))
examples[filename] = [line for line in lines if not line.startswith('goog.require')]
for require in sorted(requires):
- print require,
+ sys.stdout.write(require)
for filena... |
ecf0105a48c479f28d2e83a5816ab9b021186562 | REF/search-by-keyword.py | REF/search-by-keyword.py | import sys
import xml.etree.ElementTree as ET
def getkeywords(filename):
with open(filename) as kwfile:
terms = ()
for line in kwfile:
terms += ( '"' + line.rstrip('\n') + '"' ,)
return terms
def simpleSearch(phraseterm, proxies=None):
import requests
svcbase = \
... | Add the published keyword search proggy | Add the published keyword search proggy
| Python | mit | ijjorama/Impact | ---
+++
@@ -0,0 +1,82 @@
+import sys
+import xml.etree.ElementTree as ET
+
+
+
+
+def getkeywords(filename):
+
+ with open(filename) as kwfile:
+ terms = ()
+ for line in kwfile:
+ terms += ( '"' + line.rstrip('\n') + '"' ,)
+
+ return terms
+
+def simpleSearch(phraseterm, proxies=None... | |
149c546cb70f45ee8128966bfe1af8e8a10958b0 | largedatatest/createdata.py | largedatatest/createdata.py | #!/usr/bin/env python
import h5py
import random
X = 500
Y = 500
f = h5py.File('/tmp/test-datafile.hdf5', 'w')
dset = f.create_dataset("default", (X, Y), dtype='float64')
for x in xrange(X):
for y in xrange(Y):
dset[x,y] = random.random()
f.close()
| Add largedatatest for testing a large data set from an hdf5 file | Add largedatatest for testing a large data set from an hdf5 file
| Python | apache-2.0 | matyasselmeci/dask_condor,matyasselmeci/dask_condor | ---
+++
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+import h5py
+import random
+
+
+X = 500
+Y = 500
+
+f = h5py.File('/tmp/test-datafile.hdf5', 'w')
+dset = f.create_dataset("default", (X, Y), dtype='float64')
+for x in xrange(X):
+ for y in xrange(Y):
+ dset[x,y] = random.random()
+f.close() | |
a840dfbcfbefd2827226c4b27aa29cf7854dc36a | autoscaling/delete-old-launch-configuration.py | autoscaling/delete-old-launch-configuration.py | #!/usr/bin/env python
import re
import sys
import boto.ec2.autoscale
from boto.ec2.autoscale import LaunchConfiguration
def main(REGION, pattern):
print('Checking new launch configuration in the "{0}" region.'.format(REGION))
asConnection = boto.ec2.autoscale.connect_to_region(REGION)
lc = asConnection.g... | Add script to delete old launch configuration | Add script to delete old launch configuration
| Python | mit | tendant/aws-script | ---
+++
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+import re
+import sys
+import boto.ec2.autoscale
+from boto.ec2.autoscale import LaunchConfiguration
+
+def main(REGION, pattern):
+ print('Checking new launch configuration in the "{0}" region.'.format(REGION))
+ asConnection = boto.ec2.autoscale.connect_to_re... | |
3ba0b1cde749d92a6966e45e29c1dcf8fee54a0d | scripts/instrumentationRunner.py | scripts/instrumentationRunner.py | """
Submits the apks to BrowserStack to run the instrumentation tests.
"""
import os
import shlex
import subprocess
from subprocess import PIPE
import sys
import json
def appendData(command, dataUrl):
var = 'data={\"url\": \"%s\"}' % dataUrl
return command + " " + json.dumps(var)
def buildTestCommand(appToke... | Add a python script to schedule runs on browserstack | Add a python script to schedule runs on browserstack
| Python | apache-2.0 | dimagi/commcare-android,dimagi/commcare-android,dimagi/commcare-android,dimagi/commcare-android,dimagi/commcare-android,dimagi/commcare-android | ---
+++
@@ -0,0 +1,59 @@
+"""
+Submits the apks to BrowserStack to run the instrumentation tests.
+"""
+
+import os
+import shlex
+import subprocess
+from subprocess import PIPE
+import sys
+import json
+
+def appendData(command, dataUrl):
+ var = 'data={\"url\": \"%s\"}' % dataUrl
+ return command + " " + json... | |
790163173efb34e2b9b0ad0d8927057836f0ad51 | examples/grouped_violinplots.py | examples/grouped_violinplots.py | """
Grouped violinplots with split violins
======================================
"""
import seaborn as sns
sns.set(style="darkgrid", palette="pastel", color_codes=True)
# Load the example tips dataset
tips = sns.load_dataset("tips")
# Draw a nested violinplot and split the violins for easier comparison
sns.violinpl... | Add a split violin example script | Add a split violin example script
| Python | bsd-3-clause | jat255/seaborn,clarkfitzg/seaborn,bsipocz/seaborn,uhjish/seaborn,mwaskom/seaborn,ashhher3/seaborn,sinhrks/seaborn,sauliusl/seaborn,q1ang/seaborn,nileracecrew/seaborn,lypzln/seaborn,phobson/seaborn,mwaskom/seaborn,arokem/seaborn,lukauskas/seaborn,olgabot/seaborn,parantapa/seaborn,muku42/seaborn,anntzer/seaborn,kyleam/se... | ---
+++
@@ -0,0 +1,15 @@
+"""
+Grouped violinplots with split violins
+======================================
+
+"""
+import seaborn as sns
+sns.set(style="darkgrid", palette="pastel", color_codes=True)
+
+# Load the example tips dataset
+tips = sns.load_dataset("tips")
+
+# Draw a nested violinplot and split the vio... | |
fa5d8bbd194a7903d1f6cdc8057a76a4f3752b21 | h5shuffle.py | h5shuffle.py | from __future__ import division
import argparse
import numpy as np
import h5py
def main():
parser = argparse.ArgumentParser()
parser.add_argument('file', type=str)
args = parser.parse_args()
f = h5py.File(args.file, 'r+')
inds = None
for key, dataset in f.iteritems():
if inds is ... | Add script for shuffling the first axis of each entry in a h5 file | Add script for shuffling the first axis of each entry in a h5 file
| Python | mit | alexlee-gk/visual_dynamics | ---
+++
@@ -0,0 +1,24 @@
+from __future__ import division
+
+import argparse
+import numpy as np
+import h5py
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('file', type=str)
+
+ args = parser.parse_args()
+
+ f = h5py.File(args.file, 'r+')
+ inds = None
+ for key, dat... | |
3f4f55f3232546ea407672522f6223a9548b3167 | tests/pycurl_object_test.py | tests/pycurl_object_test.py | #! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# vi:ts=4:et
import pycurl
import unittest
import sys
class PycurlObjectTest(unittest.TestCase):
def setUp(self):
self.curl = pycurl.Curl()
def tearDown(self):
self.curl.close()
def test_set_attribute(self):
assert not h... | Add a test for general object behavior as it seems to be changed by python 3 patch | Add a test for general object behavior as it seems to be changed by python 3 patch
| Python | lgpl-2.1 | pycurl/pycurl,pycurl/pycurl,pycurl/pycurl | ---
+++
@@ -0,0 +1,32 @@
+#! /usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# vi:ts=4:et
+
+import pycurl
+import unittest
+import sys
+
+class PycurlObjectTest(unittest.TestCase):
+ def setUp(self):
+ self.curl = pycurl.Curl()
+
+ def tearDown(self):
+ self.curl.close()
+
+ def tes... | |
4c4bf05e34d46a396c3ac124c5f78bf37d142580 | nodeconductor/structure/migrations/0037_remove_customer_billing_backend_id.py | nodeconductor/structure/migrations/0037_remove_customer_billing_backend_id.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('structure', '0036_add_vat_fields'),
]
operations = [
migrations.RemoveField(
model_name='customer',
... | Remove customer billing backend id | Remove customer billing backend id
- nc-1554
| Python | mit | opennode/nodeconductor,opennode/nodeconductor,opennode/nodeconductor | ---
+++
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('structure', '0036_add_vat_fields'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ ... | |
dbf71a7f4973d22259e81e095402d39acb823651 | pymatgen/symmetry/tests/test_spacegroup.py | pymatgen/symmetry/tests/test_spacegroup.py | #!/usr/bin/env python
'''
Created on Mar 12, 2012
'''
from __future__ import division
__author__="Shyue Ping Ong"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyue@mit.edu"
__date__ = "Mar 12, 2012"
import unittest
import os
from pymatg... | Add a unittest for spacegroup. Still very basic. | Add a unittest for spacegroup. Still very basic.
| Python | mit | rousseab/pymatgen,ctoher/pymatgen,yanikou19/pymatgen,ctoher/pymatgen,sonium0/pymatgen,yanikou19/pymatgen,Bismarrck/pymatgen,migueldiascosta/pymatgen,ctoher/pymatgen,Bismarrck/pymatgen,Dioptas/pymatgen,sonium0/pymatgen,migueldiascosta/pymatgen,Bismarrck/pymatgen,Bismarrck/pymatgen,sonium0/pymatgen,rousseab/pymatgen,yani... | ---
+++
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+'''
+Created on Mar 12, 2012
+'''
+
+from __future__ import division
+
+__author__="Shyue Ping Ong"
+__copyright__ = "Copyright 2012, The Materials Project"
+__version__ = "0.1"
+__maintainer__ = "Shyue Ping Ong"
+__email__ = "shyue@mit.edu"
+__date__ = "Mar 12, 2012... | |
1098f43d5fb02328ce4708bd5a8c1b5f8ac23f51 | py/optimal-division.py | py/optimal-division.py | class Solution(object):
def optimalDivision(self, nums):
"""
:type nums: List[int]
:rtype: str
"""
min_result, max_result = dict(), dict()
lnums = len(nums)
def find_cut(start, end, need_max):
if start + 1 == end:
return 0, (nums[s... | Add py solution for 553. Optimal Division | Add py solution for 553. Optimal Division
553. Optimal Division: https://leetcode.com/problems/optimal-division/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,50 @@
+class Solution(object):
+ def optimalDivision(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: str
+ """
+ min_result, max_result = dict(), dict()
+ lnums = len(nums)
+
+ def find_cut(start, end, need_max):
+ if start + 1 == ... | |
0ebd6e8e5e8c09f15e6170de03965de150edca22 | crawler/crawler.py | crawler/crawler.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import re
import requests
from lxml import html
class Songlist(object):
def __init__(self, url):
self.url = url
response = requests.get(url)
self.tree = html.fromstring(response.text)
def _get_num... | Add a class for getting meta info from a songlist | Add a class for getting meta info from a songlist
| Python | mit | lord63/wangyi_music_top100,lord63/wangyi_music_top100,lord63/wangyi_music_top100 | ---
+++
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+from __future__ import absolute_import
+
+import re
+
+import requests
+from lxml import html
+
+
+class Songlist(object):
+ def __init__(self, url):
+ self.url = url
+ response = requests.get(url)
+ self.tree = html... | |
c00a32f913d7e22e7405b4560f8c618ea20071b8 | python/cluster-test.py | python/cluster-test.py | #!/usr/bin/env python
# Copyright (C) 2010 Red Hat, Inc.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This so... | Add a simple python clusters test | Add a simple python clusters test
| Python | lgpl-2.1 | colloquium/rhevm-api,markmc/rhevm-api,colloquium/rhevm-api,markmc/rhevm-api,markmc/rhevm-api | ---
+++
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2010 Red Hat, Inc.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your opt... | |
669a2edf8fd92b8473a8e4fe45ff2afb41babfbb | algorithms/ids.py | algorithms/ids.py | """
pynpuzzle - Solve n-puzzle with Python
Iterative deepening depth-first search algorithm
Version : 1.0.0
Author : Hamidreza Mahdavipanah
Repository: http://github.com/mahdavipanah/pynpuzzle
License : MIT License
"""
from .util.tree_search import Node
def search(state, goal_state):
"""Iterative deepening dept... | Add Iterative deepening depth-first algorithm | Add Iterative deepening depth-first algorithm
| Python | mit | mahdavipanah/pynpuzzle | ---
+++
@@ -0,0 +1,40 @@
+"""
+pynpuzzle - Solve n-puzzle with Python
+
+Iterative deepening depth-first search algorithm
+
+Version : 1.0.0
+Author : Hamidreza Mahdavipanah
+Repository: http://github.com/mahdavipanah/pynpuzzle
+License : MIT License
+"""
+from .util.tree_search import Node
+
+
+def search(state, goa... | |
4f36b66690425998ecf803c459ca652e75ae9fca | src/examples/python/extractor_metadata.py | src/examples/python/extractor_metadata.py | import sys
import os, fnmatch
from essentia.standard import MetadataReader, YamlOutput
from essentia import Pool
FILE_EXT = ('.mp3', '.flac', '.ogg')
def find_files(directory, pattern):
for root, dirs, files in os.walk(directory):
for basename in files:
if basename.lower().endswith(pattern):
... | Add script for metadata extraction given a folder | Add script for metadata extraction given a folder
- Extracts audio file metadata using MetadataReader for all audio
files in a given folder
| Python | agpl-3.0 | carthach/essentia,carthach/essentia,arseneyr/essentia,MTG/essentia,carthach/essentia,carthach/essentia,MTG/essentia,carthach/essentia,arseneyr/essentia,arseneyr/essentia,MTG/essentia,MTG/essentia,MTG/essentia,arseneyr/essentia,arseneyr/essentia | ---
+++
@@ -0,0 +1,43 @@
+import sys
+import os, fnmatch
+from essentia.standard import MetadataReader, YamlOutput
+from essentia import Pool
+
+FILE_EXT = ('.mp3', '.flac', '.ogg')
+
+def find_files(directory, pattern):
+ for root, dirs, files in os.walk(directory):
+ for basename in files:
+ if... | |
a71ce9fb543c7108f8c606bc46674cfad0ff8cc7 | migrations/versions/0218_another_letter_org.py | migrations/versions/0218_another_letter_org.py | """empty message
Revision ID: 0218_another_letter_org
Revises: 0217_default_email_branding
"""
# revision identifiers, used by Alembic.
revision = '0218_another_letter_org'
down_revision = '0217_default_email_branding'
from alembic import op
NEW_ORGANISATIONS = [
('511', 'NHS'),
]
def upgrade():
for num... | Add NHS logo for letters | Add NHS logo for letters
Matches: https://github.com/alphagov/notifications-template-preview/pull/192
| Python | mit | alphagov/notifications-api,alphagov/notifications-api | ---
+++
@@ -0,0 +1,35 @@
+"""empty message
+
+Revision ID: 0218_another_letter_org
+Revises: 0217_default_email_branding
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '0218_another_letter_org'
+down_revision = '0217_default_email_branding'
+
+from alembic import op
+
+
+NEW_ORGANISATIONS = [
+ ('5... | |
6aa2e5d3b8519ae3b8e21431e4eaf34dd9d34f9f | tests/test_wysiwyg_editor.py | tests/test_wysiwyg_editor.py | from . import TheInternetTestCase
from helium.api import click, Text, press, CONTROL, COMMAND, write
from sys import platform
class WYSIWYGEditorTest(TheInternetTestCase):
def get_page(self):
return "http://the-internet.herokuapp.com/tinymce"
def test_use_wysiwyg_editor(self):
self.assertTrue(Text("Your content ... | Add test case for tinyMCE (WYSIWYG editor). | Add test case for tinyMCE (WYSIWYG editor).
| Python | mit | bugfree-software/the-internet-solution-python | ---
+++
@@ -0,0 +1,16 @@
+from . import TheInternetTestCase
+from helium.api import click, Text, press, CONTROL, COMMAND, write
+from sys import platform
+
+class WYSIWYGEditorTest(TheInternetTestCase):
+ def get_page(self):
+ return "http://the-internet.herokuapp.com/tinymce"
+ def test_use_wysiwyg_editor(self):
+ ... | |
b8a410bc2f54a89e0e44100a890183fcd6a88e3e | tools/convert-url-history.py | tools/convert-url-history.py | #!/usr/bin/env python
# Copyright 2009 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required... | Add initial URL history importer | Add initial URL history importer
| Python | apache-2.0 | jimmsta/namebench-1,catap/namebench | ---
+++
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# Copyright 2009 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licen... | |
2759119ea8a2afe6c47575825aef9ae59c1ce921 | python/misc/oo/CSStudent.py | python/misc/oo/CSStudent.py | # Code from https://www.geeksforgeeks.org/g-fact-34-class-or-static-variables-in-python/
# Copy - Paste here to test it directly
# Python program to show that the variables with a value
# assigned in class declaration, are class variables
# Class for Computer Science Student
class CSStudent:
stream = 'cse' ... | Test d'un bout de code de GeeksForGeeks | Test d'un bout de code de GeeksForGeeks
| Python | mit | TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-workouts,TGITS/programming-worko... | ---
+++
@@ -0,0 +1,38 @@
+# Code from https://www.geeksforgeeks.org/g-fact-34-class-or-static-variables-in-python/
+# Copy - Paste here to test it directly
+# Python program to show that the variables with a value
+# assigned in class declaration, are class variables
+
+# Class for Computer Science Student
+class CSS... | |
49c73b00b5528706fbb340e53b37e59c8303d70d | oneflow/settings/snippets/common_production.py | oneflow/settings/snippets/common_production.py | #
# Put production machines hostnames here.
#
# MANAGERS += (('Matthieu Chaignot', 'mc@1flow.io'), )
ALLOWED_HOSTS += [
'1flow.io',
'app.1flow.io',
'api.1flow.io',
]
| #
# Put production machines hostnames here.
#
MANAGERS += (('Matthieu Chaignot', 'mchaignot@gmail.com'), )
ALLOWED_HOSTS += [
'1flow.io',
'app.1flow.io',
'api.1flow.io',
]
| Add Matthieu to MANAGERS, for him to receive the warn-closed-feed mail. | Add Matthieu to MANAGERS, for him to receive the warn-closed-feed mail.
| Python | agpl-3.0 | 1flow/1flow,1flow/1flow,1flow/1flow,WillianPaiva/1flow,1flow/1flow,WillianPaiva/1flow,WillianPaiva/1flow,1flow/1flow,WillianPaiva/1flow,WillianPaiva/1flow | ---
+++
@@ -2,7 +2,7 @@
# Put production machines hostnames here.
#
-# MANAGERS += (('Matthieu Chaignot', 'mc@1flow.io'), )
+MANAGERS += (('Matthieu Chaignot', 'mchaignot@gmail.com'), )
ALLOWED_HOSTS += [
'1flow.io', |
f25275dd2a65c9b962df3b522981d595c2d3809f | opendebates/migrations/0017_enable_unaccent.py | opendebates/migrations/0017_enable_unaccent.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.core.management import call_command
from django.db import migrations, models
def update_search_index(apps, schema):
print("Updating search field...")
call_command("update_search_field", "opendebates")
print("Updating search field... | Add a migration for unaccent | Add a migration for unaccent
This is on top of https://github.com/caktus/django-opendebates/pull/88
| Python | apache-2.0 | ejucovy/django-opendebates,ejucovy/django-opendebates,ejucovy/django-opendebates,caktus/django-opendebates,ejucovy/django-opendebates,caktus/django-opendebates,caktus/django-opendebates,caktus/django-opendebates | ---
+++
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.core.management import call_command
+from django.db import migrations, models
+
+
+def update_search_index(apps, schema):
+ print("Updating search field...")
+ call_command("update_search_field", "opendebat... | |
3e50e0cd6c55730bd2d2ed1c22b71ce67723a0d5 | corehq/apps/data_interfaces/migrations/0018_check_for_rule_migration.py | corehq/apps/data_interfaces/migrations/0018_check_for_rule_migration.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import absolute_import
from django.db import migrations
from corehq.sql_db.operations import HqRunPython
def noop(*args, **kwargs):
pass
def assert_rule_migration_complete(apps, schema_editor):
AutomaticUpdateRule = apps.get_mod... | Add blocking migration to ensure all rules have been migrated | Add blocking migration to ensure all rules have been migrated
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+from __future__ import absolute_import
+from django.db import migrations
+from corehq.sql_db.operations import HqRunPython
+
+
+def noop(*args, **kwargs):
+ pass
+
+
+def assert_rule_migration_complete(apps, schema_editor):... | |
2f25825812e38318076984a83a1d602d3d33bc9d | bin/tag_using_alchemy.py | bin/tag_using_alchemy.py | import copy
import requests
from urllib import quote_plus
from optparse import OptionParser
from pocketpy.auth import auth
from pocketpy.pocket import retrieve
KEYWORD_URL = "http://access.alchemyapi.com/calls/url/URLGetRankedKeywords"
def get_keywords_from_alchemy(access_token, item_url):
params = {"url": ite... | Tag using alchemy api. As request by costaclayton | Tag using alchemy api. As request by costaclayton
| Python | mit | Newky/PocketPy | ---
+++
@@ -0,0 +1,50 @@
+import copy
+import requests
+
+from urllib import quote_plus
+from optparse import OptionParser
+
+from pocketpy.auth import auth
+from pocketpy.pocket import retrieve
+
+KEYWORD_URL = "http://access.alchemyapi.com/calls/url/URLGetRankedKeywords"
+
+
+def get_keywords_from_alchemy(access_to... | |
609b27736728ce17f7f05594a2a44ed1cb0a9fd2 | scripts/util/dl_daily_shapefiles.py | scripts/util/dl_daily_shapefiles.py | #!/usr/bin/env python
"""Example script to download daily shapefiles from the dailyerosion site"""
import datetime
import urllib2
start_time = datetime.date(2007, 1, 1)
end_time = datetime.date(2015, 9, 8)
interval = datetime.timedelta(days=1)
now = start_time
while now < end_time:
print("Downloading shapefile f... | Add example script that downloads DEP daily shapefiles | Add example script that downloads DEP daily shapefiles | Python | mit | akrherz/idep,akrherz/dep,akrherz/dep,akrherz/idep,akrherz/dep,akrherz/idep,akrherz/dep,akrherz/idep,akrherz/idep,akrherz/dep,akrherz/idep | ---
+++
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+"""Example script to download daily shapefiles from the dailyerosion site"""
+import datetime
+import urllib2
+
+
+start_time = datetime.date(2007, 1, 1)
+end_time = datetime.date(2015, 9, 8)
+interval = datetime.timedelta(days=1)
+
+now = start_time
+while now < end_t... | |
a5487a417d53645bb33bf4f4b466965679813890 | sensu/plugins/check-static-route.py | sensu/plugins/check-static-route.py | #!/usr/bin/env python
#
# Checks static route for specific subnet
#
# Return CRITICAL if no route found
#
# Jose L Coello Enriquez <jlcoello@us.ibm.com>
import subprocess
import argparse
import sys
STATE_OK = 0
STATE_WARNING = 1
STATE_CRITICAL = 2
CRITICALITY = 'critical'
def switch_on_criticality():
if CRITICAL... | Check for checking a static route is present for multi subnets | Check for checking a static route is present for multi subnets
| Python | apache-2.0 | blueboxgroup/ursula-monitoring,aacole/ursula-monitoring,aacole/ursula-monitoring,blueboxgroup/ursula-monitoring,aacole/ursula-monitoring,aacole/ursula-monitoring,blueboxgroup/ursula-monitoring,sivakom/ursula-monitoring,sivakom/ursula-monitoring,sivakom/ursula-monitoring,blueboxgroup/ursula-monitoring,sivakom/ursula-mon... | ---
+++
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+#
+# Checks static route for specific subnet
+#
+# Return CRITICAL if no route found
+#
+# Jose L Coello Enriquez <jlcoello@us.ibm.com>
+
+import subprocess
+import argparse
+import sys
+
+STATE_OK = 0
+STATE_WARNING = 1
+STATE_CRITICAL = 2
+CRITICALITY = 'critical'
+
... | |
e1138ebffbdfe31d4a4acdb4e164bdd767c6e8ea | saylua/wrappers.py | saylua/wrappers.py | from flask import redirect as _redirect, url_for, render_template, g
from functools import wraps
def login_required(f, redirect='login'):
"""Redirects non-logged in users to a specified location.
Usage: `@login_required`, `@login_required(redirect=<url>)`
"""
@wraps(f)
def decorated_function(*args, **kwar... | from flask import redirect as _redirect, url_for, render_template, g
from functools import wraps
def login_required(f, redirect='login'):
"""Redirects non-logged in users to a specified location.
Usage: `@login_required`, `@login_required(redirect=<url>)`
"""
@wraps(f)
def decorated_function(*args, **kwar... | Fix for no role in admin access wrapper | Fix for no role in admin access wrapper
| Python | agpl-3.0 | LikeMyBread/Saylua,saylua/SayluaV2,LikeMyBread/Saylua,saylua/SayluaV2,saylua/SayluaV2,LikeMyBread/Saylua,LikeMyBread/Saylua | ---
+++
@@ -24,7 +24,7 @@
if not g.logged_in:
return _redirect(url_for('login'))
- if not g.user.get_role().can_access_admin:
+ if not g.user.get_role() or not g.user.get_role().can_access_admin:
return render_template('403.html'), 403
return f(*args, **kwargs) |
ca11355cb4ece27ffb9fee8e9df304b43dd6b6b8 | server/proposal/migrations/0034_fix_updated.py | server/proposal/migrations/0034_fix_updated.py | import django.contrib.gis.db.models.fields
from django.db import migrations
from django.contrib.gis.db.models import Max
def fix_updated(apps, _):
Proposal = apps.get_model("proposal", "Proposal")
proposals = Proposal.objects.annotate(published=Max("documents__published"))
for proposal in proposals:
... | Set proposal updated date to the mod date of most recent Document | Set proposal updated date to the mod date of most recent Document
| Python | mit | cityofsomerville/cornerwise,cityofsomerville/citydash,cityofsomerville/cornerwise,codeforboston/cornerwise,cityofsomerville/citydash,cityofsomerville/citydash,cityofsomerville/cornerwise,cityofsomerville/citydash,cityofsomerville/cornerwise,codeforboston/cornerwise,codeforboston/cornerwise,codeforboston/cornerwise | ---
+++
@@ -0,0 +1,22 @@
+import django.contrib.gis.db.models.fields
+from django.db import migrations
+from django.contrib.gis.db.models import Max
+
+
+def fix_updated(apps, _):
+ Proposal = apps.get_model("proposal", "Proposal")
+ proposals = Proposal.objects.annotate(published=Max("documents__published"))
+... | |
5ca5736ec9c3357f7b68ed44b3154970561a8c3d | tests/test_specify_output_dir.py | tests/test_specify_output_dir.py | # -*- coding: utf-8 -*-
import pytest
from cookiecutter import main
@pytest.fixture
def context():
"""Fixture to return a valid context as known from a cookiecutter.json."""
return {
u'cookiecutter': {
u'email': u'raphael@hackebrot.de',
u'full_name': u'Raphael Pierzina',
... | Implement a test to make sure output_dir is passed along to generate_files | Implement a test to make sure output_dir is passed along to
generate_files
| Python | bsd-3-clause | willingc/cookiecutter,pjbull/cookiecutter,luzfcb/cookiecutter,pjbull/cookiecutter,terryjbates/cookiecutter,stevepiercy/cookiecutter,dajose/cookiecutter,michaeljoseph/cookiecutter,cguardia/cookiecutter,hackebrot/cookiecutter,dajose/cookiecutter,willingc/cookiecutter,audreyr/cookiecutter,michaeljoseph/cookiecutter,cguard... | ---
+++
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+
+import pytest
+
+from cookiecutter import main
+
+
+@pytest.fixture
+def context():
+ """Fixture to return a valid context as known from a cookiecutter.json."""
+ return {
+ u'cookiecutter': {
+ u'email': u'raphael@hackebrot.de',
+ ... | |
e49331122001bf142e7478037d9ad8e932103657 | migrations/versions/306f880b11c3_.py | migrations/versions/306f880b11c3_.py | """empty message
Revision ID: 306f880b11c3
Revises: 255f81eff867
Create Date: 2018-08-03 15:07:44.354557
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '306f880b11c3'
down_revision = '255f81eff867'
branch_labels = None
depends_on = None
def upgrade():
op.... | Update cluster database to make local spark work | Update cluster database to make local spark work
| Python | apache-2.0 | eubr-bigsea/stand,eubr-bigsea/stand | ---
+++
@@ -0,0 +1,34 @@
+"""empty message
+
+Revision ID: 306f880b11c3
+Revises: 255f81eff867
+Create Date: 2018-08-03 15:07:44.354557
+
+"""
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = '306f880b11c3'
+down_revision = '255f81eff867'
+branch_labels = None
+... | |
04a93e33afd41405fcc660e9cfd7de191def4657 | backend/breach/tests/test_error_handling.py | backend/breach/tests/test_error_handling.py | from mock import patch
from django.utils import timezone
from django.test import TestCase
from breach.strategy import Strategy
from breach.models import Target, Victim, SampleSet
class ErrorHandlingTestCase(TestCase):
def setUp(self):
self.target = Target.objects.create(
endpoint='https://di.u... | Add strategy error handling tests | Add strategy error handling tests
| Python | mit | dimriou/rupture,dimkarakostas/rupture,dimriou/rupture,dimkarakostas/rupture,dimkarakostas/rupture,dimkarakostas/rupture,dimriou/rupture,dimriou/rupture,dimkarakostas/rupture,dimriou/rupture | ---
+++
@@ -0,0 +1,78 @@
+from mock import patch
+from django.utils import timezone
+from django.test import TestCase
+from breach.strategy import Strategy
+from breach.models import Target, Victim, SampleSet
+
+
+class ErrorHandlingTestCase(TestCase):
+ def setUp(self):
+ self.target = Target.objects.creat... | |
4e48b4587d8af6cce0cc083db10287c8a9f933e3 | libcloud/test/loadbalancer/test_ninefold.py | libcloud/test/loadbalancer/test_ninefold.py | import sys
import unittest
from libcloud.loadbalancer.types import Provider
from libcloud.loadbalancer.providers import get_driver
class NinefoldLbTestCase(unittest.TestCase):
def test_driver_instantiation(self):
cls = get_driver(Provider.NINEFOLD)
cls('username', 'key')
if __name__ == '__main_... | Add a test case for ninefold loadbalancer driver. | Add a test case for ninefold loadbalancer driver.
| Python | apache-2.0 | mtekel/libcloud,Kami/libcloud,briancurtin/libcloud,mistio/libcloud,briancurtin/libcloud,Jc2k/libcloud,t-tran/libcloud,t-tran/libcloud,vongazman/libcloud,mgogoulos/libcloud,jimbobhickville/libcloud,cryptickp/libcloud,carletes/libcloud,wrigri/libcloud,sahildua2305/libcloud,munkiat/libcloud,thesquelched/libcloud,mtekel/li... | ---
+++
@@ -0,0 +1,15 @@
+import sys
+import unittest
+
+from libcloud.loadbalancer.types import Provider
+from libcloud.loadbalancer.providers import get_driver
+
+
+class NinefoldLbTestCase(unittest.TestCase):
+ def test_driver_instantiation(self):
+ cls = get_driver(Provider.NINEFOLD)
+ cls('usern... | |
bb578d4237ccaf16fe5c38842cc100cdbefc0119 | senlin/tests/functional/drivers/openstack/__init__.py | senlin/tests/functional/drivers/openstack/__init__.py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed unde... | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed unde... | Add keystone driver plugin for functional test | Add keystone driver plugin for functional test
This patch adds keystone driver plugin for functional test.
Change-Id: Iefa9c1b8956854ae75f672627aa3d2f9f7d22c0e
| Python | apache-2.0 | openstack/senlin,stackforge/senlin,tengqm/senlin-container,stackforge/senlin,openstack/senlin,tengqm/senlin-container,Alzon/senlin,Alzon/senlin,openstack/senlin | ---
+++
@@ -12,27 +12,16 @@
from senlin.drivers.openstack import ceilometer_v2
from senlin.drivers.openstack import heat_v1
+from senlin.drivers.openstack import keystone_v3
from senlin.drivers.openstack import lbaas
from senlin.drivers.openstack import neutron_v2
from senlin.tests.functional.drivers.openstack... |
b483840cd7ec275090d41ee9a3b59b6300ea879e | glitch/renderer.py | glitch/renderer.py | from aiohttp import web
import asyncio
app = web.Application()
async def moosic(req):
print("req", type(req))
resp = web.StreamResponse()
resp.content_type = "text/plain" # "audio/mpeg"
await resp.prepare(req)
resp.write(b"Hello, world!")
for i in range(5):
print(i,"...")
await asyncio.sleep(i)
resp.write... | Create POC streaming server using asyncio | Create POC streaming server using asyncio
| Python | artistic-2.0 | Rosuav/appension,MikeiLL/appension,Rosuav/appension,Rosuav/appension,MikeiLL/appension,MikeiLL/appension,Rosuav/appension,MikeiLL/appension | ---
+++
@@ -0,0 +1,25 @@
+from aiohttp import web
+import asyncio
+
+app = web.Application()
+
+async def moosic(req):
+ print("req", type(req))
+ resp = web.StreamResponse()
+ resp.content_type = "text/plain" # "audio/mpeg"
+ await resp.prepare(req)
+ resp.write(b"Hello, world!")
+ for i in range(5):
+ print(i,"...... | |
0485a265c5076402acc482db6789fb46bc313451 | proc_images.py | proc_images.py | import numpy as np
import cv
from pytesser import *
from common import *
def proc_ex (ex):
try:
text = (image_file_to_string(img_filename(ex[0])),)
except IOError:
print "Exception thrown"
text = ("",)
return text + tuple(ex)
def write_txt (fname, txt):
with open(fname, 'wb')... | Add code to lift text out of images | Add code to lift text out of images
| Python | mit | hausdorff/i-like-you,hausdorff/i-like-you | ---
+++
@@ -0,0 +1,60 @@
+import numpy as np
+import cv
+from pytesser import *
+from common import *
+
+
+def proc_ex (ex):
+ try:
+ text = (image_file_to_string(img_filename(ex[0])),)
+ except IOError:
+ print "Exception thrown"
+ text = ("",)
+
+ return text + tuple(ex)
+
+def write_t... | |
c27f7651a933fa831f936ca90fd25ede3f79aa50 | pythran/analyses/ast_matcher.py | pythran/analyses/ast_matcher.py | """ Module to looks for a specified pattern in a given AST. """
from ast import AST, iter_fields
import ast
class AST_no_cond(object):
""" Class to specify we don't care about a field value in ast. """
def match(node, pattern):
"""
Check matching between an ast.Node and a pattern.
AST_no_cond per... | Add ast matcher for pattern recognition | Add ast matcher for pattern recognition
| Python | bsd-3-clause | artas360/pythran,pbrunet/pythran,pbrunet/pythran,hainm/pythran,artas360/pythran,artas360/pythran,hainm/pythran,pombredanne/pythran,pombredanne/pythran,serge-sans-paille/pythran,pombredanne/pythran,hainm/pythran,serge-sans-paille/pythran,pbrunet/pythran | ---
+++
@@ -0,0 +1,90 @@
+""" Module to looks for a specified pattern in a given AST. """
+
+from ast import AST, iter_fields
+import ast
+
+
+class AST_no_cond(object):
+
+ """ Class to specify we don't care about a field value in ast. """
+
+
+def match(node, pattern):
+ """
+ Check matching between an ast... | |
bb8774152e63ce8a09dbb75d43579ba145bbe08f | tests/cli/test_task.py | tests/cli/test_task.py | """
Copyright (c) 2021 Red Hat, Inc
All rights reserved.
This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
"""
import flexmock
from atomic_reactor.cli import task
from atomic_reactor.tasks import orchestrator, worker, sources, common
TASK_ARGS = {
... | Add unit tests for cli.task | Add unit tests for cli.task
CLOUDBLD-6300
Signed-off-by: Adam Cmiel <1217f9865bd733d1bcad0d0d64be310272c5592c@redhat.com>
| Python | bsd-3-clause | fr34k8/atomic-reactor,projectatomic/atomic-reactor,projectatomic/atomic-reactor,fr34k8/atomic-reactor | ---
+++
@@ -0,0 +1,49 @@
+"""
+Copyright (c) 2021 Red Hat, Inc
+All rights reserved.
+
+This software may be modified and distributed under the terms
+of the BSD license. See the LICENSE file for details.
+"""
+
+import flexmock
+
+from atomic_reactor.cli import task
+from atomic_reactor.tasks import orchestrator, wo... | |
45eb018082d035f36d6b5d207f6f44e77a65a895 | wk1/MeanOfASetOfFITSFiles.py | wk1/MeanOfASetOfFITSFiles.py | # Write your mean_fits function here:
from astropy.io import fits
import numpy as np
def mean_fits(fitsfiles):
count = 0
for fitsfile in fitsfiles:
hdulist = fits.open(fitsfile)
newdata = hdulist[0].data
if count == 0:
data = newdata
else:
data = data + newdata #adds matrixes
... | Read a set of FITS files and calculate the mean (average). Based on code from two previous exercizes. | Read a set of FITS files and calculate the mean (average). Based on code from two previous exercizes.
| Python | mit | lokijota/datadrivenastronomymooc | ---
+++
@@ -0,0 +1,31 @@
+# Write your mean_fits function here:
+from astropy.io import fits
+import numpy as np
+
+def mean_fits(fitsfiles):
+ count = 0
+
+ for fitsfile in fitsfiles:
+ hdulist = fits.open(fitsfile)
+ newdata = hdulist[0].data
+
+ if count == 0:
+ data = newdata
+ else:
+ ... | |
cac3636a2e49e088c2a43b2f21a7aa31af66d215 | src/tpn/data_io.py | src/tpn/data_io.py | #!/usr/bin/env python
import zipfile
import cPickle
import numpy as np
"""
track_obj: {
frames: 1 by n numpy array,
anchors: 1 by n numpy array,
features: m by n numpy array,
scores: c by n numpy array,
boxes: 4 by n numpy array,
rois: 4 by n numpy array
}
"""
d... | Add function to save track proto to zip files for efficient storage and usage. | Add function to save track proto to zip files for efficient storage and usage.
| Python | mit | myfavouritekk/TPN | ---
+++
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import zipfile
+import cPickle
+import numpy as np
+
+"""
+ track_obj: {
+ frames: 1 by n numpy array,
+ anchors: 1 by n numpy array,
+ features: m by n numpy array,
+ scores: c by n numpy array,
+ boxes: 4 by n numpy array,
+ ... | |
2c175426c93f446cad6846bee141cbd9b29c5593 | src/xml2csv.py | src/xml2csv.py | from bs4 import BeautifulSoup
import csv
import sys
XML_FILE_PATH = sys.argv[1]
CSV_FILE_PATH = sys.argv[2]
xml_file = open(XML_FILE_PATH, 'rb').read()
xml_soup = BeautifulSoup(xml_file, 'lxml-xml')
variables_file = open('data/datasets_format.html', 'rb').read()
variables_soup = BeautifulSoup(variables_file, 'lxml')... | Add script for converting XML datasets to CSV | Add script for converting XML datasets to CSV
| Python | mit | wisner23/serenata-de-amor,marcusrehm/serenata-de-amor,wisner23/serenata-de-amor,datasciencebr/serenata-de-amor,datasciencebr/serenata-de-amor,marcusrehm/serenata-de-amor,marcusrehm/serenata-de-amor,marcusrehm/serenata-de-amor | ---
+++
@@ -0,0 +1,24 @@
+from bs4 import BeautifulSoup
+import csv
+import sys
+
+XML_FILE_PATH = sys.argv[1]
+CSV_FILE_PATH = sys.argv[2]
+
+xml_file = open(XML_FILE_PATH, 'rb').read()
+xml_soup = BeautifulSoup(xml_file, 'lxml-xml')
+
+variables_file = open('data/datasets_format.html', 'rb').read()
+variables_soup ... | |
50c21151b54759d297fdbef222aaa45c17f70027 | horizon/conf/__init__.py | horizon/conf/__init__.py | import copy
from django.utils.functional import LazyObject, empty
from .default import HORIZON_CONFIG as DEFAULT_CONFIG
class LazySettings(LazyObject):
def _setup(self, name=None):
from django.conf import settings
HORIZON_CONFIG = copy.copy(DEFAULT_CONFIG)
HORIZON_CONFIG.update(settings.... | import copy
from django.utils.functional import LazyObject, empty
class LazySettings(LazyObject):
def _setup(self, name=None):
from django.conf import settings
from .default import HORIZON_CONFIG as DEFAULT_CONFIG
HORIZON_CONFIG = copy.copy(DEFAULT_CONFIG)
HORIZON_CONFIG.update(se... | Fix circular dependencies in dashboard settings | Fix circular dependencies in dashboard settings
Importing horizon.utils from dashboard local_settings.py to generate
SECRET_KEY results in a sequence of imports, and horizon.conf.default
module gets imported at some point. During initialization of default
HORIZON_CONFIG this module uses settings.LOGIN_REDIRECT_URL and... | Python | apache-2.0 | dan1/horizon-x509,rickerc/horizon_audit,Tesora/tesora-horizon,tuskar/tuskar-ui,maestro-hybrid-cloud/horizon,orbitfp7/horizon,VaneCloud/horizon,CiscoSystems/horizon,nvoron23/avos,openstack-ja/horizon,tqtran7/horizon,JioCloud/horizon,promptworks/horizon,Mirantis/mos-horizon,FNST-OpenStack/horizon,Tesora/tesora-horizon,Fr... | ---
+++
@@ -1,13 +1,12 @@
import copy
from django.utils.functional import LazyObject, empty
-
-from .default import HORIZON_CONFIG as DEFAULT_CONFIG
class LazySettings(LazyObject):
def _setup(self, name=None):
from django.conf import settings
+ from .default import HORIZON_CONFIG as DEFA... |
ca6de0795babfd911c49a0f66ca27cd063faf1f1 | tests/test_tool.py | tests/test_tool.py | import pytest
import sys
import binascii
import base64
from unittest import mock
from io import StringIO, BytesIO, TextIOWrapper
import cbor2.tool
def test_stdin(monkeypatch, tmpdir):
f = tmpdir.join('outfile')
argv = ['-o', str(f)]
inbuf = TextIOWrapper(BytesIO(binascii.unhexlify('02')))
with monkey... | Write a test for the command line tool | Write a test for the command line tool
| Python | mit | agronholm/cbor2,agronholm/cbor2,agronholm/cbor2 | ---
+++
@@ -0,0 +1,31 @@
+import pytest
+import sys
+import binascii
+import base64
+from unittest import mock
+from io import StringIO, BytesIO, TextIOWrapper
+
+import cbor2.tool
+
+
+def test_stdin(monkeypatch, tmpdir):
+ f = tmpdir.join('outfile')
+ argv = ['-o', str(f)]
+ inbuf = TextIOWrapper(BytesIO(b... | |
a6db84b191f5df54bab66615d48d9d0ade903229 | website/addons/dropbox/tests/webtest_tests.py | website/addons/dropbox/tests/webtest_tests.py | # -*- coding: utf-8 -*-
import unittest
from nose.tools import * # PEP8 asserts
from webtest_plus import TestApp
from website.app import init_app
from website.util import web_url_for, api_url_for
from website.project.model import ensure_schemas
from tests.base import DbTestCase
from tests.factories import AuthUserFac... | Add failing webtest for user settings page | Add failing webtest for user settings page
| Python | apache-2.0 | amyshi188/osf.io,asanfilippo7/osf.io,samchrisinger/osf.io,jnayak1/osf.io,brandonPurvis/osf.io,mluo613/osf.io,felliott/osf.io,kch8qx/osf.io,mfraezz/osf.io,caseyrollins/osf.io,dplorimer/osf,jnayak1/osf.io,asanfilippo7/osf.io,dplorimer/osf,binoculars/osf.io,Nesiehr/osf.io,TomBaxter/osf.io,doublebits/osf.io,billyhunt/osf.i... | ---
+++
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+import unittest
+
+from nose.tools import * # PEP8 asserts
+from webtest_plus import TestApp
+from website.app import init_app
+from website.util import web_url_for, api_url_for
+from website.project.model import ensure_schemas
+from tests.base import DbTestCase
+fr... | |
81cba73a64e72fc10170cd8a5082a109037ad27e | examples/service/test_hello_service.py | examples/service/test_hello_service.py | from pyon.util.int_test import IonIntegrationTestCase
from interface.services.examples.hello.ihello_service import HelloServiceClient
class TestHelloService(IonIntegrationTestCase):
def setUp(self):
self._start_container()
self.container.start_rel_from_url('res/deploy/examples/hello.yml')
s... | Add simple examples test for HelloService RPC | Add simple examples test for HelloService RPC
| Python | bsd-2-clause | mkl-/scioncc,scionrep/scioncc,scionrep/scioncc,ooici/pyon,crchemist/scioncc,crchemist/scioncc,mkl-/scioncc,crchemist/scioncc,scionrep/scioncc,mkl-/scioncc,ooici/pyon | ---
+++
@@ -0,0 +1,16 @@
+from pyon.util.int_test import IonIntegrationTestCase
+from interface.services.examples.hello.ihello_service import HelloServiceClient
+
+class TestHelloService(IonIntegrationTestCase):
+ def setUp(self):
+ self._start_container()
+ self.container.start_rel_from_url('res/dep... | |
d99dd117c41e850781056371043ef7de546f0c18 | test_vpoker.py | test_vpoker.py | # Copyright (c) 2016 Kirill 'Kolyat' Kiselnikov
# This file is the part of vpoker, released under modified MIT license
# See the file LICENSE.txt included in this distribution
"""
Unit tests for main module
"""
import unittest
from vpoker import CARD_BACKGROUND_HEIGHT
from vpoker import SCREEN_WIDTH
from vpoker im... | Add file with tests for main module | Add file with tests for main module
| Python | mit | kolyat/vpoker | ---
+++
@@ -0,0 +1,70 @@
+# Copyright (c) 2016 Kirill 'Kolyat' Kiselnikov
+# This file is the part of vpoker, released under modified MIT license
+# See the file LICENSE.txt included in this distribution
+
+"""
+Unit tests for main module
+"""
+
+
+import unittest
+
+from vpoker import CARD_BACKGROUND_HEIGHT
+from vp... | |
444a6d3a53e2e373e5abe2156b875f5342f371ae | pdc/apps/package/migrations/0014_auto_20170412_1331.py | pdc/apps/package/migrations/0014_auto_20170412_1331.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('package', '0013_set_default_subvariant_to_empty_string'),
]
operations = [
migrations.AddField(
model_name='rpm'... | Add missing database migration script for srpm_commit_hash and srpm_commit_branch. | Add missing database migration script for srpm_commit_hash and srpm_commit_branch.
Signed-off-by: Jan Kaluza <24a219eb5881fc77986f139dd507482b6c2e7698@redhat.com>
| Python | mit | release-engineering/product-definition-center,product-definition-center/product-definition-center,product-definition-center/product-definition-center,release-engineering/product-definition-center,product-definition-center/product-definition-center,release-engineering/product-definition-center,release-engineering/produc... | ---
+++
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('package', '0013_set_default_subvariant_to_empty_string'),
+ ]
+
+ operations = [
+ migratio... | |
e7a46e772aa09e760b9c817afb618860eeb7e33c | helenae/gui/widgets/CompleteRegCtrl.py | helenae/gui/widgets/CompleteRegCtrl.py | # -*- coding: utf-8 -*-
import wx
ID_BUTTON_CLOSE_MSG = 1000
ID_LABLE_TEXT_INFO = 1001
ID_ICON_INFO = 1002
class CompleteRegCtrl(wx.Frame):
def __init__(self, parent, id, title, ico_folder):
wx.Frame.__init__(self, parent, -1, title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
# lables, wh... | Complete register window for widget | Complete register window for widget
| Python | mit | Relrin/Helenae,Relrin/Helenae,Relrin/Helenae | ---
+++
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+import wx
+
+ID_BUTTON_CLOSE_MSG = 1000
+ID_LABLE_TEXT_INFO = 1001
+ID_ICON_INFO = 1002
+
+
+class CompleteRegCtrl(wx.Frame):
+
+ def __init__(self, parent, id, title, ico_folder):
+ wx.Frame.__init__(self, parent, -1, title, style=wx.DEFAULT_FRAME_STYLE ^ ... | |
2acfc552c42846628304e54a3b87e2bf3a59af07 | conf/ci/appveyor/get-artifacts.py | conf/ci/appveyor/get-artifacts.py | #!/usr/bin/env python
# Author: Lisandro Dalcin
# Contact: dalcinl@gmail.com
import os
import requests
APIURL = 'https://ci.appveyor.com/api'
ACCOUNT = 'mpi4py/mpi4py'
BRANCH = 'master'
BRANCH = 'maint'
branch_url = APIURL + '/projects/' + ACCOUNT + "/branch/" + BRANCH
branch = requests.get(branch_url).json()
jo... | Add helper script to download build artifacts | AppVeyor: Add helper script to download build artifacts
| Python | bsd-2-clause | mpi4py/mpi4py,mpi4py/mpi4py,mpi4py/mpi4py | ---
+++
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# Author: Lisandro Dalcin
+# Contact: dalcinl@gmail.com
+
+import os
+import requests
+
+APIURL = 'https://ci.appveyor.com/api'
+ACCOUNT = 'mpi4py/mpi4py'
+BRANCH = 'master'
+BRANCH = 'maint'
+
+branch_url = APIURL + '/projects/' + ACCOUNT + "/branch/" + BRANCH
+br... | |
4fe9d2ceb7b1d8be1b89167944c06c6c2c92d1c4 | csv2ofx/mappings/ingdirect.py | csv2ofx/mappings/ingdirect.py | # -*- coding: utf-8 -*-
# vim: sw=4:ts=4:expandtab
# pylint: disable=invalid-name
"""
csv2ofx.mappings.ingdirect
~~~~~~~~~~~~~~~~~~~~~~~~
Provides a mapping for transactions obtained via ING Direct
(Australian bank)
"""
from __future__ import absolute_import
from operator import itemgetter
mapping = {
'is_split'... | Create mapping for ING Direct | Create mapping for ING Direct
| Python | mit | reubano/csv2ofx,reubano/csv2ofx | ---
+++
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# vim: sw=4:ts=4:expandtab
+# pylint: disable=invalid-name
+"""
+csv2ofx.mappings.ingdirect
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Provides a mapping for transactions obtained via ING Direct
+(Australian bank)
+"""
+from __future__ import absolute_import
+
+from operator impor... | |
a0844c1dd37e0d487350187874804e973c106445 | TH02.py | TH02.py | #TH02 by Trent Monahan, 2015
#ported from Intel's UPM TH02 in C
import mraa
TH02_ADDR = 0x40 # device address
TH02_REG_STATUS = 0x00
TH02_REG_DATA_H = 0x01
TH02_REG_DATA_L = 0x02
TH02_REG_CONFIG = 0x03
TH02_REG_ID = 0x11
TH02_STATUS_RDY_MASK = 0x01
TH02_CMD_MEASURE_HUMI = 0x01
TH02_CMD_MEASURE_TEMP = 0x11
clas... | Add Temp & Humi API | Add Temp & Humi API | Python | mit | SinZ163/EdisonSandbox | ---
+++
@@ -0,0 +1,70 @@
+#TH02 by Trent Monahan, 2015
+#ported from Intel's UPM TH02 in C
+
+import mraa
+
+TH02_ADDR = 0x40 # device address
+TH02_REG_STATUS = 0x00
+TH02_REG_DATA_H = 0x01
+TH02_REG_DATA_L = 0x02
+TH02_REG_CONFIG = 0x03
+TH02_REG_ID = 0x11
+
+TH02_STATUS_RDY_MASK = 0x01
+
+TH02_CMD_MEASURE_HUMI... | |
f2e6fedf021e48e275a857bc7a0471a17aa10c29 | tests/integration/test_webui.py | tests/integration/test_webui.py | import requests
import pytest
class TestWebUI(object):
def get_page(self, page):
return requests.get('http://127.0.0.1' + page)
pages = [
{
'page': '/',
'matching_text': 'Diamond',
},
{
'page': '/scoreboard',
},
{
... | Add basic checks for web endpoints integraiton tests | Add basic checks for web endpoints integraiton tests
| Python | mit | pwnbus/scoring_engine,pwnbus/scoring_engine,pwnbus/scoring_engine,pwnbus/scoring_engine | ---
+++
@@ -0,0 +1,38 @@
+import requests
+import pytest
+
+
+class TestWebUI(object):
+ def get_page(self, page):
+ return requests.get('http://127.0.0.1' + page)
+
+ pages = [
+ {
+ 'page': '/',
+ 'matching_text': 'Diamond',
+ },
+ {
+ 'page': '/sco... | |
4233919f94296e1e4986345d876b3f2ebf14e0e4 | unix_rpc.py | unix_rpc.py | import socket
import struct
import json
import os
RPC_VERSION = 1
def msg_send(sock, msg):
j = json.dumps(msg)
header = struct.pack('!LL', RPC_VERSION, len(j))
sock.sendall(b'%b%b' % (header, j.encode('utf-8')))
def msg_recv(sock):
buff = b''
while len(buff) < 8:
buff += sock.recv(1024)
... | Add module for executing RPCs over UNIX sockets | Add module for executing RPCs over UNIX sockets
| Python | apache-2.0 | sagelywizard/dlex | ---
+++
@@ -0,0 +1,101 @@
+import socket
+import struct
+import json
+import os
+
+RPC_VERSION = 1
+
+def msg_send(sock, msg):
+ j = json.dumps(msg)
+ header = struct.pack('!LL', RPC_VERSION, len(j))
+ sock.sendall(b'%b%b' % (header, j.encode('utf-8')))
+
+def msg_recv(sock):
+ buff = b''
+ while len(b... | |
431292036e591e037ce83ce84173d17e86ff80d1 | lib/carbon/tests/benchmark_aggregator.py | lib/carbon/tests/benchmark_aggregator.py | import timeit
import time
from carbon.aggregator.processor import AggregationProcessor, RuleManager, settings
from carbon.aggregator.buffers import BufferManager
from carbon.tests.util import print_stats
from carbon.conf import settings
from carbon import state
METRIC = 'prod.applications.foo.1.requests'
METRIC_AGGR ... | Add a benchmark for the aggregator | Add a benchmark for the aggregator
| Python | apache-2.0 | graphite-project/carbon,deniszh/carbon,deniszh/carbon,obfuscurity/carbon,obfuscurity/carbon,criteo-forks/carbon,criteo-forks/carbon,piotr1212/carbon,graphite-project/carbon,piotr1212/carbon | ---
+++
@@ -0,0 +1,83 @@
+import timeit
+import time
+
+from carbon.aggregator.processor import AggregationProcessor, RuleManager, settings
+from carbon.aggregator.buffers import BufferManager
+from carbon.tests.util import print_stats
+from carbon.conf import settings
+from carbon import state
+
+METRIC = 'prod.appl... | |
cfee86e7e9e1e29cbdbf6d888edff1f02d733808 | 31-coin-sums.py | 31-coin-sums.py | def coin_change(left, coins, count):
if left == 0:
return count
if not coins:
return 0
coin, *coins_left = coins
return sum(coin_change(left-coin*i, coins_left, count+1)
for i
in range(0, left//coin))
if __name__ == '__main__':
coins = [200, 100, 50,... | Work on 31 coin sums | Work on 31 coin sums
| Python | mit | dawran6/project-euler | ---
+++
@@ -0,0 +1,17 @@
+def coin_change(left, coins, count):
+ if left == 0:
+ return count
+
+ if not coins:
+ return 0
+
+ coin, *coins_left = coins
+ return sum(coin_change(left-coin*i, coins_left, count+1)
+ for i
+ in range(0, left//coin))
+
+
+if __name__ ... | |
660aecd99935ef3073d8ff166c5bd131b2d95b22 | tests/unit/test_inotify.py | tests/unit/test_inotify.py | #!/usr/bin/env python
import pytest
from butter.inotify import watch
from subprocess import Popen
from tempfile import TemporaryDirectory
from time import sleep
import os
def test_watch():
FILENAME = 'inotify_test'
with TemporaryDirectory() as tmp_dir:
filename = os.path.join(tmp_dir, FILENAME)
... | Add tests for watch function | Add tests for watch function
| Python | bsd-3-clause | wdv4758h/butter,dasSOZO/python-butter | ---
+++
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import pytest
+from butter.inotify import watch
+
+from subprocess import Popen
+from tempfile import TemporaryDirectory
+from time import sleep
+import os
+
+def test_watch():
+ FILENAME = 'inotify_test'
+ with TemporaryDirectory() as tmp_dir:
+ filenam... | |
4e5ce8c0d0c998d8e9734bec584c93e0bc2fd065 | migrations/versions/790_add_g9_lots.py | migrations/versions/790_add_g9_lots.py | """add entries to lots table for G-Cloud 9
Revision ID: 790
Revises: 780
Create Date: 2017-01-27 13:33:33.333333
"""
# revision identifiers, used by Alembic.
revision = '790'
down_revision = '780'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import table, column
def upgrade():
# Insert G... | Add new lots for G-Cloud 9 | Add new lots for G-Cloud 9
| Python | mit | alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api | ---
+++
@@ -0,0 +1,49 @@
+"""add entries to lots table for G-Cloud 9
+
+Revision ID: 790
+Revises: 780
+Create Date: 2017-01-27 13:33:33.333333
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '790'
+down_revision = '780'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.sql import tab... | |
7086dcce04799d744bb594cbf6ccbe8b7b09767d | Glyphs/DecRO.py | Glyphs/DecRO.py | # MenuTitle: Copy to Background, Decompose, Remove Overlaps, Correct Path Direction
for layer in Glyphs.font.selectedLayers:
g = layer.parent
for l in g.layers:
l.background = l.copy()
l.decomposeComponents()
l.removeOverlap()
l.correctPathDirection()
| Add "Glyphs/Copy to Background, Decompose, Remove Overlaps, Correct Path Direction" | Add "Glyphs/Copy to Background, Decompose, Remove Overlaps, Correct Path Direction"
| Python | mit | jenskutilek/Glyphs-Scripts | ---
+++
@@ -0,0 +1,8 @@
+# MenuTitle: Copy to Background, Decompose, Remove Overlaps, Correct Path Direction
+for layer in Glyphs.font.selectedLayers:
+ g = layer.parent
+ for l in g.layers:
+ l.background = l.copy()
+ l.decomposeComponents()
+ l.removeOverlap()
+ l.correctPathDirect... | |
8475c80b48d02fad440acd4324b2bfba2f8e1f67 | migrations/versions/940_more_supplier_details.py | migrations/versions/940_more_supplier_details.py | """ Extend suppliers table with new fields (to be initially populated from declaration data)
Revision ID: 940
Revises: 930
Create Date: 2017-08-16 16:39:00.000000
"""
# revision identifiers, used by Alembic.
revision = '940'
down_revision = '930'
from alembic import op
import sqlalchemy as sa
def upgrade():
o... | Add columns to suppliers table | Add columns to suppliers table
The following data is moving from framework-level supplier declarations to the
supplier account level:
* Organisation size
* VAT number
* Non-companies-house registration number (for non-UK companies)
* Registered organisation name (as opposed to marketplace supplier account name)
* Reg... | Python | mit | alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api | ---
+++
@@ -0,0 +1,34 @@
+""" Extend suppliers table with new fields (to be initially populated from declaration data)
+
+Revision ID: 940
+Revises: 930
+Create Date: 2017-08-16 16:39:00.000000
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '940'
+down_revision = '930'
+
+from alembic import op
+impor... | |
fe9da2481ab777012fbfd94bd9bacef9fc8151f4 | psshlib/hosts.py | psshlib/hosts.py | import sys
import psshutil
import random
class ServerPool(list):
def __init__(self, options):
self.options = options
try:
hosts = psshutil.read_host_files(options.host_files, default_user=options.user)
except IOError:
_, e, _ = sys.exc_info()
sys.stderr.w... | import sys
import psshutil
import random
class ServerPool(list):
def __init__(self, options):
self.options = options
try:
hosts = psshutil.read_host_files(options.host_files, default_user=options.user)
except IOError:
_, e, _ = sys.exc_info()
sys.stderr.w... | Fix --sample-size error messages lacking newlines | Fix --sample-size error messages lacking newlines
| Python | bsd-3-clause | jcmcken/parallel-ssh,jorik041/parallel-ssh,gyf19/parallel-ssh | ---
+++
@@ -17,10 +17,10 @@
sample_size = options.sample_size
if sample_size:
if sample_size <= 0:
- sys.stderr.write('Sample size cannot be negative')
+ sys.stderr.write('Sample size cannot be negative\n')
sys.exit(1)
elif sam... |
8c37c1ae7f42d22a186de4751a56209ebdd77ec4 | dr27demo/dr27app/test_settings.py | dr27demo/dr27app/test_settings.py | from .base_settings import *
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
'KEY_PREFIX': 'driver27-cache-app'
}
} | Add settings for django tests. | Add settings for django tests.
| Python | mit | SRJ9/django-driver27,SRJ9/django-driver27,SRJ9/django-driver27 | ---
+++
@@ -0,0 +1,10 @@
+from .base_settings import *
+
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+ 'LOCATION': '127.0.0.1:11211',
+ 'KEY_PREFIX': 'driver27-cache-app'
+
+ }
+} | |
3e25a1b44743bbf7d0bf1205cebe5bfb6a693fef | delete_whois.py | delete_whois.py | #!/usr/bin/env python
import os
import sys
import time
import getpass
import datetime
from common.appenginepatch.aecmd import setup_env
setup_env()
import ADNS
from adns import rr
from google.appengine.ext import db
from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.api.datastore_erro... | Delete obsolete Whois model from the datastore. | Delete obsolete Whois model from the datastore.
| Python | mit | jcrocholl/nxdom,jcrocholl/nxdom | ---
+++
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import time
+import getpass
+import datetime
+
+from common.appenginepatch.aecmd import setup_env
+setup_env()
+
+import ADNS
+from adns import rr
+
+from google.appengine.ext import db
+from google.appengine.ext.remote_api import remote_api_st... | |
b977cf85a16d322cecb2bde051ad3026fa8e037e | setup.py | setup.py | from distutils.core import setup
setup(
name="pycomponents",
version='0.1',
description="A simple component entity system for python",
author="David Gabor Bodor",
url="http://github.com/dragonfi/pycomponents",
packages=['pycomponents'],
license="MIT",
)
| Make package installable via pip | Make package installable via pip
| Python | mit | dragonfi/pycomponents,dragonfi/pycomponents | ---
+++
@@ -0,0 +1,11 @@
+from distutils.core import setup
+
+setup(
+ name="pycomponents",
+ version='0.1',
+ description="A simple component entity system for python",
+ author="David Gabor Bodor",
+ url="http://github.com/dragonfi/pycomponents",
+ packages=['pycomponents'],
+ license="MIT",
+) | |
594039c17f9db7b2cb058eaca58299281a61ef29 | irrigator_pro/farms/formset_views.py | irrigator_pro/farms/formset_views.py | from extra_views import ModelFormSetView
from django.forms import Textarea, TextInput
from django.db.models import Q
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from farms.models import Field, Probe, ProbeReading, WaterHistory
from fields_filter import... | Move Probes and Water_History formset views to using a common "Farms_FormsetView" superclass. | Move Probes and Water_History formset views to using a common
"Farms_FormsetView" superclass.
| Python | mit | warnes/irrigatorpro,warnes/irrigatorpro,warnes/irrigatorpro,warnes/irrigatorpro | ---
+++
@@ -0,0 +1,71 @@
+from extra_views import ModelFormSetView
+from django.forms import Textarea, TextInput
+from django.db.models import Q
+from django.contrib.auth.decorators import login_required
+from django.utils.decorators import method_decorator
+
+from farms.models import Field, Probe, ProbeReading, Wate... | |
1337bed0e13f8e0f3d1294464e817b782b765b47 | scripts/read_in_lines.py | scripts/read_in_lines.py | from image_process.hough_transform import get_hough_lines
from lines.line import Point, LineSegment
import matplotlib.pyplot as plt
import os
image_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data', 'hough_test', 'Test_Set_1', 'PNGs',
'C(C)C(CCCC)(C)C.png')
lines = get_h... | Add Script for Testing Line Segment Features | Add Script for Testing Line Segment Features
| Python | mit | Molecular-Image-Recognition/Molecular-Image-Recognition | ---
+++
@@ -0,0 +1,46 @@
+from image_process.hough_transform import get_hough_lines
+from lines.line import Point, LineSegment
+import matplotlib.pyplot as plt
+import os
+
+image_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data', 'hough_test', 'Test_Set_1', 'PNGs',
+ 'C(... | |
05c2b5edb0ad2dd96f4146893de1bcaa2b691c64 | jenkinsapi/utils/krb_requester.py | jenkinsapi/utils/krb_requester.py | from jenkinsapi.utils.requester import Requester
from requests_kerberos import HTTPKerberosAuth, OPTIONAL
class KrbRequester(Requester):
"""
A class which carries out HTTP requests with Kerberos/GSSAPI authentication.
"""
def __init__(self, ssl_verify=None, baseurl=None, mutual_auth=OPTIONAL):
... | Add kerberos authentication requester using requests_kerberos | Add kerberos authentication requester using requests_kerberos
| Python | mit | domenkozar/jenkinsapi,imsardine/jenkinsapi,zaro0508/jenkinsapi,jduan/jenkinsapi,JohnLZeller/jenkinsapi,JohnLZeller/jenkinsapi,mistermocha/jenkinsapi,imsardine/jenkinsapi,aerickson/jenkinsapi,zaro0508/jenkinsapi,mistermocha/jenkinsapi,jduan/jenkinsapi,domenkozar/jenkinsapi,salimfadhley/jenkinsapi,salimfadhley/jenkinsapi... | ---
+++
@@ -0,0 +1,34 @@
+from jenkinsapi.utils.requester import Requester
+from requests_kerberos import HTTPKerberosAuth, OPTIONAL
+
+
+class KrbRequester(Requester):
+
+ """
+ A class which carries out HTTP requests with Kerberos/GSSAPI authentication.
+ """
+
+ def __init__(self, ssl_verify=None, base... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.