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
|
---|---|---|---|---|---|---|---|---|---|
391ff28186e40bee9ba7966b739090d67d61b2a6
|
APITaxi/models/security.py
|
APITaxi/models/security.py
|
# -*- coding: utf8 -*-
from flask.ext.security import UserMixin, RoleMixin
from ..models import db
roles_users = db.Table('roles_users',
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
class Role(db.Model, RoleMixin):
id = db.Column(db.Integer(), primary_key=True)
name = db.Column(db.String(80), unique=True)
description = db.Column(db.String(255))
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(255), unique=True)
password = db.Column(db.String(255))
active = db.Column(db.Boolean())
confirmed_at = db.Column(db.DateTime())
roles = db.relationship('Role', secondary=roles_users,
backref=db.backref('users', lazy='dynamic'))
apikey = db.Column(db.String(36), nullable=False)
def get_user_from_api_key(self, apikey):
user = self.user_model.query.filter_by(apikey=apikey)
return user.get() or None
|
# -*- coding: utf8 -*-
from flask.ext.security import UserMixin, RoleMixin
from ..models import db
from uuid import uuid4
roles_users = db.Table('roles_users',
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
class Role(db.Model, RoleMixin):
id = db.Column(db.Integer(), primary_key=True)
name = db.Column(db.String(80), unique=True)
description = db.Column(db.String(255))
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(255), unique=True)
password = db.Column(db.String(255))
active = db.Column(db.Boolean())
confirmed_at = db.Column(db.DateTime())
roles = db.relationship('Role', secondary=roles_users,
backref=db.backref('users', lazy='dynamic'))
apikey = db.Column(db.String(36), nullable=False)
def __init__(self, *args, **kwargs):
kwargs['apikey'] = str(uuid4())
super(self.__class__, self).__init__(**kwargs)
def get_user_from_api_key(self, apikey):
user = self.user_model.query.filter_by(apikey=apikey)
return user.get() or None
|
Add apikey when creating a user
|
Add apikey when creating a user
|
Python
|
agpl-3.0
|
odtvince/APITaxi,l-vincent-l/APITaxi,l-vincent-l/APITaxi,openmaraude/APITaxi,odtvince/APITaxi,odtvince/APITaxi,odtvince/APITaxi,openmaraude/APITaxi
|
8090fa9c072656497ff383e9b76d49af2955e420
|
examples/hopv/hopv_graph_conv.py
|
examples/hopv/hopv_graph_conv.py
|
"""
Script that trains graph-conv models on HOPV dataset.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
import numpy as np
from models import GraphConvTensorGraph
np.random.seed(123)
import tensorflow as tf
tf.set_random_seed(123)
import deepchem as dc
from deepchem.molnet import load_hopv
# Load HOPV dataset
hopv_tasks, hopv_datasets, transformers = load_hopv(featurizer='GraphConv')
train_dataset, valid_dataset, test_dataset = hopv_datasets
# Fit models
metric = [
dc.metrics.Metric(dc.metrics.pearson_r2_score, np.mean, mode="regression"),
dc.metrics.Metric(
dc.metrics.mean_absolute_error, np.mean, mode="regression")
]
# Number of features on conv-mols
n_feat = 75
# Batch size of models
batch_size = 50
model = GraphConvTensorGraph(
len(hopv_tasks), batch_size=batch_size, mode='regression')
# Fit trained model
model.fit(train_dataset, nb_epoch=25)
print("Evaluating model")
train_scores = model.evaluate(train_dataset, metric, transformers)
valid_scores = model.evaluate(valid_dataset, metric, transformers)
print("Train scores")
print(train_scores)
print("Validation scores")
print(valid_scores)
|
"""
Script that trains graph-conv models on HOPV dataset.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
import numpy as np
from models import GraphConvModel
np.random.seed(123)
import tensorflow as tf
tf.set_random_seed(123)
import deepchem as dc
from deepchem.molnet import load_hopv
# Load HOPV dataset
hopv_tasks, hopv_datasets, transformers = load_hopv(featurizer='GraphConv')
train_dataset, valid_dataset, test_dataset = hopv_datasets
# Fit models
metric = [
dc.metrics.Metric(dc.metrics.pearson_r2_score, np.mean, mode="regression"),
dc.metrics.Metric(
dc.metrics.mean_absolute_error, np.mean, mode="regression")
]
# Number of features on conv-mols
n_feat = 75
# Batch size of models
batch_size = 50
model = GraphConvModel(
len(hopv_tasks), batch_size=batch_size, mode='regression')
# Fit trained model
model.fit(train_dataset, nb_epoch=25)
print("Evaluating model")
train_scores = model.evaluate(train_dataset, metric, transformers)
valid_scores = model.evaluate(valid_dataset, metric, transformers)
print("Train scores")
print(train_scores)
print("Validation scores")
print(valid_scores)
|
Fix GraphConvTensorGraph to GraphConvModel in hopv example
|
Fix GraphConvTensorGraph to GraphConvModel in hopv example
|
Python
|
mit
|
Agent007/deepchem,lilleswing/deepchem,lilleswing/deepchem,Agent007/deepchem,peastman/deepchem,miaecle/deepchem,peastman/deepchem,ktaneishi/deepchem,miaecle/deepchem,Agent007/deepchem,deepchem/deepchem,ktaneishi/deepchem,deepchem/deepchem,ktaneishi/deepchem,miaecle/deepchem,lilleswing/deepchem
|
66f06164a5654f2925fb16a1ce28638fd57e3a9e
|
issue_tracker/accounts/urls.py
|
issue_tracker/accounts/urls.py
|
from django.conf.urls.defaults import *
from django.contrib.auth.views import logout_then_login, login
from django.contrib.auth.forms import AuthenticationForm
urlpatterns = patterns('',
(r'^login/$', login, {}, 'login' ),
(r'^logout/$', logout_then_login, {}, 'logout'),
)
|
from django.conf.urls.defaults import *
from django.contrib.auth.views import logout_then_login, login
from accounts.views import register
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.forms import AuthenticationForm
urlpatterns = patterns('',
(r'^register/$', register, {}, 'register' ),
(r'^login/$', login, {}, 'login' ),
(r'^logout/$', logout_then_login, {}, 'logout'),
)
|
Add url mapping to register.
|
Add url mapping to register.
|
Python
|
mit
|
hfrequency/django-issue-tracker
|
e0d510b51f44b421696958660f2ca32ee41413bd
|
click/globals.py
|
click/globals.py
|
from threading import local
_local = local()
def get_current_context(silent=False):
"""Returns the current click context. This can be used as a way to
access the current context object from anywhere. This is a more implicit
alternative to the :func:`pass_context` decorator. This function is
primarily useful for helpers such as :func:`echo` which might be
interested in changing its behavior based on the current context.
To push the current context, :meth:`Context.scope` can be used.
.. versionadded:: 5.0
:param silent: is set to `True` the return value is `None` if no context
is available. The default behavior is to raise a
:exc:`RuntimeError`.
"""
try:
return getattr(_local, 'stack')[-1]
except (AttributeError, IndexError):
if not silent:
raise RuntimeError('There is no active click context.')
def push_context(ctx):
"""Pushes a new context to the current stack."""
_local.__dict__.setdefault('stack', []).append(ctx)
def pop_context():
"""Removes the top level from the stack."""
_local.stack.pop()
def resolve_color_default(color=None):
""""Internal helper to get the default value of the color flag. If a
value is passed it's returned unchanged, otherwise it's looked up from
the current context.
"""
if color is not None:
return color
ctx = get_current_context(silent=True)
if ctx is not None:
return ctx.color
|
from threading import local
_local = local()
def get_current_context(silent=False):
"""Returns the current click context. This can be used as a way to
access the current context object from anywhere. This is a more implicit
alternative to the :func:`pass_context` decorator. This function is
primarily useful for helpers such as :func:`echo` which might be
interested in changing its behavior based on the current context.
To push the current context, :meth:`Context.scope` can be used.
.. versionadded:: 5.0
:param silent: if set to `True` the return value is `None` if no context
is available. The default behavior is to raise a
:exc:`RuntimeError`.
"""
try:
return getattr(_local, 'stack')[-1]
except (AttributeError, IndexError):
if not silent:
raise RuntimeError('There is no active click context.')
def push_context(ctx):
"""Pushes a new context to the current stack."""
_local.__dict__.setdefault('stack', []).append(ctx)
def pop_context():
"""Removes the top level from the stack."""
_local.stack.pop()
def resolve_color_default(color=None):
""""Internal helper to get the default value of the color flag. If a
value is passed it's returned unchanged, otherwise it's looked up from
the current context.
"""
if color is not None:
return color
ctx = get_current_context(silent=True)
if ctx is not None:
return ctx.color
|
Fix get_current_context typo in docstring
|
Fix get_current_context typo in docstring
|
Python
|
bsd-3-clause
|
pallets/click,mitsuhiko/click
|
1ad453f6d01d4007662fa63d59508d27bac029d5
|
keras/utils/model_utils.py
|
keras/utils/model_utils.py
|
from __future__ import print_function
import numpy as np
import theano
def print_layer_shapes(model, input_shape):
"""
Utility function that prints the shape of the output at each layer.
Arguments:
model: An instance of models.Model
input_shape: The shape of the input you will provide to the model.
"""
input_var = model.get_input(train=False)
input_tmp = np.zeros(input_shape, dtype=np.float32)
print("input shape : ", input_shape)
for l in model.layers:
shape_f = theano.function([input_var], l.get_output(train=False).shape)
out_shape = shape_f(input_tmp)
print('shape after', l.get_config()['name'], ":", out_shape)
|
from __future__ import print_function
import numpy as np
import theano
def print_layer_shapes(model, input_shape):
"""
Utility function that prints the shape of the output at each layer.
Arguments:
model: An instance of models.Model
input_shape: The shape of the input you will provide to the model.
"""
# This is to handle the case where a model has been connected to a previous
# layer (and therefore get_input would recurse into previous layer's
# output).
if hasattr(model.layers[0], 'previous'):
# TODO: If the model is used as a part of another model, get_input will
# return the input of the whole model and this won't work. So this is
# not handled yet
raise Exception("This function doesn't work on model used as subparts "
" for other models")
input_var = model.get_input(train=False)
input_tmp = np.zeros(input_shape, dtype=np.float32)
print("input shape : ", input_shape)
for l in model.layers:
shape_f = theano.function([input_var], l.get_output(train=False).shape)
out_shape = shape_f(input_tmp)
print('shape after', l.get_config()['name'], ":", out_shape)
|
Add check to print_layer_shapes to fail explicitely on model used connected to other models.
|
Add check to print_layer_shapes to fail explicitely on model used connected to other models.
|
Python
|
apache-2.0
|
asampat3090/keras,xurantju/keras,keras-team/keras,cheng6076/keras,rudaoshi/keras,bottler/keras,ashhher3/keras,wxs/keras,nzer0/keras,rodrigob/keras,pthaike/keras,EderSantana/keras,zxsted/keras,abayowbo/keras,zxytim/keras,danielforsyth/keras,hhaoyan/keras,jalexvig/keras,chenych11/keras,brainwater/keras,amy12xx/keras,daviddiazvico/keras,vseledkin/keras,wubr2000/keras,jasonyaw/keras,fmacias64/keras,jbolinge/keras,pjadzinsky/keras,LIBOTAO/keras,dxj19831029/keras,nebw/keras,MagicSen/keras,kuza55/keras,Smerity/keras,untom/keras,nt/keras,zhangxujinsh/keras,marchick209/keras,ml-lab/keras,why11002526/keras,iamtrask/keras,DeepGnosis/keras,keskarnitish/keras,dribnet/keras,zhmz90/keras,stephenbalaban/keras,iScienceLuvr/keras,jiumem/keras,JasonTam/keras,xiaoda99/keras,3dconv/keras,tencrance/keras,cvfish/keras,navyjeff/keras,Aureliu/keras,florentchandelier/keras,gamer13/keras,kod3r/keras,rlkelly/keras,saurav111/keras,relh/keras,mikekestemont/keras,eulerreich/keras,sjuvekar/keras,jimgoo/keras,meanmee/keras,happyboy310/keras,gavinmh/keras,Cadene/keras,DLlearn/keras,ogrisel/keras,llcao/keras,bboalimoe/keras,printedheart/keras,kemaswill/keras,johmathe/keras,Yingmin-Li/keras,ledbetdr/keras,ekamioka/keras,imcomking/Convolutional-GRU-keras-extension-,dhruvparamhans/keras,dolaameng/keras,jayhetee/keras,yingzha/keras,OlafLee/keras,keras-team/keras,nehz/keras,harshhemani/keras
|
fb1422c22e570da21279edee0ea79605e74f7a92
|
crispy/__init__.py
|
crispy/__init__.py
|
import logging
logging.basicConfig(level=logging.WARNING)
|
import logging
# These are required to activate the cx_Freeze hooks
import matplotlib
import matplotlib.backends.backend_qt5agg
import PyQt5.QtPrintSupport
logging.basicConfig(level=logging.WARNING)
|
Add imports imports to trigger cx_Freeze hooks
|
Add imports imports to trigger cx_Freeze hooks
|
Python
|
mit
|
mretegan/crispy,mretegan/crispy
|
d6a03fad6c9280981ae3beee24de89bd6361bcc9
|
dumbrepl.py
|
dumbrepl.py
|
if __name__ == "__main__":
import pycket.test.testhelper as th
th.dumb_repl()
|
if __name__ == "__main__":
import pycket.values
import pycket.config
from pycket.env import w_global_config
#w_global_config.set_linklet_mode_off()
import pycket.test.testhelper as th
th.dumb_repl()
|
Make sure things are loaded right.
|
Make sure things are loaded right.
|
Python
|
mit
|
samth/pycket,pycket/pycket,pycket/pycket,samth/pycket,samth/pycket,pycket/pycket
|
bd69ad0bf57876cef01cc8f7cdce49a301eb2444
|
bin/remotePush.py
|
bin/remotePush.py
|
import json,httplib
config_data = json.load(open('conf/net/ext_service/parse.json'))
silent_push_msg = {
"where": {
"deviceType": "ios"
},
"data": {
# "alert": "The Mets scored! The game is now tied 1-1.",
"content-available": 1,
"sound": "",
}
}
parse_headers = {
"X-Parse-Application-Id": config_data["emission_id"],
"X-Parse-REST-API-Key": config_data["emission_key"],
"Content-Type": "application/json"
}
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
connection.request('POST', '/1/push', json.dumps(silent_push_msg), parse_headers)
result = json.loads(connection.getresponse().read())
print result
|
import json,httplib
import sys
config_data = json.load(open('conf/net/ext_service/parse.json'))
interval = sys.argv[1]
print "pushing for interval %s" % interval
silent_push_msg = {
"where": {
"deviceType": "ios"
},
"channels": [
interval
],
"data": {
# "alert": "The Mets scored! The game is now tied 1-1.",
"content-available": 1,
"sound": "",
}
}
parse_headers = {
"X-Parse-Application-Id": config_data["emission_id"],
"X-Parse-REST-API-Key": config_data["emission_key"],
"Content-Type": "application/json"
}
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
connection.request('POST', '/1/push', json.dumps(silent_push_msg), parse_headers)
result = json.loads(connection.getresponse().read())
print result
|
Make the remote push script take in the interval as an argument
|
Make the remote push script take in the interval as an argument
We will use the interval as the channel
|
Python
|
bsd-3-clause
|
shankari/e-mission-server,sunil07t/e-mission-server,e-mission/e-mission-server,e-mission/e-mission-server,e-mission/e-mission-server,sunil07t/e-mission-server,sunil07t/e-mission-server,yw374cornell/e-mission-server,yw374cornell/e-mission-server,shankari/e-mission-server,e-mission/e-mission-server,shankari/e-mission-server,yw374cornell/e-mission-server,yw374cornell/e-mission-server,shankari/e-mission-server,sunil07t/e-mission-server
|
3794fe611e5fbbe55506a7d2e59b2f3f872d8733
|
backend/controllers/file_controller.py
|
backend/controllers/file_controller.py
|
import os
from werkzeug.utils import secure_filename
import config
from flask_restful import Resource
from flask import request, abort
def allowed_file(filename):
return ('.' in filename and
filename.rsplit('.', 1)[1].lower() in config.ALLOWED_EXTENSIONS)
class File(Resource):
def post(self):
if 'uploaded_data' not in request.files:
abort(500)
file = request.files['uploaded_data']
if file.filename == '':
abort(500)
if allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(config.UPLOAD_FOLDER, filename))
return {'response': 'File uploaded successfully'}
def delete(self):
filename = request.args.get('filename')
os.remove(os.path.join(config.UPLOAD_FOLDER, filename))
return {'response': 'File deleted successfully'}
|
import os
from werkzeug.utils import secure_filename
import config
from flask_restful import Resource
from flask import request, abort
def allowed_file(filename):
return ('.' in filename and
filename.rsplit('.', 1)[1].lower() in config.ALLOWED_EXTENSIONS)
class File(Resource):
def post(self):
if 'uploaded_data' not in request.files:
abort(400, 'Uploaded_data is required for the request')
file = request.files['uploaded_data']
if file.filename == '':
abort(400, 'Filename cannot be empty')
if allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(config.UPLOAD_FOLDER, filename))
return {'response': 'File uploaded successfully'}
else:
abort(415, 'File type is not supported')
def delete(self):
filename = secure_filename(request.args.get('filename'))
os.remove(os.path.join(config.UPLOAD_FOLDER, filename))
return {'response': 'File deleted successfully'}
|
Change status codes and messages
|
Change status codes and messages
|
Python
|
apache-2.0
|
googleinterns/inventory-visualizer,googleinterns/inventory-visualizer,googleinterns/inventory-visualizer,googleinterns/inventory-visualizer,googleinterns/inventory-visualizer
|
123875153e81253a44d0e8b2d8de5abee195362a
|
backend/shmitter/tweets/serializers.py
|
backend/shmitter/tweets/serializers.py
|
from rest_framework import serializers
from shmitter.likes import services as likes_services
from .models import Tweet
from . import services as tweets_services
class TweetSerializer(serializers.ModelSerializer):
owner = serializers.ReadOnlyField(source='owner.username')
is_fan = serializers.SerializerMethodField()
is_retweeted = serializers.SerializerMethodField()
class Meta:
model = Tweet
fields = (
'id',
'owner',
'body',
'is_fan',
'is_retweeted',
'total_likes',
'created',
)
def get_is_fan(self, obj) -> bool:
"""
Check if a `request.user` has liked this tweet (`obj`).
"""
user = self.context.get('request').user
return likes_services.is_fan(obj, user)
def get_is_retweeted(self, obj) -> bool:
"""
Check if a `request.user` has retweeted this tweet (`obj`).
"""
user = self.context.get('request').user
return tweets_services.is_retweeted(obj, user)
|
from rest_framework import serializers
from shmitter.likes import services as likes_services
from .models import Tweet
from . import services as tweets_services
class TweetSerializer(serializers.ModelSerializer):
owner = serializers.ReadOnlyField(source='owner.username')
is_fan = serializers.SerializerMethodField()
is_retweeted = serializers.SerializerMethodField()
class Meta:
model = Tweet
fields = (
'id',
'owner',
'body',
'is_fan',
'is_retweeted',
'total_likes',
'total_retweets',
'created',
)
def get_is_fan(self, obj) -> bool:
"""
Check if a `request.user` has liked this tweet (`obj`).
"""
user = self.context.get('request').user
return likes_services.is_fan(obj, user)
def get_is_retweeted(self, obj) -> bool:
"""
Check if a `request.user` has retweeted this tweet (`obj`).
"""
user = self.context.get('request').user
return tweets_services.is_retweeted(obj, user)
|
Add total retweets to the serializer
|
Add total retweets to the serializer
|
Python
|
mit
|
apirobot/shmitter,apirobot/shmitter,apirobot/shmitter
|
28a4f4ab9d6b7c3ea14d48c002273acfe05d7246
|
bumblebee/util.py
|
bumblebee/util.py
|
import shlex
import exceptions
import subprocess
def bytefmt(num):
for unit in [ "", "Ki", "Mi", "Gi" ]:
if num < 1024.0:
return "{:.2f}{}B".format(num, unit)
num /= 1024.0
return "{:05.2f%}{}GiB".format(num)
def durationfmt(duration):
minutes, seconds = divmod(duration, 60)
hours, minutes = divmod(minutes, 60)
res = "{:02d}:{:02d}".format(minutes, seconds)
if hours > 0: res = "{:02d}:{}".format(hours, res)
return res
def execute(cmd):
args = shlex.split(cmd)
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out = p.communicate()
if p.returncode != 0:
raise exceptions.RuntimeError("{} exited with {}".format(cmd, p.returncode))
|
import shlex
import subprocess
try:
from exceptions import RuntimeError
except ImportError:
# Python3 doesn't require this anymore
pass
def bytefmt(num):
for unit in [ "", "Ki", "Mi", "Gi" ]:
if num < 1024.0:
return "{:.2f}{}B".format(num, unit)
num /= 1024.0
return "{:05.2f%}{}GiB".format(num)
def durationfmt(duration):
minutes, seconds = divmod(duration, 60)
hours, minutes = divmod(minutes, 60)
res = "{:02d}:{:02d}".format(minutes, seconds)
if hours > 0: res = "{:02d}:{}".format(hours, res)
return res
def execute(cmd):
args = shlex.split(cmd)
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out = p.communicate()
if p.returncode != 0:
raise RuntimeError("{} exited with {}".format(cmd, p.returncode))
|
Fix import error for Python3
|
[core] Fix import error for Python3
Import exceptions module only for Python2.
fixes #22
|
Python
|
mit
|
tobi-wan-kenobi/bumblebee-status,tobi-wan-kenobi/bumblebee-status
|
81b7089633b9d43b05566a1e23f93fb59678fe1e
|
plugins/unicode_plugin.py
|
plugins/unicode_plugin.py
|
import string
import textwrap
import binascii
from veryprettytable import VeryPrettyTable
from plugins import BasePlugin
__author__ = 'peter'
class DecodeHexPlugin(BasePlugin):
short_description = 'Decode hex string to encodings:'
default = True
description = textwrap.dedent('''
This plugin tries to decode the given hexstring with some common encodings, then print it
'''.strip())
def sentinel(self):
return all(not len(x) % 2 for x in self.args['STRING'])
def handle(self):
result = ''
for s in self.args['STRING']:
if len(self.args['STRING']) > 1:
result += '{0}:\n'.format(s)
binary = binascii.unhexlify(s)
result += self._decode('UTF8', 'utf8', binary)
result += self._decode('iso-8859-1 (Cyrillic)', 'iso-8859-1', binary)
return result
@staticmethod
def _decode(name, encoding, binary):
try:
s = binary.decode(encoding)
except UnicodeDecodeError:
s = '<invalid>'
return '{0}: "{1}"\n'.format(name, s)
|
import string
import textwrap
import binascii
import unicodedata
from veryprettytable import VeryPrettyTable
from plugins import BasePlugin
__author__ = 'peter'
class DecodeHexPlugin(BasePlugin):
short_description = 'Decode hex string to encodings:'
default = True
description = textwrap.dedent('''
This plugin tries to decode the given hexstring with some common encodings, then print it.
It tries to remove control characters from the string after decoding to prevent terminal breakage.
'''.strip())
def sentinel(self):
return all(not len(x) % 2 for x in self.args['STRING'])
def handle(self):
result = ''
for s in self.args['STRING']:
if len(self.args['STRING']) > 1:
result += '{0}:\n'.format(s)
binary = binascii.unhexlify(s)
result += self._decode('UTF8', 'utf8', binary)
result += self._decode('iso-8859-1 (Cyrillic)', 'iso-8859-1', binary)
return result
def _decode(self, name, encoding, binary):
try:
s = self._clean(binary.decode(encoding))
except UnicodeDecodeError:
s = '<invalid>'
return '{0}: "{1}"\n'.format(name, s)
@staticmethod
def _clean(s):
return "".join(ch for ch in s if unicodedata.category(ch)[0] != "C")
|
Remove control characters from printed string to prevent terminal breakage
|
Remove control characters from printed string to prevent terminal breakage
|
Python
|
mit
|
Sakartu/stringinfo
|
e999e9b9480d31c45bf13882081e36bd7e2c4c63
|
download.py
|
download.py
|
#!/usr/bin/env python
import data
s = data.Session()
for video in s.query(data.Video):
print u'+++ Downloading {} +++'.format(video.title)
video.download()
del s
|
#!/usr/bin/env python
import data
s = data.Session()
for video in s.query(data.Video):
print u'+++ Downloading "{}" +++'.format(video.title)
video.download()
del s
|
Print video title in quotes
|
Print video title in quotes
|
Python
|
mit
|
drkitty/metatube,drkitty/metatube
|
c0596310d9281fc07d4db6e6fd2ed8433335edb9
|
examples/build_examples.py
|
examples/build_examples.py
|
#!/usr/bin/env python
import glob
import os
import platform
import subprocess
import sys
cx_path = sys.argv[1] if len(sys.argv) > 1 else "cx"
os.chdir(os.path.dirname(__file__))
for file in glob.glob("*.cx"):
if platform.system() == "Windows" and file == "tree.cx":
continue
extension = ".out" if platform.system() != "Windows" else ".exe"
output = os.path.splitext(file)[0] + extension
exit_status = subprocess.call([cx_path, file, "-o", output])
if exit_status != 0:
sys.exit(1)
print("All examples built successfully.")
|
#!/usr/bin/env python
import glob
import os
import platform
import subprocess
import sys
cx_path = sys.argv[1] if len(sys.argv) > 1 else "cx"
os.chdir(os.path.dirname(__file__))
for file in glob.glob("*.cx"):
if platform.system() == "Windows" and file == "tree.cx":
continue
extension = ".out" if platform.system() != "Windows" else ".exe"
output = os.path.splitext(file)[0] + extension
exit_status = subprocess.call([cx_path, file, "-o", output, "-Werror"])
if exit_status != 0:
sys.exit(1)
print("All examples built successfully.")
|
Use -Werror for code examples
|
Use -Werror for code examples
|
Python
|
mit
|
delta-lang/delta,delta-lang/delta,delta-lang/delta,delta-lang/delta
|
19326b0b96e053c4b4fab402a379a03c39fbe46d
|
apps/homepage/templatetags/homepage_tags.py
|
apps/homepage/templatetags/homepage_tags.py
|
from django import template
from homepage.models import Tab
register = template.Library()
@register.tag(name="get_tabs")
def get_tabs(parser, token):
return GetElementNode()
class GetElementNode(template.Node):
def __init__(self):
pass
def render(self, context):
context['tabs'] = Tab.objects.all()
return ''
|
from django import template
from homepage.models import Tab
register = template.Library()
@register.tag(name="get_tabs")
def get_tabs(parser, token):
return GetElementNode()
class GetElementNode(template.Node):
def __init__(self):
pass
def render(self, context):
context['tabs'] = Tab.objects.all().select_related('grid')
return ''
|
Reduce queries on all pages by using select_related in the get_tabs template tag.
|
Reduce queries on all pages by using select_related in the get_tabs template tag.
|
Python
|
mit
|
cartwheelweb/packaginator,nanuxbe/djangopackages,miketheman/opencomparison,audreyr/opencomparison,audreyr/opencomparison,cartwheelweb/packaginator,QLGu/djangopackages,pydanny/djangopackages,cartwheelweb/packaginator,benracine/opencomparison,nanuxbe/djangopackages,pydanny/djangopackages,pydanny/djangopackages,QLGu/djangopackages,nanuxbe/djangopackages,miketheman/opencomparison,benracine/opencomparison,QLGu/djangopackages
|
6b0049978f2a7e59146abbc9b6a265061bbe00c4
|
conda_verify/errors.py
|
conda_verify/errors.py
|
from collections import namedtuple
class Error(namedtuple('Error', ['file', 'line_number', 'code', 'message'])):
"""Error class creates error codes to be shown to the user."""
def __repr__(self):
"""Override namedtuple's __repr__ so that error codes are readable."""
return '{}:{}: {} {}' .format(self.file, self.line_number, self.code, self.message)
|
Add Error class as base for error codes
|
Add Error class as base for error codes
Add docstrings to error class
|
Python
|
bsd-3-clause
|
mandeep/conda-verify
|
|
5aff8defb8baf83176ea861b03de04a9d6ac8a31
|
bundles/views.py
|
bundles/views.py
|
from django.views.generic import DetailView, ListView
from rest_framework import filters, generics, permissions
from rest_framework.response import Response
from . import models, serializers
class BundleList(ListView):
model = models.Bundle
context_object_name = 'bundles'
paginate_by = 25
class BundleDetail(DetailView):
model = models.Bundle
context_object_name = 'bundle'
class BundleView(generics.RetrieveAPIView):
serializer_class = serializers.BundleSerializer
permission_classes = [permissions.IsAuthenticated]
def get(self, request, slug):
try:
bundle = models.Bundle.objects.get(slug=slug)
except models.Bundle.DoesNotExist:
return Response(status=404)
serializer = serializers.BundleSerializer(bundle)
return Response(serializer.data)
|
from django.views.generic import DetailView, ListView
from rest_framework import filters, generics, permissions
from rest_framework.response import Response
from . import models, serializers
class BundleList(ListView):
model = models.Bundle
context_object_name = 'bundles'
paginate_by = 25
class BundleDetail(DetailView):
model = models.Bundle
context_object_name = 'bundle'
class BundleView(generics.RetrieveAPIView):
serializer_class = serializers.BundleSerializer
def get(self, request, slug):
try:
bundle = models.Bundle.objects.get(slug=slug)
except models.Bundle.DoesNotExist:
return Response(status=404)
serializer = serializers.BundleSerializer(bundle)
return Response(serializer.data)
|
Make bundle view accessible to anyone
|
Make bundle view accessible to anyone
|
Python
|
agpl-3.0
|
lutris/website,lutris/website,lutris/website,lutris/website
|
b3391187cb87ae33d4b8dd6e55f5edfdb695ea53
|
mapbox_vector_tile/__init__.py
|
mapbox_vector_tile/__init__.py
|
from . import encoder
from . import decoder
def decode(tile, y_coord_down=False):
vector_tile = decoder.TileData()
message = vector_tile.getMessage(tile, y_coord_down)
return message
def encode(layers, quantize_bounds=None, y_coord_down=False, extents=4096,
on_invalid_geometry=None, round_fn=None, check_winding_order=True):
vector_tile = encoder.VectorTile(extents, on_invalid_geometry,
round_fn=round_fn,
check_winding_order=check_winding_order)
if (isinstance(layers, list)):
for layer in layers:
vector_tile.addFeatures(layer['features'], layer['name'],
quantize_bounds, y_coord_down)
else:
vector_tile.addFeatures(layers['features'], layers['name'],
quantize_bounds, y_coord_down)
return vector_tile.tile.SerializeToString()
|
from . import encoder
from . import decoder
# Enable Shapely "speedups" if available
# http://toblerity.org/shapely/manual.html#performance
from shapely import speedups
if speedups.available:
speedups.enable()
def decode(tile, y_coord_down=False):
vector_tile = decoder.TileData()
message = vector_tile.getMessage(tile, y_coord_down)
return message
def encode(layers, quantize_bounds=None, y_coord_down=False, extents=4096,
on_invalid_geometry=None, round_fn=None, check_winding_order=True):
vector_tile = encoder.VectorTile(extents, on_invalid_geometry,
round_fn=round_fn,
check_winding_order=check_winding_order)
if (isinstance(layers, list)):
for layer in layers:
vector_tile.addFeatures(layer['features'], layer['name'],
quantize_bounds, y_coord_down)
else:
vector_tile.addFeatures(layers['features'], layers['name'],
quantize_bounds, y_coord_down)
return vector_tile.tile.SerializeToString()
|
Enable Shapely speedups when available.
|
Enable Shapely speedups when available.
http://toblerity.org/shapely/manual.html#performance
|
Python
|
mit
|
mapzen/mapbox-vector-tile
|
e53e214b97a9a4c7ad2dbca88b01798dcc614b6a
|
auth0/v2/authentication/social.py
|
auth0/v2/authentication/social.py
|
from .base import AuthenticationBase
class Social(AuthenticationBase):
def __init__(self, domain):
self.domain = domain
def login(self, client_id, access_token, connection):
"""Login using a social provider's access token
Given the social provider's access_token and the connection specified,
it will do the authentication on the provider and return a dict with
the access_token and id_token. Currently, this endpoint only works for
Facebook, Google, Twitter and Weibo.
Args:
client_id (str): client name.
access_token (str): social provider's access_token.
connection (str): connection type (e.g: 'facebook')
Returns:
A dict with 'access_token' and 'id_token' keys.
"""
return self.post(
'https://%s/oauth/access_token' % self.domain,
data={
'client_id': client_id,
'access_token': access_token,
'connection': connection,
'scope': 'openid',
},
headers={'Content-Type': 'application/json'}
)
|
from .base import AuthenticationBase
class Social(AuthenticationBase):
"""Social provider's endpoints.
Args:
domain (str): Your auth0 domain (e.g: username.auth0.com)
"""
def __init__(self, domain):
self.domain = domain
def login(self, client_id, access_token, connection):
"""Login using a social provider's access token
Given the social provider's access_token and the connection specified,
it will do the authentication on the provider and return a dict with
the access_token and id_token. Currently, this endpoint only works for
Facebook, Google, Twitter and Weibo.
Args:
client_id (str): client name.
access_token (str): social provider's access_token.
connection (str): connection type (e.g: 'facebook')
Returns:
A dict with 'access_token' and 'id_token' keys.
"""
return self.post(
'https://%s/oauth/access_token' % self.domain,
data={
'client_id': client_id,
'access_token': access_token,
'connection': connection,
'scope': 'openid',
},
headers={'Content-Type': 'application/json'}
)
|
Add class docstring to Social
|
Add class docstring to Social
|
Python
|
mit
|
auth0/auth0-python,auth0/auth0-python
|
1608134ea633c0fe8cd4636b11dc5a931d02e024
|
intercom.py
|
intercom.py
|
import configparser
import time
import RPIO as GPIO
from client import MumbleClient
class InterCom:
def __init__(self):
config = configparser.ConfigParser()
config.read('intercom.ini')
self.mumble_client = MumbleClient(config['mumbleclient'])
self.exit = False
self.send_input = False
if config['general']['gpiotype'] == 'BCM':
GPIO.setmode(GPIO.BCM)
self.button = int(config['general']['button'])
GPIO.setup(self.button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def run(self):
while not self.exit:
if GPIO.input(self.button):
self.mumble_client.send_input_audio()
if __name__ == '__main__':
InterCom().run()
|
import configparser
import time
import RPi.GPIO as GPIO
from client import MumbleClient
class InterCom:
def __init__(self):
config = configparser.ConfigParser()
config.read('intercom.ini')
self.mumble_client = MumbleClient(config['mumbleclient'])
self.exit = False
self.send_input = False
if config['general']['gpiotype'] == 'BCM':
GPIO.setmode(GPIO.BCM)
self.button = int(config['general']['button'])
GPIO.setup(self.button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def run(self):
while not self.exit:
if GPIO.input(self.button):
self.mumble_client.send_input_audio()
if __name__ == '__main__':
try:
InterCom().run()
except Exception as e:
raise e
finally:
GPIO.cleanup()
|
Change to rpio and add clean
|
Change to rpio and add clean
|
Python
|
mit
|
pkronstrom/intercom
|
05e568571c2f6891ed7be6198b8cf5e4e540d674
|
dev_tools/run_tests.py
|
dev_tools/run_tests.py
|
#!/usr/bin/env python3
"""Run tests under a consistent environment...
Whether run from the terminal, in CI or from the editor this file makes sure
the tests are run in a consistent environment.
"""
#------------------------------------------------------------------------------
# Py2C - A Python to C++ compiler
# Copyright (C) 2014 Pradyun S. Gedam
#------------------------------------------------------------------------------
import sys
from os.path import join, realpath, dirname
# Local modules
import cleanup
cleanup.REMOVE_GENERATED_AST = False
cleanup.PRINT_OUTPUT = False
cleanup.main()
# Third Party modules
import nose
import coverage
base_dir = realpath(dirname(__file__))
root_dir = join(dirname(base_dir), "py2c")
REPORT = True
if "--dont-report" in sys.argv:
sys.argv.remove("--dont-report")
REPORT = False
cov = coverage.coverage(config_file=join(base_dir, ".coveragerc"))
cov.start()
success = nose.run(
env={
"NOSE_INCLUDE_EXE": "True",
"NOSE_WITH_HTML_REPORT": "True",
"NOSE_WITH_SPECPLUGIN": "True"
},
defaultTest=root_dir,
)
cov.stop()
cov.save()
if success and REPORT:
cov.html_report()
cov.report()
sys.exit(0 if success else 1)
|
#!/usr/bin/env python3
"""Run tests under a consistent environment...
Whether run from the terminal, in CI or from the editor this file makes sure
the tests are run in a consistent environment.
"""
#------------------------------------------------------------------------------
# Py2C - A Python to C++ compiler
# Copyright (C) 2014 Pradyun S. Gedam
#------------------------------------------------------------------------------
# Local modules
import cleanup
# Standard library
import sys
from os.path import join, realpath, dirname
# Third Party modules
import nose
import coverage
cleanup.REMOVE_GENERATED_AST = False
cleanup.main()
base_dir = realpath(dirname(__file__))
root_dir = join(dirname(base_dir), "py2c")
REPORT = True
if "--dont-report" in sys.argv:
sys.argv.remove("--dont-report")
REPORT = False
cov = coverage.coverage(config_file=join(base_dir, ".coveragerc"))
cov.start()
success = nose.run(
env={
"NOSE_INCLUDE_EXE": "True",
"NOSE_WITH_HTML_REPORT": "True",
"NOSE_WITH_SPECPLUGIN": "True"
},
defaultTest=root_dir,
)
cov.stop()
cov.save()
if success and REPORT:
cov.html_report()
cov.report()
sys.exit(0 if success else 1)
|
Move all imports to top-of-module, don't hide cleanup output.
|
[RUN_TESTS] Move all imports to top-of-module, don't hide cleanup output.
|
Python
|
bsd-3-clause
|
pradyunsg/Py2C,pradyunsg/Py2C
|
0fe30bb04e9b3d981cd1f6264485d98ca56a2fb8
|
events/migrations/0035_add_n_events_to_keyword.py
|
events/migrations/0035_add_n_events_to_keyword.py
|
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2016-12-02 15:46
from __future__ import unicode_literals
from django.db import migrations, models
def forward(apps, schema_editor):
Keyword = apps.get_model('events', 'Keyword')
for keyword in Keyword.objects.exclude(events=None) | Keyword.objects.exclude(audience_events=None):
n_events = (keyword.events.all() | keyword.audience_events.all()).distinct().count()
if n_events != keyword.n_events:
keyword.n_events = n_events
keyword.save(update_fields=("n_events",))
class Migration(migrations.Migration):
dependencies = [
('events', '0034_add_keyword_deprecated'),
]
operations = [
migrations.AddField(
model_name='keyword',
name='n_events',
field=models.IntegerField(db_index=True, default=0, editable=False, help_text='number of events with this keyword', verbose_name='event count'),
),
migrations.AlterField(
model_name='event',
name='audience',
field=models.ManyToManyField(blank=True, related_name='audience_events', to='events.Keyword'),
),
migrations.AlterField(
model_name='event',
name='keywords',
field=models.ManyToManyField(related_name='events', to='events.Keyword'),
),
migrations.RunPython(forward, migrations.RunPython.noop)
]
|
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2016-12-02 15:46
from __future__ import unicode_literals
from django.db import migrations, models
def forward(apps, schema_editor):
Keyword = apps.get_model('events', 'Keyword')
for keyword in Keyword.objects.exclude(events=None) | Keyword.objects.exclude(audience_events=None):
n_events = (keyword.events.all() | keyword.audience_events.all()).distinct().count()
if n_events != keyword.n_events:
print("Updating event number for " + str(keyword.name))
keyword.n_events = n_events
keyword.save(update_fields=("n_events",))
class Migration(migrations.Migration):
dependencies = [
('events', '0034_add_keyword_deprecated'),
]
operations = [
migrations.AddField(
model_name='keyword',
name='n_events',
field=models.IntegerField(db_index=True, default=0, editable=False, help_text='number of events with this keyword', verbose_name='event count'),
),
migrations.AlterField(
model_name='event',
name='audience',
field=models.ManyToManyField(blank=True, related_name='audience_events', to='events.Keyword'),
),
migrations.AlterField(
model_name='event',
name='keywords',
field=models.ManyToManyField(related_name='events', to='events.Keyword'),
),
migrations.RunPython(forward, migrations.RunPython.noop)
]
|
Add logging to keyword data migration
|
Add logging to keyword data migration
|
Python
|
mit
|
City-of-Helsinki/linkedevents,City-of-Helsinki/linkedevents,City-of-Helsinki/linkedevents
|
887597d31dec7fe1f49402e44691c1e745d22968
|
cellcounter/wsgi.py
|
cellcounter/wsgi.py
|
"""
WSGI config for cellcounter project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cellcounter.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
|
"""
WSGI config for cellcounter project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
import site
from distutils.sysconfig import get_python_lib
#ensure the venv is being loaded correctly
site.addsitedir(get_python_lib())
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cellcounter.settings")
#import the DATABASE_URL from an Apache environment variable
#this allows per-vhost database configuration to be passed in
import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()
def application(environ, start_response):
os.environ['DATABASE_URL'] = environ['DATABASE_URL']
return _application(environ, start_response)
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
|
Improve WSGI file for apache deployment/database configuration management
|
Improve WSGI file for apache deployment/database configuration management
|
Python
|
mit
|
cellcounter/cellcounter,cellcounter/cellcounter,cellcounter/cellcounter,oghm2/hackdayoxford,oghm2/hackdayoxford,haematologic/cellcounter,haematologic/cellcounter,haematologic/cellcounter,cellcounter/cellcounter
|
25712b9c94062f41c50a8611c5b7069bde7e1c8f
|
ibmcnx/cnx/VersionStamp.py
|
ibmcnx/cnx/VersionStamp.py
|
######
# Set the Version Stamp to actual time and date
#
# Author: Christoph Stoettner
# Mail: [email protected]
# Documentation: http://scripting101.stoeps.de
#
# Version: 2.0
# Date: 2014-06-04
#
# License: Apache 2.0
#
print "\nSet Version Stamp in LotusConnections-config.xml to actual Date and Time\n"
path = raw_input( "Path and Folder where config is temporarily stored: " )
execfile("connectionsConfig.py")
LCConfigService.checkOutConfig(path,AdminControl.getCell())
LCConfigService.updateConfig("versionStamp","")
LCConfigService.checkInConfig(path,AdminControl.getCell())
synchAllNodes()
|
######
# Set the Version Stamp to actual time and date
#
# Author: Christoph Stoettner
# Mail: [email protected]
# Documentation: http://scripting101.stoeps.de
#
# Version: 2.0
# Date: 2014-06-04
#
# License: Apache 2.0
#
import ibmcnx.functions
print "\nSet Version Stamp in LotusConnections-config.xml to actual Date and Time\n"
# Check properties if temppath is defined
if ( ibmcnx.functions.tempPath() == '' ):
path = raw_input( "Path and Folder where config is temporarily stored: " )
else:
path = ibmcnx.functions.tempPath()
execfile("connectionsConfig.py")
LCConfigService.checkOutConfig(path,AdminControl.getCell())
LCConfigService.updateConfig("versionStamp","")
LCConfigService.checkInConfig(path,AdminControl.getCell())
synchAllNodes()
|
Add option to get temppath from properties file
|
Add option to get temppath from properties file
|
Python
|
apache-2.0
|
stoeps13/ibmcnx2,stoeps13/ibmcnx2
|
e5656674eab83f7005c70d901187fd89027efeba
|
allaccess/management/commands/migrate_social_providers.py
|
allaccess/management/commands/migrate_social_providers.py
|
from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand, CommandError
from allaccess.models import Provider
class Command(NoArgsCommand):
"Convert existing providers from django-social-auth to django-all-access."
def handle_noargs(self, **options):
verbosity = int(options.get('verbosity'))
try:
from social_auth.backends import get_backends, BaseOAuth
except ImportError: # pragma: no cover
raise CommandError("django-social-auth is not installed.")
for name, backend in get_backends(force_load=True).items():
if issubclass(backend, BaseOAuth) and backend.enabled():
# Create providers if they don't already exist
key, secret = backend.get_key_and_secret()
defaults = {
'request_token_url': getattr(backend, 'REQUEST_TOKEN_URL', ''),
'authorization_url': getattr(backend, 'AUTHORIZATION_URL', ''),
'access_token_url': getattr(backend, 'ACCESS_TOKEN_URL', ''),
'profile_url': '',
'key': key or None,
'secret': secret or None,
}
provider, created = Provider.objects.get_or_create(name=name, defaults=defaults)
if created and verbosity > 0:
self.stdout.write('New provider created from "%s" backend.\n' % name)
|
from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand, CommandError
from allaccess.models import Provider
class Command(NoArgsCommand):
"Convert existing providers from django-social-auth to django-all-access."
def handle_noargs(self, **options):
verbosity = int(options.get('verbosity'))
try:
from social_auth.backends import get_backends, BaseOAuth
except ImportError: # pragma: no cover
raise CommandError("django-social-auth is not installed.")
for name, backend in get_backends().items():
if issubclass(backend, BaseOAuth) and backend.enabled():
# Create providers if they don't already exist
key, secret = backend.get_key_and_secret()
defaults = {
'request_token_url': getattr(backend, 'REQUEST_TOKEN_URL', ''),
'authorization_url': getattr(backend, 'AUTHORIZATION_URL', ''),
'access_token_url': getattr(backend, 'ACCESS_TOKEN_URL', ''),
'profile_url': '',
'key': key or None,
'secret': secret or None,
}
provider, created = Provider.objects.get_or_create(name=name, defaults=defaults)
if created and verbosity > 0:
self.stdout.write('New provider created from "%s" backend.\n' % name)
|
Remove force_load which was added in later versions.
|
Remove force_load which was added in later versions.
|
Python
|
bsd-2-clause
|
iXioN/django-all-access,vyscond/django-all-access,dpoirier/django-all-access,dpoirier/django-all-access,mlavin/django-all-access,iXioN/django-all-access,vyscond/django-all-access,mlavin/django-all-access
|
3faf3a9debc0fad175ca032f3eb0880defbd0cdb
|
akaudit/clidriver.py
|
akaudit/clidriver.py
|
#!/usr/bin/env python
import sys
import argparse
from akaudit.audit import Auditer
def main(argv = sys.argv, log = sys.stderr):
parser = argparse.ArgumentParser(description='Audit who has access to your homes.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-l', '--log', default='info', help='Log level')
args = parser.parse_args()
auditer = Auditer()
auditer.run_audit(args)
if __name__ == "__main__":
main(sys.argv[1:])
|
#!/usr/bin/env python
import sys
import argparse
from akaudit.audit import Auditer
def main(argv = sys.argv, log = sys.stderr):
parser = argparse.ArgumentParser(description='Audit who has access to your homes.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-l', '--log', default='info', help='Log level')
parser.add_argument('-i', '--interactive', help='Interactive mode (prompts asking if to delete each key)', action="store_true")
args = parser.parse_args()
auditer = Auditer()
auditer.run_audit(args)
if __name__ == "__main__":
main(sys.argv[1:])
|
Add argument option for --interactive.
|
Add argument option for --interactive.
|
Python
|
apache-2.0
|
flaccid/akaudit
|
766a2fa8a1256946af9bc3b20b98a9a6ac7e1080
|
amaranth/__init__.py
|
amaranth/__init__.py
|
"""This is the top-level amaranth module init file.
The only current use of this class is to define common constants.
"""
LOW_CALORIE_THRESHOLD = 100
HIGH_CALORIE_THRESHOLD = 500
|
"""This is the top-level amaranth module init file.
The only current use of this class is to define common constants.
"""
LOW_CALORIE_THRESHOLD = 100
HIGH_CALORIE_THRESHOLD = 300
|
Change high calorie threshold to 300
|
Change high calorie threshold to 300
|
Python
|
apache-2.0
|
googleinterns/amaranth,googleinterns/amaranth
|
572a84ae4fe7ce464fe66b6462a80b09b20f8f1c
|
fireplace/cards/gvg/neutral_epic.py
|
fireplace/cards/gvg/neutral_epic.py
|
from ..utils import *
##
# Minions
# Hobgoblin
class GVG_104:
def OWN_CARD_PLAYED(self, card):
if card.type == CardType.MINION and card.atk == 1:
return [Buff(card, "GVG_104a")]
|
from ..utils import *
##
# Minions
# Hobgoblin
class GVG_104:
def OWN_CARD_PLAYED(self, card):
if card.type == CardType.MINION and card.atk == 1:
return [Buff(card, "GVG_104a")]
# Piloted Sky Golem
class GVG_105:
def deathrattle(self):
return [Summon(CONTROLLER, randomCollectible(type=CardType.MINION, cost=4))]
# Junkbot
class GVG_106:
def OWN_MINION_DESTROY(self, minion):
if minion.race == Race.MECHANICAL:
return [Buff(SELF, "GVG_106e")]
# Enhance-o Mechano
class GVG_107:
def action(self):
for target in self.controller.field:
tag = random.choice((GameTag.WINDFURY, GameTag.TAUNT, GameTag.DIVINE_SHIELD))
yield SetTag(target, {tag: True})
|
Implement Piloted Sky Golem, Junkbot and Enhance-o Mechano
|
Implement Piloted Sky Golem, Junkbot and Enhance-o Mechano
|
Python
|
agpl-3.0
|
NightKev/fireplace,Ragowit/fireplace,liujimj/fireplace,Meerkov/fireplace,smallnamespace/fireplace,amw2104/fireplace,oftc-ftw/fireplace,beheh/fireplace,smallnamespace/fireplace,oftc-ftw/fireplace,butozerca/fireplace,Meerkov/fireplace,jleclanche/fireplace,amw2104/fireplace,butozerca/fireplace,Ragowit/fireplace,liujimj/fireplace
|
1d6984d31aaa87b5ed781e188b8b42221602cd3f
|
tests/conftest.py
|
tests/conftest.py
|
# -*- coding: utf-8 -*-
pytest_plugins = 'pytester'
|
# -*- coding: utf-8 -*-
import os
import warnings
import pytest
pytest_plugins = 'pytester'
@pytest.fixture(scope='session', autouse=True)
def verify_target_path():
import pytest_testdox
current_path_root = os.path.dirname(
os.path.dirname(os.path.realpath(__file__))
)
if current_path_root not in pytest_testdox.__file__:
warnings.warn(
'pytest-testdox was not imported from your repository. '
'You might be testing the wrong code '
'-- More: https://github.com/renanivo/pytest-testdox/issues/13',
UserWarning
)
|
Add warning on running repository's tests with pytest-testdox installed
|
Add warning on running repository's tests with pytest-testdox installed
Fix #13
|
Python
|
mit
|
renanivo/pytest-testdox
|
dc1cedc1720886dcc3c3bd3da02c7aff58e5eb90
|
tests/runTests.py
|
tests/runTests.py
|
import os
import os.path
import configparser
import shutil
import subprocess
# Setup
print("Setting up...")
if os.path.isfile("../halite.ini"):
shutil.copyfile("../halite.ini", "temp.ini")
shutil.copyfile("tests.ini", "../halite.ini")
parser = configparser.ConfigParser()
parser.read("../halite.ini")
# Website tests
print("Beginning website backend tests")
os.system("mysql -u "+parser["database"]["username"]+" -p"+parser["database"]["password"]+" < ../website/sql/Database.sql")
subprocess.call(["phpunit", "--stderr", "website/"])
# Environment tests.
print(subprocess.Popen('cd environment; python3 testenv.py', stdout=subprocess.PIPE, shell = True).stdout.read().decode('utf-8'))
# Tear down
print("Almost done...")
if os.path.isfile("../temp.ini"):
shutil.copyfile("temp.ini", "../halite.ini")
|
import os
import os.path
import configparser
import shutil
import subprocess
# Setup
print("Setting up...")
if os.path.isfile("../halite.ini"):
shutil.copyfile("../halite.ini", "temp.ini")
shutil.copyfile("tests.ini", "../halite.ini")
parser = configparser.ConfigParser()
parser.read("../halite.ini")
# Website tests
print("Beginning website backend tests")
passwordField = "" if parser["database"]["password"] == "" else "-p"+parser["database"]["password"]
os.system("mysql -u "+parser["database"]["username"]+" "+passwordField+" < ../website/sql/Database.sql")
subprocess.call(["phpunit", "--stderr", "website/"])
# Environment tests.
print(subprocess.Popen('cd environment; python3 testenv.py', stdout=subprocess.PIPE, shell = True).stdout.read().decode('utf-8'))
# Tear down
print("Almost done...")
if os.path.isfile("../temp.ini"):
shutil.copyfile("temp.ini", "../halite.ini")
|
Make test runner work with blank mysql password
|
Make test runner work with blank mysql password
|
Python
|
mit
|
HaliteChallenge/Halite,lanyudhy/Halite-II,HaliteChallenge/Halite-II,yangle/HaliteIO,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite-II,yangle/HaliteIO,yangle/HaliteIO,HaliteChallenge/Halite,lanyudhy/Halite-II,lanyudhy/Halite-II,HaliteChallenge/Halite-II,yangle/HaliteIO,HaliteChallenge/Halite,HaliteChallenge/Halite-II,lanyudhy/Halite-II,HaliteChallenge/Halite,yangle/HaliteIO,HaliteChallenge/Halite,HaliteChallenge/Halite-II,lanyudhy/Halite-II,lanyudhy/Halite-II,HaliteChallenge/Halite,lanyudhy/Halite-II,lanyudhy/Halite-II,yangle/HaliteIO,lanyudhy/Halite-II,HaliteChallenge/Halite-II,yangle/HaliteIO,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite-II,HaliteChallenge/Halite,yangle/HaliteIO,HaliteChallenge/Halite-II,HaliteChallenge/Halite,yangle/HaliteIO,yangle/HaliteIO,HaliteChallenge/Halite-II,yangle/HaliteIO,HaliteChallenge/Halite-II,HaliteChallenge/Halite-II,yangle/HaliteIO,lanyudhy/Halite-II,HaliteChallenge/Halite-II,lanyudhy/Halite-II,HaliteChallenge/Halite-II
|
a69e8d0d179f12fd42eadd85eca8e0c968d67c91
|
tests/runTests.py
|
tests/runTests.py
|
import os
import os.path
import configparser
import shutil
import subprocess
# Setup
print("Setting up...")
if os.path.isfile("../halite.ini"):
shutil.copyfile("../halite.ini", "temp.ini")
shutil.copyfile("tests.ini", "../halite.ini")
parser = configparser.ConfigParser()
parser.read("../halite.ini")
# Website tests
print("Beginning website backend tests")
os.system("mysql -u "+parser["database"]["username"]+" -p"+parser["database"]["password"]+" < ../website/sql/Database.sql")
subprocess.call(["phpunit", "--stderr", "website/"])
# Environment tests.
print(subprocess.Popen('cd environment; python3 testenv.py', stdout=subprocess.PIPE, shell = True).stdout.read().decode('utf-8'))
# Tear down
print("Almost done...")
if os.path.isfile("../temp.ini"):
shutil.copyfile("temp.ini", "../halite.ini")
|
import os
import os.path
import configparser
import shutil
import subprocess
# Setup
print("Setting up...")
if os.path.isfile("../halite.ini"):
shutil.copyfile("../halite.ini", "temp.ini")
shutil.copyfile("tests.ini", "../halite.ini")
parser = configparser.ConfigParser()
parser.read("../halite.ini")
# Website tests
print("Beginning website backend tests")
passwordField = "" if parser["database"]["password"] == "" else "-p"+parser["database"]["password"]
os.system("mysql -u "+parser["database"]["username"]+" "+passwordField+" < ../website/sql/Database.sql")
subprocess.call(["phpunit", "--stderr", "website/"])
# Environment tests.
print(subprocess.Popen('cd environment; python3 testenv.py', stdout=subprocess.PIPE, shell = True).stdout.read().decode('utf-8'))
# Tear down
print("Almost done...")
if os.path.isfile("../temp.ini"):
shutil.copyfile("temp.ini", "../halite.ini")
|
Make test runner work with blank mysql password
|
Make test runner work with blank mysql password
|
Python
|
mit
|
HaliteChallenge/Halite-II,yangle/HaliteIO,yangle/HaliteIO,HaliteChallenge/Halite,HaliteChallenge/Halite,yangle/HaliteIO,lanyudhy/Halite-II,HaliteChallenge/Halite-II,HaliteChallenge/Halite,yangle/HaliteIO,lanyudhy/Halite-II,HaliteChallenge/Halite-II,yangle/HaliteIO,lanyudhy/Halite-II,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite-II,lanyudhy/Halite-II,HaliteChallenge/Halite,lanyudhy/Halite-II,yangle/HaliteIO,lanyudhy/Halite-II,yangle/HaliteIO,HaliteChallenge/Halite-II,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite,lanyudhy/Halite-II,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite-II,yangle/HaliteIO,HaliteChallenge/Halite-II,yangle/HaliteIO,yangle/HaliteIO,yangle/HaliteIO,lanyudhy/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite-II,yangle/HaliteIO,HaliteChallenge/Halite-II,HaliteChallenge/Halite-II,HaliteChallenge/Halite,HaliteChallenge/Halite-II,lanyudhy/Halite-II,HaliteChallenge/Halite,lanyudhy/Halite-II,lanyudhy/Halite-II,HaliteChallenge/Halite-II
|
030de1eccb4819c175b2d8d43dc16c878bb689c9
|
engines/empy_engine.py
|
engines/empy_engine.py
|
#!/usr/bin/env python
"""Provide the empy templating engine."""
from __future__ import print_function
import em
from . import Engine
class EmpyEngine(Engine):
"""Empy templating engine."""
handle = 'empy'
def __init__(self, template, **kwargs):
"""Initialize empy template."""
super(EmpyEngine, self).__init__(**kwargs)
self.template = template
def apply(self, mapping):
"""Apply a mapping of name-value-pairs to a template."""
return em.expand(self.template, mapping)
|
#!/usr/bin/env python
"""Provide the empy templating engine."""
from __future__ import print_function
import os.path
import em
from . import Engine
class SubsystemWrapper(em.Subsystem):
"""Wrap EmPy's Subsystem class.
Allows to open files relative to a base directory.
"""
def __init__(self, basedir=None, **kwargs):
"""Initialize Subsystem plus a possible base directory."""
super(SubsystemWrapper, self).__init__(**kwargs)
self.basedir = basedir
def open(self, name, *args, **kwargs):
"""Open file, possibly relative to a base directory."""
if self.basedir is not None:
name = os.path.join(self.basedir, name)
return super(SubsystemWrapper, self).open(name, *args, **kwargs)
class EmpyEngine(Engine):
"""Empy templating engine."""
handle = 'empy'
def __init__(self, template, dirname=None, **kwargs):
"""Initialize empy template."""
super(EmpyEngine, self).__init__(**kwargs)
if dirname is not None:
# FIXME: This is a really bad idea, as it works like a global.
# Blame EmPy.
em.theSubsystem = SubsystemWrapper(basedir=dirname)
self.template = template
def apply(self, mapping):
"""Apply a mapping of name-value-pairs to a template."""
return em.expand(self.template, mapping)
|
Add base directory capability to empy engine.
|
Add base directory capability to empy engine.
|
Python
|
mit
|
blubberdiblub/eztemplate
|
7172962abf0d5d5aad02c632944ed8cb33ca9bae
|
django/books/admin.py
|
django/books/admin.py
|
from django.contrib import admin
from .models import Author, Book, Note, Tag, Section
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
list_display = ['name', 'goodreads_id']
prepopulated_fields = {'slug': ('name',), }
@admin.register(Section)
class SectionAdmin(admin.ModelAdmin):
list_display = ['title', 'subtitle', 'get_page_display', 'book']
list_filter = ['book']
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
list_display = ['title', 'slug']
@admin.register(Note)
class NoteAdmin(admin.ModelAdmin):
list_display = ['subject', 'section', 'book', 'get_page_display']
search_fields = ['subject', 'quote', 'comment']
@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
list_display = ['slug', 'description', 'colour']
|
from django.contrib import admin
from .models import Author, Book, Note, Tag, Section
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
list_display = ['name', 'goodreads_id']
prepopulated_fields = {'slug': ('name',), }
search_fields = ['name']
@admin.register(Section)
class SectionAdmin(admin.ModelAdmin):
list_display = ['title', 'subtitle', 'get_page_display', 'book']
list_filter = ['book']
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
list_display = ['title', 'slug']
@admin.register(Note)
class NoteAdmin(admin.ModelAdmin):
list_display = ['subject', 'section', 'book', 'get_page_display']
search_fields = ['subject', 'quote', 'comment']
@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
list_display = ['slug', 'description', 'colour']
|
Allow searching by name in AuthorAdmin
|
Allow searching by name in AuthorAdmin
|
Python
|
mit
|
dellsystem/bookmarker,dellsystem/bookmarker,dellsystem/bookmarker
|
23f404b61f2c9b89bb631ad0e60edf4416500f28
|
django_split/utils.py
|
django_split/utils.py
|
def overlapping(interval_a, interval_b):
al, ah = interval_a
bl, bh = interval_b
if al > ah:
raise ValueError("Interval A bounds are inverted")
if bl > bh:
raise ValueError("Interval B bounds are inverted")
return ah >= bl and bh >= al
|
from __future__ import division
import scipy
import scipy.stats
def overlapping(interval_a, interval_b):
al, ah = interval_a
bl, bh = interval_b
if al > ah:
raise ValueError("Interval A bounds are inverted")
if bl > bh:
raise ValueError("Interval B bounds are inverted")
return ah >= bl and bh >= al
def compute_normal_ppf(data_points):
mean, var = scipy.mean(data_points), scipy.var(data_points)
return scipy.stats.norm(mean, var).ppf
def compute_binomial_rate_ppf(hits, total):
if total == 0:
return lambda p: 0
distribution = scipy.binom((hits / total), total)
return lambda p: distribution.ppf(p) / total
def compute_poisson_daily_rate_ppf(start_date, end_date, hits):
days = (end_date - start_date).days
return scipy.poisson(hits / days).ppf
|
Add utilities for computing metrics
|
Add utilities for computing metrics
|
Python
|
mit
|
prophile/django_split
|
dd269cea5623450c3c608d10b8ddce1ae6c9e84a
|
project_one/project_one.py
|
project_one/project_one.py
|
# System imports first
import sys
# Module (local) imports
from import_data import import_data
from process import process_data, normalize, rotate_data
from output import plot_data
def main(argv=None):
""" Main function, executed when running 'project_one'. """
# Read the data
data = import_data('data.txt')
data = process_data(data)
# data = normalize(data)
# data = rotate_data(data)
plot_data(data)
# If we're being run with `python project_one.py`, execute main() and exit
# afterwards with the return value of main().
if __name__ == "__main__":
sys.exit(main())
|
# System imports first
import sys
import argparse
# Module (local) imports
from import_data import import_data
from process import process_data, normalize, rotate_data
from output import plot_data
def main(argv=None):
""" Main function, executed when running 'project_one'. """
# Parse command-line arguments, this allows the input to be
# configured from the command line.
parser = argparse.ArgumentParser(
description='Import, process and plot test data.'
)
parser.add_argument('data_file', type=str)
args = parser.parse_args(argv)
# Read the data
data = import_data(args.data_file)
data = process_data(data)
# data = normalize(data)
# data = rotate_data(data)
plot_data(data)
# If we're being run with `python project_one.py`, execute main() and exit
# afterwards with the return value of main().
if __name__ == "__main__":
sys.exit(main())
|
Use command-line argument to specify data.
|
Use command-line argument to specify data.
|
Python
|
bsd-3-clause
|
dokterbob/slf-project-one
|
2c05dba69c838cfd3808d8e03dbea3cc56d4f6d2
|
pyinfra_kubernetes/__init__.py
|
pyinfra_kubernetes/__init__.py
|
from .configure import configure_kubeconfig, configure_kubernetes_component
from .install import install_kubernetes
def deploy_kubernetes_master(etcd_nodes):
# Install server components
install_kubernetes(components=(
'kube-apiserver', 'kube-scheduler', 'kube-controller-manager',
))
# Configure the API server, passing in our etcd nodes
configure_kubernetes_component('kube-apiserver', etcd_nodes=etcd_nodes)
configure_kubernetes_component('kube-scheduler')
configure_kubernetes_component('kube-controller-manager')
def deploy_kubernetes_node(master_address):
# Install node components
install_kubernetes(components=(
'kubelet', 'kube-proxy',
))
# Setup the kubeconfig for kubelet & kube-proxy to use
configure_kubeconfig(master_address)
configure_kubernetes_component('kubelet')
configure_kubernetes_component('kube-proxy')
|
from pyinfra.api import deploy
from .configure import configure_kubeconfig, configure_kubernetes_component
from .install import install_kubernetes
@deploy('Deploy Kubernetes master')
def deploy_kubernetes_master(
state, host,
etcd_nodes,
):
# Install server components
install_kubernetes(components=(
'kube-apiserver', 'kube-scheduler', 'kube-controller-manager',
))
# Configure the API server, passing in our etcd nodes
configure_kubernetes_component('kube-apiserver', etcd_nodes=etcd_nodes)
configure_kubernetes_component('kube-scheduler')
configure_kubernetes_component('kube-controller-manager')
@deploy('Deploy Kubernetes node')
def deploy_kubernetes_node(
state, host,
master_address,
):
# Install node components
install_kubernetes(components=(
'kubelet', 'kube-proxy',
))
# Setup the kubeconfig for kubelet & kube-proxy to use
configure_kubeconfig(master_address)
configure_kubernetes_component('kubelet')
configure_kubernetes_component('kube-proxy')
|
Make helper functions full `@deploy`s so they support global pyinfra kwargs.
|
Make helper functions full `@deploy`s so they support global pyinfra kwargs.
|
Python
|
mit
|
EDITD/pyinfra-kubernetes,EDITD/pyinfra-kubernetes
|
de3f84934d86e48bf89822828df3eb9c3bd8e1e1
|
test/test_examples.py
|
test/test_examples.py
|
import glob
from libmproxy import utils, script
from libmproxy.proxy import config
import tservers
def test_load_scripts():
example_dir = utils.Data("libmproxy").path("../examples")
scripts = glob.glob("%s/*.py" % example_dir)
tmaster = tservers.TestMaster(config.ProxyConfig())
for f in scripts:
if "har_extractor" in f:
f += " -"
if "iframe_injector" in f:
f += " foo" # one argument required
if "modify_response_body" in f:
f += " foo bar" # two arguments required
s = script.Script(f, tmaster) # Loads the script file.
s.unload()
|
import glob
from libmproxy import utils, script
from libmproxy.proxy import config
import tservers
def test_load_scripts():
example_dir = utils.Data("libmproxy").path("../examples")
scripts = glob.glob("%s/*.py" % example_dir)
tmaster = tservers.TestMaster(config.ProxyConfig())
for f in scripts:
if "har_extractor" in f:
f += " -"
if "iframe_injector" in f:
f += " foo" # one argument required
if "modify_response_body" in f:
f += " foo bar" # two arguments required
try:
s = script.Script(f, tmaster) # Loads the script file.
except Exception, v:
if not "ImportError" in str(v):
raise
else:
s.unload()
|
Test suite should pass even if example dependencies are not present
|
Test suite should pass even if example dependencies are not present
|
Python
|
mit
|
ryoqun/mitmproxy,ryoqun/mitmproxy,xaxa89/mitmproxy,guiquanz/mitmproxy,ccccccccccc/mitmproxy,ADemonisis/mitmproxy,jpic/mitmproxy,pombredanne/mitmproxy,noikiy/mitmproxy,xaxa89/mitmproxy,fimad/mitmproxy,onlywade/mitmproxy,dxq-git/mitmproxy,inscriptionweb/mitmproxy,sethp-jive/mitmproxy,ParthGanatra/mitmproxy,cortesi/mitmproxy,byt3bl33d3r/mitmproxy,dufferzafar/mitmproxy,mhils/mitmproxy,owers19856/mitmproxy,zlorb/mitmproxy,fimad/mitmproxy,claimsmall/mitmproxy,sethp-jive/mitmproxy,tekii/mitmproxy,xaxa89/mitmproxy,ParthGanatra/mitmproxy,0xwindows/InfoLeak,ujjwal96/mitmproxy,vhaupert/mitmproxy,rauburtin/mitmproxy,Kriechi/mitmproxy,MatthewShao/mitmproxy,zlorb/mitmproxy,ccccccccccc/mitmproxy,elitest/mitmproxy,zbuc/mitmproxy,jpic/mitmproxy,StevenVanAcker/mitmproxy,rauburtin/mitmproxy,jvillacorta/mitmproxy,tdickers/mitmproxy,macmantrl/mitmproxy,ryoqun/mitmproxy,meizhoubao/mitmproxy,mosajjal/mitmproxy,pombredanne/mitmproxy,dufferzafar/mitmproxy,owers19856/mitmproxy,onlywade/mitmproxy,mitmproxy/mitmproxy,Fuzion24/mitmproxy,mitmproxy/mitmproxy,dweinstein/mitmproxy,vhaupert/mitmproxy,MatthewShao/mitmproxy,inscriptionweb/mitmproxy,dufferzafar/mitmproxy,devasia1000/mitmproxy,liorvh/mitmproxy,syjzwjj/mitmproxy,macmantrl/mitmproxy,0xwindows/InfoLeak,noikiy/mitmproxy,dweinstein/mitmproxy,ZeYt/mitmproxy,devasia1000/mitmproxy,dxq-git/mitmproxy,StevenVanAcker/mitmproxy,mitmproxy/mitmproxy,Kriechi/mitmproxy,inscriptionweb/mitmproxy,tekii/mitmproxy,laurmurclar/mitmproxy,ryoqun/mitmproxy,Endika/mitmproxy,cortesi/mitmproxy,vhaupert/mitmproxy,ikoz/mitmproxy,zbuc/mitmproxy,scriptmediala/mitmproxy,tfeagle/mitmproxy,guiquanz/mitmproxy,zbuc/mitmproxy,dwfreed/mitmproxy,guiquanz/mitmproxy,azureplus/mitmproxy,fimad/mitmproxy,azureplus/mitmproxy,mosajjal/mitmproxy,mosajjal/mitmproxy,onlywade/mitmproxy,meizhoubao/mitmproxy,claimsmall/mitmproxy,scriptmediala/mitmproxy,noikiy/mitmproxy,xbzbing/mitmproxy,Fuzion24/mitmproxy,zlorb/mitmproxy,dxq-git/mitmproxy,ikoz/mitmproxy,Endika/mitmproxy,MatthewShao/mitmproxy,zbuc/mitmproxy,liorvh/mitmproxy,Kriechi/mitmproxy,fimad/mitmproxy,bazzinotti/mitmproxy,meizhoubao/mitmproxy,ikoz/mitmproxy,tdickers/mitmproxy,tfeagle/mitmproxy,syjzwjj/mitmproxy,gzzhanghao/mitmproxy,scriptmediala/mitmproxy,gzzhanghao/mitmproxy,bazzinotti/mitmproxy,tfeagle/mitmproxy,ddworken/mitmproxy,dweinstein/mitmproxy,mhils/mitmproxy,mitmproxy/mitmproxy,byt3bl33d3r/mitmproxy,Fuzion24/mitmproxy,Kriechi/mitmproxy,dxq-git/mitmproxy,dwfreed/mitmproxy,owers19856/mitmproxy,legendtang/mitmproxy,tdickers/mitmproxy,liorvh/mitmproxy,byt3bl33d3r/mitmproxy,macmantrl/mitmproxy,ujjwal96/mitmproxy,pombredanne/mitmproxy,mhils/mitmproxy,onlywade/mitmproxy,mosajjal/mitmproxy,ddworken/mitmproxy,ADemonisis/mitmproxy,legendtang/mitmproxy,dwfreed/mitmproxy,ccccccccccc/mitmproxy,meizhoubao/mitmproxy,ccccccccccc/mitmproxy,ADemonisis/mitmproxy,syjzwjj/mitmproxy,sethp-jive/mitmproxy,tekii/mitmproxy,Endika/mitmproxy,xbzbing/mitmproxy,byt3bl33d3r/mitmproxy,liorvh/mitmproxy,devasia1000/mitmproxy,gzzhanghao/mitmproxy,jvillacorta/mitmproxy,syjzwjj/mitmproxy,xaxa89/mitmproxy,scriptmediala/mitmproxy,sethp-jive/mitmproxy,bazzinotti/mitmproxy,legendtang/mitmproxy,dweinstein/mitmproxy,xbzbing/mitmproxy,bazzinotti/mitmproxy,0xwindows/InfoLeak,jpic/mitmproxy,ikoz/mitmproxy,mhils/mitmproxy,xbzbing/mitmproxy,gzzhanghao/mitmproxy,Fuzion24/mitmproxy,rauburtin/mitmproxy,noikiy/mitmproxy,elitest/mitmproxy,claimsmall/mitmproxy,jvillacorta/mitmproxy,ujjwal96/mitmproxy,elitest/mitmproxy,ujjwal96/mitmproxy,StevenVanAcker/mitmproxy,pombredanne/mitmproxy,tdickers/mitmproxy,jpic/mitmproxy,laurmurclar/mitmproxy,0xwindows/InfoLeak,tfeagle/mitmproxy,owers19856/mitmproxy,laurmurclar/mitmproxy,mitmproxy/mitmproxy,macmantrl/mitmproxy,tekii/mitmproxy,mhils/mitmproxy,ZeYt/mitmproxy,StevenVanAcker/mitmproxy,ParthGanatra/mitmproxy,azureplus/mitmproxy,Endika/mitmproxy,ZeYt/mitmproxy,MatthewShao/mitmproxy,ZeYt/mitmproxy,rauburtin/mitmproxy,laurmurclar/mitmproxy,ddworken/mitmproxy,claimsmall/mitmproxy,ParthGanatra/mitmproxy,vhaupert/mitmproxy,devasia1000/mitmproxy,ddworken/mitmproxy,cortesi/mitmproxy,dufferzafar/mitmproxy,ADemonisis/mitmproxy,legendtang/mitmproxy,dwfreed/mitmproxy,zlorb/mitmproxy,jvillacorta/mitmproxy,inscriptionweb/mitmproxy,azureplus/mitmproxy,cortesi/mitmproxy,elitest/mitmproxy,guiquanz/mitmproxy
|
92d7a3cf2ec3ae669fab17906b10b784525a134a
|
pyinduct/tests/__init__.py
|
pyinduct/tests/__init__.py
|
# -*- coding: utf-8 -*-
import sys
if any([arg in {'discover', 'setup.py', 'test'} for arg in sys.argv]):
test_examples = True
test_all_examples = False
show_plots = False
elif any(['sphinx-build' in arg for arg in sys.argv]):
test_examples = False
test_all_examples = False
show_plots = False
else:
test_examples = True
test_all_examples = True
show_plots = True
# Do not want to see plots or test all examples while test run?
# Then force it and uncomment the respective line:
# test_all_examples = False
show_plots = False
|
# -*- coding: utf-8 -*-
import sys
if any([arg in {'discover', 'setup.py', 'test'} for arg in sys.argv]):
test_examples = True
test_all_examples = False
show_plots = False
elif any(['sphinx-build' in arg for arg in sys.argv]):
test_examples = False
test_all_examples = False
show_plots = False
else:
test_examples = True
test_all_examples = True
show_plots = True
# Do not want to see plots or test all examples while test run?
# Then force it and uncomment the respective line:
# test_all_examples = False
# show_plots = False
|
Revert commit of local changes
|
Revert commit of local changes
|
Python
|
bsd-3-clause
|
cklb/pyinduct,riemarc/pyinduct,pyinduct/pyinduct
|
c55243d591793a9213d27126a3c240bb47c5f82b
|
cartoframes/core/cartodataframe.py
|
cartoframes/core/cartodataframe.py
|
from geopandas import GeoDataFrame
from ..utils.geom_utils import generate_index, generate_geometry
class CartoDataFrame(GeoDataFrame):
def __init__(self, *args, **kwargs):
super(CartoDataFrame, self).__init__(*args, **kwargs)
@staticmethod
def from_carto(*args, **kwargs):
from ..io.carto import read_carto
return read_carto(*args, **kwargs)
@classmethod
def from_file(cls, filename, **kwargs):
gdf = GeoDataFrame.from_file(filename, **kwargs)
return cls(gdf)
@classmethod
def from_features(cls, features, **kwargs):
gdf = GeoDataFrame.from_features(features, **kwargs)
return cls(gdf)
def to_carto(self, *args, **kwargs):
from ..io.carto import to_carto
return to_carto(self, *args, **kwargs)
def convert(self, index_column=None, geom_column=None, lnglat_columns=None,
drop_index=True, drop_geom=True, drop_lnglat=True):
# Magic function
generate_index(self, index_column, drop_index)
generate_geometry(self, geom_column, lnglat_columns, drop_geom, drop_lnglat)
return self
def visualize(self, *args, **kwargs):
from ..viz import Map, Layer
return Map(Layer(self, *args, **kwargs))
viz = visualize
|
from geopandas import GeoDataFrame
from ..utils.geom_utils import generate_index, generate_geometry
class CartoDataFrame(GeoDataFrame):
def __init__(self, *args, **kwargs):
super(CartoDataFrame, self).__init__(*args, **kwargs)
@staticmethod
def from_carto(*args, **kwargs):
from ..io.carto import read_carto
return read_carto(*args, **kwargs)
@classmethod
def from_file(cls, filename, **kwargs):
gdf = GeoDataFrame.from_file(filename, **kwargs)
return cls(gdf)
@classmethod
def from_features(cls, features, **kwargs):
gdf = GeoDataFrame.from_features(features, **kwargs)
return cls(gdf)
def to_carto(self, *args, **kwargs):
from ..io.carto import to_carto
return to_carto(self, *args, **kwargs)
def convert(self, index_column=None, geom_column=None, lnglat_columns=None,
drop_index=True, drop_geom=True, drop_lnglat=True):
# Magic function
generate_index(self, index_column, drop_index)
generate_geometry(self, geom_column, lnglat_columns, drop_geom, drop_lnglat)
return self
def viz(self, *args, **kwargs):
from ..viz import Map, Layer
return Map(Layer(self, *args, **kwargs))
|
Rename visualize to viz in CDF
|
Rename visualize to viz in CDF
|
Python
|
bsd-3-clause
|
CartoDB/cartoframes,CartoDB/cartoframes
|
a0a98f374a66093ad3c35a2e185ac9b48d8b3f2d
|
lib/reinteract/__init__.py
|
lib/reinteract/__init__.py
|
import gobject
# https://bugzilla.gnome.org/show_bug.cgi?id=644039
def fixed_default_setter(self, instance, value):
setattr(instance, '_property_helper_'+self.name, value)
def fixed_default_getter(self, instance):
return getattr(instance, '_property_helper_'+self.name, self.default)
def monkey_patch_gobject_property():
p = gobject.property()
if hasattr(p, '_values'):
gobject.propertyhelper.property._default_setter = fixed_default_setter
gobject.propertyhelper.property._default_getter = fixed_default_getter
monkey_patch_gobject_property()
|
Work around leak in older pygobject
|
Work around leak in older pygobject
With older pygobject, any use of the default getter/setters
generated by gobject.property() would leak. If we detect this
is the case, monkey patch in the fixed version of the default
getters/setters.
(See https://bugzilla.gnome.org/show_bug.cgi?id=644039)
|
Python
|
bsd-2-clause
|
alexey4petrov/reinteract,alexey4petrov/reinteract,alexey4petrov/reinteract
|
|
a2aa2ea452c7fb2f3a83a13f000a51223cb3d13f
|
client/sources/doctest/__init__.py
|
client/sources/doctest/__init__.py
|
from client.sources.common import importing
from client.sources.doctest import models
import logging
import os
log = logging.getLogger(__name__)
def load(file, name, args):
"""Loads doctests from a specified filepath.
PARAMETERS:
file -- str; a filepath to a Python module containing OK-style
tests.
RETURNS:
Test
"""
if not os.path.isfile(file) or not file.endswith('.py'):
log.info('Cannot import doctests from {}'.format(file))
# TODO(albert): raise appropriate error
raise Exception
module = importing.load_module(file)
if not hasattr(module, name):
# TODO(albert): raise appropriate error
raise Exception
func = getattr(module, name)
if not callable(func):
# TODO(albert): raise appropriate error
raise Exception
return models.Doctest(file, args.verbose, args.interactive, args.timeout,
name=name, points=1, docstring=func.__doc__)
|
from client.sources.common import importing
from client.sources.doctest import models
import logging
import os
log = logging.getLogger(__name__)
def load(file, name, args):
"""Loads doctests from a specified filepath.
PARAMETERS:
file -- str; a filepath to a Python module containing OK-style
tests.
RETURNS:
Test
"""
if not os.path.isfile(file) or not file.endswith('.py'):
log.info('Cannot import doctests from {}'.format(file))
# TODO(albert): raise appropriate error
raise Exception('Cannot import doctests from {}'.format(file))
module = importing.load_module(file)
if not hasattr(module, name):
# TODO(albert): raise appropriate error
raise Exception('Module {} has no function {}'.format(module.__name__, name))
func = getattr(module, name)
if not callable(func):
# TODO(albert): raise appropriate error
raise Exception
return models.Doctest(file, args.verbose, args.interactive, args.timeout,
name=name, points=1, docstring=func.__doc__)
|
Add a few exception strings
|
Add a few exception strings
|
Python
|
apache-2.0
|
jackzhao-mj/ok-client,Cal-CS-61A-Staff/ok-client,jathak/ok-client
|
fc5ae93998045f340e44e267f409a7bdf534c756
|
website_slides/__init__.py
|
website_slides/__init__.py
|
# -*- coding: utf-8 -*-
# ##############################################################################
#
# Odoo, Open Source Management Solution
# Copyright (C) 2014-TODAY Odoo SA (<https://www.odoo.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import controllers
import models
|
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import controllers
import models
|
Use global LICENSE/COPYRIGHT files, remove boilerplate text
|
[LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate text
- Preserved explicit 3rd-party copyright notices
- Explicit boilerplate should not be necessary - copyright law applies
automatically in all countries thanks to Berne Convention + WTO rules,
and a reference to the applicable license is clear enough.
|
Python
|
agpl-3.0
|
Endika/website,Yajo/website,kaerdsar/website,brain-tec/website,kaerdsar/website,gfcapalbo/website,pedrobaeza/website,Antiun/website,open-synergy/website,LasLabs/website,open-synergy/website,brain-tec/website,nuobit/website,acsone/website,nuobit/website,xpansa/website,acsone/website,Antiun/website,Antiun/website,pedrobaeza/website,LasLabs/website,brain-tec/website,gfcapalbo/website,Endika/website,Endika/website,pedrobaeza/website,pedrobaeza/website,gfcapalbo/website,Yajo/website,nuobit/website,brain-tec/website,Endika/website,open-synergy/website,acsone/website,xpansa/website,kaerdsar/website,xpansa/website,Antiun/website,nuobit/website,xpansa/website,Yajo/website,LasLabs/website,acsone/website,open-synergy/website,gfcapalbo/website,LasLabs/website,Yajo/website
|
ee6f71ba0e548fdb08a3f1b065cd081b2431caa6
|
lc0222_count_complete_tree_nodes.py
|
lc0222_count_complete_tree_nodes.py
|
"""Leetcode 222. Count Complete Tree Nodes
Medium
URL: https://leetcode.com/problems/count-complete-tree-nodes/
Given a complete binary tree, count the number of nodes.
Note:
Definition of a complete binary tree from Wikipedia:
In a complete binary tree every level, except possibly the last,
is completely filled, and all nodes in the last level are as far left as
possible. It can have between 1 and 2h nodes inclusive at the last level h.
Example:
Input:
1
/ \
2 3
/ \ /
4 5 6
Output: 6
"""
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class Solution(object):
def countNodes(self, root):
"""
:type root: TreeNode
:rtype: int
"""
pass
def main():
pass
if __name__ == '__main__':
main()
|
"""Leetcode 222. Count Complete Tree Nodes
Medium
URL: https://leetcode.com/problems/count-complete-tree-nodes/
Given a complete binary tree, count the number of nodes.
Note:
Definition of a complete binary tree from Wikipedia:
In a complete binary tree every level, except possibly the last,
is completely filled, and all nodes in the last level are as far left as
possible. It can have between 1 and 2h nodes inclusive at the last level h.
Example:
Input:
1
/ \
2 3
/ \ /
4 5 6
Output: 6
"""
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class SolutionPreorderRecur(object):
def _preorder(self, root):
if not root:
return None
self.n_nodes += 1
self._preorder(root.left)
self._preorder(root.right)
def countNodes(self, root):
"""
:type root: TreeNode
:rtype: int
Time complexity: O(n).
Space complexity: O(1).
"""
self.n_nodes = 0
self._preorder(root)
return self.n_nodes
def main():
# Input:
# 1
# / \
# 2 3
# / \ /
# 4 5 6
# Output: 6
root = TreeNode(1)
root.left = TreeNode(2)
root.right = TreeNode(3)
root.left.left = TreeNode(4)
root.left.right = TreeNode(5)
root.right.left = TreeNode(6)
print SolutionPreorderRecur().countNodes(root)
if __name__ == '__main__':
main()
|
Complete preorder recur sol w/ time/space complexity
|
Complete preorder recur sol w/ time/space complexity
|
Python
|
bsd-2-clause
|
bowen0701/algorithms_data_structures
|
8c819a1cb9df54c00b7246a07e2ba832b763876d
|
stream_django/templatetags/activity_tags.py
|
stream_django/templatetags/activity_tags.py
|
from django import template
from django.template import Context, loader
from stream_django.exceptions import MissingDataException
import logging
logger = logging.getLogger(__name__)
register = template.Library()
LOG = 'warn'
IGNORE = 'ignore'
FAIL = 'fail'
missing_data_policies = [LOG, IGNORE, FAIL]
def handle_not_enriched_data(activity, policy):
message = 'could not enrich field(s) %r for activity #%s' % (activity.not_enriched_data, activity.get('id'))
if policy == IGNORE:
pass
elif policy == FAIL:
raise MissingDataException(message)
elif policy == LOG:
logger.warn(message)
else:
raise TypeError('%s is not a valid missing_data_policy' % policy)
def render_activity(context, activity, template_prefix='', missing_data_policy=LOG):
if hasattr(activity, 'enriched') and not activity.enriched:
handle_not_enriched_data(activity, missing_data_policy)
return ''
if template_prefix != '':
template_prefix = '%s_' % template_prefix
if 'activities' in activity:
template_name = "activity/aggregated/%s%s.html" % (template_prefix, activity['verb'])
else:
template_name = "activity/%s%s.html" % (template_prefix, activity['verb'])
tmpl = loader.get_template(template_name)
context['activity'] = activity
context = Context(context)
return tmpl.render(context)
register.simple_tag(takes_context=True)(render_activity)
|
from django import template
from django.template import loader
from stream_django.exceptions import MissingDataException
import logging
logger = logging.getLogger(__name__)
register = template.Library()
LOG = 'warn'
IGNORE = 'ignore'
FAIL = 'fail'
missing_data_policies = [LOG, IGNORE, FAIL]
def handle_not_enriched_data(activity, policy):
message = 'could not enrich field(s) %r for activity #%s' % (activity.not_enriched_data, activity.get('id'))
if policy == IGNORE:
pass
elif policy == FAIL:
raise MissingDataException(message)
elif policy == LOG:
logger.warn(message)
else:
raise TypeError('%s is not a valid missing_data_policy' % policy)
def render_activity(context, activity, template_prefix='', missing_data_policy=LOG):
if hasattr(activity, 'enriched') and not activity.enriched:
handle_not_enriched_data(activity, missing_data_policy)
return ''
if template_prefix != '':
template_prefix = '%s_' % template_prefix
if 'activities' in activity:
template_name = "activity/aggregated/%s%s.html" % (template_prefix, activity['verb'])
else:
template_name = "activity/%s%s.html" % (template_prefix, activity['verb'])
tmpl = loader.get_template(template_name)
context['activity'] = activity
return tmpl.render(context)
register.simple_tag(takes_context=True)(render_activity)
|
Use dict as a context object for Django 1.11 compatibility
|
Use dict as a context object for Django 1.11 compatibility
Django’s template rendering in 1.11 needs a dictionary as the context
instead of the object Context, otherwise the following error is raised:
context must be a dict rather than Context.
|
Python
|
bsd-3-clause
|
GetStream/stream-django,GetStream/stream-django
|
6727bb98c91f1185042d08f3ff2a4c5ef625cae4
|
mjstat/languages/__init__.py
|
mjstat/languages/__init__.py
|
# -*- coding: utf-8 -*-
"""__init__.py: Language-dependent features.
"""
module_cache = {}
def get_language(lang_code):
"""Return module with language localizations.
This is a poor copy of the language framework of Docutils.
"""
if lang_code in module_cache:
return module_cache[lang_code]
for i in (1, 0):
try:
module = __import__(lang_code, globals(), locals(), level=i)
break
except ImportError:
continue
else:
module = __import__('en', globals(), locals(), level=1)
module_cache[lang_code] = module
return module
|
# -*- coding: utf-8 -*-
"""__init__.py: Language-dependent features.
"""
from importlib import import_module
module_cache = {}
def get_language(lang_code):
"""Return module with language localizations.
This is a revamped version of function docutils.languages.get_language.
"""
if lang_code in module_cache:
return module_cache[lang_code]
try:
module = import_module('.' + lang_code, __name__)
except ImportError:
from . import en
module = en
module_cache[lang_code] = module
return module
|
Use importlib.import_module instead of built-in __import__.
|
Use importlib.import_module instead of built-in __import__.
|
Python
|
mit
|
showa-yojyo/bin,showa-yojyo/bin
|
030d425bb2b9b552516957277aebb22806bfc699
|
bills/redis_queue.py
|
bills/redis_queue.py
|
# -*- coding: utf-8 -*-
import redis
class RedisQueue(object):
"""Simple Queue with Redis Backend"""
def __init__(self, name, namespace='queue', **redis_kwargs):
"""The default connection parameters are: host='localhost', port=6379, db=0"""
self.db = redis.Redis(**redis_kwargs)
self.key = '%s:%s' %(namespace, name)
def qsize(self):
"""Return the approximate size of the queue."""
return self.db.llen(self.key)
def empty(self):
"""Return True if the queue is empty, False otherwise."""
return self.qsize() == 0
def put(self, item):
"""Put item into the queue."""
self.db.rpush(self.key, item)
def get(self, block=True, timeout=None):
"""Remove and return an item from the queue.
If optional args block is true and timeout is None (the default), block
if necessary until an item is available."""
if block:
item = self.db.blpop(self.key, timeout=timeout)
else:
item = self.db.lpop(self.key)
if item:
item = item[1]
return item
def get_nowait(self):
"""Equivalent to get(False)."""
return self.get(False)
def __iter__(self):
return self
def next(self):
item = self.get(False)
if item is None:
raise StopIteration
return item
|
# -*- coding: utf-8 -*-
import redis
class RedisQueue(object):
"""Simple Queue with Redis Backend"""
def __init__(self, name, namespace='queue', **redis_kwargs):
"""The default connection parameters are: host='localhost', port=6379, db=0"""
self.db = redis.Redis(**redis_kwargs)
self.key = '%s:%s' %(namespace, name)
def qsize(self):
"""Return the approximate size of the queue."""
return self.db.llen(self.key)
def empty(self):
"""Return True if the queue is empty, False otherwise."""
return self.qsize() == 0
def put(self, item):
"""Put item into the queue."""
self.db.rpush(self.key, item)
def get(self, block=True, timeout=None):
"""Remove and return an item from the queue.
If optional args block is true and timeout is None (the default), block
if necessary until an item is available."""
if block:
item = self.db.blpop(self.key, timeout=timeout)
if item:
item = item[1]
else:
item = self.db.lpop(self.key)
return item
def get_nowait(self):
"""Equivalent to get(False)."""
return self.get(False)
def __iter__(self):
return self
def next(self):
item = self.get(False)
if item is None:
raise StopIteration
return item
|
Fix a bug in redis queue
|
Fix a bug in redis queue
|
Python
|
agpl-3.0
|
teampopong/crawlers,majorika/crawlers,majorika/crawlers,lexifdev/crawlers,lexifdev/crawlers,teampopong/crawlers
|
6a1d9a327ebf64acba9bd02330bfa047e8137337
|
bmi_live/__init__.py
|
bmi_live/__init__.py
|
"""BMI Live clinic"""
import os
pkg_directory = os.path.dirname(__file__)
data_directory = os.path.join(pkg_directory, 'data')
|
"""BMI Live clinic"""
import os
from .diffusion import Diffusion
from .bmi_diffusion import BmiDiffusion
__all__ = ['Diffusion', 'BmiDiffusion']
pkg_directory = os.path.dirname(__file__)
data_directory = os.path.join(pkg_directory, 'data')
|
Include classes in package definition
|
Include classes in package definition
|
Python
|
mit
|
csdms/bmi-live,csdms/bmi-live
|
1648e071fe69ba159261f27e4b2d0e2b977d6d83
|
zou/app/models/working_file.py
|
zou/app/models/working_file.py
|
from sqlalchemy_utils import UUIDType
from zou.app import db
from zou.app.models.serializer import SerializerMixin
from zou.app.models.base import BaseMixin
class WorkingFile(db.Model, BaseMixin, SerializerMixin):
shotgun_id = db.Column(db.Integer())
name = db.Column(db.String(250))
description = db.Column(db.String(200))
comment = db.Column(db.Text())
revision = db.Column(db.Integer())
size = db.Column(db.Integer())
checksum = db.Column(db.Integer())
task_id = db.Column(UUIDType(binary=False), db.ForeignKey("task.id"))
entity_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"))
person_id = \
db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))
__table_args__ = (
db.UniqueConstraint(
"name",
"task_id",
"entity_id",
"revision",
name="working_file_uc"
),
)
def __repr__(self):
return "<WorkingFile %s>" % self.id
|
from sqlalchemy.orm import relationship
from sqlalchemy_utils import UUIDType
from zou.app import db
from zou.app.models.serializer import SerializerMixin
from zou.app.models.base import BaseMixin
class WorkingFile(db.Model, BaseMixin, SerializerMixin):
shotgun_id = db.Column(db.Integer())
name = db.Column(db.String(250))
description = db.Column(db.String(200))
comment = db.Column(db.Text())
revision = db.Column(db.Integer())
size = db.Column(db.Integer())
checksum = db.Column(db.Integer())
path = db.Column(db.String(400))
task_id = db.Column(UUIDType(binary=False), db.ForeignKey("task.id"))
entity_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"))
person_id = \
db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))
software_id = \
db.Column(UUIDType(binary=False), db.ForeignKey("software.id"))
outputs = relationship(
"OutputFile",
back_populates="source_file"
)
__table_args__ = (
db.UniqueConstraint(
"name",
"task_id",
"entity_id",
"revision",
name="working_file_uc"
),
)
def __repr__(self):
return "<WorkingFile %s>" % self.id
|
Add fields to working file model
|
Add fields to working file model
* Software
* List of output files generated
* Path used to store the working file
|
Python
|
agpl-3.0
|
cgwire/zou
|
afb195b1ca647d776f29fbc1d68a495190caec59
|
astropy/time/setup_package.py
|
astropy/time/setup_package.py
|
import os
import numpy
from distutils.extension import Extension
TIMEROOT = os.path.relpath(os.path.dirname(__file__))
def get_extensions():
time_ext = Extension(
name="astropy.time.sofa_time",
sources=[os.path.join(TIMEROOT, "sofa_time.pyx"), "cextern/sofa/sofa.c"],
include_dirs=[numpy.get_include(), 'cextern/sofa'],
language="c",)
return [time_ext]
|
import os
from distutils.extension import Extension
TIMEROOT = os.path.relpath(os.path.dirname(__file__))
def get_extensions():
time_ext = Extension(
name="astropy.time.sofa_time",
sources=[os.path.join(TIMEROOT, "sofa_time.pyx"), "cextern/sofa/sofa.c"],
include_dirs=['numpy', 'cextern/sofa'],
language="c",)
return [time_ext]
|
Fix remaining include_dirs that imported numpy ('numpy' gets replaced at build-time). This is necessary for egg_info to work.
|
Fix remaining include_dirs that imported numpy ('numpy' gets replaced at build-time). This is necessary for egg_info to work.
|
Python
|
bsd-3-clause
|
kelle/astropy,AustereCuriosity/astropy,joergdietrich/astropy,stargaser/astropy,astropy/astropy,bsipocz/astropy,bsipocz/astropy,kelle/astropy,larrybradley/astropy,StuartLittlefair/astropy,DougBurke/astropy,mhvk/astropy,stargaser/astropy,aleksandr-bakanov/astropy,tbabej/astropy,dhomeier/astropy,lpsinger/astropy,DougBurke/astropy,astropy/astropy,funbaker/astropy,pllim/astropy,pllim/astropy,tbabej/astropy,dhomeier/astropy,aleksandr-bakanov/astropy,larrybradley/astropy,MSeifert04/astropy,pllim/astropy,DougBurke/astropy,DougBurke/astropy,AustereCuriosity/astropy,lpsinger/astropy,mhvk/astropy,funbaker/astropy,bsipocz/astropy,astropy/astropy,funbaker/astropy,lpsinger/astropy,saimn/astropy,saimn/astropy,astropy/astropy,AustereCuriosity/astropy,MSeifert04/astropy,joergdietrich/astropy,dhomeier/astropy,MSeifert04/astropy,larrybradley/astropy,kelle/astropy,saimn/astropy,mhvk/astropy,tbabej/astropy,kelle/astropy,kelle/astropy,joergdietrich/astropy,astropy/astropy,joergdietrich/astropy,dhomeier/astropy,larrybradley/astropy,aleksandr-bakanov/astropy,bsipocz/astropy,stargaser/astropy,saimn/astropy,mhvk/astropy,funbaker/astropy,stargaser/astropy,dhomeier/astropy,pllim/astropy,AustereCuriosity/astropy,pllim/astropy,StuartLittlefair/astropy,StuartLittlefair/astropy,mhvk/astropy,StuartLittlefair/astropy,saimn/astropy,joergdietrich/astropy,aleksandr-bakanov/astropy,StuartLittlefair/astropy,larrybradley/astropy,lpsinger/astropy,tbabej/astropy,AustereCuriosity/astropy,MSeifert04/astropy,lpsinger/astropy,tbabej/astropy
|
55d22f95301c4c96c42e30fa037df5bc957dc7b4
|
incunafein/module/page/extensions/prepared_date.py
|
incunafein/module/page/extensions/prepared_date.py
|
from django.db import models
def register(cls, admin_cls):
cls.add_to_class('prepared_date', models.TextField('Date of Preparation', blank=True, null=True))
|
from django.db import models
def get_prepared_date(cls):
return cls.prepared_date or cls.parent.prepared_date
def register(cls, admin_cls):
cls.add_to_class('prepared_date', models.TextField('Date of Preparation', blank=True, null=True))
cls.add_to_class('get_prepared_date', get_prepared_date)
|
Add a get prepared date method
|
Add a get prepared date method
Child pages won't necessarily have a prepared date and it makes sense to
use the parent date to avoid repetition.
|
Python
|
bsd-2-clause
|
incuna/incuna-feincms,incuna/incuna-feincms,incuna/incuna-feincms
|
0fdb33dc0da1aa953e91e71b0e0cfa75fca3d639
|
skylines/views/__init__.py
|
skylines/views/__init__.py
|
from flask import redirect
from skylines import app
import skylines.views.i18n
import skylines.views.login
import skylines.views.search
from skylines.views.about import about_blueprint
from skylines.views.api import api_blueprint
from skylines.views.flights import flights_blueprint
from skylines.views.notifications import notifications_blueprint
from skylines.views.ranking import ranking_blueprint
from skylines.views.statistics import statistics_blueprint
from skylines.views.upload import upload_blueprint
from skylines.views.users import users_blueprint
app.register_blueprint(about_blueprint, url_prefix='/about')
app.register_blueprint(api_blueprint, url_prefix='/api')
app.register_blueprint(flights_blueprint, url_prefix='/flights')
app.register_blueprint(notifications_blueprint, url_prefix='/notifications')
app.register_blueprint(ranking_blueprint, url_prefix='/ranking')
app.register_blueprint(statistics_blueprint, url_prefix='/statistics')
app.register_blueprint(upload_blueprint, url_prefix='/flights/upload')
app.register_blueprint(users_blueprint, url_prefix='/users')
@app.route('/')
def index():
return redirect('/flights/latest')
|
from flask import redirect, url_for
from skylines import app
import skylines.views.i18n
import skylines.views.login
import skylines.views.search
from skylines.views.about import about_blueprint
from skylines.views.api import api_blueprint
from skylines.views.flights import flights_blueprint
from skylines.views.notifications import notifications_blueprint
from skylines.views.ranking import ranking_blueprint
from skylines.views.statistics import statistics_blueprint
from skylines.views.upload import upload_blueprint
from skylines.views.users import users_blueprint
app.register_blueprint(about_blueprint, url_prefix='/about')
app.register_blueprint(api_blueprint, url_prefix='/api')
app.register_blueprint(flights_blueprint, url_prefix='/flights')
app.register_blueprint(notifications_blueprint, url_prefix='/notifications')
app.register_blueprint(ranking_blueprint, url_prefix='/ranking')
app.register_blueprint(statistics_blueprint, url_prefix='/statistics')
app.register_blueprint(upload_blueprint, url_prefix='/flights/upload')
app.register_blueprint(users_blueprint, url_prefix='/users')
@app.route('/')
def index():
return redirect(url_for('flights.latest'))
|
Use url_for for base redirection
|
views: Use url_for for base redirection
|
Python
|
agpl-3.0
|
shadowoneau/skylines,Turbo87/skylines,snip/skylines,shadowoneau/skylines,Harry-R/skylines,TobiasLohner/SkyLines,RBE-Avionik/skylines,RBE-Avionik/skylines,kerel-fs/skylines,Turbo87/skylines,snip/skylines,kerel-fs/skylines,skylines-project/skylines,RBE-Avionik/skylines,TobiasLohner/SkyLines,skylines-project/skylines,RBE-Avionik/skylines,skylines-project/skylines,Harry-R/skylines,Turbo87/skylines,Harry-R/skylines,Turbo87/skylines,kerel-fs/skylines,shadowoneau/skylines,skylines-project/skylines,shadowoneau/skylines,TobiasLohner/SkyLines,snip/skylines,Harry-R/skylines
|
217829993e108fb4f5c17ae2bbc80151418cf733
|
Mobiles_Stadtgedaechtnis/urls.py
|
Mobiles_Stadtgedaechtnis/urls.py
|
from django.conf.urls import patterns, include, url
import stadtgedaechtnis_backend.admin
import settings
from thread import start_new_thread
js_info_dict = {
'packages': ('stadtgedaechtnis_backend',),
}
urlpatterns = patterns(
'',
url(r'^', include('stadtgedaechtnis_backend.urls', namespace="stadtgedaechtnis_backend")),
url(r'^', include('stadtgedaechtnis_frontend.urls', namespace="stadtgedaechtnis_frontend")),
url(r'^admin/', include(stadtgedaechtnis_backend.admin.site.urls)),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, }),
)
def run_cronjobs():
"""
Runs the cronjobs. Needs to be called in a seperate thread or the main thread will be blocked.
:return:
"""
import schedule
import time
from stadtgedaechtnis_backend.import_entries.importers import do_silent_json_import
from stadtgedaechtnis_backend.import_entries.urls import JSON_URL
schedule.every().day.at("23:00").do(do_silent_json_import, JSON_URL)
while True:
schedule.run_pending()
time.sleep(1)
start_new_thread(run_cronjobs, [])
|
from django.conf.urls import patterns, include, url
import stadtgedaechtnis_backend.admin
import settings
from thread import start_new_thread
js_info_dict = {
'packages': ('stadtgedaechtnis_backend',),
}
urlpatterns = patterns(
'',
url(r'^', include('stadtgedaechtnis_backend.urls', namespace="stadtgedaechtnis_backend")),
url(r'^', include('stadtgedaechtnis_frontend.urls', namespace="stadtgedaechtnis_frontend")),
url(r'^admin/', include(stadtgedaechtnis_backend.admin.site.urls)),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, }),
)
def run_cronjobs():
"""
Runs the cronjobs. Needs to be called in a seperate thread or the main thread will be blocked.
:return:
"""
import schedule
import time
from stadtgedaechtnis_backend.import_entries.importers import do_silent_json_import
from stadtgedaechtnis_backend.import_entries.urls import JSON_URL
schedule.every().day.at("23:00").do(do_silent_json_import, JSON_URL)
while True:
schedule.run_pending()
time.sleep(1)
start_new_thread(run_cronjobs, ())
|
Replace list with tuple in start new thread
|
Replace list with tuple in start new thread
|
Python
|
mit
|
fraunhoferfokus/mobile-city-memory,fraunhoferfokus/mobile-city-memory,jessepeng/coburg-city-memory,jessepeng/coburg-city-memory
|
cc3ab3af17e30e7dd9991d68f01eaa4535b64e6b
|
djangae/models.py
|
djangae/models.py
|
from django.db import models
class CounterShard(models.Model):
count = models.PositiveIntegerField()
|
from django.db import models
class CounterShard(models.Model):
count = models.PositiveIntegerField()
#Apply our django patches
from .patches import *
|
Patch update_contenttypes so that it's less likely to fail due to eventual consistency
|
Patch update_contenttypes so that it's less likely to fail due to eventual consistency
|
Python
|
bsd-3-clause
|
nealedj/djangae,martinogden/djangae,grzes/djangae,stucox/djangae,asendecka/djangae,trik/djangae,trik/djangae,wangjun/djangae,armirusco/djangae,b-cannon/my_djae,jscissr/djangae,grzes/djangae,wangjun/djangae,chargrizzle/djangae,chargrizzle/djangae,leekchan/djangae,kirberich/djangae,martinogden/djangae,pablorecio/djangae,nealedj/djangae,armirusco/djangae,asendecka/djangae,nealedj/djangae,jscissr/djangae,stucox/djangae,potatolondon/djangae,leekchan/djangae,grzes/djangae,jscissr/djangae,asendecka/djangae,kirberich/djangae,leekchan/djangae,SiPiggles/djangae,kirberich/djangae,martinogden/djangae,armirusco/djangae,SiPiggles/djangae,chargrizzle/djangae,pablorecio/djangae,stucox/djangae,SiPiggles/djangae,trik/djangae,potatolondon/djangae,wangjun/djangae,pablorecio/djangae
|
776c3b0df6136606b8b7474418fd5d078457bd0a
|
test/persistence_test.py
|
test/persistence_test.py
|
from os.path import exists, join
import shutil
import tempfile
import time
from lwr.managers.queued import QueueManager
from lwr.managers.stateful import StatefulManagerProxy
from lwr.tools.authorization import get_authorizer
from .test_utils import TestDependencyManager
from galaxy.util.bunch import Bunch
def test_persistence():
"""
Tests persistence of a managers jobs.
"""
staging_directory = tempfile.mkdtemp()
try:
app = Bunch(staging_directory=staging_directory,
persistence_directory=staging_directory,
authorizer=get_authorizer(None),
dependency_manager=TestDependencyManager(),
)
assert not exists(join(staging_directory, "queued_jobs"))
queue1 = StatefulManagerProxy(QueueManager('test', app, num_concurrent_jobs=0))
job_id = queue1.setup_job('4', 'tool1', '1.0.0')
touch_file = join(staging_directory, 'ran')
queue1.launch(job_id, 'touch %s' % touch_file)
time.sleep(.4)
assert (not(exists(touch_file)))
queue1.shutdown()
queue2 = StatefulManagerProxy(QueueManager('test', app, num_concurrent_jobs=1))
time.sleep(1)
assert exists(touch_file)
finally:
shutil.rmtree(staging_directory)
try:
queue2.shutdown()
except:
pass
|
from os.path import exists, join
import shutil
import tempfile
import time
from lwr.managers.queued import QueueManager
from lwr.managers.stateful import StatefulManagerProxy
from lwr.tools.authorization import get_authorizer
from .test_utils import TestDependencyManager
from galaxy.util.bunch import Bunch
from galaxy.jobs.metrics import NULL_JOB_INSTRUMENTER
def test_persistence():
"""
Tests persistence of a managers jobs.
"""
staging_directory = tempfile.mkdtemp()
try:
app = Bunch(staging_directory=staging_directory,
persistence_directory=staging_directory,
authorizer=get_authorizer(None),
dependency_manager=TestDependencyManager(),
job_metrics=Bunch(default_job_instrumenter=NULL_JOB_INSTRUMENTER),
)
assert not exists(join(staging_directory, "queued_jobs"))
queue1 = StatefulManagerProxy(QueueManager('test', app, num_concurrent_jobs=0))
job_id = queue1.setup_job('4', 'tool1', '1.0.0')
touch_file = join(staging_directory, 'ran')
queue1.launch(job_id, 'touch %s' % touch_file)
time.sleep(.4)
assert (not(exists(touch_file)))
queue1.shutdown()
queue2 = StatefulManagerProxy(QueueManager('test', app, num_concurrent_jobs=1))
time.sleep(1)
assert exists(touch_file)
finally:
shutil.rmtree(staging_directory)
try:
queue2.shutdown()
except:
pass
|
Fix another failing unit test (from metrics work).
|
Fix another failing unit test (from metrics work).
|
Python
|
apache-2.0
|
jmchilton/lwr,natefoo/pulsar,natefoo/pulsar,jmchilton/pulsar,galaxyproject/pulsar,jmchilton/pulsar,ssorgatem/pulsar,galaxyproject/pulsar,ssorgatem/pulsar,jmchilton/lwr
|
3ee7d716f0eb3202ccf7ca213747eb903f9bb471
|
__init__.py
|
__init__.py
|
from .Averager import Averager
from .Config import Config
from .RateTicker import RateTicker
from .Ring import Ring
from .SortedList import SortedList
from .String import string2time, time2string
from .Timer import Timer
from .UserInput import user_input
|
from .Averager import Averager
from .Config import Config
from .RateTicker import RateTicker
from .Ring import Ring
from .SortedList import SortedList
from .String import string2time, time2string, time2levels, time2dir, time2fname
from .Timer import Timer
from .UserInput import user_input
|
Add missing names to module namespace.
|
Add missing names to module namespace.
|
Python
|
mit
|
vmlaker/coils
|
c05fc3ae4d6ac0ed459150acf2c19fd892c2ea9f
|
bumblebee/modules/caffeine.py
|
bumblebee/modules/caffeine.py
|
#pylint: disable=C0111,R0903
"""Enable/disable automatic screen locking.
Requires the following executables:
* xdg-screensaver
* notify-send
"""
import bumblebee.input
import bumblebee.output
import bumblebee.engine
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text="")
)
self._active = False
self.interval(1)
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self._toggle
)
def state(self, widget):
if self._active:
return "activated"
return "deactivated"
def _toggle(self, event):
self._active = not self._active
if self._active:
bumblebee.util.execute("xdg-screensaver reset")
bumblebee.util.execute("notify-send \"Consuming caffeine\"")
else:
bumblebee.util.execute("notify-send \"Out of coffee\"")
def update(self, widgets):
if self._active:
bumblebee.util.execute("xdg-screensaver reset")
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
#pylint: disable=C0111,R0903
"""Enable/disable automatic screen locking.
Requires the following executables:
* xdg-screensaver
* notify-send
"""
import bumblebee.input
import bumblebee.output
import bumblebee.engine
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text="")
)
self._active = False
self.interval(1)
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self._toggle
)
def state(self, widget):
if self._active:
return "activated"
return "deactivated"
def _toggle(self, event):
self._active = not self._active
try:
if self._active:
bumblebee.util.execute("xdg-screensaver reset")
bumblebee.util.execute("notify-send \"Consuming caffeine\"")
else:
bumblebee.util.execute("notify-send \"Out of coffee\"")
except:
self._active = not self._active
def update(self, widgets):
if self._active:
bumblebee.util.execute("xdg-screensaver reset")
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
Add some basic error handling in case the executables don't exist
|
Add some basic error handling in case the executables don't exist
|
Python
|
mit
|
tobi-wan-kenobi/bumblebee-status,tobi-wan-kenobi/bumblebee-status
|
ffadde617db8ac3d0d5362b4a521dd4e9839710f
|
order/order_2_login_system_by_https.py
|
order/order_2_login_system_by_https.py
|
import json
import requests
""" Order 2: Login system by https
```
curl -k https://192.168.105.88/axapi/v3/auth -H "Content-type:application/json" -d '{
"credentials": {
"username": "admin",
"password": "a10"
}
}'
```
"""
class LoginSystemByHttps(object):
login_url = 'http://192.168.105.88/axapi/v3/auth'
def login(self):
"""
Note: the dict playload must be use json.dumps() to turn to str.
:return: Result string data
"""
payload = {'credentials': {'username': "admin", 'password': "a10"}}
headers = {'content-type': 'application/json', 'Connection': 'keep-alive'}
response = requests.post(self.login_url, data=json.dumps(payload), verify=False, headers=headers)
print(response.text)
return response.text
# login = LoginSystemByHttps()
# login.login()
|
import json
import requests
""" Order 2: Login system by https
This is the code which use curl to login system
```
curl -k https://192.168.105.88/axapi/v3/auth -H "Content-type:application/json" -d '{
"credentials": {
"username": "admin",
"password": "a10"
}
}'
```
"""
class LoginSystemByHttps(object):
login_url = 'http://192.168.105.88/axapi/v3/auth'
def login(self):
"""
Note: the dict playload must be use json.dumps() to turn to str.
:return: Result string data
"""
payload = {'credentials': {'username': "admin", 'password': "a10"}}
headers = {'content-type': 'application/json', 'Connection': 'keep-alive'}
response = requests.post(self.login_url, data=json.dumps(payload), verify=False, headers=headers)
print(response.text)
return response.text
# login = LoginSystemByHttps()
# login.login()
|
Order 2: Login system by https
|
[Order] Order 2: Login system by https
|
Python
|
mit
|
flyingSprite/spinelle
|
646a248d59f835264729b48a0116d51089f6113e
|
oscar/templatetags/currency_filters.py
|
oscar/templatetags/currency_filters.py
|
from decimal import Decimal as D, InvalidOperation
from django import template
from django.conf import settings
from babel.numbers import format_currency
register = template.Library()
@register.filter(name='currency')
def currency(value):
"""
Format decimal value as currency
"""
try:
value = D(value)
except (TypeError, InvalidOperation):
return u""
# Using Babel's currency formatting
# http://packages.python.org/Babel/api/babel.numbers-module.html#format_currency
kwargs = {
'currency': settings.OSCAR_DEFAULT_CURRENCY,
'format': getattr(settings, 'OSCAR_CURRENCY_FORMAT', None)}
locale = getattr(settings, 'OSCAR_CURRENCY_LOCALE', None)
if locale:
kwargs['locale'] = locale
return format_currency(value, **kwargs)
|
from decimal import Decimal as D, InvalidOperation
from django import template
from django.conf import settings
from babel.numbers import format_currency
register = template.Library()
@register.filter(name='currency')
def currency(value):
"""
Format decimal value as currency
"""
try:
value = D(value)
except (TypeError, InvalidOperation):
return u""
# Using Babel's currency formatting
# http://babel.pocoo.org/docs/api/numbers/#babel.numbers.format_currency
kwargs = {
'currency': settings.OSCAR_DEFAULT_CURRENCY,
'format': getattr(settings, 'OSCAR_CURRENCY_FORMAT', None)}
locale = getattr(settings, 'OSCAR_CURRENCY_LOCALE', None)
if locale:
kwargs['locale'] = locale
return format_currency(value, **kwargs)
|
Replace broken babel documentation link
|
Replace broken babel documentation link
According to Babel's PyPI package page, http://babel.pocoo.org/docs/ is
the official documentation website.
|
Python
|
bsd-3-clause
|
lijoantony/django-oscar,faratro/django-oscar,michaelkuty/django-oscar,MatthewWilkes/django-oscar,django-oscar/django-oscar,dongguangming/django-oscar,taedori81/django-oscar,pasqualguerrero/django-oscar,marcoantoniooliveira/labweb,faratro/django-oscar,Jannes123/django-oscar,binarydud/django-oscar,Jannes123/django-oscar,solarissmoke/django-oscar,faratro/django-oscar,pdonadeo/django-oscar,ademuk/django-oscar,vovanbo/django-oscar,michaelkuty/django-oscar,okfish/django-oscar,thechampanurag/django-oscar,sasha0/django-oscar,rocopartners/django-oscar,binarydud/django-oscar,pdonadeo/django-oscar,elliotthill/django-oscar,john-parton/django-oscar,adamend/django-oscar,ahmetdaglarbas/e-commerce,mexeniz/django-oscar,Jannes123/django-oscar,monikasulik/django-oscar,rocopartners/django-oscar,josesanch/django-oscar,QLGu/django-oscar,Bogh/django-oscar,dongguangming/django-oscar,spartonia/django-oscar,bschuon/django-oscar,vovanbo/django-oscar,marcoantoniooliveira/labweb,WadeYuChen/django-oscar,manevant/django-oscar,anentropic/django-oscar,django-oscar/django-oscar,thechampanurag/django-oscar,Jannes123/django-oscar,solarissmoke/django-oscar,marcoantoniooliveira/labweb,jinnykoo/wuyisj,monikasulik/django-oscar,Bogh/django-oscar,bnprk/django-oscar,lijoantony/django-oscar,adamend/django-oscar,okfish/django-oscar,itbabu/django-oscar,jinnykoo/wuyisj,kapt/django-oscar,jinnykoo/wuyisj.com,pasqualguerrero/django-oscar,MatthewWilkes/django-oscar,anentropic/django-oscar,DrOctogon/unwash_ecom,josesanch/django-oscar,WadeYuChen/django-oscar,makielab/django-oscar,WillisXChen/django-oscar,manevant/django-oscar,faratro/django-oscar,john-parton/django-oscar,itbabu/django-oscar,spartonia/django-oscar,kapari/django-oscar,WillisXChen/django-oscar,ademuk/django-oscar,thechampanurag/django-oscar,kapari/django-oscar,saadatqadri/django-oscar,machtfit/django-oscar,makielab/django-oscar,sonofatailor/django-oscar,jinnykoo/christmas,michaelkuty/django-oscar,makielab/django-oscar,okfish/django-oscar,manevant/django-oscar,DrOctogon/unwash_ecom,taedori81/django-oscar,Idematica/django-oscar,Idematica/django-oscar,nickpack/django-oscar,jinnykoo/christmas,ahmetdaglarbas/e-commerce,mexeniz/django-oscar,vovanbo/django-oscar,jinnykoo/wuyisj.com,okfish/django-oscar,mexeniz/django-oscar,jinnykoo/wuyisj.com,machtfit/django-oscar,itbabu/django-oscar,bschuon/django-oscar,dongguangming/django-oscar,MatthewWilkes/django-oscar,anentropic/django-oscar,machtfit/django-oscar,Idematica/django-oscar,michaelkuty/django-oscar,jinnykoo/wuyisj.com,sasha0/django-oscar,amirrpp/django-oscar,monikasulik/django-oscar,bnprk/django-oscar,elliotthill/django-oscar,spartonia/django-oscar,lijoantony/django-oscar,jinnykoo/wuyisj,nickpack/django-oscar,sonofatailor/django-oscar,nfletton/django-oscar,jmt4/django-oscar,ka7eh/django-oscar,WadeYuChen/django-oscar,WillisXChen/django-oscar,eddiep1101/django-oscar,rocopartners/django-oscar,saadatqadri/django-oscar,binarydud/django-oscar,jlmadurga/django-oscar,django-oscar/django-oscar,itbabu/django-oscar,ademuk/django-oscar,jmt4/django-oscar,sasha0/django-oscar,nfletton/django-oscar,DrOctogon/unwash_ecom,taedori81/django-oscar,Bogh/django-oscar,ahmetdaglarbas/e-commerce,anentropic/django-oscar,binarydud/django-oscar,WadeYuChen/django-oscar,jlmadurga/django-oscar,makielab/django-oscar,marcoantoniooliveira/labweb,nfletton/django-oscar,manevant/django-oscar,nickpack/django-oscar,lijoantony/django-oscar,taedori81/django-oscar,sonofatailor/django-oscar,ahmetdaglarbas/e-commerce,kapari/django-oscar,ka7eh/django-oscar,saadatqadri/django-oscar,bnprk/django-oscar,solarissmoke/django-oscar,john-parton/django-oscar,solarissmoke/django-oscar,QLGu/django-oscar,kapt/django-oscar,john-parton/django-oscar,WillisXChen/django-oscar,jlmadurga/django-oscar,elliotthill/django-oscar,pdonadeo/django-oscar,pasqualguerrero/django-oscar,amirrpp/django-oscar,nickpack/django-oscar,bschuon/django-oscar,kapari/django-oscar,sasha0/django-oscar,MatthewWilkes/django-oscar,Bogh/django-oscar,nfletton/django-oscar,pasqualguerrero/django-oscar,dongguangming/django-oscar,amirrpp/django-oscar,saadatqadri/django-oscar,josesanch/django-oscar,QLGu/django-oscar,monikasulik/django-oscar,ademuk/django-oscar,spartonia/django-oscar,jlmadurga/django-oscar,jinnykoo/christmas,ka7eh/django-oscar,rocopartners/django-oscar,sonofatailor/django-oscar,eddiep1101/django-oscar,QLGu/django-oscar,jmt4/django-oscar,adamend/django-oscar,adamend/django-oscar,eddiep1101/django-oscar,bnprk/django-oscar,jinnykoo/wuyisj,WillisXChen/django-oscar,amirrpp/django-oscar,eddiep1101/django-oscar,vovanbo/django-oscar,bschuon/django-oscar,kapt/django-oscar,mexeniz/django-oscar,WillisXChen/django-oscar,ka7eh/django-oscar,thechampanurag/django-oscar,pdonadeo/django-oscar,jmt4/django-oscar,django-oscar/django-oscar
|
315b581b9b0438389c7f4eb651d2893b805a2369
|
translit.py
|
translit.py
|
class Transliterator(object):
def __init__(self, mapping, invert=False):
self.mapping = [
(v, k) if invert else (k, v)
for k, v in mapping.items()
]
self._rules = sorted(
self.mapping,
key=lambda item: len(item[0]),
reverse=True,
)
@property
def rules(self):
for r in self._rules:
yield r
# Handle the case when one source upper char is represented by
# several latin chars, all uppercase. i.e. "CH" instead of "Ch"
k, v = r
if len(k) > 1 and k[0].isupper():
yield (k.upper(), v.upper())
def convert(self, input_string):
"""Transliterate input string."""
for (source_char, translit_char) in self.rules:
input_string = input_string.replace(source_char, translit_char)
return input_string
|
class Transliterator(object):
def __init__(self, mapping, invert=False):
self.mapping = [
(v, k) if invert else (k, v)
for k, v in mapping.items()
]
self._rules = sorted(
self.mapping,
key=lambda item: len(item[0]),
reverse=True,
)
@property
def rules(self):
for r in self._rules:
k, v = r
if len(k) == 0:
continue # for case when char is removed and mapping inverted
yield r
# Handle the case when one source upper char is represented by
# several latin chars, all uppercase. i.e. "CH" instead of "Ch"
if len(k) > 1 and k[0].isupper():
yield (k.upper(), v.upper())
def convert(self, input_string):
"""Transliterate input string."""
for (source_char, translit_char) in self.rules:
input_string = input_string.replace(source_char, translit_char)
return input_string
|
Handle case when char is mapped to empty (removed) and table is inverted
|
Handle case when char is mapped to empty (removed) and table is inverted
|
Python
|
mit
|
malexer/SublimeTranslit
|
6f8f449316a71dd284d2661d206d88d35c01ea54
|
TrevorNet/tests/test_idx.py
|
TrevorNet/tests/test_idx.py
|
from .. import idx
import os
def test__find_depth():
yield check__find_depth, 9, 0
yield check__find_depth, [1, 2], 1
yield check__find_depth, [[1, 2], [3, 6, 2]], 2
yield check__find_depth, [[[1,2], [2]]], 3
def check__find_depth(lst, i):
assert idx._find_dimensions(lst) == i
# these two are equivalent according to the format on http://yann.lecun.com/exdb/mnist/
_somelist = [[1, 2], [3, 4]]
_somebytes = '\x00\x00\x0C\x02' + '\x01\x02\x03\x04'
_testfolder = os.path.dirname(os.path.realpath(__file__))
_somepath = os.path.join(_testfolder, 'test_idx_file')
def test_list_to_idx():
idx.list_to_idx(_somelist, _somepath, 'i')
with open(_somepath, 'rb') as f:
data = f.read()
os.remove(_somepath)
assert data == _somebytes
def test_idx_to_list():
with open(_somepath, 'wb') as f:
f.write(_somebytes)
lst = idx.idx_to_list(_somepath)
os.remove(_somepath)
assert lst == _somelist
|
from .. import idx
import os
def test__count_dimensions():
yield check__count_dimensions, 9, 0
yield check__count_dimensions, [1, 2], 1
yield check__count_dimensions, [[1, 2], [3, 6, 2]], 2
yield check__count_dimensions, [[[1,2], [2]]], 3
def check__count_dimensions(lst, i):
assert idx._count_dimensions(lst) == i
# these two are equivalent according to the format on http://yann.lecun.com/exdb/mnist/
_somelist = [[1, 2], [3, 4]]
_somebytes = b'\x00\x00\x0C\x02' + b'\x01\x02\x03\x04'
def test_list_to_idx():
data = idx.list_to_idx(_somelist, 'i')
assert data == _somebytes
def test_idx_to_list():
lst = idx.idx_to_list(_somebytes)
assert lst == _somelist
|
Update for python 3 and new idx design
|
Update for python 3 and new idx design
idx no longer writes to files, it only processes bytes
|
Python
|
mit
|
tmerr/trevornet
|
c5b130444e2061ae1c6bdf16ebc14d08817a8aea
|
dsub/_dsub_version.py
|
dsub/_dsub_version.py
|
# Copyright 2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required 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.
"""Single source of truth for dsub's version.
This must remain small and dependency-free so that any dsub module may
import it without creating circular dependencies. Note that this module
is parsed as a text file by setup.py and changes to the format of this
file could break setup.py.
The version should follow formatting requirements specified in PEP-440.
- https://www.python.org/dev/peps/pep-0440
A typical release sequence will be versioned as:
0.1.3.dev0 -> 0.1.3 -> 0.1.4.dev0 -> ...
"""
DSUB_VERSION = '0.3.10.dev0'
|
# Copyright 2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required 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.
"""Single source of truth for dsub's version.
This must remain small and dependency-free so that any dsub module may
import it without creating circular dependencies. Note that this module
is parsed as a text file by setup.py and changes to the format of this
file could break setup.py.
The version should follow formatting requirements specified in PEP-440.
- https://www.python.org/dev/peps/pep-0440
A typical release sequence will be versioned as:
0.1.3.dev0 -> 0.1.3 -> 0.1.4.dev0 -> ...
"""
DSUB_VERSION = '0.3.10'
|
Update dsub version to 0.3.10
|
Update dsub version to 0.3.10
PiperOrigin-RevId: 324884094
|
Python
|
apache-2.0
|
DataBiosphere/dsub,DataBiosphere/dsub
|
564075cbb66c6e79a6225d7f678aea804075b966
|
api/urls.py
|
api/urls.py
|
from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'fbxnano.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url('^status$', TemplateView.as_view(template_name='api/status.html'), name='status'),
)
|
from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
from .views import StatusView
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'fbxnano.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url('^status$', StatusView.as_view(), name='status'),
)
|
Switch from generic TemplateView to new StatusView
|
Switch from generic TemplateView to new StatusView
|
Python
|
mit
|
Kromey/fbxnano,Kromey/akwriters,Kromey/akwriters,Kromey/akwriters,Kromey/akwriters,Kromey/fbxnano,Kromey/fbxnano,Kromey/fbxnano
|
e615e2ebf3f364ba093c48d6fb0c988f0b97bc13
|
nyuki/workflow/tasks/__init__.py
|
nyuki/workflow/tasks/__init__.py
|
from .factory import FactoryTask
from .report import ReportTask
from .sleep import SleepTask
# Generic schema to reference a task ID
TASKID_SCHEMA = {
'type': 'string',
'description': 'task_id'
}
|
from .factory import FactoryTask
from .report import ReportTask
from .sleep import SleepTask
# Generic schema to reference a task ID
TASKID_SCHEMA = {
'type': 'string',
'description': 'task_id',
'maxLength': 128
}
|
Add maxlength to taskid schema
|
Add maxlength to taskid schema
|
Python
|
apache-2.0
|
gdraynz/nyuki,optiflows/nyuki,gdraynz/nyuki,optiflows/nyuki
|
fe4ce6dfa26c60747b6024fa9f6d991aa3b95614
|
scripts/codegen_driverwrappers/generate_driver_wrappers.py
|
scripts/codegen_driverwrappers/generate_driver_wrappers.py
|
#!/usr/bin/env python3
import sys
import json
import os
import jinja2
def render(tpl_path):
path, filename = os.path.split(tpl_path)
return jinja2.Environment(
loader=jinja2.FileSystemLoader(path or './')
).get_template(filename).render()
n = len(sys.argv)
if ( n != 3 ):
sys.exit("The template file name and output file name are expected as arguments")
# set template file name, output file name
driver_wrapper_template_filename = sys.argv[1]
driver_wrapper_output_filename = sys.argv[2]
# render the template
result = render(driver_wrapper_template_filename)
# write output to file
outFile = open(driver_wrapper_output_filename,"w")
outFile.write(result)
outFile.close()
|
#!/usr/bin/env python3
import sys
import json
import os
import jinja2
def render(tpl_path):
path, filename = os.path.split(tpl_path)
return jinja2.Environment(
loader=jinja2.FileSystemLoader(path or './'),
keep_trailing_newline=True,
).get_template(filename).render()
n = len(sys.argv)
if ( n != 3 ):
sys.exit("The template file name and output file name are expected as arguments")
# set template file name, output file name
driver_wrapper_template_filename = sys.argv[1]
driver_wrapper_output_filename = sys.argv[2]
# render the template
result = render(driver_wrapper_template_filename)
# write output to file
outFile = open(driver_wrapper_output_filename,"w")
outFile.write(result)
outFile.close()
|
Fix trailing newline getting dropped
|
Fix trailing newline getting dropped
Signed-off-by: Gilles Peskine <[email protected]>
|
Python
|
apache-2.0
|
Mbed-TLS/mbedtls,NXPmicro/mbedtls,NXPmicro/mbedtls,Mbed-TLS/mbedtls,NXPmicro/mbedtls,NXPmicro/mbedtls,ARMmbed/mbedtls,Mbed-TLS/mbedtls,ARMmbed/mbedtls,ARMmbed/mbedtls,Mbed-TLS/mbedtls,ARMmbed/mbedtls
|
c264e4b19505bfb0ccebc1551c7b82e96b6a2882
|
amqpy/tests/test_version.py
|
amqpy/tests/test_version.py
|
class TestVersion:
def test_version_is_consistent(self):
from .. import VERSION
with open('README.rst') as f:
readme = f.read().split('\n')
version_list = readme[3].split(':')[2].strip().split('.')
version_list = [int(i) for i in version_list]
readme_version = tuple(version_list)
assert VERSION == readme_version
|
import re
def get_field(doc: str, name: str):
match = re.search(':{}: (.*)$'.format(name), doc, re.IGNORECASE | re.MULTILINE)
if match:
return match.group(1).strip()
class TestVersion:
def test_version_is_consistent(self):
from .. import VERSION
with open('README.rst') as f:
readme = f.read()
version = get_field(readme, 'version')
version = version.split('.')
version = [int(i) for i in version]
version = tuple(version)
assert VERSION == version
|
Clean up test for version number
|
Clean up test for version number
A new function is implemented to cleanly extract the version field from the
README.rst field list.
|
Python
|
mit
|
veegee/amqpy,gst/amqpy
|
a7830d85c6966732e46da63903c04234d8d16c39
|
admin/nodes/serializers.py
|
admin/nodes/serializers.py
|
import json
from website.util.permissions import reduce_permissions
from admin.users.serializers import serialize_simple_node
def serialize_node(node):
embargo = node.embargo
if embargo is not None:
embargo = node.embargo.end_date
return {
'id': node._id,
'title': node.title,
'public': node.is_public,
'parent': node.parent_id,
'root': node.root._id,
'is_registration': node.is_registration,
'date_created': node.date_created,
'withdrawn': node.is_retracted,
'embargo': embargo,
'contributors': [serialize_simple_user_and_node_permissions(node, user) for user in node.contributors],
'children': map(serialize_simple_node, node.nodes),
'deleted': node.is_deleted,
'pending_registration': node.is_pending_registration,
'creator': node.creator._id,
'spam_status': node.spam_status,
'spam_pro_tip': node.spam_pro_tip,
'spam_data': json.dumps(node.spam_data, indent=4),
'is_public': node.is_public,
}
def serialize_simple_user_and_node_permissions(node, user):
return {
'id': user._id,
'name': user.fullname,
'permission': reduce_permissions(node.get_permissions(user))
}
|
import json
from website.util.permissions import reduce_permissions
from admin.users.serializers import serialize_simple_node
def serialize_node(node):
embargo = node.embargo
if embargo is not None:
embargo = node.embargo.end_date
return {
'id': node._id,
'title': node.title,
'public': node.is_public,
'parent': node.parent_id,
'root': node.root._id,
'is_registration': node.is_registration,
'date_created': node.date_created,
'withdrawn': node.is_retracted,
'embargo': embargo,
'contributors': [serialize_simple_user_and_node_permissions(node, user) for user in node.contributors],
'children': map(serialize_simple_node, node.nodes),
'deleted': node.is_deleted,
'pending_registration': node.is_pending_registration,
'registered_date': node.registered_date,
'creator': node.creator._id,
'spam_status': node.spam_status,
'spam_pro_tip': node.spam_pro_tip,
'spam_data': json.dumps(node.spam_data, indent=4),
'is_public': node.is_public,
}
def serialize_simple_user_and_node_permissions(node, user):
return {
'id': user._id,
'name': user.fullname,
'permission': reduce_permissions(node.get_permissions(user))
}
|
Add date_registered to node serializer
|
Add date_registered to node serializer
[#OSF-7230]
|
Python
|
apache-2.0
|
mattclark/osf.io,laurenrevere/osf.io,brianjgeiger/osf.io,saradbowman/osf.io,mattclark/osf.io,caseyrollins/osf.io,chennan47/osf.io,adlius/osf.io,leb2dg/osf.io,Johnetordoff/osf.io,cslzchen/osf.io,brianjgeiger/osf.io,hmoco/osf.io,CenterForOpenScience/osf.io,adlius/osf.io,chennan47/osf.io,hmoco/osf.io,caneruguz/osf.io,mfraezz/osf.io,caneruguz/osf.io,cslzchen/osf.io,sloria/osf.io,caneruguz/osf.io,felliott/osf.io,Nesiehr/osf.io,icereval/osf.io,mattclark/osf.io,binoculars/osf.io,aaxelb/osf.io,cwisecarver/osf.io,cwisecarver/osf.io,leb2dg/osf.io,Johnetordoff/osf.io,HalcyonChimera/osf.io,erinspace/osf.io,icereval/osf.io,sloria/osf.io,chennan47/osf.io,pattisdr/osf.io,HalcyonChimera/osf.io,Nesiehr/osf.io,chrisseto/osf.io,TomBaxter/osf.io,CenterForOpenScience/osf.io,leb2dg/osf.io,brianjgeiger/osf.io,baylee-d/osf.io,erinspace/osf.io,caseyrollins/osf.io,HalcyonChimera/osf.io,CenterForOpenScience/osf.io,pattisdr/osf.io,aaxelb/osf.io,binoculars/osf.io,crcresearch/osf.io,felliott/osf.io,cwisecarver/osf.io,Nesiehr/osf.io,TomBaxter/osf.io,baylee-d/osf.io,caneruguz/osf.io,caseyrollins/osf.io,adlius/osf.io,chrisseto/osf.io,binoculars/osf.io,sloria/osf.io,HalcyonChimera/osf.io,Johnetordoff/osf.io,leb2dg/osf.io,laurenrevere/osf.io,felliott/osf.io,mfraezz/osf.io,cslzchen/osf.io,hmoco/osf.io,Nesiehr/osf.io,mfraezz/osf.io,crcresearch/osf.io,aaxelb/osf.io,chrisseto/osf.io,crcresearch/osf.io,cwisecarver/osf.io,cslzchen/osf.io,icereval/osf.io,felliott/osf.io,adlius/osf.io,hmoco/osf.io,CenterForOpenScience/osf.io,baylee-d/osf.io,erinspace/osf.io,saradbowman/osf.io,TomBaxter/osf.io,Johnetordoff/osf.io,aaxelb/osf.io,brianjgeiger/osf.io,mfraezz/osf.io,chrisseto/osf.io,laurenrevere/osf.io,pattisdr/osf.io
|
f625cac0a49bafc96403f5b34c2e138f8d2cfbea
|
dev/lint.py
|
dev/lint.py
|
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import os
from flake8.engine import get_style_guide
cur_dir = os.path.dirname(__file__)
config_file = os.path.join(cur_dir, '..', 'tox.ini')
def run():
"""
Runs flake8 lint
:return:
A bool - if flake8 did not find any errors
"""
print('Running flake8')
flake8_style = get_style_guide(config_file=config_file)
paths = []
for root, _, filenames in os.walk('asn1crypto'):
for filename in filenames:
if not filename.endswith('.py'):
continue
paths.append(os.path.join(root, filename))
report = flake8_style.check_files(paths)
success = report.total_errors == 0
if success:
print('OK')
return success
|
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import os
import flake8
if flake8.__version_info__ < (3,):
from flake8.engine import get_style_guide
else:
from flake8.api.legacy import get_style_guide
cur_dir = os.path.dirname(__file__)
config_file = os.path.join(cur_dir, '..', 'tox.ini')
def run():
"""
Runs flake8 lint
:return:
A bool - if flake8 did not find any errors
"""
print('Running flake8')
flake8_style = get_style_guide(config_file=config_file)
paths = []
for root, _, filenames in os.walk('asn1crypto'):
for filename in filenames:
if not filename.endswith('.py'):
continue
paths.append(os.path.join(root, filename))
report = flake8_style.check_files(paths)
success = report.total_errors == 0
if success:
print('OK')
return success
|
Add support for flake8 3.0
|
Add support for flake8 3.0
|
Python
|
mit
|
wbond/asn1crypto
|
573718a17e5e2d3fe23b1c8cd128a9b46d6076e6
|
example-theme.py
|
example-theme.py
|
# Supported 16 color values:
# 'h0' (color number 0) through 'h15' (color number 15)
# or
# 'default' (use the terminal's default foreground),
# 'black', 'dark red', 'dark green', 'brown', 'dark blue',
# 'dark magenta', 'dark cyan', 'light gray', 'dark gray',
# 'light red', 'light green', 'yellow', 'light blue',
# 'light magenta', 'light cyan', 'white'
#
# Supported 256 color values:
# 'h0' (color number 0) through 'h255' (color number 255)
#
# 256 color chart: http://en.wikipedia.org/wiki/File:Xterm_color_chart.png
#
# "setting_name": (foreground_color, background_color),
palette.update({
"source": (add_setting("black", "underline"), "dark green"),
"comment": ("h250", "default")
})
|
# Supported 16 color values:
# 'h0' (color number 0) through 'h15' (color number 15)
# or
# 'default' (use the terminal's default foreground),
# 'black', 'dark red', 'dark green', 'brown', 'dark blue',
# 'dark magenta', 'dark cyan', 'light gray', 'dark gray',
# 'light red', 'light green', 'yellow', 'light blue',
# 'light magenta', 'light cyan', 'white'
#
# Supported 256 color values:
# 'h0' (color number 0) through 'h255' (color number 255)
#
# 256 color chart: http://en.wikipedia.org/wiki/File:Xterm_color_chart.png
#
# "setting_name": (foreground_color, background_color),
# See this URL to see what keys there are:
# https://github.com/inducer/pudb/blob/master/pudb/theme.py
palette.update({
"source": (add_setting("black", "underline"), "dark green"),
"comment": ("h250", "default")
})
|
Add link to defined colors to example theme
|
Add link to defined colors to example theme
|
Python
|
mit
|
amigrave/pudb,albfan/pudb,amigrave/pudb,albfan/pudb
|
a45f5ca2e92cfaa4478d632ada3889b81fef5f53
|
features/urls.py
|
features/urls.py
|
from django.conf.urls import url, include
from django.views.generic import TemplateView
from rest_framework import routers
from .views import FeatureRequestViewSet, ClientViewSet, ProductAreaViewSet
router = routers.DefaultRouter()
router.register(r'features', FeatureRequestViewSet)
router.register(r'client', ClientViewSet)
router.register(r'productarea', ProductAreaViewSet)
urlpatterns = [
url(r'^', TemplateView.as_view(template_name='features/index.html')),
url(r'^api/', include(router.urls)),
url(r'api-auth/', include('rest_framework.urls', namespace='rest_framework')),
]
|
from django.conf.urls import url, include
from django.views.generic import TemplateView
from rest_framework import routers
from .views import FeatureRequestViewSet, ClientViewSet, ProductAreaViewSet
router = routers.DefaultRouter()
router.register(r'features', FeatureRequestViewSet)
router.register(r'client', ClientViewSet)
router.register(r'productarea', ProductAreaViewSet)
urlpatterns = [
url(r'^$', TemplateView.as_view(template_name='features/index.html')),
url(r'^api/', include(router.urls)),
url(r'api-auth/', include('rest_framework.urls', namespace='rest_framework')),
]
|
Index route should only match on '/'
|
BUGFIX: Index route should only match on '/'
|
Python
|
mit
|
wkevina/feature-requests-app,wkevina/feature-requests-app,wkevina/feature-requests-app
|
72c122d8ff580a4c0c5fa4554844c73c657a6581
|
apnsclient/__init__.py
|
apnsclient/__init__.py
|
# Copyright 2013 Getlogic BV, Sardar Yumatov
#
# 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.
__title__ = 'APNS client'
__version__ = "0.1.1"
__author__ = "Sardar Yumatov"
__contact__ = "[email protected]"
__license__ = "Apache 2.0"
__homepage__ = "https://bitbucket.org/sardarnl/apns-client/"
__copyright__ = 'Copyright 2013 Getlogic BV, Sardar Yumatov'
from apnsclient.apns import *
|
# Copyright 2013 Getlogic BV, Sardar Yumatov
#
# 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.
__title__ = 'APNS client'
__version__ = "0.1.5"
__author__ = "Sardar Yumatov"
__contact__ = "[email protected]"
__license__ = "Apache 2.0"
__homepage__ = "https://bitbucket.org/sardarnl/apns-client/"
__copyright__ = 'Copyright 2013 Getlogic BV, Sardar Yumatov'
from apnsclient.apns import *
|
Adjust the module __version__ to match the version advertised in PyPI.
|
Adjust the module __version__ to match the version advertised in PyPI.
--HG--
branch : intellectronica/adjust-the-module-__version__-to-match-t-1371450045566
|
Python
|
apache-2.0
|
marcinkaszynski/apnsclient
|
efd64433fab0cae0aaffbd30864c9271c0627502
|
packages/fsharp-3.1.py
|
packages/fsharp-3.1.py
|
class Fsharp31Package(GitHubTarballPackage):
def __init__(self):
GitHubTarballPackage.__init__(self,
'fsharp', 'fsharp',
'3.1.1.31',
'1f79c0455fb8b5ec816985f922413894ce19359a',
configure = '')
self.sources.extend ([
'fsharp-fix-net45-profile.patch')
def prep(self):
Package.prep (self)
for p in range (1, len (self.sources)):
self.sh ('patch -p1 < "%{sources[' + str (p) + ']}"')
def build(self):
self.sh ('autoreconf')
self.sh ('./configure --prefix="%{prefix}"')
self.sh ('make')
Fsharp31Package()
|
class Fsharp31Package(GitHubTarballPackage):
def __init__(self):
GitHubTarballPackage.__init__(self,
'fsharp', 'fsharp',
'3.1.1.31',
'1f79c0455fb8b5ec816985f922413894ce19359a',
configure = '')
self.sources.extend ([
'patches/fsharp-fix-net45-profile.patch'])
def prep(self):
Package.prep (self)
for p in range (1, len (self.sources)):
self.sh ('patch -p1 < "%{sources[' + str (p) + ']}"')
def build(self):
self.sh ('autoreconf')
self.sh ('./configure --prefix="%{prefix}"')
self.sh ('make')
Fsharp31Package()
|
Fix the typos, fix the build.
|
Fix the typos, fix the build.
|
Python
|
mit
|
mono/bockbuild,BansheeMediaPlayer/bockbuild,BansheeMediaPlayer/bockbuild,BansheeMediaPlayer/bockbuild,mono/bockbuild
|
b50b7143185131a81e84f0659ff6405317f7d36f
|
resolwe/flow/execution_engines/base.py
|
resolwe/flow/execution_engines/base.py
|
"""Workflow execution engines."""
from resolwe.flow.engine import BaseEngine
class BaseExecutionEngine(BaseEngine):
"""A workflow execution engine."""
def evaluate(self, data):
"""Return the code needed to compute a given Data object."""
raise NotImplementedError
def get_expression_engine(self, name):
"""Return an expression engine by its name."""
return self.manager.get_expression_engine(name)
def get_output_schema(self, process):
"""Return any additional output schema for the process."""
return []
def discover_process(self, path):
"""Perform process discovery in given path.
This method will be called during process registration and
should return a list of dictionaries with discovered process
schemas.
"""
return []
def prepare_runtime(self, runtime_dir, data):
"""Prepare runtime directory.
This method should return a dictionary of volume maps, where
keys are files or directories relative the the runtime directory
and values are paths under which these should be made available
to the executing program. All volumes will be read-only.
"""
|
"""Workflow execution engines."""
from resolwe.flow.engine import BaseEngine
class BaseExecutionEngine(BaseEngine):
"""A workflow execution engine."""
def evaluate(self, data):
"""Return the code needed to compute a given Data object."""
raise NotImplementedError
def get_expression_engine(self, name):
"""Return an expression engine by its name."""
return self.manager.get_expression_engine(name)
def get_output_schema(self, process):
"""Return any additional output schema for the process."""
return []
def discover_process(self, path):
"""Perform process discovery in given path.
This method will be called during process registration and
should return a list of dictionaries with discovered process
schemas.
"""
return []
def prepare_runtime(self, runtime_dir, data):
"""Prepare runtime directory.
This method should return a dictionary of volume maps, where
keys are files or directories relative the the runtime directory
and values are paths under which these should be made available
to the executing program. All volumes will be read-only.
"""
return {}
|
Return empty dictionary instead of None
|
Return empty dictionary instead of None
|
Python
|
apache-2.0
|
genialis/resolwe,genialis/resolwe
|
b62f52a30404901ff3ffa7af90a3f1bdd7d05401
|
project/hhlcallback/utils.py
|
project/hhlcallback/utils.py
|
# -*- coding: utf-8 -*-
import environ
env = environ.Env()
HOLVI_CNC = False
def get_holvi_singleton():
global HOLVI_CNC
if HOLVI_CNC:
return HOLVI_CNC
holvi_pool = env('HOLVI_POOL', default=None)
holvi_key = env('HOLVI_APIKEY', default=None)
if not holvi_pool or not holvi_key:
return False
import holviapi
HOLVI_CNC = holviapi.Connection(holvi_pool, holvi_key)
return HOLVI_CNC
|
# -*- coding: utf-8 -*-
import holviapi.utils
def get_nordea_payment_reference(member_id, number):
base = member_id + 1000
return holviapi.utils.int2fin_reference(int("%s%s" % (base, number)))
|
Remove copy-pasted code, add helper for making legacy reference number for payments
|
Remove copy-pasted code, add helper for making legacy reference number for payments
|
Python
|
mit
|
HelsinkiHacklab/asylum,HelsinkiHacklab/asylum,HelsinkiHacklab/asylum,HelsinkiHacklab/asylum
|
6f30aed2b5f157bb22c8761a92464302ec5d8911
|
DebianChangesBot/utils/__init__.py
|
DebianChangesBot/utils/__init__.py
|
# -*- coding: utf-8 -*-
import email.quoprimime
def quoted_printable(val):
try:
if type(val) is str:
return email.quoprimime.header_decode(val)
else:
return unicode(email.quoprimime.header_decode(str(val)), 'utf-8')
except Exception, e:
# We ignore errors here. Most of these originate from a spam
# report adding a synopsis of a message with broken encodings.
pass
return val
from parse_mail import parse_mail
|
# -*- coding: utf-8 -*-
import email
import re
def header_decode(s):
def unquote_match(match):
s = match.group(0)
return chr(int(s[1:3], 16))
s = s.replace('_', ' ')
return re.sub(r'=\w{2}', unquote_match, s)
def quoted_printable(val):
try:
if type(val) is str:
save = header_decode(val)
val = ' '.join([chunk.decode(encoding or 'ascii', 'replace') for chunk, encoding in
email.Header.decode_header(val)])
if len(val) > len(save):
val = unicode(save, 'utf-8', 'replace')
else:
return unicode(email.quoprimime.header_decode(str(val)), 'utf-8', 'replace')
except Exception, e:
# We ignore errors here. Most of these originate from a spam
# report adding a synopsis of a message with broken encodings.
pass
return val
from parse_mail import parse_mail
|
Update header_decode to handle bare and non-bare quoted-printable chars
|
Update header_decode to handle bare and non-bare quoted-printable chars
Signed-off-by: Chris Lamb <[email protected]>
|
Python
|
agpl-3.0
|
xtaran/debian-devel-changes-bot,xtaran/debian-devel-changes-bot,lamby/debian-devel-changes-bot,lamby/debian-devel-changes-bot,sebastinas/debian-devel-changes-bot,lamby/debian-devel-changes-bot
|
b5b17c5152e969ed4e629a5df8dd296cde164f9b
|
polymer_states/__init__.py
|
polymer_states/__init__.py
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Link states
UP, DOWN = (0, 1), (0, -1)
LEFT, RIGHT = (-1, 0), (1, 0)
SLACK = (0, 0)
|
Add link states to polymer_states
|
Add link states to polymer_states
|
Python
|
mpl-2.0
|
szabba/applied-sims
|
656c0a9b91ee6f6f3f9811b16ab75dc8003402ad
|
altair/examples/line_chart_with_generator.py
|
altair/examples/line_chart_with_generator.py
|
"""
Line Chart with Sequence Generator
----------------------------------
This examples shows how to create multiple lines using the sequence generator.
"""
# category: line charts
import altair as alt
source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')
alt.Chart(source).mark_line().transform_calculate(
sin='sin(datum.x)'
).transform_calculate(
cos='cos(datum.x)'
).transform_fold(
['sin', 'cos']
).encode(
x='x:Q',
y='value:Q',
color='key:N'
)
|
"""
Line Chart with Sequence Generator
----------------------------------
This examples shows how to create multiple lines using the sequence generator.
"""
# category: line charts
import altair as alt
source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')
alt.Chart(source).mark_line().transform_calculate(
sin='sin(datum.x)',
cos='cos(datum.x)'
).transform_fold(
['sin', 'cos']
).encode(
x='x:Q',
y='value:Q',
color='key:N'
)
|
Modify generator example to use single calculation transform
|
DOC: Modify generator example to use single calculation transform
|
Python
|
bsd-3-clause
|
jakevdp/altair,altair-viz/altair
|
4d1dc36e7426a13906dd1b75eda2c8bff94c88b4
|
pwm_server/__init__.py
|
pwm_server/__init__.py
|
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from logging import getLogger
import os
import pwm
db = SQLAlchemy()
_logger = getLogger('pwm_server')
class PWMApp(Flask):
def bootstrap(self):
""" Initialize database tables for both pwm_server and pwm. """
from .models import Certificate
with self.app_context():
db.metadata.create_all(db.engine, tables=[Certificate.__table__, pwm.Domain.__table__])
def create_app(config_file=None):
app = PWMApp(__name__)
app.config['WTF_CSRF_ENABLED'] = False
if config_file:
config_path = os.path.join(os.getcwd(), config_file)
_logger.debug('Loading config from %s', config_path)
app.config.from_pyfile(config_path)
else:
_logger.debug('Loading config from envvar, file %s', os.environ['PWM_SERVER_CONFIG_FILE'])
app.config.from_envvar('PWM_SERVER_CONFIG_FILE')
from . import views
app.register_blueprint(views.mod)
db.init_app(app)
return app
|
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from logging import getLogger
import os
import pwm
db = SQLAlchemy()
_logger = getLogger('pwm_server')
class PWMApp(Flask):
def bootstrap(self):
""" Initialize database tables for both pwm_server and pwm. """
from .models import Certificate
with self.app_context():
db.metadata.create_all(db.engine, tables=[Certificate.__table__, pwm.Domain.__table__])
def create_app(config_file=None):
app = PWMApp(__name__)
app.config['WTF_CSRF_ENABLED'] = False
if config_file:
config_path = os.path.join(os.getcwd(), config_file)
_logger.debug('Loading config from %s', config_path)
else:
_logger.debug('Loading config from envvar, file %s', os.environ['PWM_SERVER_CONFIG_FILE'])
config_path = os.path.join(os.getcwd(), os.environ['PWM_SERVER_CONFIG_FILE'])
app.config.from_pyfile(config_path)
from . import views
app.register_blueprint(views.mod)
db.init_app(app)
return app
|
Resolve config from envvar relative to cwd
|
Resolve config from envvar relative to cwd
|
Python
|
mit
|
thusoy/pwm-server,thusoy/pwm-server
|
7319ac2eb5d31b14c731371a82102c90d8ec3979
|
tests/test_reflection_views.py
|
tests/test_reflection_views.py
|
from sqlalchemy import MetaData, Table, inspect
from sqlalchemy.schema import CreateTable
from rs_sqla_test_utils.utils import clean, compile_query
def table_to_ddl(engine, table):
return str(CreateTable(table)
.compile(engine))
def test_view_reflection(redshift_engine):
table_ddl = "CREATE TABLE my_table (col1 INTEGER, col2 INTEGER)"
view_query = "SELECT my_table.col1, my_table.col2 FROM my_table"
view_ddl = "CREATE VIEW my_view AS %s" % view_query
conn = redshift_engine.connect()
conn.execute(table_ddl)
conn.execute(view_ddl)
insp = inspect(redshift_engine)
view_definition = insp.get_view_definition('my_view')
assert(clean(compile_query(view_definition)) == clean(view_query))
view = Table('my_view', MetaData(),
autoload=True, autoload_with=redshift_engine)
assert(len(view.columns) == 2)
|
from sqlalchemy import MetaData, Table, inspect
from sqlalchemy.schema import CreateTable
from rs_sqla_test_utils.utils import clean, compile_query
def table_to_ddl(engine, table):
return str(CreateTable(table)
.compile(engine))
def test_view_reflection(redshift_engine):
table_ddl = "CREATE TABLE my_table (col1 INTEGER, col2 INTEGER)"
view_query = "SELECT my_table.col1, my_table.col2 FROM my_table"
view_ddl = "CREATE VIEW my_view AS %s" % view_query
conn = redshift_engine.connect()
conn.execute(table_ddl)
conn.execute(view_ddl)
insp = inspect(redshift_engine)
view_definition = insp.get_view_definition('my_view')
assert(clean(compile_query(view_definition)) == clean(view_query))
view = Table('my_view', MetaData(),
autoload=True, autoload_with=redshift_engine)
assert(len(view.columns) == 2)
def test_late_binding_view_reflection(redshift_engine):
table_ddl = "CREATE TABLE my_table (col1 INTEGER, col2 INTEGER)"
view_query = "SELECT my_table.col1, my_table.col2 FROM public.my_table"
view_ddl = ("CREATE VIEW my_late_view AS "
"%s WITH NO SCHEMA BINDING" % view_query)
conn = redshift_engine.connect()
conn.execute(table_ddl)
conn.execute(view_ddl)
insp = inspect(redshift_engine)
view_definition = insp.get_view_definition('my_late_view')
# For some reason, Redshift returns the entire DDL for late binding views.
assert(clean(compile_query(view_definition)) == clean(view_ddl))
view = Table('my_late_view', MetaData(),
autoload=True, autoload_with=redshift_engine)
assert(len(view.columns) == 2)
|
Add test for late-binding views
|
Add test for late-binding views
|
Python
|
mit
|
sqlalchemy-redshift/sqlalchemy-redshift,sqlalchemy-redshift/sqlalchemy-redshift,graingert/redshift_sqlalchemy
|
e051c915d72b76a189c16de6ff82bcebdab9f881
|
caffe2/python/layers/__init__.py
|
caffe2/python/layers/__init__.py
|
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from importlib import import_module
import pkgutil
import sys
import inspect
from . import layers
def import_recursive(package, clsmembers):
"""
Takes a package and imports all modules underneath it
"""
pkg_dir = package.__path__
module_location = package.__name__
for (_module_loader, name, ispkg) in pkgutil.iter_modules(pkg_dir):
module_name = "{}.{}".format(module_location, name) # Module/package
module = import_module(module_name)
clsmembers += [cls[1] for cls in inspect.getmembers(module, inspect.isclass)]
if ispkg:
import_recursive(module, clsmembers)
clsmembers = []
import_recursive(sys.modules[__name__], clsmembers)
for cls in clsmembers:
if issubclass(cls, layers.ModelLayer) and cls is not layers.ModelLayer:
layers.register_layer(cls.__name__, cls)
|
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from importlib import import_module
import pkgutil
import sys
from . import layers
def import_recursive(package):
"""
Takes a package and imports all modules underneath it
"""
pkg_dir = package.__path__
module_location = package.__name__
for (_module_loader, name, ispkg) in pkgutil.iter_modules(pkg_dir):
module_name = "{}.{}".format(module_location, name) # Module/package
module = import_module(module_name)
if ispkg:
import_recursive(module)
def find_subclasses_recursively(base_cls, sub_cls):
cur_sub_cls = base_cls.__subclasses__()
sub_cls.update(cur_sub_cls)
for cls in cur_sub_cls:
find_subclasses_recursively(cls, sub_cls)
import_recursive(sys.modules[__name__])
model_layer_subcls = set()
find_subclasses_recursively(layers.ModelLayer, model_layer_subcls)
for cls in list(model_layer_subcls):
layers.register_layer(cls.__name__, cls)
|
Allow to import subclasses of layers
|
Allow to import subclasses of layers
Summary:
We want it to be able to register children of layers who
are not direct children of ModelLayer.
This requires us to find subclasses of ModelLayer recursively.
Reviewed By: kittipatv, kennyhorror
Differential Revision: D5397120
fbshipit-source-id: cb1e03d72e3bedb960b1b865877a76e413218a71
|
Python
|
apache-2.0
|
Yangqing/caffe2,xzturn/caffe2,sf-wind/caffe2,pietern/caffe2,pietern/caffe2,davinwang/caffe2,sf-wind/caffe2,davinwang/caffe2,sf-wind/caffe2,caffe2/caffe2,Yangqing/caffe2,bwasti/caffe2,Yangqing/caffe2,bwasti/caffe2,xzturn/caffe2,pietern/caffe2,davinwang/caffe2,bwasti/caffe2,bwasti/caffe2,sf-wind/caffe2,sf-wind/caffe2,bwasti/caffe2,pietern/caffe2,Yangqing/caffe2,davinwang/caffe2,xzturn/caffe2,Yangqing/caffe2,xzturn/caffe2,davinwang/caffe2,pietern/caffe2,xzturn/caffe2
|
b99770a7c55cd6951df872793a54bfa260b145f9
|
basics/test/module-test.py
|
basics/test/module-test.py
|
from unittest import TestCase
from basics import BaseCharacter
from basics import BaseAttachment
class ModuleTest(TestCase):
def test_character_attach_attachment(self):
character = BaseCharacter().save()
attachment = BaseAttachment().save()
# Attachment should not be among the character's attachments
self.assertNotIn(attachment.id, character.attachments())
# Attach the attachment
character.attach(attachment)
# Attachment should be among the character's attachments
self.assertIn(attachment.id, character.attachments())
def test_container_containment(self):
self.fail("Test unwritten")
|
from unittest import TestCase
from basics import BaseCharacter
from basics import BaseAttachment
from basics import BaseThing
class ModuleTest(TestCase):
def test_character_attach_attachment(self):
character = BaseCharacter().save()
attachment = BaseAttachment().save()
# Attachment should not be among the character's attachments
self.assertNotIn(attachment.id, character.attachments())
# Attach the attachment
character.attach(attachment)
# Attachment should be among the character's attachments
self.assertIn(attachment.id, character.attachments())
def test_container_containment(self):
thing_a = BaseThing().save()
thing_b = BaseThing().save()
# thing_b should not be among thing_a's stuff
self.assertNotIn(thing_b.id, thing_a.stuff())
# thing_b aint contained
self.assertIsNone(thing_b.container())
# Move thing_b into thing_a
thing_b.move_to(thing_a)
# thing_b should be among thing_a's stuff
self.assertIn(thing_b.id, thing_a.stuff())
# thing_b is contained by thing_a
self.assertEqual(thing_a, thing_b.container())
|
Write test for container containment.
|
Write test for container containment.
|
Python
|
apache-2.0
|
JASchilz/RoverMUD
|
b506b6796a8ed9e778f69ddc7718a8ea3b0f9e7a
|
flynn/__init__.py
|
flynn/__init__.py
|
# coding: utf-8
import flynn.decoder
import flynn.encoder
def dump(obj, fp):
return flynn.encoder.encode(fp, obj)
def dumps(obj):
return flynn.encoder.encode_str(obj)
def dumph(obj):
return "".join(hex(n)[2:].rjust(2, "0") for n in dumps(obj))
def load(s):
return flynn.decoder.decode(s)
def loads(s):
return flynn.decoder.decode(s)
def loadh(s):
return flynn.decoder.decode(s)
|
# coding: utf-8
import base64
import flynn.decoder
import flynn.encoder
__all__ = [
"decoder",
"encoder",
"dump",
"dumps",
"dumph",
"load",
"loads",
"loadh"
]
def dump(obj, fp):
return flynn.encoder.encode(fp, obj)
def dumps(obj):
return flynn.encoder.encode_str(obj)
def dumph(obj):
return base64.b16encode(dumps(obj)).decode("utf-8")
def load(s):
return flynn.decoder.decode(s)
def loads(s):
return flynn.decoder.decode(s)
def loadh(s):
return flynn.decoder.decode(s)
|
Use base64 module to convert between bytes and base16 string
|
Use base64 module to convert between bytes and base16 string
|
Python
|
mit
|
fritz0705/flynn
|
7b71425a4434ac2544340d651f52c0d87ff37132
|
web/impact/impact/v1/helpers/refund_code_helper.py
|
web/impact/impact/v1/helpers/refund_code_helper.py
|
# MIT License
# Copyright (c) 2017 MassChallenge, Inc.
from impact.models import RefundCode
from impact.v1.helpers.model_helper import(
INTEGER_ARRAY_FIELD,
INTEGER_FIELD,
ModelHelper,
PK_FIELD,
STRING_FIELD,
)
PROGRAMS_FIELD = {
"json-schema": {
"type": "array",
"items": {"type": "string"},
},
"POST": {"required": False},
"PATCH": {"required": False},
}
REFUND_CODE_FIELDS = {
"id": PK_FIELD,
"issued_to": INTEGER_FIELD,
"created_at": STRING_FIELD,
"unique_code": STRING_FIELD,
"discount": INTEGER_FIELD,
"maximum_uses": INTEGER_FIELD,
"programs": INTEGER_ARRAY_FIELD,
}
class RefundCodeHelper(ModelHelper):
model = RefundCode
@classmethod
def fields(self):
return REFUND_CODE_FIELDS
@property
def issued_to(self):
return self.field_pk("issued_to")
@property
def programs(self):
if hasattr(self.subject, "programs"):
programs = self.subject.programs
if programs:
return [program.pk for program in programs.all()]
|
# MIT License
# Copyright (c) 2017 MassChallenge, Inc.
from impact.models import RefundCode
from impact.v1.helpers.model_helper import(
BOOLEAN_FIELD,
INTEGER_ARRAY_FIELD,
INTEGER_FIELD,
ModelHelper,
PK_FIELD,
STRING_FIELD,
)
PROGRAMS_FIELD = {
"json-schema": {
"type": "array",
"items": {"type": "string"},
},
"POST": {"required": False},
"PATCH": {"required": False},
}
REFUND_CODE_FIELDS = {
"id": PK_FIELD,
"issued_to": INTEGER_FIELD,
"created_at": STRING_FIELD,
"unique_code": STRING_FIELD,
"discount": INTEGER_FIELD,
"maximum_uses": INTEGER_FIELD,
"programs": INTEGER_ARRAY_FIELD,
"notes": STRING_FIELD,
"internal": BOOLEAN_FIELD,
}
class RefundCodeHelper(ModelHelper):
model = RefundCode
@classmethod
def fields(self):
return REFUND_CODE_FIELDS
@property
def issued_to(self):
return self.field_pk("issued_to")
@property
def programs(self):
if hasattr(self.subject, "programs"):
programs = self.subject.programs
if programs:
return [program.pk for program in programs.all()]
|
Add Notes and Internal Fields
|
[AC-5291] Add Notes and Internal Fields
|
Python
|
mit
|
masschallenge/impact-api,masschallenge/impact-api,masschallenge/impact-api,masschallenge/impact-api
|
c1f71014218d9b6cdb6c45d9d1ce0cc0424f70f8
|
doc/pyplots/stylesheet_gallery.py
|
doc/pyplots/stylesheet_gallery.py
|
# -*- coding: utf-8 -*-
"""Generate a gallery to compare all available typhon styles.
"""
import numpy as np
import matplotlib.pyplot as plt
from typhon.plots import styles
def simple_plot(stylename):
"""Generate a simple plot using a given matplotlib style."""
x = np.linspace(0, np.pi, 20)
fig, ax = plt.subplots()
for s in np.linspace(0, np.pi / 2, 12):
ax.plot(x, np.sin(x+s),
label=r'$\Delta\omega = {:.2f}$'.format(s),
marker='.',
)
ax.set_ylabel('y-axis')
ax.set_xlabel('x-axis')
ax.set_title(stylename)
ax.grid()
ax.legend()
# Create plot using default styles.
simple_plot('matplotlib 2.0')
# Create a plot for each available typhon style.
for style_name in styles.available:
with plt.style.context(styles(style_name)):
simple_plot(style_name)
plt.show()
|
# -*- coding: utf-8 -*-
"""Generate a gallery to compare all available typhon styles.
"""
import numpy as np
import matplotlib.pyplot as plt
from typhon.plots import styles
def simple_plot(stylename):
"""Generate a simple plot using a given matplotlib style."""
if stylename == 'typhon-dark':
# TODO: Sphinx build is broken for non-white figure facecolor.
return
x = np.linspace(0, np.pi, 20)
fig, ax = plt.subplots()
for s in np.linspace(0, np.pi / 2, 12):
ax.plot(x, np.sin(x+s),
label=r'$\Delta\omega = {:.2f}$'.format(s),
marker='.',
)
ax.set_ylabel('y-axis')
ax.set_xlabel('x-axis')
ax.set_title(stylename)
ax.grid()
ax.legend()
# Create plot using default styles.
simple_plot('matplotlib 2.0')
# Create a plot for each available typhon style.
for style_name in styles.available:
with plt.style.context(styles(style_name)):
simple_plot(style_name)
plt.show()
|
Exclude dark-colored theme from stylesheet gallery.
|
Exclude dark-colored theme from stylesheet gallery.
|
Python
|
mit
|
atmtools/typhon,atmtools/typhon
|
41fbd5b92ac04c3a4ca0e33204bb08b12a533052
|
ibmcnx/doc/DataSources.py
|
ibmcnx/doc/DataSources.py
|
######
# Check ExId (GUID) by Email through JDBC
#
# Author: Christoph Stoettner
# Mail: [email protected]
# Documentation: http://scripting101.stoeps.de
#
# Version: 2.0
# Date: 2014-06-04
#
# License: Apache 2.0
#
# Check ExId of a User in all Connections Applications
import ibmcnx.functions
cell = AdminConfig.getid( '"/Cell:' + AdminControl.getCell() + '/"' )
dbs = AdminConfig.list( 'DataSource', cell )
for db in dbs:
t1 = ibmcnx.functions.getDSId( db )
AdminConfig.list( t1 )
|
######
# Check ExId (GUID) by Email through JDBC
#
# Author: Christoph Stoettner
# Mail: [email protected]
# Documentation: http://scripting101.stoeps.de
#
# Version: 2.0
# Date: 2014-06-04
#
# License: Apache 2.0
#
# Check ExId of a User in all Connections Applications
import ibmcnx.functions
cell = "'/Cell:" + AdminControl.getCell() + "/'"
print cell
cellid = AdminConfig.getid( )
dbs = AdminConfig.list( 'DataSource', cellid )
for db in dbs:
t1 = ibmcnx.functions.getDSId( db )
AdminConfig.list( t1 )
|
Create script to save documentation to a file
|
4: Create script to save documentation to a file
Task-Url: http://github.com/stoeps13/ibmcnx2/issues/issue/4
|
Python
|
apache-2.0
|
stoeps13/ibmcnx2,stoeps13/ibmcnx2
|
07c3c7e00a4c2733a3233ff483797c798451a87f
|
apps/predict/mixins.py
|
apps/predict/mixins.py
|
"""
Basic view mixins for predict views
"""
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from .models import PredictDataset
class PredictMixin(object):
"""The baseline predict view"""
slug_field = 'md5'
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
"""Only allow a logged in users to view"""
return super(PredictMixin, self).dispatch(request, *args, **kwargs)
def get_queryset(self):
"""Limit queryset to the user's own predictions only"""
qs = PredictDataset.objects.all()
if 'slug' not in self.kwargs:
# Limit to my own predictions unless I have the md5
qs = qs.filter(user_id=self.request.user.pk)
return qs
|
"""
Basic view mixins for predict views
"""
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from .models import PredictDataset
class PredictMixin(object):
"""The baseline predict view"""
slug_field = 'md5'
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
"""Only allow a logged in users to view"""
return super(PredictMixin, self).dispatch(request, *args, **kwargs)
def get_queryset(self):
"""Limit queryset to the user's own predictions only"""
qset = PredictDataset.objects.all()
if 'slug' not in self.kwargs:
# Limit to my own predictions unless I have the md5
qset = qset.filter(user_id=self.request.user.pk)
return qset.prefetch_related('strains', 'strains__piperun', 'strains__piperun__programs')
|
Improve prefetch speed in predict listing pages
|
Improve prefetch speed in predict listing pages
|
Python
|
agpl-3.0
|
IQSS/gentb-site,IQSS/gentb-site,IQSS/gentb-site,IQSS/gentb-site,IQSS/gentb-site,IQSS/gentb-site,IQSS/gentb-site,IQSS/gentb-site
|
324941bb4946cea19800fb1102035bd32e8028db
|
apps/profiles/views.py
|
apps/profiles/views.py
|
from django.views.generic import DetailView, UpdateView
from django.contrib.auth.views import redirect_to_login
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from braces.views import LoginRequiredMixin
from .models import User
class ProfileDetailView(DetailView):
'''
Displays the user profile information
'''
model = User
slug_field = 'username'
slug_url_kwarg = 'username'
def get(self, request, *args, **kwargs):
user = request.user
username = self.kwargs.get(self.slug_url_kwarg)
if user.is_authenticated() and not username:
return redirect('profile_detail', username=user.username)
elif not user.is_authenticated() and not username:
return redirect_to_login(reverse('profile_detail_me'))
return super(ProfileDetailView, self).get(request, *args, **kwargs)
class ProfileUpdateView(LoginRequiredMixin, UpdateView):
model = User
slug_field = 'username'
slug_url_kwarg = 'username'
|
from django.views.generic import DetailView, UpdateView
from django.contrib.auth.views import redirect_to_login
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from braces.views import LoginRequiredMixin
from .models import User
class ProfileDetailView(DetailView):
'''
Displays the user profile information
'''
queryset = User.objects.select_related('location', 'location__country')
slug_field = 'username'
slug_url_kwarg = 'username'
def get(self, request, *args, **kwargs):
user = request.user
username = self.kwargs.get(self.slug_url_kwarg)
if user.is_authenticated() and not username:
return redirect('profile_detail', username=user.username)
elif not user.is_authenticated() and not username:
return redirect_to_login(reverse('profile_detail_me'))
return super(ProfileDetailView, self).get(request, *args, **kwargs)
class ProfileUpdateView(LoginRequiredMixin, UpdateView):
model = User
slug_field = 'username'
slug_url_kwarg = 'username'
|
Use select_related in user profile detail view
|
Use select_related in user profile detail view
|
Python
|
mit
|
SoPR/horas,SoPR/horas,SoPR/horas,SoPR/horas
|
3e842228beba066000eac536635e7e9d4d87c8e2
|
instruments/Instrument.py
|
instruments/Instrument.py
|
from traits.api import HasTraits
import json
class Instrument(HasTraits):
"""
Main super-class for all instruments.
"""
def get_settings(self):
return self.__getstate__()
def set_settings(self, settings):
for key,value in settings.items():
setattr(self, key, value)
|
from traits.api import HasTraits, Bool
import json
class Instrument(HasTraits):
"""
Main super-class for all instruments.
"""
enabled = Bool(True, desc='Whether the unit is used/enabled.')
def get_settings(self):
return self.__getstate__()
def set_settings(self, settings):
for key,value in settings.items():
setattr(self, key, value)
|
Add enabled to top-level instrument class.
|
Add enabled to top-level instrument class.
|
Python
|
apache-2.0
|
Plourde-Research-Lab/PyQLab,rmcgurrin/PyQLab,calebjordan/PyQLab,BBN-Q/PyQLab
|
cfe594ec7576ba36e93762981067ad02176a585e
|
instruments/Instrument.py
|
instruments/Instrument.py
|
from traits.api import HasTraits
import json
class Instrument(HasTraits):
"""
Main super-class for all instruments.
"""
def get_settings(self):
return self.__getstate__()
def set_settings(self, settings):
for key,value in settings.items():
setattr(self, key, value)
|
from traits.api import HasTraits, Bool
import json
class Instrument(HasTraits):
"""
Main super-class for all instruments.
"""
enabled = Bool(True, desc='Whether the unit is used/enabled.')
def get_settings(self):
return self.__getstate__()
def set_settings(self, settings):
for key,value in settings.items():
setattr(self, key, value)
|
Add enabled to top-level instrument class.
|
Add enabled to top-level instrument class.
|
Python
|
apache-2.0
|
Plourde-Research-Lab/PyQLab,BBN-Q/PyQLab,calebjordan/PyQLab,rmcgurrin/PyQLab
|
413413ac7b2f5a953443bdd08d625a55bd890938
|
flaws/__init__.py
|
flaws/__init__.py
|
#!/usr/bin/env python
import sys
from funcy import split, map
from .analysis import global_usage, local_usage, FileSet
def main():
command = sys.argv[1]
opts, args = split(r'^--', sys.argv[2:])
opts = dict(map(r'^--(\w+)(?:=(.+))?', opts))
# Run ipdb on exception
if 'ipdb' in opts:
import ipdb, traceback
def info(type, value, tb):
traceback.print_exception(type, value, tb)
print
ipdb.pm()
sys.excepthook = info
# Register plugins
from .ext import django
django.register(args, opts)
# Do the job
files = FileSet(args, base=opts.get('base'), ignore=opts.get('ignore'))
if command == 'global':
global_usage(files)
elif command == 'local':
local_usage(files)
else:
print 'Unknown command', command
if __name__ == '__main__':
main()
|
#!/usr/bin/env python
import sys
from funcy import split, map
from .analysis import global_usage, local_usage, FileSet
def main():
command = sys.argv[1]
opts, args = split(r'^--', sys.argv[2:])
opts = dict(map(r'^--(\w+)(?:=(.+))?', opts))
# Run ipdb on exception
if 'ipdb' in opts:
import ipdb, traceback
def info(type, value, tb):
traceback.print_exception(type, value, tb)
print
# Insert look-around helpers into the frame
import inspect, ast
from .asttools import to_source
frame = inspect.getinnerframes(tb)[-1][0]
frame.f_globals.setdefault('ast', ast)
frame.f_globals.setdefault('to_source', to_source)
# Run debugger
ipdb.pm()
sys.excepthook = info
# Register plugins
from .ext import django
django.register(args, opts)
# Do the job
files = FileSet(args, base=opts.get('base'), ignore=opts.get('ignore'))
if command == 'global':
global_usage(files)
elif command == 'local':
local_usage(files)
else:
print 'Unknown command', command
if __name__ == '__main__':
main()
|
Insert look-around helpers into ipdb context
|
Insert look-around helpers into ipdb context
These are `ast` and `to_source`.
|
Python
|
bsd-2-clause
|
Suor/flaws
|
8beb6ddd2e58d6a3e54ab297d490c6650fb85a9d
|
logya/generate.py
|
logya/generate.py
|
# -*- coding: utf-8 -*-
import os
import shutil
from logya.core import Logya
from logya.fs import copytree
from logya.writer import DocWriter
class Generate(Logya):
"""Generate a Web site to deploy from current directory as source."""
def __init__(self, **kwargs):
super(self.__class__, self).__init__(**kwargs)
self.init_env()
# Init writer before executing scripts, so they can use it.
self.writer = DocWriter(self.dir_deploy, self.template)
if not kwargs['keep']:
self.info('Remove existing deploy directory')
shutil.rmtree(self.dir_deploy, True)
self.info('Generating site in directory: {}'.format(self.dir_deploy))
if os.path.exists(self.dir_static):
self.info('Copy static files')
copytree(self.dir_static, self.dir_deploy)
self.info('Build document index')
self.build_index()
self.info('Write documents')
for doc in self.docs.values():
self.writer.write(doc, self.get_doc_template(doc))
self.info(
'Written {:d} documents to deploy directory'
.format(len(self.docs)))
self.info('Write index files')
self.write_index_files()
self.info(
'Written {:d} index files to deploy directory'
.format(len(self.index)))
|
# -*- coding: utf-8 -*-
import os
import shutil
from logya.core import Logya
from logya.fs import copytree
from logya.writer import DocWriter
class Generate(Logya):
"""Generate a Web site to deploy from current directory as source."""
def __init__(self, **kwargs):
super(self.__class__, self).__init__(**kwargs)
self.init_env()
self.writer = DocWriter(self.dir_deploy, self.template)
if not kwargs['keep']:
self.info('Remove existing deploy directory')
shutil.rmtree(self.dir_deploy, True)
self.info('Generate site in directory: {}'.format(self.dir_deploy))
if os.path.exists(self.dir_static):
self.info('Copy static files')
copytree(self.dir_static, self.dir_deploy)
self.build()
self.write()
def build(self):
self.info('Build document index')
self.build_index()
def write(self):
self.info('Write documents')
for doc in self.docs.values():
self.writer.write(doc, self.get_doc_template(doc))
self.info(
'Written {:d} documents to deploy directory'
.format(len(self.docs)))
self.info('Write index files')
self.write_index_files()
self.info(
'Written {:d} index files to deploy directory'
.format(len(self.index)))
|
Add build and write function to make it easy to subclass Generate and overwrite build step
|
Add build and write function to make it easy to subclass Generate and overwrite build step
|
Python
|
mit
|
elaOnMars/logya,elaOnMars/logya,elaOnMars/logya,yaph/logya,yaph/logya
|
9971e5424b998f45e26b9da8288f20d641885043
|
massa/__init__.py
|
massa/__init__.py
|
# -*- coding: utf-8 -*-
from flask import Flask, render_template, g
from flask.ext.appconfig import AppConfig
def create_app(configfile=None):
app = Flask('massa')
AppConfig(app, configfile)
@app.route('/')
def index():
return render_template('index.html')
from .container import build
sl = build(app.config)
from .api import bp
app.register_blueprint(bp, url_prefix='/api')
@app.before_request
def globals():
g.sl = sl
return app
|
# -*- coding: utf-8 -*-
from flask import Flask, render_template, g
from flask.ext.appconfig import AppConfig
from .container import build
from .api import bp as api
def create_app(configfile=None):
app = Flask('massa')
AppConfig(app, configfile)
@app.route('/')
def index():
return render_template('index.html')
sl = build(app.config)
app.register_blueprint(api, url_prefix='/api')
@app.before_request
def globals():
g.sl = sl
return app
|
Move import statements to the top.
|
Move import statements to the top.
|
Python
|
mit
|
jaapverloop/massa
|
12c97be97a8816720899531b932be99743b6d90d
|
rest_framework_plist/__init__.py
|
rest_framework_plist/__init__.py
|
# -*- coding: utf-8 -*-
from distutils import version
__version__ = '0.2.0'
version_info = version.StrictVersion(__version__).version
|
# -*- coding: utf-8 -*-
from distutils import version
__version__ = '0.2.0'
version_info = version.StrictVersion(__version__).version
from .parsers import PlistParser # NOQA
from .renderers import PlistRenderer # NOQA
|
Make parser and renderer available at package root
|
Make parser and renderer available at package root
|
Python
|
bsd-2-clause
|
lpomfrey/django-rest-framework-plist,pombredanne/django-rest-framework-plist
|
3f7371c796a420cc077cf79b210d401c77b77815
|
rest_framework/response.py
|
rest_framework/response.py
|
from django.core.handlers.wsgi import STATUS_CODE_TEXT
from django.template.response import SimpleTemplateResponse
class Response(SimpleTemplateResponse):
"""
An HttpResponse that allows it's data to be rendered into
arbitrary media types.
"""
def __init__(self, data=None, status=None, headers=None,
renderer=None, accepted_media_type=None):
"""
Alters the init arguments slightly.
For example, drop 'template_name', and instead use 'data'.
Setting 'renderer' and 'media_type' will typically be defered,
For example being set automatically by the `APIView`.
"""
super(Response, self).__init__(None, status=status)
self.data = data
self.headers = headers and headers[:] or []
self.renderer = renderer
self.accepted_media_type = accepted_media_type
@property
def rendered_content(self):
self['Content-Type'] = self.renderer.media_type
if self.data is None:
return self.renderer.render()
render_media_type = self.accepted_media_type or self.renderer.media_type
return self.renderer.render(self.data, render_media_type)
@property
def status_text(self):
"""
Returns reason text corresponding to our HTTP response status code.
Provided for convenience.
"""
return STATUS_CODE_TEXT.get(self.status_code, '')
|
from django.core.handlers.wsgi import STATUS_CODE_TEXT
from django.template.response import SimpleTemplateResponse
class Response(SimpleTemplateResponse):
"""
An HttpResponse that allows it's data to be rendered into
arbitrary media types.
"""
def __init__(self, data=None, status=None, headers=None,
renderer=None, accepted_media_type=None):
"""
Alters the init arguments slightly.
For example, drop 'template_name', and instead use 'data'.
Setting 'renderer' and 'media_type' will typically be defered,
For example being set automatically by the `APIView`.
"""
super(Response, self).__init__(None, status=status)
self.data = data
self.headers = headers and headers[:] or []
self.renderer = renderer
# Accepted media type is the portion of the request Accept header
# that the renderer satisfied. It could be '*/*', or somthing like
# 'application/json; indent=4'
#
# This is NOT the value that will be returned in the 'Content-Type'
# header, but we do need to know the value in case there are
# any specific parameters which affect the rendering process.
self.accepted_media_type = accepted_media_type
@property
def rendered_content(self):
self['Content-Type'] = self.renderer.media_type
if self.data is None:
return self.renderer.render()
render_media_type = self.accepted_media_type or self.renderer.media_type
return self.renderer.render(self.data, render_media_type)
@property
def status_text(self):
"""
Returns reason text corresponding to our HTTP response status code.
Provided for convenience.
"""
return STATUS_CODE_TEXT.get(self.status_code, '')
|
Tweak media_type -> accepted_media_type. Need to document, but marginally less confusing
|
Tweak media_type -> accepted_media_type. Need to document, but marginally less confusing
|
Python
|
bsd-2-clause
|
kylefox/django-rest-framework,cyberj/django-rest-framework,vstoykov/django-rest-framework,wedaly/django-rest-framework,canassa/django-rest-framework,tomchristie/django-rest-framework,linovia/django-rest-framework,cheif/django-rest-framework,nhorelik/django-rest-framework,jpulec/django-rest-framework,James1345/django-rest-framework,ashishfinoit/django-rest-framework,ticosax/django-rest-framework,rubendura/django-rest-framework,d0ugal/django-rest-framework,ashishfinoit/django-rest-framework,werthen/django-rest-framework,adambain-vokal/django-rest-framework,jpadilla/django-rest-framework,kgeorgy/django-rest-framework,ebsaral/django-rest-framework,jerryhebert/django-rest-framework,VishvajitP/django-rest-framework,edx/django-rest-framework,pombredanne/django-rest-framework,douwevandermeij/django-rest-framework,douwevandermeij/django-rest-framework,maryokhin/django-rest-framework,nryoung/django-rest-framework,jness/django-rest-framework,rafaelang/django-rest-framework,wzbozon/django-rest-framework,johnraz/django-rest-framework,ossanna16/django-rest-framework,maryokhin/django-rest-framework,VishvajitP/django-rest-framework,agconti/django-rest-framework,kennydude/django-rest-framework,brandoncazander/django-rest-framework,callorico/django-rest-framework,antonyc/django-rest-framework,alacritythief/django-rest-framework,wangpanjun/django-rest-framework,rhblind/django-rest-framework,iheitlager/django-rest-framework,bluedazzle/django-rest-framework,atombrella/django-rest-framework,gregmuellegger/django-rest-framework,paolopaolopaolo/django-rest-framework,elim/django-rest-framework,kgeorgy/django-rest-framework,nryoung/django-rest-framework,kezabelle/django-rest-framework,cheif/django-rest-framework,aericson/django-rest-framework,xiaotangyuan/django-rest-framework,tigeraniya/django-rest-framework,nhorelik/django-rest-framework,YBJAY00000/django-rest-framework,sheppard/django-rest-framework,jpulec/django-rest-framework,wangpanjun/django-rest-framework,justanr/django-rest-framework,agconti/django-rest-framework,hunter007/django-rest-framework,sbellem/django-rest-framework,canassa/django-rest-framework,abdulhaq-e/django-rest-framework,AlexandreProenca/django-rest-framework,elim/django-rest-framework,arpheno/django-rest-framework,werthen/django-rest-framework,potpath/django-rest-framework,damycra/django-rest-framework,delinhabit/django-rest-framework,ticosax/django-rest-framework,ticosax/django-rest-framework,rafaelang/django-rest-framework,HireAnEsquire/django-rest-framework,wzbozon/django-rest-framework,raphaelmerx/django-rest-framework,hnakamur/django-rest-framework,edx/django-rest-framework,buptlsl/django-rest-framework,yiyocx/django-rest-framework,potpath/django-rest-framework,wwj718/django-rest-framework,hunter007/django-rest-framework,jness/django-rest-framework,fishky/django-rest-framework,andriy-s/django-rest-framework,antonyc/django-rest-framework,ajaali/django-rest-framework,damycra/django-rest-framework,yiyocx/django-rest-framework,qsorix/django-rest-framework,buptlsl/django-rest-framework,abdulhaq-e/django-rest-framework,buptlsl/django-rest-framework,dmwyatt/django-rest-framework,yiyocx/django-rest-framework,aericson/django-rest-framework,jness/django-rest-framework,uruz/django-rest-framework,ambivalentno/django-rest-framework,dmwyatt/django-rest-framework,MJafarMashhadi/django-rest-framework,adambain-vokal/django-rest-framework,kylefox/django-rest-framework,thedrow/django-rest-framework-1,canassa/django-rest-framework,zeldalink0515/django-rest-framework,sehmaschine/django-rest-framework,paolopaolopaolo/django-rest-framework,aericson/django-rest-framework,agconti/django-rest-framework,nhorelik/django-rest-framework,xiaotangyuan/django-rest-framework,zeldalink0515/django-rest-framework,krinart/django-rest-framework,bluedazzle/django-rest-framework,rafaelcaricio/django-rest-framework,leeahoward/django-rest-framework,iheitlager/django-rest-framework,raphaelmerx/django-rest-framework,jpadilla/django-rest-framework,abdulhaq-e/django-rest-framework,hunter007/django-rest-framework,kennydude/django-rest-framework,davesque/django-rest-framework,iheitlager/django-rest-framework,ebsaral/django-rest-framework,ebsaral/django-rest-framework,akalipetis/django-rest-framework,tcroiset/django-rest-framework,wedaly/django-rest-framework,James1345/django-rest-framework,xiaotangyuan/django-rest-framework,sehmaschine/django-rest-framework,cyberj/django-rest-framework,mgaitan/django-rest-framework,tigeraniya/django-rest-framework,mgaitan/django-rest-framework,hnakamur/django-rest-framework,MJafarMashhadi/django-rest-framework,MJafarMashhadi/django-rest-framework,alacritythief/django-rest-framework,rafaelang/django-rest-framework,simudream/django-rest-framework,zeldalink0515/django-rest-framework,simudream/django-rest-framework,d0ugal/django-rest-framework,kylefox/django-rest-framework,ezheidtmann/django-rest-framework,ajaali/django-rest-framework,leeahoward/django-rest-framework,sbellem/django-rest-framework,waytai/django-rest-framework,rafaelcaricio/django-rest-framework,mgaitan/django-rest-framework,tomchristie/django-rest-framework,hnakamur/django-rest-framework,uploadcare/django-rest-framework,cheif/django-rest-framework,pombredanne/django-rest-framework,sheppard/django-rest-framework,wwj718/django-rest-framework,tcroiset/django-rest-framework,krinart/django-rest-framework,atombrella/django-rest-framework,lubomir/django-rest-framework,AlexandreProenca/django-rest-framework,brandoncazander/django-rest-framework,raphaelmerx/django-rest-framework,arpheno/django-rest-framework,delinhabit/django-rest-framework,brandoncazander/django-rest-framework,waytai/django-rest-framework,ajaali/django-rest-framework,gregmuellegger/django-rest-framework,leeahoward/django-rest-framework,paolopaolopaolo/django-rest-framework,HireAnEsquire/django-rest-framework,arpheno/django-rest-framework,jpadilla/django-rest-framework,jerryhebert/django-rest-framework,andriy-s/django-rest-framework,krinart/django-rest-framework,ezheidtmann/django-rest-framework,davesque/django-rest-framework,vstoykov/django-rest-framework,tomchristie/django-rest-framework,ezheidtmann/django-rest-framework,simudream/django-rest-framework,thedrow/django-rest-framework-1,ambivalentno/django-rest-framework,rubendura/django-rest-framework,adambain-vokal/django-rest-framework,justanr/django-rest-framework,johnraz/django-rest-framework,fishky/django-rest-framework,jpulec/django-rest-framework,kezabelle/django-rest-framework,d0ugal/django-rest-framework,ossanna16/django-rest-framework,wwj718/django-rest-framework,uploadcare/django-rest-framework,fishky/django-rest-framework,douwevandermeij/django-rest-framework,lubomir/django-rest-framework,YBJAY00000/django-rest-framework,linovia/django-rest-framework,lubomir/django-rest-framework,ashishfinoit/django-rest-framework,vstoykov/django-rest-framework,ossanna16/django-rest-framework,linovia/django-rest-framework,antonyc/django-rest-framework,wedaly/django-rest-framework,rhblind/django-rest-framework,sehmaschine/django-rest-framework,YBJAY00000/django-rest-framework,potpath/django-rest-framework,thedrow/django-rest-framework-1,delinhabit/django-rest-framework,VishvajitP/django-rest-framework,elim/django-rest-framework,jtiai/django-rest-framework,rafaelcaricio/django-rest-framework,sbellem/django-rest-framework,callorico/django-rest-framework,pombredanne/django-rest-framework,andriy-s/django-rest-framework,kgeorgy/django-rest-framework,sheppard/django-rest-framework,akalipetis/django-rest-framework,tigeraniya/django-rest-framework,hnarayanan/django-rest-framework,cyberj/django-rest-framework,atombrella/django-rest-framework,dmwyatt/django-rest-framework,HireAnEsquire/django-rest-framework,waytai/django-rest-framework,wangpanjun/django-rest-framework,damycra/django-rest-framework,ambivalentno/django-rest-framework,AlexandreProenca/django-rest-framework,nryoung/django-rest-framework,gregmuellegger/django-rest-framework,hnarayanan/django-rest-framework,johnraz/django-rest-framework,James1345/django-rest-framework,tcroiset/django-rest-framework,uruz/django-rest-framework,uploadcare/django-rest-framework,werthen/django-rest-framework,davesque/django-rest-framework,bluedazzle/django-rest-framework,qsorix/django-rest-framework,alacritythief/django-rest-framework,callorico/django-rest-framework,jerryhebert/django-rest-framework,jtiai/django-rest-framework,jtiai/django-rest-framework,rubendura/django-rest-framework,kennydude/django-rest-framework,qsorix/django-rest-framework,uruz/django-rest-framework,edx/django-rest-framework,justanr/django-rest-framework,akalipetis/django-rest-framework,rhblind/django-rest-framework,hnarayanan/django-rest-framework,wzbozon/django-rest-framework,kezabelle/django-rest-framework,maryokhin/django-rest-framework
|
7a1254fa530b02d32f39e2210ec864f78dd9504a
|
groundstation/transfer/response_handlers/describeobjects.py
|
groundstation/transfer/response_handlers/describeobjects.py
|
from groundstation import logger
log = logger.getLogger(__name__)
def handle_describeobjects(self):
if not self.payload:
log.info("station %s sent empty DESCRIVEOBJECTS payload - new database?" % (str(self.origin)))
return
for obj in self.payload.split(chr(0)):
if obj not in self.station or True:
request = self._Request("FETCHOBJECT", payload=obj)
self.stream.enqueue(request)
else:
log.debug("Not fetching already present object %s" % (str(obj)))
|
from groundstation import logger
log = logger.getLogger(__name__)
def handle_describeobjects(self):
if not self.payload:
log.info("station %s sent empty DESCRIVEOBJECTS payload - new database?" % (str(self.origin)))
return
for obj in self.payload.split(chr(0)):
if obj not in self.station:
request = self._Request("FETCHOBJECT", payload=obj)
self.stream.enqueue(request)
else:
log.debug("Not fetching already present object %s" % (str(obj)))
|
Remove hook that snuck in
|
Remove hook that snuck in
|
Python
|
mit
|
richo/groundstation,richo/groundstation,richo/groundstation,richo/groundstation,richo/groundstation
|
b11a0197bbecbbdb6e5f3c82285f6b749596947d
|
api/oauth2_urls.py
|
api/oauth2_urls.py
|
from django.conf.urls import url
from oauth2_provider import views
urlpatterns = (
url(r'^authorize/$', views.AuthorizationView.as_view(
template_name='accounts/authorize_client.html',
), name="authorize"),
url(r'^token/$', views.TokenView.as_view(), name="token"),
url(r'^revoke_token/$', views.RevokeTokenView.as_view(), name="revoke-token"),
)
|
from django.conf.urls import url
from oauth2_provider import views
urlpatterns = (
url(r'^authorize/?$', views.AuthorizationView.as_view(
template_name='accounts/authorize_client.html',
), name="authorize"),
url(r'^token/?$', views.TokenView.as_view(), name="token"),
url(r'^revoke_token/?$', views.RevokeTokenView.as_view(), name="revoke-token"),
)
|
Make trailing slash optional in API oauth URL patterns
|
Make trailing slash optional in API oauth URL patterns
https://github.com/AudioCommons/ac-mediator/issues/19
|
Python
|
apache-2.0
|
AudioCommons/ac-mediator,AudioCommons/ac-mediator,AudioCommons/ac-mediator
|
eb763a7c7048b857d408825241ed3de6b68b88f6
|
1/sumofmultiplesof3and5.py
|
1/sumofmultiplesof3and5.py
|
# Project Euler - Problem 1
sum = 0
for i in xrange(1, 1001):
if i % 3 == 0 or i % 5 == 0:
sum = sum + i
print "The sum is: {}".format(sum)
|
# Project Euler - Problem 1
# If we list all the natural numbers below 10 that are multiples of 3 or 5,
# we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
def main(limit):
sum = 0
for i in xrange(1, limit):
if i % 3 == 0 or i % 5 == 0:
sum = sum + i
print "The sum of all multiples of 3 and 5 below {} is: {}".format(limit, sum)
if __name__ == "__main__":
main(10)
main(1001)
|
Clean up problem 1 solution a bit.
|
Clean up problem 1 solution a bit.
|
Python
|
mit
|
gregmojonnier/ProjectEuler
|
1179d825cafb512119906894527de801e43ed906
|
metatlas/tests/test_query.py
|
metatlas/tests/test_query.py
|
from __future__ import print_function
from metatlas.mzml_loader import mzml_to_hdf, get_test_data
from metatlas.h5_query import get_XICof, get_data
def rmse(target, predictions):
target = target / target.max()
predictions = predictions / predictions.max()
return np.sqrt(((predictions - targets) ** 2).mean())
def test_xicof():
return
fid = tables.open_file('140808_1_RCH2_neg.h5')
x, y = get_XICof(fid, 1, 1000, 1, 0)
xicof_scidb = np.load('xicof_scidb.npy')
assert rmse(y, xicof_scidb[:, 1]) < 0.01
data = get_data(fid, 1, 0, mz_min=1, mz_max=1000)
assert x.sum() == data['i'].sum()
assert y[0] == data['rt'][0]
assert y[-1] == data['rt'][-1]
|
from __future__ import print_function
from metatlas.mzml_loader import mzml_to_hdf, get_test_data
from metatlas.h5_query import get_XIC, get_data
def rmse(target, predictions):
target = target / target.max()
predictions = predictions / predictions.max()
return np.sqrt(((predictions - targets) ** 2).mean())
def test_xicof():
return
fid = tables.open_file('140808_1_RCH2_neg.h5')
x, y = get_XICof(fid, 1, 1000, 1, 0)
xicof_scidb = np.load('xicof_scidb.npy')
assert rmse(y, xicof_scidb[:, 1]) < 0.01
data = get_data(fid, 1, 0, mz_min=1, mz_max=1000)
assert x.sum() == data['i'].sum()
assert y[0] == data['rt'][0]
assert y[-1] == data['rt'][-1]
|
Fix another import in test
|
Fix another import in test
|
Python
|
bsd-3-clause
|
biorack/metatlas,biorack/metatlas,metabolite-atlas/metatlas,aitatanit/metatlas,metabolite-atlas/metatlas,aitatanit/metatlas,aitatanit/metatlas,metabolite-atlas/metatlas
|
d05c68b110e4adf5f411816196cf1f457e51951e
|
nbrmd/__init__.py
|
nbrmd/__init__.py
|
"""R markdown notebook format for Jupyter
Use this module to read or write Jupyter notebooks as Rmd documents (methods 'read', 'reads', 'write', 'writes')
Use the 'pre_save_hook' method (see its documentation) to automatically dump your Jupyter notebooks as a Rmd file, in addition
to the ipynb file.
Use the 'nbrmd' conversion script to convert Jupyter notebooks from/to R markdown notebooks.
"""
from .nbrmd import read, reads, readf, write, writes, writef
from .hooks import update_rmd, update_ipynb, update_rmd_and_ipynb, update_selected_formats
from .cm import RmdFileContentsManager
|
"""R markdown notebook format for Jupyter
Use this module to read or write Jupyter notebooks as Rmd documents (methods 'read', 'reads', 'write', 'writes')
Use the 'pre_save_hook' method (see its documentation) to automatically dump your Jupyter notebooks as a Rmd file, in addition
to the ipynb file.
Use the 'nbrmd' conversion script to convert Jupyter notebooks from/to R markdown notebooks.
"""
from .nbrmd import read, reads, readf, write, writes, writef
from .hooks import update_rmd, update_ipynb, update_rmd_and_ipynb, update_selected_formats
try:
from .cm import RmdFileContentsManager
except ImportError as e:
RmdFileContentsManager = e.message
|
Allow import in case of missing notebook package
|
Allow import in case of missing notebook package
|
Python
|
mit
|
mwouts/jupytext,mwouts/jupytext,mwouts/jupytext,mwouts/jupytext,mwouts/jupytext,mwouts/jupytext,mwouts/jupytext,mwouts/jupytext,mwouts/jupytext,mwouts/jupytext
|
a918dbdb18f579543916da8dfc14e7d3d06237ae
|
logtacts/prod_settings/__init__.py
|
logtacts/prod_settings/__init__.py
|
from logtacts.settings import *
import dj_database_url
DEBUG = False
TEMPLATE_DEBUG = DEBUG
DATABASES['default'] = dj_database_url.parse(get_env_variable('LOGTACTS_DB_URL'))
SECRET_KEY = get_env_variable("LOGTACTS_SECRET_KEY")
ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
'.pebble.ink',
'.logtacts.com',
'.contactotter.com',
]
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 3600
SECURE_FRAME_DENY = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
STATIC_URL = '//logtacts.s3.amazonaws.com/assets/'
INSTALLED_APPS += (
'gunicorn',
'opbeat.contrib.django',
)
MIDDLEWARE_CLASSES = (
'opbeat.contrib.django.middleware.OpbeatAPMMiddleware',
) + MIDDLEWARE_CLASSES
OPBEAT = {
'ORGANIZATION_ID': get_env_variable("OPBEAT_ORG_ID"),
'APP_ID': get_env_variable("OPBEAT_APP_ID"),
'SECRET_TOKEN': get_env_variable("OPBEAT_SECRET_KEY"),
}
|
from logtacts.settings import *
import dj_database_url
DEBUG = False
TEMPLATE_DEBUG = DEBUG
DATABASES['default'] = dj_database_url.parse(get_env_variable('LOGTACTS_DB_URL'))
SECRET_KEY = get_env_variable("LOGTACTS_SECRET_KEY")
ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
'.pebble.ink',
'.logtacts.com',
'.contactotter.com',
'.herokuapp.com',
]
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 3600
SECURE_FRAME_DENY = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
STATIC_URL = '//logtacts.s3.amazonaws.com/assets/'
INSTALLED_APPS += (
'gunicorn',
'opbeat.contrib.django',
)
MIDDLEWARE_CLASSES = (
'opbeat.contrib.django.middleware.OpbeatAPMMiddleware',
) + MIDDLEWARE_CLASSES
OPBEAT = {
'ORGANIZATION_ID': get_env_variable("OPBEAT_ORG_ID"),
'APP_ID': get_env_variable("OPBEAT_APP_ID"),
'SECRET_TOKEN': get_env_variable("OPBEAT_SECRET_KEY"),
}
|
Make sure heroku is in accepted hosts
|
Make sure heroku is in accepted hosts
|
Python
|
mit
|
phildini/logtacts,phildini/logtacts,phildini/logtacts,phildini/logtacts,phildini/logtacts
|
802626461779e4de34e7994c88ab698495dfca59
|
docs/source/conf.py
|
docs/source/conf.py
|
# Copyright (c) 2014, German Neuroinformatics Node (G-Node)
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted under the terms of the BSD License. See
# LICENSE file in the root of the Project.
# general config
extensions = ['sphinx.ext.autodoc']
source_suffix = '.rst'
master_doc = 'index'
project = 'NIX Python bindings'
copyright = '2014, German Neuroinformatics Node, Adrian Stoewer, Christian Kellner'
exclude_patterns = []
pygments_style = 'sphinx'
# html options
html_theme = 'default'
htmlhelp_basename = 'nix'
|
# Copyright (c) 2014, German Neuroinformatics Node (G-Node)
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted under the terms of the BSD License. See
# LICENSE file in the root of the Project.
# general config
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']
source_suffix = '.rst'
master_doc = 'index'
project = 'NIX Python bindings'
copyright = '2014, German Neuroinformatics Node, Adrian Stoewer, Christian Kellner'
exclude_patterns = []
pygments_style = 'sphinx'
# html options
html_theme = 'default'
htmlhelp_basename = 'nix'
# intersphinx configuration
intersphinx_mapping = {
'http://docs.python.org/2.7' : None,
'http://docs.scipy.org/doc/numpy': None
}
|
Enable intersphinx and add mapping for py2.7 + numpy
|
[doc] Enable intersphinx and add mapping for py2.7 + numpy
|
Python
|
bsd-3-clause
|
stoewer/nixpy,stoewer/nixpy
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.