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 |
|---|---|---|---|---|---|---|---|---|---|---|
5b8518d3b7bdd55ee20dec81f18c4b9a8732decd | test/views/test_failures.py | test/views/test_failures.py | from textwrap import dedent
import pytest
from puppetboard.views.failures import get_friendly_error
# flake8: noqa
@pytest.mark.parametrize("raw_message,friendly_message", [
("Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation "
"Error: Error while evaluating a Res... | Add tests for friendly errors | Add tests for friendly errors
| Python | apache-2.0 | voxpupuli/puppetboard,voxpupuli/puppetboard,voxpupuli/puppetboard | ---
+++
@@ -0,0 +1,42 @@
+from textwrap import dedent
+
+import pytest
+
+from puppetboard.views.failures import get_friendly_error
+
+
+# flake8: noqa
+@pytest.mark.parametrize("raw_message,friendly_message", [
+ ("Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation "
+ ... | |
5b7b301c3f9dd906b8450acc5b28dbcb35fe973a | candidates/management/commands/candidates_fix_not_standing.py | candidates/management/commands/candidates_fix_not_standing.py | from __future__ import print_function, unicode_literals
from django.core.management.base import BaseCommand
from popolo.models import Membership
from candidates.models import PersonExtra
class Command(BaseCommand):
help = "Find elections in not_standing that should be removed"
def add_arguments(self, pars... | Add a script to fix the not_standing relationships of people | Add a script to fix the not_standing relationships of people
There was a bug in bulk adding people which meant that their
"not_standing" status for an election wasn't removed when reinstating
them as a candidate in that election.
That bug has been fixed in the parent commit, but there are still people
in the database... | Python | agpl-3.0 | DemocracyClub/yournextrepresentative,DemocracyClub/yournextrepresentative,DemocracyClub/yournextrepresentative | ---
+++
@@ -0,0 +1,45 @@
+from __future__ import print_function, unicode_literals
+
+from django.core.management.base import BaseCommand
+
+from popolo.models import Membership
+
+from candidates.models import PersonExtra
+
+class Command(BaseCommand):
+
+ help = "Find elections in not_standing that should be remo... | |
a2efa662f0f5b8fe77da5673cb6d6df2e2f583d2 | django/website/contacts/migrations/0004_auto_20160421_1645.py | django/website/contacts/migrations/0004_auto_20160421_1645.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
def add_user_profiles(apps, schema_editor):
User = apps.get_model('contacts', 'User')
UserPreferences = apps.get_model('contacts', 'UserPreferences')
for user in User.objects.all():
UserPrefe... | Add migration to create user profiles | Add migration to create user profiles | Python | agpl-3.0 | aptivate/kashana,aptivate/alfie,daniell/kashana,aptivate/alfie,daniell/kashana,aptivate/kashana,aptivate/alfie,daniell/kashana,daniell/kashana,aptivate/kashana,aptivate/alfie,aptivate/kashana | ---
+++
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+def add_user_profiles(apps, schema_editor):
+ User = apps.get_model('contacts', 'User')
+ UserPreferences = apps.get_model('contacts', 'UserPreferences')
+
+ for user in... | |
572f6d8e789495fc34ed67230b10b0c1f0b3572f | helusers/tests/test_utils.py | helusers/tests/test_utils.py | import pytest
import random
from uuid import UUID
from helusers.utils import uuid_to_username, username_to_uuid
def test_uuid_to_username():
assert uuid_to_username('00fbac99-0bab-5e66-8e84-2e567ea4d1f6') == 'u-ad52zgilvnpgnduefzlh5jgr6y'
def test_username_to_uuid():
assert username_to_uuid('u-ad52zgilvnpgn... | Add some tests for helusers | Add some tests for helusers
| Python | bsd-2-clause | City-of-Helsinki/django-helusers,City-of-Helsinki/django-helusers | ---
+++
@@ -0,0 +1,20 @@
+import pytest
+import random
+from uuid import UUID
+from helusers.utils import uuid_to_username, username_to_uuid
+
+
+def test_uuid_to_username():
+ assert uuid_to_username('00fbac99-0bab-5e66-8e84-2e567ea4d1f6') == 'u-ad52zgilvnpgnduefzlh5jgr6y'
+
+
+def test_username_to_uuid():
+ a... | |
3127cface44165d3200657c3fa626a5051c6ad48 | tests/test_show_resource.py | tests/test_show_resource.py | from nose.plugins.attrib import attr
from rightscale.rightscale import RightScale, Resource
@attr('rc_creds', 'real_conn')
def test_show_first_cloud():
api = RightScale()
res = api.clouds.show(res_id=1)
assert isinstance(res, Resource)
| Test API call that only returns a single Resource | Test API call that only returns a single Resource
| Python | mit | diranged/python-rightscale-1,brantai/python-rightscale | ---
+++
@@ -0,0 +1,10 @@
+from nose.plugins.attrib import attr
+
+from rightscale.rightscale import RightScale, Resource
+
+
+@attr('rc_creds', 'real_conn')
+def test_show_first_cloud():
+ api = RightScale()
+ res = api.clouds.show(res_id=1)
+ assert isinstance(res, Resource) | |
d76809021c99f841cd8d123058d307404b7c025c | py/split-array-into-consecutive-subsequences.py | py/split-array-into-consecutive-subsequences.py | from itertools import groupby
class Solution(object):
def isPossible(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
prev = None
not_full_1, not_full_2, attach = 0, 0, 0
for n, items in groupby(nums):
cnt = len(list(items))
if p... | Add py solution for 659. Split Array into Consecutive Subsequences | Add py solution for 659. Split Array into Consecutive Subsequences
659. Split Array into Consecutive Subsequences: https://leetcode.com/problems/split-array-into-consecutive-subsequences/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,27 @@
+from itertools import groupby
+class Solution(object):
+ def isPossible(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: bool
+ """
+ prev = None
+ not_full_1, not_full_2, attach = 0, 0, 0
+ for n, items in groupby(nums):
+ c... | |
f8db46b40629cfdb145a4a000d47277f72090c5b | powerline/lib/memoize.py | powerline/lib/memoize.py | # vim:fileencoding=utf-8:noet
from functools import wraps
import time
def default_cache_key(**kwargs):
return frozenset(kwargs.items())
class memoize(object):
'''Memoization decorator with timeout.'''
def __init__(self, timeout, cache_key=default_cache_key, cache_reg_func=None):
self.timeout = timeout
self.... | # vim:fileencoding=utf-8:noet
from functools import wraps
try:
# Python>=3.3, the only valid clock source for this job
from time import monotonic as time
except ImportError:
# System time, is affected by clock updates.
from time import time
def default_cache_key(**kwargs):
return frozenset(kwargs.items())
cla... | Use proper clock if possible | Use proper clock if possible
| Python | mit | Liangjianghao/powerline,kenrachynski/powerline,darac/powerline,darac/powerline,bezhermoso/powerline,firebitsbr/powerline,bartvm/powerline,cyrixhero/powerline,junix/powerline,prvnkumar/powerline,s0undt3ch/powerline,S0lll0s/powerline,Luffin/powerline,EricSB/powerline,dragon788/powerline,prvnkumar/powerline,wfscheper/powe... | ---
+++
@@ -1,7 +1,12 @@
# vim:fileencoding=utf-8:noet
from functools import wraps
-import time
+try:
+ # Python>=3.3, the only valid clock source for this job
+ from time import monotonic as time
+except ImportError:
+ # System time, is affected by clock updates.
+ from time import time
def default_cache_ke... |
0886d0fe49f4176bfe6860c643d240a9b7e0053d | db/player_draft.py | db/player_draft.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from .common import Base, session_scope
class PlayerDraft(Base):
__tablename__ = 'player_drafts'
__autoload__ = True
def __init__(self, player_id, team_id, year, round, overall, dft_type='e'):
self.player_id = player_id
self.team_id =... | Integrate initial version of player draft item | Integrate initial version of player draft item
| Python | mit | leaffan/pynhldb | ---
+++
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from .common import Base, session_scope
+
+
+class PlayerDraft(Base):
+ __tablename__ = 'player_drafts'
+ __autoload__ = True
+
+ def __init__(self, player_id, team_id, year, round, overall, dft_type='e'):
+ self.player_id... | |
699f1f42e0387ac542cbe0905f825079e7aab755 | testupload.py | testupload.py | #!/usr/bin/python
from datetime import datetime
from datetime import timedelta
import subprocess
import time
import logging
from wrappers import GPhoto
from wrappers import Identify
from wrappers import Curl
#sudo /usr/local/bin/gphoto2 --capture-image-and-download --filename 'test3.jpg'
#curl --form "fileupload=@te... | Add upload and delay test | Add upload and delay test
| Python | mit | Lakerfield/timelapse | ---
+++
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+from datetime import datetime
+from datetime import timedelta
+import subprocess
+import time
+import logging
+
+from wrappers import GPhoto
+from wrappers import Identify
+from wrappers import Curl
+
+#sudo /usr/local/bin/gphoto2 --capture-image-and-download --filename ... | |
67164cadc3f3445298da2fb490971cf22e2f146b | curious/ext/loapi/__init__.py | curious/ext/loapi/__init__.py | """
A lower-level State that doesn't do any special object handling.
"""
import inspect
import typing
from curious.gateway import Gateway
from curious.state import State
class PureDispatchState(State):
"""
A lower-level State that doesn't do any special object handling.
This state allows you to pass JSON... | Add very low level state handlers. | Add very low level state handlers.
| Python | mit | SunDwarf/curious | ---
+++
@@ -0,0 +1,62 @@
+"""
+A lower-level State that doesn't do any special object handling.
+"""
+import inspect
+import typing
+
+from curious.gateway import Gateway
+from curious.state import State
+
+
+class PureDispatchState(State):
+ """
+ A lower-level State that doesn't do any special object handling... | |
af7b495b954bb624cbd95e0019fa3b2cb3be6b05 | rsa.py | rsa.py | #!/usr/local/bin/python
"""
RSA.py
@author Elliot and Erica
"""
import random
from cryptography_utilities import (block_split, decimal_to_binary,
binary_to_decimal, gcd, extended_gcd, random_prime, left_pad,
pad_plaintext, unpad_plaintext, random_relative_prime,
group_exponentiation)
MODULUS_BITS = 16
... | Implement a public-key cipher (RSA) | Implement a public-key cipher (RSA)
| Python | mit | ElliotPenson/cryptography | ---
+++
@@ -0,0 +1,58 @@
+#!/usr/local/bin/python
+
+"""
+RSA.py
+
+@author Elliot and Erica
+"""
+
+import random
+from cryptography_utilities import (block_split, decimal_to_binary,
+ binary_to_decimal, gcd, extended_gcd, random_prime, left_pad,
+ pad_plaintext, unpad_plaintext, random_relative_prime,
+ gr... | |
3f55d16fb40acc07cf07588249126cc543d9ad07 | dissector/main.py | dissector/main.py | import os
import sys
sys.path.append('../p4_hlir/')
from p4_hlir.main import HLIR
p4_source = sys.argv[1]
absolute_source = os.path.join(os.getcwd(), p4_source)
if not os.path.isfile(absolute_source):
print "Source file '" + p4_source + \
"' could not be opened or does not exist."
hlir = HLIR(absolute_s... | Read a P4 file and get its HLIR. | Read a P4 file and get its HLIR.
| Python | apache-2.0 | yo2seol/P4-Wireshark-Dissector | ---
+++
@@ -0,0 +1,13 @@
+import os
+import sys
+sys.path.append('../p4_hlir/')
+from p4_hlir.main import HLIR
+
+p4_source = sys.argv[1]
+absolute_source = os.path.join(os.getcwd(), p4_source)
+if not os.path.isfile(absolute_source):
+ print "Source file '" + p4_source + \
+ "' could not be opened or doe... | |
31525d83ea74852709b1dd1596854a74c050f9f2 | scripts/add_requests.py | scripts/add_requests.py | from google.cloud import firestore
import argparse
import datetime
import names
import random
def queryUsers(db):
users_ref = db.collection(u'users')
docs = users_ref.get()
docList = list()
for doc in docs:
docList.append(doc)
return docList
def queryRequests(db):
requests_ref = db.collection(u'requests')
do... | Add script to add requests | Add script to add requests
| Python | mit | frinder/frinder-app,frinder/frinder-app,frinder/frinder-app | ---
+++
@@ -0,0 +1,83 @@
+from google.cloud import firestore
+import argparse
+import datetime
+import names
+import random
+
+def queryUsers(db):
+ users_ref = db.collection(u'users')
+ docs = users_ref.get()
+ docList = list()
+ for doc in docs:
+ docList.append(doc)
+ return docList
+
+def queryRequests(db):
+ re... | |
e5716c90e97d1364c551701f3bae772f08c9c561 | upload/management/commands/import_sheet.py | upload/management/commands/import_sheet.py | import csv
from django.contrib.auth.models import User
from opencivicdata.models import Jurisdiction, Division
from upload.backend.parser import import_stream
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
args = '<csv> <jurisdiction> <source> <user>'
help = 'Lo... | Add management command to do one-off imports. | Add management command to do one-off imports.
| Python | bsd-3-clause | opencivicdata/opencivicdata.org,opencivicdata/opencivicdata.org,opencivicdata/opencivicdata.org | ---
+++
@@ -0,0 +1,32 @@
+import csv
+from django.contrib.auth.models import User
+from opencivicdata.models import Jurisdiction, Division
+from upload.backend.parser import import_stream
+
+from django.core.management.base import BaseCommand, CommandError
+
+
+class Command(BaseCommand):
+ args = '<csv> <jurisdic... | |
127dbd5779280fc62f56f06f8ef2733b7aa4cdd9 | corehq/apps/case_search/tests/test_case_search_registry.py | corehq/apps/case_search/tests/test_case_search_registry.py | import uuid
from django.test import TestCase
from casexml.apps.case.mock import CaseBlock
from corehq.apps.case_search.models import CaseSearchConfig
from corehq.apps.domain.shortcuts import create_user
from corehq.apps.es.tests.utils import (
case_search_es_setup,
case_search_es_teardown,
es_test,
)
fro... | Add test setup for registry case search | Add test setup for registry case search
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,84 @@
+import uuid
+
+from django.test import TestCase
+
+from casexml.apps.case.mock import CaseBlock
+
+from corehq.apps.case_search.models import CaseSearchConfig
+from corehq.apps.domain.shortcuts import create_user
+from corehq.apps.es.tests.utils import (
+ case_search_es_setup,
+ case_... | |
3f3f6e2e3a7f62e7fcaa24c4260a0f09e0800b6a | tests/test_bounce.py | tests/test_bounce.py | import sys, pygame
pygame.init()
size = width, height = 320, 240
speed = [2, 2]
black = 0, 0, 0
screen = pygame.display.set_mode(size)
#ball = pygame.image.load("ball.bmp")
ball = pygame.surface.Surface((100, 100))
ball.fill(pygame.Color(0, 0, 255, 255))
ballrect = ball.get_rect()
clock = pygame.time.Clock()
while ... | Add simple animation example from pygame tutorial | Add simple animation example from pygame tutorial
| Python | lgpl-2.1 | caseyc37/pygame_cffi,CTPUG/pygame_cffi,CTPUG/pygame_cffi,CTPUG/pygame_cffi,GertBurger/pygame_cffi,GertBurger/pygame_cffi,caseyc37/pygame_cffi,caseyc37/pygame_cffi,GertBurger/pygame_cffi,GertBurger/pygame_cffi | ---
+++
@@ -0,0 +1,30 @@
+import sys, pygame
+pygame.init()
+
+size = width, height = 320, 240
+speed = [2, 2]
+black = 0, 0, 0
+
+screen = pygame.display.set_mode(size)
+
+#ball = pygame.image.load("ball.bmp")
+ball = pygame.surface.Surface((100, 100))
+ball.fill(pygame.Color(0, 0, 255, 255))
+ballrect = ball.get_re... | |
264b4112ccfdebeb7524036b6f32d49fa38bb321 | tests/test_heroku.py | tests/test_heroku.py | """Tests for the Wallace API."""
import subprocess
import re
import requests
class TestHeroku(object):
"""The Heroku test class."""
def test_sandbox(self):
"""Launch the experiment on Heroku."""
sandbox_output = subprocess.check_output(
"cd examples/bartlett1932; wallace sandbox... | Create test for sandboxing via Heroku | Create test for sandboxing via Heroku
| Python | mit | berkeley-cocosci/Wallace,suchow/Wallace,Dallinger/Dallinger,jcpeterson/Dallinger,jcpeterson/Dallinger,Dallinger/Dallinger,suchow/Wallace,berkeley-cocosci/Wallace,jcpeterson/Dallinger,suchow/Wallace,jcpeterson/Dallinger,Dallinger/Dallinger,jcpeterson/Dallinger,berkeley-cocosci/Wallace,Dallinger/Dallinger,Dallinger/Dalli... | ---
+++
@@ -0,0 +1,22 @@
+"""Tests for the Wallace API."""
+
+import subprocess
+import re
+import requests
+
+
+class TestHeroku(object):
+
+ """The Heroku test class."""
+
+ def test_sandbox(self):
+ """Launch the experiment on Heroku."""
+ sandbox_output = subprocess.check_output(
+ ... | |
c20b1b8c2362f2484baacd15acd9d72ae1e2b6d7 | tools/commitstats.py | tools/commitstats.py |
# Run svn log -l <some number>
import re
import numpy as np
import os
names = re.compile(r'r\d+\s[|]\s(.*)\s[|]\s200')
def get_count(filename, repo):
mystr = open(filename).read()
result = names.findall(mystr)
u = np.unique(result)
count = [(x,result.count(x),repo) for x in u]
return count
... | Add a tool for determining active SVN committers. | Add a tool for determining active SVN committers.
git-svn-id: 77a43f9646713b91fea7788fad5dfbf67e151ece@7427 94b884b6-d6fd-0310-90d3-974f1d3f35e1
| Python | bsd-3-clause | teoliphant/numpy-refactor,jasonmccampbell/numpy-refactor-sprint,jasonmccampbell/numpy-refactor-sprint,jasonmccampbell/numpy-refactor-sprint,Ademan/NumPy-GSoC,teoliphant/numpy-refactor,teoliphant/numpy-refactor,jasonmccampbell/numpy-refactor-sprint,teoliphant/numpy-refactor,Ademan/NumPy-GSoC,Ademan/NumPy-GSoC,Ademan/Num... | ---
+++
@@ -0,0 +1,43 @@
+
+# Run svn log -l <some number>
+
+import re
+import numpy as np
+import os
+
+names = re.compile(r'r\d+\s[|]\s(.*)\s[|]\s200')
+
+def get_count(filename, repo):
+ mystr = open(filename).read()
+ result = names.findall(mystr)
+ u = np.unique(result)
+ count = [(x,result.count(x)... | |
d3df6283db7e9ed56c41f4e7a866c8622743da40 | set_markdown_template.py | set_markdown_template.py | import sublime
import sublime_plugin
from os.path import exists, join
TEMPLATE_NAME = "custom-template.html"
def set_template():
path = join(sublime.packages_path(), "User", TEMPLATE_NAME)
settings = sublime.load_settings("MarkdownPreview.sublime-settings")
if settings.get("html_template") != path:
... | Add script to set markdown template | Add script to set markdown template
| Python | mit | facelessuser/SublimeRandomCrap,facelessuser/SublimeRandomCrap | ---
+++
@@ -0,0 +1,23 @@
+import sublime
+import sublime_plugin
+from os.path import exists, join
+
+TEMPLATE_NAME = "custom-template.html"
+
+
+def set_template():
+ path = join(sublime.packages_path(), "User", TEMPLATE_NAME)
+ settings = sublime.load_settings("MarkdownPreview.sublime-settings")
+ if settin... | |
53b17d83300d5d1607e0124229bf830cb1eb8a31 | xmlrpc_download.py | xmlrpc_download.py | #!/usr/bin/env python
import json
import sys
import xmlrpc.client
# XXX Edit this to your liking
MAX_BUG_ID = 3210
EXPORT_FILE = "bugzilla.json"
BLACKLIST = [489, 3188]
class RPCEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, xmlrpc.client.DateTime):
return o.value
raise NotImplementedErr... | Add an XML-RPC downloader for bugzilla | Add an XML-RPC downloader for bugzilla
| Python | mit | jleclanche/bugzilla-to-github | ---
+++
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+import json
+import sys
+import xmlrpc.client
+
+
+# XXX Edit this to your liking
+MAX_BUG_ID = 3210
+EXPORT_FILE = "bugzilla.json"
+BLACKLIST = [489, 3188]
+
+
+class RPCEncoder(json.JSONEncoder):
+ def default(self, o):
+ if isinstance(o, xmlrpc.client.DateTime):
... | |
d1afa600338bb0d9c1c040a42b6de5504e48d699 | similar_photos_sqlite.py | similar_photos_sqlite.py | import graphlab
import sqlite3
def main():
# load photos with their deep features
photos = graphlab.SFrame('photos_deep_features.gl')
# train a nearest neighbors model on deep features of photos
nn_model = graphlab.nearest_neighbors.create(photos, features=['deep_features'], label='path')
# ... | Store names of similar photos into sqlite database | Store names of similar photos into sqlite database | Python | mit | aysent/yelp-photo-explorer | ---
+++
@@ -0,0 +1,29 @@
+import graphlab
+import sqlite3
+
+def main():
+
+ # load photos with their deep features
+ photos = graphlab.SFrame('photos_deep_features.gl')
+
+ # train a nearest neighbors model on deep features of photos
+ nn_model = graphlab.nearest_neighbors.create(photos, features=['d... | |
272b2238ce9d0d8d1424a470bb7f4f7b41edd9e0 | script/unarchive-forecast.py | script/unarchive-forecast.py | #!/usr/bin/env python3
import pickle
import sys
class Forecast:
pass
for fn in sys.argv:
with open(fn,"rb") as fp:
forecast = pickle.load(fp)
print(dir(forecast))
| Add unarchiver of the forecast | Add unarchiver of the forecast
| Python | mit | nushio3/UFCORIN,nushio3/UFCORIN,nushio3/UFCORIN,nushio3/UFCORIN,nushio3/UFCORIN | ---
+++
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import pickle
+import sys
+
+class Forecast:
+ pass
+
+for fn in sys.argv:
+ with open(fn,"rb") as fp:
+ forecast = pickle.load(fp)
+ print(dir(forecast)) | |
733726467c397ff530a556e9a624466994e7c13c | wagtailmenus/tests/test_commands.py | wagtailmenus/tests/test_commands.py | from __future__ import absolute_import, unicode_literals
from django.test import TestCase
from django.core.management import call_command
from wagtail.wagtailcore.models import Site
from wagtailmenus import app_settings
class TestAutoPopulateMainMenus(TestCase):
fixtures = ['test.json']
def setUp(self):
... | Add tests for new command | Add tests for new command
| Python | mit | rkhleics/wagtailmenus,rkhleics/wagtailmenus,ababic/wagtailmenus,rkhleics/wagtailmenus,ababic/wagtailmenus,ababic/wagtailmenus | ---
+++
@@ -0,0 +1,41 @@
+from __future__ import absolute_import, unicode_literals
+
+from django.test import TestCase
+from django.core.management import call_command
+from wagtail.wagtailcore.models import Site
+
+from wagtailmenus import app_settings
+
+
+class TestAutoPopulateMainMenus(TestCase):
+ fixtures = ... | |
4cb37cabb3aa171391958f4d6e6d0eb5b8731989 | climate_data/migrations/0022_auto_20170623_0236.py | climate_data/migrations/0022_auto_20170623_0236.py | # -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-06-23 02:36
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('climate_data', '0021_auto_20170619_2053'),
]
opera... | Add migration which updates field / model metadata. | Add migration which updates field / model metadata.
| Python | apache-2.0 | qubs/data-centre,qubs/climate-data-api,qubs/data-centre,qubs/climate-data-api | ---
+++
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.6 on 2017-06-23 02:36
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('climate_data', '0021... | |
32525203ee392be60c0ea32a817323ccf5cace12 | kirppu/tests/test_itemdump.py | kirppu/tests/test_itemdump.py | from django.test import Client, TestCase
from ..models import Item
from .factories import EventFactory, EventPermissionFactory, ItemFactory, ItemTypeFactory, UserFactory, VendorFactory
class ItemDumpTest(TestCase):
def _addPermission(self):
EventPermissionFactory(event=self.event, user=self.user, can_see... | Add simple test for item dump. | Add simple test for item dump.
| Python | mit | jlaunonen/kirppu,jlaunonen/kirppu,jlaunonen/kirppu,jlaunonen/kirppu | ---
+++
@@ -0,0 +1,68 @@
+from django.test import Client, TestCase
+
+from ..models import Item
+from .factories import EventFactory, EventPermissionFactory, ItemFactory, ItemTypeFactory, UserFactory, VendorFactory
+
+
+class ItemDumpTest(TestCase):
+ def _addPermission(self):
+ EventPermissionFactory(event... | |
e5e068c5fa94d68aa81dbcd3e498ba17dae37d2c | axelrod/tests/test_reflex.py | axelrod/tests/test_reflex.py | """
Test suite for Reflex Axelrod PD player.
"""
import axelrod
from test_player import TestPlayer
class Reflex_test(TestPlayer):
def test_initial_nice_strategy(self):
""" First response should always be cooperation. """
p1 = axelrod.Reflex()
p2 = axelrod.Player()
self.assertEqual... | """
Test suite for Reflex Axelrod PD player.
"""
import axelrod
from test_player import TestPlayer
class Reflex_test(TestPlayer):
name = "Reflex"
player = axelrod.Reflex
stochastic = False
def test_strategy(self):
""" First response should always be cooperation. """
p1 = axelrod.Ref... | Simplify tests to new format. | Simplify tests to new format.
| Python | mit | emmagordon/Axelrod,uglyfruitcake/Axelrod,kathryncrouch/Axelrod,emmagordon/Axelrod,mojones/Axelrod,drvinceknight/Axelrod,bootandy/Axelrod,uglyfruitcake/Axelrod,bootandy/Axelrod,risicle/Axelrod,risicle/Axelrod,mojones/Axelrod,kathryncrouch/Axelrod | ---
+++
@@ -7,17 +7,16 @@
class Reflex_test(TestPlayer):
- def test_initial_nice_strategy(self):
+ name = "Reflex"
+ player = axelrod.Reflex
+ stochastic = False
+
+
+ def test_strategy(self):
""" First response should always be cooperation. """
p1 = axelrod.Reflex()
p2 ... |
357067b0cfe6fd781813404ba7d587f5bd00917a | bazaar/goods/utils.py | bazaar/goods/utils.py | from __future__ import unicode_literals
from django.core.exceptions import ImproperlyConfigured
from .models import Product, PriceList
def get_default_price_list():
"""
Return the default price list
"""
try:
return PriceList.objects.get(default=True)
except PriceList.DoesNotExist:
... | Add utility function to retrieve default price list and to create a product from a good | Add utility function to retrieve default price list and to create a product from a good
| Python | bsd-2-clause | evonove/django-bazaar,meghabhoj/NEWBAZAAR,meghabhoj/NEWBAZAAR,meghabhoj/NEWBAZAAR,evonove/django-bazaar,evonove/django-bazaar | ---
+++
@@ -0,0 +1,34 @@
+from __future__ import unicode_literals
+
+from django.core.exceptions import ImproperlyConfigured
+
+from .models import Product, PriceList
+
+
+def get_default_price_list():
+ """
+ Return the default price list
+ """
+ try:
+ return PriceList.objects.get(default=True)
+... | |
576c2a1565fe9860c1188a9862b54e24aab64ed4 | tests/test_update_languages.py | tests/test_update_languages.py | # tests.test_update_languagess
# coding=utf-8
from __future__ import unicode_literals
import nose.tools as nose
from mock import patch
import utilities.update_languages as update_langs
from tests import set_up, tear_down
from tests.decorators import redirect_stdout_unicode
@nose.with_setup(set_up, tear_down)
@patc... | Add tests for update_languages utility | Add tests for update_languages utility
| Python | mit | caleb531/youversion-suggest,caleb531/youversion-suggest | ---
+++
@@ -0,0 +1,39 @@
+# tests.test_update_languagess
+# coding=utf-8
+
+from __future__ import unicode_literals
+
+import nose.tools as nose
+from mock import patch
+
+import utilities.update_languages as update_langs
+from tests import set_up, tear_down
+from tests.decorators import redirect_stdout_unicode
+
+
+... | |
66da5a6bd67ae3645eeff5856ae4614e4be9f5d8 | microdrop/tests/update_dmf_control_board.py | microdrop/tests/update_dmf_control_board.py | import os
import subprocess
if __name__ == '__main__':
os.chdir('microdrop/plugins')
if not os.path.exists('dmf_control_board'):
print 'Clone dmf_control_board repository...'
subprocess.call(['git', 'clone',
'http://microfluidics.utoronto.ca/git/dmf_control_board.git']... | Add script for downloading latest dmf_control_board | Add script for downloading latest dmf_control_board
| Python | bsd-3-clause | wheeler-microfluidics/microdrop | ---
+++
@@ -0,0 +1,13 @@
+import os
+import subprocess
+
+if __name__ == '__main__':
+ os.chdir('microdrop/plugins')
+
+ if not os.path.exists('dmf_control_board'):
+ print 'Clone dmf_control_board repository...'
+ subprocess.call(['git', 'clone',
+ 'http://microfluidics.utoronto.ca... | |
4173d3abeeda29ffbd81379233e88311780b6b09 | tests/test_load.py | tests/test_load.py | from .utils import TemplateTestCase, Mock
from knights import Template
class LoadTagTest(TemplateTestCase):
def test_load_default(self):
t = Template('{! knights.defaultfilters !}')
self.assertIn('title', t.parser.filters)
| Add a test for library loading | Add a test for library loading
| Python | mit | funkybob/knights-templater,funkybob/knights-templater | ---
+++
@@ -0,0 +1,10 @@
+from .utils import TemplateTestCase, Mock
+
+from knights import Template
+
+
+class LoadTagTest(TemplateTestCase):
+
+ def test_load_default(self):
+ t = Template('{! knights.defaultfilters !}')
+ self.assertIn('title', t.parser.filters) | |
fe62ab5e609aba0c1739ca81d5cdd266d208a217 | Build/make_payload.py | Build/make_payload.py | '''Quick and dirty script to generate vs.payload blocks for a set of URLs.
Usage:
make_payload.py URL [URL ...]
'''
__author__ = 'Steve Dower <steve.dower@microsoft.com>'
__version__ = '0.1'
import hashlib
import os
import urllib.request
import sys
for u in sys.argv[1:]:
is_temp = False
if os.path.isf... | Add MSI generating tool for python updating | Add MSI generating tool for python updating
| Python | apache-2.0 | int19h/PTVS,int19h/PTVS,int19h/PTVS,int19h/PTVS,int19h/PTVS,int19h/PTVS | ---
+++
@@ -0,0 +1,58 @@
+'''Quick and dirty script to generate vs.payload blocks for a set of URLs.
+
+Usage:
+ make_payload.py URL [URL ...]
+
+
+'''
+
+__author__ = 'Steve Dower <steve.dower@microsoft.com>'
+__version__ = '0.1'
+
+import hashlib
+import os
+import urllib.request
+import sys
+
+for u in sys.argv... | |
739e302506cb542011b8f022c6175637feaf20b4 | misc/disablepasscomplexity.py | misc/disablepasscomplexity.py | #!/usr/bin/env python
import pyghmi.util.webclient as webclient
import json
import os
import sys
tmppassword = 'to3BdS91ABrd'
missingargs = False
if 'XCCUSER' not in os.environ:
print('Must set XCCUSER environment variable')
missingargs = True
if 'XCCPASS' not in os.environ:
print('Must set XCCPASS environ... | Add an example for just disabling password complexity | Add an example for just disabling password complexity
| Python | apache-2.0 | jjohnson42/confluent,jjohnson42/confluent,xcat2/confluent,xcat2/confluent,jjohnson42/confluent,xcat2/confluent,jjohnson42/confluent,xcat2/confluent,xcat2/confluent,jjohnson42/confluent | ---
+++
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+import pyghmi.util.webclient as webclient
+import json
+import os
+import sys
+
+tmppassword = 'to3BdS91ABrd'
+missingargs = False
+if 'XCCUSER' not in os.environ:
+ print('Must set XCCUSER environment variable')
+ missingargs = True
+if 'XCCPASS' not in os.envir... | |
72c38a8b67b23080ab9fea7a6fd3405b2f88ad7a | wm_metrics/count_articles_improved_for_image_collection.py | wm_metrics/count_articles_improved_for_image_collection.py | # -*- coding: utf-8 -*-
"""Analysing a Glamorous report to identify articles improved."""
import sys
import xml.dom.minidom
def handle_node_attribute(node, tag_name, attribute_name):
"""Return the contents of a tag based on his given name inside of a given node."""
element = node.getElementsByTagName(tag_na... | Add script to compute articles improved for media collection | Add script to compute articles improved for media collection
| Python | mit | Commonists/wm_metrics,Commonists/wm_metrics,Commonists/wm_metrics,Commonists/wm_metrics | ---
+++
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+
+"""Analysing a Glamorous report to identify articles improved."""
+
+import sys
+import xml.dom.minidom
+
+
+def handle_node_attribute(node, tag_name, attribute_name):
+ """Return the contents of a tag based on his given name inside of a given node."""
+ elem... | |
bd2f302e2bcc02a3f222d0c00be9fe61351517e2 | flask_typecheck_decorator.py | flask_typecheck_decorator.py | #!/usr/bin/env python3
import json
from flask import Response, Flask, request
import inspect
from typecheck import typecheck
from typing import (
List,
Dict)
def typed_service(func):
def service():
print(request.json)
print(type(request.json))
args_... | Add first draft of Flask type check decorator | Add first draft of Flask type check decorator | Python | mit | jacopofar/runtime_typecheck | ---
+++
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+import json
+from flask import Response, Flask, request
+
+import inspect
+from typecheck import typecheck
+from typing import (
+ List,
+ Dict)
+
+
+def typed_service(func):
+ def service():
+ print(request.json)
+ ... | |
0b547b69c9e603f77de6d8855a2fe1f153ba49d5 | busshaming/fetch_realtime.py | busshaming/fetch_realtime.py | import os
from datetime import datetime, timedelta
import django
import pytz
import requests
from google.transit import gtfs_realtime_pb2
django.setup()
from busshaming.models import Feed, TripDate, RealtimeEntry, Stop
GTFS_API_KEY = os.environ.get('TRANSPORT_NSW_API_KEY')
def process_trip_update(trip_dates, stop... | Add script which logs realtime data into the db. | Add script which logs realtime data into the db.
| Python | mit | katharosada/bus-shaming,katharosada/bus-shaming,katharosada/bus-shaming,katharosada/bus-shaming,katharosada/bus-shaming | ---
+++
@@ -0,0 +1,65 @@
+import os
+from datetime import datetime, timedelta
+
+import django
+import pytz
+import requests
+from google.transit import gtfs_realtime_pb2
+
+django.setup()
+
+from busshaming.models import Feed, TripDate, RealtimeEntry, Stop
+
+GTFS_API_KEY = os.environ.get('TRANSPORT_NSW_API_KEY')
+
... | |
f226c81bbc7052dcac0993bacdaa4a93761b4dce | cvmfs/webapi/test-api.py | cvmfs/webapi/test-api.py | #! /usr/bin/env python
# This tester listens on port 8051 for a single http request, with
# a URL that starts with /api/v....
# It exits after one request.
# It assumes that GeoIP is already installed on the current machine
# with an installation of cvmfs-server, but reads the rest from
# the current directory.
fr... | Add this little development tester for webapi | Add this little development tester for webapi
| Python | bsd-3-clause | trshaffer/cvmfs,MicBrain/cvmfs,cvmfs-testing/cvmfs,alhowaidi/cvmfsNDN,Moliholy/cvmfs,alhowaidi/cvmfsNDN,trshaffer/cvmfs,DrDaveD/cvmfs,Moliholy/cvmfs,cvmfs/cvmfs,djw8605/cvmfs,reneme/cvmfs,MicBrain/cvmfs,cvmfs/cvmfs,Moliholy/cvmfs,trshaffer/cvmfs,cvmfs/cvmfs,alhowaidi/cvmfsNDN,cvmfs-testing/cvmfs,DrDaveD/cvmfs,Moliholy/... | ---
+++
@@ -0,0 +1,29 @@
+#! /usr/bin/env python
+
+# This tester listens on port 8051 for a single http request, with
+# a URL that starts with /api/v....
+# It exits after one request.
+# It assumes that GeoIP is already installed on the current machine
+# with an installation of cvmfs-server, but reads the rest ... | |
2dfd9cfc42e17f36446ff5da36e497bfff8d1d89 | sara_flexbe_states/src/sara_flexbe_states/Wonderland_Request.py | sara_flexbe_states/src/sara_flexbe_states/Wonderland_Request.py | #!/usr/bin/env python
# encoding=utf8
import requests
from flexbe_core import EventState, Logger
class Wonderland_Request(EventState):
'''
MoveArm receive a ROS pose as input and launch a ROS service with the same pose
># url string url to call
<= response string Finish job.
'''
def __init__(sel... | Add a state for send requests to Wonderland. | Add a state for send requests to Wonderland.
| Python | bsd-3-clause | WalkingMachine/sara_behaviors,WalkingMachine/sara_behaviors | ---
+++
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# encoding=utf8
+
+import requests
+from flexbe_core import EventState, Logger
+
+
+class Wonderland_Request(EventState):
+ '''
+ MoveArm receive a ROS pose as input and launch a ROS service with the same pose
+
+ ># url string url to call
+ <= response string ... | |
1f6ec9185edfe3469c5ae0c991a308a06599bcd9 | backend/globaleaks/db/migrations/update_22_23.py | backend/globaleaks/db/migrations/update_22_23.py | # -*- encoding: utf-8 -*-
from storm.locals import Int, Bool, Unicode, DateTime, JSON, Reference, ReferenceSet
from globaleaks.db.base_updater import TableReplacer
from globaleaks.models import BaseModel, Model
class InternalFile_v_22(Model):
__storm_table__ = 'internalfile'
internaltip_id = Unicode()
na... | Add migration script 22->23 (to be completed) | Add migration script 22->23 (to be completed)
| Python | agpl-3.0 | vodkina/GlobaLeaks,vodkina/GlobaLeaks,vodkina/GlobaLeaks,vodkina/GlobaLeaks | ---
+++
@@ -0,0 +1,35 @@
+# -*- encoding: utf-8 -*-
+
+from storm.locals import Int, Bool, Unicode, DateTime, JSON, Reference, ReferenceSet
+from globaleaks.db.base_updater import TableReplacer
+from globaleaks.models import BaseModel, Model
+
+
+class InternalFile_v_22(Model):
+ __storm_table__ = 'internalfile'
+... | |
604ce43cd9a66ae52224d174bc5743bcbfc86546 | test/test_url_parser.py | test/test_url_parser.py | import pytest
from lib.purl import Purl
from lib.purl_exc import *
class TestParserFunctions(object):
def test_simple_url(self):
str_url = 'http://blank'
url = Purl(str_url)
assert str(url) == str_url
str_url = 'https://blank'
url = Purl(str_url)
assert str(url) == str_url
str_url = '... | Add url parsing unit tests | Add url parsing unit tests
| Python | mit | ultrabluewolf/p.url | ---
+++
@@ -0,0 +1,69 @@
+import pytest
+
+from lib.purl import Purl
+from lib.purl_exc import *
+
+class TestParserFunctions(object):
+
+ def test_simple_url(self):
+ str_url = 'http://blank'
+ url = Purl(str_url)
+ assert str(url) == str_url
+
+ str_url = 'https://blank'
+ url = Purl(str_url)
+ a... | |
4a60fdf4896a41d52fc90e8a5f719976e605e8cc | lazy_helpers.py | lazy_helpers.py | # Lazy objects, for the serializer to find them we put them here
class LazyDriver(object):
_driver = None
def get(self):
if self._driver is None:
from selenium import webdriver
self._driver = webdriver.Firefox()
return self._driver
class LazyPool(object):
_poo... | Move the lazy classes out for the serializer to be able to find them | Move the lazy classes out for the serializer to be able to find them
| Python | apache-2.0 | holdenk/diversity-analytics,holdenk/diversity-analytics | ---
+++
@@ -0,0 +1,21 @@
+# Lazy objects, for the serializer to find them we put them here
+
+class LazyDriver(object):
+ _driver = None
+
+ def get(self):
+ if self._driver is None:
+ from selenium import webdriver
+ self._driver = webdriver.Firefox()
+ return self._driv... | |
d247427d60944d529fa17865ac4e0556a9ccda3f | tools/telemetry/telemetry/page/actions/navigate.py | tools/telemetry/telemetry/page/actions/navigate.py | # Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page.actions import page_action
class NavigateAction(page_action.PageAction):
def __init__(self, attributes=None):
super(NavigateAction... | # Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page.actions import page_action
class NavigateAction(page_action.PageAction):
def __init__(self, attributes=None):
super(NavigateAction... | Add a timeout attr to NavigateAction. | Add a timeout attr to NavigateAction.
BUG=320748
Review URL: https://codereview.chromium.org/202483006
git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@257922 0039d316-1c4b-4281-b951-d872f2087c98
| Python | bsd-3-clause | dushu1203/chromium.src,Just-D/chromium-1,krieger-od/nwjs_chromium.src,Fireblend/chromium-crosswalk,hgl888/chromium-crosswalk,ondra-novak/chromium.src,hgl888/chromium-crosswalk,markYoungH/chromium.src,crosswalk-project/chromium-crosswalk-efl,ltilve/chromium,dednal/chromium.src,PeterWangIntel/chromium-crosswalk,Just-D/ch... | ---
+++
@@ -14,5 +14,10 @@
else:
target_side_url = page.url
- tab.Navigate(target_side_url, page.script_to_evaluate_on_commit)
+ if hasattr(self, 'timeout_seconds') and self.timeout_seconds:
+ tab.Navigate(target_side_url,
+ page.script_to_evaluate_on_commit,
+ ... |
ee66b13c952118f85e0ce14264da29807e8ab814 | trunk/examples/gaussian_smoother.py | trunk/examples/gaussian_smoother.py | import matplotlib.pyplot as plt
x = np.linspace(-10, 10, 40)
y = np.linspace(-15, 15, 60)
Y,X = np.meshgrid(y,x)
noise = np.random.randn(*X.shape) * 10
data = X**2 + Y**2 + noise
data = np.ma.array(data, mask=((X**2 + Y**2) < 0.4))
data_filt = gaussian_filter(x, y, data, 4, 4)
plt.subplot(1, 2, 1)
plt.imshow(data.T,... | Add example using the gaussian smoother/filter. | Add example using the gaussian smoother/filter.
git-svn-id: acf0ef94bfce630b1a882387fc03ab8593ec6522@292 150532fb-1d5b-0410-a8ab-efec50f980d4
| Python | bsd-3-clause | dopplershift/MetPy,dopplershift/MetPy,deeplycloudy/MetPy,jrleeman/MetPy,ahaberlie/MetPy,ahaberlie/MetPy,ahill818/MetPy,Unidata/MetPy,jrleeman/MetPy,Unidata/MetPy,ShawnMurd/MetPy | ---
+++
@@ -0,0 +1,20 @@
+import matplotlib.pyplot as plt
+
+x = np.linspace(-10, 10, 40)
+y = np.linspace(-15, 15, 60)
+Y,X = np.meshgrid(y,x)
+noise = np.random.randn(*X.shape) * 10
+data = X**2 + Y**2 + noise
+data = np.ma.array(data, mask=((X**2 + Y**2) < 0.4))
+
+data_filt = gaussian_filter(x, y, data, 4, 4)
+
+... | |
62955786e7ffd2e961849860dfd2146ef611890c | src/logfile_values.py | src/logfile_values.py | #!/usr/bin/env python
#
# logfile_values.py
#
# Copyright (c) 2017, InnoGames GmbH
#
"""
logfile_values.py -- a python script to find metrics values in log file
This script is using last line of log file to get metric value by column number
python logfile_values.py --metric="metric1:1" --metric="metric2:2" ...
"""
f... | Add plugin to parse values from log file | Add plugin to parse values from log file
| Python | mit | innogames/igcollect | ---
+++
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# logfile_values.py
+#
+# Copyright (c) 2017, InnoGames GmbH
+#
+"""
+logfile_values.py -- a python script to find metrics values in log file
+
+This script is using last line of log file to get metric value by column number
+
+python logfile_values.py --metric="met... | |
a3dc1ebac114d1591dd9cdb211e6d975a10b0da3 | education/management/commands/reschedule_teacher_weekly_polls.py | education/management/commands/reschedule_teacher_weekly_polls.py | '''
Created on Feb 21, 2013
@author: raybesiga
'''
from django.core.management.base import BaseCommand
from education.models import reschedule_teacher_weekly_polls
from optparse import OptionParser, make_option
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option("-g", "... | Add new reschedule teacher weekly poll | Add new reschedule teacher weekly poll
| Python | bsd-3-clause | unicefuganda/edtrac,unicefuganda/edtrac,unicefuganda/edtrac | ---
+++
@@ -0,0 +1,24 @@
+'''
+Created on Feb 21, 2013
+
+@author: raybesiga
+'''
+
+from django.core.management.base import BaseCommand
+from education.models import reschedule_teacher_weekly_polls
+from optparse import OptionParser, make_option
+
+class Command(BaseCommand):
+
+ option_list = BaseCommand.opt... | |
d64e576e74ddc68364259ed4ca941165a9038a56 | tests/test_digitdestroyer.py | tests/test_digitdestroyer.py | from unittest import TestCase
from spicedham.digitdestroyer import DigitDestroyer
class TestDigitDestroyer(TestCase):
def test_classify(self):
dd = DigitDestroyer()
dd.filter_match = 1
dd.filter_miss = 0
match_message = ['1', '2', '3', '1', '1']
miss_message = ['a', '1... | Add a test for the digitdestroyer filter | Add a test for the digitdestroyer filter
| Python | mpl-2.0 | mozilla/spicedham,mozilla/spicedham | ---
+++
@@ -0,0 +1,15 @@
+from unittest import TestCase
+
+from spicedham.digitdestroyer import DigitDestroyer
+
+class TestDigitDestroyer(TestCase):
+
+ def test_classify(self):
+ dd = DigitDestroyer()
+ dd.filter_match = 1
+ dd.filter_miss = 0
+ match_message = ['1', '2', '3', '1'... | |
0fd33596d292f758a463f95dbbbcbbd729fd15cb | datatools/scripts/terms_from_marcframe.py | datatools/scripts/terms_from_marcframe.py | import json
def get_terms(marcframe):
terms = set()
for k, v in marcframe['entityTypeMap'].items():
terms.add(k)
terms.update(v.get('instanceTypes', []))
dfn_keys = {'property', 'addProperty', 'link', 'addLink', 'domainEntity', 'rangeEntity'}
def add_terms(dfn):
for k, v in dfn.... | Make simple script for finding terms used in marcframe | Make simple script for finding terms used in marcframe
| Python | apache-2.0 | libris/librisxl,libris/librisxl,libris/librisxl | ---
+++
@@ -0,0 +1,29 @@
+import json
+
+def get_terms(marcframe):
+ terms = set()
+ for k, v in marcframe['entityTypeMap'].items():
+ terms.add(k)
+ terms.update(v.get('instanceTypes', []))
+ dfn_keys = {'property', 'addProperty', 'link', 'addLink', 'domainEntity', 'rangeEntity'}
+ def add_... | |
64bb470bc58d6d467f4bd807f82cc56aa5e674bc | nova/tests/test_sqlalchemy.py | nova/tests/test_sqlalchemy.py | # vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2012 Rackspace Hosting
# 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.apach... | Add eventlet db_pool use for mysql | Add eventlet db_pool use for mysql
This adds the use of eventlet's db_pool module so that we can make mysql
calls without blocking the whole process.
New config options are introduced:
sql_dbpool_enable -- Enables the use of eventlet's db_pool
sql_min_pool_size -- Set the minimum number of SQL connections
The defau... | Python | apache-2.0 | n0ano/gantt,n0ano/gantt | ---
+++
@@ -0,0 +1,66 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+# Copyright (c) 2012 Rackspace Hosting
+# 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 Licen... | |
f10b89d8c2b847555223a4a025d78e1223f57696 | scripts/fork_my_feedstocks.py | scripts/fork_my_feedstocks.py | #!/usr/bin/env conda-execute
"""
This script can be run to fork conda-forge feedstocks to which you are a maintainer.
This is super useful if you maintain many feedstocks and would like to cutdown maintenance on your next PR...
Requires a token stored in the environment variable `GH_TOKEN` with the permissions `publi... | Add a script to fork all feedstocks one is a maintainer on. | scripts: Add a script to fork all feedstocks one is a maintainer on.
| Python | bsd-3-clause | conda-forge/conda-forge.github.io,conda-forge/conda-forge.github.io,conda-forge/conda-forge.github.io,conda-forge/conda-forge.github.io | ---
+++
@@ -0,0 +1,66 @@
+#!/usr/bin/env conda-execute
+
+"""
+This script can be run to fork conda-forge feedstocks to which you are a maintainer.
+This is super useful if you maintain many feedstocks and would like to cutdown maintenance on your next PR...
+
+Requires a token stored in the environment variable `GH_... | |
773a389f2ae69384f09cbada8b4b2615a7c430de | celery/tests/test_messaging.py | celery/tests/test_messaging.py | import unittest
from celery.messaging import MSG_OPTIONS, get_msg_options, extract_msg_options
class TestMsgOptions(unittest.TestCase):
def test_MSG_OPTIONS(self):
self.assertTrue(MSG_OPTIONS)
def test_extract_msg_options(self):
testing = {"mandatory": True, "routing_key": "foo.xuzzy"}
... | Add regression test for the message options bug. | Add regression test for the message options bug.
| Python | bsd-3-clause | frac/celery,cbrepo/celery,frac/celery,ask/celery,ask/celery,WoLpH/celery,mitsuhiko/celery,cbrepo/celery,mitsuhiko/celery,WoLpH/celery | ---
+++
@@ -0,0 +1,16 @@
+import unittest
+from celery.messaging import MSG_OPTIONS, get_msg_options, extract_msg_options
+
+
+class TestMsgOptions(unittest.TestCase):
+
+ def test_MSG_OPTIONS(self):
+ self.assertTrue(MSG_OPTIONS)
+
+ def test_extract_msg_options(self):
+ testing = {"mandatory": T... | |
4448f88734a3fb631a02aeb9b84675575226845d | examples/matplotlib/matplotlib_example.py | examples/matplotlib/matplotlib_example.py | # Copyright 2013 Christoph Reiter
#
# This library 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.
import sys
sys.path.insert... | Add a matplotlib example (needs cffi) | Add a matplotlib example (needs cffi)
| Python | lgpl-2.1 | lazka/pgi,lazka/pgi | ---
+++
@@ -0,0 +1,29 @@
+# Copyright 2013 Christoph Reiter
+#
+# This library 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 ver... | |
8d9eae677ef81ba3dcb000e528985276a920ef05 | test/test_loader.py | test/test_loader.py | from .helper import BJOTest
from bernard.actors import Locker, Notifier
from bernard.loader import YAMLLoader
from praw.models import Comment, Submission
class TestValidation(BJOTest):
def setUp(self):
super().setUp()
self.loader = YAMLLoader(self.db, self.cur, self.subreddit)
def test_bad_pa... | Add some tests for the new validation logic | Add some tests for the new validation logic
| Python | mit | leviroth/bernard | ---
+++
@@ -0,0 +1,26 @@
+from .helper import BJOTest
+from bernard.actors import Locker, Notifier
+from bernard.loader import YAMLLoader
+from praw.models import Comment, Submission
+
+
+class TestValidation(BJOTest):
+ def setUp(self):
+ super().setUp()
+ self.loader = YAMLLoader(self.db, self.cur,... | |
d727758e3db52327e7326b5f8546ecde06d409e7 | test/test_logger.py | test/test_logger.py | # encoding: utf-8
"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""
from __future__ import print_function
from __future__ import unicode_literals
from dataproperty import (
set_logger,
set_log_level,
)
import logbook
import pytest
class Test_set_logger(object):
@pytest.mark.param... | Add test cases for the logger | Add test cases for the logger
| Python | mit | thombashi/DataProperty | ---
+++
@@ -0,0 +1,49 @@
+# encoding: utf-8
+
+"""
+.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
+"""
+
+from __future__ import print_function
+from __future__ import unicode_literals
+
+from dataproperty import (
+ set_logger,
+ set_log_level,
+)
+import logbook
+import pytest
+
+
+class Tes... | |
0200c03f8f6232965f924a765c5ebb0f9c439f4d | sample_app/forms.py | sample_app/forms.py | from flask_wtf import Form
from wtforms.fields import (TextField, SubmitField, BooleanField, DateField,
DateTimeField)
from wtforms.validators import Required
class SignupForm(Form):
name = TextField(u'Your name', validators=[Required()])
birthday = DateField(u'Your birthday')
... | from flask_wtf import Form
from wtforms.fields import (TextField, SubmitField, BooleanField, DateField,
DateTimeField)
from wtforms.validators import Required, Email
class SignupForm(Form):
name = TextField(u'Your name', validators=[Required()])
email = TextField(u'Your email addre... | Add email field to sample app. | Add email field to sample app.
| Python | apache-2.0 | vishnugonela/flask-bootstrap,BeardedSteve/flask-bootstrap,livepy/flask-bootstrap,suvorom/flask-bootstrap,vishnugonela/flask-bootstrap,JingZhou0404/flask-bootstrap,vishnugonela/flask-bootstrap,BeardedSteve/flask-bootstrap,suvorom/flask-bootstrap,eshijia/flask-bootstrap,JingZhou0404/flask-bootstrap,moha24/flask-bootstrap... | ---
+++
@@ -1,11 +1,12 @@
from flask_wtf import Form
from wtforms.fields import (TextField, SubmitField, BooleanField, DateField,
DateTimeField)
-from wtforms.validators import Required
+from wtforms.validators import Required, Email
class SignupForm(Form):
name = TextField(u'... |
e97649a29a10ecc06eaa33b0898b2c22368e7102 | tests/tests_list.py | tests/tests_list.py |
#List of input files and reference databases
sim_files = [("./inputs/physor/1_Enrichment_2_Reactor.xml", "./benchmarks/physor_1_Enrichment_2_Reactor.h5"),
("./inputs/physor/2_Sources_3_Reactors.xml", "./benchmarks/physor_2_Sources_3_Reactors.h5")]
| Add python file with a list of simulation files. | Add python file with a list of simulation files.
| Python | bsd-3-clause | Baaaaam/cycamore,rwcarlsen/cycamore,Baaaaam/cyBaM,gonuke/cycamore,rwcarlsen/cycamore,gonuke/cycamore,cyclus/cycaless,Baaaaam/cyBaM,Baaaaam/cyCLASS,rwcarlsen/cycamore,Baaaaam/cyBaM,Baaaaam/cycamore,rwcarlsen/cycamore,gonuke/cycamore,Baaaaam/cyCLASS,jlittell/cycamore,Baaaaam/cyBaM,jlittell/cycamore,jlittell/cycamore,gonu... | ---
+++
@@ -0,0 +1,4 @@
+
+#List of input files and reference databases
+sim_files = [("./inputs/physor/1_Enrichment_2_Reactor.xml", "./benchmarks/physor_1_Enrichment_2_Reactor.h5"),
+ ("./inputs/physor/2_Sources_3_Reactors.xml", "./benchmarks/physor_2_Sources_3_Reactors.h5")] | |
8ce21d0d060fcaaea192f002d12c79101f4bc1a2 | corehq/apps/commtrack/management/commands/fix_default_program.py | corehq/apps/commtrack/management/commands/fix_default_program.py | from django.core.management.base import BaseCommand
from corehq.apps.commtrack.models import Program
from corehq.apps.domain.models import Domain
from corehq.apps.commtrack.util import get_or_create_default_program
class Command(BaseCommand):
help = 'Populate default program flag for domains'
def handle(self... | Add management command to migrate programs | Add management command to migrate programs
| Python | bsd-3-clause | dimagi/commcare-hq,puttarajubr/commcare-hq,puttarajubr/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,35 @@
+from django.core.management.base import BaseCommand
+from corehq.apps.commtrack.models import Program
+from corehq.apps.domain.models import Domain
+from corehq.apps.commtrack.util import get_or_create_default_program
+
+
+class Command(BaseCommand):
+ help = 'Populate default program fla... | |
b4a7e92bb8f3876c12982ef5f63ed1ad56f30ac7 | tests/parthole_test.py | tests/parthole_test.py | """Tests on the particle-hole model."""
import pytest
from drudge import PartHoleDrudge, CR, AN
from drudge.wick import wick_expand
@pytest.fixture(scope='module')
def parthole(spark_ctx):
"""Initialize the environment for a free algebra."""
dr = PartHoleDrudge(spark_ctx)
return dr
def test_parthole_n... | Add minimal tests for PartHoleDrudge | Add minimal tests for PartHoleDrudge
Here only the number of terms in the different forms of the Hamiltonian
is checked. It should later be replaced with actual value inspection.
| Python | mit | tschijnmo/drudge,tschijnmo/drudge,tschijnmo/drudge | ---
+++
@@ -0,0 +1,57 @@
+"""Tests on the particle-hole model."""
+
+import pytest
+
+from drudge import PartHoleDrudge, CR, AN
+from drudge.wick import wick_expand
+
+
+@pytest.fixture(scope='module')
+def parthole(spark_ctx):
+ """Initialize the environment for a free algebra."""
+ dr = PartHoleDrudge(spark_c... | |
2ff14d38266322d3e428c29a01a3de5015269166 | package/src/get_rss_feeds.py | package/src/get_rss_feeds.py | # Chap07/blogs_rss_get_posts.py
import json
from argparse import ArgumentParser
import feedparser
def get_parser():
parser = ArgumentParser()
parser.add_argument('--rss-url')
parser.add_argument('--json')
return parser
if __name__ == '__main__':
parser = get_parser()
args = parser.parse_args... | Add minimal feed sourcing example | Add minimal feed sourcing example
| Python | mit | MrKriss/full-fact-rss-miner | ---
+++
@@ -0,0 +1,22 @@
+# Chap07/blogs_rss_get_posts.py
+import json
+from argparse import ArgumentParser
+import feedparser
+
+
+def get_parser():
+ parser = ArgumentParser()
+ parser.add_argument('--rss-url')
+ parser.add_argument('--json')
+ return parser
+
+
+if __name__ == '__main__':
+ parser =... | |
bf3a32714e43fdb4abc226c5c353ccfc10448854 | spark/wordcount.py | spark/wordcount.py | from pyspark import SparkConf, SparkContext
import sys
if __name__ == "__main__":
if len(sys.argv) != 3:
print "Incorrect number of arguments, correct usage: wordcount.py [inputfile] [outputfile]"
sys.exit(-1)
# set input and dictionary from args
input = sys.argv[1]
output = sys.argv[... | Add Spark Python word count program | Add Spark Python word count program
| Python | mit | bbengfort/hadoop-fundamentals,bbengfort/hadoop-fundamentals,bbengfort/hadoop-fundamentals,cycuq/hadoop-fundamentals-for-data-scientists,sssllliang/hadoop-fundamentals,nvoron23/hadoop-fundamentals | ---
+++
@@ -0,0 +1,26 @@
+from pyspark import SparkConf, SparkContext
+import sys
+
+
+if __name__ == "__main__":
+ if len(sys.argv) != 3:
+ print "Incorrect number of arguments, correct usage: wordcount.py [inputfile] [outputfile]"
+ sys.exit(-1)
+
+ # set input and dictionary from args
+ inpu... | |
244d95937c1fbae6a0f415cbdcbd4ed65cc6d8c4 | CodeFights/prefSum.py | CodeFights/prefSum.py | #!/usr/local/bin/python
# Code Fights Pref Sum Problem
from itertools import accumulate
def prefSum(a):
return list(accumulate(a))
def main():
tests = [
[[1, 2, 3], [1, 3, 6]],
[[1, 2, 3, -6], [1, 3, 6, 0]],
[[0, 0, 0], [0, 0, 0]]
]
for t in tests:
res = prefSum(t[0... | Solve Code Fights pref sum problem | Solve Code Fights pref sum problem
| Python | mit | HKuz/Test_Code | ---
+++
@@ -0,0 +1,30 @@
+#!/usr/local/bin/python
+# Code Fights Pref Sum Problem
+
+from itertools import accumulate
+
+
+def prefSum(a):
+ return list(accumulate(a))
+
+
+def main():
+ tests = [
+ [[1, 2, 3], [1, 3, 6]],
+ [[1, 2, 3, -6], [1, 3, 6, 0]],
+ [[0, 0, 0], [0, 0, 0]]
+ ]
+
+... | |
6c8cdc4460204cf4ffcb9b1a42da3ba7bb469031 | py/g1/asyncs/kernels/tests/test_public.py | py/g1/asyncs/kernels/tests/test_public.py | import unittest
from g1.asyncs import kernels
class KernelsTest(unittest.TestCase):
"""Test ``g1.asyncs.kernels`` public interface."""
def test_contexts(self):
self.assertIsNone(kernels.get_kernel())
self.assertEqual(kernels.get_all_tasks(), [])
self.assertIsNone(kernels.get_current... | Add unit test of g1.asyncs.kernels public interface | Add unit test of g1.asyncs.kernels public interface
| Python | mit | clchiou/garage,clchiou/garage,clchiou/garage,clchiou/garage | ---
+++
@@ -0,0 +1,48 @@
+import unittest
+
+from g1.asyncs import kernels
+
+
+class KernelsTest(unittest.TestCase):
+ """Test ``g1.asyncs.kernels`` public interface."""
+
+ def test_contexts(self):
+
+ self.assertIsNone(kernels.get_kernel())
+ self.assertEqual(kernels.get_all_tasks(), [])
+ ... | |
c0496d83049e02db718941b7cdd6fa0bacd28ce2 | python-tools/mods/raven/transport/http.py | python-tools/mods/raven/transport/http.py | # See https://github.com/getsentry/raven-python/issues/1109
"""
raven.transport.http
~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import
import requests
from raven.utils.compat import s... | Add raven SSL fix mod. | Add raven SSL fix mod.
See https://github.com/getsentry/raven-python/issues/1109.
| Python | mit | Mediamoose/python-tools | ---
+++
@@ -0,0 +1,60 @@
+# See https://github.com/getsentry/raven-python/issues/1109
+
+"""
+raven.transport.http
+~~~~~~~~~~~~~~~~~~~~
+:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
+:license: BSD, see LICENSE for more details.
+"""
+from __future__ import absolute_import
+import reque... | |
0ac7a79dda372763c88b237e269aa9f955b88fdd | Titanic_Survival_Exploration/Titanic_Surv_Expl.py | Titanic_Survival_Exploration/Titanic_Surv_Expl.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 16 15:53:32 2017
@author: Anani Assoutovi
"""
import numpy as np
import pandas as pd | Add A new Folder and file @AnaniSkywalker | Add A new Folder and file @AnaniSkywalker
| Python | mit | AnaniSkywalker/UDACITY_Machine_Learning,AnaniSkywalker/UDACITY_Machine_Learning | ---
+++
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Sun Jul 16 15:53:32 2017
+
+@author: Anani Assoutovi
+"""
+
+import numpy as np
+import pandas as pd | |
d73dfec24b2b77edcab5a1daf1acb35640320aa4 | Lib/test/test_platform.py | Lib/test/test_platform.py | import unittest
from test import test_support
import platform
class PlatformTest(unittest.TestCase):
def test_architecture(self):
res = platform.architecture()
def test_machine(self):
res = platform.machine()
def test_node(self):
res = platform.node()
def test_platform(self):... | Add a rudimentary test for the platform module that at least calls each documented function once. | Add a rudimentary test for the platform module that at least calls each
documented function once.
| Python | mit | sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator | ---
+++
@@ -0,0 +1,74 @@
+import unittest
+from test import test_support
+import platform
+
+class PlatformTest(unittest.TestCase):
+ def test_architecture(self):
+ res = platform.architecture()
+
+ def test_machine(self):
+ res = platform.machine()
+
+ def test_node(self):
+ res = platf... | |
3a06a24c5ce0e5357dfc87eccfc198fd05e881e4 | corehq/apps/es/tests/test_user_es.py | corehq/apps/es/tests/test_user_es.py | import uuid
from django.test import TestCase
from pillowtop.es_utils import initialize_index_and_mapping
from corehq.apps.domain.shortcuts import create_domain
from corehq.apps.es import UserES
from corehq.apps.es.tests.utils import es_test
from corehq.apps.users.dbaccessors.all_commcare_users import delete_all_user... | Write a basic test for filtering by user data | Write a basic test for filtering by user data
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,52 @@
+import uuid
+
+from django.test import TestCase
+
+from pillowtop.es_utils import initialize_index_and_mapping
+
+from corehq.apps.domain.shortcuts import create_domain
+from corehq.apps.es import UserES
+from corehq.apps.es.tests.utils import es_test
+from corehq.apps.users.dbaccessors.all_... | |
5b333f9547908db05663afacc7487749dda168fc | dynd/tests/test_array_as_py.py | dynd/tests/test_array_as_py.py | import sys
import unittest
from dynd import nd, ndt
class TestArrayAsPy(unittest.TestCase):
def test_struct_or_tuple(self):
a = nd.array((3, "testing", 1.5), type='{x:int, y:string, z:real}')
self.assertEqual(nd.as_py(a), {'x': 3, 'y': "testing", 'z': 1.5})
self.assertEqual(nd.as_py(a, tupl... | Add tests for tuple option to nd.as_py | Add tests for tuple option to nd.as_py
| Python | bsd-2-clause | pombredanne/dynd-python,pombredanne/dynd-python,ContinuumIO/dynd-python,insertinterestingnamehere/dynd-python,izaid/dynd-python,pombredanne/dynd-python,izaid/dynd-python,insertinterestingnamehere/dynd-python,insertinterestingnamehere/dynd-python,mwiebe/dynd-python,michaelpacer/dynd-python,aterrel/dynd-python,cpcloud/dy... | ---
+++
@@ -0,0 +1,51 @@
+import sys
+import unittest
+from dynd import nd, ndt
+
+class TestArrayAsPy(unittest.TestCase):
+ def test_struct_or_tuple(self):
+ a = nd.array((3, "testing", 1.5), type='{x:int, y:string, z:real}')
+ self.assertEqual(nd.as_py(a), {'x': 3, 'y': "testing", 'z': 1.5})
+ ... | |
55017eadf948fb951e6303cd4c914c968d6f60b2 | cmsplugin_contact/migrations_django/0003_auto_20161107_1614.py | cmsplugin_contact/migrations_django/0003_auto_20161107_1614.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2016-11-07 15:14
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cmsplugin_contact', '0002_auto_20160810_1130'),
]
o... | Add an auto-generated missing migration | Add an auto-generated missing migration
| Python | bsd-2-clause | maccesch/cmsplugin-contact,maccesch/cmsplugin-contact | ---
+++
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.9 on 2016-11-07 15:14
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('cmsplugin_contact', '... | |
dccd8403a93a0c86054d61142198643d30b8d9af | migrations/versions/0c98b865104f_add_score_user_id_column.py | migrations/versions/0c98b865104f_add_score_user_id_column.py | """Add score.user_id column
Revision ID: 0c98b865104f
Revises: 7b6a65c708b9
Create Date: 2016-10-27 19:03:44.901639
"""
# revision identifiers, used by Alembic.
revision = '0c98b865104f'
down_revision = '7b6a65c708b9'
from alembic import op
import sqlalchemy as sa
import server
def upgrade():
op.add_column('s... | Add migration that sets score.user_id appropriately | Add migration that sets score.user_id appropriately
| Python | apache-2.0 | Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok | ---
+++
@@ -0,0 +1,34 @@
+"""Add score.user_id column
+
+Revision ID: 0c98b865104f
+Revises: 7b6a65c708b9
+Create Date: 2016-10-27 19:03:44.901639
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '0c98b865104f'
+down_revision = '7b6a65c708b9'
+
+from alembic import op
+import sqlalchemy as sa
+import se... | |
b2bef05e0490d161ecec07b4403964c19875ee5d | numba/cuda/tests/nocuda/test_function_resolution.py | numba/cuda/tests/nocuda/test_function_resolution.py | from numba.cuda.testing import unittest, skip_on_cudasim
import operator
from numba.core import types, typing
@skip_on_cudasim("Skip on simulator due to use of cuda_target")
class TestFunctionResolutionNoCuda(unittest.TestCase):
def test_fp16_binary_operators(self):
from numba.cuda.descriptor import cuda_... | Add new case for function resolution of fp16 unary and binary operators | Add new case for function resolution of fp16 unary and binary operators
| Python | bsd-2-clause | numba/numba,cpcloud/numba,cpcloud/numba,cpcloud/numba,numba/numba,numba/numba,numba/numba,cpcloud/numba,numba/numba,cpcloud/numba | ---
+++
@@ -0,0 +1,35 @@
+from numba.cuda.testing import unittest, skip_on_cudasim
+import operator
+from numba.core import types, typing
+
+
+@skip_on_cudasim("Skip on simulator due to use of cuda_target")
+class TestFunctionResolutionNoCuda(unittest.TestCase):
+ def test_fp16_binary_operators(self):
+ fro... | |
c456ec0a5dd4c48b13d82930eab32c85bcc0e7be | migrations/versions/75f579d01f0d_.py | migrations/versions/75f579d01f0d_.py | """empty message
Revision ID: 75f579d01f0d
Revises: 25f4f234760c
Create Date: 2017-05-06 23:15:02.228272
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '75f579d01f0d'
down_revision = '25f4f234760c'
branch_labels = None
depends_on = None
def upgrade():
# ... | Add short_url column to Graph | Add short_url column to Graph
Make username a nullable field in Graph, so people don't have to
register to share graphs.
| Python | mit | stardust66/math3d,ChristopherChudzicki/math3d,ChristopherChudzicki/math3d,stardust66/math3d,ChristopherChudzicki/math3d,ChristopherChudzicki/math3d,stardust66/math3d,stardust66/math3d | ---
+++
@@ -0,0 +1,28 @@
+"""empty message
+
+Revision ID: 75f579d01f0d
+Revises: 25f4f234760c
+Create Date: 2017-05-06 23:15:02.228272
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '75f579d01f0d'
+down_revision = '25f4f234760c'
+branch_labels = None... | |
189ec6dabc25eb91335568a7e6547483f9ec2960 | modules/tools/extractor/extractor.py | modules/tools/extractor/extractor.py | #!/usr/bin/env python
###############################################################################
# Copyright 2017 The Apollo Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy ... | Add tool to extract routing from planning debug | Add tool to extract routing from planning debug
| Python | apache-2.0 | ApolloAuto/apollo,ycool/apollo,ApolloAuto/apollo,xiaoxq/apollo,xiaoxq/apollo,ycool/apollo,ycool/apollo,ycool/apollo,jinghaomiao/apollo,wanglei828/apollo,wanglei828/apollo,ycool/apollo,ApolloAuto/apollo,jinghaomiao/apollo,jinghaomiao/apollo,jinghaomiao/apollo,xiaoxq/apollo,wanglei828/apollo,wanglei828/apollo,xiaoxq/apol... | ---
+++
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+###############################################################################
+# Copyright 2017 The Apollo Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the... | |
0e98d0fae4a81deec57ae162b8db5bcf950b3ea3 | cnxarchive/sql/migrations/20160128110515_mimetype_on_files_table.py | cnxarchive/sql/migrations/20160128110515_mimetype_on_files_table.py | # -*- coding: utf-8 -*-
"""\
- Add a ``media_type`` column to the ``files`` table.
- Move the mimetype value from ``module_files`` to ``files``.
"""
from __future__ import print_function
import sys
def up(cursor):
# Add a ``media_type`` column to the ``files`` table.
cursor.execute("ALTER TABLE files ADD COL... | Move mimetype column from module_files to files | Move mimetype column from module_files to files
| Python | agpl-3.0 | Connexions/cnx-archive,Connexions/cnx-archive | ---
+++
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+"""\
+- Add a ``media_type`` column to the ``files`` table.
+- Move the mimetype value from ``module_files`` to ``files``.
+
+"""
+from __future__ import print_function
+import sys
+
+
+def up(cursor):
+ # Add a ``media_type`` column to the ``files`` table.
+ c... | |
ce9657eec421eb626f22405ab744f1554d8c376f | src/utils/clean_categories.py | src/utils/clean_categories.py | import re
def clean_categories(text):
"""Replace Wikipedia category links with the name of the category in the
text of an article.
Text like "[[Category:Foo]]" will be replaced with "Foo". Sorting hints are
thrown away during this cleaning, so text like "[[Category:Bar|Sorting
hint]]" will be repla... | Add script to clean Wikipedia categories | Add script to clean Wikipedia categories
| Python | apache-2.0 | tiffanyj41/hermes,tiffanyj41/hermes,tiffanyj41/hermes,tiffanyj41/hermes | ---
+++
@@ -0,0 +1,48 @@
+import re
+def clean_categories(text):
+ """Replace Wikipedia category links with the name of the category in the
+ text of an article.
+
+ Text like "[[Category:Foo]]" will be replaced with "Foo". Sorting hints are
+ thrown away during this cleaning, so text like "[[Category:Bar... | |
190153d06864b64275fbd515c2f1a2b8c8a5cdba | tests/test_specs.py | tests/test_specs.py | from imagekit.cachefiles import ImageCacheFile
from nose.tools import assert_false
from .imagegenerators import TestSpec
def test_no_source():
"""
Ensure sourceless specs are falsy.
"""
spec = TestSpec(source=None)
file = ImageCacheFile(spec)
assert_false(bool(file))
| Add test to ensure sourceless specs are falsy | Add test to ensure sourceless specs are falsy
Currently failing; related to #187
| Python | bsd-3-clause | tawanda/django-imagekit,FundedByMe/django-imagekit,FundedByMe/django-imagekit,tawanda/django-imagekit | ---
+++
@@ -0,0 +1,12 @@
+from imagekit.cachefiles import ImageCacheFile
+from nose.tools import assert_false
+from .imagegenerators import TestSpec
+
+
+def test_no_source():
+ """
+ Ensure sourceless specs are falsy.
+ """
+ spec = TestSpec(source=None)
+ file = ImageCacheFile(spec)
+ assert_false... | |
c831bfb8e5e28fdcf0dff818dd08274fa2fdb5cd | scripts/consistency/fix_tag_guids.py | scripts/consistency/fix_tag_guids.py | """Removes legacy Tag objects from the Guid namespace.
Tags were once GuidStoredObjects, but are no longer. The Guid table was not
cleaned of these references.
This caused a specific issue where "project" was a Tag id, and therefore was
resolveable to a Guid object, thereby breaking our routing system for URLs
beginn... | Refactor of migration script for migrating invalid Guid objects | Refactor of migration script for migrating invalid Guid objects
- Remove import side effects
- Add tests
| Python | apache-2.0 | lyndsysimon/osf.io,binoculars/osf.io,doublebits/osf.io,rdhyee/osf.io,arpitar/osf.io,brandonPurvis/osf.io,abought/osf.io,erinspace/osf.io,chennan47/osf.io,felliott/osf.io,aaxelb/osf.io,Ghalko/osf.io,leb2dg/osf.io,cldershem/osf.io,mattclark/osf.io,SSJohns/osf.io,baylee-d/osf.io,cslzchen/osf.io,felliott/osf.io,zamattiac/o... | ---
+++
@@ -0,0 +1,71 @@
+"""Removes legacy Tag objects from the Guid namespace.
+
+Tags were once GuidStoredObjects, but are no longer. The Guid table was not
+cleaned of these references.
+
+This caused a specific issue where "project" was a Tag id, and therefore was
+resolveable to a Guid object, thereby breaking ... | |
efc21569590e90bddaf9d06ea3747f3dd3476253 | aqt/utils/common.py | aqt/utils/common.py | # coding=utf-8
# Copyright 2021 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | Create a new util function that computes precision for floating-point quantization. | Create a new util function that computes precision for floating-point quantization.
PiperOrigin-RevId: 395302655
| Python | apache-2.0 | google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,... | ---
+++
@@ -0,0 +1,31 @@
+# coding=utf-8
+# Copyright 2021 The Google Research Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-... | |
3209a38b795cb5519f92bbfc2651df5b69ba0f76 | moderation_queue/migrations/0008_add_ignore_to_decision_choices.py | moderation_queue/migrations/0008_add_ignore_to_decision_choices.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('moderation_queue', '0007_auto_20150303_1420'),
]
operations = [
migrations.AlterField(
model_name='queuedimage',... | Add a forgotten migration (to add 'ignore' as a decision choice) | Add a forgotten migration (to add 'ignore' as a decision choice)
This should have gone into d5086f1d74d448
| Python | agpl-3.0 | mysociety/yournextmp-popit,datamade/yournextmp-popit,YoQuieroSaber/yournextrepresentative,neavouli/yournextrepresentative,DemocracyClub/yournextrepresentative,neavouli/yournextrepresentative,DemocracyClub/yournextrepresentative,mysociety/yournextrepresentative,YoQuieroSaber/yournextrepresentative,mysociety/yournextrepr... | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('moderation_queue', '0007_auto_20150303_1420'),
+ ]
+
+ operations = [
+ migrations.AlterFie... | |
883707309447fa4edd47459b4f2d8e7d449afd41 | array/80.py | array/80.py | class Solution:
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
length = len(nums)
pre = 0
cur = 1
flag = False #False 1连续 True 2连续
while cur < length:
i... | Remove Duplicates from Sorted Array II | Remove Duplicates from Sorted Array II
| Python | apache-2.0 | MingfeiPan/leetcode,MingfeiPan/leetcode,MingfeiPan/leetcode,MingfeiPan/leetcode,MingfeiPan/leetcode | ---
+++
@@ -0,0 +1,33 @@
+class Solution:
+ def removeDuplicates(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+
+ if not nums:
+ return 0
+ length = len(nums)
+ pre = 0
+ cur = 1
+ flag = False #False 1连续 True 2连续
+... | |
087ba4c6bb7f268eb11584e4dbcf449e08fcaf0b | analysis/10-extract-jacobian-chunks.py | analysis/10-extract-jacobian-chunks.py | import climate
import joblib
import numpy as np
def extract(trial, output, frames):
dirname = os.path.join(output, trial.subject.key)
pattern = '{}-{}-{{}}.npy'.format(trial.block.key, trial.key)
if not os.path.isdir(dirname):
os.makedirs(dirname)
def save(key, arr):
out = os.path.joi... | Add a script for saving paired posture/jacobian arrays. | Add a script for saving paired posture/jacobian arrays.
| Python | mit | lmjohns3/cube-experiment,lmjohns3/cube-experiment,lmjohns3/cube-experiment | ---
+++
@@ -0,0 +1,43 @@
+import climate
+import joblib
+import numpy as np
+
+
+def extract(trial, output, frames):
+ dirname = os.path.join(output, trial.subject.key)
+ pattern = '{}-{}-{{}}.npy'.format(trial.block.key, trial.key)
+ if not os.path.isdir(dirname):
+ os.makedirs(dirname)
+
+ def sa... | |
7b33ea38283c9e9f00a2aacaa17634e50e55e42b | stationspinner/accounting/migrations/0005_auto_20150919_2207.py | stationspinner/accounting/migrations/0005_auto_20150919_2207.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.core.validators
import django.contrib.auth.models
class Migration(migrations.Migration):
dependencies = [
('accounting', '0004_apikey_brokeness'),
]
operations = [
migr... | Migrate auth for django 1.8 | Migrate auth for django 1.8
| Python | agpl-3.0 | kriberg/stationspinner,kriberg/stationspinner | ---
+++
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import django.core.validators
+import django.contrib.auth.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('accounting', '0004_apikey_brokeness'),... | |
23b4ad3b028e674307fdc6cc7a72953150fd0be3 | zephyr/management/commands/check_redis.py | zephyr/management/commands/check_redis.py | from __future__ import absolute_import
from zephyr.models import UserProfile, get_user_profile_by_id
from zephyr.lib.rate_limiter import redis_key, client, max_api_calls, max_api_window
from django.core.management.base import BaseCommand
from django.conf import settings
from optparse import make_option
import os, ti... | Add a redis_check management command | Add a redis_check management command
(imported from commit 04a272ca8d8288f7e3b1a54fd5d73629bde938a0)
| Python | apache-2.0 | bitemyapp/zulip,cosmicAsymmetry/zulip,mahim97/zulip,jessedhillon/zulip,esander91/zulip,Diptanshu8/zulip,JPJPJPOPOP/zulip,akuseru/zulip,RobotCaleb/zulip,m1ssou/zulip,ApsOps/zulip,AZtheAsian/zulip,themass/zulip,vabs22/zulip,zhaoweigg/zulip,wangdeshui/zulip,rishig/zulip,alliejones/zulip,ashwinirudrappa/zulip,Gabriel0402/z... | ---
+++
@@ -0,0 +1,66 @@
+from __future__ import absolute_import
+
+from zephyr.models import UserProfile, get_user_profile_by_id
+from zephyr.lib.rate_limiter import redis_key, client, max_api_calls, max_api_window
+
+from django.core.management.base import BaseCommand
+from django.conf import settings
+from optpars... | |
29ed484c77ab1c68c5e81f06a527da49713ee427 | euler020.py | euler020.py | #!/usr/bin/python
from math import factorial
fact = str(factorial(100))
result = 0
for i in range(len(fact)):
result += int(fact[i])
print(result)
| Add solution for problem 20 | Add solution for problem 20
| Python | mit | cifvts/PyEuler | ---
+++
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+
+from math import factorial
+
+fact = str(factorial(100))
+
+result = 0
+for i in range(len(fact)):
+ result += int(fact[i])
+
+print(result) | |
073bcb1f6f495305c9d02300646e269fcd2b920e | hc/api/migrations/0059_auto_20190314_1744.py | hc/api/migrations/0059_auto_20190314_1744.py | # Generated by Django 2.1.7 on 2019-03-14 17:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0058_auto_20190312_1716'),
]
operations = [
migrations.AlterField(
model_name='channel',
name='kind',
... | Add migration (autogenerated via `manage.py makemigrations`) | Add migration (autogenerated via `manage.py makemigrations`)
| Python | bsd-3-clause | healthchecks/healthchecks,iphoting/healthchecks,healthchecks/healthchecks,iphoting/healthchecks,healthchecks/healthchecks,iphoting/healthchecks,healthchecks/healthchecks,iphoting/healthchecks | ---
+++
@@ -0,0 +1,18 @@
+# Generated by Django 2.1.7 on 2019-03-14 17:44
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0058_auto_20190312_1716'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='c... | |
75f69d02100e4f804fd6e742841c0e5ecb1731d2 | algorithms/graph-theory/prims-mst-special-subtree/prims-mst.py | algorithms/graph-theory/prims-mst-special-subtree/prims-mst.py | #!/usr/bin/env python
import sys
from queue import PriorityQueue
class Graph(object):
"""
Represents a graph using an adjacency list.
"""
def __init__(self, N):
self.nodes = [None] * N
def add_undir_edge(self, x, y, r):
self.add_dir_edge(x, y, r)
self.add_dir_edge(y, x, r... | Implement Prim's MST in Python | Implement Prim's MST in Python
| Python | mit | andreimaximov/algorithms,andreimaximov/algorithms,andreimaximov/algorithms,andreimaximov/algorithms | ---
+++
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+
+import sys
+from queue import PriorityQueue
+
+
+class Graph(object):
+ """
+ Represents a graph using an adjacency list.
+ """
+ def __init__(self, N):
+ self.nodes = [None] * N
+
+ def add_undir_edge(self, x, y, r):
+ self.add_dir_edge(... | |
5b29eaacb363501c9596061a1bd197c49bb00db3 | qa/manage_crypto_listings.py | qa/manage_crypto_listings.py | import requests
import json
import time
from collections import OrderedDict
from test_framework.test_framework import OpenBazaarTestFramework, TestFailure
class ManageCryptoListingsTest(OpenBazaarTestFramework):
def __init__(self):
super().__init__()
self.num_nodes = 1
def run_test(self):
... | Add crypto listing management qa test and test listings index. | TESTS: Add crypto listing management qa test and test listings index.
| Python | mit | OpenBazaar/openbazaar-go,gubatron/openbazaar-go,hoffmabc/openbazaar-go,hoffmabc/openbazaar-go,OpenBazaar/openbazaar-go,hoffmabc/openbazaar-go,gubatron/openbazaar-go,OpenBazaar/openbazaar-go,gubatron/openbazaar-go | ---
+++
@@ -0,0 +1,67 @@
+import requests
+import json
+import time
+from collections import OrderedDict
+from test_framework.test_framework import OpenBazaarTestFramework, TestFailure
+
+
+class ManageCryptoListingsTest(OpenBazaarTestFramework):
+
+ def __init__(self):
+ super().__init__()
+ self.nu... | |
a29540ea36ab4e73ba3d89fc8ed47022af28b482 | readthedocs/rtd_tests/tests/test_build_storage.py | readthedocs/rtd_tests/tests/test_build_storage.py | import os
import shutil
import tempfile
from django.test import TestCase
from readthedocs.builds.storage import BuildMediaFileSystemStorage
files_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'files')
class TestBuildMediaStorage(TestCase):
def setUp(self):
self.test_media_dir = tempfi... | Add tests for the build media storage | Add tests for the build media storage
| Python | mit | rtfd/readthedocs.org,rtfd/readthedocs.org,rtfd/readthedocs.org,rtfd/readthedocs.org | ---
+++
@@ -0,0 +1,52 @@
+import os
+import shutil
+import tempfile
+
+from django.test import TestCase
+
+from readthedocs.builds.storage import BuildMediaFileSystemStorage
+
+
+files_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'files')
+
+
+class TestBuildMediaStorage(TestCase):
+ def setUp(se... | |
7ed7cab1cc41fea7665d9e9c05cbb2eb097486a3 | appointment/migrations/0002_vaccineappointment_20181031_1852.py | appointment/migrations/0002_vaccineappointment_20181031_1852.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2018-10-31 23:52
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('appointment', '0001_initial'),
]
... | Add migration for vaccine appointment update. | Add migration for vaccine appointment update.
| Python | mit | SaturdayNeighborhoodHealthClinic/clintools,SaturdayNeighborhoodHealthClinic/clintools,SaturdayNeighborhoodHealthClinic/clintools | ---
+++
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.1 on 2018-10-31 23:52
+from __future__ import unicode_literals
+
+import datetime
+from django.db import migrations, models
+from django.utils.timezone import utc
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ (... | |
c46731098c6a8f26e4de899d2d2e083734f6772f | numpy/typing/tests/test_typing_extensions.py | numpy/typing/tests/test_typing_extensions.py | """Tests for the optional typing-extensions dependency."""
import sys
import types
import inspect
import importlib
import typing_extensions
import numpy.typing as npt
def _is_sub_module(obj: object) -> bool:
"""Check if `obj` is a `numpy.typing` submodule."""
return inspect.ismodule(obj) and obj.__name__.st... | Test that `numpy.typing` can be imported in the the absence of typing-extensions | TST: Test that `numpy.typing` can be imported in the the absence of typing-extensions
| Python | bsd-3-clause | pdebuyl/numpy,rgommers/numpy,charris/numpy,anntzer/numpy,numpy/numpy,rgommers/numpy,mhvk/numpy,seberg/numpy,pdebuyl/numpy,endolith/numpy,jakirkham/numpy,mattip/numpy,mhvk/numpy,simongibbons/numpy,numpy/numpy,endolith/numpy,simongibbons/numpy,pdebuyl/numpy,simongibbons/numpy,endolith/numpy,anntzer/numpy,seberg/numpy,num... | ---
+++
@@ -0,0 +1,56 @@
+"""Tests for the optional typing-extensions dependency."""
+
+import sys
+import types
+import inspect
+import importlib
+
+import typing_extensions
+import numpy.typing as npt
+
+
+def _is_sub_module(obj: object) -> bool:
+ """Check if `obj` is a `numpy.typing` submodule."""
+ return ... | |
0a6f6db77dd888b810089659100158ed4e8e3cee | test/test_object_factory.py | test/test_object_factory.py | import unittest
import groundstation.objects.object_factory as object_factory
from groundstation.objects.root_object import RootObject
from groundstation.objects.update_object import UpdateObject
class TestRootObject(unittest.TestCase):
def test_hydrate_root_object(self):
root = RootObject(
... | Add tests for the object factory with various permutations | Add tests for the object factory with various permutations
| Python | mit | richo/groundstation,richo/groundstation,richo/groundstation,richo/groundstation,richo/groundstation | ---
+++
@@ -0,0 +1,33 @@
+import unittest
+import groundstation.objects.object_factory as object_factory
+from groundstation.objects.root_object import RootObject
+from groundstation.objects.update_object import UpdateObject
+
+
+class TestRootObject(unittest.TestCase):
+ def test_hydrate_root_object(self):
+ ... | |
93bc13af093186b3a74570882135b81ddeeb6719 | drudge/term.py | drudge/term.py | """Tensor term definition and utility."""
from sympy import sympify
class Range:
"""A symbolic range that can be summed over.
This class is for symbolic ranges that is going to be summed over in
tensors. Each range should have a label, and optionally lower and upper
bounds, which should be both giv... | Add class for symbolic ranges | Add class for symbolic ranges
Compared with PySLATA, this definition is a lot more simplified. All
the ranges are assumed to be atomic and disjoint. No need to implement
the range arithmetic.
| Python | mit | tschijnmo/drudge,tschijnmo/drudge,tschijnmo/drudge | ---
+++
@@ -0,0 +1,91 @@
+"""Tensor term definition and utility."""
+
+from sympy import sympify
+
+
+class Range:
+ """A symbolic range that can be summed over.
+
+ This class is for symbolic ranges that is going to be summed over in
+ tensors. Each range should have a label, and optionally lower and upper... | |
0f72c4bf32986aae7a59b2380c5a314038c7ed61 | aids/stack/queue_two_stacks.py | aids/stack/queue_two_stacks.py | '''
Implement Queue data structure using two stacks
'''
from stack import Stack
class QueueUsingTwoStacks(object):
def __init__(self):
'''
Initialize Queue
'''
self.stack1 = Stack()
self.stack2 = Stack()
def __len__(self):
'''
Return number of items in Queue
'''
return len(self.stack1) + len(s... | Add Queue implementation using two stacks | Add Queue implementation using two stacks
| Python | mit | ueg1990/aids | ---
+++
@@ -0,0 +1,40 @@
+'''
+Implement Queue data structure using two stacks
+
+'''
+
+from stack import Stack
+
+class QueueUsingTwoStacks(object):
+ def __init__(self):
+ '''
+ Initialize Queue
+
+ '''
+ self.stack1 = Stack()
+ self.stack2 = Stack()
+
+ def __len__(self):
+ '''
+ Return number of items in ... | |
1cc99c8e7c020457034d8ff1a4b85033bbe64353 | tools/generator/raw-data-extractor/extract-sam.py | tools/generator/raw-data-extractor/extract-sam.py |
import urllib.request
import zipfile
import re, io, os
import shutil
from pathlib import Path
from multiprocessing import Pool
from collections import defaultdict
from distutils.version import StrictVersion
packurl = "http://packs.download.atmel.com/"
shutil.rmtree("../raw-device-data/sam-devices", ignore_errors=T... | Add SAM device data extractor | [dfg] Add SAM device data extractor
| Python | mpl-2.0 | modm-io/modm-devices | ---
+++
@@ -0,0 +1,47 @@
+
+import urllib.request
+import zipfile
+import re, io, os
+import shutil
+
+from pathlib import Path
+from multiprocessing import Pool
+from collections import defaultdict
+from distutils.version import StrictVersion
+
+
+packurl = "http://packs.download.atmel.com/"
+
+shutil.rmtree("../raw... | |
3b519b6ce6319797ef0544ea2567e918fa4df1b3 | hangul_test.py | hangul_test.py | import hangul
s = 'ㅎㅏㄴㅅㅓㅁㄱㅣ'
print(hangul.conjoin(s))
s = '한섬기'
print(hangul.conjoin(s))
print(ord('ㅎ'))
print(ord(u'\u1112'))
print(chr(12622))
print(chr(4370))
print(hex(12622))
print(hex(4370))
| Add test module of hangul. | Add test module of hangul.
| Python | mit | iandmyhand/python-utils | ---
+++
@@ -0,0 +1,14 @@
+import hangul
+
+s = 'ㅎㅏㄴㅅㅓㅁㄱㅣ'
+print(hangul.conjoin(s))
+
+s = '한섬기'
+print(hangul.conjoin(s))
+
+print(ord('ㅎ'))
+print(ord(u'\u1112'))
+print(chr(12622))
+print(chr(4370))
+print(hex(12622))
+print(hex(4370)) | |
fe760be64eac3290a358e4a488af9946ea6f2a1d | corehq/form_processor/management/commands/run_sql.py | corehq/form_processor/management/commands/run_sql.py | from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import sys
import traceback
import attr
import gevent
from django.core.management.base import BaseCommand
from django.db import connections
from six.moves import input
from corehq.sql_db.util import ge... | Add management command to run SQL on form dbs | Add management command to run SQL on form dbs
This is specifically to create an index concurrently, but could be useful in the future to run any SQL on multiple databases.
[ci skip] tested locally | Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,74 @@
+from __future__ import absolute_import
+from __future__ import print_function
+from __future__ import unicode_literals
+import sys
+import traceback
+
+import attr
+import gevent
+from django.core.management.base import BaseCommand
+from django.db import connections
+from six.moves import in... | |
1040e17e006fef93d990a6212e8be06e0a818c2f | middleware/python/test_middleware.py | middleware/python/test_middleware.py | from tyk.decorators import *
@Pre
def AddSomeHeader(request, session):
# request['Body'] = 'tyk=python'
request['SetHeaders']['SomeHeader'] = 'python2'
return request, session
def NotARealHandler():
pass
| from tyk.decorators import *
from tyk.gateway import TykGateway as tyk
@Pre
def AddSomeHeader(request, session):
request['SetHeaders']['SomeHeader'] = 'python'
tyk.store_data( "cool_key", "cool_value", 300 )
return request, session
def NotARealHandler():
pass
| Update middleware syntax with "TykGateway" | Update middleware syntax with "TykGateway"
| Python | mpl-2.0 | mvdan/tyk,nebolsin/tyk,nebolsin/tyk,lonelycode/tyk,mvdan/tyk,mvdan/tyk,lonelycode/tyk,mvdan/tyk,nebolsin/tyk,lonelycode/tyk,mvdan/tyk,mvdan/tyk,nebolsin/tyk,mvdan/tyk,nebolsin/tyk,nebolsin/tyk,mvdan/tyk,nebolsin/tyk,nebolsin/tyk | ---
+++
@@ -1,9 +1,10 @@
from tyk.decorators import *
+from tyk.gateway import TykGateway as tyk
@Pre
def AddSomeHeader(request, session):
- # request['Body'] = 'tyk=python'
- request['SetHeaders']['SomeHeader'] = 'python2'
+ request['SetHeaders']['SomeHeader'] = 'python'
+ tyk.store_data( "cool_key"... |
88d87f4051629c6a32e458077c543275eed0243e | setup.py | setup.py | from setuptools import setup, find_packages
setup(
name='jupyterhub-kubespawner',
version='0.5.1',
install_requires=[
'jupyterhub',
'pyyaml',
'kubernetes==2.*',
'escapism',
'jupyter',
],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
desc... | from setuptools import setup, find_packages
setup(
name='jupyterhub-kubespawner',
version='0.5.1',
install_requires=[
'jupyterhub',
'pyYAML',
'kubernetes==2.*',
'escapism',
'jupyter',
],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
desc... | Fix install of pyYAML on Travis | Fix install of pyYAML on Travis
| Python | bsd-3-clause | yuvipanda/jupyterhub-kubernetes-spawner,jupyterhub/kubespawner,ktong/kubespawner | ---
+++
@@ -5,7 +5,7 @@
version='0.5.1',
install_requires=[
'jupyterhub',
- 'pyyaml',
+ 'pyYAML',
'kubernetes==2.*',
'escapism',
'jupyter', |
6534d06c450be73044d8130cfa6a534f7bff885f | iypm_domain.py | iypm_domain.py | import sys
try:
from troposphere import Join, Sub, Output, Export
from troposphere import Parameter, Ref, Template
from troposphere.route53 import HostedZone
from troposphere.certificatemanager import Certificate
except ImportError:
sys.exit('Unable to import troposphere. '
'Try "pip i... | Add troposphere cloudformation domain and ssl script | Add troposphere cloudformation domain and ssl script
| Python | mpl-2.0 | MinnSoe/ifyoupayme,MinnSoe/ifyoupayme,MinnSoe/ifyoupayme | ---
+++
@@ -0,0 +1,54 @@
+import sys
+
+try:
+ from troposphere import Join, Sub, Output, Export
+ from troposphere import Parameter, Ref, Template
+ from troposphere.route53 import HostedZone
+ from troposphere.certificatemanager import Certificate
+except ImportError:
+ sys.exit('Unable to import tro... | |
9f48522c385c81200f04a027e0299ddf7c81ef84 | runtime_stats/combine_graphs.py | runtime_stats/combine_graphs.py | #!/usr/bin/env python2.7
#
# Copyright 2011-2013 Colin Scott
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | Add a script for combining graphs | Add a script for combining graphs
| Python | apache-2.0 | jmiserez/sts,ucb-sts/sts,ucb-sts/sts,jmiserez/sts | ---
+++
@@ -0,0 +1,55 @@
+#!/usr/bin/env python2.7
+#
+# Copyright 2011-2013 Colin Scott
+#
+# 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... | |
c689a03dcc84315ff5c3796615a80146f8e74d1f | scripts/get_bank_registry_lv.py | scripts/get_bank_registry_lv.py | #!/usr/bin/env python
import json
import xlrd
import requests
URL = "https://www.bank.lv/images/stories/pielikumi/makssist/bic_saraksts_22.01.2020_eng.xls"
def process():
registry = []
book = xlrd.open_workbook(file_contents=requests.get(URL).content)
sheet = book.sheet_by_index(0)
for row in list(... | Add generate Latvia bank registry script | Add generate Latvia bank registry script
| Python | mit | figo-connect/schwifty | ---
+++
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+import json
+import xlrd
+import requests
+
+URL = "https://www.bank.lv/images/stories/pielikumi/makssist/bic_saraksts_22.01.2020_eng.xls"
+
+
+def process():
+ registry = []
+
+ book = xlrd.open_workbook(file_contents=requests.get(URL).content)
+ sheet = book... | |
90fc1ce356ca1bc367f6a5234d2267600a0a789a | contrib/create_smimea.py | contrib/create_smimea.py | #!/usr/bin/env python
import os
import sys
import base64 as b64
import argparse
def smimea(usage, der):
cert = []
c = 0
with open(der, "rb") as f:
while True:
l = f.read(1024)
if l == "": break
c += len(l)
cert.append(l)
data = b64.b16encode("... | Add little helper script to create DNS records | Add little helper script to create DNS records
| Python | agpl-3.0 | sys4/smilla | ---
+++
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import base64 as b64
+import argparse
+
+def smimea(usage, der):
+ cert = []
+
+ c = 0
+ with open(der, "rb") as f:
+ while True:
+ l = f.read(1024)
+ if l == "": break
+
+ c += len(l)
+ ... | |
1f80b634596bfaa8c4b538a5e8011399bcad6253 | test/selenium/src/lib/element/widget_info.py | test/selenium/src/lib/element/widget_info.py | # Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: jernej@reciprocitylabs.com
# Maintained By: jernej@reciprocitylabs.com
from lib import base
from lib.constants import locator
from lib.page import ... | Add missing widget info element | Add missing widget info element
| Python | apache-2.0 | josthkko/ggrc-core,kr41/ggrc-core,NejcZupec/ggrc-core,VinnieJohns/ggrc-core,josthkko/ggrc-core,andrei-karalionak/ggrc-core,NejcZupec/ggrc-core,plamut/ggrc-core,NejcZupec/ggrc-core,VinnieJohns/ggrc-core,j0gurt/ggrc-core,andrei-karalionak/ggrc-core,AleksNeStu/ggrc-core,jmakov/ggrc-core,VinnieJohns/ggrc-core,NejcZupec/ggr... | ---
+++
@@ -0,0 +1,44 @@
+# Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
+# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
+# Created By: jernej@reciprocitylabs.com
+# Maintained By: jernej@reciprocitylabs.com
+
+from lib import base
+from lib.constants im... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.