commit stringlengths 40 40 | old_file stringlengths 4 236 | new_file stringlengths 4 236 | old_contents stringlengths 1 3.26k | new_contents stringlengths 16 4.43k | subject stringlengths 16 624 | message stringlengths 17 3.29k | lang stringclasses 5
values | license stringclasses 13
values | repos stringlengths 5 91.5k |
|---|---|---|---|---|---|---|---|---|---|
6086b970e6c37ca4f343291a35bbb9e533109c1c | flask_wiki/backend/routes.py | flask_wiki/backend/routes.py | from flask_wiki.backend.backend import api
from flask_wiki.backend.views import PageView
api.add_resource(PageView, '/pages-list', endpoint='pages-list') | from flask_wiki.backend.backend import api
from flask_wiki.backend.views import PageView, PageDetail
api.add_resource(PageView, '/pages-list', endpoint='pages-list')
api.add_resource(PageDetail, '/pages/<slug>', endpoint='page-detail') | Support for page-detail url added. | Support for page-detail url added.
| Python | bsd-2-clause | gcavalcante8808/flask-wiki,gcavalcante8808/flask-wiki,gcavalcante8808/flask-wiki |
76a2248ffe8c64b15a6f7d307b6d7c726e97165c | alerts/cloudtrail_logging_disabled.py | alerts/cloudtrail_logging_disabled.py | #!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation
#
# Contributors:
# Brandon Myers bmyers@mozilla.com
fro... | #!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation
#
# Contributors:
# Brandon Myers bmyers@mozilla.com
fro... | Send Cloudtrail logging disabled alert to MOC | Send Cloudtrail logging disabled alert to MOC
| Python | mpl-2.0 | mozilla/MozDef,Phrozyn/MozDef,ameihm0912/MozDef,gdestuynder/MozDef,ameihm0912/MozDef,mpurzynski/MozDef,mozilla/MozDef,gdestuynder/MozDef,jeffbryner/MozDef,jeffbryner/MozDef,mpurzynski/MozDef,mpurzynski/MozDef,Phrozyn/MozDef,jeffbryner/MozDef,ameihm0912/MozDef,mozilla/MozDef,ameihm0912/MozDef,jeffbryner/MozDef,gdestuynd... |
6099451fe088fe74945bbeedeeee66896bd7ff3d | voctocore/lib/sources/__init__.py | voctocore/lib/sources/__init__.py | import logging
from lib.config import Config
from lib.sources.decklinkavsource import DeckLinkAVSource
from lib.sources.imgvsource import ImgVSource
from lib.sources.tcpavsource import TCPAVSource
from lib.sources.testsource import TestSource
from lib.sources.videoloopsource import VideoLoopSource
log = logging.getLo... | import logging
from lib.config import Config
from lib.sources.decklinkavsource import DeckLinkAVSource
from lib.sources.imgvsource import ImgVSource
from lib.sources.tcpavsource import TCPAVSource
from lib.sources.testsource import TestSource
from lib.sources.videoloopsource import VideoLoopSource
log = logging.getLo... | Use test sources as the default in configuration (and improve warning message, when falling back to) | Use test sources as the default in configuration (and improve warning message, when falling back to)
| Python | mit | voc/voctomix,voc/voctomix |
3d9d1b10149655030d172de38f9caeb5906d093c | source/lucidity/__init__.py | source/lucidity/__init__.py | # :coding: utf-8
# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips
# :license: See LICENSE.txt.
from .template import Template
| # :coding: utf-8
# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips
# :license: See LICENSE.txt.
import os
import uuid
import imp
from .template import Template
def discover_templates(paths=None, recursive=True):
'''Search *paths* for mount points and load templates from them.
*paths* should be a li... | Add helper method to load templates from disk. | Add helper method to load templates from disk.
| Python | apache-2.0 | 4degrees/lucidity,nebukadhezer/lucidity,BigRoy/lucidity |
0e2e30382def1f911987ca22fce5adc6c6b73fb6 | airship/__init__.py | airship/__init__.py | import os
import json
from flask import Flask, render_template
def channels_json(station, escaped=False):
channels = [{"name": channel} for channel in station.channels()]
jsonbody = json.dumps(channels)
if escaped:
jsonbody = jsonbody.replace("</", "<\\/")
return jsonbody
def make_airship(s... | import os
import json
from flask import Flask, render_template
def jsonate(obj, escaped):
jsonbody = json.dumps(obj)
if escaped:
jsonbody = jsonbody.replace("</", "<\\/")
return jsonbody
def channels_json(station, escaped=False):
channels = [{"name": channel} for channel in station.channels... | Fix the grefs route in the airship server | Fix the grefs route in the airship server
| Python | mit | richo/airship,richo/airship,richo/airship |
6f83b42ae9aaf9cd23bc8d15b66157a75bbc3aed | util/createCollector.py | util/createCollector.py | import os
import sys
import subprocesses
THIS_SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
fuzzManagerPath = os.path.abspath(os.path.join(THIS_SCRIPT_DIRECTORY, os.pardir, os.pardir, 'FuzzManager'))
if not os.path.exists(fuzzManagerPath):
print "Please check out Lithium and FuzzManager side-by-si... | import os
import sys
THIS_SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
fuzzManagerPath = os.path.abspath(os.path.join(THIS_SCRIPT_DIRECTORY, os.pardir, os.pardir, 'FuzzManager'))
if not os.path.exists(fuzzManagerPath):
print "Please check out Lithium and FuzzManager side-by-side with funfuzz. Li... | Use the signature (cache) directory specified in .fuzzmanagerconf | Use the signature (cache) directory specified in .fuzzmanagerconf
| Python | mpl-2.0 | nth10sd/funfuzz,MozillaSecurity/funfuzz,MozillaSecurity/funfuzz,MozillaSecurity/funfuzz,nth10sd/funfuzz,nth10sd/funfuzz |
28add39cbd964d9a26ff8f12c1ee3668b765c7a7 | perforce/p4login.py | perforce/p4login.py | #!/usr/bin/env python3
"""Script to automate logging into Perforce.
Use P4API to log in to the server.
"""
import P4
def main():
"""Log in to the Perforce server."""
# Yep, pretty much that easy.
p4 = P4.P4()
p4.connect()
p4.run_login()
if __name__ == "__main__":
main()
| #!/usr/bin/env python
"""Script to automate logging into Perforce."""
import subprocess
import sys
def main():
"""Log in to the Perforce server."""
# Yep, pretty much that easy.
result = subprocess.check_output(['p4', 'set', '-q', 'P4PASSWD'])
passwd = result.strip().split('=')[1]
proc = subproce... | Use p4 cli instead of p4 api | Use p4 cli instead of p4 api
| Python | bsd-3-clause | nlfiedler/devscripts,nlfiedler/devscripts |
ad42da9cb3c944f5bd5e953f947a0be96a4b8e17 | astropy/samp/tests/test_hub_proxy.py | astropy/samp/tests/test_hub_proxy.py | from astropy.samp import conf
from astropy.samp.hub import SAMPHubServer
from astropy.samp.hub_proxy import SAMPHubProxy
def setup_module(module):
conf.use_internet = False
class TestHubProxy:
def setup_method(self, method):
self.hub = SAMPHubServer(web_profile=False, mode='multiple', pool_size=1)... | from astropy.samp import conf
from astropy.samp.hub import SAMPHubServer
from astropy.samp.hub_proxy import SAMPHubProxy
def setup_module(module):
conf.use_internet = False
class TestHubProxy:
def setup_method(self, method):
self.hub = SAMPHubServer(web_profile=False, mode='multiple', pool_size=1)... | Replace `tmpdir` with `tmp_path` in `samp` tests | Replace `tmpdir` with `tmp_path` in `samp` tests
| Python | bsd-3-clause | pllim/astropy,mhvk/astropy,lpsinger/astropy,lpsinger/astropy,mhvk/astropy,larrybradley/astropy,pllim/astropy,lpsinger/astropy,lpsinger/astropy,lpsinger/astropy,astropy/astropy,pllim/astropy,astropy/astropy,larrybradley/astropy,pllim/astropy,astropy/astropy,mhvk/astropy,larrybradley/astropy,larrybradley/astropy,astropy/... |
b4a92b80d2cfe316d89dbecdf1026486d5288fe0 | simulator-perfect.py | simulator-perfect.py | #!/usr/bin/env python3
import timer
import sys
import utils
def simulate():
# A set of files already in the storage
seen = set()
# The size of the all uploads combined (deduplicated or not)
total_in = 0
# The size of the data sent to the service
data_in = 0
tmr = timer.Timer()
for (... | #!/usr/bin/env python3
import timer
import sys
import utils
def simulate():
# A set of files already in the storage
seen = set()
# The size of the all uploads combined (deduplicated or not)
total_in = 0
# The size of the data sent to the service
data_in = 0
tmr = timer.Timer()
for (... | Make perfect simulator print data after each upload | Make perfect simulator print data after each upload
| Python | apache-2.0 | sjakthol/dedup-simulator,sjakthol/dedup-simulator |
1a871cf3bf1fd40342e490599361d57017cdcc65 | backend/breach/tests/test_strategy.py | backend/breach/tests/test_strategy.py | from mock import patch
from breach.tests.base import RuptureTestCase
from breach.strategy import Strategy
class StrategyTestCase(RuptureTestCase):
@patch('breach.strategy.Sniffer')
def test_first_round(self, Sniffer):
strategy0 = Strategy(self.victim)
work0 = strategy0.get_work()
sel... | from mock import patch
from breach.tests.base import RuptureTestCase
from breach.strategy import Strategy
class StrategyTestCase(RuptureTestCase):
@patch('breach.strategy.Sniffer')
def test_first_round(self, Sniffer):
strategy0 = Strategy(self.victim)
work0 = strategy0.get_work()
sel... | Update first round test, create huffman based on knownalphabet | Update first round test, create huffman based on knownalphabet
| Python | mit | dionyziz/rupture,dimriou/rupture,esarafianou/rupture,esarafianou/rupture,dimkarakostas/rupture,dimkarakostas/rupture,esarafianou/rupture,dionyziz/rupture,dimkarakostas/rupture,dionyziz/rupture,esarafianou/rupture,dimkarakostas/rupture,dimkarakostas/rupture,dimriou/rupture,dimriou/rupture,dimriou/rupture,dimriou/rupture... |
91b01e37897ea20f6486118e4dd595439f81006b | ktane/Model/Modules/WiresModule.py | ktane/Model/Modules/WiresModule.py | from enum import Enum
from .AbstractModule import AbstractModule, ModuleState
class WireColors(Enum):
MISSING = 'missing'
BLACK = 'black'
RED = 'red'
WHITE = 'white'
BLUE = 'blue'
YELLOW = 'yellow'
def get_correct_wire(sequence, boolpar):
wires_count = get_wires_count(sequence)
def ge... | from enum import Enum
from .AbstractModule import AbstractModule, ModuleState
class WireColors(Enum):
MISSING = 'missing'
BLACK = 'black'
RED = 'red'
WHITE = 'white'
BLUE = 'blue'
YELLOW = 'yellow'
def get_correct_wire(sequence, boolpar):
wires_count = get_wires_count(sequence)
def ge... | Implement Wires helper method get_nth_wire_position | Implement Wires helper method get_nth_wire_position
| Python | mit | hanzikl/ktane-controller |
d8d77d4dd98d9287be8a98f0024e5f458bef2b66 | tests/test_time.py | tests/test_time.py | from immobilus import immobilus
from immobilus.logic import _datetime_to_utc_timestamp
from datetime import datetime
from time import time
def test_time_function():
dt = datetime(1970, 1, 1)
assert _datetime_to_utc_timestamp(dt) == 0.0
assert type(_datetime_to_utc_timestamp(dt)) is float
assert time... | from immobilus import immobilus
from immobilus.logic import _datetime_to_utc_timestamp
from datetime import datetime
from time import time
def test_time_function():
dt = datetime(1970, 1, 1)
timestamp = _datetime_to_utc_timestamp(dt)
assert timestamp == 0.0
assert type(timestamp) is float
assert... | Tidy test - reuse timestamp | Tidy test - reuse timestamp
| Python | apache-2.0 | pokidovea/immobilus |
a9f55a57559a6647c451d38893624be4109be23b | Spiders.py | Spiders.py | '''
Created on 2 сент. 2016 г.
@author: garet
'''
class BaseSpider():
def __init__(self):
pass
def AddUrls(self, urls):
pass
def Routing(self, url):
pass
def SaveCache(self, url, data=None):
pass
def GetCache(self, url):
pass
... | '''
Created on 2 сент. 2016 г.
@author: garet
'''
import queue
import sqlite3
class BaseSpider():
def __init__(self):
pass
def AddUrls(self, urls):
pass
def Routing(self, url):
pass
def SaveCache(self, url, data=None):
pass
def GetCa... | Add SqliteCache for html raw data. Add QueueUrls for list urls. | Add SqliteCache for html raw data. Add QueueUrls for list urls. | Python | bsd-3-clause | SaltusVita/ReoGrab |
20eb711953a8981e7b73b59613018514157e352a | spyder_terminal/__init__.py | spyder_terminal/__init__.py | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) Spyder Project Contributors
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Spyder Te... | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) Spyder Project Contributors
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Spyder Te... | Set development version number to v0.3.0.dev0 | Set development version number to v0.3.0.dev0
| Python | mit | spyder-ide/spyder-terminal,andfoy/spyder-terminal,spyder-ide/spyder-terminal,andfoy/spyder-terminal,spyder-ide/spyder-terminal,andfoy/spyder-terminal,spyder-ide/spyder-terminal |
caf18b1cd8923e6d070d2652f9969dabba50e81b | lotteryResult.py | lotteryResult.py | #!/usr/bin/env python
import sys
import json
import requests
import hashlib
def hashToNumber(txhash,total):
result = long(txhash, 16) % total
return result
def getBlocktxs(blockhash, number, total, startnum):
url = "https://blockexplorer.com/api/block/" + blockhash
params = dict()
resp = requests.get... | #!/usr/bin/env python
import sys
import json
import requests
def hashToNumber(txhash, total):
result = long(txhash, 16) % total
return result
def getBlocktxs(blockhash, number, total, startnum):
url = "https://blockexplorer.com/api/block/" + blockhash
params = dict()
resp = requests.get(url=ur... | Format code with pep8 and add timeout to requests | Format code with pep8 and add timeout to requests
| Python | mit | planetcoder/readerLottery |
5ec99974a6611cc5993bf56f3f0f4e299a89e29d | txircd/modules/cmd_pass.py | txircd/modules/cmd_pass.py | from twisted.words.protocols import irc
from txircd.modbase import Command, Module
class PassCommand(Command, Module):
def onUse(self, user, params):
if user.registered == 0:
user.sendMessage(irc.ERR_ALREADYREGISTRED, ":Unauthorized command (already registered)")
return
if not params:
user.sendMessage(ir... | from twisted.words.protocols import irc
from txircd.modbase import Command, Module
class PassCommand(Command, Module):
def onUse(self, user, params):
if user.registered == 0:
user.sendMessage(irc.ERR_ALREADYREGISTRED, ":Unauthorized command (already registered)")
return
if not params:
user.sendMessage(ir... | Add the function (not class) to actions as is now required | Add the function (not class) to actions as is now required
| Python | bsd-3-clause | DesertBus/txircd,Heufneutje/txircd,ElementalAlchemist/txircd |
1dd681517fd1831f3990caa043ea8220f5d1bb90 | app/app.py | app/app.py | #!/usr/bin/env python3.5
import os,time,asyncio,json
from datetime import datetime
from aiohttp import web
import logging;logging.basicConfig(level=logging.INFO)
from tools.log import Log
from tools.httptools import Middleware,Route
from tools.template import Template
from models import *
from tools.con... | #!/usr/bin/env python3.5
import os,time,asyncio,json
from datetime import datetime
from aiohttp import web
import logging;logging.basicConfig(level=logging.INFO)
from tools.log import Log
from tools.httptools import Middleware,Route
from tools.template import Template
from models import *
from tools.con... | Change Template() to Template.init() in init function | Change Template() to Template.init() in init function
| Python | mit | free-free/pyblog,free-free/pyblog,free-free/pyblog,free-free/pyblog |
178474ceb7227313d039666db3c235c2ee18251e | astropy/tests/image_tests.py | astropy/tests/image_tests.py | import matplotlib
from matplotlib import pyplot as plt
from astropy.utils.decorators import wraps
MPL_VERSION = matplotlib.__version__
ROOT = "http://{server}/testing/astropy/2018-10-24T12:38:34.134556/{mpl_version}/"
IMAGE_REFERENCE_DIR = (ROOT.format(server='data.astropy.org', mpl_version=MPL_VERSION[:3] + '.x') +... | import matplotlib
from matplotlib import pyplot as plt
from astropy.utils.decorators import wraps
MPL_VERSION = matplotlib.__version__
# The developer versions of the form 3.1.x+... contain changes that will only
# be included in the 3.2.x release, so we update this here.
if MPL_VERSION[:3] == '3.1' and '+' in MPL_V... | Use 3.2.x reference images for developer version of Matplotlib | Use 3.2.x reference images for developer version of Matplotlib | Python | bsd-3-clause | pllim/astropy,StuartLittlefair/astropy,mhvk/astropy,stargaser/astropy,stargaser/astropy,mhvk/astropy,mhvk/astropy,saimn/astropy,aleksandr-bakanov/astropy,astropy/astropy,lpsinger/astropy,dhomeier/astropy,aleksandr-bakanov/astropy,MSeifert04/astropy,StuartLittlefair/astropy,saimn/astropy,bsipocz/astropy,dhomeier/astropy... |
41a83c6742f0e688dad5a98761c0f0415c77bac9 | outgoing_mail.py | outgoing_mail.py | #!/usr/bin/env python
#
# Copyright 2010 Eric Entzel <eric@ubermac.net>
#
from google.appengine.api import mail
from google.appengine.ext.webapp import template
import os
from_address = '"EventBot" <admin@myeventbot.com>'
def send(to, template_name, values):
path = os.path.join(os.path.dirname(__file__), 'emai... | #!/usr/bin/env python
#
# Copyright 2010 Eric Entzel <eric@ubermac.net>
#
from google.appengine.api import mail
from google.appengine.ext.webapp import template
from google.appengine.api import memcache
from datetime import datetime
import os
from_address = '"EventBot" <admin@myeventbot.com>'
email_interval = 10
d... | Use memcache to rate-limit outgoing emails. | Use memcache to rate-limit outgoing emails.
| Python | mit | eentzel/myeventbot,eentzel/myeventbot,eentzel/myeventbot,eentzel/myeventbot,eentzel/myeventbot |
cf7b2bb0569431e97cc316dc41924c78806af5a9 | drivers/vnfm/gvnfm/gvnfmadapter/driver/pub/config/config.py | drivers/vnfm/gvnfm/gvnfmadapter/driver/pub/config/config.py | # Copyright 2017 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | # Copyright 2017 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | Add code framework of gvnfm-driver | Add code framework of gvnfm-driver
Change-Id: Ibb0dd98a73860f538599328b718040df5f3f7007
Issue-Id: NFVO-132
Signed-off-by: fujinhua <302f4934d283b6f50163b4a7fd9b6c869e0ad64e@zte.com.cn>
| Python | apache-2.0 | open-o/nfvo,open-o/nfvo,open-o/nfvo,open-o/nfvo,open-o/nfvo |
c4c71dd65675f904c34a0d86a80d5abe7bafdbb1 | txircd/modules/cmd_user.py | txircd/modules/cmd_user.py | from twisted.words.protocols import irc
from txircd.modbase import Command
class UserCommand(Command):
def onUse(self, user, params):
if user.registered == 0:
self.sendMessage(irc.ERR_ALREADYREGISTRED, ":Unauthorized command (already registered)")
return
if params and len(params) < 4:
user.sendMessage(ir... | from twisted.words.protocols import irc
from txircd.modbase import Command
class UserCommand(Command):
def onUse(self, user, data):
if not user.username:
user.registered -= 1
user.username = data["ident"]
user.realname = data["gecos"]
if user.registered == 0:
user.register()
def processParams(self, u... | Update the USER command to take advantage of core capabilities as well | Update the USER command to take advantage of core capabilities as well
| Python | bsd-3-clause | ElementalAlchemist/txircd,Heufneutje/txircd,DesertBus/txircd |
2c082afb4024cafb530ffab6a62cc6602e75e092 | stock_request_picking_type/models/stock_request_order.py | stock_request_picking_type/models/stock_request_order.py | # Copyright 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models
class StockRequestOrder(models.Model):
_inherit = 'stock.request.order'
@api.model
def _get_default_picking_type(self):
return self.env['stock.picki... | # Copyright 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models
class StockRequestOrder(models.Model):
_inherit = 'stock.request.order'
@api.model
def _get_default_picking_type(self):
return self.env['stock.picki... | Synchronize Picking Type and Warehouse | [IMP] Synchronize Picking Type and Warehouse
[IMP] User write()
| Python | agpl-3.0 | Vauxoo/stock-logistics-warehouse,Vauxoo/stock-logistics-warehouse,Vauxoo/stock-logistics-warehouse |
be0a078aa004470a450dddfa5a8e770b2e0ad97c | disk/datadog_checks/disk/__init__.py | disk/datadog_checks/disk/__init__.py | # (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .__about__ import __version__
from .disk import Disk
all = [
'__version__', 'Disk'
]
| # (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .__about__ import __version__ # NOQA F401
from .disk import Disk # NOQA F401
all = [
'__version__', 'Disk'
]
| Fix flake8 issues and ignore unused | [Disk] Fix flake8 issues and ignore unused
| Python | bsd-3-clause | DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core,DataDog/integrations-core |
a4f41648cd0318694d551b067309539df475c2d7 | tests/test_function_calls.py | tests/test_function_calls.py | from thinglang.runner import run
def test_function_calls():
assert run("""
thing Program
does start
number n = 1
number m = 2
Output.write("before n=", n, " m=", m)
self.say_hello()
Output.write("after n=", n, " m=", m)
does say_hello
number n = 3
O... | from thinglang.runner import run
def test_zero_arg_function_calls():
assert run("""
thing Program
does start
number n = 1
number m = 2
Output.write("before n=", n, " m=", m)
self.say_hello()
Output.write("after n=", n, " m=", m)
does say_hello
number n = 3
... | Test for method argument calls | Test for method argument calls
| Python | mit | ytanay/thinglang,ytanay/thinglang,ytanay/thinglang,ytanay/thinglang |
ebbc68da19755097b2131d60bc9757ecb4dc6d4c | bundles/auth/models/token.py | bundles/auth/models/token.py | import hashlib
import random
import string
from ext.aboard.model import *
def set_value(token):
"""Randomly create and return a value."""
value = str(token.user) + "_" + str(token.timestamp)
len_rand = random.randint(20, 40)
to_pick = string.digits + string.ascii_letters + \
"_-+^$"
fo... | import hashlib
import random
import string
from ext.aboard.model import *
class Token(Model):
"""A token model."""
id = None
user = Integer()
timestamp = Integer()
value = String(pkey=True)
def __init__(self, user=None, timestamp=None):
value = None
if user and t... | Use the Model constructor to generate a default value | [user] Use the Model constructor to generate a default value
| Python | bsd-3-clause | v-legoff/pa-poc2,v-legoff/pa-poc2 |
1b40a51e371d10cc37f4d8f8c7557dbc741d690f | butterfly/ImageLayer/HDF5.py | butterfly/ImageLayer/HDF5.py | from Datasource import Datasource
import numpy as np
import h5py
class HDF5(Datasource):
pass
@classmethod
def load_tile(ds, query):
Sk,Sj,Si = query.all_scales
path = query.OUTPUT.INFO.PATH.VALUE
(K0,J0,I0),(K1,J1,I1) = query.source_bounds
with h5py.File(path) as fd:
... | from Datasource import Datasource
import numpy as np
import h5py
class HDF5(Datasource):
pass
@classmethod
def load_tile(ds, query):
Sk,Sj,Si = query.all_scales
path = query.OUTPUT.INFO.PATH.VALUE
z0,y0,x0 = query.index_zyx*query.blocksize
z1,y1,x1 = query.index_zyx*query.bl... | Fix loading a whole tile into memory. | Fix loading a whole tile into memory.
| Python | mit | Rhoana/butterfly,Rhoana/butterfly,Rhoana/butterfly2,Rhoana/butterfly,Rhoana/butterfly |
78c5580d349d6bec0715a36c13437177a726f7ad | tests/test_isim.py | tests/test_isim.py | import pytest
def test_isim():
import os
import shutil
import tempfile
import yaml
from fusesoc.edatools import get_edatool
from edalize_common import compare_files, files, param_gen, tests_dir, vpi
(parameters, args) = param_gen(['plusarg', 'vlogdefine', 'vlogparam'])
work_root = tem... | import pytest
def test_isim():
import os
import shutil
from edalize_common import compare_files, setup_backend, tests_dir
ref_dir = os.path.join(tests_dir, __name__)
paramtypes = ['plusarg', 'vlogdefine', 'vlogparam']
name = 'test_isim_0'
tool = 'isim'
tool_optio... | Reduce code duplication in isim test | Reduce code duplication in isim test
| Python | bsd-2-clause | olofk/fusesoc,olofk/fusesoc,lowRISC/fusesoc,lowRISC/fusesoc |
1e60c603321729c71895ac5dc19adc669cce4a72 | tests/udev_test.py | tests/udev_test.py | #!/usr/bin/python
import unittest
import mock
class UdevTest(unittest.TestCase):
def setUp(self):
import blivet.udev
blivet.udev.os = mock.Mock()
blivet.udev.log = mock.Mock()
def test_udev_get_device(self):
import blivet.udev
devices = blivet.udev.global_udev.list_de... | #!/usr/bin/python
import unittest
import mock
class UdevTest(unittest.TestCase):
def setUp(self):
import blivet.udev
self._blivet_os = blivet.udev.os
self._blivet_log = blivet.udev.log
self._blivet_util = blivet.udev.util
blivet.udev.os = mock.Mock()
blivet.udev.lo... | Clean up mocking done by udev tests when finished. | Clean up mocking done by udev tests when finished.
| Python | lgpl-2.1 | dwlehman/blivet,rvykydal/blivet,AdamWill/blivet,rhinstaller/blivet,vpodzime/blivet,AdamWill/blivet,vojtechtrefny/blivet,vojtechtrefny/blivet,vpodzime/blivet,rvykydal/blivet,rhinstaller/blivet,dwlehman/blivet,jkonecny12/blivet,jkonecny12/blivet |
c3029a3796437add90cdd6c0033be70fe5766a3a | mapit/middleware/__init__.py | mapit/middleware/__init__.py | import re
from .view_error import *
class JSONPMiddleware(object):
def process_response(self, request, response):
# If the response is a redirect, the callback will be dealt
# on the next request:
if response.status_code == 302:
return response
else:
if requ... | import re
from .view_error import *
class JSONPMiddleware(object):
def process_response(self, request, response):
# If the response is a redirect, the callback will be dealt
# on the next request:
if response.status_code == 302:
return response
else:
cb = re... | Include typeof check in JSONP callback response. | Include typeof check in JSONP callback response.
This is more robust, and helps against attacks such as Rosetta Flash:
https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
| Python | agpl-3.0 | opencorato/mapit,chris48s/mapit,opencorato/mapit,Code4SA/mapit,Code4SA/mapit,opencorato/mapit,Code4SA/mapit,chris48s/mapit,chris48s/mapit |
9c2075f13e2aa8ff7a5c4644208e8de17ebefbab | finding-geodesic-basins-with-scipy.py | finding-geodesic-basins-with-scipy.py | # IPython log file
import numpy as np
from scipy import sparse
from skimage import graph
from skimage.graph import _mcp
image = np.array([[1, 1, 2, 2], [2, 1, 1, 3], [3, 2, 1, 2], [2, 2, 2, 1]])
mcp = graph.MCP_Geometric(image)
destinations = [[0, 0], [3, 3]]
costs, traceback = mcp.find_costs(destinations)
offsets = ... | # IPython log file
# See https://stackoverflow.com/questions/62135639/mcp-geometrics-for-calculating-marketsheds/62144556
import numpy as np
from scipy import sparse
from skimage import graph
from skimage.graph import _mcp
image = np.array([[1, 1, 2, 2], [2, 1, 1, 3], [3, 2, 1, 2], [2, 2, 2, 1]])
mcp = graph.MCP_Geom... | Add link to SO question | Add link to SO question
| Python | bsd-3-clause | jni/useful-histories |
897b637ca9de93b7107cd6d6ab76ed0cb485aba9 | classifiers/ppmc.py | classifiers/ppmc.py | __author__ = 'sharvey'
from classifiers import Classifier
from corpus.mysql.reddit import RedditMySQLCorpus
from ppm import Trie
class RedditPPM(Classifier):
corpus = None
trie = None
user = None
reddit = None
order = 5
def __init__(self, corpus):
self.corpus = corpus
def train(... | __author__ = 'sharvey'
from classifiers import Classifier
from corpus.mysql.reddit import RedditMySQLCorpus
from ppm import Trie
class RedditPPM(Classifier):
corpus = None
trie = None
user = None
reddit = None
order = 5
def __init__(self, corpus):
self.corpus = corpus
def train(... | Add field for test result return | Add field for test result return
| Python | mit | worldwise001/stylometry |
552caa1d1fefcc48107eae02091aaca4a39123b4 | src/zeit/content/cp/field.py | src/zeit/content/cp/field.py | import zc.form.field
import zope.schema.interfaces
class DynamicCombination(zc.form.field.Combination):
def __init__(self, type_field, type_interface, **kw):
self.type_field = type_field
self.type_field.__name__ = "combination_00"
self.fields = (type_field,)
self.type_interface = ... | import zc.form.field
import zc.form.interfaces
import zope.schema.interfaces
class DynamicCombination(zc.form.field.Combination):
def __init__(self, type_field, type_interface, **kw):
self.type_field = type_field
self.type_field.__name__ = "combination_00"
self.fields = (type_field,)
... | Support sequences with value_type other than combination | TMS-227: Support sequences with value_type other than combination
| Python | bsd-3-clause | ZeitOnline/zeit.content.cp,ZeitOnline/zeit.content.cp |
0b4097394fd05da204624d1c6093176feb158bb1 | ajaxuploader/backends/thumbnail.py | ajaxuploader/backends/thumbnail.py | import os
from sorl.thumbnail import get_thumbnail
from ajaxuploader.backends.local import LocalUploadBackend
class ThumbnailUploadBackend(LocalUploadBackend):
def __init__(self, dimension):
self._dimension = dimension
def upload_complete(self, request, filename):
thumbnail = get_thumbna... | import os
from django.conf import settings
from sorl.thumbnail import get_thumbnail
from ajaxuploader.backends.local import LocalUploadBackend
class ThumbnailUploadBackend(LocalUploadBackend):
DIMENSION = "100x100"
def upload_complete(self, request, filename):
thumbnail = get_thumbnail(self._path, s... | Use dimension as a constant, so we keep same interface for all backends; also returns full path to the place where image was saved | Use dimension as a constant, so we keep same interface for all backends; also returns full path to the place where image was saved
| Python | bsd-3-clause | OnlyInAmerica/django-ajax-uploader,derek-adair/django-ajax-uploader,derek-adair/django-ajax-uploader,skoczen/django-ajax-uploader,brilliant-org/django-ajax-uploader,derek-adair/django-ajax-uploader,brilliant-org/django-ajax-uploader,skoczen/django-ajax-uploader,OnlyInAmerica/django-ajax-uploader,brilliant-org/django-aj... |
a3c4f151a9a44aae3528492d4a00a1815c52cda6 | website_membership_contact_visibility/models/res_partner.py | website_membership_contact_visibility/models/res_partner.py | # -*- coding: utf-8 -*-
# © 2016 Michael Viriyananda
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agp
from openerp import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
website_membership_published = fields.Boolean(
string='Visible In The Website',
copy=F... | # -*- coding: utf-8 -*-
# © 2016 Michael Viriyananda
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agp
from openerp import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
website_membership_published = fields.Boolean(
string='Visible Contact Info On The Website',
... | Change the label of "website_membership_published" into "Visible Contact Info On The Website" | Change the label of "website_membership_published" into "Visible Contact Info On The Website"
| Python | agpl-3.0 | open-synergy/vertical-association |
b56c2063dbb8ea6145048eb8a74bfd2693b2b6f4 | app.py | app.py | #!/usr/bin/env python
from flask import Flask
app = Flask(__name__)
@app.route("/ping")
def hello():
return "pong"
if __name__ == "__main__":
app.run() | #!/usr/bin/env python
from flask import Flask
app = Flask(__name__)
@app.route("/ping")
def hello():
return "pong"
# Returns larger sample JSON from http://json.org/example.html to exercise performance with larger payloads
@app.route("/bigger")
def big_response():
return '''{
"glossary": {
"title":... | Add bigger response payload option of 512B | Add bigger response payload option of 512B
| Python | apache-2.0 | svanoort/python-client-benchmarks,svanoort/python-client-benchmarks |
d7cb9bdd63b381b81bf89c5e3c1cc3031c5928d9 | run.py | run.py | """
Entry point for running the sqmpy application standalone
"""
import os
from gevent import monkey
monkey.patch_all()
from sqmpy.factory import create_app
# This line added to support heroku deployment
port = int(os.environ.get("PORT", 3000))
app = create_app('../config.py')
app.run(host='0.0.0.0', port=port,
... | """
Entry point for running the sqmpy application standalone
"""
import os
from gevent import monkey
monkey.patch_all()
from sqmpy.factory import create_app
# This line added to support heroku deployment
port = int(os.environ.get("PORT", 3000))
# Workaround for passing ssh options to underlying library. Since we want... | Add comments and more gitignore | Add comments and more gitignore
| Python | bsd-3-clause | mehdisadeghi/sqmpy,mehdisadeghi/sqmpy,mehdisadeghi/sqmpy,simphony/sqmpy,simphony/sqmpy,simphony/sqmpy |
ca758b2813ae77b795c4318d7d5566cd47ab0ec7 | postgres/operations.py | postgres/operations.py | from django.db.migrations.operations.base import Operation
from django.db import connection
from psycopg2.extras import register_composite
class LoadSQLFromScript(Operation):
def __init__(self, filename):
self.filename = filename
@property
def reversible(self):
return False
def state... | from django.db.migrations.operations.base import Operation
from django.db import connection
from psycopg2.extras import register_composite
from .fields.composite import composite_type_created
class LoadSQLFromScript(Operation):
def __init__(self, filename):
self.filename = filename
@property
def... | Send a signal after creation of composite field. | Send a signal after creation of composite field.
| Python | bsd-3-clause | wlanslovenija/django-postgres |
7f51b7a74df8e2c8d6756b8c3e95f7fbf47b291b | hashbrown/utils.py | hashbrown/utils.py | from django.conf import settings
from .models import Switch
def is_active(label, user=None):
defaults = getattr(settings, 'HASHBROWN_SWITCH_DEFAULTS', {})
globally_active = defaults[label].get(
'globally_active',
False) if label in defaults else False
description = defaults[label].get(
... | from django.conf import settings
from .models import Switch
SETTINGS_KEY = 'HASHBROWN_SWITCH_DEFAULTS'
def is_active(label, user=None):
defaults = getattr(settings, SETTINGS_KEY, {})
globally_active = defaults[label].get(
'globally_active',
False) if label in defaults else False
descri... | Use a constant for the 'HASHBROWN_SWITCH_DEFAULTS' settings key so it is easier to re-use. | Use a constant for the 'HASHBROWN_SWITCH_DEFAULTS' settings key so it is easier to re-use.
| Python | bsd-2-clause | potatolondon/django-hashbrown |
df57b55c8ffa2a1948d7442d041415a3f19bbca0 | python/Cloudbot/bbm.py | python/Cloudbot/bbm.py | from cloudbot import hook
@hook.command("bbmstaff")
def bbmStaff(text, message, chan):
if chan in ("#bbm-bots", "#bbm-dev", "#bbm-packs", "#builtbrokenmodding", "#builtbroken"):
message("Owners: Dmodoomsirius, DarkGuardsman");
message("textureArtist: Morton0000");
message("Developers: Snow... | from cloudbot import hook
bbmChannels = ["#bbm-bots","#bbm-dev","#builtbroken","#builtbrokenmodding","#bbm-packs","#icbm","#artillects "]
@hook.command("bbmstaff")
def bbmStaff(text, message, chan):
if any(x in chan for x in bbmChannels):
message("Owners: Dmodoomsirius, DarkGuardsman");
#m... | Update and add more commands. | Update and add more commands. | Python | unknown | dmodoomsirius/DmodCode,dmodoomsirius/DmodCode,dsirius/DmodCode,dmodoomsirius/DmodCode,dsirius/DmodCode,dsirius/DmodCode |
373fd6e9332ca225c1939b5bba675161bdec3596 | bika/lims/upgrade/__init__.py | bika/lims/upgrade/__init__.py | # see https://gist.github.com/malthe/704910
import imp
import sys
def create_modules(module_path):
path = ""
module = None
for element in module_path.split('.'):
path += element
try:
module = __import__(path)
except ImportError:
new = imp.new_module(path)
... | # see https://gist.github.com/malthe/704910
import imp
import sys
def create_modules(module_path):
path = ""
module = None
for element in module_path.split('.'):
path += element
try:
module = __import__(path)
except ImportError:
new = imp.new_module(path)
... | Add return False to be sure all works as expected | Add return False to be sure all works as expected
| Python | agpl-3.0 | labsanmartin/Bika-LIMS,labsanmartin/Bika-LIMS,veroc/Bika-LIMS,labsanmartin/Bika-LIMS,veroc/Bika-LIMS,veroc/Bika-LIMS,rockfruit/bika.lims,rockfruit/bika.lims |
6168ce884a1234910bace1a026402a21501b499c | buildbot_travis/steps/base.py | buildbot_travis/steps/base.py | from buildbot.process import buildstep
from buildbot.process.buildstep import SUCCESS, FAILURE, EXCEPTION
from buildbot.process.properties import Properties
from twisted.internet import defer
from ..travisyml import TravisYml
class ConfigurableStep(buildstep.LoggingBuildStep):
"""
Base class for a step whic... | from buildbot.process import buildstep
from buildbot.process.buildstep import SUCCESS, FAILURE, EXCEPTION
from buildbot.process.properties import Properties
from twisted.internet import defer
from ..travisyml import TravisYml
class ConfigurableStep(buildstep.LoggingBuildStep):
"""
Base class for a step whic... | Save .travis.yml into build properties | Save .travis.yml into build properties
| Python | unknown | tardyp/buildbot_travis,isotoma/buildbot_travis,tardyp/buildbot_travis,buildbot/buildbot_travis,buildbot/buildbot_travis,isotoma/buildbot_travis,tardyp/buildbot_travis,tardyp/buildbot_travis,buildbot/buildbot_travis |
dbfa6398ae84d6920181a750f1447fd1b9a9c521 | tests/test_packet.py | tests/test_packet.py | # coding: utf-8
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Tests for Packet.
"""
import os
import json
import pytest
from laniakea.core.providers.packet import... | # coding: utf-8
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Tests for Packet.
"""
import os
import json
import pytest
from laniakea.core.providers.packet import... | Disable dummy Packet test temporarily | Disable dummy Packet test temporarily
| Python | mpl-2.0 | nth10sd/laniakea,MozillaSecurity/laniakea,MozillaSecurity/laniakea,nth10sd/laniakea |
1239623e7e23d7c51e864f715c0908ef2c0d2765 | tests/test_reduce.py | tests/test_reduce.py | import mr_streams as ms
import unittest
# :::: auxilary functions ::::
def sum_reduction(x,y):
return x + y
class TestMisc(unittest.TestCase):
def test_sum_reduce(self):
_ = ms.stream([1,2,3,4,5]).reduce(sum_reduction)
assert _ is 15
def test_reduce_with_one_element(self):
_ = ms... | import mr_streams as ms
import unittest
# :::: auxilary functions ::::
def sum_reduction(x,y):
return x + y
class TestMisc(unittest.TestCase):
def test_sum_reduce(self):
_ = ms.stream([1,2,3,4,5]).reduce(sum_reduction)
assert _ is 15
def test_initializer(self):
_ = ms.stream([1])... | Refactor reduce to handle edge-case streams of length 0 and 1. | Refactor reduce to handle edge-case streams of length 0 and 1.
| Python | mit | caffeine-potent/Streamer-Datastructure |
9a97b9df87f06268ab1075726835da95f4852052 | romanesco/format/tree/nested_to_vtktree.py | romanesco/format/tree/nested_to_vtktree.py | from romanesco.format import dict_to_vtkarrays, dict_to_vtkrow
import vtk
vtk_builder = vtk.vtkMutableDirectedGraph()
node_fields = input["node_fields"]
edge_fields = input["edge_fields"]
dict_to_vtkarrays(input["node_data"], node_fields, vtk_builder.GetVertexData())
if "children" in input and len(input["children"]) >... | from romanesco.format import dict_to_vtkarrays, dict_to_vtkrow
import vtk
vtk_builder = vtk.vtkMutableDirectedGraph()
node_fields = input["node_fields"]
edge_fields = input["edge_fields"]
dict_to_vtkarrays(input["node_data"], node_fields, vtk_builder.GetVertexData())
if "children" in input and len(input["children"]) >... | Revert "tolerate missing edge data" | Revert "tolerate missing edge data"
This reverts commit 93f1f6b24b7e8e61dbbfebe500048db752bc9fed.
| Python | apache-2.0 | Kitware/romanesco,Kitware/romanesco,Kitware/romanesco,Kitware/romanesco,girder/girder_worker,girder/girder_worker,girder/girder_worker |
47831156874d31dcf9b8b61118399cb5ac77632c | PyFVCOM/__init__.py | PyFVCOM/__init__.py | """
The FVCOM Python toolbox (PyFvcom)
"""
__version__ = '1.2'
__author__ = 'Pierre Cazenave'
__credits__ = ['Pierre Cazenave']
__license__ = 'MIT'
__maintainer__ = 'Pierre Cazenave'
__email__ = 'pica@pml.ac.uk'
import inspect
from warnings import warn
# Import numpy so we have it across the board.
import numpy as n... | """
The FVCOM Python toolbox (PyFvcom)
"""
__version__ = '1.2'
__author__ = 'Pierre Cazenave'
__credits__ = ['Pierre Cazenave']
__license__ = 'MIT'
__maintainer__ = 'Pierre Cazenave'
__email__ = 'pica@pml.ac.uk'
import inspect
from warnings import warn
# Import numpy so we have it across the board.
import numpy as n... | Remove the (dodgy) function to convert from an image to data. | Remove the (dodgy) function to convert from an image to data.
| Python | mit | pwcazenave/PyFVCOM |
751f40ef23250cf9fad1374359393588edee477a | back/blog/models/base.py | back/blog/models/base.py | from sqlalchemy.ext.declarative import declared_attr
from blog.lib.database import db
class ModelMixin(object):
"""A base mixin for all models."""
@declared_attr
def __tablename__(cls):
return cls.__name__.lower()
def __str__(self):
return '<{} (id={})>'.format(self.__class__.__name_... | from sqlalchemy.ext.declarative import declared_attr
from blog.lib.database import db
class ModelMixin(object):
"""A base mixin for all models."""
@declared_attr
def __tablename__(cls):
return cls.__name__.lower()
def __str__(self):
return '<{} (id={})>'.format(self.__class__.__name_... | Return "id" key to front instead of "id_". | Return "id" key to front instead of "id_".
| Python | mit | astex/living-with-django,astex/living-with-django,astex/living-with-django |
564d54c377bf6a8c16cae3681934cc7ba5007c76 | bundledApps/wailEndpoint.py | bundledApps/wailEndpoint.py | import tornado.ioloop
import tornado.web
import requests
host = 'localhost'
waybackPort = '8080'
archiveConfigFile = '/Applications/WAIL.app/config/archive.json'
class MainHandler(tornado.web.RequestHandler):
def get(self):
iwa = isWaybackAccessible()
print iwa
self.write(iwa)
def make_ap... | import tornado.ioloop
import tornado.web
import requests
host = 'localhost'
waybackPort = '8080'
# Use a separate JSON file that only queries the local WAIL instance for MemGator
archiveConfigFile = '/Applications/WAIL.app/config/archive.json'
class MainHandler(tornado.web.RequestHandler):
def get(self):
... | Add comment to justify separate JSON file existence | Add comment to justify separate JSON file existence
| Python | mit | machawk1/wail,machawk1/wail,machawk1/wail,machawk1/wail,machawk1/wail,machawk1/wail,machawk1/wail,machawk1/wail |
b32f4955665b8618a9623f6898a15d4da40dc58e | dxtbx/command_line/print_header.py | dxtbx/command_line/print_header.py | def print_header():
import sys
from dxtbx.format.Registry import Registry
# this will do the lookup for every frame - this is strictly not needed
# if all frames are from the same instrument
for arg in sys.argv[1:]:
format = Registry.find(arg)
i = format(arg)
print 'Bea... | def print_header():
import sys
from dxtbx.format.Registry import Registry
# this will do the lookup for every frame - this is strictly not needed
# if all frames are from the same instrument
for arg in sys.argv[1:]:
format = Registry.find(arg)
print 'Using header reader: %s' % ... | Print the Format class used | Print the Format class used | Python | bsd-3-clause | dials/dials,dials/dials,dials/dials,dials/dials,dials/dials |
c790055fa7e6810703599bc0124507133b8a55fc | crispy_forms/compatibility.py | crispy_forms/compatibility.py | import sys
try:
basestring
except:
basestring = str # Python3
PY2 = sys.version_info[0] == 2
if not PY2:
text_type = str
binary_type = bytes
string_types = (str,)
integer_types = (int,)
else:
text_type = unicode
binary_type = str
string_types = basestring
integer_types = (int, ... | import sys
try:
basestring
except:
basestring = str # Python3
PY2 = sys.version_info[0] == 2
if not PY2:
text_type = str
binary_type = bytes
string_types = (str,)
integer_types = (int,)
else:
text_type = unicode
binary_type = str
string_types = basestring
integer_types = (int, ... | Fix lru_cache import as memoize | Fix lru_cache import as memoize
Thanks to @jcomeauictx for the heads up
| Python | mit | scuml/django-crispy-forms,VishvajitP/django-crispy-forms,saydulk/django-crispy-forms,alanwj/django-crispy-forms,schrd/django-crispy-forms,bouttier/django-crispy-forms,smirolo/django-crispy-forms,saydulk/django-crispy-forms,IanLee1521/django-crispy-forms,zixan/django-crispy-forms,Stranger6667/django-crispy-forms,RamezIs... |
3a18c25ef019a9a54475419bfabc4b6e2776df9c | lib/unsubscribe.py | lib/unsubscribe.py | from lxml.html import fromstring as lxml_from_string
from unidecode import unidecode
UNSUBSCRIBE_MARKERS = [
# English
"unsub", "blacklist", "opt-out", "opt out",
# French
"desinscription", "desinscrire", "desabonner", "desabonnement",
"ne souhaitez plus", "ne plus recevoir", "cesser de recevoir"
]
def... | from lxml.html import fromstring as lxml_from_string
from unidecode import unidecode
UNSUBSCRIBE_MARKERS = [
# English
"unsub", "blacklist", "opt-out", "opt out", "removealert", "removeme",
# French
"desinscription", "desinscrire", "desabonner", "desabonnement",
"ne souhaitez plus", "ne plus recevoir", "c... | Fix a bug with uppercase links | Fix a bug with uppercase links
| Python | mit | sylvinus/reclaim-my-gmail-inbox |
593e826b24d83997a5be450be1401e16ec17c07c | application.py | application.py | #!/usr/bin/env python
from __future__ import print_function
import os
from flask.ext.script import Manager, Server
from flask.ext.migrate import Migrate, MigrateCommand
from app import create_app, db
application = create_app(os.getenv('DM_ENVIRONMENT') or 'development')
manager = Manager(application)
manager.add_... | #!/usr/bin/env python
from __future__ import print_function
import os
from dmutils import init_manager
from flask.ext.migrate import Migrate, MigrateCommand
from app import create_app, db
application = create_app(os.getenv('DM_ENVIRONMENT') or 'development')
manager = init_manager(application, 5000, ['./json_sche... | Use new dmutils init_manager to set up reload on schema changes | Use new dmutils init_manager to set up reload on schema changes
| Python | mit | alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api |
39603bde90ebad7e0d70e41403a9a971867dcbac | backend/breach/views.py | backend/breach/views.py | from django.shortcuts import render
from django.http import HttpResponse
def get_work(request):
return HttpResponse('Not implemented')
def work_completed(request):
return HttpResponse('Not implemented')
| from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
def get_work(request):
return HttpResponse('Not implemented')
@csrf_exempt
def work_completed(request):
return HttpResponse('Not implemented')
| Allow POST request to work_completed view | Allow POST request to work_completed view
| Python | mit | esarafianou/rupture,esarafianou/rupture,dimkarakostas/rupture,esarafianou/rupture,dionyziz/rupture,dimriou/rupture,dimriou/rupture,dionyziz/rupture,dimkarakostas/rupture,dionyziz/rupture,dimriou/rupture,esarafianou/rupture,dimkarakostas/rupture,dimriou/rupture,dionyziz/rupture,dimkarakostas/rupture,dimriou/rupture,dion... |
a633fd37a4d795e7b565254ef10aaa0f2ad77f31 | vcontrol/rest/machines/shutdown.py | vcontrol/rest/machines/shutdown.py | from ..helpers import get_allowed
import subprocess
import web
class ShutdownMachineR:
"""
This endpoint is for shutting down a running machine.
"""
allow_origin, rest_url = get_allowed.get_allowed()
def GET(self, machine):
web.header('Access-Control-Allow-Origin', self.allow_origin)
... | from ..helpers import get_allowed
import subprocess
import web
class ShutdownMachineR:
"""
This endpoint is for shutting down a running machine.
"""
allow_origin, rest_url = get_allowed.get_allowed()
def GET(self, machine):
try:
web.header('Access-Control-Allow-Origin', self.... | Put the web.header function in a try/except block | Put the web.header function in a try/except block
| Python | apache-2.0 | cglewis/vcontrol,CyberReboot/vcontrol,CyberReboot/vcontrol,cglewis/vcontrol,CyberReboot/vcontrol,cglewis/vcontrol |
633c3a356a0ed88c00fbb1a5c972171de2255890 | dinosaurs/transaction/database.py | dinosaurs/transaction/database.py | from peewee import *
db = SqliteDatabase('emails.db')
class Transaction(Model):
cost = FloatField()
address = CharField()
tempPass = CharField()
domain = CharField(index=True)
email = CharField(primary_key=True, unique=True)
is_complete = BooleanField(default=False, index=True)
class Met... | from datetime import datetime
from peewee import *
from dinosaurs import settings
from dinosaurs.transaction.coin import generate_address
db = SqliteDatabase(settings.database)
class Transaction(Model):
cost = FloatField()
address = CharField()
started = DateField()
tempPass = CharField()
doma... | Update what a transaction is | Update what a transaction is
| Python | mit | chrisseto/dinosaurs.sexy,chrisseto/dinosaurs.sexy |
820ddf412d09f10977b4bec525d478cc55fe443b | math/prime_test.py | math/prime_test.py | '''
prime_test(n) returns a True if n is a prime number else it returns False
'''
def prime_test(n):
if n <= 1:
return False
if n==2 or n==3:
return True
if n%2==0 or n%3==0:
return False
j = 5
while(j*j <= n):
if n%(j)==0 or n%(j+2)==0:
return False
... | '''
prime_test(n) returns a True if n is a prime number else it returns False
'''
def prime_test(n):
if n <= 1:
return False
if n==2 or n==3:
return True
if n%2==0 or n%3==0:
return False
j = 5
while(j*j <= n):
if n%(j)==0 or n%(j+2)==0:
return False
... | Change the return type to boolean | Change the return type to boolean | Python | mit | amaozhao/algorithms,keon/algorithms |
64a653b6bd6c9aae2492f3ee838bda1fafe639d6 | upnpy/utils.py | upnpy/utils.py | # -*- coding: utf-8 -*-
"""
utils.py
~~~~~~~~
Defines utility functions used by UPnPy.
"""
def camelcase_to_underscore(text):
"""
Convert a camelCasedString to one separated_by_underscores. Treats
neighbouring capitals as acronyms and doesn't separated them, e.g. URL does
not become u_r_l. That would... | # -*- coding: utf-8 -*-
"""
utils.py
~~~~~~~~
Defines utility functions used by UPnPy.
"""
def camelcase_to_underscore(text):
"""
Convert a camelCasedString to one separated_by_underscores. Treats
neighbouring capitals as acronyms and doesn't separated them, e.g. URL does
not become u_r_l. That would... | Correct an AttributeError and a potential IndexErr | Correct an AttributeError and a potential IndexErr
| Python | mit | WenhaoYu/upnpy,Lukasa/upnpy |
41c49a44c5f1bc9747b22b6d1f1088f1354a2cd5 | nes/cpu/decoder.py | nes/cpu/decoder.py | from sqlite3 import Connection, Row
class Decoder:
def __init__(self):
self.conn = Connection('nes.sqlite')
self.conn.row_factory = Row
def __del__(self):
self.conn.close()
def decode(self, opcode):
c = self.conn.cursor()
c.execute('select * from instruction where... | from sqlite3 import Connection, Row
class Decoder:
def __init__(self):
self.conn = Connection('nes.sqlite')
self.conn.row_factory = Row
def __del__(self):
self.conn.close()
def decode(self, opcode):
c = self.conn.cursor()
c.execute('select * from instruction where... | Raise an exception when it's an undocumented opcode. | Raise an exception when it's an undocumented opcode.
| Python | mit | Hexadorsimal/pynes |
6829e9b4cf87b8d8d8b6e5a1c3aaf881f66393cf | healthcheck/contrib/django/status_endpoint/views.py | healthcheck/contrib/django/status_endpoint/views.py | import json
from django.conf import settings
from django.views.decorators.http import require_http_methods
from django.http import HttpResponse
from healthcheck.healthcheck import (
DjangoDBsHealthCheck, FilesDontExistHealthCheck, HealthChecker)
class JsonResponse(HttpResponse):
def __init__(self, data, **k... | import json
from django.conf import settings
from django.views.decorators.http import require_http_methods
from django.http import HttpResponse
from healthcheck.healthcheck import (
DjangoDBsHealthCheck, FilesDontExistHealthCheck, HealthChecker)
class JsonResponse(HttpResponse):
def __init__(self, data, **k... | Remove duplicated JSON encoding for error messages | Remove duplicated JSON encoding for error messages
| Python | mit | yola/healthcheck |
089e8c74106f3a19b229d085d73c932df6fe4e7d | application.py | application.py | from canis import siriusxm, spotify, oauth
def main():
try:
current = siriusxm.get_currently_playing('siriusxmu')
spotify_id = spotify.id_for_song(current)
print(current, spotify_id)
except Exception, e:
print "Error {}".format(e)
if __name__ == "__main__":
oauth.app.run(de... | from canis import siriusxm, spotify, oauth
def main():
try:
current = siriusxm.get_currently_playing('siriusxmu')
spotify_id = spotify.id_for_song(current)
print(current, spotify_id)
except Exception, e:
print "Error {}".format(e)
if __name__ == "__main__":
oauth.app.run()
... | Remove debug mode on flask | Remove debug mode on flask
| Python | mit | maxgoedjen/canis |
697833caade1323ddb9a0b4e51031f1d494262cd | 201705/migonzalvar/biggest_set.py | 201705/migonzalvar/biggest_set.py | #!/usr/bin/env python3
from contextlib import contextmanager
import time
from main import has_subset_sum_zero
class Duration:
def __init__(self, elapsed=None):
self.elapsed = elapsed
@contextmanager
def less_than(secs):
duration = Duration()
tic = time.time()
yield duration
elapsed = ti... | #!/usr/bin/env python3
from contextlib import contextmanager
import time
from main import has_subset_sum_zero
class Duration:
def __init__(self, elapsed=None):
self.elapsed = elapsed
@contextmanager
def less_than(secs):
duration = Duration()
tic = time.time()
yield duration
elapsed = ti... | Use several strategies for performance | Use several strategies for performance
| Python | bsd-3-clause | VigoTech/reto,VigoTech/reto,VigoTech/reto,VigoTech/reto,VigoTech/reto,VigoTech/reto,VigoTech/reto,vigojug/reto,vigojug/reto,vigojug/reto,vigojug/reto,VigoTech/reto,vigojug/reto,vigojug/reto,vigojug/reto,vigojug/reto,VigoTech/reto,VigoTech/reto,vigojug/reto,vigojug/reto |
0c785e349c2000bbf3b22671071a66eaca4d82d0 | astropy/io/votable/__init__.py | astropy/io/votable/__init__.py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package reads and writes data formats used by the Virtual
Observatory (VO) initiative, particularly the VOTable XML format.
"""
from .table import (
parse, parse_single_table, validate, from_table, is_votable)
from .exceptions import (
VO... | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package reads and writes data formats used by the Virtual
Observatory (VO) initiative, particularly the VOTable XML format.
"""
from .table import (
parse, parse_single_table, validate, from_table, is_votable, writeto)
from .exceptions import... | Put astropy.io.votable.writeto in the top-level namespace | Put astropy.io.votable.writeto in the top-level namespace
| Python | bsd-3-clause | DougBurke/astropy,AustereCuriosity/astropy,funbaker/astropy,joergdietrich/astropy,StuartLittlefair/astropy,larrybradley/astropy,tbabej/astropy,mhvk/astropy,pllim/astropy,stargaser/astropy,lpsinger/astropy,joergdietrich/astropy,lpsinger/astropy,AustereCuriosity/astropy,kelle/astropy,saimn/astropy,DougBurke/astropy,bsipo... |
fb1f03c7d46d9274f144a767830cf9c81078e8c8 | kovfig.py | kovfig.py | #! /usr/bin/env python
# coding:utf-8
from os import path
# the number of loop for train IBM Model 2
loop_count = 10
phrase_model_file = path.join(
path.abspath(path.dirname(__file__)),
"phrase.model"
)
bigram_model_file = path.join(
path.abspath(path.dirname(__file__)),
"bigram.model"
)
if __name__... | #! /usr/bin/env python
# coding:utf-8
from os import path
# the number of loop for train IBM Model 2
LOOP_COUNT = 10
PHRASE_MODEL_FILE = path.join(
path.abspath(path.dirname(__file__)),
"phrase.model"
)
BIGRAM_MODEL_FILE = path.join(
path.abspath(path.dirname(__file__)),
"bigram.model"
)
if __name__... | Use upper case variable for global vars | Use upper case variable for global vars
| Python | mit | kenkov/kovlive |
b9b9382a62b00aa00255fbc9271ef5ec2db8c295 | fabfile.py | fabfile.py | from fabric.api import (
cd,
env,
put,
run,
sudo,
task
)
PRODUCTION_IP = '54.154.235.243'
PROJECT_DIRECTORY = '/home/ubuntu/ztm/'
COMPOSE_FILE = 'compose-production.yml'
@task
def production():
env.run = sudo
env.hosts = [
'ubuntu@' + PRODUCTION_IP + ':22',
]
def create... | from datetime import datetime
from fabric.api import (
cd,
env,
put,
run,
sudo,
task
)
PRODUCTION_IP = '54.154.235.243'
PROJECT_DIRECTORY = '/home/ubuntu/ztm/'
BACKUP_DIRECTORY = '/home/ubuntu/backup/'
COMPOSE_FILE = 'compose-production.yml'
@task
def production():
env.run = sudo
en... | Add S3 command for performing backup data | Add S3 command for performing backup data
| Python | mit | prontotools/zendesk-tickets-machine,prontotools/zendesk-tickets-machine,prontotools/zendesk-tickets-machine,prontotools/zendesk-tickets-machine |
873b82225d287dcca9b9bc0e0c3746233d15d947 | utilities.py | utilities.py | """
Various utilities
"""
import pprint
def load_state(path):
"""
Load an n-puzzle state from a file into an array and return it.
"""
result = []
with open(path) as f:
for line in f:
result.append(line.split())
return result
def print_state(state):
"""
Prittily re... | """
Various utilities
"""
import pprint
def load_state(path):
"""
Load an n-puzzle state from a file into an array and return it.
"""
result = []
with open(path) as f:
for line in f:
result.append([])
for square in line.split():
try:
... | Add function to check for goal state. | Add function to check for goal state.
| Python | mit | bandrebandrebandre/npuzz |
422bb9ebfcff9826cf58d17a20df61cea21fdd77 | app/supplier_constants.py | app/supplier_constants.py | # Here we define a set of hardcoded keys that we use when denormalizing data from Supplier/ContactInformation tables
# into the SupplierFramework.declaration field. These are used only by the API and by the
# `digitalmarketplace-scripts/scripts/generate-framework-agreement-*-pages`, which generates framework agreement
... | # Here we define a set of hardcoded keys that we use when denormalizing data from Supplier/ContactInformation tables
# into the SupplierFramework.declaration field. These are used only by the API and by the
# `digitalmarketplace-scripts/scripts/generate-framework-agreement-*-pages`, which generates framework agreement
... | Remove VAT number from supplier constants | Remove VAT number from supplier constants
| Python | mit | alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api |
99909048bc702e21e980bb1167caf9217aa31196 | steel/fields/strings.py | steel/fields/strings.py | import codecs
from steel.fields import Field
from steel.fields.mixin import Fixed
__all__ = ['Bytes', 'String', 'FixedBytes', 'FixedString']
class Bytes(Field):
"A stream of bytes that should be left unconverted"
def encode(self, value):
# Nothing to do here
return value
d... | import codecs
from steel.fields import Field
from steel.fields.mixin import Fixed
__all__ = ['Bytes', 'String', 'FixedBytes', 'FixedString']
class Bytes(Field):
"A stream of bytes that should be left unconverted"
def encode(self, value):
# Nothing to do here
return value
d... | Fix the docstring for FixedString | Fix the docstring for FixedString
| Python | bsd-3-clause | gulopine/steel-experiment |
be00af0a0e87af5b4c82107d2f1356f378b65cb4 | obj_sys/management/commands/tag_the_file.py | obj_sys/management/commands/tag_the_file.py | import os
from optparse import make_option
from django.core.management import BaseCommand
from djangoautoconf.cmd_handler_base.msg_process_cmd_base import DjangoCmdBase
from obj_sys.models_ufs_obj import UfsObj
class FileTagger(DjangoCmdBase):
option_list = BaseCommand.option_list + (
make_option('--tag... | import os
from optparse import make_option
from django.core.management import BaseCommand
from djangoautoconf.cmd_handler_base.msg_process_cmd_base import DjangoCmdBase
from obj_sys.models_ufs_obj import UfsObj
class FileTagger(DjangoCmdBase):
option_list = BaseCommand.option_list + (
make_option('--tag... | Fix the issue that get_or_create returns a tuple instead of one object. | Fix the issue that get_or_create returns a tuple instead of one object.
| Python | bsd-3-clause | weijia/obj_sys,weijia/obj_sys |
fffb98874066d5762b815987d7e6768a2e9cb03c | tests/daemon_uid_gid.py | tests/daemon_uid_gid.py | #!/usr/bin/env python
from os import getuid, geteuid, getgid, getegid
from sys import argv
from time import sleep
from daemonize import Daemonize
pid = argv[1]
log = argv[2]
def main():
uids = getuid(), geteuid()
gids = getgid(), getegid()
with open(log, "w") as f:
f.write(" ".join(map(str, uid... | #!/usr/bin/env python
from os import getuid, geteuid, getgid, getegid
from sys import argv
from time import sleep
from daemonize import Daemonize
pid = argv[1]
log = argv[2]
def main():
uids = getuid(), geteuid()
gids = getgid(), getegid()
with open(log, "w") as f:
f.write(" ".join(map(str, uid... | Support debian based distributives in tests | Support debian based distributives in tests | Python | mit | thesharp/daemonize |
329f4cd5123440baf537db30340fd3d33d7bbbf1 | games/management/commands/makelove.py | games/management/commands/makelove.py | from django.core.management.base import BaseCommand
from games import models, bundle
def package_love(stdout, game, release):
if release.get_asset('love') is not None:
stdout.write(u"SKIPPING {}".format(release))
return
upload = release.get_asset('uploaded')
if upload is None:
s... | import zipfile
from django.core.management.base import BaseCommand
from games import models, bundle
def package_love(stdout, game, release):
if release.get_asset('love') is not None:
stdout.write(u"SKIPPING {}".format(release))
return
upload = release.get_asset('uploaded')
if upload is... | Make sure that uploaded files are zipfiles | Make sure that uploaded files are zipfiles
| Python | mit | stackmachine/bearweb,stackmachine/bearweb,stackmachine/bearweb,stackmachine/bearweb,stackmachine/bearweb,stackmachine/bearweb |
52430087413e24c94a532e67a2c77248ecc0598c | saleor/core/extensions/checks.py | saleor/core/extensions/checks.py | import importlib
from typing import List
from django.conf import settings
from django.core.checks import Error, register
@register()
def check_extensions(app_configs, **kwargs):
"""Confirm a correct import of plugins and manager."""
errors = []
check_manager(errors)
plugins = settings.PLUGINS or []
... | from typing import List
from django.conf import settings
from django.core.checks import Error, register
from django.utils.module_loading import import_string
@register()
def check_extensions(app_configs, **kwargs):
"""Confirm a correct import of plugins and manager."""
errors = []
check_manager(errors)
... | Use django helper to validate manager and plugins paths | Use django helper to validate manager and plugins paths
| Python | bsd-3-clause | mociepka/saleor,mociepka/saleor,mociepka/saleor,maferelo/saleor,maferelo/saleor,maferelo/saleor |
6f8a19c46a1d8b6b31039f212e733cd660551de7 | mws/apis/__init__.py | mws/apis/__init__.py | from .feeds import Feeds
from .finances import Finances
from .inbound_shipments import InboundShipments
from .inventory import Inventory
from .merchant_fulfillment import MerchantFulfillment
from .offamazonpayments import OffAmazonPayments
from .orders import Orders
from .products import Products
from .recommendations ... | from .feeds import Feeds
from .finances import Finances
from .inbound_shipments import InboundShipments
from .inventory import Inventory
from .merchant_fulfillment import MerchantFulfillment
from .offamazonpayments import OffAmazonPayments
from .orders import Orders
from .outbound_shipments import OutboundShipments
fro... | Include the new Subscriptions stub | Include the new Subscriptions stub | Python | unlicense | Bobspadger/python-amazon-mws,GriceTurrble/python-amazon-mws |
22935ee89217ac1f8b8d3c921571381336069584 | lctools/lc.py | lctools/lc.py | from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
import libcloud.security
from config import get_config
def get_lc(profile, resource=None):
if resource is None:
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driv... | from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
import libcloud.security
from config import get_config
def get_lc(profile, resource=None):
if resource is None:
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driv... | Add a hack to overcome driver name inconsistency in libcloud. | Add a hack to overcome driver name inconsistency in libcloud.
| Python | apache-2.0 | novel/lc-tools,novel/lc-tools |
c541e85f8b1dccaabd047027e89791d807550ee5 | fade/config.py | fade/config.py | #!/usr/bin/env python
"""
See LICENSE.txt file for copyright and license details.
"""
import os
basedir = os.path.abspath(os.path.dirname(__file__))
WTF_CSRF_ENABLED = True
SECRET_KEY = '3124534675689780'
# TODO: switch this to postgresql
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
... | #!/usr/bin/env python
"""
See LICENSE.txt file for copyright and license details.
"""
import os
basedir = os.path.abspath(os.path.dirname(__file__))
WTF_CSRF_ENABLED = True
SECRET_KEY = '3124534675689780'
dbuser = 'rockwolf'
dbpass = ''
dbhost = 'testdb'
dbname = 'finance'
SQLALCHEMY_DATABASE_URI = 'postgresql:... | Switch database connection string to pg | Switch database connection string to pg | Python | bsd-3-clause | rockwolf/python,rockwolf/python,rockwolf/python,rockwolf/python,rockwolf/python,rockwolf/python |
6c8feca973703cf87a82cfa954fa3c7a3f152c72 | manage.py | manage.py | from project import app, db
from project import models
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()
| from project import app, db
from project import models
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
@manager.command
def create_db():
"""Creates the db tables."""
db.crea... | Create create_db, drop_db and create_admin functions | Create create_db, drop_db and create_admin functions
| Python | mit | dylanshine/streamschool,dylanshine/streamschool |
e6f3bd9c61be29560e09f5d5d9c7e355ec14c2e3 | manage.py | manage.py | #!/usr/bin/env python
import sys
if __name__ == "__main__":
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| #!/usr/bin/env python
import sys
import os
if __name__ == "__main__":
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| Set a default settings module | Set a default settings module
| Python | bsd-3-clause | wagnerand/olympia,andymckay/addons-server,kumar303/addons-server,andymckay/olympia,aviarypl/mozilla-l10n-addons-server,aviarypl/mozilla-l10n-addons-server,wagnerand/addons-server,lavish205/olympia,Prashant-Surya/addons-server,harry-7/addons-server,harikishen/addons-server,mstriemer/olympia,mozilla/addons-server,andymck... |
34f0e697ba4d6a787f0f4fc294163a09a52c185f | tests/test_arrayfire.py | tests/test_arrayfire.py | import arrayfire
# We're going to test several arrayfire behaviours that we rely on
from asserts import *
import afnumpy as af
import numpy as np
def test_cast():
a = afnumpy.random.rand(2,3)
# Check that device_ptr does not cause a copy
assert a.d_array.device_ptr() == a.d_array.device_ptr()
# Chec... | import arrayfire
# We're going to test several arrayfire behaviours that we rely on
from asserts import *
import afnumpy as af
import numpy as np
def test_af_cast():
a = afnumpy.arrayfire.randu(2,3)
# Check that device_ptr does not cause a copy
assert a.device_ptr() == a.device_ptr()
# Check that ca... | Add a pure arrayfire cast test to check for seg faults | Add a pure arrayfire cast test to check for seg faults
| Python | bsd-2-clause | FilipeMaia/afnumpy,daurer/afnumpy |
aac31b69da5ec3a3622ca7752e8273886b344683 | sublist/sublist.py | sublist/sublist.py | SUPERLIST = "superlist"
SUBLIST = "sublist"
EQUAL = "equal"
UNEQUAL = "unequal"
def check_lists(a, b):
if a == b:
return EQUAL
elif is_sublist(a, b):
return SUBLIST
elif is_sublist(b, a):
return SUPERLIST
else:
return UNEQUAL
def is_sublist(a, b):
return a in [b[i... | SUPERLIST = "superlist"
SUBLIST = "sublist"
EQUAL = "equal"
UNEQUAL = "unequal"
VERY_UNLIKELY_STRING = "ꗲꅯḪꍙ"
def check_lists(a, b):
if a == b:
return EQUAL
_a = VERY_UNLIKELY_STRING.join(map(str, a))
_b = VERY_UNLIKELY_STRING.join(map(str, b))
if _a in _b:
return SUBLIST
elif _b... | Switch back to the substring method - it's faster | Switch back to the substring method - it's faster
| Python | agpl-3.0 | CubicComet/exercism-python-solutions |
6eae274fc200df9319e82abf99d0f2314a17a2af | formlibrary/migrations/0005_auto_20171204_0203.py | formlibrary/migrations/0005_auto_20171204_0203.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-12-04 10:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
dependencies = [
('workflow', '0007_auto_20171204_0203'),
... | # -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-12-04 10:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('workflow', '0007_auto_20171204_0203'),
('formlibrar... | Split migration script of customform | Split migration script of customform
| Python | apache-2.0 | toladata/TolaActivity,toladata/TolaActivity,toladata/TolaActivity,toladata/TolaActivity |
265edc24561bdacfae2412680048c203f7f78c14 | calendarapp.py | calendarapp.py | from kivy.app import App
class CalendarApp(App):
"""Basic App to hold the calendar widget."""
def build(self):
return self.root
| import kivy
kivy.require('1.8.0')
from kivy.config import Config
Config.set('graphics', 'width', '360')
Config.set('graphics', 'height', '640')
from kivy.app import App
class CalendarApp(App):
"""Basic App to hold the calendar widget."""
def build(self):
return self.root
| Set the window size to emulate a mobile device | Set the window size to emulate a mobile device
| Python | mit | hackebrot/garden.calendar |
401aafee6979cc95692555548b1fc10dea44a44e | product/api/views.py | product/api/views.py | from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from .serializers import ProductSerializer
from ..models import Product
from django.http import Http404
from rest_framework.views import APIView
class ProductDetail(APIView):
permission_classes = (IsAuthenticated,)... | from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from .serializers import ProductSerializer
from ..models import Product
from django.http import Http404
from rest_framework.views import APIView
class ProductDetail(APIView):
permission_classes = (IsAuthenticated,)... | Use remote fallback for API request | Use remote fallback for API request
| Python | bsd-3-clause | KlubJagiellonski/pola-backend,KlubJagiellonski/pola-backend,KlubJagiellonski/pola-backend,KlubJagiellonski/pola-backend |
17bd35d7a2b442faebdb39aad07294612d8e7038 | nflh/games.py | nflh/games.py | from datetime import datetime
GAME_VIDEO_BASE_URL = "http://www.nfl.com/feeds-rs/videos/byGameCenter/{0}.json"
LIVE_UPDATE_BASE_URL = "http://www.nfl.com/liveupdate/game-center/{0}/{0}_gtd.json"
class Game(object):
def __init__(self, id_, h, v):
self.id_ = id_
self.date = self.id_[:-2]
s... | from datetime import datetime
GAME_VIDEO_BASE_URL = "http://www.nfl.com/feeds-rs/videos/byGameCenter/{0}.json"
LIVE_UPDATE_BASE_URL = "http://www.nfl.com/liveupdate/game-center/{0}/{0}_gtd.json"
class Game(object):
def __init__(self, id_, h, v):
self.id_ = id_
self.date = self.id_[:-2]
s... | Add videos dict to Games. | Add videos dict to Games.
| Python | apache-2.0 | twbarber/nfl-highlight-bot |
c36b0639190de6517260d6b6e8e5991976336760 | shared/btr3baseball/DatasourceRepository.py | shared/btr3baseball/DatasourceRepository.py | import json
resource_package = __name__
resource_path_format = 'datasource/{}.json'
class DatasourceRepository:
def __init__(self):
self.availableSources = json.loads(pkg_resources.resource_string(resource_package, resource_path_format.format('all')))['available']
self.data = {}
for source... | import pkg_resources
import json
resource_package = __name__
resource_path_format = 'datasource/{}.json'
class DatasourceRepository:
def __init__(self):
self.availableSources = json.loads(pkg_resources.resource_string(resource_package, resource_path_format.format('all')))['available']
self.data = ... | Add pkg_resources back, working forward | Add pkg_resources back, working forward
| Python | apache-2.0 | bryantrobbins/baseball,bryantrobbins/baseball,bryantrobbins/baseball,bryantrobbins/baseball,bryantrobbins/baseball |
e9949cdf609aeb99cfe97c37638c6cb80c947198 | longclaw/longclawshipping/wagtail_hooks.py | longclaw/longclawshipping/wagtail_hooks.py | from wagtail.contrib.modeladmin.options import (
ModelAdmin, modeladmin_register
)
from longclaw.longclawshipping.models import ShippingCountry
class ShippingCountryModelAdmin(ModelAdmin):
model = ShippingCountry
menu_order = 200
menu_icon = 'site'
add_to_settings_menu = False
exclude_from_exp... | from wagtail.contrib.modeladmin.options import (
ModelAdmin, modeladmin_register
)
from longclaw.longclawshipping.models import ShippingCountry
class ShippingCountryModelAdmin(ModelAdmin):
model = ShippingCountry
menu_label = 'Shipping'
menu_order = 200
menu_icon = 'site'
add_to_settings_menu ... | Rename shipping label in model admin | Rename shipping label in model admin
| Python | mit | JamesRamm/longclaw,JamesRamm/longclaw,JamesRamm/longclaw,JamesRamm/longclaw |
8eddab84f27d5c068f5da477e05736c222cac4e2 | mass/utils.py | mass/utils.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Helper functions.
"""
# built-in modules
import json
# 3rd-party modules
from botocore.client import Config
# local modules
from mass.exception import UnsupportedScheduler
from mass.input_handler import InputHandler
def submit(job, protocol=None, priority=1, sched... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Helper functions.
"""
# built-in modules
import json
# 3rd-party modules
from botocore.client import Config
# local modules
from mass.exception import UnsupportedScheduler
from mass.input_handler import InputHandler
def submit(job, protocol=None, priority=1, sched... | Use [job.title] as genealogy of input_handler.save while submit job. | Use [job.title] as genealogy of input_handler.save while submit job.
| Python | apache-2.0 | badboy99tw/mass,KKBOX/mass,KKBOX/mass,badboy99tw/mass,KKBOX/mass,badboy99tw/mass |
facaa380b9b0fbb8f5d6d4d7c6c24257235cbb65 | plugin.py | plugin.py | # -*- coding: utf-8 -*-
"""Load and Unload all GitGutter modules.
This module exports __all__ modules, which Sublime Text needs to know about.
The list of __all__ exported symbols is defined in modules/__init__.py.
"""
try:
from .modules import *
except ValueError:
from modules import *
def plugin_loaded():... | # -*- coding: utf-8 -*-
"""Load and Unload all GitGutter modules.
This module exports __all__ modules, which Sublime Text needs to know about.
The list of __all__ exported symbols is defined in modules/__init__.py.
"""
try:
from .modules import *
except ValueError:
from modules import *
except ImportError:
... | Handle module reload exceptions gracefully | Enhancement: Handle module reload exceptions gracefully
In some rare cases if the internal module structure has changed the 'reload' module can't recover all modules and will fail with ImportError. This is the situation we need to advice a restart of Sublime Text.
| Python | mit | jisaacks/GitGutter |
a07ac44d433981b7476ab3b57339797edddb368c | lenet_slim.py | lenet_slim.py | import tensorflow as tf
slim = tf.contrib.slim
def le_net(images, num_classes=10, scope='LeNet'):
with tf.variable_scope(scope, 'LeNet', [images, num_classes]):
net = slim.conv2d(images, 32, [5, 5], scope='conv1')
net = slim.max_pool2d(net, [2, 2], 2, scope='pool1')
net = slim.conv2d(net,... | import tensorflow as tf
slim = tf.contrib.slim
def le_net(images, num_classes=10, scope='LeNet'):
with tf.variable_scope(scope, 'LeNet', [images, num_classes]):
net = slim.conv2d(images, 32, [5, 5], scope='conv1')
net = slim.max_pool2d(net, [2, 2], 2, scope='pool1')
net = slim.conv2d(net,... | Fix the shape of gap_w | Fix the shape of gap_w | Python | mit | philipperemy/tensorflow-class-activation-mapping |
7f48dde064acbf1c192ab0bf303ac8e80e56e947 | wafer/kv/models.py | wafer/kv/models.py | from django.contrib.auth.models import Group
from django.db import models
from jsonfield import JSONField
class KeyValue(models.Model):
group = models.ForeignKey(Group, on_delete=models.CASCADE)
key = models.CharField(max_length=64, db_index=True)
value = JSONField()
def __unicode__(self):
r... | from django.contrib.auth.models import Group
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from jsonfield import JSONField
@python_2_unicode_compatible
class KeyValue(models.Model):
group = models.ForeignKey(Group, on_delete=models.CASCADE)
key = models.CharField(... | Use @python_2_unicode_compatible rather than repeating methods | Use @python_2_unicode_compatible rather than repeating methods
| Python | isc | CTPUG/wafer,CTPUG/wafer,CTPUG/wafer,CTPUG/wafer |
9be09ccf5749fae1d7a72663d592de5a88a755eb | archive/archive_api/src/responses.py | archive/archive_api/src/responses.py | # -*- encoding: utf-8
import json
from flask import Response, jsonify
class ContextResponse(Response):
"""
This class adds the "@context" parameter to JSON responses before
they're sent to the user.
For an explanation of how this works/is used, read
https://blog.miguelgrinberg.com/post/customiz... | # -*- encoding: utf-8
import json
from flask import Response, jsonify
from werkzeug.wsgi import ClosingIterator
class ContextResponse(Response):
"""
This class adds the "@context" parameter to JSON responses before
they're sent to the user.
For an explanation of how this works/is used, read
htt... | Handle a Werkzeug ClosingIterator (as exposed by the tests) | Handle a Werkzeug ClosingIterator (as exposed by the tests)
| Python | mit | wellcometrust/platform-api,wellcometrust/platform-api,wellcometrust/platform-api,wellcometrust/platform-api |
939e5721300013b2977375f28897a6a573509112 | xml4h/exceptions.py | xml4h/exceptions.py | """
Custom *xml4h* exceptions.
"""
class BaseXml4hException(Exception):
"""
Base exception class for all non-standard exceptions raised by *xml4h*.
"""
pass
class FeatureUnavailableException(BaseXml4hException):
"""
User has attempted to use a feature that is available in some *xml4h*
im... | """
Custom *xml4h* exceptions.
"""
class Xml4hException(Exception):
"""
Base exception class for all non-standard exceptions raised by *xml4h*.
"""
pass
class FeatureUnavailableException(Xml4hException):
"""
User has attempted to use a feature that is available in some *xml4h*
implementa... | Rename base exception class; less ugly | Rename base exception class; less ugly
| Python | mit | jmurty/xml4h,pipermerriam/xml4h,czardoz/xml4h |
a23e211ebdee849543cd7c729a8dafc145ea6b5c | TorGTK/var.py | TorGTK/var.py | from gi.repository import Gtk
import tempfile
import os.path
version = "0.2.2"
# Define default port numbers
default_socks_port = 19050
default_control_port = 19051
# Tor process descriptor placeholder
tor_process = None
# Tor logfile location placeholder
tor_logfile_dir = tempfile.mkdtemp()
tor_logfile_location = ... | from gi.repository import Gtk
import tempfile
import os.path
import platform
version = "0.2.2"
# Define default port numbers
default_socks_port = 19050
default_control_port = 19051
# Tor process descriptor placeholder
tor_process = None
# Tor logfile location placeholder
tor_logfile_dir = tempfile.mkdtemp()
tor_log... | Add OS detection (mainly Windows vs Unix) to preferences directory selection | Add OS detection (mainly Windows vs Unix) to preferences directory selection
| Python | bsd-2-clause | neelchauhan/TorGTK,neelchauhan/TorNova |
3e54119f07b0fdcbbe556e86de3c161a3eb20ddf | mwikiircbot.py | mwikiircbot.py | import ircbotframe
import sys
class Handler:
def __init__(self, host, port=6667, name="MediaWiki", description="MediaWiki recent changes bot", channels=[]):
self.channels = channels
self.bot = ircbotframe.ircBot(host, port, name, description)
self.bot.bind("376", self.endMOTD)
self.... | import ircbotframe
import sys
class Handler:
def __init__(self, host, port=6667, name="MediaWiki", description="MediaWiki recent changes bot", channels=[]):
self.channels = channels
self.bot = ircbotframe.ircBot(host, port, name, description)
self.bot.bind("376", self.endMOTD)
self.... | Fix bot not joining any channels | Fix bot not joining any channels
Also removed unnecessary usage comment.
| Python | mit | fenhl/mwikiircbot |
e91a923efd7cff36368059f47ffbd52248362305 | me_api/middleware/me.py | me_api/middleware/me.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from flask import Blueprint, jsonify
from me_api.configs import Config
me = Blueprint('me', __name__)
@me.route('/')
def index():
routers = []
for module in Config.modules['modules'].values():
routers.append(modu... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from flask import Blueprint, jsonify
from me_api.configs import Config
me = Blueprint('me', __name__)
@me.route('/')
def index():
routers = [module_config['path'] for module_config in
Config.modules['modules']... | Improve the way that get all the routers | Improve the way that get all the routers
| Python | mit | lord63/me-api |
850fba4b07e4c444aa8640c6f4c3816f8a3259ea | website_medical_patient_species/controllers/main.py | website_medical_patient_species/controllers/main.py | # -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import http
from openerp.http import request
from openerp.addons.website_medical.controllers.main import (
WebsiteMedical
)
class WebsiteMedical(WebsiteMedical):
def _inje... | # -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.http import request
from openerp.addons.website_medical.controllers.main import (
WebsiteMedical
)
class WebsiteMedical(WebsiteMedical):
def _inject_medical_detail_vals(se... | Fix lint * Remove stray import to fix lint | [FIX] website_medical_patient_species: Fix lint
* Remove stray import to fix lint
| Python | agpl-3.0 | laslabs/vertical-medical,laslabs/vertical-medical |
bd1df334d68c82b0fc57b4c20da7844155382f83 | numpy-array-of-tuple.py | numpy-array-of-tuple.py | # Numpy converts a list of tuples *not* into an array of tuples, but into a 2D
# array instead.
list_of_tuples = [(1, 2), (3, 4)]
import numpy as np
print('list of tuples:', list_of_tuples, 'type:', type(list_of_tuples))
A = np.array(list_of_tuples)
print('numpy array of tuples:', A, 'type:', type(A))
# It makes comp... | # Numpy converts a list of tuples *not* into an array of tuples, but into a 2D
# array instead.
import numpy as np # 1.11.1
list_of_tuples = [(1, 2), (3, 4)]
print('list of tuples:', list_of_tuples, 'type:', type(list_of_tuples))
A = np.array(list_of_tuples)
print('numpy array of tuples:', A, 'type:', type(A))
# I... | Update numpy array of tuples with np version | Update numpy array of tuples with np version
| Python | mit | cmey/surprising-snippets,cmey/surprising-snippets |
717339f2cb2aed818729a407009a30de53b62a2c | oocgcm/test/test_eos.py | oocgcm/test/test_eos.py | import os
import numpy as np
import xarray as xr
from . import TestCase, assert_equal,assert_allclose,requires_numba
from oocgcm.oceanfuncs.eos import misc
@requires_numba
def test_numpy_spice():
assert_allclose(misc._spice(15,33),0.54458641375)
| import os
import numpy as np
import xarray as xr
from . import TestCase, assert_equal,assert_allclose,requires_numba,has_numba
if has_numba:
from oocgcm.oceanfuncs.eos import misc
@requires_numba
def test_numpy_spice():
assert_allclose(misc._spice(15,33),0.54458641375)
| Fix has_numba for travis build | Fix has_numba for travis build
| Python | apache-2.0 | lesommer/oocgcm |
d60ce9b23bcf2f8c60b2a8ce75eeba8779345b8b | Orange/tests/__init__.py | Orange/tests/__init__.py | import os
import unittest
from Orange.widgets.tests import test_setting_provider, \
test_settings_handler, test_context_handler, \
test_class_values_context_handler, test_domain_context_handler
from Orange.widgets.data.tests import test_owselectcolumns
try:
from Orange.widgets.tests import test_widget
... | import os
import unittest
from Orange.widgets.tests import test_setting_provider, \
test_settings_handler, test_context_handler, \
test_class_values_context_handler, test_domain_context_handler
from Orange.widgets.data.tests import test_owselectcolumns
try:
from Orange.widgets.tests import test_widget
... | Disable widget test. (does not run on travis) | Disable widget test. (does not run on travis)
| Python | bsd-2-clause | marinkaz/orange3,cheral/orange3,qPCR4vir/orange3,kwikadi/orange3,kwikadi/orange3,kwikadi/orange3,cheral/orange3,qusp/orange3,marinkaz/orange3,cheral/orange3,qPCR4vir/orange3,qusp/orange3,qPCR4vir/orange3,marinkaz/orange3,marinkaz/orange3,kwikadi/orange3,cheral/orange3,kwikadi/orange3,qPCR4vir/orange3,qPCR4vir/orange3,q... |
ed1a14ef8f2038950b7e56c7ae5c21daa1d6618a | ordered_model/models.py | ordered_model/models.py | from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.db import models
class OrderedModel(models.Model):
"""
An abstract model that allows objects to be ordered relative to each other.
Provides an ``order`` field.
"""
order = models.Po... | from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import Max
class OrderedModel(models.Model):
"""
An abstract model that allows objects to be ordered relative to each other.
Provides an ``order`` fiel... | Use aggregate Max to fetch new order value. | Use aggregate Max to fetch new order value.
| Python | bsd-3-clause | foozmeat/django-ordered-model,foozmeat/django-ordered-model,pombredanne/django-ordered-model,pombredanne/django-ordered-model,pombredanne/django-ordered-model,foozmeat/django-ordered-model |
6443a0fed1b915745c591f425027d07216d28e12 | podium/urls.py | podium/urls.py | """podium URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-bas... | """podium URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-bas... | Use include, not a view, for the root URL. | Use include, not a view, for the root URL.
| Python | mit | pyatl/podium-django,pyatl/podium-django,pyatl/podium-django |
04c32537f7925aaeb54d8d7aa6da34ce85479c2c | mistraldashboard/test/helpers.py | mistraldashboard/test/helpers.py | # Copyright 2015 Huawei Technologies Co., Ltd.
#
# 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 applic... | # Copyright 2015 Huawei Technologies Co., Ltd.
#
# 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 applic... | Drop mox, no longer needed | Drop mox, no longer needed
The porting of mistral-dashboard is complete.
This fullfills the community goal "Remove Use of mox/mox3 for Testing"
set for Rocky: https://governance.openstack.org/tc/goals/rocky/mox_removal.html
Remove use_mox and remove dead code.
Change-Id: I59839fecd85caaf8b81129b7f890c4ed50d39db8
Sig... | Python | apache-2.0 | openstack/mistral-dashboard,openstack/mistral-dashboard,openstack/mistral-dashboard |
087a706fb8cadf98e3bd515427665997ca2001ba | tests/pytests/functional/states/test_npm.py | tests/pytests/functional/states/test_npm.py | import pytest
from salt.exceptions import CommandExecutionError
@pytest.fixture(scope="module", autouse=True)
def install_npm(sminion):
try:
sminion.functions.pkg.install("npm")
# Just name the thing we're looking for
sminion.functions.npm # pylint: disable=pointless-statement
except ... | import pytest
from salt.exceptions import CommandExecutionError
@pytest.fixture(scope="module", autouse=True)
def install_npm(sminion):
try:
sminion.functions.state.single("pkg.installed", name="npm")
# Just name the thing we're looking for
sminion.functions.npm # pylint: disable=pointles... | Use state.single to not upgrade npm | Use state.single to not upgrade npm
| Python | apache-2.0 | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.