commit
stringlengths 40
40
| old_file
stringlengths 4
264
| new_file
stringlengths 4
264
| old_contents
stringlengths 0
3.26k
| new_contents
stringlengths 1
4.43k
| subject
stringlengths 15
624
| message
stringlengths 15
4.7k
| lang
stringclasses 3
values | license
stringclasses 13
values | repos
stringlengths 5
91.5k
|
---|---|---|---|---|---|---|---|---|---|
b8139440a2509d5b197889664f9ec34be9296210
|
form_designer/contrib/cms_plugins/form_designer_form/cms_plugins.py
|
form_designer/contrib/cms_plugins/form_designer_form/cms_plugins.py
|
from form_designer.contrib.cms_plugins.form_designer_form.models import CMSFormDefinition
from form_designer.views import process_form
from form_designer import settings
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext as _
class FormDesignerPlugin(CMSPluginBase):
model = CMSFormDefinition
module = _('Form Designer')
name = _('Form')
admin_preview = False
render_template = False
def render(self, context, instance, placeholder):
if instance.form_definition.form_template_name:
self.render_template = instance.form_definition.form_template_name
else:
self.render_template = settings.DEFAULT_FORM_TEMPLATE
# Redirection does not work with CMS plugin, hence disable:
return process_form(context['request'], instance.form_definition, context, disable_redirection=True)
plugin_pool.register_plugin(FormDesignerPlugin)
|
from form_designer.contrib.cms_plugins.form_designer_form.models import CMSFormDefinition
from form_designer.views import process_form
from form_designer import settings
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext as _
class FormDesignerPlugin(CMSPluginBase):
model = CMSFormDefinition
module = _('Form Designer')
name = _('Form')
admin_preview = False
render_template = False
cache = False
def render(self, context, instance, placeholder):
if instance.form_definition.form_template_name:
self.render_template = instance.form_definition.form_template_name
else:
self.render_template = settings.DEFAULT_FORM_TEMPLATE
# Redirection does not work with CMS plugin, hence disable:
return process_form(context['request'], instance.form_definition, context, disable_redirection=True)
plugin_pool.register_plugin(FormDesignerPlugin)
|
Disable caching so CSRF tokens are not cached.
|
Disable caching so CSRF tokens are not cached.
|
Python
|
bsd-3-clause
|
USGM/django-form-designer,USGM/django-form-designer
|
21f209b618850d15734c476bd3c1b359b9a7426e
|
infosystem/queue.py
|
infosystem/queue.py
|
import flask
from pika import BlockingConnection, PlainCredentials, ConnectionParameters
class RabbitMQ:
def __init__(self):
self.url = flask.current_app.config['ORMENU_QUEUE_URL']
self.port = flask.current_app.config['ORMENU_QUEUE_PORT']
self.virtual_host = \
flask.current_app.config['ORMENU_QUEUE_VIRTUAL_HOST']
self.username = flask.current_app.config['ORMENU_QUEUE_USERNAME']
self.password = flask.current_app.config['ORMENU_QUEUE_PASSWORD']
credentials = PlainCredentials(self.username, self.password)
self.params = ConnectionParameters(
self.url, self.port, self.virtual_host, credentials)
def connect(self):
try:
return BlockingConnection(self.params)
except Exception as e:
raise
class ProducerQueue:
def __init__(self, exchange, exchange_type):
rabbitMQ = RabbitMQ()
self.connection = rabbitMQ.connect()
self.exchange = exchange
self.channel = self.connection.channel()
self.channel.exchange_declare(
exchange=exchange, exchange_type=exchange_type, durable=True)
def publish(self, routing_key):
body = ""
self.channel.basic_publish(
exchange=self.exchange, routing_key=routing_key, body=body)
self.close()
def close(self):
self.channel.close()
self.connection.close()
|
import flask
from pika import BlockingConnection, PlainCredentials, ConnectionParameters
class RabbitMQ:
def __init__(self):
self.url = flask.current_app.config['INFOSYSTEM_QUEUE_URL']
self.port = flask.current_app.config['INFOSYSTEM_QUEUE_PORT']
self.virtual_host = \
flask.current_app.config['INFOSYSTEM_QUEUE_VIRTUAL_HOST']
self.username = flask.current_app.config['INFOSYSTEM_QUEUE_USERNAME']
self.password = flask.current_app.config['INFOSYSTEM_QUEUE_PASSWORD']
credentials = PlainCredentials(self.username, self.password)
self.params = ConnectionParameters(
self.url, self.port, self.virtual_host, credentials)
def connect(self):
try:
return BlockingConnection(self.params)
except Exception as e:
raise
class ProducerQueue:
def __init__(self, exchange, exchange_type):
rabbitMQ = RabbitMQ()
self.connection = rabbitMQ.connect()
self.exchange = exchange
self.channel = self.connection.channel()
self.channel.exchange_declare(
exchange=exchange, exchange_type=exchange_type, durable=True)
def publish(self, routing_key):
body = ""
self.channel.basic_publish(
exchange=self.exchange, routing_key=routing_key, body=body)
self.close()
def close(self):
self.channel.close()
self.connection.close()
|
Use INFOSYSTEM enviroment for Queue
|
Use INFOSYSTEM enviroment for Queue
|
Python
|
apache-2.0
|
samueldmq/infosystem
|
305ba7ee3fff41a7d866968c5332394301c0e83f
|
digi/wagtail_hooks.py
|
digi/wagtail_hooks.py
|
from wagtail.contrib.modeladmin.options import \
ModelAdmin, ModelAdminGroup, modeladmin_register
from .models import Indicator, FooterLinkSection
class IndicatorAdmin(ModelAdmin):
model = Indicator
menu_icon = 'user'
class FooterLinkSectionAdmin(ModelAdmin):
model = FooterLinkSection
menu_icon = 'redirect'
class DigiHelAdminGroup(ModelAdminGroup):
label = "DigiHel"
items = (IndicatorAdmin, FooterLinkSectionAdmin)
modeladmin_register(DigiHelAdminGroup)
|
from wagtail.contrib.modeladmin.options import \
ModelAdmin, ModelAdminGroup, modeladmin_register
from .models import Indicator, FooterLinkSection
from django.utils.html import format_html
from wagtail.wagtailcore import hooks
class IndicatorAdmin(ModelAdmin):
model = Indicator
menu_icon = 'user'
class FooterLinkSectionAdmin(ModelAdmin):
model = FooterLinkSection
menu_icon = 'redirect'
class DigiHelAdminGroup(ModelAdminGroup):
label = "DigiHel"
items = (IndicatorAdmin, FooterLinkSectionAdmin)
modeladmin_register(DigiHelAdminGroup)
# Enable editing of raw HTML
@hooks.register('insert_editor_js')
def enable_source_editing():
return format_html(
"""
<script>
registerHalloPlugin('hallohtml');
</script>
"""
)
|
Enable HTML source editing in the content editor
|
Enable HTML source editing in the content editor
|
Python
|
mit
|
terotic/digihel,City-of-Helsinki/digihel,terotic/digihel,City-of-Helsinki/digihel,City-of-Helsinki/digihel,terotic/digihel,City-of-Helsinki/digihel
|
c8fdc9aaea13567a293237e7a4126f83a52f0a22
|
salt/modules/test_virtual.py
|
salt/modules/test_virtual.py
|
# -*- coding: utf-8 -*-
'''
Module for running arbitrary tests with a __virtual__ function
'''
from __future__ import absolute_import
def __virtual__():
return False
def test():
return True
|
# -*- coding: utf-8 -*-
'''
Module for running arbitrary tests with a __virtual__ function
'''
from __future__ import absolute_import
def __virtual__():
return False
def ping():
return True
|
Fix mis-naming from pylint cleanup
|
Fix mis-naming from pylint cleanup
|
Python
|
apache-2.0
|
saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt
|
60497ba61c80863cd0414e39a9cd12b42b519897
|
chainer/training/extensions/value_observation.py
|
chainer/training/extensions/value_observation.py
|
from chainer.training import extension
import time
def observe_value(key, target_func):
"""Returns a trainer extension to continuously record a value.
Args:
key (str): Key of observation to record.
target_func (function): Function that returns the value to record.
It must take one argument: trainer object.
Returns:
The extension function.
"""
@extension.make_extension(
trigger=(1, 'epoch'), priority=extension.PRIORITY_WRITER)
def _observe_value(trainer):
trainer.observation[key] = target_func(trainer)
return _observe_value
def observe_time(key='time'):
"""Returns a trainer extension to record the elapsed time.
Args:
key (str): Key of observation to record.
Returns:
The extension function.
"""
start_time = time.time()
return observe_value(key, lambda _: time.time() - start_time)
def observe_lr(optimizer, key='lr'):
"""Returns a trainer extension to record the learning rate.
Args:
optimizer: Optimizer object whose learning rate is recorded.
key (str): Key of observation to record.
Returns:
The extension function.
"""
return observe_value(key, lambda _: optimizer.lr)
|
import time
from chainer.training import extension
def observe_value(key, target_func):
"""Returns a trainer extension to continuously record a value.
Args:
key (str): Key of observation to record.
target_func (function): Function that returns the value to record.
It must take one argument: trainer object.
Returns:
The extension function.
"""
@extension.make_extension(
trigger=(1, 'epoch'), priority=extension.PRIORITY_WRITER)
def _observe_value(trainer):
trainer.observation[key] = target_func(trainer)
return _observe_value
def observe_time(key='time'):
"""Returns a trainer extension to record the elapsed time.
Args:
key (str): Key of observation to record.
Returns:
The extension function.
"""
start_time = time.time()
return observe_value(key, lambda _: time.time() - start_time)
def observe_lr(optimizer, key='lr'):
"""Returns a trainer extension to record the learning rate.
Args:
optimizer: Optimizer object whose learning rate is recorded.
key (str): Key of observation to record.
Returns:
The extension function.
"""
return observe_value(key, lambda _: optimizer.lr)
|
Split system import and project import
|
Split system import and project import
|
Python
|
mit
|
cupy/cupy,chainer/chainer,keisuke-umezawa/chainer,wkentaro/chainer,okuta/chainer,ktnyt/chainer,wkentaro/chainer,jnishi/chainer,tkerola/chainer,keisuke-umezawa/chainer,jnishi/chainer,niboshi/chainer,delta2323/chainer,keisuke-umezawa/chainer,ktnyt/chainer,chainer/chainer,ysekky/chainer,chainer/chainer,keisuke-umezawa/chainer,niboshi/chainer,aonotas/chainer,rezoo/chainer,hvy/chainer,pfnet/chainer,okuta/chainer,jnishi/chainer,hvy/chainer,kiyukuta/chainer,cupy/cupy,niboshi/chainer,anaruse/chainer,hvy/chainer,chainer/chainer,niboshi/chainer,ronekko/chainer,jnishi/chainer,ktnyt/chainer,hvy/chainer,okuta/chainer,cupy/cupy,cupy/cupy,kashif/chainer,okuta/chainer,wkentaro/chainer,wkentaro/chainer,ktnyt/chainer
|
2b11762c418d1a985c3bd64d76abbf9b515bb8da
|
scanpointgenerator/compat.py
|
scanpointgenerator/compat.py
|
import os
try:
range_ = xrange
except NameError:
# For Python3
range_ = range
if os.name == 'java':
import scisoftpy as numpy
else:
import numpy
np = numpy
|
import os
try:
range_ = xrange
except NameError:
# For Python3
range_ = range
if os.name == 'java':
import numjy as numpy
else:
import numpy
np = numpy
|
Replace scisoftpy import with numjy
|
Replace scisoftpy import with numjy
|
Python
|
apache-2.0
|
dls-controls/scanpointgenerator
|
1f22226575455349b3417cdae70a7a5b7181c3b3
|
tests/test_wikibugs2.py
|
tests/test_wikibugs2.py
|
import wikibugs
import configfetcher
import unittest
import os
p = os.path.split(__file__)[0]
class TestWikibugs(unittest.TestCase):
def setUp(self):
self.bugs = wikibugs.Wikibugs2(
configfetcher.ConfigFetcher()
)
def test_offline_scrape(self):
content = open(p + "/T87834", encoding="utf-8").read()
tags = self.bugs.get_tags(content)
self.assertSetEqual(set(tags), {
'§ Fundraising Sprint Devo',
'§ Fundraising Tech Backlog',
'Wikimedia-Fundraising',
'Wikimedia-Fundraising-CiviCRM',
})
self.assertSetEqual(set(next(iter(tags.values()))), {
'shade',
'disabled',
'uri',
'tagtype'
})
|
# encoding: utf-8
import wikibugs
import configfetcher
import unittest
import os
import requests
p = os.path.split(__file__)[0]
class TestWikibugs(unittest.TestCase):
def setUp(self):
self.bugs = wikibugs.Wikibugs2(
configfetcher.ConfigFetcher()
)
def run_scrape(self, content):
tags = self.bugs.get_tags(content)
self.assertSetEqual(set(tags), {
'§ Fundraising Sprint Devo',
'§ Fundraising Tech Backlog',
'Wikimedia-Fundraising',
'Wikimedia-Fundraising-CiviCRM',
})
self.assertSetEqual(set(next(iter(tags.values()))), {
'shade',
'disabled',
'uri',
'tagtype'
})
def test_offline_scrape(self):
content = open(p + "/T87834", encoding="utf-8").read()
self.run_scrape(content)
def test_online_scrape(self):
content = requests.get('https://phabricator.wikimedia.org/T87834').text
self.run_scrape(content)
|
Add online project scrape test
|
Add online project scrape test
Change-Id: Idc112f9397ac2f2fcfe51ca60259b257dff86e91
|
Python
|
mit
|
wikimedia/labs-tools-wikibugs2,wikimedia/labs-tools-wikibugs2
|
a774f3750b506c77f2c37d08b3d33dc66da2a12d
|
jsonmapping/util.py
|
jsonmapping/util.py
|
import os
import json
from jsonschema import Draft4Validator
def validate_mapping(mapping):
""" Validate a mapping configuration file against the relevant schema. """
file_path = os.path.join(os.path.dirname(__file__),
'schemas', 'mapping.json')
with open(file_path, 'rb') as fh:
validator = Draft4Validator(json.load(fh))
validator.validate(mapping)
return mapping
class RefScoped(object):
""" Objects which have a JSON schema-style scope. """
def __init__(self, resolver, scoped, scope=None, parent=None, name=None):
self.resolver = resolver
self._scoped = scoped
self._scope = scope or ''
self.name = name
self.parent = parent
@property
def id(self):
return self._scoped.get('id')
@property
def path(self):
if self.id is not None:
return self.id
if self.parent:
path = self.parent.path
if self.name:
if '#' not in path:
return path + '#/' + self.name
else:
return path + '/' + self.name
return path
@property
def scope(self):
if self.id:
return self.id
if self.parent:
return self.parent.scope
return self._scope
|
import os
import json
from jsonschema import Draft4Validator
def validate_mapping(mapping):
""" Validate a mapping configuration file against the relevant schema. """
file_path = os.path.join(os.path.dirname(__file__),
'schemas', 'mapping.json')
with open(file_path, 'r') as fh:
validator = Draft4Validator(json.load(fh))
validator.validate(mapping)
return mapping
class RefScoped(object):
""" Objects which have a JSON schema-style scope. """
def __init__(self, resolver, scoped, scope=None, parent=None, name=None):
self.resolver = resolver
self._scoped = scoped
self._scope = scope or ''
self.name = name
self.parent = parent
@property
def id(self):
return self._scoped.get('id')
@property
def path(self):
if self.id is not None:
return self.id
if self.parent:
path = self.parent.path
if self.name:
if '#' not in path:
return path + '#/' + self.name
else:
return path + '/' + self.name
return path
@property
def scope(self):
if self.id:
return self.id
if self.parent:
return self.parent.scope
return self._scope
|
Fix python 3 compat. BREAKS python 2.x
|
Fix python 3 compat. BREAKS python 2.x
|
Python
|
mit
|
Ramblurr/jsonmapping
|
64d17f591bfde49d3a7b5f49f987c1138eecebf8
|
tests/source/start_trace.py
|
tests/source/start_trace.py
|
"""Write some logs."""
import sys
import time
from mdk import start
mdk = start()
def main():
session = mdk.session()
session.info("process1", "hello")
time.sleep(1)
sys.stdout.write(session.inject())
sys.stdout.flush()
mdk.stop()
if __name__ == '__main__':
main()
|
"""Write some logs."""
import sys
import time
from mdk import start
mdk = start()
def main():
session = mdk.session()
session.info("process1", "hello")
time.sleep(5)
sys.stdout.write(session.inject())
sys.stdout.flush()
mdk.stop()
if __name__ == '__main__':
main()
|
Increase sleep in test to reduce timing sensitivity with prod servers.
|
Increase sleep in test to reduce timing sensitivity with prod servers.
|
Python
|
apache-2.0
|
datawire/mdk,datawire/mdk,datawire/mdk,datawire/mdk
|
14ea472acfce8b5317a8c8c970db901501ea34c0
|
_tests/macro_testing/runner.py
|
_tests/macro_testing/runner.py
|
# -*- coding: utf-8 -*-
import os, os.path
import sys
import unittest
from macrotest import JSONSpecMacroTestCaseFactory
def JSONTestCaseLoader(tests_path, recursive=False):
"""
Load JSON specifications for Jinja2 macro test cases from the given
path and returns the resulting test classes.
This function will create a MacroTestCase subclass (using
JSONSpecMacrosTestCaseFactory) for each JSON file in the given path.
If `recursive` is True, it will also look in subdirectories. This is
not yet supported.
"""
json_files = [f for f in os.listdir(tests_path) if f.endswith('.json')]
for json_file in json_files:
# Create a camelcased name for the test. This is a minor thing, but I
# think it's nice.
name, extension = os.path.splitext(json_file)
class_name = ''.join(x for x in name.title() if x not in ' _-') + 'TestCase'
# Get the full path to the file and create a test class
json_file_path = os.path.join(tests_path, json_file)
test_class = JSONSpecMacroTestCaseFactory(class_name, json_file_path)
# Add the test class to globals() so that unittest.main() picks it up
globals()[class_name] = test_class
if __name__ == '__main__':
JSONTestCaseLoader('./tests/')
unittest.main()
|
# -*- coding: utf-8 -*-
import os, os.path
import sys
import unittest
from macrotest import JSONSpecMacroTestCaseFactory
def JSONTestCaseLoader(tests_path, recursive=False):
"""
Load JSON specifications for Jinja2 macro test cases from the given
path and returns the resulting test classes.
This function will create a MacroTestCase subclass (using
JSONSpecMacrosTestCaseFactory) for each JSON file in the given path.
If `recursive` is True, it will also look in subdirectories. This is
not yet supported.
"""
path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), tests_path))
json_files = [f for f in os.listdir(path) if f.endswith('.json')]
for json_file in json_files:
# Create a camelcased name for the test. This is a minor thing, but I
# think it's nice.
name, extension = os.path.splitext(json_file)
class_name = ''.join(x for x in name.title() if x not in ' _-') + 'TestCase'
# Get the full path to the file and create a test class
json_file_path = os.path.join(path, json_file)
test_class = JSONSpecMacroTestCaseFactory(class_name, json_file_path)
# Add the test class to globals() so that unittest.main() picks it up
globals()[class_name] = test_class
if __name__ == '__main__':
JSONTestCaseLoader('./tests/')
unittest.main()
|
Make the paths not relative, so tests can be run from anywhere.
|
Make the paths not relative, so tests can be run from anywhere.
|
Python
|
cc0-1.0
|
kave/cfgov-refresh,kave/cfgov-refresh,kave/cfgov-refresh,kave/cfgov-refresh
|
90699f4fa6c1ce2b02e81a8fef9bfafd2175fa7f
|
kmapper/__init__.py
|
kmapper/__init__.py
|
from .kmapper import KeplerMapper
from .kmapper import cluster
from .kmapper import Cover
from .kmapper import GraphNerve
|
from .kmapper import KeplerMapper
from .kmapper import cluster
from .cover import Cover
from .nerve import GraphNerve
import pkg_resources
__version__ = pkg_resources.get_distribution('kmapper').version
|
Add __version__ variable to package
|
Add __version__ variable to package
|
Python
|
mit
|
MLWave/kepler-mapper,MLWave/kepler-mapper,MLWave/kepler-mapper
|
884852eeb2dec07dccefc26595f097ec9ae8532b
|
forum/forms.py
|
forum/forms.py
|
from django.forms import ModelForm,Textarea
from .models import Post
class PostForm(ModelForm):
class Meta:
model = Post
fields = ('subject','body')
widgets = {
'body': Textarea(
attrs={
'data-provide':'markdown',
'data-hidden-buttons':'cmdHeading',
}),
}
|
from django.forms import ModelForm,Textarea,TextInput
from .models import Post
class PostForm(ModelForm):
class Meta:
model = Post
fields = ('subject','body')
widgets = {
'subject': TextInput(attrs={'autofocus':'autofocus'}),
'body': Textarea(
attrs={
'data-provide':'markdown',
'data-hidden-buttons':'cmdHeading',
}),
}
|
Add autofocus to subject field
|
Add autofocus to subject field
|
Python
|
mit
|
Kromey/fbxnano,Kromey/akwriters,Kromey/fbxnano,Kromey/akwriters,Kromey/fbxnano,Kromey/fbxnano,Kromey/akwriters,Kromey/akwriters
|
16553fd759e70d93824407f18cdea419703d85d4
|
gcn/metrics.py
|
gcn/metrics.py
|
import tensorflow as tf
def masked_softmax_cross_entropy(preds, labels, mask):
"""Softmax cross-entropy loss with masking."""
loss = tf.nn.softmax_cross_entropy_with_logits(logits=preds, lables=labels)
mask = tf.cast(mask, dtype=tf.float32)
mask /= tf.reduce_mean(mask)
loss *= mask
return tf.reduce_mean(loss)
def masked_accuracy(preds, labels, mask):
"""Accuracy with masking."""
correct_prediction = tf.equal(tf.argmax(preds, 1), tf.argmax(labels, 1))
accuracy_all = tf.cast(correct_prediction, tf.float32)
mask = tf.cast(mask, dtype=tf.float32)
mask /= tf.reduce_mean(mask)
accuracy_all *= mask
return tf.reduce_mean(accuracy_all)
|
import tensorflow as tf
def masked_softmax_cross_entropy(preds, labels, mask):
"""Softmax cross-entropy loss with masking."""
loss = tf.nn.softmax_cross_entropy_with_logits(logits=preds, labels=labels)
mask = tf.cast(mask, dtype=tf.float32)
mask /= tf.reduce_mean(mask)
loss *= mask
return tf.reduce_mean(loss)
def masked_accuracy(preds, labels, mask):
"""Accuracy with masking."""
correct_prediction = tf.equal(tf.argmax(preds, 1), tf.argmax(labels, 1))
accuracy_all = tf.cast(correct_prediction, tf.float32)
mask = tf.cast(mask, dtype=tf.float32)
mask /= tf.reduce_mean(mask)
accuracy_all *= mask
return tf.reduce_mean(accuracy_all)
|
Fix typo for named argument
|
Fix typo for named argument
|
Python
|
mit
|
tkipf/gcn
|
1b7634e3a98919df5f2f4d54c57bb72dfbf308df
|
py3-test/tests.py
|
py3-test/tests.py
|
# -*- coding: utf-8 -*-
import nose.tools as nt
from asyncio import get_event_loop
from asyncio import sleep as async_sleep
from pyee import EventEmitter
def test_async_emit():
"""Test that event_emitters can handle wrapping coroutines
"""
ee = EventEmitter()
loop = get_event_loop()
class SenseWasCalled():
def __init__(self):
self.was_called = False
def am_calling(self):
self.was_called = True
def assert_was_called(self):
nt.assert_true(self.was_called)
sensor = SenseWasCalled()
@ee.on('event')
async def event_handler():
sensor.am_calling()
ee.emit('event')
loop.run_until_complete(async_sleep(1))
sensor.assert_was_called()
|
# -*- coding: utf-8 -*-
import nose.tools as nt
from asyncio import Future, gather, get_event_loop, sleep
from pyee import EventEmitter
def test_async_emit():
"""Test that event_emitters can handle wrapping coroutines
"""
loop = get_event_loop()
ee = EventEmitter(loop=loop)
future = Future()
@ee.on('event')
async def event_handler():
future.set_result(True)
async def create_timeout(loop=loop):
await sleep(1, loop=loop)
future.cancel()
timeout = create_timeout(loop=loop)
@future.add_done_callback
def _done(result):
nt.assert_true(result)
ee.emit('event')
loop.run_until_complete(gather(future, timeout))
|
Rewrite asyncio test to use futures
|
Rewrite asyncio test to use futures
|
Python
|
mit
|
jfhbrook/pyee
|
a8bb719061a68b5d322868768203476c4ee1e9b9
|
gnocchi/cli.py
|
gnocchi/cli.py
|
# Copyright (c) 2013 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from gnocchi.indexer import sqlalchemy as sql_db
from gnocchi.rest import app
from gnocchi import service
def storage_dbsync():
service.prepare_service()
indexer = sql_db.SQLAlchemyIndexer(cfg.CONF)
indexer.upgrade()
def api():
service.prepare_service()
app.build_server()
|
# Copyright (c) 2013 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from gnocchi.indexer import sqlalchemy as sql_db
from gnocchi.rest import app
from gnocchi import service
def storage_dbsync():
service.prepare_service()
indexer = sql_db.SQLAlchemyIndexer(cfg.CONF)
indexer.connect()
indexer.upgrade()
def api():
service.prepare_service()
app.build_server()
|
Connect to database before upgrading it
|
Connect to database before upgrading it
This change ensure we are connected to the database before
we upgrade it.
Change-Id: Ia0be33892a99897ff294d004f4d935f3753e6200
|
Python
|
apache-2.0
|
idegtiarov/gnocchi-rep,leandroreox/gnocchi,sileht/gnocchi,idegtiarov/gnocchi-rep,gnocchixyz/gnocchi,sileht/gnocchi,idegtiarov/gnocchi-rep,gnocchixyz/gnocchi,leandroreox/gnocchi
|
45fcbaa7515faaa2f812bd9ceb0800fbeb64f1e7
|
pytest_pycharm.py
|
pytest_pycharm.py
|
# -*- coding: utf-8 -*-
import threading
def pytest_exception_interact(node, call, report):
"""
Drop into PyCharm debugger, if available, on uncaught exceptions.
"""
try:
import pydevd
from pydevd import pydevd_tracing
except ImportError:
pass
else:
exctype, value, traceback = call.excinfo._excinfo
frames = []
while traceback:
frames.append(traceback.tb_frame)
traceback = traceback.tb_next
thread = threading.current_thread()
frames_by_id = dict([(id(frame), frame) for frame in frames])
frame = frames[-1]
thread.additionalInfo.exception = (exctype, value, traceback)
thread.additionalInfo.pydev_force_stop_at_exception = (frame, frames_by_id)
thread.additionalInfo.message = "test fail"
debugger = pydevd.debugger
debugger.force_post_mortem_stop += 1
pydevd_tracing.SetTrace(None)
debugger.handle_post_mortem_stop(thread.additionalInfo, thread)
return report
|
# -*- coding: utf-8 -*-
import threading
def pytest_exception_interact(node, call, report):
"""
Drop into PyCharm debugger, if available, on uncaught exceptions.
"""
try:
import pydevd
from pydevd import pydevd_tracing
except ImportError:
pass
else:
exctype, value, traceback = call.excinfo._excinfo
frames = []
while traceback:
frames.append(traceback.tb_frame)
traceback = traceback.tb_next
thread = threading.current_thread()
frames_by_id = dict([(id(frame), frame) for frame in frames])
frame = frames[-1]
thread.additionalInfo.exception = (exctype, value, traceback)
thread.additionalInfo.pydev_force_stop_at_exception = (frame, frames_by_id)
thread.additionalInfo.message = "test fail"
debugger = pydevd.debugger
if hasattr(debugger, "force_post_mortem_stop"):
debugger.force_post_mortem_stop += 1
pydevd_tracing.SetTrace(None)
debugger.handle_post_mortem_stop(thread.additionalInfo, thread)
return report
|
Fix for pycharm 4.0.0 changes
|
Fix for pycharm 4.0.0 changes
|
Python
|
bsd-3-clause
|
jlubcke/pytest-pycharm
|
68fa1fd0df0f4048ac32e80698ebd872fb1f7fba
|
pytest_pycharm.py
|
pytest_pycharm.py
|
# -*- coding: utf-8 -*-
import threading
def pytest_exception_interact(node, call, report):
"""
Drop into PyCharm debugger, if available, on uncaught exceptions.
"""
try:
import pydevd
from pydevd import pydevd_tracing
except ImportError:
pass
else:
exctype, value, traceback = call.excinfo._excinfo
frames = []
while traceback:
frames.append(traceback.tb_frame)
traceback = traceback.tb_next
thread = threading.current_thread()
frames_by_id = dict([(id(frame), frame) for frame in frames])
frame = frames[-1]
exception = (exctype, value, traceback)
thread.additional_info.pydev_message = 'test fail'
debugger = pydevd.debugger
pydevd_tracing.SetTrace(None) # no tracing from here
debugger.handle_post_mortem_stop(thread, frame, frames_by_id, exception)
return report
|
# -*- coding: utf-8 -*-
import threading
def pytest_exception_interact(node, call, report):
"""
Drop into PyCharm debugger, if available, on uncaught exceptions.
"""
try:
import pydevd
from pydevd import pydevd_tracing
except ImportError:
pass
else:
exctype, value, traceback = call.excinfo._excinfo
frames = []
while traceback:
frames.append(traceback.tb_frame)
traceback = traceback.tb_next
thread = threading.current_thread()
frames_by_id = dict([(id(frame), frame) for frame in frames])
frame = frames[-1]
exception = (exctype, value, traceback)
thread.additional_info.pydev_message = 'test fail'
try:
debugger = pydevd.debugger
except AttributeError:
debugger = pydevd.get_global_debugger()
pydevd_tracing.SetTrace(None) # no tracing from here
debugger.handle_post_mortem_stop(thread, frame, frames_by_id, exception)
return report
|
Fix stopping on a breakpoint for PyCharm 2017.3
|
Fix stopping on a breakpoint for PyCharm 2017.3
|
Python
|
bsd-3-clause
|
jlubcke/pytest-pycharm
|
82740c7956a2bae0baceedd658b9ad9352254ad0
|
nlppln/wfgenerator.py
|
nlppln/wfgenerator.py
|
from scriptcwl import WorkflowGenerator as WFGenerator
from .utils import CWL_PATH
class WorkflowGenerator(WFGenerator):
def __init__(self, working_dir=None, copy_steps=True):
WFGenerator.__init__(self, steps_dir=CWL_PATH, working_dir=working_dir,
copy_steps=copy_steps)
def save(self, fname, inline=True, relative=False, validate=True,
encoding='utf-8'):
"""Save workflow to file
For nlppln, the default is to save steps inline.
"""
super(WorkflowGenerator, self).save(fname,
inline=inline,
relative=relative,
validate=validate,
encoding=encoding)
|
from scriptcwl import WorkflowGenerator as WFGenerator
from .utils import CWL_PATH
class WorkflowGenerator(WFGenerator):
def __init__(self, working_dir=None):
WFGenerator.__init__(self, steps_dir=CWL_PATH, working_dir=working_dir)
def save(self, fname, validate=True, wd=True, inline=False, relative=False,
pack=False, encoding='utf-8'):
"""Save workflow to file
For nlppln, the default is to use a working directory (and save steps
using the ``wd`` option).
"""
super(WorkflowGenerator, self).save(fname,
validate=validate,
wd=wd,
inline=inline,
relative=relative,
pack=pack,
encoding=encoding)
|
Update to use newest (unreleased) scriptcwl options
|
Update to use newest (unreleased) scriptcwl options
|
Python
|
apache-2.0
|
WhatWorksWhenForWhom/nlppln,WhatWorksWhenForWhom/nlppln,WhatWorksWhenForWhom/nlppln
|
b728470c61fbd742052e5befb4c27adbacef1a7e
|
pinax_theme_bootstrap/templatetags/pinax_theme_bootstrap_tags.py
|
pinax_theme_bootstrap/templatetags/pinax_theme_bootstrap_tags.py
|
from django import template
from django.contrib.messages.utils import get_level_tags
LEVEL_TAGS = get_level_tags()
register = template.Library()
@register.simple_tag()
def get_message_tags(message):
"""
Returns tags for a message
"""
level_name = LEVEL_TAGS[message.level]
if level_name == u"error":
level_name = u"danger"
level_tag = u"alert-{name}".format(name=level_name)
tags = [level_tag]
if message.extra_tags:
tags.append(message.extra_tags)
return u" ".join(tags)
|
from django import template
from django.contrib.messages.utils import get_level_tags
LEVEL_TAGS = get_level_tags()
register = template.Library()
@register.simple_tag()
def get_message_tags(message):
"""
Returns the message's level_tag prefixed with Bootstrap's "alert-" prefix
along with any tags included in message.extra_tags
Messages in Django >= 1.7 have a message.level_tag attr
"""
level_tag = LEVEL_TAGS[message.level]
if level_tag == u"error":
level_tag = u"danger"
alert_level_tag = u"alert-{tag}".format(tag=level_tag)
tags = [alert_level_tag]
if message.extra_tags:
tags.append(message.extra_tags)
return u" ".join(tags)
|
Use level_tag to be consistent with Django >= 1.7
|
Use level_tag to be consistent with Django >= 1.7
|
Python
|
mit
|
grahamu/pinax-theme-bootstrap,jacobwegner/pinax-theme-bootstrap,foraliving/foraliving,jacobwegner/pinax-theme-bootstrap,druss16/danslist,druss16/danslist,foraliving/foraliving,foraliving/foraliving,grahamu/pinax-theme-bootstrap,jacobwegner/pinax-theme-bootstrap,grahamu/pinax-theme-bootstrap,druss16/danslist
|
fec7885d2632b887002f0071f4898faf52dd927c
|
chainerx/__init__.py
|
chainerx/__init__.py
|
import sys
if sys.version_info[0] < 3:
_available = False
else:
try:
from chainerx import _core
_available = True
except Exception:
_available = False
if _available:
from numpy import dtype, bool_, int8, int16, int32, int64, uint8, float32, float64 # NOQA
from chainerx._core import * # NOQA
from builtins import bool, int, float # NOQA
from chainerx.creation.from_data import asanyarray # NOQA
from chainerx.creation.from_data import fromfile # NOQA
from chainerx.creation.from_data import fromfunction # NOQA
from chainerx.creation.from_data import fromiter # NOQA
from chainerx.creation.from_data import fromstring # NOQA
from chainerx.creation.from_data import loadtxt # NOQA
_global_context = _core.Context()
_core.set_global_default_context(_global_context)
# Add workaround implementation for NumPy-compatible functions
from chainerx import _numpy_compat_workarounds
_numpy_compat_workarounds.populate()
else:
class ndarray(object):
pass # for type testing
def is_available():
return _available
|
import sys
if sys.version_info[0] < 3:
_available = False
else:
try:
from chainerx import _core
_available = True
except Exception:
_available = False
if _available:
from numpy import dtype, bool_, int8, int16, int32, int64, uint8, float32, float64 # NOQA
from chainerx._core import * # NOQA
from builtins import bool, int, float # NOQA
from chainerx.creation.from_data import asanyarray # NOQA
from chainerx.creation.from_data import fromfile # NOQA
from chainerx.creation.from_data import fromfunction # NOQA
from chainerx.creation.from_data import fromiter # NOQA
from chainerx.creation.from_data import fromstring # NOQA
from chainerx.creation.from_data import loadtxt # NOQA
_global_context = _core.Context()
_core.set_global_default_context(_global_context)
# Add workaround implementation for NumPy-compatible functions
from chainerx import _numpy_compat_workarounds
_numpy_compat_workarounds.populate()
else:
class ndarray(object):
"""Dummy class for type testing."""
def __init__(self, *args, **kwargs):
raise RuntimeError('chainerx is not available.')
def is_available():
return _available
|
Raise an error on dummy class init
|
Raise an error on dummy class init
|
Python
|
mit
|
okuta/chainer,jnishi/chainer,chainer/chainer,ktnyt/chainer,ktnyt/chainer,okuta/chainer,hvy/chainer,niboshi/chainer,ktnyt/chainer,chainer/chainer,ktnyt/chainer,hvy/chainer,wkentaro/chainer,jnishi/chainer,jnishi/chainer,okuta/chainer,wkentaro/chainer,keisuke-umezawa/chainer,niboshi/chainer,chainer/chainer,keisuke-umezawa/chainer,tkerola/chainer,hvy/chainer,jnishi/chainer,pfnet/chainer,wkentaro/chainer,keisuke-umezawa/chainer,niboshi/chainer,keisuke-umezawa/chainer,hvy/chainer,wkentaro/chainer,chainer/chainer,niboshi/chainer,okuta/chainer
|
f16c8f696a282da6c04de6b7530f1d0316eda88b
|
providers/edu/harvarddataverse/normalizer.py
|
providers/edu/harvarddataverse/normalizer.py
|
import arrow
import dateparser
from share.normalize import *
class Person(Parser):
given_name = ParseName(ctx).first
family_name = ParseName(ctx).last
additional_name = ParseName(ctx).middle
suffix = ParseName(ctx).suffix
class Contributor(Parser):
person = Delegate(Person, ctx)
cited_name = ctx
order_cited = ctx('index')
class Link(Parser):
url = ctx
type = RunPython('get_link_type', ctx)
def get_link_type(self, link):
if 'dx.doi.org' in link:
return 'doi'
elif 'dataverse.harvard.edu' in link:
return 'provider'
return 'misc'
class ThroughLinks(Parser):
link = Delegate(Link, ctx)
class CreativeWork(Parser):
title = ctx.name
description = ctx.description
contributors = Map(Delegate(Contributor), ctx.authors)
date_published = ParseDate(ctx.published_at)
links = Concat(
Delegate(ThroughLinks, ctx.url),
Delegate(ThroughLinks, ctx.image_url),
)
|
import arrow
import dateparser
from share.normalize import *
class Person(Parser):
given_name = ParseName(ctx).first
family_name = ParseName(ctx).last
additional_name = ParseName(ctx).middle
suffix = ParseName(ctx).suffix
class Contributor(Parser):
person = Delegate(Person, ctx)
cited_name = ctx
order_cited = ctx('index')
class Link(Parser):
url = ctx
type = RunPython('get_link_type', ctx)
def get_link_type(self, link):
if 'dx.doi.org' in link:
return 'doi'
elif 'dataverse.harvard.edu' in link:
return 'provider'
return 'misc'
class ThroughLinks(Parser):
link = Delegate(Link, ctx)
class CreativeWork(Parser):
title = ctx.name
description = Try(ctx.description)
contributors = Map(Delegate(Contributor), Try(ctx.authors))
date_published = ParseDate(ctx.published_at)
links = Concat(
Delegate(ThroughLinks, ctx.url),
Delegate(ThroughLinks, ctx.image_url),
)
|
Handle missing fields in dataverse
|
Handle missing fields in dataverse
|
Python
|
apache-2.0
|
CenterForOpenScience/SHARE,laurenbarker/SHARE,aaxelb/SHARE,aaxelb/SHARE,laurenbarker/SHARE,zamattiac/SHARE,zamattiac/SHARE,CenterForOpenScience/SHARE,laurenbarker/SHARE,CenterForOpenScience/SHARE,zamattiac/SHARE,aaxelb/SHARE
|
3327c204f34a725a2d070beb24a7a5a66d414930
|
migrations/versions/538eeb160af6_.py
|
migrations/versions/538eeb160af6_.py
|
"""empty message
Revision ID: 538eeb160af6
Revises: 1727fb4309d8
Create Date: 2015-09-17 04:22:21.262285
"""
# revision identifiers, used by Alembic.
revision = '538eeb160af6'
down_revision = '1727fb4309d8'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('role', sa.String(length=30), nullable=True))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('user', 'role')
### end Alembic commands ###
|
"""empty message
Revision ID: 538eeb160af6
Revises: 1727fb4309d8
Create Date: 2015-09-17 04:22:21.262285
"""
# revision identifiers, used by Alembic.
revision = '538eeb160af6'
down_revision = '6b9d673d8e30'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('role', sa.String(length=30), nullable=True))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('user', 'role')
### end Alembic commands ###
|
Update alembic order for merging
|
Update alembic order for merging
|
Python
|
apache-2.0
|
bunjiboys/security_monkey,stackArmor/security_monkey,markofu/security_monkey,bunjiboys/security_monkey,bunjiboys/security_monkey,markofu/security_monkey,markofu/security_monkey,Netflix/security_monkey,stackArmor/security_monkey,Netflix/security_monkey,Netflix/security_monkey,stackArmor/security_monkey,Netflix/security_monkey,bunjiboys/security_monkey,Netflix/security_monkey,bunjiboys/security_monkey,stackArmor/security_monkey,stackArmor/security_monkey,markofu/security_monkey,markofu/security_monkey
|
aae0a19e6b03c9b42272f403cc1e5e7c943ea8ab
|
setup.py
|
setup.py
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from setuptools import setup, find_packages
import os
def read_file(filename):
"""Read a file into a string"""
path = os.path.abspath(os.path.dirname(__file__))
filepath = os.path.join(path, filename)
try:
return open(filepath).read()
except IOError:
return ''
setup(
name='python-hcalendar',
version=__import__('hcalendar').__version__,
author='Marc Hoersken',
author_email='[email protected]',
packages=find_packages(exclude=['unittests']),
include_package_data=True,
url='https://github.com/mback2k/python-hcalendar',
license='MIT',
description=' '.join(__import__('hcalendar').__doc__.splitlines()).strip(),
install_requires=['isodate>=0.5.0', 'beautifulsoup4>=4.3.2'],
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Topic :: Text Processing :: Markup :: HTML',
'Topic :: Software Development :: Libraries :: Python Modules',
'Development Status :: 4 - Beta',
'Operating System :: OS Independent',
],
long_description=read_file('README.md'),
)
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from setuptools import setup, find_packages
import os
def read_file(filename):
"""Read a file into a string"""
path = os.path.abspath(os.path.dirname(__file__))
filepath = os.path.join(path, filename)
try:
return open(filepath).read()
except IOError:
return ''
setup(
name='python-hcalendar',
version=__import__('hcalendar').__version__,
author='Marc Hoersken',
author_email='[email protected]',
packages=find_packages(exclude=['unittests']),
include_package_data=True,
url='https://github.com/mback2k/python-hcalendar',
license='MIT',
description=' '.join(__import__('hcalendar').__doc__.splitlines()).strip(),
install_requires=['isodate>=0.5.0', 'beautifulsoup4>=4.3.2'],
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Topic :: Text Processing :: Markup :: HTML',
'Topic :: Software Development :: Libraries :: Python Modules',
'Development Status :: 4 - Beta',
'Operating System :: OS Independent',
],
long_description=read_file('README.md'),
long_description_content_type='text/markdown',
)
|
Set long description content type to markdown
|
Set long description content type to markdown
|
Python
|
mit
|
mback2k/python-hcalendar
|
fea8e206f3ef2755710a585b6aa76ce5c148a817
|
setup.py
|
setup.py
|
#! /usr/bin/env python
from setuptools import setup, find_packages
setup(
name='armet',
version='0.3.0-pre',
description='Clean and modern framework for creating RESTful APIs.',
author='Concordus Applications',
author_email='[email protected]',
url='http://github.com/armet/python-armet',
package_dir={'armet': 'src/armet'},
packages=find_packages('src'),
install_requires=(
'six', # Python 2 and 3 normalization layer
'python-mimeparse' # For parsing accept and content-type headers
),
extras_require={
'test': (
'nose',
'yanc'
)
}
)
|
#! /usr/bin/env python
from setuptools import setup, find_packages
setup(
name='armet',
version='0.3.0-pre',
description='Clean and modern framework for creating RESTful APIs.',
author='Concordus Applications',
author_email='[email protected]',
url='http://github.com/armet/python-armet',
package_dir={'armet': 'src/armet'},
packages=find_packages('src'),
install_requires=(
'six', # Python 2 and 3 normalization layer
'python-mimeparse' # For parsing accept and content-type headers
),
extras_require={
'test': (
'nose',
'yanc',
'httplib2'
)
}
)
|
Add httplib2 as a test dependency.
|
Add httplib2 as a test dependency.
|
Python
|
mit
|
armet/python-armet
|
20117a8c35ef47842a98bff92fc98773508ebbe0
|
setup.py
|
setup.py
|
"""
Usage instructions:
- If you are installing: `python setup.py install`
- If you are developing: `python setup.py sdist bdist --format=zip bdist_wheel --universal`
"""
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except ImportError:
try:
long_description = open('README.md').read()
except:
try:
long_description = open('README.rst').read()
except:
print('Failed to convert README to rst.')
long_description = ''
from setuptools import setup
setup(
name='keyboard',
version='0.7.1',
author='BoppreH',
author_email='[email protected]',
packages=['keyboard'],
url='https://github.com/boppreh/keyboard',
license='MIT',
description='Hook and simulate keyboard events on Windows and Linux',
keywords = 'keyboard hook simulate hotkey',
long_description=long_description,
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: Microsoft :: Windows',
'Operating System :: Unix',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
)
|
"""
Usage instructions:
- If you are installing: `python setup.py install`
- If you are developing: `python setup.py sdist bdist --format=zip bdist_wheel --universal`
"""
try:
long_description = open('README.rst').read()
except ImportError:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
from setuptools import setup
setup(
name='keyboard',
version='0.7.1',
author='BoppreH',
author_email='[email protected]',
packages=['keyboard'],
url='https://github.com/boppreh/keyboard',
license='MIT',
description='Hook and simulate keyboard events on Windows and Linux',
keywords = 'keyboard hook simulate hotkey',
long_description=long_description,
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: Microsoft :: Windows',
'Operating System :: Unix',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
)
|
Make README publishing more conservative
|
Make README publishing more conservative
|
Python
|
mit
|
boppreh/keyboard,glitchassassin/keyboard
|
d2d822a9fb60bbc8ded7f9e3c70d91cf25f794b2
|
src/volunteers/models.py
|
src/volunteers/models.py
|
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.validators import MinValueValidator
class Volunteer(models.Model):
first_name = models.CharField(_('First name'), max_length=100)
last_name = models.CharField(_('Last name'), max_length=100)
age = models.PositiveIntegerField(_('Age'))
phone = models.CharField(_('Phone'), max_length=100)
email = models.EmailField(_('E-mail'), unique=True)
is_group = models.BooleanField(_('Is group representative'), default=False)
group_name = models.CharField(_('Group/organization name'), max_length=100,
blank=True)
participant_count = models.PositiveIntegerField(_('Participant count'),
default=1, validators=[MinValueValidator(1)])
class Meta:
verbose_name = _('Volunteer')
verbose_name_plural = _('Volunteers')
@property
def name(self):
template = u'{first_name} {last_name}'
if self.is_group:
template += u' (grupp, {participant_count} osalejat)'
return template.format(**self.__dict__)
def __unicode__(self):
return self.name
|
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.validators import MinValueValidator
class Volunteer(models.Model):
first_name = models.CharField(_('First name'), max_length=100)
last_name = models.CharField(_('Last name'), max_length=100)
age = models.PositiveIntegerField(_('Age'))
phone = models.CharField(_('Phone'), max_length=100)
email = models.EmailField(_('E-mail'), unique=True)
is_group = models.BooleanField(_('Is group representative'), default=False)
group_name = models.CharField(_('Group/organization name'), max_length=100,
blank=True)
participant_count = models.PositiveIntegerField(_('Participant count'),
default=1, validators=[MinValueValidator(1)])
class Meta:
verbose_name = _('Volunteer')
verbose_name_plural = _('Volunteers')
@property
def name(self):
template = u'{first_name} {last_name}'
if self.is_group:
template += u' ({group_name} grupp, {participant_count} osalejat)'
return template.format(**self.__dict__)
def __unicode__(self):
return self.name
|
Add group name to volunteer string representation
|
Add group name to volunteer string representation
|
Python
|
mit
|
mrts/foodbank-campaign,mrts/foodbank-campaign,mrts/foodbank-campaign,mrts/foodbank-campaign
|
e57e13bde61a233b18504ab1617c6ecabad20fc3
|
setup.py
|
setup.py
|
#!/usr/bin/env python
from setuptools import setup
from setuptools import find_packages
import re
def find_version():
return re.search(r"^__version__ = '(.*)'$",
open('cantools/version.py', 'r').read(),
re.MULTILINE).group(1)
setup(name='cantools',
version=find_version(),
description='CAN BUS tools.',
long_description=open('README.rst', 'r').read(),
author='Erik Moqvist',
author_email='[email protected]',
license='MIT',
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
keywords=['can', 'can bus', 'dbc', 'kcd', 'automotive'],
url='https://github.com/eerimoq/cantools',
packages=find_packages(exclude=['tests']),
python_requires='>=3.6',
install_requires=[
'bitstruct>=6.0.0',
'python-can>=2.2.0',
'textparser>=0.21.1',
'diskcache',
'argparse_addons',
],
test_suite="tests",
entry_points = {
'console_scripts': ['cantools=cantools.__init__:_main']
})
|
#!/usr/bin/env python
from setuptools import setup
from setuptools import find_packages
import re
def find_version():
return re.search(r"^__version__ = '(.*)'$",
open('cantools/version.py', 'r').read(),
re.MULTILINE).group(1)
setup(name='cantools',
version=find_version(),
description='CAN BUS tools.',
long_description=open('README.rst', 'r').read(),
author='Erik Moqvist',
author_email='[email protected]',
license='MIT',
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
],
keywords=['can', 'can bus', 'dbc', 'kcd', 'automotive'],
url='https://github.com/eerimoq/cantools',
packages=find_packages(exclude=['tests']),
python_requires='>=3.6',
install_requires=[
'bitstruct>=6.0.0',
'python-can>=2.2.0',
'textparser>=0.21.1',
'diskcache',
'argparse_addons',
],
test_suite="tests",
entry_points = {
'console_scripts': ['cantools=cantools.__init__:_main']
})
|
Remove per patch version classifiers
|
Remove per patch version classifiers
|
Python
|
mit
|
eerimoq/cantools,cantools/cantools
|
621968ca6bd2fb986d83ccc8d4c0d5a83ce3aadb
|
setup.py
|
setup.py
|
from setuptools import setup
import generate
generate.run()
setup(
name='nnpy',
version='0.1',
url='https://github.com/nanomsg/nnpy',
license='MIT',
author='Dirkjan Ochtman',
author_email='[email protected]',
description='cffi-based Python bindings for nanomsg',
long_description=open('README.rst').read(),
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
],
packages=['nnpy'],
package_data={'nnpy': ['*.h']},
install_requires=['cffi'],
)
|
from setuptools import setup
import generate
generate.run()
setup(
name='nnpy',
version='0.1',
url='https://github.com/nanomsg/nnpy',
license='MIT',
author='Dirkjan Ochtman',
author_email='[email protected]',
description='cffi-based Python bindings for nanomsg',
long_description=open('README.rst').read(),
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: CPython',
],
packages=['nnpy'],
package_data={'nnpy': ['*.h']},
install_requires=['cffi'],
)
|
Add tested python version in classifiers
|
Add tested python version in classifiers
|
Python
|
mit
|
nanomsg/nnpy
|
80f59dd5b99605d212243641d01fcd635ddd0d93
|
setup.py
|
setup.py
|
#! /usr/bin/env python
from setuptools import find_packages, setup
setup(name='oemof.db',
# Unfortunately we can't use a `__version__` attribute on `oemof.db` as
# we can't import that module here. It depends on packages which might
# not be available prior to installation.
version='0.0.6dev',
description='The oemof database extension',
namespace_package = ['oemof'],
packages=find_packages(),
package_dir={'oemof': 'oemof'},
install_requires=['sqlalchemy >= 1.0',
'keyring >= 4.0',
'shapely',
'psycopg2',
'keyrings.alt',
'pandas >=0.19.1, <=0.19.1'])
|
#! /usr/bin/env python
from setuptools import find_packages, setup
setup(name='oemof.db',
# Unfortunately we can't use a `__version__` attribute on `oemof.db` as
# we can't import that module here. It depends on packages which might
# not be available prior to installation.
version='0.0.6dev',
description='The oemof database extension',
namespace_package = ['oemof'],
packages=find_packages(),
package_dir={'oemof': 'oemof'},
install_requires=['sqlalchemy >= 1.0',
'keyring >= 4.0',
'shapely',
'psycopg2',
'keyrings.alt',
'pandas >=0.19.1'])
|
Drop upper version bound on pandas
|
Drop upper version bound on pandas
There's really no reason for having it.
|
Python
|
mit
|
oemof/oemof.db
|
e1111ad6e8802b3c90df55e05eb695d6db9005e4
|
import_script/create_users.py
|
import_script/create_users.py
|
#!/usr/bin/python
import django.contrib.auth.models as auth_models
import django.contrib.contenttypes as contenttypes
def main():
# Read only user:
# auth_models.User.objects.create_user('cube', 'toolkit_admin_readonly@localhost', '***REMOVED***')
# Read/write user:
user_rw = auth_models.User.objects.create_user('admin', 'toolkit_admin@localhost', '***REMOVED***')
# Create dummy ContentType:
ct = contenttypes.models.ContentType.objects.get_or_create(
model='',
app_label='toolkit'
)[0]
# Create 'write' permission:
write_permission = auth_models.Permission.objects.get_or_create(
name='Write access to all toolkit content',
content_type=ct,
codename='write'
)[0]
# Give "admin" user the write permission:
user_rw.user_permissions.add(write_permission)
if __name__ == "__main__":
main()
|
#!/usr/bin/python
import django.contrib.auth.models as auth_models
import django.contrib.contenttypes as contenttypes
def get_password():
print "*" * 80
password = raw_input("Please enter string to use as admin password: ")
check_password = None
while check_password != password:
print
check_password = raw_input("Please re-enter for confirmation: ")
return password
def main():
# Read only user:
# auth_models.User.objects.create_user('cube', 'toolkit_admin_readonly@localhost', '********')
# Read/write user:
cube_password = get_password()
user_rw = auth_models.User.objects.create_user('admin', 'toolkit_admin@localhost', cube_password)
# Create dummy ContentType:
ct = contenttypes.models.ContentType.objects.get_or_create(
model='',
app_label='toolkit'
)[0]
# Create 'write' permission:
write_permission = auth_models.Permission.objects.get_or_create(
name='Write access to all toolkit content',
content_type=ct,
codename='write'
)[0]
# Give "admin" user the write permission:
user_rw.user_permissions.add(write_permission)
if __name__ == "__main__":
main()
|
Remove cube credentials from import script
|
Remove cube credentials from import script
|
Python
|
agpl-3.0
|
BenMotz/cubetoolkit,BenMotz/cubetoolkit,BenMotz/cubetoolkit,BenMotz/cubetoolkit
|
e6457c384eaa13eff82217ef4eb15f580efd8121
|
setup.py
|
setup.py
|
import re
from setuptools import setup
init_py = open('wikipediabase/__init__.py').read()
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", init_py))
metadata['doc'] = re.findall('"""(.+)"""', init_py)[0]
setup(
name='wikipediabase',
version=metadata['version'],
description=metadata['doc'],
author=metadata['author'],
author_email=metadata['email'],
url=metadata['url'],
packages=[
'wikipediabase',
'wikipediabase.resolvers',
'wikipediabase.adhoc',
'tests',
],
include_package_data=True,
install_requires=[
'edn_format',
'docopt',
'flake8 < 3.0.0',
'unittest2 < 1.0.0',
'overlay-parse',
'lxml',
'sqlitedict',
'requests',
'beautifulsoup4',
'redis',
'redis',
'hiredis',
],
dependency_links=[
'git+https://github.com/fakedrake/overlay_parse#egg=overlay-parse',
],
tests_require=[
'nose>=1.0',
'sqlitedict',
],
entry_points={
'console_scripts': [
'wikipediabase = wikipediabase.cli:main',
],
},
test_suite='nose.collector',
license=open('LICENSE').read(),
)
|
import re
from setuptools import setup
init_py = open('wikipediabase/__init__.py').read()
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", init_py))
metadata['doc'] = re.findall('"""(.+)"""', init_py)[0]
setup(
name='wikipediabase',
version=metadata['version'],
description=metadata['doc'],
author=metadata['author'],
author_email=metadata['email'],
url=metadata['url'],
packages=[
'wikipediabase',
'wikipediabase.resolvers',
'wikipediabase.adhoc',
'tests',
],
include_package_data=True,
install_requires=[
'edn_format',
'docopt',
'flake8 < 3.0.0',
'unittest2 < 1.0.0',
'overlay-parse',
'lxml',
'sqlitedict',
'requests',
'beautifulsoup4',
'redis',
'redis',
'hiredis',
'unidecode',
],
dependency_links=[
'git+https://github.com/fakedrake/overlay_parse#egg=overlay-parse',
],
tests_require=[
'nose>=1.0',
'sqlitedict',
],
entry_points={
'console_scripts': [
'wikipediabase = wikipediabase.cli:main',
],
},
test_suite='nose.collector',
license=open('LICENSE').read(),
)
|
Add unidecode as a dependency
|
Add unidecode as a dependency
|
Python
|
apache-2.0
|
fakedrake/WikipediaBase
|
1a37d53df02942cb27794303e68fe041f73f5135
|
setup.py
|
setup.py
|
import os
from setuptools import setup
from setuptools import find_packages
setup(
name='MobOff',
version='0.1',
py_modules=['moboff'],
packages=find_packages(),
description = 'Download youtube music and send to devices',
author = 'Parth Verma',
author_email = '[email protected]',
url = "https://github.com/parth-vader/MobOff",
license = "MIT License",
install_requires=[
'pushbullet.py',
'youtube_dl',
'Click',
],
entry_points='''
[console_scripts]
moboff=mainscript:cli
''',
)
os.system('chmod a+x mainscript.py')
os.system('export PATH=mainscript.py:$PATH')
|
import os
from setuptools import setup
from setuptools import find_packages
setup(
name='MobOff',
version='0.2',
py_modules=['moboff'],
packages=find_packages(),
description = 'Download youtube music and send to devices',
author = 'Parth Verma',
author_email = '[email protected]',
url = "https://github.com/parth-vader/MobOff",
download_url = 'https://codeload.github.com/Parth-Vader/MobOff/tar.gz/0.2'
license = "MIT License",
install_requires=[
'pushbullet.py',
'youtube_dl',
'Click',
],
entry_points='''
[console_scripts]
moboff=mainscript:cli
''',
)
os.system('chmod a+x mainscript.py')
os.system('export PATH=mainscript.py:$PATH')
|
Tag updated and download link added
|
Tag updated and download link added
|
Python
|
mit
|
Parth-Vader/MobOff
|
c89abd6a285225313c91ba03c0fd8ab2cfed399d
|
setup.py
|
setup.py
|
#!/usr/bin/env python
import os
import urllib
import zipfile
script_path = os.path.dirname(os.path.realpath(__file__))
packer_archive_path = script_path + "/packer.zip"
bin_path = script_path + "/bin"
if not os.path.isfile(bin_path + "/packer"):
if not os.path.exists(bin_path):
os.makedirs(bin_path)
try:
urllib.urlretrieve("https://dl.bintray.com/mitchellh/packer/packer_0.8.6_linux_amd64.zip", packer_archive_path)
with zipfile.ZipFile(packer_archive_path, "r") as packer_archive:
packer_archive.extractall(path=bin_path)
finally:
os.remove(packer_archive_path)
for root, subdirectories, files in os.walk(bin_path):
for f in files:
os.chmod("%s/%s" % (root, f), 0755)
|
#!/usr/bin/env python
import os
import urllib
import zipfile
script_path = os.path.dirname(os.path.realpath(__file__))
packer_archive_path = script_path + "/packer.zip"
bin_path = script_path + "/bin"
if not os.path.isfile(bin_path + "/packer"):
if not os.path.exists(bin_path):
os.makedirs(bin_path)
try:
urllib.urlretrieve("https://dl.bintray.com/mitchellh/packer/packer_0.8.6_linux_amd64.zip", packer_archive_path)
with zipfile.ZipFile(packer_archive_path, "r") as packer_archive:
packer_archive.extractall(path=bin_path)
finally:
os.remove(packer_archive_path)
for root, subdirectories, files in os.walk(bin_path):
for f in files:
os.chmod(root + "/" + f, 755)
|
Fix false positive octal syntax warning
|
Fix false positive octal syntax warning
|
Python
|
unlicense
|
dharmab/centos-vagrant
|
110f62562a4802f99c93a53ea09e1e3deb2b3714
|
setup.py
|
setup.py
|
from setuptools import setup, find_packages
import os
version = '0.3.10'
here = os.path.abspath(os.path.dirname(__file__))
try:
README = open(os.path.join(here, 'README.txt')).read()
CHANGES = open(os.path.join(here, 'docs/HISTORY.txt')).read()
except IOError:
README = CHANGES = ''
setup(name='tgext.admin',
version=version,
description="Admin Controller add-on for basic TG identity model.",
long_description=README + "\n" +
CHANGES,
# Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords='TG2, TG, sprox, Rest, internet, adminn',
author='Christopher Perkins',
author_email='[email protected]',
url='tgtools.googlecode.com',
license='MIT',
packages=find_packages(exclude=['ez_setup']),
namespace_packages=['tgext'],
include_package_data=True,
zip_safe=True,
install_requires=[
'setuptools',
'sprox>=0.6.4',
'tgext.crud>=0.3.7',
# -*- Extra requirements: -*-
],
entry_points="""
# -*- Entry points: -*-
""",
)
|
from setuptools import setup, find_packages
import os
version = '0.3.11'
here = os.path.abspath(os.path.dirname(__file__))
try:
README = open(os.path.join(here, 'README.txt')).read()
CHANGES = open(os.path.join(here, 'docs/HISTORY.txt')).read()
except IOError:
README = CHANGES = ''
setup(name='tgext.admin',
version=version,
description="Admin Controller add-on for basic TG identity model.",
long_description=README + "\n" +
CHANGES,
# Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords='TG2, TG, sprox, Rest, internet, adminn',
author='Christopher Perkins',
author_email='[email protected]',
url='tgtools.googlecode.com',
license='MIT',
packages=find_packages(exclude=['ez_setup']),
namespace_packages=['tgext'],
include_package_data=True,
zip_safe=True,
install_requires=[
'setuptools',
'sprox>=0.6.4',
'tgext.crud>=0.3.7',
# -*- Extra requirements: -*-
],
entry_points="""
# -*- Entry points: -*-
""",
)
|
Increase to version 0.3.11 due to TG-dev requiring it for ming support
|
Increase to version 0.3.11 due to TG-dev requiring it for ming support
|
Python
|
mit
|
pedersen/tgtools.tgext-admin,pedersen/tgtools.tgext-admin
|
23f2306617a4e4bceecd20190c328b2b3418abc4
|
setup.py
|
setup.py
|
#! /usr/bin/python
"""Setuptools-based setup script for datreant.
For a basic installation just type the command::
python setup.py install
"""
from setuptools import setup
setup(name='datreant',
version='0.5.1',
author='David Dotson',
author_email='[email protected]',
packages=['datreant', 'datreant.tests'],
scripts=[],
license='BSD',
long_description=open('README.rst').read(),
install_requires=['pandas', 'tables', 'h5py', 'scandir']
)
|
#! /usr/bin/python
"""Setuptools-based setup script for datreant.
For a basic installation just type the command::
python setup.py install
"""
from setuptools import setup
setup(name='datreant',
version='0.5.1',
author='David Dotson',
author_email='[email protected]',
packages=['datreant', 'datreant.tests'],
scripts=[],
license='BSD',
long_description=open('README.rst').read(),
install_requires=[
'numpy',
'pandas',
'tables',
'h5py',
'scandir',
'PyYAML'
]
)
|
Add PyYAML & numpy dependency
|
Add PyYAML & numpy dependency
I'm adding numpy too because we import it directly.
|
Python
|
bsd-3-clause
|
datreant/datreant,dotsdl/datreant,datreant/datreant.core,datreant/datreant.core,datreant/datreant,datreant/datreant.data
|
95e15792b50f28c5c40dcad17de2fd4535345bc8
|
setup.py
|
setup.py
|
from setuptools import setup
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.rst')) as readme_file:
long_description = readme_file.read()
setup(
name='pyfds',
description='Modular field simulation tool using finite differences.',
long_description=long_description,
url='http://emt.uni-paderborn.de',
author='Leander Claes',
author_email='[email protected]',
license='Proprietary',
# Automatically generate version number from git tags
use_scm_version=True,
packages=[
'pyfds'
],
# Runtime dependencies
install_requires=[
'numpy',
'scipy',
'matplotlib'
],
# Setup/build dependencies; setuptools_scm required for git-based versioning
setup_requires=['setuptools_scm'],
# For a list of valid classifiers, see
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers for full list.
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Science/Research',
'License :: Other/Proprietary License',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering',
],
)
|
from setuptools import setup
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.rst')) as readme_file:
long_description = readme_file.read()
setup(
name='pyfds',
description='Modular field simulation tool using finite differences.',
long_description=long_description,
url='http://emt.uni-paderborn.de',
author='Leander Claes',
author_email='[email protected]',
license='Proprietary',
# Automatically generate version number from git tags
use_scm_version=True,
packages=[
'pyfds'
],
# Runtime dependencies
install_requires=[
'numpy',
'scipy',
'matplotlib',
'siprefix'
],
# Setup/build dependencies; setuptools_scm required for git-based versioning
setup_requires=['setuptools_scm'],
# For a list of valid classifiers, see
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers for full list.
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Science/Research',
'License :: Other/Proprietary License',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering',
],
)
|
Add siprefix to runtime dependencies.
|
Add siprefix to runtime dependencies.
|
Python
|
bsd-3-clause
|
emtpb/pyfds
|
a25f36c76301f67beab29dc2a273d819c49cd8eb
|
setup.py
|
setup.py
|
import os
import sys
try:
from setuptools import setup
except:
from distutils.core import setup
from distutils.command.build_py import build_py
path, script = os.path.split(sys.argv[0])
os.chdir(os.path.abspath(path))
VERSION="0.0.3"
install_requires = []
setup(name='imgix',
cmdclass={'build_py': build_py},
version=VERSION,
description='Python client library for imgix.',
author='imgix',
author_email='[email protected]',
url='http://www.imgix.com/',
packages=['imgix'],
install_requires=install_requires
)
|
import os
import sys
try:
from setuptools import setup
except:
from distutils.core import setup
from distutils.command.build_py import build_py
path, script = os.path.split(sys.argv[0])
os.chdir(os.path.abspath(path))
VERSION="0.0.3"
install_requires = []
setup(name='imgix',
cmdclass={'build_py': build_py},
version=VERSION,
description='Python client library for imgix.',
author='imgix',
author_email='[email protected]',
url='https://github.com/imgix/imgix-python',
packages=['imgix'],
install_requires=install_requires
)
|
Change the URL of the package
|
Change the URL of the package
|
Python
|
bsd-2-clause
|
imgix/imgix-python
|
b0e44fcca09a2d62ea0dc217d1538e03d48e2558
|
setup.py
|
setup.py
|
from setuptools import setup, find_packages
from buildcmds.addon import addon
setup(
name='io_scene_previz',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.0.7',
description='Blender Previz addon',
url='https://app.previz.co',
author='Previz',
author_email='[email protected]',
license='MIT',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Multimedia :: Graphics :: 3D Modeling',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
],
keywords='previz development 3d scene exporter',
packages=find_packages(exclude=['tests']),
install_requires=['previz'],
extras_require={},
package_data={},
data_files=[],
cmdclass={
'addon': addon
}
)
|
from setuptools import setup, find_packages
from buildcmds.addon import bdist_blender_addon
setup(
name='io_scene_previz',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.0.7',
description='Blender Previz addon',
url='https://app.previz.co',
author='Previz',
author_email='[email protected]',
license='MIT',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Multimedia :: Graphics :: 3D Modeling',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
],
keywords='previz development 3d scene exporter',
packages=find_packages(exclude=['buildcmds', 'tests']),
install_requires=['previz'],
extras_require={},
package_data={},
data_files=[],
cmdclass={
'bdist_blender_addon': bdist_blender_addon
}
)
|
Rename command addon to bdist_blender_addon
|
Rename command addon to bdist_blender_addon
|
Python
|
mit
|
Previz-app/io_scene_dnb_previz,Previz-app/io_scene_previz,Previz-app/io_scene_previz,Previz-app/io_scene_dnb_previz
|
3a3c1491cf185899a5e5b6288ae0a3542b536dee
|
setup.py
|
setup.py
|
from distutils.core import setup
setup(
name="pocketlint",
description="Pocket-lint a composite linter and style checker.",
version="0.5.7",
maintainer="Curtis C. Hovey",
maintainer_email="[email protected]",
url="https://launchpad.net/pocket-lint",
packages=[
'pocketlint', 'pocketlint/contrib', 'pocketlint/contrib/pyflakes'],
scripts=['scripts/pocketlint'],
)
|
from distutils.core import setup
setup(
name="pocketlint",
description="Pocket-lint a composite linter and style checker.",
version="0.5.8",
maintainer="Curtis C. Hovey",
maintainer_email="[email protected]",
url="https://launchpad.net/pocket-lint",
packages=[
'pocketlint', 'pocketlint/contrib', 'pocketlint/contrib/pyflakes'],
scripts=['scripts/pocketlint'],
)
|
Increment version to suport Python 2.6.
|
Increment version to suport Python 2.6.
|
Python
|
mit
|
chevah/pocket-lint,chevah/pocket-lint
|
f52c77b746ca98ed06df293ba142a5ecf2577a62
|
setup.py
|
setup.py
|
import sys
from setuptools import setup
# Be verbose about Python < 3.4 being deprecated.
if sys.version_info < (3, 4):
print('\n' * 3 + '*' * 64)
print('lastcast requires Python 3.4+, and might be broken if run with\n'
'this version of Python.')
print('*' * 64 + '\n' * 3)
setup(
name='lastcast',
version='1.0.0',
description='Scrobble music to last.fm from Chromecast.',
author='Erik Price',
url='https://github.com/erik/lastcast',
packages=['lastcast'],
entry_points={
'console_scripts': [
'lastcast = lastcast:main',
],
},
license='MIT',
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
install_requires=[
'PyChromecast==2.0.0',
'click==6.7',
'pylast==1.7.0',
'toml==0.9.4',
]
)
|
import sys
from setuptools import setup
# Be verbose about Python < 3.5 being deprecated.
if sys.version_info < (3, 5):
print('\n' * 3 + '*' * 64)
print('lastcast requires Python 3.5+, and might be broken if run with\n'
'this version of Python.')
print('*' * 64 + '\n' * 3)
setup(
name='lastcast',
version='1.0.1',
description='Scrobble music to last.fm from Chromecast.',
author='Erik Price',
url='https://github.com/erik/lastcast',
packages=['lastcast'],
entry_points={
'console_scripts': [
'lastcast = lastcast:main',
],
},
license='MIT',
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
install_requires=[
'PyChromecast==2.0.0',
'click==6.7',
'pylast==1.7.0',
'toml==0.9.4',
]
)
|
Support is actually py >= 35
|
Support is actually py >= 35
|
Python
|
mit
|
erik/lastcast
|
ab55fab78743650eb9bb219957d7305114e4f8ca
|
setup.py
|
setup.py
|
#!/usr/bin/env python
from setuptools import find_packages, Command
setup_params = dict(
name='bugimporters',
version=0.1,
author='Various contributers to the OpenHatch project, Berry Phillips',
author_email='[email protected], [email protected]',
packages=find_packages(),
description='Bug importers for the OpenHatch project',
install_requires=[
'gdata',
'lxml',
'pyopenssl',
'unicodecsv',
'feedparser',
'twisted',
'python-dateutil',
'decorator',
],
)
if __name__ == '__main__':
from setuptools import setup
setup(**setup_params)
|
#!/usr/bin/env python
from setuptools import find_packages, Command
setup_params = dict(
name='bugimporters',
version=0.1,
author='Various contributers to the OpenHatch project, Berry Phillips',
author_email='[email protected], [email protected]',
packages=find_packages(),
description='Bug importers for the OpenHatch project',
install_requires=[
'gdata',
'lxml',
'pyopenssl',
'unicodecsv',
'feedparser',
'twisted',
'python-dateutil',
'decorator',
'scrapy',
],
)
if __name__ == '__main__':
from setuptools import setup
setup(**setup_params)
|
Add a dependency on Scrapy
|
Add a dependency on Scrapy
|
Python
|
agpl-3.0
|
openhatch/oh-bugimporters,openhatch/oh-bugimporters,openhatch/oh-bugimporters
|
3d888afa88326c97246947141c357509c2f72bbc
|
setup.py
|
setup.py
|
from distutils.core import setup
setup(
name='firebase-token-generator',
version='1.2',
author='Greg Soltis',
author_email='[email protected]',
py_modules=['firebase_token_generator'],
license='LICENSE',
url='https://github.com/firebase/firebase-token-generator-python',
description='A utility to generate signed Firebase Authentication Tokens',
long_description=open('README.md').read()
)
|
from distutils.core import setup
setup(
name='firebase-token-generator',
version='1.3',
author='Greg Soltis',
author_email='[email protected]',
zip_safe=False,
py_modules=['firebase_token_generator'],
license='LICENSE',
url='https://github.com/firebase/firebase-token-generator-python',
description='A utility to generate signed Firebase Authentication Tokens',
long_description=open('README.md').read()
)
|
Set zip_safe=False. Bump version to 1.3.
|
Set zip_safe=False. Bump version to 1.3.
|
Python
|
mit
|
googlearchive/firebase-token-generator-python
|
927e2bc4b8774cdffd753f99f63086baf437a509
|
setup.py
|
setup.py
|
from pip.download import PipSession
from pip.req import parse_requirements
from setuptools import setup
setup(
name='aws-portknock',
version='0.1',
py_modules=['aws_portknock'],
description='Port knocking for AWS security groups',
author='Michel Alexandre Salim',
author_email='[email protected]',
url='https://github.com/michel-slm/aws-portknock',
download_url='https://github.com/michel-slm/aws-portknock/tarball/0.1',
keywords=['aws'],
classifiers=[],
install_requires=[str(r.req)
for r in parse_requirements(
'requirements.txt',
session=PipSession())],
entry_points='''
[console_scripts]
aws-portknock=aws_portknock:cli
''',
)
|
import os
from pip.download import PipSession
from pip.req import parse_requirements
from setuptools import setup
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
reqs_file = os.path.join(BASE_DIR, 'requirements.txt')
install_reqs = parse_requirements(reqs_file, session=PipSession())
setup(
name='aws-portknock',
version='0.1',
py_modules=['aws_portknock'],
description='Port knocking for AWS security groups',
author='Michel Alexandre Salim',
author_email='[email protected]',
url='https://github.com/michel-slm/aws-portknock',
download_url='https://github.com/michel-slm/aws-portknock/tarball/0.1',
keywords=['aws'],
classifiers=[],
install_requires=[str(r.req)
for r in install_reqs],
entry_points='''
[console_scripts]
aws-portknock=aws_portknock:cli
''',
)
|
Add path to requirements.txt so installation from pip succeeds
|
Add path to requirements.txt so installation from pip succeeds
cf http://lorenamesa.com/packaging-my-first-python-egg.html
|
Python
|
mpl-2.0
|
michel-slm/aws-portknock
|
03875be96ba09a252a05ba0ea84a3558c6428011
|
setup.py
|
setup.py
|
#!/usr/bin/env python
import os
from setuptools import setup, find_packages
reqs_file = os.path.join(os.path.dirname(os.path.realpath(__file__))
, "requirements.txt")
reqs = None
with open(reqs_file) as f:
reqs = f.readlines()
setup(
version='0.1.0',
name='mediachain-client',
description='mediachain reader command line interface',
author='Mediachain Labs',
packages=find_packages('.'),
entry_points={
'console_scripts': [
'mediachain = mediachain.cli.main:main'
]
},
url='http://mediachain.io',
install_requires=reqs,
)
|
#!/usr/bin/env python
import os, sys
from setuptools import setup, find_packages
from setuptools.command.install import install as _install
reqs_file = os.path.join(os.path.dirname(os.path.realpath(__file__))
, "requirements.txt")
reqs = None
with open(reqs_file) as f:
reqs = f.readlines()
def _pre_install(dir):
from subprocess import check_call
check_call(['scripts/build_grpc.sh'],
cwd=dir)
class install(_install):
def run(self):
self.execute(_pre_install, [os.path.dirname(__file__)],
msg="Generating protobuf")
_install.run(self)
setup(
version='0.1.0',
name='mediachain-client',
description='mediachain reader command line interface',
author='Mediachain Labs',
packages=find_packages('.'),
entry_points={
'console_scripts': [
'mediachain = mediachain.cli.main:main'
]
},
url='http://mediachain.io',
install_requires=reqs,
cmdclass={'install': install},
)
|
Add pre-install protobuf gen script
|
Add pre-install protobuf gen script
|
Python
|
mit
|
mediachain/mediachain-client,mediachain/mediachain-client
|
453bd468d9de609999ef814f24111923177374fe
|
setup.py
|
setup.py
|
from setuptools import find_packages
from setuptools import setup
from pip import req
_install_requirements = req.parse_requirements('requirements.txt')
setup(
name='jetway',
version=open('VERSION').read().strip(),
description=(
'Client library for the Jetway static site staging service.'
),
url='https://github.com/grow/jetway-client',
license='MIT',
author='Grow SDK Authors',
author_email='[email protected]',
include_package_data=True,
install_requires=[str(ir.req) for ir in _install_requirements],
packages=find_packages(),
keywords=[
'grow',
'cms',
'static site generator',
's3',
'google cloud storage',
'content management'
],
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
])
|
import uuid
from setuptools import find_packages
from setuptools import setup
from pip import req
_install_requirements = req.parse_requirements(
'requirements.txt', session=uuid.uuid1())
setup(
name='jetway',
version=open('VERSION').read().strip(),
description=(
'Client library for the Jetway static site staging service.'
),
url='https://github.com/grow/jetway-client',
license='MIT',
author='Grow SDK Authors',
author_email='[email protected]',
include_package_data=True,
install_requires=[str(ir.req) for ir in _install_requirements],
packages=find_packages(),
keywords=[
'grow',
'cms',
'static site generator',
's3',
'google cloud storage',
'content management'
],
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
])
|
Fix pip parse_requirements for v0.6+.
|
Fix pip parse_requirements for v0.6+.
|
Python
|
mit
|
grow/webreview-client
|
ee2d27eca45768a07a562405cf4431cb8d2b09bf
|
setup.py
|
setup.py
|
from distutils.core import setup
setup(name='pyresttest',
version='0.1',
description='Python Rest Testing',
maintainer='Naveen Malik',
maintainer_email='[email protected]',
url='https://github.com/svanoort/pyresttest',
py_modules=['resttest','pycurl_benchmark','test_resttest'],
license='Apache License, Version 2.0'
)
|
from distutils.core import setup
setup(name='pyresttest',
version='0.1',
description='Python Rest Testing',
maintainer='Sam Van Oort',
maintainer_email='[email protected]',
url='https://github.com/svanoort/pyresttest',
py_modules=['resttest','test_resttest'],
license='Apache License, Version 2.0',
requires=['argparse','yaml','pycurl']
)
|
Set maintainer and add dependencies to distutils config
|
Set maintainer and add dependencies to distutils config
|
Python
|
apache-2.0
|
sunyanhui/pyresttest,satish-suradkar/pyresttest,suvarnaraju/pyresttest,wirewit/pyresttest,netjunki/pyresttest,MorrisJobke/pyresttest,wirewit/pyresttest,suvarnaraju/pyresttest,svanoort/pyresttest,alazaro/pyresttest,sunyanhui/pyresttest,TimYi/pyresttest,MorrisJobke/pyresttest,holdenweb/pyresttest,TimYi/pyresttest,alazaro/pyresttest,janusnic/pyresttest,janusnic/pyresttest,holdenweb/pyresttest,netjunki/pyresttest,svanoort/pyresttest,satish-suradkar/pyresttest
|
b5898dc6d16868cd7908872916fa6099ad85049f
|
setup.py
|
setup.py
|
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='prompt_toolkit',
author='Jonathan Slenders',
version='0.25',
license='LICENSE.txt',
url='https://github.com/jonathanslenders/python-prompt-toolkit',
description='Library for building powerful interactive command lines in Python',
long_description='',
packages=find_packages('.'),
install_requires = [
'docopt',
'jedi>=0.8.1-final0',
'pygments',
'six>=1.8.0',
'wcwidth',
],
entry_points={
'console_scripts': [
'ptpython = prompt_toolkit.contrib.entry_points.ptpython:run',
'ptipython = prompt_toolkit.contrib.entry_points.ptipython:run',
]
},
extras_require = {
'ptipython': ['ipython'] # For ptipython, we need to have IPython
}
)
|
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='prompt_toolkit',
author='Jonathan Slenders',
version='0.25',
license='LICENSE.txt',
url='https://github.com/jonathanslenders/python-prompt-toolkit',
description='Library for building powerful interactive command lines in Python',
long_description='',
packages=find_packages('.'),
install_requires = [
'docopt',
'jedi>=0.8.1',
'pygments',
'six>=1.8.0',
'wcwidth',
],
entry_points={
'console_scripts': [
'ptpython = prompt_toolkit.contrib.entry_points.ptpython:run',
'ptipython = prompt_toolkit.contrib.entry_points.ptipython:run',
]
},
extras_require = {
'ptipython': ['ipython'] # For ptipython, we need to have IPython
}
)
|
Use again jedi==0.8.1. (This was pushed to pypi.)
|
Use again jedi==0.8.1. (This was pushed to pypi.)
|
Python
|
bsd-3-clause
|
melund/python-prompt-toolkit,ALSchwalm/python-prompt-toolkit,niklasf/python-prompt-toolkit,amjith/python-prompt-toolkit,jonathanslenders/python-prompt-toolkit,jaseg/python-prompt-toolkit,ddalex/python-prompt-toolkit
|
2ac5d587c057d877db217b0303a06e0382bd8a2d
|
setup.py
|
setup.py
|
#!/usr/bin/python3
# SPDX-License-Identifier: LGPL-2.1+
import sys
from setuptools import setup
if sys.version_info < (3, 6):
sys.exit("Sorry, we need at least Python 3.6.")
setup(
name="mkosi",
version="5",
description="Create legacy-free OS images",
url="https://github.com/systemd/mkosi",
maintainer="mkosi contributors",
maintainer_email="[email protected]",
license="LGPLv2+",
scripts=["mkosi"],
)
|
#!/usr/bin/python3
# SPDX-License-Identifier: LGPL-2.1+
import sys
from setuptools import setup, Command
class BuildManpage(Command):
description = ('builds the manpage')
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.spawn(['pandoc', '-t', 'man', '-o', 'mkosi.1', 'mkosi.md'])
if sys.version_info < (3, 6):
sys.exit("Sorry, we need at least Python 3.6.")
setup(
name="mkosi",
version="5",
description="Create legacy-free OS images",
url="https://github.com/systemd/mkosi",
maintainer="mkosi contributors",
maintainer_email="[email protected]",
license="LGPLv2+",
scripts=["mkosi"],
cmdclass = { "man": BuildManpage }
)
|
Add custom command to build the manpage
|
Add custom command to build the manpage
Remembering the exact pandoc incantation is annoying
|
Python
|
lgpl-2.1
|
systemd/mkosi,systemd/mkosi
|
8fea58292e41352b0b58947f4182dd32ff4f225d
|
opps/fields/models.py
|
opps/fields/models.py
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
from opps.boxes.models import OPPS_APPS
FIELD_TYPE = (
('checkbox', _('CheckBox')),
('radio', _('Radio')),
('text', _('Text')),
('textarea', _('TextArea')),
)
class Field(models.Model):
name = models.CharField(_('Name'), max_length=100)
slug = models.SlugField(_('Slug'), max_length=255)
application = models.CharField(_('Application'),
max_length=255,
choices=OPPS_APPS,
db_index=True)
type = models.CharField(_("Type"), max_length=15,
choices=FIELD_TYPE,
db_index=True)
def __unicode__(self):
return u"{} - {}".format(self.application, self.name)
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
from opps.boxes.models import OPPS_APPS
FIELD_TYPE = (
('checkbox', _('CheckBox')),
('radio', _('Radio')),
('text', _('Text')),
('textarea', _('TextArea')),
)
class Field(models.Model):
name = models.CharField(_('Name'), max_length=100)
slug = models.SlugField(_('Slug'), max_length=255)
application = models.CharField(_('Application'),
max_length=255,
choices=OPPS_APPS,
db_index=True)
type = models.CharField(_("Type"), max_length=15,
choices=FIELD_TYPE,
db_index=True)
def __unicode__(self):
return u"{} - {}".format(self.application, self.name)
class Option(models.Model):
field = models.ForeignKey('fields.Field')
name = models.CharField(_('Name'), max_length=100)
slug = models.SlugField(_('Slug'), max_length=140)
value = models.CharField(_('Value'), max_length=255)
def __unicode__(self):
return u"{} - {}".format(self.field.slug, self.name)
class FieldOption(models.Model):
field = models.ForeignKey('fields.Field')
option = models.ForeignKey('fields.Option')
order = models.PositiveIntegerField(_(u'Order'), default=0)
def __unicode__(self):
return u"{} - {}".format(self.field.slug, self.option.slug)
class Meta:
ordering = ['-order']
|
Add new model option to add field options if exist (radio/checkbox)
|
Add new model option to add field options if exist (radio/checkbox)
|
Python
|
mit
|
williamroot/opps,jeanmask/opps,jeanmask/opps,williamroot/opps,YACOWS/opps,williamroot/opps,opps/opps,opps/opps,YACOWS/opps,jeanmask/opps,jeanmask/opps,YACOWS/opps,opps/opps,williamroot/opps,YACOWS/opps,opps/opps
|
4f730cb70fc4e65b568732fdcbb7f0209870bfca
|
osf_tests/settings.py
|
osf_tests/settings.py
|
# Use API defaults. This allows these settings to work with API tests
from api.base.settings.defaults import * # noqa
DEBUG_PROPAGATE_EXCEPTIONS = True
#DATABASES = {
# 'default': {
# 'CONN_MAX_AGE': 0,
# 'ENGINE': 'osf.db.backends.postgresql',
# 'HOST': '',
# 'NAME': 'osf-models-test',
# 'PASSWORD': '',
# 'PORT': '',
# 'USER': '',
# 'ATOMIC_REQUESTS': True,
# }
#}
SITE_ID = 1
# SECRET_KEY = 'not very secret in tests'
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
)
REST_FRAMEWORK['ALLOWED_VERSIONS'] = (
'2.0',
'2.1',
'2.2',
'2.3',
'3.0',
'3.0.1',
)
|
# Use API defaults. This allows these settings to work with API tests
from api.base.settings.defaults import * # noqa
DEBUG_PROPAGATE_EXCEPTIONS = True
#DATABASES = {
# 'default': {
# 'CONN_MAX_AGE': 0,
# 'ENGINE': 'osf.db.backends.postgresql',
# 'HOST': '',
# 'NAME': 'osf-models-test',
# 'PASSWORD': '',
# 'PORT': '',
# 'USER': '',
# 'ATOMIC_REQUESTS': True,
# }
#}
SITE_ID = 1
# SECRET_KEY = 'not very secret in tests'
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
)
REST_FRAMEWORK['ALLOWED_VERSIONS'] = (
'2.0',
'2.0.1',
'2.1',
'2.2',
'2.3',
'3.0',
'3.0.1',
)
|
Add in API testing version
|
Add in API testing version
Signed-off-by: Chris Wisecarver <[email protected]>
|
Python
|
apache-2.0
|
cwisecarver/osf.io,chennan47/osf.io,mfraezz/osf.io,Johnetordoff/osf.io,cslzchen/osf.io,monikagrabowska/osf.io,baylee-d/osf.io,baylee-d/osf.io,crcresearch/osf.io,saradbowman/osf.io,monikagrabowska/osf.io,mattclark/osf.io,CenterForOpenScience/osf.io,Nesiehr/osf.io,brianjgeiger/osf.io,CenterForOpenScience/osf.io,Nesiehr/osf.io,felliott/osf.io,erinspace/osf.io,felliott/osf.io,acshi/osf.io,brianjgeiger/osf.io,laurenrevere/osf.io,baylee-d/osf.io,felliott/osf.io,TomBaxter/osf.io,mfraezz/osf.io,chrisseto/osf.io,monikagrabowska/osf.io,caseyrollins/osf.io,CenterForOpenScience/osf.io,caneruguz/osf.io,chennan47/osf.io,leb2dg/osf.io,icereval/osf.io,crcresearch/osf.io,cslzchen/osf.io,chrisseto/osf.io,Johnetordoff/osf.io,erinspace/osf.io,TomBaxter/osf.io,adlius/osf.io,laurenrevere/osf.io,caseyrollins/osf.io,leb2dg/osf.io,cwisecarver/osf.io,acshi/osf.io,acshi/osf.io,chennan47/osf.io,hmoco/osf.io,adlius/osf.io,laurenrevere/osf.io,binoculars/osf.io,cslzchen/osf.io,hmoco/osf.io,mfraezz/osf.io,cwisecarver/osf.io,brianjgeiger/osf.io,sloria/osf.io,icereval/osf.io,cwisecarver/osf.io,adlius/osf.io,HalcyonChimera/osf.io,hmoco/osf.io,mfraezz/osf.io,aaxelb/osf.io,Johnetordoff/osf.io,caseyrollins/osf.io,CenterForOpenScience/osf.io,monikagrabowska/osf.io,caneruguz/osf.io,mattclark/osf.io,sloria/osf.io,hmoco/osf.io,HalcyonChimera/osf.io,brianjgeiger/osf.io,monikagrabowska/osf.io,caneruguz/osf.io,felliott/osf.io,aaxelb/osf.io,pattisdr/osf.io,HalcyonChimera/osf.io,sloria/osf.io,saradbowman/osf.io,acshi/osf.io,Nesiehr/osf.io,caneruguz/osf.io,pattisdr/osf.io,Johnetordoff/osf.io,chrisseto/osf.io,leb2dg/osf.io,binoculars/osf.io,Nesiehr/osf.io,pattisdr/osf.io,acshi/osf.io,aaxelb/osf.io,icereval/osf.io,HalcyonChimera/osf.io,TomBaxter/osf.io,mattclark/osf.io,adlius/osf.io,leb2dg/osf.io,cslzchen/osf.io,binoculars/osf.io,chrisseto/osf.io,erinspace/osf.io,crcresearch/osf.io,aaxelb/osf.io
|
6f83fb7dd071786dc01a015addbdb541e7eaf7db
|
meinberlin/apps/documents/migrations/0002_rename_document_to_chapter.py
|
meinberlin/apps/documents/migrations/0002_rename_document_to_chapter.py
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
dependencies = [
('meinberlin_documents', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Document',
new_name='Chapter',
),
migrations.RenameField(
model_name='paragraph',
old_name='document',
new_name='chapter',
),
]
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
atomic=False
dependencies = [
('meinberlin_documents', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Document',
new_name='Chapter',
),
migrations.RenameField(
model_name='paragraph',
old_name='document',
new_name='chapter',
),
]
|
Work around a migration issue in sqlite
|
apps/documents: Work around a migration issue in sqlite
|
Python
|
agpl-3.0
|
liqd/a4-meinberlin,liqd/a4-meinberlin,liqd/a4-meinberlin,liqd/a4-meinberlin
|
408ec05722cacd1e8574d9af206bffcf319c23b2
|
pipes/iam/__main__.py
|
pipes/iam/__main__.py
|
"""Create IAM Instance Profiles, Roles, Users, and Groups."""
import argparse
import logging
from .create_iam import create_iam_resources
LOG = logging.getLogger(__name__)
def main():
"""Command to create IAM Instance Profiles, Roles, Users, and Groups."""
logging.basicConfig()
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument('-d',
'--debug',
action='store_const',
const=logging.DEBUG,
default=logging.INFO,
help='Set DEBUG output')
parser.add_argument('-e',
'--env',
choices=('dev', 'stage', 'prod'),
default='dev',
help='Deploy environment')
parser.add_argument('-a',
'--app',
default='testapp',
help='Spinnaker Application name')
args = parser.parse_args()
LOG.setLevel(args.debug)
logging.getLogger(__package__).setLevel(args.debug)
vars(args).pop('debug')
assert create_iam_resources(env=args.env, app=args.app)
if __name__ == '__main__':
main()
|
"""Create IAM Instance Profiles, Roles, Users, and Groups."""
import argparse
import logging
from .create_iam import create_iam_resources
LOG = logging.getLogger(__name__)
def main():
"""Command to create IAM Instance Profiles, Roles, Users, and Groups."""
logging.basicConfig()
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument('-d',
'--debug',
action='store_const',
const=logging.DEBUG,
default=logging.INFO,
help='Set DEBUG output')
parser.add_argument('-e',
'--env',
choices=('build', 'dev', 'stage', 'prod'),
default='dev',
help='Deploy environment')
parser.add_argument('-a',
'--app',
default='testapp',
help='Spinnaker Application name')
args = parser.parse_args()
LOG.setLevel(args.debug)
logging.getLogger(__package__).setLevel(args.debug)
vars(args).pop('debug')
assert create_iam_resources(env=args.env, app=args.app)
if __name__ == '__main__':
main()
|
Add build as available environment
|
Add build as available environment
|
Python
|
apache-2.0
|
gogoair/foremast,gogoair/foremast
|
3d2f19ff097cf144efd9135c52e4d584193f9ddb
|
tohu/v7/custom_generator/tohu_items_class.py
|
tohu/v7/custom_generator/tohu_items_class.py
|
import attr
__all__ = ["make_tohu_items_class"]
def make_tohu_items_class(clsname, field_names):
"""
Parameters
----------
clsname: string
Name of the class to be created.
field_names: list of strings
Names of the field attributes of the class to be created.
"""
item_cls = attr.make_class(clsname, {name: attr.ib() for name in field_names}, repr=True, cmp=True, frozen=True)
func_eq_orig = item_cls.__eq__
def func_eq_new(self, other):
"""
Custom __eq__() method which also allows comparisons with
tuples and dictionaries. This is mostly for convenience
during testing.
"""
if isinstance(other, self.__class__):
return func_eq_orig(self, other)
else:
if isinstance(other, tuple):
return attr.astuple(self) == other
elif isinstance(other, dict):
return attr.asdict(self) == other
else:
raise TypeError(
f"Tohu items have types that cannot be compared: "
"{self.__class__.__name__}, {other.__class__.__name__}"
)
item_cls.__eq__ = func_eq_new
item_cls.field_names = field_names
item_cls.as_dict = lambda self: attr.asdict(self)
item_cls.as_tuple = lambda self: attr.astuple(self)
return item_cls
|
import attr
__all__ = ["make_tohu_items_class"]
def make_tohu_items_class(clsname, field_names):
"""
Parameters
----------
clsname: string
Name of the class to be created.
field_names: list of strings
Names of the field attributes of the class to be created.
"""
item_cls = attr.make_class(clsname, {name: attr.ib() for name in field_names}, repr=True, cmp=True, frozen=True)
func_eq_orig = item_cls.__eq__
def func_eq_new(self, other):
"""
Custom __eq__() method which also allows comparisons with
tuples and dictionaries. This is mostly for convenience
during testing.
"""
if isinstance(other, self.__class__):
return func_eq_orig(self, other)
else:
if isinstance(other, tuple):
return attr.astuple(self) == other
elif isinstance(other, dict):
return attr.asdict(self) == other
else:
raise TypeError(
f"Tohu items have types that cannot be compared: "
"{self.__class__.__name__}, {other.__class__.__name__}"
)
item_cls.__eq__ = func_eq_new
item_cls.field_names = field_names
item_cls.as_dict = lambda self: attr.asdict(self)
item_cls.as_tuple = lambda self: attr.astuple(self)
item_cls.is_unset = False
return item_cls
|
Add attribute 'is_unset' so that the interface is consistent with MissingTohuItemsCls
|
Add attribute 'is_unset' so that the interface is consistent with MissingTohuItemsCls
|
Python
|
mit
|
maxalbert/tohu
|
445b80562e038bc3749930d44e00eda55edaa180
|
ci_scripts/buildLinuxWheels.py
|
ci_scripts/buildLinuxWheels.py
|
from subprocess import call, check_output
import sys
import os
isPython3 = sys.version_info.major == 3
# https://stackoverflow.com/a/3357357
command = 'git log --format=%B -n 1'.split()
out = check_output(command)
if b'build wheels' not in out.lower() or not isPython3:
exit(0)
path = os.path.abspath(argv[1])
call('pip install cibuildwheel==0.7.0'.split())
call('cibuildwheel --output-dir {}'.format(path).split())
from dropboxUpload import uploadAll
uploadAll(path)
|
from subprocess import call, check_output
import sys
import os
isPython3 = sys.version_info.major == 3
# https://stackoverflow.com/a/3357357
command = 'git log --format=%B -n 1'.split()
out = check_output(command)
if b'build wheels' not in out.lower() or not isPython3:
exit(0)
path = os.path.abspath(sys.argv[1])
call('pip install cibuildwheel==0.7.0'.split())
call('cibuildwheel --output-dir {}'.format(sys.argv[1]).split())
from dropboxUpload import uploadAll
uploadAll(path)
|
Fix build wheels and upload 4.
|
Fix build wheels and upload 4.
|
Python
|
bsd-3-clause
|
jr-garcia/AssimpCy,jr-garcia/AssimpCy
|
bec498894ebd612058f905e1cfe4f5230df91841
|
client/examples/cycle-cards.py
|
client/examples/cycle-cards.py
|
#!/bin/python
import removinator
import subprocess
# This example cycles through each card slot in the Removinator. Any
# slots that have a card present will then have the certificates on the
# card printed out using the pkcs15-tool utility, which is provided by
# the OpenSC project.
#
# Examples of parsing the Removinator status output and enabling debug
# output from the firmware are also provided.
print('--- Connecting to Removinator ---')
ctl = removinator.Removinator()
print('--- Cycling through cards ---')
for card in range(1, 9):
try:
ctl.insert_card(card)
print('Inserted card {0}'.format(card))
print('{0}'.format(subprocess.check_output(['pkcs15-tool',
'--list-certificates'])
.rstrip()))
except removinator.SlotError:
print('Card {0} is not inserted'.format(card))
print('--- Checking Removinator status ---')
status = ctl.get_status()
print('Current card: {0}'.format(status['current']))
for card in status['present']:
print('Card {0} is present'.format(card))
print('--- Debug output for re-insertion of current card ---')
ctl.set_debug(True)
ctl.insert_card(status['current'])
print('{0}'.format(ctl.last_response.rstrip()))
ctl.set_debug(False)
print('--- Remove current card ---')
ctl.remove_card()
|
#!/bin/python
import removinator
import subprocess
# This example cycles through each card slot in the Removinator. Any
# slots that have a card present will then have the certificates on the
# card printed out using the pkcs15-tool utility, which is provided by
# the OpenSC project.
#
# Examples of parsing the Removinator status output and enabling debug
# output from the firmware are also provided.
print('--- Connecting to Removinator ---')
ctl = removinator.Removinator()
print('--- Cycling through cards ---')
for card in range(1, 9):
try:
ctl.insert_card(card)
print('Inserted card {0}'.format(card))
print('{0}'.format(subprocess.check_output(['pkcs15-tool',
'--list-certificates'])
.rstrip()))
except removinator.SlotError:
print('Card {0} is not inserted'.format(card))
print('--- Checking Removinator status ---')
status = ctl.get_status()
print('Current card: {0}'.format(status['current']))
for card in status['present']:
print('Card {0} is present'.format(card))
print('--- Debug output for re-insertion of current card ---')
ctl.set_debug(True)
ctl.insert_card(status['current'])
print('{0}'.format(ctl.last_response.rstrip()))
ctl.set_debug(False)
print('--- Remove current card ---')
ctl.remove_card()
|
Correct PEP8 indendation issue in client example
|
Correct PEP8 indendation issue in client example
|
Python
|
apache-2.0
|
nkinder/smart-card-removinator
|
a10407bf4d9dd404d734985717aa7bcebfa0981d
|
api/digital_ocean.py
|
api/digital_ocean.py
|
"""
@fileoverview Digital Ocean API
@author David Parlevliet
@version 20130315
@preserve Copyright 2013 David Parlevliet.
Digital Ocean API
=================
Class to get the server details via the Digital Ocean API.
"""
import urllib2
import json
class Api():
group_name = "Digital Ocean"
client_key = None
api_key = None
servers = {}
def __init__(self, **kwargs):
for key in kwargs:
setattr(self, key, kwargs[key])
def grab_servers(self):
DROPLETS_URL = 'https%s/droplets/?client_id=%s&api_key=%s' % \
('://api.digitalocean.com',
self.client_key,
self.api_key)
droplets = urllib2.urlopen(DROPLETS_URL)
try:
data = json.loads(droplets.read())
except:
raise Exception("Fatal error: No droplets found")
for droplet in data['droplets']:
if droplet['status'] == 'active':
name = droplet['name']
if name not in self.servers:
self.servers[name] = []
self.servers[name].append(droplet['ip_address'])
def get_servers(self, name):
return self.servers[name] if name in self.servers else None
|
"""
@fileoverview Digital Ocean API
@author David Parlevliet
@version 20130315
@preserve Copyright 2013 David Parlevliet.
Digital Ocean API
=================
Class to get the server details via the Digital Ocean API.
"""
import urllib2
import json
class Api():
group_name = "Digital Ocean"
client_key = None
api_key = None
servers = {}
def __init__(self, **kwargs):
for key in kwargs:
setattr(self, key, kwargs[key])
def grab_servers(self):
DROPLETS_URL = 'https%s/droplets/?client_id=%s&api_key=%s' % \
('://api.digitalocean.com',
self.client_key,
self.api_key)
try:
droplets = urllib2.urlopen(DROPLETS_URL)
except urllib2.URLError:
raise Exception("Fatal error: Unable to connect to API")
try:
data = json.loads(droplets.read())
except:
raise Exception("Fatal error: No droplets found")
for droplet in data['droplets']:
if droplet['status'] == 'active':
name = droplet['name']
if name not in self.servers:
self.servers[name] = []
self.servers[name].append(droplet['ip_address'])
def get_servers(self, name):
return self.servers[name] if name in self.servers else None
|
Return a helpful exception if API is uncontactable
|
Return a helpful exception if API is uncontactable
|
Python
|
mit
|
dparlevliet/elastic-firewall,dparlevliet/elastic-firewall,dparlevliet/elastic-firewall
|
7ff6c9d85eef03c225b511f39bbb07796b47659f
|
datapipe/history.py
|
datapipe/history.py
|
class History:
def __init__(self):
self.conn = sqlite3.connect('.history.db')
|
import sqlite3
class History:
def __init__(self, path):
self.conn = sqlite3.connect(path)
|
Make database filepath configurable on History
|
Make database filepath configurable on History
|
Python
|
mit
|
ibab/datapipe
|
fd4539942dafe622d3f7a7d183db3d69f95a00c4
|
shop/urls/cart.py
|
shop/urls/cart.py
|
from django.conf.urls.defaults import url, patterns
from shop.views.cart import CartDetails, CartItemDetail
urlpatterns = patterns('',
url(r'^delete/$', CartDetails.as_view(action='delete'), # DELETE
name='cart_delete'),
url('^item/$', CartDetails.as_view(action='post'), # POST
name='cart_item_add'),
url(r'^$', CartDetails.as_view(), name='cart'), # GET
url(r'^update/$', CartDetails.as_view(action='put'),
name='cart_update'),
# CartItems
url('^item/(?P<id>[0-9A-Za-z-_.//]+)$', CartItemDetail.as_view(),
name='cart_item'),
url('^item/(?P<id>[0-9A-Za-z-_.//]+)/delete$',
CartItemDetail.as_view(action='delete'),
name='cart_item_delete'),
)
|
from django.conf.urls.defaults import url, patterns
from shop.views.cart import CartDetails, CartItemDetail
urlpatterns = patterns('',
url(r'^delete/$', CartDetails.as_view(action='delete'), # DELETE
name='cart_delete'),
url('^item/$', CartDetails.as_view(action='post'), # POST
name='cart_item_add'),
url(r'^$', CartDetails.as_view(), name='cart'), # GET
url(r'^update/$', CartDetails.as_view(action='put'),
name='cart_update'),
# CartItems
url('^item/(?P<id>[0-9]+)$', CartItemDetail.as_view(),
name='cart_item'),
url('^item/(?P<id>[0-9]+)/delete$',
CartItemDetail.as_view(action='delete'),
name='cart_item_delete'),
)
|
Make sure that ID will not match the first CartItems rule EVERY time ("//" was in regex).
|
Make sure that ID will not match the first CartItems rule EVERY time ("//" was in regex).
|
Python
|
bsd-3-clause
|
schacki/django-shop,khchine5/django-shop,khchine5/django-shop,dwx9/test,febsn/django-shop,DavideyLee/django-shop,awesto/django-shop,jrief/django-shop,dwx9/test,thenewguy/django-shop,thenewguy/django-shop,bmihelac/django-shop,pjdelport/django-shop,creimers/django-shop,creimers/django-shop,jrief/django-shop,bmihelac/django-shop,awesto/django-shop,awesto/django-shop,febsn/django-shop,febsn/django-shop,nimbis/django-shop,khchine5/django-shop,pjdelport/django-shop,rfleschenberg/django-shop,rfleschenberg/django-shop,dwx9/test,rfleschenberg/django-shop,fusionbox/django-shop,chriscauley/django-shop,jrief/django-shop,divio/django-shop,creimers/django-shop,DavideyLee/django-shop,pjdelport/django-shop,schacki/django-shop,schacki/django-shop,nimbis/django-shop,atheiste/django-shop,nimbis/django-shop,katomaso/django-shop,fusionbox/django-shop,chriscauley/django-shop,atheiste/django-shop,chriscauley/django-shop,jrutila/django-shop,jrutila/django-shop,khchine5/django-shop,schacki/django-shop,nimbis/django-shop,jrutila/django-shop,divio/django-shop,divio/django-shop,katomaso/django-shop,katomaso/django-shop,rfleschenberg/django-shop,atheiste/django-shop,jrief/django-shop
|
10948cd88d51383e13af0a116703984752092c6a
|
jenkinsapi_tests/systests/test_jenkins_matrix.py
|
jenkinsapi_tests/systests/test_jenkins_matrix.py
|
'''
System tests for `jenkinsapi.jenkins` module.
'''
import re
import time
import unittest
from jenkinsapi_tests.systests.base import BaseSystemTest
from jenkinsapi_tests.systests.job_configs import MATRIX_JOB
from jenkinsapi_tests.test_utils.random_strings import random_string
class TestMatrixJob(BaseSystemTest):
def test_invoke_matrix_job(self):
job_name = 'create_%s' % random_string()
job = self.jenkins.create_job(job_name, MATRIX_JOB)
job.invoke(block=True)
b = job.get_last_build()
while b.is_running():
time.sleep(1)
s = set()
for r in b.get_matrix_runs():
self.assertEquals(r.get_number(), b.get_number())
self.assertEquals(r.get_upstream_build(), b)
m = re.search(u'\xbb (.*) #\\d+$', r.name)
self.assertIsNotNone(m)
s.add(m.group(1))
# This is a bad test, it simply verifies that this function does
# not crash on a build from a matrix job.
self.assertFalse(b.get_master_job_name())
self.assertEqual(s, set(['one', 'two', 'three']))
if __name__ == '__main__':
unittest.main()
|
'''
System tests for `jenkinsapi.jenkins` module.
'''
import re
import time
import unittest
from jenkinsapi_tests.systests.base import BaseSystemTest
from jenkinsapi_tests.systests.job_configs import MATRIX_JOB
from jenkinsapi_tests.test_utils.random_strings import random_string
class TestMatrixJob(BaseSystemTest):
def test_invoke_matrix_job(self):
job_name = 'create_%s' % random_string()
job = self.jenkins.create_job(job_name, MATRIX_JOB)
job.invoke(block=True)
build = job.get_last_build()
while build.is_running():
time.sleep(1)
set_of_groups = set()
for run in build.get_matrix_runs():
self.assertEquals(run.get_number(), build.get_number())
self.assertEquals(run.get_upstream_build(), build)
match_result = re.search(u'\xbb (.*) #\\d+$', run.name)
self.assertIsNotNone(match_result)
set_of_groups.add(match_result.group(1))
build.get_master_job_name()
# This is a bad test, it simply verifies that this function does
# not crash on a build from a matrix job.
self.assertFalse(build.get_master_job_name())
self.assertEqual(set_of_groups, set(['one', 'two', 'three']))
if __name__ == '__main__':
unittest.main()
|
Tidy up this test - still quite bad & useless.
|
Tidy up this test - still quite bad & useless.
|
Python
|
mit
|
imsardine/jenkinsapi,salimfadhley/jenkinsapi,JohnLZeller/jenkinsapi,JohnLZeller/jenkinsapi,aerickson/jenkinsapi,domenkozar/jenkinsapi,zaro0508/jenkinsapi,imsardine/jenkinsapi,zaro0508/jenkinsapi,jduan/jenkinsapi,mistermocha/jenkinsapi,domenkozar/jenkinsapi,salimfadhley/jenkinsapi,zaro0508/jenkinsapi,mistermocha/jenkinsapi,aerickson/jenkinsapi,jduan/jenkinsapi,JohnLZeller/jenkinsapi,mistermocha/jenkinsapi,imsardine/jenkinsapi
|
238ba8cec34ec02dc521f25ef1ada6e230194c32
|
kitsune/kbadge/migrations/0002_auto_20181023_1319.py
|
kitsune/kbadge/migrations/0002_auto_20181023_1319.py
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('kbadge', '0001_initial'),
]
operations = [
migrations.RunSQL(
"UPDATE badger_badge SET image = CONCAT('uploads/', image)"
)
]
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('kbadge', '0001_initial'),
]
operations = [
migrations.RunSQL(
"UPDATE badger_badge SET image = CONCAT('uploads/', image) WHERE image NOT LIKE 'uploads/%'"
)
]
|
Add WHERE clause to SQL data migration.
|
Add WHERE clause to SQL data migration.
|
Python
|
bsd-3-clause
|
mozilla/kitsune,anushbmx/kitsune,anushbmx/kitsune,anushbmx/kitsune,mozilla/kitsune,mozilla/kitsune,mozilla/kitsune,anushbmx/kitsune
|
4651d3b5666fe3ddf3bd92b31ee6ffe4a72ce94e
|
core/api/__init__.py
|
core/api/__init__.py
|
import os
from flask import Flask, jsonify
from flask_pymongo import PyMongo, BSONObjectIdConverter
from werkzeug.exceptions import HTTPException, default_exceptions
from core.api import settings
def create_app(environment=None):
app = Flask('veritrans')
app.url_map.converters['ObjectId'] = BSONObjectIdConverter
# Config app for environment
if not environment:
environment = os.environ.get('BACKEND_ENVIRONMENT', 'Prod')
app.config.from_object('core.api.settings.%s' % environment)
# convert exceptions to JSON
def make_json_error(ex):
response = jsonify(
message=str(ex)
)
response.status_code = (ex.code
if isinstance(ex, HTTPException)
else 500)
return response
for code in default_exceptions.items():
app.error_handler_spec[None][code] = make_json_error
from core.api.views.endpoints import api
app.register_module(api)
return app
class API(object):
app = None
mongo_client = None
@staticmethod
def init():
env = os.environ.get('SITE_NAME', 'Dev')
API.app = create_app(env)
API.mongo_client = PyMongo(API.app)
|
import os
from flask import Flask, jsonify
from flask_pymongo import PyMongo, BSONObjectIdConverter
from werkzeug.exceptions import HTTPException, default_exceptions
from core.api import settings
def create_app(environment=None):
app = Flask('veritrans')
app.url_map.converters['ObjectId'] = BSONObjectIdConverter
# Config app for environment
if not environment:
environment = os.environ.get('BACKEND_ENVIRONMENT', 'Prod')
app.config.from_object('core.api.settings.%s' % environment)
# convert exceptions to JSON
def make_json_error(ex):
response = jsonify(
message=str(ex)
)
response.status_code = (ex.code
if isinstance(ex, HTTPException)
else 500)
return response
for code in default_exceptions.items():
app.error_handler_spec[None][code] = make_json_error
from core.api.views.endpoints import api
app.register_module(api)
return app
class API(object):
app = None
mongo_client = None
@staticmethod
def init():
API.app = create_app()
API.mongo_client = PyMongo(API.app)
|
Use Production config unless specified
|
Use Production config unless specified
|
Python
|
mit
|
onyb/veritrans-payment-portals
|
ced218643784838d68961a926cc0dd18c3a3f01f
|
skald/geometry.py
|
skald/geometry.py
|
# -*- coding: utf-8 -*-
from collections import namedtuple
Size = namedtuple("Size", ["width", "height"])
Rectangle = namedtuple("Rectangle", ["x0", "y0", "x1", "y1"])
class Point(namedtuple("Point", ["x", "y"])):
"""Point in a two-dimensional space.
Named tuple implementation that allows for addition and subtraction.
"""
__slots__ = ()
def __add__(self, other):
x = self.x + other.x
y = self.y + other.y
return Point(x, y)
def __sub__(self, other):
x = self.x - other.x
y = self.y - other.y
return Point(x, y)
class Box(namedtuple("Box", ["point", "size"])):
__slots__ = ()
@property
def rectangle(self):
return Rectangle(
x0=self.point.x,
y0=self.point.y,
x1=self.point.x+self.size.width,
y1=self.point.y+self.size.height
)
|
# -*- coding: utf-8 -*-
from collections import namedtuple
Size = namedtuple("Size", ["width", "height"])
class Rectangle(namedtuple("Rectangle", ["x0", "y0", "x1", "y1"])):
def __contains__(self, other):
"""Check if this rectangle and `other` overlaps eachother.
Essentially this is a bit of a hack to be able to write
`rect1 in rect2`.
"""
if self.x0 < other.x0 and self.x1 > other.x1 and \
self.y0 < other.y0 and self.y1 > other.y1:
return True
return False
class Point(namedtuple("Point", ["x", "y"])):
"""Point in a two-dimensional space.
Named tuple implementation that allows for addition and subtraction.
"""
__slots__ = ()
def __add__(self, other):
x = self.x + other.x
y = self.y + other.y
return Point(x, y)
def __sub__(self, other):
x = self.x - other.x
y = self.y - other.y
return Point(x, y)
class Box(namedtuple("Box", ["point", "size"])):
__slots__ = ()
@property
def rectangle(self):
return Rectangle(
x0=self.point.x,
y0=self.point.y,
x1=self.point.x+self.size.width,
y1=self.point.y+self.size.height
)
|
Add intersection test for rectangles
|
Add intersection test for rectangles
|
Python
|
mit
|
bjornarg/skald,bjornarg/skald
|
8f03f51c89aeea44943f9cb0b39330e676ae0089
|
utils.py
|
utils.py
|
import vx
from contextlib import contextmanager
from functools import partial
import sys
from io import StringIO
def _expose(f=None, name=None):
if f is None:
return partial(_expose, name=name)
if name is None:
name = f.__name__.lstrip('_')
if getattr(vx, name, None) is not None:
raise AttributeError("Cannot expose duplicate name: '{}'".format(name))
setattr(vx, name, f)
return f
vx.expose = _expose
@vx.expose
def _repeat(c, times=4):
for _ in range(times):
c()
@vx.expose
@contextmanager
def _cursor_wander(command=None, window=None):
if window is None:
window = vx.window.focused_window
y, x = vx.get_linecol_window(window)
if command is not None:
command()
yp, xp = vx.get_linecol_window(window)
yield (yp, xp)
vx.set_linecol_window(window, y, x)
@contextmanager
def stdoutIO(stdout=None):
old = sys.stdout
if stdout is None:
stdout = StringIO()
sys.stdout = stdout
yield stdout
sys.stdout = old
|
import vx
from contextlib import contextmanager
from functools import partial
import sys
from io import StringIO
def _expose(f=None, name=None):
if f is None:
return partial(_expose, name=name)
if name is None:
name = f.__name__.lstrip('_')
if getattr(vx, name, None) is not None:
raise AttributeError("Cannot expose duplicate name: '{}'".format(name))
setattr(vx, name, f)
return f
vx.expose = _expose
@vx.expose
def _repeat(c, times=4):
res = []
for _ in range(times):
res.append(c())
return res
@vx.expose
@contextmanager
def _cursor_wander(command=None, window=None):
if window is None:
window = vx.window.focused_window
y, x = vx.get_linecol_window(window)
if command is not None:
command()
yp, xp = vx.get_linecol_window(window)
yield (yp, xp)
vx.set_linecol_window(window, y, x)
@contextmanager
def stdoutIO(stdout=None):
old = sys.stdout
if stdout is None:
stdout = StringIO()
sys.stdout = stdout
yield stdout
sys.stdout = old
|
Change repeat command to return a list of the results of the repeated commands
|
Change repeat command to return a list of the results of the repeated commands
|
Python
|
mit
|
philipdexter/vx,philipdexter/vx
|
822e6123cc598b4f6a0eafedfb2f0d0cbfba5f37
|
currencies/migrations/0003_auto_20151216_1906.py
|
currencies/migrations/0003_auto_20151216_1906.py
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from extra_countries.models import ExtraCountry
def add_currencies_with_countries(apps, schema_editor):
# We can't import the model directly as it may be a newer
# version than this migration expects. We use the historical version.
Currency = apps.get_model("currencies", "Currency")
for extra_country in ExtraCountry.objects.all():
print("seeding currency for county: %s" % extra_country.country.name)
# trying to find a currency with the same code first
try:
currency = Currency.objects.get(code=extra_country.country.currency)
except Currency.DoesNotExist: # no such currency yet
currency = Currency(code=extra_country.country.currency,
name=extra_country.country.currency_name)
currency.save()
currency.countries.add(extra_country.pk)
def reverse_data(apps, schema_editor):
Currency = apps.get_model("currencies", "Currency")
Currency.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('currencies', '0002_currency_countries'),
]
operations = [
migrations.RunPython(add_currencies_with_countries, reverse_data)
]
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from extra_countries.models import ExtraCountry
def add_currencies_with_countries(apps, schema_editor):
# We can't import the model directly as it may be a newer
# version than this migration expects. We use the historical version.
Currency = apps.get_model("currencies", "Currency")
for extra_country in ExtraCountry.objects.all():
print("seeding currency for county: %s" % extra_country.country.name)
# trying to find a currency with the same code first
try:
currency = Currency.objects.get(code=extra_country.country.currency)
except Currency.DoesNotExist: # no such currency yet
currency = Currency(code=extra_country.country.currency,
name=extra_country.country.currency_name)
if (str(extra_country.country.currency) == '') or (str(extra_country.country.currency_name) == ''):
pass
else:
currency.save()
currency.countries.add(extra_country.pk)
def reverse_data(apps, schema_editor):
Currency = apps.get_model("currencies", "Currency")
Currency.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('currencies', '0002_currency_countries'),
]
operations = [
migrations.RunPython(add_currencies_with_countries, reverse_data)
]
|
Fix currencies seeding, so it won't have empty currencies
|
Fix currencies seeding, so it won't have empty currencies
|
Python
|
mit
|
openspending/cosmopolitan,kiote/cosmopolitan
|
041b271baa7ae0bbd20c30ac4f70b42fda267e93
|
mozillians/groups/__init__.py
|
mozillians/groups/__init__.py
|
from django.apps import AppConfig
CIS_GROUPS = [
'cis_whitelist',
'nda'
]
default_app_config = 'mozillians.groups.GroupConfig'
class GroupConfig(AppConfig):
name = 'mozillians.groups'
|
from django.apps import AppConfig
CIS_GROUPS = [
'cis_whitelist',
'nda',
'open-innovation-reps-council'
]
default_app_config = 'mozillians.groups.GroupConfig'
class GroupConfig(AppConfig):
name = 'mozillians.groups'
|
Add a group in the whitelist.
|
Add a group in the whitelist.
|
Python
|
bsd-3-clause
|
mozilla/mozillians,akatsoulas/mozillians,mozilla/mozillians,johngian/mozillians,mozilla/mozillians,mozilla/mozillians,akatsoulas/mozillians,akatsoulas/mozillians,johngian/mozillians,johngian/mozillians,johngian/mozillians,akatsoulas/mozillians
|
199c9bae8e2ad42ee1c8699c678dd56d6074b2de
|
main/models.py
|
main/models.py
|
from django.db import models
from django.contrib.auth.models import User
import string, random
from django import forms
# Create your models here.
def _generate_default_hashtag():
return "".join(random.choice(string.lowercase) for i in range(3))
class Wall(models.Model):
hashtag = models.CharField(max_length=20, help_text='Twitter hashtag to tweet to', default=_generate_default_hashtag())
user = models.ForeignKey(User, editable=False)
sms_keyword = models.CharField(max_length=20)
def __unicode__(self):
return self.name
TRAFFIC_SOURCE = (
('BG', 'Blog'),
('FR', 'Friend'),
('OT', 'Other',)
)
|
from django.db import models
from django.contrib.auth.models import User
import string, random
from django import forms
# Create your models here.
def _generate_default_hashtag():
return "".join(random.choice(string.lowercase) for i in range(3))
class Wall(models.Model):
hashtag = models.CharField(max_length=20, help_text='Twitter hashtag to tweet to', default=_generate_default_hashtag())
user = models.ForeignKey(User, editable=False)
sms_keyword = models.CharField(max_length=20)
def __unicode__(self):
return self.sms_keyword
TRAFFIC_SOURCE = (
('BG', 'Blog'),
('FR', 'Friend'),
('OT', 'Other',)
)
|
Return sms_keyword as wall name
|
Return sms_keyword as wall name
|
Python
|
mit
|
Aaron1011/texting_wall
|
523ee893118413caa45e66869e9380f5e52f3402
|
src/parser/python/print_libpython.py
|
src/parser/python/print_libpython.py
|
# Print embeddable python library, as well as other libs it requires.
# Will prefer static linkage unless invoked with "shared" argument.
# JGG, 8/4/04
import sys, distutils.sysconfig
static_link = 1
nargs = len(sys.argv)
if nargs == 2 and sys.argv[1] == "shared":
static_link = 0
# Note that this adds libraries we've certainly already linked to.
libs = distutils.sysconfig.get_config_var("LIBS")
libs += " " + distutils.sysconfig.get_config_var("SYSLIBS")
if static_link:
prefix = distutils.sysconfig.get_config_var("LIBPL")
pythonlib = distutils.sysconfig.get_config_var("BLDLIBRARY")
if len(pythonlib) > 0:
print prefix + '/' + pythonlib, libs
sys.exit(0)
# else try shared linkage
linkshared = distutils.sysconfig.get_config_vars("LINKFORSHARED")[0]
# FIXME: Will this sanity test work for all platforms??
# NB: sys.platform can help us if we need to test for platform
if linkshared.find("ython") != -1:
print linkshared, libs
sys.exit(0)
print >> sys.stderr, "***ERROR: Can't find a python to embed."
sys.exit(1)
|
# Print embeddable python library, as well as other libs it requires.
# Will prefer static linkage unless invoked with "shared" argument.
# JGG, 8/4/04
import sys, distutils.sysconfig
static_link = 1
nargs = len(sys.argv)
if nargs == 2 and sys.argv[1] == "shared":
static_link = 0
# Note that this adds libraries we've certainly already linked to.
libs = distutils.sysconfig.get_config_var("LIBS")
libs += " " + distutils.sysconfig.get_config_var("SYSLIBS")
if static_link:
prefix = distutils.sysconfig.get_config_var("LIBPL")
pythonlib = distutils.sysconfig.get_config_var("BLDLIBRARY")
if len(pythonlib) > 0:
import os.path
plib = prefix + '/' + pythonlib
# Must see if file exists, because it doesn't in Jaguar!
if os.path.exists(plib):
print plib, libs
sys.exit(0)
# else try shared linkage
linkshared = distutils.sysconfig.get_config_vars("LINKFORSHARED")[0]
# FIXME: Will this sanity test work for all platforms??
# NB: sys.platform can help us if we need to test for platform
if linkshared.find("ython") != -1:
print linkshared, libs
sys.exit(0)
print >> sys.stderr, "***ERROR: Can't find a python to embed."
sys.exit(1)
|
Test file existence for brain-dead Jaguar.
|
Test file existence for brain-dead Jaguar.
|
Python
|
apache-2.0
|
RTcmix/RTcmix,RTcmix/RTcmix,RTcmix/RTcmix,RTcmix/RTcmix,RTcmix/RTcmix,RTcmix/RTcmix
|
b6ec3ba9efae7b6b291391b0333e80f2e9fc6fa0
|
src/waldur_mastermind/invoices/migrations/0053_invoiceitem_uuid.py
|
src/waldur_mastermind/invoices/migrations/0053_invoiceitem_uuid.py
|
import uuid
from django.db import migrations
import waldur_core.core.fields
def gen_uuid(apps, schema_editor):
InvoiceItem = apps.get_model('invoices', 'InvoiceItem')
for row in InvoiceItem.objects.all():
row.uuid = uuid.uuid4().hex
row.save(update_fields=['uuid'])
class Migration(migrations.Migration):
dependencies = [
('invoices', '0052_delete_servicedowntime'),
]
operations = [
migrations.AddField(
model_name='invoiceitem',
name='uuid',
field=waldur_core.core.fields.UUIDField(null=True),
),
migrations.RunPython(gen_uuid, elidable=True),
migrations.AlterField(
model_name='invoiceitem',
name='uuid',
field=waldur_core.core.fields.UUIDField(),
),
]
|
import uuid
from django.db import migrations, models
import waldur_core.core.fields
def gen_uuid(apps, schema_editor):
InvoiceItem = apps.get_model('invoices', 'InvoiceItem')
for row in InvoiceItem.objects.all():
row.uuid = uuid.uuid4().hex
row.save(update_fields=['uuid'])
class Migration(migrations.Migration):
dependencies = [
('invoices', '0052_delete_servicedowntime'),
]
operations = [
migrations.AddField(
model_name='invoiceitem', name='uuid', field=models.UUIDField(null=True),
),
migrations.RunPython(gen_uuid, elidable=True),
migrations.AlterField(
model_name='invoiceitem',
name='uuid',
field=waldur_core.core.fields.UUIDField(),
),
]
|
Fix database migration script for UUID field in invoice item model.
|
Fix database migration script for UUID field in invoice item model.
|
Python
|
mit
|
opennode/waldur-mastermind,opennode/waldur-mastermind,opennode/waldur-mastermind,opennode/waldur-mastermind
|
9b19d366c7e1cf41ffc6af4eaed789995ddc5cc2
|
byceps/blueprints/core_admin/views.py
|
byceps/blueprints/core_admin/views.py
|
"""
byceps.blueprints.core_admin.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""
from ...services.brand import service as brand_service
from ...util.framework.blueprint import create_blueprint
from ..authorization.registry import permission_registry
from .authorization import AdminPermission
blueprint = create_blueprint('core_admin', __name__)
permission_registry.register_enum(AdminPermission)
@blueprint.app_context_processor
def inject_brands():
brands = brand_service.get_brands()
return {
'all_brands': brands,
}
|
"""
byceps.blueprints.core_admin.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""
from ...services.brand import service as brand_service
from ...util.framework.blueprint import create_blueprint
from ..authorization.registry import permission_registry
from .authorization import AdminPermission
blueprint = create_blueprint('core_admin', __name__)
permission_registry.register_enum(AdminPermission)
@blueprint.app_context_processor
def inject_template_variables():
brands = brand_service.get_brands()
return {
'all_brands': brands,
}
|
Generalize name of function to inject admin template variables
|
Generalize name of function to inject admin template variables
|
Python
|
bsd-3-clause
|
homeworkprod/byceps,m-ober/byceps,m-ober/byceps,homeworkprod/byceps,homeworkprod/byceps,m-ober/byceps
|
f3bb89a58375ac91efb1fa6f3426c0a7e7dd85d5
|
tests/fixtures/source.py
|
tests/fixtures/source.py
|
#!/usr/bin/env python
class Person:
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def fullname(self):
return "%s %s" % (self.first_name, self.last_name)
def not_called(self):
print("Shouldn't be called")
person = Person("Marty", "McFly")
person.fullname()
|
#!/usr/bin/env python
class Person:
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def fullname(self):
return "%s %s" % (self.first_name, self.last_name)
def not_called(self):
print("Shouldn't be called")
person = Person("Marty", "McFly")
person.fullname()
|
Add BOM signature to test fixture
|
Add BOM signature to test fixture
|
Python
|
mit
|
codeclimate/python-test-reporter,codeclimate/python-test-reporter
|
6ac683ca1905fbf17dd63c1264609e770439fa7f
|
test/integration/targets/module_utils/library/test_env_override.py
|
test/integration/targets/module_utils/library/test_env_override.py
|
#!/usr/bin/python
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.json_utils import data
from ansible.module_utils.mork import data as mork_data
results = {"json_utils": data, "mork": mork_data}
AnsibleModule(argument_spec=dict()).exit_json(**results)
|
#!/usr/bin/python
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.json_utils import data
from ansible.module_utils.mork import data as mork_data
results = {"json_utils": data, "mork": mork_data}
AnsibleModule(argument_spec=dict()).exit_json(**results)
|
Disable pylint check for names existing in modules for test data
|
Disable pylint check for names existing in modules for test data
This test data imports from modules which are only available via
PluginLoader for this test case. So pylint doesn't know anything about
them
|
Python
|
mit
|
thaim/ansible,thaim/ansible
|
d4acff165712281cb7205cca1c39e7eaf1fdd23b
|
base/broadcast.py
|
base/broadcast.py
|
from abc import ABCMeta, abstractmethod
from enum import Enum
class Broadcast(metaclass=ABCMeta):
"""
An interface for defining a broadcast protocol.
The 'propose' and 'decide' methods need to be defined
"""
class MessageType(Enum):
SEND = 1
ECHO = 2
READY = 3
def __init__(self, node_number, faulty_nodes):
self.N = node_number
self.f = faulty_nodes
@abstractmethod
def broadcast(self, message):
pass
@abstractmethod
def broadcast_listener(self):
pass
@abstractmethod
def deliver(self, sender, message):
pass
|
Add abstract Broadcast protocol class
|
Add abstract Broadcast protocol class
|
Python
|
mit
|
koevskinikola/ByzantineRandomizedConsensus
|
|
7872abf00b24a504fccba576b13ecdd140e0135f
|
pybb/read_tracking.py
|
pybb/read_tracking.py
|
def update_read_tracking(topic, user):
tracking = user.readtracking
#if last_read > last_read - don't check topics
if tracking.last_read and tracking.last_read > (topic.last_post.updated or
topic.last_post.created):
return
if isinstance(tracking.topics, dict):
#clear topics if len > 5Kb and set last_read to current time
if len(tracking.topics) > 5120:
tracking.topics = None
tracking.last_read = datetime.now()
tracking.save()
#update topics if exist new post or does't exist in dict
if topic.last_post.pk > tracking.topics.get(str(topic.pk), 0):
tracking.topics.setdefault(str(topic.pk), topic.last_post.pk)
tracking.save()
else:
#initialize topic tracking dict
tracking.topics = {topic.pk: topic.last_post.pk}
tracking.save()
|
def update_read_tracking(topic, user):
tracking = user.readtracking
#if last_read > last_read - don't check topics
if tracking.last_read and tracking.last_read > (topic.last_post.updated or
topic.last_post.created):
return
if isinstance(tracking.topics, dict):
#clear topics if len > 5Kb and set last_read to current time
if len(tracking.topics) > 5120:
tracking.topics = None
tracking.last_read = datetime.now()
tracking.save()
#update topics if new post exists or cache entry is empty
if topic.last_post.pk > tracking.topics.get(str(topic.pk), 0):
tracking.topics[str(topic.pk)] = topic.last_post.pk
tracking.save()
else:
#initialize topic tracking dict
tracking.topics = {topic.pk: topic.last_post.pk}
tracking.save()
|
Fix bug in read tracking system
|
Fix bug in read tracking system
|
Python
|
bsd-2-clause
|
ttyS15/pybbm,onecue/pybbm,katsko/pybbm,katsko/pybbm,wengole/pybbm,wengole/pybbm,webu/pybbm,acamposruiz/quecoins,springmerchant/pybbm,NEERAJIITKGP/pybbm,webu/pybbm,concentricsky/pybbm,skolsuper/pybbm,hovel/pybbm,NEERAJIITKGP/pybbm,hovel/pybbm,webu/pybbm,artfinder/pybbm,onecue/pybbm,katsko/pybbm,ttyS15/pybbm,wengole/pybbm,jonsimington/pybbm,jonsimington/pybbm,ttyS15/pybbm,skolsuper/pybbm,just-work/pybbm,zekone/dj_pybb,onecue/pybbm,hovel/pybbm,just-work/pybbm,acamposruiz/quecoins,acamposruiz/quecoins,springmerchant/pybbm,springmerchant/pybbm,skolsuper/pybbm,artfinder/pybbm,zekone/dj_pybb,concentricsky/pybbm,DylannCordel/pybbm,just-work/pybbm,zekone/dj_pybb,DylannCordel/pybbm,jonsimington/pybbm,artfinder/pybbm,concentricsky/pybbm,DylannCordel/pybbm,NEERAJIITKGP/pybbm
|
346ffdb3e3836e2931f838a6dd929a325da0d5e6
|
tests/test_arithmetic.py
|
tests/test_arithmetic.py
|
from intervals import Interval
class TestArithmeticOperators(object):
def test_add_operator(self):
assert Interval(1, 2) + Interval(1, 2) == Interval(2, 4)
def test_sub_operator(self):
assert Interval(1, 3) - Interval(1, 2) == Interval(-1, 2)
def test_isub_operator(self):
range_ = Interval(1, 3)
range_ -= Interval(1, 2)
assert range_ == Interval(-1, 2)
def test_iadd_operator(self):
range_ = Interval(1, 2)
range_ += Interval(1, 2)
assert range_ == Interval(2, 4)
|
from pytest import mark
from intervals import Interval
class TestArithmeticOperators(object):
def test_add_operator(self):
assert Interval(1, 2) + Interval(1, 2) == Interval(2, 4)
def test_sub_operator(self):
assert Interval(1, 3) - Interval(1, 2) == Interval(-1, 2)
def test_isub_operator(self):
range_ = Interval(1, 3)
range_ -= Interval(1, 2)
assert range_ == Interval(-1, 2)
def test_iadd_operator(self):
range_ = Interval(1, 2)
range_ += Interval(1, 2)
assert range_ == Interval(2, 4)
@mark.parametrize(('first', 'second', 'intersection'), (
('[1, 5]', '[2, 9]', '[2, 5]'),
('[3, 4]', '[3, 9]', '[3, 4]'),
('(3, 6]', '[2, 6)', '(3, 6)')
))
def test_intersection(self, first, second, intersection):
Interval(first) & Interval(second) == Interval(intersection)
|
Add some tests for intersection
|
Add some tests for intersection
|
Python
|
bsd-3-clause
|
kvesteri/intervals
|
2a0c8bdb74404556483cd60e7cb2f8e25559e500
|
pylearn2/scripts/tutorials/grbm_smd/test_grbm_smd.py
|
pylearn2/scripts/tutorials/grbm_smd/test_grbm_smd.py
|
import pylearn2
from pylearn2.utils.serial import load_train_file
import os
from pylearn2.testing import no_debug_mode
from theano import config
@no_debug_mode
def test_train_example():
""" tests that the grbm_smd example script runs correctly """
assert config.mode != "DEBUG_MODE"
path = pylearn2.__path__[0]
train_example_path = os.path.join(path, 'scripts', 'tutorials', 'grbm_smd')
train_yaml_path = os.path.join(train_example_path, 'cifar_grbm_smd.yaml')
train_object = load_train_file(train_yaml_path)
#make the termination criterion really lax so the test won't run for long
train_object.algorithm.termination_criterion.prop_decrease = 0.5
train_object.algorithm.termination_criterion.N = 1
train_object.main_loop()
if __name__ == '__main__':
test_train_example()
|
import pylearn2
from pylearn2.utils.serial import load_train_file
import os
from pylearn2.testing import no_debug_mode
from theano import config
@no_debug_mode
def test_train_example():
""" tests that the grbm_smd example script runs correctly """
assert config.mode != "DEBUG_MODE"
path = pylearn2.__path__[0]
train_example_path = os.path.join(path, 'scripts', 'tutorials', 'grbm_smd')
cwd = os.getcwd()
try:
os.chdir(train_example_path)
train_yaml_path = os.path.join(train_example_path, 'cifar_grbm_smd.yaml')
train_object = load_train_file(train_yaml_path)
#make the termination criterion really lax so the test won't run for long
train_object.algorithm.termination_criterion.prop_decrease = 0.5
train_object.algorithm.termination_criterion.N = 1
train_object.main_loop()
finally:
os.chdir(cwd)
if __name__ == '__main__':
test_train_example()
|
Fix failing test through loading of examples from $PWD.
|
Fix failing test through loading of examples from $PWD.
|
Python
|
bsd-3-clause
|
aalmah/pylearn2,TNick/pylearn2,shiquanwang/pylearn2,alexjc/pylearn2,fyffyt/pylearn2,bartvm/pylearn2,pkainz/pylearn2,lancezlin/pylearn2,pkainz/pylearn2,CIFASIS/pylearn2,daemonmaker/pylearn2,woozzu/pylearn2,ddboline/pylearn2,caidongyun/pylearn2,shiquanwang/pylearn2,mclaughlin6464/pylearn2,chrish42/pylearn,theoryno3/pylearn2,ddboline/pylearn2,Refefer/pylearn2,abergeron/pylearn2,skearnes/pylearn2,aalmah/pylearn2,lisa-lab/pylearn2,chrish42/pylearn,alexjc/pylearn2,JesseLivezey/plankton,alexjc/pylearn2,TNick/pylearn2,woozzu/pylearn2,fulmicoton/pylearn2,aalmah/pylearn2,matrogers/pylearn2,mclaughlin6464/pylearn2,fishcorn/pylearn2,hyqneuron/pylearn2-maxsom,junbochen/pylearn2,shiquanwang/pylearn2,CIFASIS/pylearn2,matrogers/pylearn2,bartvm/pylearn2,theoryno3/pylearn2,skearnes/pylearn2,fyffyt/pylearn2,se4u/pylearn2,pombredanne/pylearn2,fulmicoton/pylearn2,nouiz/pylearn2,ddboline/pylearn2,lisa-lab/pylearn2,fyffyt/pylearn2,skearnes/pylearn2,jamessergeant/pylearn2,junbochen/pylearn2,alexjc/pylearn2,w1kke/pylearn2,w1kke/pylearn2,daemonmaker/pylearn2,sandeepkbhat/pylearn2,daemonmaker/pylearn2,lancezlin/pylearn2,fishcorn/pylearn2,bartvm/pylearn2,TNick/pylearn2,sandeepkbhat/pylearn2,JesseLivezey/pylearn2,ashhher3/pylearn2,lancezlin/pylearn2,sandeepkbhat/pylearn2,matrogers/pylearn2,shiquanwang/pylearn2,JesseLivezey/plankton,kastnerkyle/pylearn2,TNick/pylearn2,CIFASIS/pylearn2,woozzu/pylearn2,theoryno3/pylearn2,KennethPierce/pylearnk,fulmicoton/pylearn2,jamessergeant/pylearn2,junbochen/pylearn2,daemonmaker/pylearn2,chrish42/pylearn,hantek/pylearn2,kastnerkyle/pylearn2,nouiz/pylearn2,mkraemer67/pylearn2,lisa-lab/pylearn2,lamblin/pylearn2,w1kke/pylearn2,Refefer/pylearn2,kose-y/pylearn2,w1kke/pylearn2,ddboline/pylearn2,goodfeli/pylearn2,jeremyfix/pylearn2,sandeepkbhat/pylearn2,hantek/pylearn2,kose-y/pylearn2,KennethPierce/pylearnk,se4u/pylearn2,JesseLivezey/pylearn2,lancezlin/pylearn2,ashhher3/pylearn2,goodfeli/pylearn2,lisa-lab/pylearn2,lunyang/pylearn2,theoryno3/pylearn2,hyqneuron/pylearn2-maxsom,ashhher3/pylearn2,se4u/pylearn2,JesseLivezey/pylearn2,lunyang/pylearn2,hantek/pylearn2,kose-y/pylearn2,fishcorn/pylearn2,goodfeli/pylearn2,matrogers/pylearn2,cosmoharrigan/pylearn2,lamblin/pylearn2,cosmoharrigan/pylearn2,pombredanne/pylearn2,hyqneuron/pylearn2-maxsom,mkraemer67/pylearn2,fyffyt/pylearn2,nouiz/pylearn2,msingh172/pylearn2,JesseLivezey/plankton,lunyang/pylearn2,ashhher3/pylearn2,Refefer/pylearn2,caidongyun/pylearn2,pombredanne/pylearn2,CIFASIS/pylearn2,chrish42/pylearn,caidongyun/pylearn2,abergeron/pylearn2,msingh172/pylearn2,kastnerkyle/pylearn2,mkraemer67/pylearn2,mclaughlin6464/pylearn2,skearnes/pylearn2,hantek/pylearn2,pombredanne/pylearn2,msingh172/pylearn2,JesseLivezey/plankton,kastnerkyle/pylearn2,junbochen/pylearn2,KennethPierce/pylearnk,lamblin/pylearn2,bartvm/pylearn2,fulmicoton/pylearn2,pkainz/pylearn2,KennethPierce/pylearnk,pkainz/pylearn2,fishcorn/pylearn2,Refefer/pylearn2,jeremyfix/pylearn2,nouiz/pylearn2,cosmoharrigan/pylearn2,jeremyfix/pylearn2,caidongyun/pylearn2,msingh172/pylearn2,mkraemer67/pylearn2,jamessergeant/pylearn2,hyqneuron/pylearn2-maxsom,mclaughlin6464/pylearn2,cosmoharrigan/pylearn2,jamessergeant/pylearn2,goodfeli/pylearn2,JesseLivezey/pylearn2,woozzu/pylearn2,abergeron/pylearn2,se4u/pylearn2,aalmah/pylearn2,lamblin/pylearn2,kose-y/pylearn2,jeremyfix/pylearn2,abergeron/pylearn2,lunyang/pylearn2
|
4cfd8771b91c7c2b9f28ca4b9776e9770683093b
|
frigg/builds/admin.py
|
frigg/builds/admin.py
|
# -*- coding: utf8 -*-
from django.contrib import admin
from .models import Build, BuildResult, Project
class BuildResultInline(admin.StackedInline):
model = BuildResult
readonly_fields = ('result_log', 'succeeded', 'return_code')
extra = 0
max_num = 0
class BuildInline(admin.TabularInline):
model = Build
readonly_fields = ('build_number', 'branch', 'color', 'pull_request_id', 'sha')
extra = 0
max_num = 0
@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
list_display = ('__str__', 'git_repository', 'average_time', 'last_build_number')
inlines = [BuildInline]
list_filter = ['owner']
@admin.register(Build)
class BuildAdmin(admin.ModelAdmin):
list_display = ('build_number', 'project', 'branch', 'pull_request_id', 'sha', 'color')
inlines = [BuildResultInline]
list_filter = ['project']
@admin.register(BuildResult)
class BuildResultAdmin(admin.ModelAdmin):
list_display = ('__str__', 'succeeded', 'return_code', 'coverage')
|
# -*- coding: utf8 -*-
from django.contrib import admin
from django.template.defaultfilters import pluralize
from .models import Build, BuildResult, Project
class BuildResultInline(admin.StackedInline):
model = BuildResult
readonly_fields = ('result_log', 'succeeded', 'return_code')
extra = 0
max_num = 0
class BuildInline(admin.TabularInline):
model = Build
readonly_fields = ('build_number', 'branch', 'color', 'pull_request_id', 'sha')
extra = 0
max_num = 0
@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
list_display = ('__str__', 'git_repository', 'average_time', 'last_build_number')
inlines = [BuildInline]
list_filter = ['owner']
@admin.register(Build)
class BuildAdmin(admin.ModelAdmin):
list_display = ('build_number', 'project', 'branch', 'pull_request_id', 'sha', 'color')
inlines = [BuildResultInline]
list_filter = ['project']
actions = ['restart_build']
def restart_build(self, request, queryset):
for build in queryset:
build.start()
self.message_user(
request,
'{} build{} was restarted'.format(len(queryset), pluralize(len(queryset)))
)
restart_build.short_description = 'Restart selected builds'
@admin.register(BuildResult)
class BuildResultAdmin(admin.ModelAdmin):
list_display = ('__str__', 'succeeded', 'return_code', 'coverage')
|
Add restart_build action to BuildAdmin
|
Add restart_build action to BuildAdmin
|
Python
|
mit
|
frigg/frigg-hq,frigg/frigg-hq,frigg/frigg-hq
|
b1b1392d2f268a5c74fd21c826a3ea6387567cab
|
froide/bounce/apps.py
|
froide/bounce/apps.py
|
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class BounceConfig(AppConfig):
name = 'froide.bounce'
verbose_name = _('Bounce')
def ready(self):
from froide.account import account_canceled
account_canceled.connect(cancel_user)
def cancel_user(sender, user=None, **kwargs):
from .models import Bounce
if user is None:
return
Bounce.objects.filter(user=user).delete()
|
import json
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class BounceConfig(AppConfig):
name = 'froide.bounce'
verbose_name = _('Bounce')
def ready(self):
from froide.account import account_canceled
from froide.account.export import registry
account_canceled.connect(cancel_user)
registry.register(export_user_data)
def cancel_user(sender, user=None, **kwargs):
from .models import Bounce
if user is None:
return
Bounce.objects.filter(user=user).delete()
def export_user_data(user):
from .models import Bounce
bounces = Bounce.objects.filter(user=user)
if not bounces:
return
yield ('bounces.json', json.dumps([
{
'last_update': (
b.last_update.isoformat() if b.last_update else None
),
'bounces': b.bounces,
'email': b.email,
}
for b in bounces]).encode('utf-8')
)
|
Add user data export for bounce handling
|
Add user data export for bounce handling
|
Python
|
mit
|
fin/froide,fin/froide,stefanw/froide,stefanw/froide,fin/froide,stefanw/froide,stefanw/froide,fin/froide,stefanw/froide
|
f9d7f69d7e8ae1dceaba09ac4412438076261744
|
tests/test_completion.py
|
tests/test_completion.py
|
import os
import subprocess
import sys
from pathlib import Path
import typer
from typer.testing import CliRunner
from first_steps import tutorial001 as mod
runner = CliRunner()
app = typer.Typer()
app.command()(mod.main)
def test_show_completion():
result = subprocess.run(
[
"bash",
"-c",
f"{sys.executable} -m coverage run {mod.__file__} --show-completion",
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env={**os.environ, "SHELL": "/bin/bash"},
)
assert "_TUTORIAL001.PY_COMPLETE=complete-bash" in result.stdout
def test_install_completion():
bash_completion_path: Path = Path.home() / ".bash_completion"
text = ""
if bash_completion_path.is_file():
text = bash_completion_path.read_text()
result = subprocess.run(
[
"bash",
"-c",
f"{sys.executable} -m coverage run {mod.__file__} --install-completion",
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env={**os.environ, "SHELL": "/bin/bash"},
)
new_text = bash_completion_path.read_text()
assert "_TUTORIAL001.PY_COMPLETE=complete-bash" in new_text
bash_completion_path.write_text(text)
|
import os
import subprocess
import sys
from pathlib import Path
import typer
from typer.testing import CliRunner
from first_steps import tutorial001 as mod
runner = CliRunner()
app = typer.Typer()
app.command()(mod.main)
def test_show_completion():
result = subprocess.run(
[
"bash",
"-c",
f"{sys.executable} -m coverage run {mod.__file__} --show-completion",
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env={**os.environ, "SHELL": "/bin/bash"},
)
assert "_TUTORIAL001.PY_COMPLETE=complete-bash" in result.stdout
def test_install_completion():
bash_completion_path: Path = Path.home() / ".bash_completion"
text = ""
if bash_completion_path.is_file():
text = bash_completion_path.read_text()
result = subprocess.run(
[
"bash",
"-c",
f"{sys.executable} -m coverage run {mod.__file__} --install-completion",
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env={**os.environ, "SHELL": "/bin/bash"},
)
new_text = bash_completion_path.read_text()
bash_completion_path.write_text(text)
assert "_TUTORIAL001.PY_COMPLETE=complete-bash" in new_text
assert "completion installed in" in result.stdout
assert "Completion will take effect once you restart the terminal." in result.stdout
|
Update completion tests, checking for printed message
|
:white_check_mark: Update completion tests, checking for printed message
|
Python
|
mit
|
tiangolo/typer,tiangolo/typer
|
83ea38ee5616b1637cc2d983d4518d83793c7b72
|
lint/events.py
|
lint/events.py
|
from collections import defaultdict
import traceback
LINT_START = 'LINT_START'
LINT_RESULT = 'LINT_RESULT'
LINT_END = 'LINT_END'
listeners = defaultdict(set)
def subscribe(topic, fn):
listeners[topic].add(fn)
def unsubscribe(topic, fn):
try:
listeners[topic].remove(fn)
except KeyError:
pass
def broadcast(topic, message=None):
payload = message.copy() or {}
for fn in listeners.get(topic, []):
try:
fn(**payload)
except Exception:
traceback.print_exc()
map_fn_to_topic = {}
def on(topic):
def inner(fn):
subscribe(topic, fn)
map_fn_to_topic[fn] = topic
return fn
return inner
def off(fn):
topic = map_fn_to_topic.get(fn, None)
if topic:
unsubscribe(topic, fn)
|
from collections import defaultdict
import traceback
LINT_START = 'LINT_START' # (buffer_id)
LINT_RESULT = 'LINT_RESULT' # (buffer_id, linter_name, errors)
LINT_END = 'LINT_END' # (buffer_id)
listeners = defaultdict(set)
def subscribe(topic, fn):
listeners[topic].add(fn)
def unsubscribe(topic, fn):
try:
listeners[topic].remove(fn)
except KeyError:
pass
def broadcast(topic, message=None):
payload = message.copy() or {}
for fn in listeners.get(topic, []):
try:
fn(**payload)
except Exception:
traceback.print_exc()
map_fn_to_topic = {}
def on(topic):
def inner(fn):
subscribe(topic, fn)
map_fn_to_topic[fn] = topic
return fn
return inner
def off(fn):
topic = map_fn_to_topic.get(fn, None)
if topic:
unsubscribe(topic, fn)
|
Add very brief comments about the event types
|
Add very brief comments about the event types
|
Python
|
mit
|
SublimeLinter/SublimeLinter3,SublimeLinter/SublimeLinter3
|
d572c7228d4c4fb84530b8a33df7bd4596e01d8b
|
app/billing/billing_schemas.py
|
app/billing/billing_schemas.py
|
from datetime import datetime
create_or_update_free_sms_fragment_limit_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "POST annual billing schema",
"type": "object",
"title": "Create",
"properties": {
"free_sms_fragment_limit": {"type": "integer", "minimum": 1},
},
"required": ["free_sms_fragment_limit"]
}
def serialize_ft_billing_remove_emails(data):
results = []
billed_notifications = [x for x in data if x.notification_type != 'email']
for notification in billed_notifications:
json_result = {
"month": (datetime.strftime(notification.month, "%B")),
"notification_type": notification.notification_type,
"billing_units": notification.billable_units,
"rate": float(notification.rate),
"postage": notification.postage,
}
results.append(json_result)
return results
def serialize_ft_billing_yearly_totals(data):
yearly_totals = []
for total in data:
json_result = {
"notification_type": total.notification_type,
"billing_units": total.billable_units,
"rate": float(total.rate),
"letter_total": float(total.billable_units * total.rate) if total.notification_type == 'letter' else 0
}
yearly_totals.append(json_result)
return yearly_totals
|
from datetime import datetime
create_or_update_free_sms_fragment_limit_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "POST annual billing schema",
"type": "object",
"title": "Create",
"properties": {
"free_sms_fragment_limit": {"type": "integer", "minimum": 0},
},
"required": ["free_sms_fragment_limit"]
}
def serialize_ft_billing_remove_emails(data):
results = []
billed_notifications = [x for x in data if x.notification_type != 'email']
for notification in billed_notifications:
json_result = {
"month": (datetime.strftime(notification.month, "%B")),
"notification_type": notification.notification_type,
"billing_units": notification.billable_units,
"rate": float(notification.rate),
"postage": notification.postage,
}
results.append(json_result)
return results
def serialize_ft_billing_yearly_totals(data):
yearly_totals = []
for total in data:
json_result = {
"notification_type": total.notification_type,
"billing_units": total.billable_units,
"rate": float(total.rate),
"letter_total": float(total.billable_units * total.rate) if total.notification_type == 'letter' else 0
}
yearly_totals.append(json_result)
return yearly_totals
|
Allow the free SMS fragment limit to be 0
|
Allow the free SMS fragment limit to be 0
This updates the schema so that the free allowance has a minimum value
of 0 instead of 1.
|
Python
|
mit
|
alphagov/notifications-api,alphagov/notifications-api
|
9b93ffa1662e99888c430e6deab01bd215055253
|
examples/analog_watch.py
|
examples/analog_watch.py
|
from microbit import *
hands = Image.ALL_CLOCKS
#A centre dot of brightness 2.
ticker_image = Image("2\n").crop(-2,-2,5,5)
#Adjust these to taste
MINUTE_BRIGHT = 0.1111
HOUR_BRIGHT = 0.55555
#Generate hands for 5 minute intervals
def fiveticks():
fivemins = 0
hours = 0
while True:
yield hands[fivemins]*MINUTE_BRIGHT + hands[hours]*HOUR_BRIGHT
fivemins = (fivemins+1)%12
hours = (hours + (fivemins == 0))%12
#Generate hands with ticker superimposed for 1 minute intervals.
def ticks():
on = True
for face in fiveticks():
for i in range(5):
if on:
yield face + ticker_image
else:
yield face - ticker_image
on = not on
#Run a clock speeded up 60 times, so we can watch the animation.
display.animate(ticks(), 1000)
|
from microbit import *
hands = Image.ALL_CLOCKS
#A centre dot of brightness 2.
ticker_image = Image("2\n").crop(-2,-2,5,5)
#Adjust these to taste
MINUTE_BRIGHT = 0.1111
HOUR_BRIGHT = 0.55555
#Generate hands for 5 minute intervals
def fiveticks():
fivemins = 0
hours = 0
while True:
yield hands[fivemins]*MINUTE_BRIGHT + hands[hours]*HOUR_BRIGHT
fivemins = (fivemins+1)%12
hours = (hours + (fivemins == 0))%12
#Generate hands with ticker superimposed for 1 minute intervals.
def ticks():
on = True
for face in fiveticks():
for i in range(5):
if on:
yield face + ticker_image
else:
yield face - ticker_image
on = not on
#Run a clock speeded up 60 times, so we can watch the animation.
display.show(ticks(), 1000)
|
Use display.show instead of display.animate
|
Use display.show instead of display.animate
|
Python
|
mit
|
JoeGlancy/micropython,JoeGlancy/micropython,JoeGlancy/micropython
|
4286d2d6a685571c70a8f48c3cd6802d13c4acef
|
braid/postgres.py
|
braid/postgres.py
|
from fabric.api import sudo, quiet
from braid import package
from pipes import quote
def install():
package.install(['postgresql-9.1', 'postgresql-server-dev-9.1'])
def _runQuery(query):
with quiet():
return sudo('psql --no-align --no-readline --no-password --quiet '
'--tuples-only -c {}'.format(quote(query)),
user='postgres', pty=False, combine_stderr=False)
def _dbExists(name):
res = _runQuery("select count(*) from pg_database "
"where datname = '{}';".format(name))
return res == '1'
def _userExists(name):
res = _runQuery("select count(*) from pg_user "
"where usename = '{}';".format(name))
return res == '1'
def createUser(name):
if not _userExists(name):
sudo('createuser -D -R -S {}'.format(name), user='postgres', pty=False)
def createDb(name, owner):
if not _dbExists(name):
sudo('createdb -O {} {}'.format(owner, name), user='postgres',
pty=False)
def grantRead(user, database):
"""
Grant read permissions to C{user} to all tables in C{database}.
"""
def grantReadWrite(user, database):
"""
Grant read and write permissions to C{user} to all tables in C{database}.
"""
|
from fabric.api import sudo, hide
from braid import package
from pipes import quote
def install():
package.install(['postgresql-9.1', 'postgresql-server-dev-9.1'])
def _runQuery(query):
with hide('running', 'output'):
return sudo('psql --no-align --no-readline --no-password --quiet '
'--tuples-only -c {}'.format(quote(query)),
user='postgres', pty=False, combine_stderr=False)
def _dbExists(name):
res = _runQuery("select count(*) from pg_database "
"where datname = '{}';".format(name))
return res == '1'
def _userExists(name):
res = _runQuery("select count(*) from pg_user "
"where usename = '{}';".format(name))
return res == '1'
def createUser(name):
if not _userExists(name):
sudo('createuser -D -R -S {}'.format(name), user='postgres', pty=False)
def createDb(name, owner):
if not _dbExists(name):
sudo('createdb -O {} {}'.format(owner, name), user='postgres',
pty=False)
def grantRead(user, database):
"""
Grant read permissions to C{user} to all tables in C{database}.
"""
def grantReadWrite(user, database):
"""
Grant read and write permissions to C{user} to all tables in C{database}.
"""
|
Make _runQuery to fail if the query fails, but still hide the execution messages
|
Make _runQuery to fail if the query fails, but still hide the execution messages
|
Python
|
mit
|
alex/braid,alex/braid
|
92d253fdce108162ab2ce05dd38da971ca42293d
|
keystone/contrib/kds/common/service.py
|
keystone/contrib/kds/common/service.py
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from keystone.openstack.common import log
CONF = cfg.CONF
API_SERVICE_OPTS = [
cfg.StrOpt('bind_ip',
default='0.0.0.0',
help='IP for the server to bind to'),
cfg.IntOpt('port',
default=9109,
help='The port for the server'),
]
CONF.register_opts(API_SERVICE_OPTS)
def parse_args(args, default_config_files=None):
CONF(args=args[1:],
project='kds',
default_config_files=default_config_files)
def prepare_service(argv=[]):
cfg.set_defaults(log.log_opts,
default_log_levels=['sqlalchemy=WARN',
'eventlet.wsgi.server=WARN'
])
parse_args(argv)
log.setup('kds')
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from keystone.openstack.common import log
CONF = cfg.CONF
FILE_OPTIONS = {
None: [
cfg.StrOpt('bind_ip',
default='0.0.0.0',
help='IP for the server to bind to'),
cfg.IntOpt('port',
default=9109,
help='The port for the server')]}
def configure(conf=None):
if conf is None:
conf = CONF
for group in FILE_OPTIONS:
conf.register_opts(FILE_OPTIONS[group], group=group)
def parse_args(args, default_config_files=None):
CONF(args=args[1:],
project='kds',
default_config_files=default_config_files)
def prepare_service(argv=[]):
cfg.set_defaults(log.log_opts,
default_log_levels=['sqlalchemy=WARN',
'eventlet.wsgi.server=WARN'
])
parse_args(argv)
log.setup('kds')
configure()
|
Restructure KDS options to be more like Keystone's options
|
Restructure KDS options to be more like Keystone's options
Restructure the KDS options to be more closely aligned with the way
Keystone options work and allowing movement towards not registering
the options on import. This will also prevent KDS options from
appearing in the Keystone auto-generated sample config.
Change-Id: I073aa58ff3132e2714478f54c88c3a8200ff47da
|
Python
|
apache-2.0
|
rushiagr/keystone,jumpstarter-io/keystone,reeshupatel/demo,dstanek/keystone,idjaw/keystone,jonnary/keystone,vivekdhayaal/keystone,MaheshIBM/keystone,klmitch/keystone,rajalokan/keystone,rajalokan/keystone,nuxeh/keystone,ging/keystone,rushiagr/keystone,takeshineshiro/keystone,ilay09/keystone,nuxeh/keystone,roopali8/keystone,JioCloud/keystone,himanshu-setia/keystone,blueboxgroup/keystone,dims/keystone,vivekdhayaal/keystone,jamielennox/keystone,maestro-hybrid-cloud/keystone,idjaw/keystone,ilay09/keystone,maestro-hybrid-cloud/keystone,ajayaa/keystone,mahak/keystone,mahak/keystone,blueboxgroup/keystone,jamielennox/keystone,cernops/keystone,openstack/keystone,ging/keystone,rushiagr/keystone,rodrigods/keystone,JioCloud/keystone,openstack/keystone,jonnary/keystone,klmitch/keystone,reeshupatel/demo,takeshineshiro/keystone,dstanek/keystone,MaheshIBM/keystone,UTSA-ICS/keystone-kerberos,ajayaa/keystone,dstanek/keystone,rodrigods/keystone,nuxeh/keystone,vivekdhayaal/keystone,rajalokan/keystone,promptworks/keystone,cernops/keystone,jumpstarter-io/keystone,openstack/keystone,mahak/keystone,himanshu-setia/keystone,roopali8/keystone,ilay09/keystone,dims/keystone,reeshupatel/demo,promptworks/keystone,jumpstarter-io/keystone,UTSA-ICS/keystone-kerberos,promptworks/keystone
|
eaa13f9005a8aaf8c748a98de697b03eee9e675b
|
salt/client/netapi.py
|
salt/client/netapi.py
|
# encoding: utf-8
'''
The main entry point for salt-api
'''
from __future__ import absolute_import
# Import python libs
import logging
# Import salt-api libs
import salt.loader
import salt.utils.process
logger = logging.getLogger(__name__)
class NetapiClient(object):
'''
Start each netapi module that is configured to run
'''
def __init__(self, opts):
self.opts = opts
self.process_manager = salt.utils.process.ProcessManager()
self.netapi = salt.loader.netapi(self.opts)
def run(self):
'''
Load and start all available api modules
'''
for fun in self.netapi:
if fun.endswith('.start'):
logger.info('Starting {0} netapi module'.format(fun))
self.process_manager.add_process(self.netapi[fun])
self.process_manager.run()
|
# encoding: utf-8
'''
The main entry point for salt-api
'''
from __future__ import absolute_import
# Import python libs
import logging
# Import salt-api libs
import salt.loader
import salt.utils.process
logger = logging.getLogger(__name__)
class NetapiClient(object):
'''
Start each netapi module that is configured to run
'''
def __init__(self, opts):
self.opts = opts
self.process_manager = salt.utils.process.ProcessManager()
self.netapi = salt.loader.netapi(self.opts)
def run(self):
'''
Load and start all available api modules
'''
if not len(self.netapi):
logger.error("Did not find any netapi configurations, nothing to start")
for fun in self.netapi:
if fun.endswith('.start'):
logger.info('Starting {0} netapi module'.format(fun))
self.process_manager.add_process(self.netapi[fun])
self.process_manager.run()
|
Add log error if we run salt-api w/ no config
|
Add log error if we run salt-api w/ no config
Currently, the salt-api script will exit with no error or hint of why it
failed if there is no netapi module configured. Added a short line if
we find no api modules to start, warning the user that the config may be
missing.
Fixes #28240
|
Python
|
apache-2.0
|
saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt
|
917c2701f25f15b0d39a4dd8f93254b75aa058dd
|
script/release/release/pypi.py
|
script/release/release/pypi.py
|
from __future__ import absolute_import
from __future__ import unicode_literals
from configparser import Error
from requests.exceptions import HTTPError
from twine.commands.upload import main as twine_upload
from twine.utils import get_config
from .utils import ScriptError
def pypi_upload(args):
print('Uploading to PyPi')
try:
rel = args.release.replace('-rc', 'rc')
twine_upload([
'dist/docker_compose-{}*.whl'.format(rel),
'dist/docker-compose-{}*.tar.gz'.format(rel)
])
except HTTPError as e:
if e.response.status_code == 400 and 'File already exists' in e.message:
if not args.finalize_resume:
raise ScriptError(
'Package already uploaded on PyPi.'
)
print('Skipping PyPi upload - package already uploaded')
else:
raise ScriptError('Unexpected HTTP error uploading package to PyPi: {}'.format(e))
def check_pypirc():
try:
config = get_config()
except Error as e:
raise ScriptError('Failed to parse .pypirc file: {}'.format(e))
if config is None:
raise ScriptError('Failed to parse .pypirc file')
if 'pypi' not in config:
raise ScriptError('Missing [pypi] section in .pypirc file')
if not (config['pypi'].get('username') and config['pypi'].get('password')):
raise ScriptError('Missing login/password pair for pypi repo')
|
from __future__ import absolute_import
from __future__ import unicode_literals
from configparser import Error
from requests.exceptions import HTTPError
from twine.commands.upload import main as twine_upload
from twine.utils import get_config
from .utils import ScriptError
def pypi_upload(args):
print('Uploading to PyPi')
try:
rel = args.release.replace('-rc', 'rc')
twine_upload([
'dist/docker_compose-{}*.whl'.format(rel),
'dist/docker-compose-{}*.tar.gz'.format(rel)
])
except HTTPError as e:
if e.response.status_code == 400 and 'File already exists' in str(e):
if not args.finalize_resume:
raise ScriptError(
'Package already uploaded on PyPi.'
)
print('Skipping PyPi upload - package already uploaded')
else:
raise ScriptError('Unexpected HTTP error uploading package to PyPi: {}'.format(e))
def check_pypirc():
try:
config = get_config()
except Error as e:
raise ScriptError('Failed to parse .pypirc file: {}'.format(e))
if config is None:
raise ScriptError('Failed to parse .pypirc file')
if 'pypi' not in config:
raise ScriptError('Missing [pypi] section in .pypirc file')
if not (config['pypi'].get('username') and config['pypi'].get('password')):
raise ScriptError('Missing login/password pair for pypi repo')
|
Fix script for release file already present case
|
Fix script for release file already present case
This avoids a:
"AttributeError: 'HTTPError' object has no attribute 'message'"
Signed-off-by: Ulysses Souza <[email protected]>
|
Python
|
apache-2.0
|
thaJeztah/compose,vdemeester/compose,vdemeester/compose,thaJeztah/compose
|
0f1ed52e7525ea5f41d63642bca1eaeb9d5af8ba
|
emission/core/wrapper/labelprediction.py
|
emission/core/wrapper/labelprediction.py
|
# Based on modeprediction.py
import emission.core.wrapper.wrapperbase as ecwb
class Labelprediction(ecwb.WrapperBase):
props = {"trip_id": ecwb.WrapperBase.Access.WORM, # the trip that this is part of
"prediction": ecwb.WrapperBase.Access.WORM, # What we predict
"start_ts": ecwb.WrapperBase.Access.WORM, # start time for the prediction, so that it can be captured in time-based queries, e.g. to reset the pipeline
"end_ts": ecwb.WrapperBase.Access.WORM, # end time for the prediction, so that it can be captured in time-based queries, e.g. to reset the pipeline
}
enums = {}
geojson = {}
local_dates = {}
def _populateDependencies(self):
pass
|
# Based on modeprediction.py
import emission.core.wrapper.wrapperbase as ecwb
# The "prediction" data structure is a list of label possibilities, each one consisting of a set of labels and a probability:
# [
# {"labels": {"labeltype1": "labelvalue1", "labeltype2": "labelvalue2"}, "p": 0.61},
# {"labels": {"labeltype1": "labelvalue3", "labeltype2": "labelvalue4"}, "p": 0.27},
# ...
# ]
class Labelprediction(ecwb.WrapperBase):
props = {"trip_id": ecwb.WrapperBase.Access.WORM, # the trip that this is part of
"prediction": ecwb.WrapperBase.Access.WORM, # What we predict -- see above
"start_ts": ecwb.WrapperBase.Access.WORM, # start time for the prediction, so that it can be captured in time-based queries, e.g. to reset the pipeline
"end_ts": ecwb.WrapperBase.Access.WORM, # end time for the prediction, so that it can be captured in time-based queries, e.g. to reset the pipeline
}
enums = {}
geojson = {}
local_dates = {}
def _populateDependencies(self):
pass
|
Add comments explaining prediction data structure
|
Add comments explaining prediction data structure
|
Python
|
bsd-3-clause
|
shankari/e-mission-server,shankari/e-mission-server,shankari/e-mission-server,shankari/e-mission-server,e-mission/e-mission-server,e-mission/e-mission-server,e-mission/e-mission-server,e-mission/e-mission-server
|
3e614788b179fa3549098870c5ba9ca0ce4a35a1
|
src/euth/setup.py
|
src/euth/setup.py
|
"""Adhocracy frontend customization package."""
import os
import version
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
requires = ['adhocracy_frontend',
'adhocracy_kit',
]
test_requires = ['adhocracy_frontend[test]',
'adhocracy_kit[test]',
]
debug_requires = ['adhocracy_frontend[debug]',
'adhocracy_kit[debug]',
]
setup(name='euth',
version=version.get_git_version(),
description='Adhocracy meta package for backend/frontend customization.',
long_description=README + '\n\n' + CHANGES,
classifiers=["Programming Language :: Python",
"Framework :: Pylons",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='',
author_email='',
url='',
keywords='web pyramid pylons adhocracy',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires,
tests_require=requires,
extras_require={'test': test_requires,
'debug': debug_requires},
entry_points="""\
[paste.app_factory]
main = euth:main
""",
)
|
"""Adhocracy frontend customization package."""
import os
import version
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
requires = ['adhocracy_frontend',
'adhocracy_euth',
]
test_requires = ['adhocracy_frontend[test]',
'adhocracy_euth[test]',
]
debug_requires = ['adhocracy_frontend[debug]',
'adhocracy_euth[debug]',
]
setup(name='euth',
version=version.get_git_version(),
description='Adhocracy meta package for backend/frontend customization.',
long_description=README + '\n\n' + CHANGES,
classifiers=["Programming Language :: Python",
"Framework :: Pylons",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='',
author_email='',
url='',
keywords='web pyramid pylons adhocracy',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires,
tests_require=requires,
extras_require={'test': test_requires,
'debug': debug_requires},
entry_points="""\
[paste.app_factory]
main = euth:main
""",
)
|
Remove old dependency to kit from euth frontend
|
Remove old dependency to kit from euth frontend
|
Python
|
agpl-3.0
|
liqd/adhocracy3.mercator,liqd/adhocracy3.mercator,liqd/adhocracy3.mercator,liqd/adhocracy3.mercator,liqd/adhocracy3.mercator,liqd/adhocracy3.mercator,liqd/adhocracy3.mercator
|
841289e7092a5e4bf485ef525f358aa3a58f7fb9
|
meta-iotqa/lib/oeqa/runtime/sanity/comm_btcheck.py
|
meta-iotqa/lib/oeqa/runtime/sanity/comm_btcheck.py
|
import time
from oeqa.oetest import oeRuntimeTest
from oeqa.utils.decorators import tag
@tag(TestType="FVT", FeatureID="IOTOS-453")
class CommBluetoothTest(oeRuntimeTest):
"""
@class CommBluetoothTest
"""
log = ""
def setUp(self):
self.target.run('connmanctl enable bluetooth')
time.sleep(8)
def tearDown(self):
self.target.run('connmanctl disable bluetooth')
def target_collect_info(self, cmd):
"""
@fn target_collect_info
@param self
@param cmd
@return
"""
(status, output) = self.target.run(cmd)
self.log = self.log + "\n\n[Debug] Command output --- %s: \n" % cmd
self.log = self.log + output
'''Bluetooth device check'''
def test_comm_btcheck(self):
'''check bluetooth device
@fn test_comm_btcheck
@param self
@return
'''
# un-block software rfkill lock
self.target.run('rfkill unblock all')
# This is special for edison platform
# Collect system information as log
self.target_collect_info("ifconfig")
self.target_collect_info("hciconfig")
self.target_collect_info("lsmod")
# Detect BT device status
(status, output) = self.target.run('hciconfig hci0')
##
# TESTPOINT: #1, test_comm_btcheck
#
self.assertEqual(status, 0, msg="Error messages: %s" % self.log)
|
import time
from oeqa.oetest import oeRuntimeTest
from oeqa.utils.decorators import tag
@tag(TestType="FVT", FeatureID="IOTOS-453")
class CommBluetoothTest(oeRuntimeTest):
"""
@class CommBluetoothTest
"""
log = ""
def setUp(self):
self.target.run('connmanctl enable bluetooth')
time.sleep(8)
def tearDown(self):
self.target.run('connmanctl disable bluetooth')
def target_collect_info(self, cmd):
"""
@fn target_collect_info
@param self
@param cmd
@return
"""
(status, output) = self.target.run(cmd)
self.log = self.log + "\n\n[Debug] Command output --- %s: \n" % cmd
self.log = self.log + output
'''Bluetooth device check'''
def test_comm_btcheck(self):
'''check bluetooth device
@fn test_comm_btcheck
@param self
@return
'''
# Collect system information as log
self.target_collect_info("ifconfig")
self.target_collect_info("hciconfig")
self.target_collect_info("lsmod")
# Detect BT device status
(status, output) = self.target.run('hciconfig hci0')
##
# TESTPOINT: #1, test_comm_btcheck
#
self.assertEqual(status, 0, msg="Error messages: %s" % self.log)
|
Remove Edison specific command from Bluetooth test
|
meta-iotqa: Remove Edison specific command from Bluetooth test
The platform isn't supported anymore and the command isn't needed with
current devices.
Signed-off-by: Simo Kuusela <[email protected]>
|
Python
|
mit
|
YinThong/intel-iot-refkit,mythi/intel-iot-refkit,mythi/intel-iot-refkit,klihub/intel-iot-refkit,jairglez/intel-iot-refkit,klihub/intel-iot-refkit,intel/intel-iot-refkit,YinThong/intel-iot-refkit,jairglez/intel-iot-refkit,YinThong/intel-iot-refkit,YinThong/intel-iot-refkit,mythi/intel-iot-refkit,intel/intel-iot-refkit,klihub/intel-iot-refkit,klihub/intel-iot-refkit,mythi/intel-iot-refkit,YinThong/intel-iot-refkit,intel/intel-iot-refkit,ipuustin/intel-iot-refkit,ipuustin/intel-iot-refkit,intel/intel-iot-refkit,intel/intel-iot-refkit,jairglez/intel-iot-refkit,intel/intel-iot-refkit,jairglez/intel-iot-refkit,ipuustin/intel-iot-refkit,jairglez/intel-iot-refkit,jairglez/intel-iot-refkit,mythi/intel-iot-refkit,ipuustin/intel-iot-refkit,ipuustin/intel-iot-refkit,mythi/intel-iot-refkit,klihub/intel-iot-refkit,intel/intel-iot-refkit,YinThong/intel-iot-refkit,jairglez/intel-iot-refkit,klihub/intel-iot-refkit,ipuustin/intel-iot-refkit,klihub/intel-iot-refkit,ipuustin/intel-iot-refkit,YinThong/intel-iot-refkit,mythi/intel-iot-refkit
|
4a48be97254f4626eaadf86492d98e0dd640d43d
|
flower/utils/__init__.py
|
flower/utils/__init__.py
|
from __future__ import absolute_import
import uuid
import base64
import os.path
from .. import __version__
def gen_cookie_secret():
return base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes)
def bugreport():
try:
import celery
return 'flower -> %s' % __version__ + celery.bugreport()
except (ImportError, AttributeError):
return 'Unknown Celery version'
def abs_path(path):
path = os.path.expanduser(path)
if not os.path.isabs(path):
cwd = os.environ.get('PWD') or os.getcwd()
path = os.path.join(cwd, path)
return path
|
from __future__ import absolute_import
import uuid
import base64
import os.path
from .. import __version__
def gen_cookie_secret():
return base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes)
def bugreport():
try:
import celery
import tornado
import babel
return 'flower -> flower:%s tornado:%s babel:%s' %\
(__version__, tornado.version, babel.__version__)\
+ celery.bugreport()
except (ImportError, AttributeError):
return 'Unknown Celery version'
def abs_path(path):
path = os.path.expanduser(path)
if not os.path.isabs(path):
cwd = os.environ.get('PWD') or os.getcwd()
path = os.path.join(cwd, path)
return path
|
Include tornado and babel version info in bug report
|
Include tornado and babel version info in bug report
|
Python
|
bsd-3-clause
|
raphaelmerx/flower,ChinaQuants/flower,pj/flower,Lingling7/flower,tellapart/flower,alexmojaki/flower,ucb-bar/bar-crawl-web,Lingling7/flower,ChinaQuants/flower,jzhou77/flower,Lingling7/flower,lucius-feng/flower,lucius-feng/flower,ucb-bar/bar-crawl-web,allengaller/flower,asmodehn/flower,allengaller/flower,lucius-feng/flower,marrybird/flower,pygeek/flower,ucb-bar/bar-crawl-web,ChinaQuants/flower,pj/flower,pygeek/flower,alexmojaki/flower,jzhou77/flower,barseghyanartur/flower,jzhou77/flower,marrybird/flower,asmodehn/flower,pj/flower,pygeek/flower,getupcloud/flower,marrybird/flower,barseghyanartur/flower,alexmojaki/flower,getupcloud/flower,getupcloud/flower,tellapart/flower,asmodehn/flower,raphaelmerx/flower,tellapart/flower,raphaelmerx/flower,allengaller/flower,barseghyanartur/flower
|
98e574061dc430b1cad6c9bbef5b55aa92803206
|
command_line/rebin_images.py
|
command_line/rebin_images.py
|
# LIBTBX_SET_DISPATCHER_NAME dev.dials.rebin_images
from __future__ import division
def rebin_images(in_template, out_template, start, end):
from dials.util.rebin_images import main
in_images = [in_template % j for j in range(start, end + 1)]
out_images = [out_template % j for j in range(start, end + 1)]
main(in_images, out_images)
if __name__ == '__main__':
import sys
if len(sys.argv) != 5:
raise RuntimeError, '%s in_\%04d.cbf out_\%04d.cbf start end' % \
sys.argv[0]
in_template = sys.argv[1]
out_template = sys.argv[2]
start = int(sys.argv[3])
end = int(sys.argv[4])
rebin_images(in_template, out_template, start, end)
|
# LIBTBX_SET_DISPATCHER_NAME dev.dials.rebin_images
from __future__ import division
def rebin_images(in_template, out_template, start, end):
from dials.util.rebin_images import main
in_images = [in_template % j for j in range(start, end + 1)]
out_images = [out_template % j for j in range(start, end + 1)]
main(in_images, out_images)
return
if __name__ == '__main__':
import sys
if len(sys.argv) != 5:
raise RuntimeError, '%s in_\%04d.cbf out_\%04d.cbf start end' % \
sys.argv[0]
in_template = sys.argv[1]
out_template = sys.argv[2]
start = int(sys.argv[3])
end = int(sys.argv[4])
rebin_images(in_template, out_template, start, end)
|
Check email update on branch for YT only
|
Check email update on branch for YT only
|
Python
|
bsd-3-clause
|
dials/dials,dials/dials,dials/dials,dials/dials,dials/dials
|
4e483d6443e809f9e7e1a59c3fe959fd5f42f938
|
simple-cipher/simple_cipher.py
|
simple-cipher/simple_cipher.py
|
import math
import secrets
from string import ascii_lowercase
class Cipher(object):
def __init__(self, key=None):
if not key:
key = Cipher._random_key()
if not key.isalpha() or not key.islower():
raise ValueError("Key must consist only of lowercase letters")
self.key = key
self._key = [ord(k)-97 for k in key]
def encode(self, s):
key = self._key * math.ceil(len(s)/len(self._key))
chars = [c for c in s.lower() if c in ascii_lowercase]
return "".join(Cipher._shift(c, k) for c, k in zip(chars, key))
def decode(self, s):
key = self._key * math.ceil(len(s)/len(self._key))
chars = [c for c in s.lower() if c in ascii_lowercase]
return "".join(Cipher._shift(c, -k) for c, k in zip(chars, key))
@staticmethod
def _shift(char, key):
return chr(97 + ((ord(char) - 97 + key) % 26))
@staticmethod
def _random_key(length=256):
return "".join(secrets.choice(ascii_lowercase) for _ in range(length))
class Caesar(Cipher):
def __init__(self):
Cipher.__init__(self, "d")
|
import math
import secrets
from string import ascii_lowercase
class Cipher(object):
def __init__(self, key=None):
if not key:
key = self._random_key()
if not key.isalpha() or not key.islower():
raise ValueError("Key must consist only of lowercase letters")
self.key = key
self._key = [ord(k)-97 for k in key]
def encode(self, s):
key = self._key * math.ceil(len(s)/len(self._key))
chars = [c for c in s.lower() if c in ascii_lowercase]
return "".join(self._shift(c, k) for c, k in zip(chars, key))
def decode(self, s):
key = self._key * math.ceil(len(s)/len(self._key))
chars = [c for c in s.lower() if c in ascii_lowercase]
return "".join(self._shift(c, -k) for c, k in zip(chars, key))
@staticmethod
def _shift(char, key):
return chr(97 + ((ord(char) - 97 + key) % 26))
@staticmethod
def _random_key(length=256):
return "".join(secrets.choice(ascii_lowercase) for _ in range(length))
class Caesar(Cipher):
def __init__(self):
super().__init__("d")
|
Use super() and self within the Cipher and Caesar classes
|
Use super() and self within the Cipher and Caesar classes
|
Python
|
agpl-3.0
|
CubicComet/exercism-python-solutions
|
5ca96beb26dd2ab5285a57f5cade6f01160df368
|
joequery/blog/posts/code/notes-on-dynamic-programming-part-1/meta.py
|
joequery/blog/posts/code/notes-on-dynamic-programming-part-1/meta.py
|
title="Notes on dynamic programming - part 1"
description="""
Part 1 of extensive notes discussing the fundamentals of dynamic programming.
Examples in these notes include the Fibonacci sequence and Warshall's
algorithm. Pseudocode and Python implementations of the algorithms are
provided.
"""
time="2012-12-10 Mon 02:28 AM"
# related=[("Some article", "its/url")]
|
title="Notes on dynamic programming - part 1"
description="""
Part 1 of extensive notes discussing the fundamentals of dynamic programming.
Examples in these notes include the Fibonacci sequence, the Binomial Formula,
and Warshall's algorithm. Python implementations of the algorithms are
provided.
"""
time="2012-12-10 Mon 02:48 AM"
# related=[("Some article", "its/url")]
|
Update description and timestamp for dynamic programming part 1
|
Update description and timestamp for dynamic programming part 1
|
Python
|
mit
|
joequery/joequery.me,joequery/joequery.me,joequery/joequery.me,joequery/joequery.me
|
c04b9813b5d6d3f8bc8eaa7be2d49d32f150aaf2
|
tests/test_authentication.py
|
tests/test_authentication.py
|
import unittest
from flask import json
from api import db
from api.BucketListAPI import app
from instance.config import application_config
class AuthenticationTestCase(unittest.TestCase):
def setUp(self):
app.config.from_object(application_config['TestingEnv'])
self.client = app.test_client()
# Binds the app to current context
with app.app_context():
# Create all tables
db.create_all()
def test_index_route(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 201)
self.assertIn('Welcome Message', response.data.decode())
def tearDown(self):
# Drop all tables
with app.app_context():
# Drop all tables
db.session.remove()
db.drop_all()
if __name__ == '__main__':
unittest.main()
|
import unittest
from flask import json
from api import db
from api.BucketListAPI import app
from instance.config import application_config
class AuthenticationTestCase(unittest.TestCase):
def setUp(self):
app.config.from_object(application_config['TestingEnv'])
self.client = app.test_client()
# Binds the app to current context
with app.app_context():
# Create all tables
db.create_all()
def test_index_route(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 201)
self.assertIn('Welcome Message', response.data.decode())
def test_registration_with_missing_dredentials(self):
"""Should throw error for missing credentials"""
user = json.dumps({
'name': '',
'email': '',
'password': ''
})
response = self.client.post('/auth/register', data=user)
self.assertEqual(response.status_code, 400)
self.assertIn('Missing', response.data.decode())
def tearDown(self):
# Drop all tables
with app.app_context():
# Drop all tables
db.session.remove()
db.drop_all()
if __name__ == '__main__':
unittest.main()
|
Add test for user with missing credentials
|
Add test for user with missing credentials
|
Python
|
mit
|
patlub/BucketListAPI,patlub/BucketListAPI
|
47f1b47f37da4f9a3444a2ac6cc7b7a0affafbf3
|
node_bridge.py
|
node_bridge.py
|
import os
import platform
import subprocess
IS_MACOS = platform.system() == 'Darwin'
IS_WINDOWS = platform.system() == 'Windows'
def node_bridge(data, bin, args=[]):
env = None
startupinfo = None
if IS_MACOS:
# GUI apps on macOS doesn't contain .bashrc/.zshrc set paths
env = os.environ.copy()
env['PATH'] += ':/usr/local/bin'
if IS_WINDOWS:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
try:
p = subprocess.Popen(['node', bin] + args,
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
env=env, startupinfo=startupinfo)
except OSError:
raise Exception('Couldn\'t find Node.js. Make sure it\'s in your $PATH by running `node -v` in your command-line.')
stdout, stderr = p.communicate(input=data.encode('utf-8'))
stdout = stdout.decode('utf-8')
stderr = stderr.decode('utf-8')
if stderr:
raise Exception('Error: %s' % stderr)
else:
return stdout
|
import os
import platform
import subprocess
IS_MACOS = platform.system() == 'Darwin'
IS_WINDOWS = platform.system() == 'Windows'
def node_bridge(data, bin, args=[]):
env = None
startupinfo = None
if IS_MACOS:
# GUI apps on macOS doesn't contain .bashrc/.zshrc set paths
env = os.environ.copy()
env['PATH'] += os.path.expanduser('~/n/bin')
env['PATH'] += ':/usr/local/bin'
if IS_WINDOWS:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
try:
p = subprocess.Popen(['node', bin] + args,
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
env=env, startupinfo=startupinfo)
except OSError:
raise Exception('Couldn\'t find Node.js. Make sure it\'s in your $PATH by running `node -v` in your command-line.')
stdout, stderr = p.communicate(input=data.encode('utf-8'))
stdout = stdout.decode('utf-8')
stderr = stderr.decode('utf-8')
if stderr:
raise Exception('Error: %s' % stderr)
else:
return stdout
|
Add support for `n` Node.js version manager
|
Add support for `n` Node.js version manager
|
Python
|
mit
|
sindresorhus/sublime-autoprefixer,sindresorhus/sublime-autoprefixer,sindresorhus/sublime-autoprefixer
|
c7660db45e0275a685a6cc450fd4341a69c52b92
|
threaded_multihost/fields.py
|
threaded_multihost/fields.py
|
from django.db.models import ForeignKey
from django.contrib.auth.models import User
import threadlocals
class UserField(ForeignKey):
""" UserField
By defaults, foreign key to User; null=True, blank=True
"""
def __init__(self, **kwargs):
kwargs.setdefault('null', True)
kwargs.setdefault('blank', True)
ForeignKey.__init__(self, User, **kwargs)
class CreatorField(UserField):
""" CreatorField
By default, sets editable=False, default=threadlocals.get_current_user
"""
def __init__(self, **kwargs):
kwargs.setdefault('editable', False)
kwargs.setdefault('default', threadlocals.get_current_user)
UserField.__init__(self, **kwargs)
class EditorField(CreatorField):
""" EditorField
By default, sets editable=False, default=threadlocals.get_current_user
Sets value to get_current_user() on each save of the model.
"""
def __init__(self, **kwargs):
super(CreatorField, self).__init__(**kwargs)
def pre_save(self, model_instance, add):
value = threadlocals.get_current_user()
setattr(model_instance, self.name, value)
if value:
value = value.pk
setattr(model_instance, self.attname, value)
return value
|
from django.db.models import ForeignKey
from django.contrib.auth.models import User
import threadlocals
class UserField(ForeignKey):
""" UserField
By defaults, foreign key to User; null=True, blank=True
"""
def __init__(self, **kwargs):
kwargs.setdefault('to', User)
kwargs.setdefault('null', True)
kwargs.setdefault('blank', True)
ForeignKey.__init__(self, **kwargs)
class CreatorField(UserField):
""" CreatorField
By default, sets editable=False, default=threadlocals.get_current_user
"""
def __init__(self, **kwargs):
kwargs.setdefault('editable', False)
kwargs.setdefault('default', threadlocals.get_current_user)
UserField.__init__(self, **kwargs)
class EditorField(CreatorField):
""" EditorField
By default, sets editable=False, default=threadlocals.get_current_user
Sets value to get_current_user() on each save of the model.
"""
def __init__(self, **kwargs):
super(CreatorField, self).__init__(**kwargs)
def pre_save(self, model_instance, add):
value = threadlocals.get_current_user()
setattr(model_instance, self.name, value)
if value:
value = value.pk
setattr(model_instance, self.attname, value)
return value
try:
from south.modelsinspector import add_introspection_rules
except ImportError:
add_introspection_rules = False
if add_introspection_rules:
add_introspection_rules([], [r"^threaded_multihost\.fields\.(User|Creator|Editor)Field"])
|
Patch from chrischambers to enable south migrations.
|
Patch from chrischambers to enable south migrations.
|
Python
|
bsd-3-clause
|
diver-in-sky/django-threaded-multihost
|
305e88780fc2d3638fb3a9f33bfec8d6c295535e
|
feincms/views/base.py
|
feincms/views/base.py
|
from django.contrib.auth.decorators import permission_required
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from feincms.module.page.models import Page
def build_page_response(page, request):
response = page.setup_request(request)
if response is None:
extra_context = request._feincms_extra_context
response = render_to_response(page.template.path, {
'feincms_page': page,
}, context_instance=RequestContext(request, extra_context))
return response
def handler(request, path=None):
"""
This is the default handler for feincms page content.
"""
if path is None:
path = request.path
page = Page.objects.page_for_path_or_404(path)
response = build_page_response(page, request)
page.finalize_response(request, response)
return response
@permission_required('page.change_page')
def preview_handler(request, page_id):
"""
This handler is for previewing site content; it takes a page_id so
the page is uniquely identified and does not care whether the page
is active or expired. To balance that, it requires a logged in user.
"""
page = get_object_or_404(Page, pk=page_id)
return build_page_response(page, request)
|
from django.contrib.auth.decorators import permission_required
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from feincms.module.page.models import Page
def _build_page_response(page, request):
response = page.setup_request(request)
if response is None:
extra_context = request._feincms_extra_context
response = render_to_response(page.template.path, {
'feincms_page': page,
}, context_instance=RequestContext(request, extra_context))
return response
def build_page_response(page, request):
response = _build_page_response(page, request)
page.finalize_response(request, response)
return response
def handler(request, path=None):
"""
This is the default handler for feincms page content.
"""
if path is None:
path = request.path
page = Page.objects.page_for_path_or_404(path)
response = build_page_response(page, request)
return response
@permission_required('page.change_page')
def preview_handler(request, page_id):
"""
This handler is for previewing site content; it takes a page_id so
the page is uniquely identified and does not care whether the page
is active or expired. To balance that, it requires a logged in user.
"""
page = get_object_or_404(Page, pk=page_id)
return _build_page_response(page, request)
|
Make sure we invoke the response processors even for app content.
|
Make sure we invoke the response processors even for app content.
|
Python
|
bsd-3-clause
|
matthiask/feincms2-content,joshuajonah/feincms,nickburlett/feincms,nickburlett/feincms,hgrimelid/feincms,feincms/feincms,mjl/feincms,mjl/feincms,joshuajonah/feincms,pjdelport/feincms,matthiask/django-content-editor,feincms/feincms,matthiask/feincms2-content,matthiask/django-content-editor,hgrimelid/feincms,pjdelport/feincms,michaelkuty/feincms,joshuajonah/feincms,michaelkuty/feincms,mjl/feincms,feincms/feincms,michaelkuty/feincms,joshuajonah/feincms,michaelkuty/feincms,nickburlett/feincms,matthiask/django-content-editor,matthiask/django-content-editor,pjdelport/feincms,hgrimelid/feincms,matthiask/feincms2-content,nickburlett/feincms
|
c7ef639ac9bab4a01e4c8cbafb71bf09d973c355
|
src/adhocracy/lib/auth/shibboleth.py
|
src/adhocracy/lib/auth/shibboleth.py
|
from pylons import config
def get_userbadge_mapping(config=config):
mapping = config.get('adhocracy.shibboleth.userbadge_mapping', u'')
return (line.strip().split(u' ')
for line in mapping.strip().split(u'\n')
if line is not u'')
def _attribute_equals(request, key, value):
"""
exact match
"""
return request.headers.get(key) == value
def _attribute_contains(request, key, value):
"""
contains element
"""
elements = (e.strip() for e in request.headers.get(key).split(','))
return value in elements
def _attribute_contains_substring(request, key, value):
"""
contains substring
"""
return value in request.headers.get(key)
USERBADGE_MAPPERS = {
'attribute_equals': _attribute_equals,
'attribute_contains': _attribute_contains,
'attribute_contains_substring': _attribute_contains_substring,
}
|
from pylons import config
def get_userbadge_mapping(config=config):
mapping = config.get('adhocracy.shibboleth.userbadge_mapping', u'')
return (line.strip().split(u' ')
for line in mapping.strip().split(u'\n')
if line is not u'')
def _attribute_equals(request, key, value):
"""
exact match
"""
return request.headers.get(key) == value
def _attribute_contains(request, key, value):
"""
contains element
"""
elements = (e.strip() for e in request.headers.get(key).split(';'))
return value in elements
def _attribute_contains_substring(request, key, value):
"""
contains substring
"""
return value in request.headers.get(key)
USERBADGE_MAPPERS = {
'attribute_equals': _attribute_equals,
'attribute_contains': _attribute_contains,
'attribute_contains_substring': _attribute_contains_substring,
}
|
Use ; instead of , for Shibboleth multi value fields
|
Use ; instead of , for Shibboleth multi value fields
This corresponds to what mod_shibboleth does.
|
Python
|
agpl-3.0
|
liqd/adhocracy,liqd/adhocracy,phihag/adhocracy,DanielNeugebauer/adhocracy,liqd/adhocracy,alkadis/vcv,phihag/adhocracy,phihag/adhocracy,phihag/adhocracy,SysTheron/adhocracy,alkadis/vcv,DanielNeugebauer/adhocracy,SysTheron/adhocracy,alkadis/vcv,alkadis/vcv,DanielNeugebauer/adhocracy,DanielNeugebauer/adhocracy,liqd/adhocracy,SysTheron/adhocracy,alkadis/vcv,DanielNeugebauer/adhocracy,phihag/adhocracy
|
1702fbc607816544c28a8f2895a82d234226e48b
|
euler/p007.py
|
euler/p007.py
|
"""Solution to Project Euler Problem 7
https://projecteuler.net/problem=7
"""
INDEX = 10001
def compute(index=INDEX):
"""Find the `index`th prime number."""
primes = list()
test_number = 2
while len(primes) < index:
for prime in primes:
if test_number % prime == 0:
break
else:
primes.append(test_number)
test_number += 1
return primes[-1]
|
"""Solution to Project Euler Problem 7
https://projecteuler.net/problem=7
"""
INDEX = 10001
def compute(index=INDEX):
"""Find the `index`th prime number."""
primes = [2]
test_number = 3
while len(primes) < index:
for prime in primes:
if test_number % prime == 0:
break
else:
primes.append(test_number)
test_number += 2
return primes[-1]
|
Check only odd numbers after 2
|
P007: Check only odd numbers after 2
|
Python
|
mit
|
2Cubed/ProjectEuler
|
fc472d043e81c2b5687a0f83dbbdd0dd02b73e35
|
flowtype/commands/exec_flow.py
|
flowtype/commands/exec_flow.py
|
import os
import json
import threading
import subprocess
import sublime
class ExecFlowCommand(threading.Thread):
"""Threaded class used for running flow commands in a different thread.
The subprocess must be threaded so we don't lockup the UI.
"""
def __init__(self, cmd, content):
"""Initialize with the command and the file content to send."""
self.cmd = cmd
self.content = content
self.stdout = None
self.returncode = 0
self.stderr = None
threading.Thread.__init__(self)
def run(self):
"""Execute the command in a subprocess."""
read, write = os.pipe()
os.write(write, str.encode(self.content))
os.close(write)
try:
output = subprocess.check_output(
self.cmd,
shell=sublime.platform() == 'windows',
stdin=read,
stderr=subprocess.STDOUT
)
if type(output) is bytes:
output = output.decode('utf-8')
try:
self.stdout = json.loads(output)
except ValueError:
self.stdout = output
os.close(read)
except subprocess.CalledProcessError as err:
self.stderr = str(err)
self.returncode = 1
|
import os
import json
import threading
import subprocess
import sublime
class ExecFlowCommand(threading.Thread):
"""Threaded class used for running flow commands in a different thread.
The subprocess must be threaded so we don't lockup the UI.
"""
def __init__(self, cmd, content):
"""Initialize with the command and the file content to send."""
self.cmd = cmd
self.content = content
self.stdout = None
self.returncode = 0
self.stderr = None
threading.Thread.__init__(self)
def run(self):
"""Execute the command in a subprocess."""
read, write = os.pipe()
os.write(write, str.encode(self.content))
os.close(write)
try:
output = subprocess.check_output(
self.cmd,
shell=sublime.platform() == 'windows',
stdin=read,
stderr=subprocess.STDOUT
)
if type(output) is bytes:
output = output.decode('utf-8')
try:
self.stdout = json.loads(output)
except ValueError:
self.stdout = output
os.close(read)
except subprocess.CalledProcessError as err:
if type(err.output) is bytes:
output = err.output.decode('utf-8')
else:
output = err.output
self.stderr = str(err) + ': ' + str(output)
self.returncode = 1
|
Add error output to exec error messages
|
Add error output to exec error messages
e.g. for an error like "env: ‘node’: No such file or directory"
the sublime console was only reporting "exited with code 127"
which wasn't very helpful in determining the cause.
|
Python
|
mit
|
Pegase745/sublime-flowtype
|
3aa13efa28b4ededa465541a7db8df5fc5878ce3
|
tempora/tests/test_timing.py
|
tempora/tests/test_timing.py
|
import datetime
import time
import contextlib
import os
from unittest import mock
from tempora import timing
def test_IntervalGovernor():
"""
IntervalGovernor should prevent a function from being called more than
once per interval.
"""
func_under_test = mock.MagicMock()
# to look like a function, it needs a __name__ attribute
func_under_test.__name__ = 'func_under_test'
interval = datetime.timedelta(seconds=1)
governed = timing.IntervalGovernor(interval)(func_under_test)
governed('a')
governed('b')
governed(3, 'sir')
func_under_test.assert_called_once_with('a')
@contextlib.contextmanager
def change(alt_tz, monkeypatch):
monkeypatch.setitem(os.environ, 'TZ', alt_tz)
time.tzset()
try:
yield
finally:
monkeypatch.delitem(os.environ, 'TZ')
time.tzset()
def test_Stopwatch_timezone_change(monkeypatch):
"""
The stopwatch should provide a consistent duration even
if the timezone changes.
"""
watch = timing.Stopwatch()
with change('AEST-10AEDT-11,M10.5.0,M3.5.0', monkeypatch):
assert abs(watch.split().total_seconds()) < 0.1
|
import datetime
import time
import contextlib
import os
from unittest import mock
import pytest
from tempora import timing
def test_IntervalGovernor():
"""
IntervalGovernor should prevent a function from being called more than
once per interval.
"""
func_under_test = mock.MagicMock()
# to look like a function, it needs a __name__ attribute
func_under_test.__name__ = 'func_under_test'
interval = datetime.timedelta(seconds=1)
governed = timing.IntervalGovernor(interval)(func_under_test)
governed('a')
governed('b')
governed(3, 'sir')
func_under_test.assert_called_once_with('a')
@pytest.fixture
def alt_tz(monkeypatch):
if not hasattr(time, 'tzset'):
pytest.skip("tzset not available")
@contextlib.contextmanager
def change():
val = 'AEST-10AEDT-11,M10.5.0,M3.5.0'
with monkeypatch.context() as ctx:
ctx.setitem(os.environ, 'TZ', val)
time.tzset()
yield
time.tzset()
return change()
def test_Stopwatch_timezone_change(alt_tz):
"""
The stopwatch should provide a consistent duration even
if the timezone changes.
"""
watch = timing.Stopwatch()
with alt_tz:
assert abs(watch.split().total_seconds()) < 0.1
|
Rewrite alt_tz as proper fixture. Skip when tzset isn't available.
|
Rewrite alt_tz as proper fixture. Skip when tzset isn't available.
|
Python
|
mit
|
jaraco/tempora
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.