commit
stringlengths
40
40
old_file
stringlengths
4
236
new_file
stringlengths
4
236
old_contents
stringlengths
1
3.26k
new_contents
stringlengths
16
4.43k
subject
stringlengths
16
624
message
stringlengths
17
3.29k
lang
stringclasses
5 values
license
stringclasses
13 values
repos
stringlengths
5
91.5k
0fb7e8d901addc801fb9b99d744666f573f672d3
billjobs/migrations/0003_auto_20160822_2341.py
billjobs/migrations/0003_auto_20160822_2341.py
# -*- coding: utf-8 -*- # Generated by Django 1.10 on 2016-08-22 23:41 from __future__ import unicode_literals from django.db import migrations def add_billing_address(apps, schema_editor): ''' Data migration add billing_address in Bill from user billing_address field ''' Bill = apps.get_model('billj...
# -*- coding: utf-8 -*- # Generated by Django 1.10 on 2016-08-22 23:41 from __future__ import unicode_literals from django.db import migrations, models def add_billing_address(apps, schema_editor): ''' Data migration add billing_address in Bill from user billing_address field ''' Bill = apps.get_mode...
Add billing_address and migrate data
Add billing_address and migrate data
Python
mit
ioO/billjobs
bbb4496a99a5c65218b12c56de01c12ab83a1056
demo/recent_questions.py
demo/recent_questions.py
#!/usr/bin/env python from __future__ import print_function # Same directory hack import sys sys.path.append('.') sys.path.append('..') try: get_input = raw_input except NameError: get_input = input user_api_key = get_input("Please enter an API key if you have one (Return for none):") if not user_api_key: us...
#!/usr/bin/env python from __future__ import print_function from six.moves import input # Same directory hack import sys sys.path.append('.') sys.path.append('..') user_api_key = input("Please enter an API key if you have one (Return for none):") if not user_api_key: user_api_key = None import stackexchange, thread ...
Use six function for input() in recent questions demo
Use six function for input() in recent questions demo
Python
bsd-3-clause
Khilo84/Py-StackExchange,lucjon/Py-StackExchange,damanjitsingh/StackExchange-python-
d358a759d86ce2a377e4fef84f20075bd0481d3b
ditto/flickr/views.py
ditto/flickr/views.py
from ..ditto.views import PaginatedListView from .models import Account, Photo, User class Home(PaginatedListView): template_name = 'flickr/index.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['account_list'] = Account.objects.all() r...
from ..ditto.views import PaginatedListView from .models import Account, Photo, User class Home(PaginatedListView): template_name = 'flickr/index.html' paginate_by = 48 def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['account_list'] = Account.ob...
Change number of photos per page
Change number of photos per page
Python
mit
philgyford/django-ditto,philgyford/django-ditto,philgyford/django-ditto
7560bce01be5560395dd2373e979dbee086f3c21
py2app/converters/nibfile.py
py2app/converters/nibfile.py
""" Automatic compilation of XIB files """ import subprocess, os from py2app.decorators import converts @converts(suffix=".xib") def convert_xib(source, destination, dry_run=0): destination = destination[:-4] + ".nib" if dry_run: return p = subprocess.Popen(['ibtool', '--compile', destination, so...
""" Automatic compilation of XIB files """ from __future__ import print_function import subprocess, os from py2app.decorators import converts gTool = None def _get_ibtool(): global gTool if gTool is None: if os.path.exists('/usr/bin/xcrun'): gTool = subprocess.check_output(['/usr/bin/xcrun'...
Simplify nib compiler and support recent Xcode versions by using xcrun
Simplify nib compiler and support recent Xcode versions by using xcrun
Python
mit
metachris/py2app,metachris/py2app,metachris/py2app,metachris/py2app
b6d08abf7bc4aafaeec59944bdcdf8ae4a9352d5
recipe_scrapers/consts.py
recipe_scrapers/consts.py
import re TIME_REGEX = re.compile( r'\A(\s*(?P<hours>\d+)\s{1}(hours|hrs|hr|h))?((?P<minutes>\s*\d+)\s{1}(minutes|mins|min|m))?\Z' ) HTML_SYMBOLS = '\xa0' # &nbsp;
import re TIME_REGEX = re.compile( r'\A(\s*(?P<hours>\d+)\s*(hours|hrs|hr|h))?(\s*(?P<minutes>\d+)\s*(minutes|mins|min|m))?\Z' ) HTML_SYMBOLS = '\xa0' # &nbsp;
Update time_regex captcher so to work with more sites
Update time_regex captcher so to work with more sites
Python
mit
hhursev/recipe-scraper
c0de2a081cfe9af7f6b9d39daae557d45f5d69ee
middleware/module_yaml.py
middleware/module_yaml.py
from __future__ import unicode_literals import os import yaml def main(app, data): filepath = os.path.join(app.data_dir, data.get('filename')) with open(filepath, 'r') as f: contents = yaml.load(f) return contents
from __future__ import unicode_literals import os import yaml import requests def local(app, data): filepath = os.path.join(app.data_dir, data.get('filename')) with open(filepath, 'r') as f: contents = yaml.load(f) return contents def remote(app, data): r = requests.get(data.get('url')) ...
Allow remote and local files.
Allow remote and local files.
Python
mit
myles/me-api,myles/me-api
cb0baa6abcb358c4f44135b3f17d02af2d1d4d06
ibmcnx/doc/DataSources.py
ibmcnx/doc/DataSources.py
###### # Check ExId (GUID) by Email through JDBC # # Author: Christoph Stoettner # Mail: christoph.stoettner@stoeps.de # Documentation: http://scripting101.stoeps.de # # Version: 2.0 # Date: 2014-06-04 # # License: Apache 2.0 # # Check ExId of a User in all Connections Appli...
###### # Check ExId (GUID) by Email through JDBC # # Author: Christoph Stoettner # Mail: christoph.stoettner@stoeps.de # Documentation: http://scripting101.stoeps.de # # Version: 2.0 # Date: 2014-06-04 # # License: Apache 2.0 # # Check ExId of a User in all Connections Appli...
Create documentation of DataSource Settings
8: Create documentation of DataSource Settings Task-Url: http://github.com/stoeps13/ibmcnx2/issues/issue/8
Python
apache-2.0
stoeps13/ibmcnx2,stoeps13/ibmcnx2
3a924ebac8ecd1c8ff1dcbf60b9e5ea45fa58554
src/database/__init__.py
src/database/__init__.py
from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy.pool import StaticPool session = None def init_session(connection_string=None, drop=False): if connection_string is None: engine = create_engine('sqlite://', echo...
from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy.pool import StaticPool # The global database session. session = None def init_session(connection_string=None, drop=False): """Initialize the database session and create the schema if it does not exis...
Add documentation on the database session stuff.
Add documentation on the database session stuff.
Python
bsd-3-clause
eXma/meet-and-eat-registration-system,janLo/meet-and-eat-registration-system,janLo/meet-and-eat-registration-system,janLo/meet-and-eat-registration-system,eXma/meet-and-eat-registration-system,eXma/meet-and-eat-registration-system,eXma/meet-and-eat-registration-system,janLo/meet-and-eat-registration-system
2c8351ff8691eb9ad3009d316d932528d6f5c57d
runtests.py
runtests.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os import django from django.conf import settings from django.core.management import call_command sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) opts = {'INSTALLED_APPS': ['widget_tweaks']} if django.VERSION[:2] < (1, 5): opts['DATAB...
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os import django from django.conf import settings from django.core.management import call_command sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) opts = {'INSTALLED_APPS': ['widget_tweaks']} if django.VERSION[:2] < (1, 5): opts['DATAB...
Add more verbosity on test running
:lipstick: Add more verbosity on test running
Python
mit
kmike/django-widget-tweaks,daniboy/django-widget-tweaks
4359a9947c1d86d9e4003c1e8fc358e9a66c6b1d
DisplayAdapter/display_adapter/scripts/init_db.py
DisplayAdapter/display_adapter/scripts/init_db.py
__author__ = 'richard'
""" Script that is run from the command line in order to """ import sys import sqlite3 from display_adapter import db_name help_message = """ This initialises an sqlite3 db for the purposes of the DisplayAdapter programs. Arguments: init_db.py database_name """ runs_table = """ CREATE TABLE runs ( id INTEGER NOT...
Create internal db initialisation script
Create internal db initialisation script Paired by Michael and Richard
Python
mit
CO600GOL/Game_of_life,CO600GOL/Game_of_life,CO600GOL/Game_of_life
4e9dfbaff5a91af75e3b18e6b4e06379747c6083
research_pyutils/__init__.py
research_pyutils/__init__.py
# expose the most frequently used functions in the top level. from .path_related import (mkdir_p, rm_if_exists, remove_empty_paths, copy_contents_of_folder, count_files, copy_the_previous_if_missing, folders_last_modification) try: ...
# expose the most frequently used functions in the top level. from .path_related import (mkdir_p, rm_if_exists, remove_empty_paths, copy_contents_of_folder, count_files, copy_the_previous_if_missing, folders_last_modification) try: ...
Add in the init the newly introduced function
Add in the init the newly introduced function
Python
apache-2.0
grigorisg9gr/pyutils,grigorisg9gr/pyutils
ba4f692e00d87afdd65d3a1b88046089b709eaab
organizer/views.py
organizer/views.py
from django.http.response import HttpResponse from django.template import Context, loader from .models import Tag def homepage(request): tag_list = Tag.objects.all() template = loader.get_template( 'organizer/tag_list.html') context = Context({'tag_list': tag_list}) output = template.render(c...
from django.http.response import HttpResponse from django.template import Context, loader from .models import Tag def homepage(request): tag_list = Tag.objects.all() template = loader.get_template( 'organizer/tag_list.html') context = Context({'tag_list': tag_list}) output = template.render(c...
Tag Detail: get Tag from database.
Ch05: Tag Detail: get Tag from database.
Python
bsd-2-clause
jambonrose/DjangoUnleashed-1.8,jambonrose/DjangoUnleashed-1.8
147a3d1c690b7e1c80fafd6eb4c834585e733564
ibmcnx/test/loadFunction.py
ibmcnx/test/loadFunction.py
import sys from java.lang import String from java.util import HashSet from java.util import HashMap import java globdict = globals() def loadFilesService(): global globdict execfile("filesAdmin.py", globdict)
import sys from java.lang import String from java.util import HashSet from java.util import HashMap import java globdict = globals() def loadFilesService(): global globdict exec open("filesAdmin.py").read()
Customize scripts to work with menu
Customize scripts to work with menu
Python
apache-2.0
stoeps13/ibmcnx2,stoeps13/ibmcnx2
76c87d06efaac19350d870cd1c95229ed0a66c29
editdistance/__init__.py
editdistance/__init__.py
from .bycython import eval __all__ = ('eval',)
from .bycython import eval def distance(*args, **kwargs): """"An alias to eval""" return eval(*args, **kwargs) __all__ = ('eval', 'distance')
Add alias method named "distance"
Add alias method named "distance"
Python
mit
aflc/editdistance,aflc/editdistance,aflc/editdistance
bea98b8228131d4228ba364c18ec89f4188c8a18
rdtools/__init__.py
rdtools/__init__.py
from energy_normalization import normalize_with_sapm from ._version import get_versions __version__ = get_versions()['version'] del get_versions
from energy_normalization import normalize_with_sapm from degradation import rd_with_ols from ._version import get_versions __version__ = get_versions()['version'] del get_versions
Add degradation module to init.
Add degradation module to init.
Python
mit
kwhanalytics/rdtools,kwhanalytics/rdtools
aff77b144c1a1895c9e8c0ca2d4e79451525901c
terminus/models/trunk.py
terminus/models/trunk.py
""" Copyright (C) 2017 Open Source Robotics Foundation 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...
""" Copyright (C) 2017 Open Source Robotics Foundation 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...
Make Trunks have opposite directions in the included lanes
Make Trunks have opposite directions in the included lanes
Python
apache-2.0
ekumenlabs/terminus,ekumenlabs/terminus
e8940b632737f75897c0ea7c108563a63f1a5dde
transducer/test/test_functional.py
transducer/test/test_functional.py
import unittest from transducer.functional import compose class TestComposition(unittest.TestCase): def test_single(self): """ compose(f)(x) -> f(x) """ f = lambda x: x * 2 c = compose(f) # We can't test the equivalence of functions completely, so... self...
import unittest from transducer.functional import compose, true, identity, false class TestComposition(unittest.TestCase): def test_single(self): """ compose(f)(x) -> f(x) """ f = lambda x: x * 2 c = compose(f) # We can't test the equivalence of functions complet...
Improve test coverage of functional.py.
Improve test coverage of functional.py.
Python
mit
sixty-north/python-transducers
2408c5260106e050557b4898d5826932eb758142
normandy/selfrepair/views.py
normandy/selfrepair/views.py
from django.shortcuts import render from normandy.base.decorators import api_cache_control @api_cache_control() def repair(request, locale): return render(request, "selfrepair/repair.html")
from django.shortcuts import render from django.views.decorators.cache import cache_control ONE_WEEK_IN_SECONDS = 60 * 60 * 24 * 7 @cache_control(public=True, max_age=ONE_WEEK_IN_SECONDS) def repair(request, locale): return render(request, "selfrepair/repair.html")
Increase cache on deprecated self-repair to one week
Increase cache on deprecated self-repair to one week This view serves a message that the system is no longer active. We keep it around because it is still gets about 40 million hits per day, primarily from Firefox ESR 52, which never got the Normandy client. Notably, when we dropped support for Windows XP from Firefox...
Python
mpl-2.0
mozilla/normandy,mozilla/normandy,mozilla/normandy,mozilla/normandy
dd260182bd8157fd6ac2a266b3ae5cf168400266
tests/custom_keywords.py
tests/custom_keywords.py
import os from raven import Client def generate_event(msg, dsn): client = Client(dsn) client.captureMessage(msg) def clear_inbox(maildir): print('Clearing inbox at {}'.format(maildir)) for fname in os.listdir(maildir): os.remove(os.path.join(maildir, fname)) def inbox_should_contain_num_m...
import os from raven import Client def generate_event(msg, dsn): client = Client(dsn) client.captureMessage(msg) def clear_inbox(maildir): print('Clearing inbox at {}'.format(maildir)) if not os.path.isdir(maildir): return for fname in os.listdir(maildir): os.remove(os.path.join...
Make Clear Inbox keyword more robust.
Make Clear Inbox keyword more robust.
Python
bsd-3-clause
andialbrecht/sentry-comments,andialbrecht/sentry-comments
114f40dd282d1837db42ffb6625760d1483d3192
jfu/templatetags/jfutags.py
jfu/templatetags/jfutags.py
from django.core.context_processors import csrf from django.core.urlresolvers import reverse from django.template import Library, Context, loader register = Library() @register.simple_tag( takes_context = True ) def jfu( context, template_name = 'jfu/upload_form.html', upload_handler_name =...
from django.core.context_processors import csrf from django.core.urlresolvers import reverse from django.template import Library, Context, loader register = Library() @register.simple_tag( takes_context = True ) def jfu( context, template_name = 'jfu/upload_form.html', upload_handler_name =...
Allow args and kwargs to upload_handler_name
Allow args and kwargs to upload_handler_name Now can use args and kwargs for reverse url. Example in template: {% jfu 'core/core_fileuploader.html' 'core_upload' object_id=1 content_type_str='app.model' %}
Python
bsd-3-clause
Alem/django-jfu,dzhuang/django-jfu,Alem/django-jfu,dzhuang/django-jfu,Alem/django-jfu,dzhuang/django-jfu,dzhuang/django-jfu,Alem/django-jfu
9f3289f45c727835c8f52b0c2489b06da2f03c25
pyglab/__init__.py
pyglab/__init__.py
__title__ = 'pyglab' __version__ = '0.0dev' __author__ = 'Michael Schlottke' __license__ = 'MIT License' __copyright__ = '(c) 2014 Michael Schlottke' from .pyglab import Pyglab from .apirequest import ApiRequest, RequestType
__title__ = 'pyglab' __version__ = '0.0dev' __author__ = 'Michael Schlottke' __license__ = 'MIT License' __copyright__ = '(c) 2014 Michael Schlottke' from .pyglab import Pyglab from .exceptions import RequestError from .apirequest import ApiRequest, RequestType
Make RequestError available in package root.
Make RequestError available in package root.
Python
mit
sloede/pyglab,sloede/pyglab
cd2bc29837d31d8999d9f72f7ddaecddb56e26a5
tests/unit/test_views.py
tests/unit/test_views.py
from flask import json from nose.tools import eq_ from server import app client = app.test_client() def test_hello_world(): # When: I access root path resp = client.get('/') # Then: Expected response is returned eq_(resp.status_code, 200) eq_(resp.headers['Content-Type'], 'application/json') ...
from flask import json from nose.tools import eq_ from server import app client = app.test_client() def test_hello_world(): # When: I access root path resp = client.get('/') # Then: Expected response is returned eq_(resp.status_code, 200) eq_(resp.headers['Content-Type'], 'application/json') ...
Use startswith instead of exact string match
Use startswith instead of exact string match
Python
mit
agarone-mm/scholastic-demo,totem/totem-demo,risingspiral/appnexus-demo
a59a856a52a175ae3cbe79fcd6ea49d481aaacf3
fabfile.py
fabfile.py
from fabric.api import * # noqa env.hosts = [ '104.131.30.135', ] env.user = "root" env.directory = "/home/django/api.freemusic.ninja" env.deploy_path = "/home/django/django_project" def deploy(): with cd(env.directory): run("git fetch") run("git reset --hard origin/master") sudo("p...
from fabric.api import * # noqa env.hosts = [ '104.131.30.135', ] env.user = "root" env.directory = "/home/django/api.freemusic.ninja" env.deploy_path = "/home/django/django_project" def deploy(): with cd(env.directory): run("git fetch") run("git reset --hard origin/master") sudo("p...
Break celeryd restart into distict 'stop' and 'start' commands on deploy
Break celeryd restart into distict 'stop' and 'start' commands on deploy
Python
bsd-3-clause
FreeMusicNinja/api.freemusic.ninja
b30d4301d58766471f435536cf804f7a63448ac5
qotr/tests/test_server.py
qotr/tests/test_server.py
from tornado import testing from qotr.server import make_application from qotr.config import config class TestChannelHandler(testing.AsyncHTTPTestCase): ''' Test the channel creation handler. ''' port = None application = None def get_app(self): return make_application() def te...
from tornado import testing from qotr.server import make_application from qotr.config import config class TestChannelHandler(testing.AsyncHTTPTestCase): ''' Test the channel creation handler. ''' port = None application = None def get_app(self): return make_application() # def t...
Disable testing for index.html, needs ember build
Disable testing for index.html, needs ember build Signed-off-by: Rohan Jain <f3a935f2cb7c3d75d1446a19169b923809d6e623@gmail.com>
Python
agpl-3.0
rmoorman/qotr,rmoorman/qotr,sbuss/qotr,rmoorman/qotr,crodjer/qotr,sbuss/qotr,crodjer/qotr,sbuss/qotr,curtiszimmerman/qotr,curtiszimmerman/qotr,rmoorman/qotr,crodjer/qotr,curtiszimmerman/qotr,curtiszimmerman/qotr,sbuss/qotr,crodjer/qotr
cda81a4585d2b2be868e784566f3c804feb1e9bf
analyze.py
analyze.py
import sys import re def main(argv): # Message to perform sentiment analysis on message = argv[0] if len(argv) > 0 else "" if message == "": print("Usage: python analyze.py [message]") sys.exit(1) # Load the positive and negative words words = {} with open("words/positive.txt"...
import sys import re def main(argv): # Load the positive and negative words words = {} with open("words/positive.txt") as file: for line in file: words[line.rstrip()] = 1 with open("words/negative.txt") as file: for line in file: words[line.rstrip()] = -1 #...
Read from standard input and perform on each line
Read from standard input and perform on each line The analyze script can now be run with, for example - echo "Message" | python analyze.py - cat | python analyze.py (enter messages and end with Ctrl-D) - python analyze.py < filename - MapReduce (at some point)
Python
mit
timvandermeij/sentiment-analysis,timvandermeij/sentiment-analysis
da72373b572d3ce76ccc82b9f4ada7a122e76eb2
__init__.py
__init__.py
# The version of Review Board. # # This is in the format of: # # (Major, Minor, Micro, alpha/beta/rc/final, Release Number, Released) # VERSION = (1, 0, 1, 'alpha', 1, False) def get_version_string(): version = '%s.%s' % (VERSION[0], VERSION[1]) if VERSION[2]: version += ".%s" % VERSION[2] if ...
# The version of Review Board. # # This is in the format of: # # (Major, Minor, Micro, alpha/beta/rc/final, Release Number, Released) # VERSION = (1, 0, 1, 'alpha', 1, False) def get_version_string(): version = '%s.%s' % (VERSION[0], VERSION[1]) if VERSION[2]: version += ".%s" % VERSION[2] if ...
Fix the version string generation when not a final or RC release.
Fix the version string generation when not a final or RC release.
Python
mit
chipx86/reviewboard,sgallagher/reviewboard,chazy/reviewboard,davidt/reviewboard,custode/reviewboard,beol/reviewboard,atagar/ReviewBoard,Khan/reviewboard,1tush/reviewboard,reviewboard/reviewboard,custode/reviewboard,davidt/reviewboard,reviewboard/reviewboard,Khan/reviewboard,chazy/reviewboard,Khan/reviewboard,chazy/revi...
ac3c0e93adf35015d7f6cfc8c6cf2e6ec45cdeae
server/canonicalization/relationship_mapper.py
server/canonicalization/relationship_mapper.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """Contains functions to canonicalize relationships.""" from __future__ import absolute_import from __future__ import print_function from nltk.corpus import wordnet from .utils import wordnet_helper from .utils import common def canonicalize_relationship(text): words...
#!/usr/bin/env python # -*- coding: utf-8 -*- """Contains functions to canonicalize relationships.""" from __future__ import absolute_import from __future__ import print_function import repoze.lru from nltk.corpus import wordnet from .utils import wordnet_helper from .utils import common @repoze.lru.lru_cache(4096) ...
Add LRU for relationship mapper.
[master] Add LRU for relationship mapper.
Python
mit
hotpxl/canonicalization-server,hotpxl/canonicalization-server
452924faafcfb4dcb1eb960ea30ab000f1f93962
migrations/versions/0245_archived_flag_jobs.py
migrations/versions/0245_archived_flag_jobs.py
""" Revision ID: 0245_archived_flag_jobs Revises: 0244_another_letter_org Create Date: 2018-11-22 16:32:01.105803 """ from alembic import op import sqlalchemy as sa revision = '0245_archived_flag_jobs' down_revision = '0244_another_letter_org' def upgrade(): # ### commands auto generated by Alembic - please a...
""" Revision ID: 0245_archived_flag_jobs Revises: 0244_another_letter_org Create Date: 2018-11-22 16:32:01.105803 """ from alembic import op import sqlalchemy as sa revision = '0245_archived_flag_jobs' down_revision = '0244_another_letter_org' def upgrade(): # ### commands auto generated by Alembic - please a...
Update jobs archived flag before setting the default value
Update jobs archived flag before setting the default value Running an update before setting the column default value reduces the time the table is locked (since most rows don't have a NULL value anymore), but the migration takes slightly longer to run overall.
Python
mit
alphagov/notifications-api,alphagov/notifications-api
e3a530d741529a7bbfeb274c232e2c6b8a5faddc
kokki/cookbooks/postgresql9/recipes/default.py
kokki/cookbooks/postgresql9/recipes/default.py
import os from kokki import Execute, Package apt_list_path = '/etc/apt/sources.list.d/pitti-postgresql-lucid.list' Execute("apt-update-postgresql9", command = "apt-get update", action = "nothing") apt = None if env.system.platform == "ubuntu": Package("python-software-properties") Execute("add-apt-re...
import os from kokki import Execute, Package if not (env.system.platform == "ubuntu" and env.system.lsb['release'] in ["11.10"]): apt_list_path = '/etc/apt/sources.list.d/pitti-postgresql-lucid.list' Execute("apt-update-postgresql9", command = "apt-get update", action = "nothing") apt = N...
Use standard repo for postgresql9 in ubuntu 11.10
Use standard repo for postgresql9 in ubuntu 11.10
Python
bsd-3-clause
samuel/kokki
8e47696a805cce70989a79cc6e8324aaec870f6d
electionleaflets/apps/people/devs_dc_helpers.py
electionleaflets/apps/people/devs_dc_helpers.py
import requests from django.conf import settings class DevsDCAPIHelper: def __init__(self): self.AUTH_TOKEN = settings.DEVS_DC_AUTH_TOKEN self.base_url = "https://developers.democracyclub.org.uk/api/v1" def make_request(self, endpoint, **params): default_params = { "auth_...
import requests from django.conf import settings class DevsDCAPIHelper: def __init__(self): self.AUTH_TOKEN = settings.DEVS_DC_AUTH_TOKEN self.base_url = "https://developers.democracyclub.org.uk/api/v1" self.ballot_cache = {} def make_request(self, endpoint, **params): defaul...
Add a cached ballot fetcher to the DevsDC helper
Add a cached ballot fetcher to the DevsDC helper If we happen to run out of RAM in Lambda (we won't), Lambda will just kill the function and invoke a new one next time.
Python
mit
DemocracyClub/electionleaflets,DemocracyClub/electionleaflets,DemocracyClub/electionleaflets
00c808efd2ab38bcf9d808dcb784c9360a19937f
api/radar_api/views/organisation_consultants.py
api/radar_api/views/organisation_consultants.py
from radar_api.serializers.organisation_consultants import OrganisationConsultantSerializer from radar.models import OrganisationConsultant from radar.views.core import RetrieveUpdateDestroyModelView, ListCreateModelView class OrganisationConsultantListView(ListCreateModelView): serializer_class = OrganisationCon...
from radar_api.serializers.organisation_consultants import OrganisationConsultantSerializer from radar.models import OrganisationConsultant from radar.views.core import RetrieveUpdateDestroyModelView, ListCreateModelView from radar.permissions import AdminPermission class OrganisationConsultantListView(ListCreateMode...
Add permissions to organisation consultants endpoint
Add permissions to organisation consultants endpoint
Python
agpl-3.0
renalreg/radar,renalreg/radar,renalreg/radar,renalreg/radar
c977e1c235ccb040f28bc03c63d2667924d5edd3
pythonforandroid/recipes/xeddsa/__init__.py
pythonforandroid/recipes/xeddsa/__init__.py
from pythonforandroid.recipe import CythonRecipe from pythonforandroid.toolchain import current_directory, shprint from os.path import join import sh class XedDSARecipe(CythonRecipe): name = 'xeddsa' version = '0.4.4' url = 'https://pypi.python.org/packages/source/X/XEdDSA/XEdDSA-{version}.tar.gz' dep...
from pythonforandroid.recipe import CythonRecipe from pythonforandroid.toolchain import current_directory, shprint from os.path import join import sh class XedDSARecipe(CythonRecipe): name = 'xeddsa' version = '0.4.4' url = 'https://pypi.python.org/packages/source/X/XEdDSA/XEdDSA-{version}.tar.gz' dep...
Fix xeddsa crypto_sign shared lib copy
Fix xeddsa crypto_sign shared lib copy Could be `_crypto_sign.cpython-37m-x86_64-linux-gnu.so` or simply `_crypto_sign.so` depending on the platform/distribution
Python
mit
germn/python-for-android,rnixx/python-for-android,rnixx/python-for-android,germn/python-for-android,rnixx/python-for-android,kivy/python-for-android,PKRoma/python-for-android,germn/python-for-android,germn/python-for-android,kronenpj/python-for-android,kivy/python-for-android,kronenpj/python-for-android,kivy/python-for...
6deab74e41cabcb9a3fb4075f270a9cdd591a435
pgallery/tests/test_utils.py
pgallery/tests/test_utils.py
from __future__ import unicode_literals import unittest from ..models import sanitize_exif_value class SanitizeExifValueTestCase(unittest.TestCase): def test_strip_null_bytes(self): """ Check that null bytes are stripped from the string. """ key = "not relevant" value = "...
from __future__ import unicode_literals import unittest from ..models import sanitize_exif_value class SanitizeExifValueTestCase(unittest.TestCase): def test_strip_null_bytes(self): """ Check that null bytes are stripped from the string. """ key = "not relevant" value = "...
Test type coercion in sanitize_exif_value
Test type coercion in sanitize_exif_value
Python
mit
zsiciarz/django-pgallery,zsiciarz/django-pgallery
42709afec9f2e2ed419365f61324ce0c8ff96423
budget/forms.py
budget/forms.py
from django import forms from django.template.defaultfilters import slugify from budget.models import Budget, BudgetEstimate class BudgetForm(forms.ModelForm): class Meta: model = Budget fields = ('name', 'start_date') def save(self): if not self.instance.slug: self.in...
import datetime from django import forms from django.template.defaultfilters import slugify from budget.models import Budget, BudgetEstimate class BudgetForm(forms.ModelForm): start_date = forms.DateTimeField(initial=datetime.datetime.now, required=False, widget=forms.SplitDateTimeWidget) class Meta: ...
Split the start_date for better data entry (and Javascript date pickers).
Split the start_date for better data entry (and Javascript date pickers).
Python
bsd-3-clause
jokimies/django-pj-budget,jokimies/django-pj-budget,toastdriven/django-budget,toastdriven/django-budget,jokimies/django-pj-budget
db6b9761d51d45b2708ba6bca997196fc73fbe94
sheldon/__init__.py
sheldon/__init__.py
# -*- coding: utf-8 -*- """ @author: Seva Zhidkov @contact: zhidkovseva@gmail.com @license: The MIT license Copyright (C) 2015 """ # Bot module contains bot's main class - Sheldon from sheldon.bot import * # Hooks module contains hooks for plugins from sheldon.hooks import * # Utils folder contains scripts for mor...
# -*- coding: utf-8 -*- """ @author: Seva Zhidkov @contact: zhidkovseva@gmail.com @license: The MIT license Copyright (C) 2015 """ # Bot module contains bot's main class - Sheldon from sheldon.bot import * # Hooks module contains hooks for plugins from sheldon.hooks import * # Adapter module contains classes and t...
Add adapter module to init file
Add adapter module to init file
Python
mit
lises/sheldon
82d312826ee67b098d9e9a52277912d8e1829960
geocode.py
geocode.py
import os import sys import json import urllib import urllib2 api_key = os.getenv("MAPS_API_KEY") if api_key == "": sys.exit("Please obtain an API key from https://developers.google.com/maps/documentation/geocoding/start#get-a-key and set the environment variable MAPS_API_KEY") #print api_key url = 'https://maps...
import os import sys import json import urllib import urllib2 api_key = os.getenv("MAPS_API_KEY") if api_key == "": sys.exit("Please obtain an API key from https://developers.google.com/maps/documentation/geocoding/start#get-a-key and set the environment variable MAPS_API_KEY") #print api_key url = 'https://maps...
Remove second ? from URL
Remove second ? from URL
Python
bsd-3-clause
caseyjlaw/flaskigm,caseyjlaw/flaskigm
987fd7555eadfa15d10db7991f4a7e8a4a7dbbbf
custom/topo-2sw-2host.py
custom/topo-2sw-2host.py
"""Custom topology example author: Brandon Heller (brandonh@stanford.edu) Two directly connected switches plus a host for each switch: host --- switch --- switch --- host Adding the 'topos' dict with a key/value pair to generate our newly defined topology enables one to pass in '--topo=mytopo' from the command l...
"""Custom topology example author: Brandon Heller (brandonh@stanford.edu) Two directly connected switches plus a host for each switch: host --- switch --- switch --- host Adding the 'topos' dict with a key/value pair to generate our newly defined topology enables one to pass in '--topo=mytopo' from the command l...
Fix custom topology example; outdated import
Fix custom topology example; outdated import Reported-by: Julius Bachnick
Python
bsd-3-clause
mininet/mininet,mininet/mininet,mininet/mininet
66805c134125d957d7c7a0234e6b46e6aa1fa17f
walltime.py
walltime.py
#!/usr/bin/env python """ Created on Fri Mar 14 15:25:36 2014 @author: ibackus """ import time t0 = time.time() import matplotlib.pyplot as plt import numpy as np import datetime import sys t1 = time.time() print 'Importing took {} s'.format(t1-t0) if len(sys.argv) < 2: print 'USAGE: walltime filename...
#!/usr/bin/env python """ Created on Fri Mar 14 15:25:36 2014 @author: ibackus """ import matplotlib.pyplot as plt import numpy as np import datetime import sys if len(sys.argv) < 2: print 'USAGE: walltime filename' else: fname = sys.argv[-1] log_file = np.genfromtxt(fname, comments='#...
Revert "Print statements added for profiling"
Revert "Print statements added for profiling" This reverts commit a6ae05c13666b83a1f1a8707fe21972bd1f758d9.
Python
mit
ibackus/custom_python_packages,trquinn/custom_python_packages
4b819129557d5f0546d9edf206710fd2ec962881
utsokt/restapi/models.py
utsokt/restapi/models.py
from django.db import models from django.utils.translation import ugettext_lazy as _ class Story(models.Model): url = models.URLField(_('URL')) title = models.CharField(_('Title'), max_length=64) excerpt = models.CharField(_('Excerpt'), max_length=64, null=True, blank=True) created_at = models.TimeFie...
from django.db import models from django.utils.translation import ugettext_lazy as _ class Story(models.Model): url = models.URLField(_('URL')) title = models.CharField(_('Title'), max_length=64) excerpt = models.CharField(_('Excerpt'), max_length=64, null=True, blank=True) created_at = models.TimeFie...
Order stories by descending creation time
Order stories by descending creation time
Python
bsd-3-clause
madr/utsokt,madr/utsokt
dd50858ee22c27076919614d1994e3ce9c8e2399
soundem/handlers.py
soundem/handlers.py
from flask import jsonify from soundem import app def json_error_handler(e): return jsonify({ 'status_code': e.code, 'error': 'Bad Request', 'detail': e.description }), e.code @app.errorhandler(400) def bad_request_handler(e): return json_error_handler(e) @app.errorhandler(401...
from flask import jsonify from soundem import app def json_error_handler(e): return jsonify({ 'status_code': e.code, 'error': e.name, 'detail': e.description }), e.code @app.errorhandler(400) def bad_request_handler(e): return json_error_handler(e) @app.errorhandler(401) def u...
Fix json error handler name
Fix json error handler name
Python
mit
building4theweb/soundem-api
dfc7e8a46558d3cf0e7f63da347e2b34253e302c
soundmeter/utils.py
soundmeter/utils.py
from ctypes import * from contextlib import contextmanager import os import stat def get_file_path(f): if f: name = getattr(f, 'name') if name: path = os.path.abspath(name) return path def create_executable(path, content): with open(path, 'w') as f: f.write(co...
from ctypes import * # NOQA from contextlib import contextmanager import os import stat def get_file_path(f): if f: name = getattr(f, 'name') if name: path = os.path.abspath(name) return path def create_executable(path, content): with open(path, 'w') as f: f.w...
Enforce flake8 and NOQA cases
Enforce flake8 and NOQA cases
Python
bsd-2-clause
shichao-an/soundmeter
00eb518f9caeab4df20f08a08826aac57f23300e
notescli/core.py
notescli/core.py
import argparse import yaml import shutil import os from subprocess import call from os.path import expanduser, isdir from config import load_config import cliparser import indexer import io import commands def main(): config = load_config("~/.notes-cli/config.yaml") options = cliparser.parse_options() index =...
import argparse import yaml import shutil import os from subprocess import call from os.path import expanduser, isdir from config import load_config import cliparser import indexer import io import commands def main(): config = load_config("~/.notes-cli/config.yaml") options = cliparser.parse_options() index =...
Remove reindex calls after changes
Remove reindex calls after changes Already reindex notes on initialization
Python
mit
phss/notes-cli
b8e1e5a926bc11d2d8ea975ad24496fca444f09e
betainvite/management/commands/send_waitlist_invites.py
betainvite/management/commands/send_waitlist_invites.py
from django.core.management.base import BaseCommand from optparse import make_option class Command(BaseCommand): help = "Send invitations to people on the waiting list" option_list = BaseCommand.option_list + ( make_option('-c', '--count', type="int", default = 1...
from django.core.management.base import BaseCommand from optparse import make_option class Command(BaseCommand): help = "Send invitations to people on the waiting list" def handle(self, *args, **options): try: count = args[0] except IndexError: print u'usage :', __name__...
Add console log send invitations command
Add console log send invitations command
Python
bsd-3-clause
euanlau/django-betainvite
569dbdc820d9ead02a8941d69b1c8143fe4d4cfa
pytest_pipeline/plugin.py
pytest_pipeline/plugin.py
# -*- coding: utf-8 -*- """ pytest_pipeline.plugin ~~~~~~~~~~~~~~~~~~~~~~ pytest plugin entry point. :copyright: (c) 2014 Wibowo Arindrarto <bow@bow.web.id> :license: BSD """ ## credits to Holger Krekel himself for these xfail marking functions ## http://stackoverflow.com/a/12579625/243058 def p...
# -*- coding: utf-8 -*- """ pytest_pipeline.plugin ~~~~~~~~~~~~~~~~~~~~~~ pytest plugin entry point. :copyright: (c) 2014 Wibowo Arindrarto <bow@bow.web.id> :license: BSD """ ## credits to Holger Krekel himself for these xfail marking functions ## http://stackoverflow.com/a/12579625/243058 def p...
Remove unused 'skip_run' option flag
Remove unused 'skip_run' option flag
Python
bsd-3-clause
bow/pytest-pipeline
4f2a3f26b8b0ec1f62e036f0bd9d15d71a628e0c
mamba/formatters.py
mamba/formatters.py
# -*- coding: utf-8 -*- from clint.textui import indent, puts, colored from mamba import spec class DocumentationFormatter(object): def __init__(self): self.has_failed_tests = False self.total_specs = 0 self.total_seconds = .0 def format(self, item): puts(colored.white(item....
# -*- coding: utf-8 -*- from clint.textui import indent, puts, colored from mamba import spec class DocumentationFormatter(object): def __init__(self): self.has_failed_tests = False self.total_specs = 0 self.total_seconds = .0 def format(self, item): puts() puts(colo...
Put a blank line among main suites
Put a blank line among main suites
Python
mit
alejandrodob/mamba,eferro/mamba,jaimegildesagredo/mamba,dex4er/mamba,angelsanz/mamba,nestorsalceda/mamba,markng/mamba
f9f9111ddafb7dfd0554d541befd3cc660169689
apps/redirects/urls.py
apps/redirects/urls.py
from django.conf.urls.defaults import * from util import redirect urlpatterns = patterns('', redirect(r'^b2g', 'firefoxos'), redirect(r'^b2g/faq', 'firefoxos'), redirect(r'^b2g/about', 'firefoxos'), )
from django.conf.urls.defaults import * from util import redirect urlpatterns = patterns('', redirect(r'^b2g', 'firefoxos.firefoxos'), redirect(r'^b2g/faq', 'firefoxos.firefoxos'), redirect(r'^b2g/about', 'firefoxos.firefoxos'), )
Fix view name for b2g redirects
Fix view name for b2g redirects bug 792482
Python
mpl-2.0
dudepare/bedrock,rishiloyola/bedrock,mahinthjoe/bedrock,ckprice/bedrock,davehunt/bedrock,davidwboswell/documentation_autoresponse,jpetto/bedrock,dudepare/bedrock,glogiotatidis/bedrock,kyoshino/bedrock,mahinthjoe/bedrock,MichaelKohler/bedrock,ckprice/bedrock,analytics-pros/mozilla-bedrock,analytics-pros/mozilla-bedrock,...
960eb0ce813988d8f90e76fbfd0485656cef541f
mff_rams_plugin/__init__.py
mff_rams_plugin/__init__.py
from uber.common import * from ._version import __version__ from .config import * from .models import * from .model_checks import * from .automated_emails import * static_overrides(join(config['module_root'], 'static')) template_overrides(join(config['module_root'], 'templates')) mount_site_sections(config['module_roo...
from uber.common import * from ._version import __version__ from .config import * from .models import * from .model_checks import * from .automated_emails import * static_overrides(join(config['module_root'], 'static')) template_overrides(join(config['module_root'], 'templates')) mount_site_sections(config['module_roo...
Rename new admin dropdown menu
Rename new admin dropdown menu
Python
agpl-3.0
MidwestFurryFandom/mff-rams-plugin,MidwestFurryFandom/mff-rams-plugin
6196c1fe13df88c1d9f1fe706120c175ab890a1d
gen_tone.py
gen_tone.py
import math import numpy from demodulate.cfg import * def gen_tone(pattern, WPM): cycles_per_sample = MORSE_FREQ/SAMPLE_FREQ radians_per_sample = cycles_per_sample * 2 * math.pi elements_per_second = WPM * 50.0 / 60.0 samples_per_element = int(SAMPLE_FREQ/elements_per_second) length = samples_per_element * len(...
import math import numpy from demodulate.cfg import * def gen_tone(pattern, WPM): cycles_per_sample = MORSE_FREQ/SAMPLE_FREQ radians_per_sample = cycles_per_sample * 2 * math.pi elements_per_second = WPM * 50.0 / 60.0 samples_per_element = int(SAMPLE_FREQ/elements_per_second) length = samples_per_element * len(...
Use 16 bit samples instead of float
Use 16 bit samples instead of float
Python
mit
nickodell/morse-code
da28458dffc3529f16cb222fce1676ddb0d87e05
oembed/resources.py
oembed/resources.py
from django.utils.simplejson import simplejson from oembed.exceptions import OEmbedException class OEmbedResource(object): """ OEmbed resource, as well as a factory for creating resource instances from response json """ _data = {} content_object = None def __getattr__(self, name): ...
from django.utils import simplejson from oembed.exceptions import OEmbedException class OEmbedResource(object): """ OEmbed resource, as well as a factory for creating resource instances from response json """ _data = {} content_object = None def __getattr__(self, name): return...
Use the simplejson bundled with django
Use the simplejson bundled with django
Python
mit
0101/djangoembed,worldcompany/djangoembed,akvo/djangoembed,akvo/djangoembed,worldcompany/djangoembed,d4nielcosta/djangoembed,0101/djangoembed,d4nielcosta/djangoembed
1cb201c57c592ebd014910fe225fa594cd87c745
opendebates/middleware.py
opendebates/middleware.py
from opendebates.utils import get_site_mode class SiteModeMiddleware(object): """ Gets or creates a SiteMode for the request, based on the hostname. """ def process_view(self, request, view_func, view_args, view_kwargs): request.site_mode = get_site_mode(request)
from opendebates.utils import get_site_mode class SiteModeMiddleware(object): """ Gets or creates a SiteMode for the request, based on the hostname. """ def process_request(self, request): request.site_mode = get_site_mode(request)
Make sure that the site mode is populated on the request
Make sure that the site mode is populated on the request even if the request winds up getting dispatched to a flatpage.
Python
apache-2.0
caktus/django-opendebates,caktus/django-opendebates,caktus/django-opendebates,caktus/django-opendebates
9651c0278d93bf5c4620e198baac975f0c84e9a0
src/unittest/stattestmain.py
src/unittest/stattestmain.py
def main(): from _m5.stattest import stattest_init, stattest_run import m5.stats stattest_init() # Initialize the global statistics m5.stats.initSimStats() m5.stats.initText("cout") # We're done registering statistics. Enable the stats package now. m5.stats.enable() # Reset to p...
def main(): from _m5.stattest import stattest_init, stattest_run import m5.stats stattest_init() # Initialize the global statistics m5.stats.initSimStats() m5.stats.addStatVisitor("cout") # We're done registering statistics. Enable the stats package now. m5.stats.enable() # Rese...
Fix the stats unit test.
tests: Fix the stats unit test. This has been broken since February. The interface for opening initializing where the stats output should go was changed, but the test wasn't updated. Change-Id: I54bd8be15bf870352d5fcfad95ded28d87c7cc5a Reviewed-on: https://gem5-review.googlesource.com/6001 Reviewed-by: Andreas Sandbe...
Python
bsd-3-clause
TUD-OS/gem5-dtu,gem5/gem5,TUD-OS/gem5-dtu,gem5/gem5,gem5/gem5,TUD-OS/gem5-dtu,TUD-OS/gem5-dtu,gem5/gem5,TUD-OS/gem5-dtu,gem5/gem5,TUD-OS/gem5-dtu,gem5/gem5,gem5/gem5,TUD-OS/gem5-dtu
c9f1335bff52e54f90eed151a273879b0f5144ea
test/test_commonsdowloader.py
test/test_commonsdowloader.py
#!/usr/bin/env python # -*- coding: latin-1 -*- """Unit tests.""" import unittest import commonsdownloader class TestCommonsDownloader(unittest.TestCase): """Testing methods from commonsdownloader.""" def test_clean_up_filename(self): """Test clean_up_filename.""" values = [('Example.jpg',...
#!/usr/bin/env python # -*- coding: latin-1 -*- """Unit tests.""" import unittest import commonsdownloader class TestCommonsDownloader(unittest.TestCase): """Testing methods from commonsdownloader.""" def test_clean_up_filename(self): """Test clean_up_filename.""" values = [('Example.jpg',...
Add unit test for make_thumbnail_name()
Add unit test for make_thumbnail_name()
Python
mit
Commonists/CommonsDownloader
61accbe3fa6ebdeed3bbf48573d5ac5412d0f1db
app/status/views.py
app/status/views.py
import os from flask import jsonify, current_app, request from sqlalchemy.exc import SQLAlchemyError from . import status from . import utils from dmutils.status import get_flags @status.route('/_status') def status_no_db(): if 'ignore-dependencies' in request.args: return jsonify( status="o...
from flask import jsonify, current_app, request from sqlalchemy.exc import SQLAlchemyError from . import status from . import utils from ..models import Framework from dmutils.status import get_flags @status.route('/_status') def status_no_db(): if 'ignore-dependencies' in request.args: return jsonify( ...
Add framework status to API /_status
Add framework status to API /_status To figure out current framework statuses for the given environment you either need access to the API token or you'd have to look through a number of frontend pages to infer the status from. Framework status is a part of almost every request to the API, so it should always be avail...
Python
mit
alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api
8d1a4869286735a55773ce0c074349bb0cafd3aa
ca_on_ottawa/people.py
ca_on_ottawa/people.py
# coding: utf-8 from utils import CSVScraper class OttawaPersonScraper(CSVScraper): csv_url = 'http://data.ottawa.ca/en/dataset/fd26ae83-fe1a-40d8-8951-72df40021c82/resource/33a437d3-a06d-4c56-a7fe-4fd622364ce6/download/elected-officials-282014-201829-v.2.csv'
# coding: utf-8 from utils import CSVScraper class OttawaPersonScraper(CSVScraper): csv_url = 'http://data.ottawa.ca/en/dataset/fd26ae83-fe1a-40d8-8951-72df40021c82/resource/33a437d3-a06d-4c56-a7fe-4fd622364ce6/download/elected-officials-282014-201829-v.2.csv' corrections = { 'district name': { ...
Use corrections, as none of utf-8, iso-8859-1 or windows-1252 work
ca_on_ottawa: Use corrections, as none of utf-8, iso-8859-1 or windows-1252 work
Python
mit
opencivicdata/scrapers-ca,opencivicdata/scrapers-ca
e326cef4ae66d4d2dd500e933ff4f7c6fc619b28
fix-perm.py
fix-perm.py
#!/usr/bin/env python """fix-perm.py - Fix file permissions """ from __future__ import print_function import os import stat import sys if __name__ == '__main__': for line in sys.stdin: path = line.rstrip('\n') if path == '': continue if not os.path.isfile(path): ...
#!/usr/bin/env python """fix-perm.py - Fix file permissions """ from __future__ import print_function import os import stat import sys if __name__ == '__main__': for line in sys.stdin: path = line.rstrip('\n') if path == '': continue if not os.path.isfile(path): ...
Change permissions to either 644 or 755.
Change permissions to either 644 or 755.
Python
isc
eliteraspberries/minipkg,eliteraspberries/minipkg
b7b6fdbc270359e82a2f13f5257a0c2a3875c28f
src/foremast/slacknotify/slack_notification.py
src/foremast/slacknotify/slack_notification.py
"""Notify Slack channel.""" import time from ..utils import get_properties, get_template, post_slack_message class SlackNotification: """Post slack notification. Inform users about infrastructure changes to prod* accounts. """ def __init__(self, app=None, env=None, prop_path=None): timestam...
"""Notify Slack channel.""" import time from ..utils import get_properties, get_template, post_slack_message class SlackNotification: """Post slack notification. Inform users about infrastructure changes to prod* accounts. """ def __init__(self, app=None, env=None, prop_path=None): timestam...
Move properties fetching before dict
fix: Move properties fetching before dict
Python
apache-2.0
gogoair/foremast,gogoair/foremast
0078bb14b85df519744371df89e243822a86ed4c
generate.py
generate.py
import random import sys population = bytes([i for i in range(256)]) if sys.argv[1] == 'reflector': popset = set(population) buffer = [None for i in range(256)] for i in range(128): x, y = random.sample(popset, 2) popset.remove(x) popset.remove(y) buffer[x] = y buff...
import random import sys population = bytes([i for i in range(256)]) if sys.argv[1] == 'reflector': print('WIRING') popset = set(population) buffer = [None for i in range(256)] for i in range(128): x, y = random.sample(popset, 2) popset.remove(x) popset.remove(y) buffer...
Add a little more detail to the generator
Add a little more detail to the generator
Python
mit
spgill/bitnigma
211f1fdfe1d969df7c9762ba8e914d3ea829e9b4
manual/conf.py
manual/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For # a full list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # # To see the default sample conf.py, run sphinx-quickstart in an empty # directory. Mo...
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For # a full list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # # To see the default sample conf.py, run sphinx-quickstart in an empty # directory. Mo...
Allow real <= and >= in LateX
Allow real <= and >= in LateX
Python
apache-2.0
jberkenbilt/qpdf,jberkenbilt/qpdf,jberkenbilt/qpdf,qpdf/qpdf,jberkenbilt/qpdf,qpdf/qpdf,jberkenbilt/qpdf,qpdf/qpdf,qpdf/qpdf,qpdf/qpdf
ad55d04d6688f75f0e441603668e0337a0333d76
tests/test_validate.py
tests/test_validate.py
# -*- coding: utf-8 -*- import pytest from marshmallow import validate, ValidationError def test_invalid_email(): invalid1 = "user@example" with pytest.raises(ValidationError): validate.email(invalid1) invalid2 = "example.com" with pytest.raises(ValidationError): validate.email(invalid...
# -*- coding: utf-8 -*- import pytest from marshmallow import validate, ValidationError def test_invalid_email(): invalid1 = "user@example" with pytest.raises(ValidationError): validate.email(invalid1) invalid2 = "example.com" with pytest.raises(ValidationError): validate.email(invalid...
Add length validator unit tests
Add length validator unit tests
Python
mit
maximkulkin/marshmallow,0xDCA/marshmallow,Tim-Erwin/marshmallow,xLegoz/marshmallow,marshmallow-code/marshmallow,VladimirPal/marshmallow,0xDCA/marshmallow,daniloakamine/marshmallow,dwieeb/marshmallow,mwstobo/marshmallow,quxiaolong1504/marshmallow,etataurov/marshmallow,Bachmann1234/marshmallow,bartaelterman/marshmallow
98eaf33328814342cdf6a2e8379c87cd00c911ce
campaign/views.py
campaign/views.py
from django.core.urlresolvers import reverse from django.shortcuts import redirect, render_to_response from django.template import RequestContext from campaign.forms import CampaignFormSet, ProspectusForm from campaign.models import PROSPECTUS_FIELD_HELP def create_edit_prospectus(request): if request.method == ...
from django.core.urlresolvers import reverse from django.shortcuts import redirect, render_to_response from django.template import RequestContext from campaign.forms import CampaignFormSet, ProspectusForm from campaign.models import PROSPECTUS_FIELD_HELP, Campaign def create_edit_prospectus(request): if request....
Update default queryset for formsets
Update default queryset for formsets
Python
mit
tdphillips/campaigns,tdphillips/campaigns
547130e5f3717fd5bfd083be89afd361fdcdefc1
van/contactology/tests/test_contactology.py
van/contactology/tests/test_contactology.py
import unittest from simplejson import dumps from twisted.trial.unittest import TestCase from twisted.internet import defer from mock import patch, Mock from van.contactology import Contactology class TestProxy(TestCase): @defer.inlineCallbacks def test_list_return(self): patcher = patch('van.contact...
import unittest from simplejson import dumps from twisted.trial.unittest import TestCase from twisted.internet import defer from mock import patch, Mock from van.contactology import Contactology, APIError class TestProxy(TestCase): @defer.inlineCallbacks def test_list_return(self): patcher = patch('v...
Test for exception raising on API error.
Test for exception raising on API error.
Python
bsd-3-clause
jinty/van.contactology
e4c7a9186ef90ab6af637dbfb2bf5331823e64d9
kimochiconsumer/views.py
kimochiconsumer/views.py
from pyramid.view import view_config from pyramid.httpexceptions import ( HTTPNotFound, ) @view_config(route_name='page', renderer='templates/page.mako') @view_config(route_name='page_view', renderer='templates/page.mako') def page_view(request): if 'page_id' in request.matchdict: data = request.kimoc...
from pyramid.view import view_config from pyramid.httpexceptions import ( HTTPNotFound, ) @view_config(route_name='page', renderer='templates/page.mako') @view_config(route_name='page_view', renderer='templates/page.mako') def page_view(request): if 'page_id' in request.matchdict: data = request.kimo...
Remove pprint and add PEP-8 lf
Remove pprint and add PEP-8 lf
Python
mit
matslindh/kimochi-consumer
ee4f312e89fe262a682011da3a7881bfbf47fcdf
spacy/lang/ar/__init__.py
spacy/lang/ar/__init__.py
# coding: utf8 from __future__ import unicode_literals from .stop_words import STOP_WORDS from .lex_attrs import LEX_ATTRS from .punctuation import TOKENIZER_SUFFIXES from .tokenizer_exceptions import TOKENIZER_EXCEPTIONS from ..tokenizer_exceptions import BASE_EXCEPTIONS from ..norm_exceptions import BASE_NORMS from...
# coding: utf8 from __future__ import unicode_literals from .stop_words import STOP_WORDS from .lex_attrs import LEX_ATTRS from .punctuation import TOKENIZER_SUFFIXES from .tokenizer_exceptions import TOKENIZER_EXCEPTIONS from ..tokenizer_exceptions import BASE_EXCEPTIONS from ..norm_exceptions import BASE_NORMS from...
Add writing_system to ArabicDefaults (experimental)
Add writing_system to ArabicDefaults (experimental)
Python
mit
honnibal/spaCy,explosion/spaCy,explosion/spaCy,spacy-io/spaCy,spacy-io/spaCy,explosion/spaCy,explosion/spaCy,explosion/spaCy,honnibal/spaCy,explosion/spaCy,spacy-io/spaCy,honnibal/spaCy,spacy-io/spaCy,honnibal/spaCy,spacy-io/spaCy,spacy-io/spaCy
87de1fce846d7f50017fba885725a0907d43275e
swf/querysets/__init__.py
swf/querysets/__init__.py
#! -*- coding:utf-8 -*- from swf.querysets.activity import ActivityTypeQuerySet from swf.querysets.domain import DomainQuerySet from swf.querysets.workflow import (WorkflowTypeQuerySet, WorkflowExecutionQuerySet)
#! -*- coding:utf-8 -*- from swf.querysets.activity import ActivityTypeQuerySet from swf.querysets.domain import DomainQuerySet from swf.querysets.history import HistoryQuerySet from swf.querysets.workflow import (WorkflowTypeQuerySet, WorkflowExecutionQuerySet)
Add history qs to swf querysets modules
Add history qs to swf querysets modules
Python
mit
botify-labs/python-simple-workflow,botify-labs/python-simple-workflow
3a0b844f33274f7d9c389dd89b21a953cb9c1510
promgen/sender/webhook.py
promgen/sender/webhook.py
''' Simple webhook bridge Accepts alert json from Alert Manager and then POSTs individual alerts to configured webhook destinations ''' import logging import requests from promgen.sender import SenderBase logger = logging.getLogger(__name__) class SenderWebhook(SenderBase): def _send(self, url, alert, data): ...
''' Simple webhook bridge Accepts alert json from Alert Manager and then POSTs individual alerts to configured webhook destinations ''' import logging import requests from promgen.sender import SenderBase logger = logging.getLogger(__name__) class SenderWebhook(SenderBase): def _send(self, url, alert, data): ...
Fix case where annotations may not exist
Fix case where annotations may not exist
Python
mit
kfdm/promgen,kfdm/promgen,kfdm/promgen,kfdm/promgen
cfc50cb9e70b7a5358b36a54d4b3bc27a2cfb2cb
us_ignite/common/sanitizer.py
us_ignite/common/sanitizer.py
import bleach ALLOWED_TAGS = [ 'a', 'abbr', 'acronym', 'b', 'blockquote', 'code', 'em', 'i', 'li', 'ol', 'strong', 'ul', 'p', 'br', 'h3', 'h4', 'h5', 'h6', ] ALLOWED_ATTRIBUTES = { 'a': ['href', 'title'], 'abbr': ['title'], 'acronym':...
import bleach ALLOWED_TAGS = [ 'a', 'abbr', 'acronym', 'b', 'blockquote', 'code', 'em', 'i', 'li', 'ol', 'strong', 'ul', 'p', 'br', 'h3', 'h4', 'h5', 'h6', 'table', 'tr', 'th', 'td', ] ALLOWED_ATTRIBUTES = { 'a': ['href', 'tit...
Allow ``table`` attributes during HTML sanitation.
Allow ``table`` attributes during HTML sanitation. Tables are part of the content expected to be added in some of the resources in the site.
Python
bsd-3-clause
us-ignite/us_ignite,us-ignite/us_ignite,us-ignite/us_ignite,us-ignite/us_ignite,us-ignite/us_ignite
f7bb5a58774cdb6ecdfae12f7919ae2e3dfd8f8d
upsrv/conary_schema.py
upsrv/conary_schema.py
#!/usr/bin/python # Copyright (c) 2006 rPath, Inc # All rights reserved import sys import os import pwd from conary.server import schema from conary.lib import cfgtypes, tracelog from conary.repository.netrepos.netserver import ServerConfig from conary import dbstore class SimpleFileLog(tracelog.FileLog): def pr...
#!/usr/bin/python # # Copyright (c) SAS Institute Inc. # import sys import os import pwd from conary.server import schema from conary.lib import cfgtypes, tracelog from conary import dbstore from .config import UpsrvConfig class SimpleFileLog(tracelog.FileLog): def printLog(self, level, msg): self.fd.wri...
Update conary migration script to deal with extended config
Update conary migration script to deal with extended config
Python
apache-2.0
sassoftware/rbm,sassoftware/rbm,sassoftware/rbm
130d73d64e6f4abe4946240a8e876891cb02182c
corehq/ex-submodules/pillow_retry/admin.py
corehq/ex-submodules/pillow_retry/admin.py
from django.contrib import admin from pillow_retry.models import PillowError @admin.register(PillowError) class PillowErrorAdmin(admin.ModelAdmin): model = PillowError list_display = [ 'pillow', 'doc_id', 'error_type', 'date_created', 'date_last_attempt', 'dat...
from datetime import datetime from django.contrib import admin from pillow_retry.models import PillowError @admin.register(PillowError) class PillowErrorAdmin(admin.ModelAdmin): model = PillowError list_display = [ 'pillow', 'doc_id', 'error_type', 'date_created', 'da...
Add reset attempts to PillowError actions
Add reset attempts to PillowError actions
Python
bsd-3-clause
dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq
e9e632008db1eb2bbdbd989584b82255a10f8944
CodeFights/arrayReplace.py
CodeFights/arrayReplace.py
#!/usr/local/bin/python # Code Fights Add Border Problem def arrayReplace(inputArray, elemToReplace, substitutionElem): pass def main(): pass if __name__ == '__main__': main()
#!/usr/local/bin/python # Code Fights Add Border Problem def arrayReplace(inputArray, elemToReplace, substitutionElem): return [x if x != elemToReplace else substitutionElem for x in inputArray] def main(): tests = [ [[1, 2, 1], 1, 3, [3, 2, 3]], [[1, 2, 3, 4, 5], 3, 0, [1, 2, 0, 4, 5]], ...
Solve Code Fights array replace problem
Solve Code Fights array replace problem
Python
mit
HKuz/Test_Code
9d93a7a5d474a8725125077ae888f2d586955489
tests/cli/fsm/fsm_test.py
tests/cli/fsm/fsm_test.py
# Copyright 2015 Yelp Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2015 Yelp Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
Remove comments in fsm tests
Remove comments in fsm tests
Python
apache-2.0
Yelp/paasta,gstarnberger/paasta,somic/paasta,somic/paasta,Yelp/paasta,gstarnberger/paasta
016d955319b6971fec42ac6ada1052f88d867cee
freepacktbook/__init__.py
freepacktbook/__init__.py
import os from bs4 import BeautifulSoup import requests class FreePacktBook(object): base_url = 'https://www.packtpub.com' url = base_url + '/packt/offers/free-learning/' def __init__(self, email=None, password=None): self.session = requests.Session() self.email = email self.pas...
import os from bs4 import BeautifulSoup import requests class FreePacktBook(object): base_url = 'https://www.packtpub.com' url = base_url + '/packt/offers/free-learning/' def __init__(self, email=None, password=None): self.session = requests.Session() self.email = email self.pas...
Add ability to get book details
Add ability to get book details
Python
mit
bogdal/freepacktbook
76b39021fb0171da6036ceaf7894e3ff18d259ae
src/syft/grid/client/request_api/worker_api.py
src/syft/grid/client/request_api/worker_api.py
# stdlib from typing import Any from typing import Dict # third party from pandas import DataFrame # syft relative from ...messages.infra_messages import CreateWorkerMessage from ...messages.infra_messages import DeleteWorkerMessage from ...messages.infra_messages import GetWorkerMessage from ...messages.infra_messag...
# stdlib from typing import Callable # syft relative from ...messages.infra_messages import CreateWorkerMessage from ...messages.infra_messages import DeleteWorkerMessage from ...messages.infra_messages import GetWorkerMessage from ...messages.infra_messages import GetWorkersMessage from ...messages.infra_messages imp...
Update Worker API - ADD type hints - Remove unused imports
Update Worker API - ADD type hints - Remove unused imports
Python
apache-2.0
OpenMined/PySyft,OpenMined/PySyft,OpenMined/PySyft,OpenMined/PySyft
6153952ca9794ccb1dd5d76696aa2d4881a665c1
tests/core/migrations/0004_bookwithchapters.py
tests/core/migrations/0004_bookwithchapters.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-06-09 10:26 from __future__ import unicode_literals import django.contrib.postgres.fields from django.db import migrations, models class PostgresOnlyCreateModel(migrations.CreateModel): def database_forwards(self, app_label, schema_editor, from_state, t...
from __future__ import unicode_literals from django import VERSION from django.db import migrations, models if VERSION >= (1, 8): from django.contrib.postgres.fields import ArrayField chapters_field = ArrayField(base_field=models.CharField(max_length=100), default=list, size=None) else: chapters_field = mo...
Add version check for importing django.contrib.postgres.fields.ArrayField
Add version check for importing django.contrib.postgres.fields.ArrayField
Python
bsd-2-clause
daniell/django-import-export,jnns/django-import-export,django-import-export/django-import-export,bmihelac/django-import-export,copperleaftech/django-import-export,brillgen/django-import-export,PetrDlouhy/django-import-export,daniell/django-import-export,daniell/django-import-export,PetrDlouhy/django-import-export,PetrD...
d317b27a5dac13900beb8f2674b0725313970a80
nodeconductor/core/handlers.py
nodeconductor/core/handlers.py
from __future__ import unicode_literals import logging from nodeconductor.core.log import EventLoggerAdapter logger = logging.getLogger(__name__) event_logger = EventLoggerAdapter(logger) def log_ssh_key_save(sender, instance, created=False, **kwargs): if created: event_logger.info( 'SSH k...
from __future__ import unicode_literals import logging from nodeconductor.core.log import EventLoggerAdapter logger = logging.getLogger(__name__) event_logger = EventLoggerAdapter(logger) def log_ssh_key_save(sender, instance, created=False, **kwargs): if created: event_logger.info( 'SSH k...
Rename event types for consistency
Rename event types for consistency - NC-332
Python
mit
opennode/nodeconductor,opennode/nodeconductor,opennode/nodeconductor
fba983fa54691fcde0de93d6519b3906dff3cb32
sara_flexbe_states/src/sara_flexbe_states/get_distance2D.py
sara_flexbe_states/src/sara_flexbe_states/get_distance2D.py
#!/usr/bin/env python from flexbe_core import EventState, Logger import rospy import re import ros import math class getDistance(EventState): """ Calcule la distance entre deux points donnes. ### InputKey ># point1 ># point2 ### OutputKey #> distance <= done """ def __init__...
#!/usr/bin/env python from flexbe_core import EventState, Logger import rospy import re import ros import math class getDistance(EventState): """ Calcule la distance entre deux points donnes. ### InputKey ># point1 ># point2 ### OutputKey #> distance <= done """ def __init__...
Correct call to super constructor
Correct call to super constructor
Python
bsd-3-clause
WalkingMachine/sara_behaviors,WalkingMachine/sara_behaviors
fcdcf2b997c4adebd852ce399492a76868e8b0ad
greenmine/base/monkey.py
greenmine/base/monkey.py
# -*- coding: utf-8 -*- from rest_framework import views from rest_framework import status, exceptions from rest_framework.response import Response def patch_api_view(): from django.views.generic import View if hasattr(views, "_patched"): return views._APIView = views.APIView views._patched ...
# -*- coding: utf-8 -*- from __future__ import print_function import sys from rest_framework import views from rest_framework import status, exceptions from rest_framework.response import Response def patch_api_view(): from django.views.generic import View if hasattr(views, "_patched"): return v...
Send print message to sys.stderr
Smallfix: Send print message to sys.stderr
Python
agpl-3.0
astronaut1712/taiga-back,gauravjns/taiga-back,obimod/taiga-back,gauravjns/taiga-back,Tigerwhit4/taiga-back,EvgeneOskin/taiga-back,rajiteh/taiga-back,CoolCloud/taiga-back,bdang2012/taiga-back-casting,jeffdwyatt/taiga-back,astronaut1712/taiga-back,frt-arch/taiga-back,bdang2012/taiga-back-casting,crr0004/taiga-back,CMLL/t...
06914af3d8df899947a53c2fe3b3ce1de208d04d
robot-framework-needle.py
robot-framework-needle.py
from needle.cases import NeedleTestCase from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec class TestLogo(NeedleTestCase): def test_logo(self): self.driver.get('http://www.bbc.co.uk/news/') ...
from needle.cases import NeedleTestCase from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec class TestLogo(NeedleTestCase): def test_logo(self): self.driver.get('http://www.bbc.co.uk/news/') ...
Fix locators used in needle example on BBC site
Fix locators used in needle example on BBC site
Python
apache-2.0
laurentbristiel/robotframework-needle
061306d137b85ac59e182ffbba29d22bc8c624ba
characters/views.py
characters/views.py
from django.shortcuts import get_object_or_404, redirect, render from django.views import generic from characters.forms import CharacterForm from characters.models import Character, Class, Race class CharacterIndexView(generic.ListView): template_name = 'characters/index.html' context_object_name = 'all_cha...
from django.shortcuts import get_object_or_404, redirect, render from django.views import generic from characters.forms import CharacterForm from characters.models import Character, Class, Race class CharacterIndexView(generic.ListView): template_name = 'characters/index.html' context_object_name = 'all_cha...
Order character listing by name
Order character listing by name
Python
mit
mpirnat/django-tutorial-v2
ede4689ce3f9e03db5f250617e793083333af3a5
notification/backends/email.py
notification/backends/email.py
from django.conf import settings from django.core.urlresolvers import reverse from django.template.loader import render_to_string from django.utils.translation import ugettext from django.contrib.sites.models import Site from notification import backends from notification.message import message_to_text # favour djan...
from django.conf import settings from django.db.models.loading import get_app from django.core.urlresolvers import reverse from django.template.loader import render_to_string from django.utils.translation import ugettext from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigur...
Use get_app over to include django-mailer support over a standard import and ImportError exception handling.
pluggable-backends: Use get_app over to include django-mailer support over a standard import and ImportError exception handling. git-svn-id: 12265af7f62f437cb19748843ef653b20b846039@130 590c3fc9-4838-0410-bb95-17a0c9b37ca9
Python
mit
brosner/django-notification,arctelix/django-notification-automated
24c1309a9f221ec8be6a3b15dc843769f4157cf1
allauth/socialaccount/providers/twitch/views.py
allauth/socialaccount/providers/twitch/views.py
import requests from allauth.socialaccount.providers.oauth2.views import ( OAuth2Adapter, OAuth2CallbackView, OAuth2LoginView, ) from .provider import TwitchProvider class TwitchOAuth2Adapter(OAuth2Adapter): provider_id = TwitchProvider.id access_token_url = 'https://api.twitch.tv/kraken/oauth2/...
import requests from allauth.socialaccount.providers.oauth2.client import OAuth2Error from allauth.socialaccount.providers.oauth2.views import ( OAuth2Adapter, OAuth2CallbackView, OAuth2LoginView, ) from .provider import TwitchProvider class TwitchOAuth2Adapter(OAuth2Adapter): provider_id = TwitchPr...
Add error checking in API response
twitch: Add error checking in API response
Python
mit
rsalmaso/django-allauth,lukeburden/django-allauth,pennersr/django-allauth,AltSchool/django-allauth,pztrick/django-allauth,AltSchool/django-allauth,rsalmaso/django-allauth,bittner/django-allauth,pztrick/django-allauth,pennersr/django-allauth,lukeburden/django-allauth,lukeburden/django-allauth,pztrick/django-allauth,bitt...
8d9bb10d5281fe89f693068143e45ff761200abd
01_Built-in_Types/list.py
01_Built-in_Types/list.py
#!/usr/bin/env python import sys print("argv: %d" % len(sys.argv)) # Object related test print(type(sys.argv)) print(id(sys.argv)) print(type(sys.argv) is list) if len(sys.argv) != 2: print("%s filename" % sys.argv[0]) raise SystemExit(1) file = open(sys.argv[1], "w") line = [] while True: line = sys.s...
#!/usr/bin/env python import sys print("argv: %d" % len(sys.argv)) # Object related test # type and id are unique # ref: https://docs.python.org/2/reference/datamodel.html # mutable object: value can be changed # immutable object: value can NOT be changed after created # This means readonly # ex: ...
Add comment for object types
Add comment for object types
Python
bsd-2-clause
zzz0072/Python_Exercises,zzz0072/Python_Exercises
8386d7372f9ff8bfad651efe43504746aff19b73
app/models/rooms/rooms.py
app/models/rooms/rooms.py
from models.people.people import Staff, Fellow from models.rooms.rooms import Office, LivingSpace import random class Dojo(object): def __init__(self): self.offices = [] self.livingrooms = [] self.staff = [] self.fellows = [] self.all_rooms = [] self.all_people = []...
import os import sys from os import path sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) class Room(object): """Models the kind of rooms available at Andela, It forms the base class Room from which OfficeSpace and LivingRoom inherit""" def __init__(self, room_name, room_type, room_...
Implement the Room base class
Implement the Room base class
Python
mit
Alweezy/alvin-mutisya-dojo-project
df2d24757d8e12035437d152d17dc9016f1cd9df
app/__init__.py
app/__init__.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ File: __init__.py Author: huxuan <i(at)huxuan.org> Description: Initial file for app. """ from flask import Flask app = Flask(__name__) # pylint: disable=invalid-name app.config.from_object('config') # commented as for file structure, should recover later. # from ap...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ File: __init__.py Author: huxuan <i(at)huxuan.org> Description: Initial file for app. """ from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) # pylint: disable=invalid-name app.config.from_object('config') # commented as for fil...
Create model in config file.
Create model in config file.
Python
mit
CAPU-ENG/CAPUHome-API,huxuan/CAPUHome-API
8c2996b94cdc3210b24ebeaeb957c625629f68a5
hunting/level/encoder.py
hunting/level/encoder.py
import json import hunting.sim.entities as entities class GameObjectEncoder(json.JSONEncoder): def default(self, o): d = o.__dict__ d.pop('owner', None) if isinstance(o, entities.GameObject): d.pop('log', None) d.pop('ai', None) return d elif is...
import json import hunting.sim.entities as entities class GameObjectEncoder(json.JSONEncoder): def default(self, o): d = o.__dict__ d.pop('owner', None) if isinstance(o, entities.GameObject): d.pop('log', None) d.pop('ai', None) return d elif is...
Add log to encoding output (still fails due to objects)
Add log to encoding output (still fails due to objects)
Python
mit
MoyTW/RL_Arena_Experiment
28960dc03e5e14db94d18b968947257029f934d8
cw_draw_stairs.py
cw_draw_stairs.py
"""Codewars: Draw stairs 8 kyu URL: https://www.codewars.com/kata/draw-stairs/ Given a number n, draw stairs using the letter "I", n tall and n wide, with the tallest in the top left. For example n = 3 result in "I\n I\n I", or printed: I I I Another example, a 7-step stairs should be drawn like this: I I I ...
"""Codewars: Draw stairs 8 kyu URL: https://www.codewars.com/kata/draw-stairs/ Given a number n, draw stairs using the letter "I", n tall and n wide, with the tallest in the top left. For example n = 3 result in "I\n I\n I", or printed: I I I Another example, a 7-step stairs should be drawn like this: I I I ...
Simplify adding spaces and add time/space complexity
Simplify adding spaces and add time/space complexity
Python
bsd-2-clause
bowen0701/algorithms_data_structures
b723cbceb896f7ca8690eaa13c38ffb20fecd0be
avocado/search_indexes.py
avocado/search_indexes.py
import warnings from haystack import indexes from avocado.conf import settings from avocado.models import DataConcept, DataField # Warn if either of the settings are set to false if not getattr(settings, 'CONCEPT_SEARCH_ENABLED', True) or \ not getattr(settings, 'FIELD_SEARCH_ENABLED', True): warnings.warn...
from haystack import indexes from avocado.models import DataConcept, DataField class DataIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) text_auto = indexes.EdgeNgramField(use_template=True) def index_queryset(self, using=None): return self.get_model().objec...
Change DataIndex to restrict on published and archived flags only
Change DataIndex to restrict on published and archived flags only In addition, the warnings of the deprecated settings have been removed. Fix #290 Signed-off-by: Byron Ruth <e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98@devel.io>
Python
bsd-2-clause
murphyke/avocado,murphyke/avocado,murphyke/avocado,murphyke/avocado
d36a4453eb6b62f8eda4614f276fdf9ba7afb26a
tests/test_main.py
tests/test_main.py
# -*- coding:utf-8 -*- from os.path import curdir, devnull from subprocess import check_call from pytest import fixture, mark, raises from csft import __main__ as main @fixture def null(): with open(devnull, 'w') as fobj: yield fobj def test_call(null): check_call(['python', '-m', 'csft', 'csft']...
# -*- coding:utf-8 -*- from os.path import curdir, devnull from subprocess import check_call from pytest import fixture, mark, raises from csft import __main__ as main @fixture def null(): with open(devnull, 'w') as fobj: yield fobj def test_call(null): check_call(['python', '-m', 'csft', 'csft']...
Fix compatible error about capsys.
Fix compatible error about capsys.
Python
mit
yanqd0/csft
87acf306addc60d7678ff980aef4b87f4225839b
theo_actual_nut.py
theo_actual_nut.py
from itertools import combinations from deuces.deuces import Card, Evaluator, Deck from nuts import nut_hand evaluator = Evaluator() deck = Deck() flop = deck.draw(3) def omaha_eval(hole, board): assert(len(hole)) == 4 ranks = [] for ph in combinations(hole, 2): thisrank = evaluator.evaluate(list(...
from itertools import combinations from deuces.deuces import Card, Evaluator, Deck from nuts import nut_hand evaluator = Evaluator() deck = Deck() flop = deck.draw(3) def omaha_eval(hole, board): assert(len(hole)) == 4 ranks = [] for ph in combinations(hole, 2): thisrank = evaluator.evaluate(list(...
Determine winning hand & compare to nut hand.
Determine winning hand & compare to nut hand.
Python
mit
zimolzak/poker-experiments,zimolzak/poker-experiments,zimolzak/poker-experiments
86a2e55954ff4b8f5e005296e2ae336b6be627a0
py/rackattack/clientfactory.py
py/rackattack/clientfactory.py
import os from rackattack.tcp import client _VAR_NAME = "RACKATTACK_PROVIDER" def factory(): if _VAR_NAME not in os.environ: raise Exception( "The environment variable '%s' must be defined properly" % _VAR_NAME) request, subscribe, http = os.environ[_VAR_NAME].split("@@") return clie...
import os from rackattack.tcp import client _VAR_NAME = "RACKATTACK_PROVIDER" def factory(connectionString=None): if connectionString is None: if _VAR_NAME not in os.environ: raise Exception( "The environment variable '%s' must be defined properly" % _VAR_NAME) connec...
Allow passing the rackattack connection string as an argument to the client factory
Allow passing the rackattack connection string as an argument to the client factory
Python
apache-2.0
eliran-stratoscale/rackattack-api,Stratoscale/rackattack-api
d78fad6937fb20a1ea7374240607b5d6800aa11b
username_to_uuid.py
username_to_uuid.py
""" Username to UUID Converts a Minecraft username to it's UUID equivalent. Parses http://www.lb-stuff.com/Minecraft-Name-History output to retrieve the UUID of an old name that's no longer in use. """ import http.client from bs4 import BeautifulSoup class UsernameToUUID: def __init__(self, username): ...
""" Username to UUID Converts a Minecraft username to it's UUID equivalent. Uses the official Mojang API to fetch player data. """ import http.client import json class UsernameToUUID: def __init__(self, username): self.username = username def get_uuid(self, timestamp=None): """ Ge...
Use the Mojang API directly; reduces overhead.
Use the Mojang API directly; reduces overhead.
Python
mit
mrlolethan/MinecraftUsernameToUUID
43f67067c470386b6b24080642cc845ec1655f58
utils/networking.py
utils/networking.py
import fcntl import socket import struct from contextlib import contextmanager @contextmanager def use_interface(ifname): """ :type ifname: str """ ip = _ip_address_for_interface(ifname.encode('ascii')) original_socket = socket.socket def rebound_socket(*args, **kwargs): sock = origi...
import fcntl import socket import struct from contextlib import contextmanager @contextmanager def use_interface(ifname): """ :type ifname: str """ ip = _ip_address_for_interface(ifname) original_socket = socket.socket def rebound_socket(*args, **kwargs): sock = original_socket(*args...
Make _ip_address_for_interface easier to use
Make _ip_address_for_interface easier to use
Python
apache-2.0
OPWEN/opwen-webapp,ascoderu/opwen-webapp,ascoderu/opwen-webapp,OPWEN/opwen-webapp,OPWEN/opwen-webapp,ascoderu/opwen-cloudserver,ascoderu/opwen-cloudserver,ascoderu/opwen-webapp
c80a68b81e936435434931f0b5bf748bcbea54dc
statistics/webui.py
statistics/webui.py
from flask import render_template, g, redirect, request from db import connect_db, get_all_sum from statistics import app @app.before_request def before_request(): g.db = connect_db() g.fields = ["CPU", "TOTAL", "SQL", "SOLR", "REDIS", "MEMCACHED"] @app.route("/") def main_page(): sort_by = request.args....
from flask import render_template, g, redirect, request from db import connect_db, get_all_sum from statistics import app @app.before_request def before_request(): g.db = connect_db() g.fields = ["CPU", "TOTAL", "SQL", "SOLR", "REDIS", "MEMCACHED"] @app.route("/") def main_page(): sort_by = request.args....
Add proto of average page. Without sorting.
Add proto of average page. Without sorting.
Python
mit
uvNikita/appstats,uvNikita/appstats,uvNikita/appstats
236a3e81164e8f7c37c50eaf59bfadd32e76735a
defines.py
defines.py
INFINITY = 1e+31 DIRECTIONS = ((-1,-1),(-1,0),(-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)) EMPTY = 0 BLACK = 1 WHITE = 2 def opposite_colour(col): if col == BLACK: return WHITE if col == WHITE: return BLACK
INFINITY = 1e+31 DIRECTIONS = ((-1,-1),(-1,0),(-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)) EMPTY = 0 BLACK = 1 WHITE = 2 def opposite_colour(col): if col == BLACK: return WHITE if col == WHITE: return BLACK from pdb import set_trace as st
Make a shortcut for debugging with pdb
Make a shortcut for debugging with pdb
Python
mit
cropleyb/pentai,cropleyb/pentai,cropleyb/pentai
1bd3d7d16da7cc1cf98fa68768910010251f2fea
tests/storage_adapter_tests/test_storage_adapter.py
tests/storage_adapter_tests/test_storage_adapter.py
from unittest import TestCase from chatterbot.storage import StorageAdapter class StorageAdapterTestCase(TestCase): """ This test case is for the StorageAdapter base class. Although this class is not intended for direct use, this test case ensures that exceptions requiring basic functionality are ...
from unittest import TestCase from chatterbot.storage import StorageAdapter class StorageAdapterTestCase(TestCase): """ This test case is for the StorageAdapter base class. Although this class is not intended for direct use, this test case ensures that exceptions requiring basic functionality are ...
Add test for unimplemented get_response_statements function
Add test for unimplemented get_response_statements function
Python
bsd-3-clause
gunthercox/ChatterBot,vkosuri/ChatterBot
67b243915ef95ff1b9337bc67053d18df372e79d
unitypack/enums.py
unitypack/enums.py
from enum import IntEnum class RuntimePlatform(IntEnum): OSXEditor = 0 OSXPlayer = 1 WindowsPlayer = 2 OSXWebPlayer = 3 OSXDashboardPlayer = 4 WindowsWebPlayer = 5 WindowsEditor = 7 IPhonePlayer = 8 PS3 = 9 XBOX360 = 10 Android = 11 NaCl = 12 LinuxPlayer = 13 FlashPlayer = 15 WebGLPlayer = 17 MetroPla...
from enum import IntEnum class RuntimePlatform(IntEnum): OSXEditor = 0 OSXPlayer = 1 WindowsPlayer = 2 OSXWebPlayer = 3 OSXDashboardPlayer = 4 WindowsWebPlayer = 5 WindowsEditor = 7 IPhonePlayer = 8 PS3 = 9 XBOX360 = 10 Android = 11 NaCl = 12 LinuxPlayer = 13 FlashPlayer = 15 WebGLPlayer = 17 MetroPla...
Add PSMPlayer and SamsungTVPlayer platforms
Add PSMPlayer and SamsungTVPlayer platforms
Python
mit
andburn/python-unitypack
c4de9152f34d2831d43dfa3769a7a6452bba5814
blockbuster/bb_security.py
blockbuster/bb_security.py
__author__ = 'matt' from blockbuster import bb_dbconnector_factory def credentials_are_valid(username, password): db = bb_dbconnector_factory.DBConnectorInterfaceFactory().create() print(username) result = db.api_username_exists(username) print (result) return result
__author__ = 'matt' from blockbuster import bb_dbconnector_factory def credentials_are_valid(username, password): db = bb_dbconnector_factory.DBConnectorInterfaceFactory().create() print(username) result = db.api_credentials_are_valid(username, password) print (result) return result
Update method to check both username and password
Update method to check both username and password
Python
mit
mattstibbs/blockbuster-server,mattstibbs/blockbuster-server
b28a40e38f0cbd40e01906063b97731ba6cd3fb6
backend/geonature/core/gn_profiles/models.py
backend/geonature/core/gn_profiles/models.py
from geonature.utils.env import DB from utils_flask_sqla.serializers import serializable @serializable class VmCorTaxonPhenology(DB.Model): __tablename__ = "vm_cor_taxon_phenology" __table_args__ = {"schema": "gn_profiles"} cd_ref = DB.Column(DB.Integer, primary_key=True) period = DB.Column(DB.Integer)...
from flask import current_app from geoalchemy2 import Geometry from utils_flask_sqla.serializers import serializable from utils_flask_sqla_geo.serializers import geoserializable from geonature.utils.env import DB @serializable class VmCorTaxonPhenology(DB.Model): __tablename__ = "vm_cor_taxon_phenology" __ta...
Add VM valid profile model
Add VM valid profile model
Python
bsd-2-clause
PnEcrins/GeoNature,PnEcrins/GeoNature,PnEcrins/GeoNature,PnEcrins/GeoNature
753f5bdc3f023cf31c0f189dd835978aad2b5d49
djs_playground/urls.py
djs_playground/urls.py
from django.conf import settings from django.conf.urls import url, include from django.conf.urls.static import static from django.contrib import admin from djs_playground.views import index urlpatterns = [ url(r'^$', index, name='index'), url(r'^admin/', admin.site.urls), url(r'^summernote/', include('djan...
from django.conf import settings from django.urls import re_path, include from django.conf.urls.static import static from django.contrib import admin from djs_playground.views import index urlpatterns = [ re_path(r'^$', index, name='index'), re_path(r'^admin/', admin.site.urls), re_path(r'^summernote/', in...
Change url in favor of the re_path
Change url in favor of the re_path
Python
mit
summernote/django-summernote,summernote/django-summernote,summernote/django-summernote
5a641736faf6bb3ce335480848464a1f22fab040
fabfile.py
fabfile.py
# -*- coding: utf-8 -*- from contextlib import nested from fabric.api import * def prepare_project(): u""" Enters the directory and sources environment configuration. I know ``nested`` is deprecated, but what a nice shortcut it is here ;) """ return nested( cd(PROJECT_PATH), pre...
# -*- coding: utf-8 -*- from contextlib import nested from fabric.api import * def prepare_project(): u""" Enters the directory and sources environment configuration. I know ``nested`` is deprecated, but what a nice shortcut it is here ;) """ return nested( cd(PROJECT_PATH), pre...
Make Fabric honor .ssh/config settings
Make Fabric honor .ssh/config settings
Python
mit
zsiciarz/variablestars.net,zsiciarz/variablestars.net,zsiciarz/variablestars.net
dc1cf6fabcf871e3661125f7ac5d1cf9567798d6
cms/management/commands/load_dev_fixtures.py
cms/management/commands/load_dev_fixtures.py
import requests from django.core.management import call_command from django.core.management.base import NoArgsCommand from django.conf import settings from django.utils.six.moves import input class Command(NoArgsCommand): """ Download and load dev fixtures from www.python.org """ help = "Download and...
import requests from django.core.management import call_command from django.core.management.base import NoArgsCommand from django.conf import settings from django.utils.six.moves import input class Command(NoArgsCommand): """ Download and load dev fixtures from www.python.org """ help = "Download and...
Use self.stdout.write() instead of print().
Use self.stdout.write() instead of print(). This is the recommended way in the Django documentation: https://docs.djangoproject.com/en/1.7/howto/custom-management-commands/
Python
apache-2.0
manhhomienbienthuy/pythondotorg,python/pythondotorg,SujaySKumar/pythondotorg,lebronhkh/pythondotorg,SujaySKumar/pythondotorg,lepture/pythondotorg,python/pythondotorg,proevo/pythondotorg,Mariatta/pythondotorg,malemburg/pythondotorg,willingc/pythondotorg,fe11x/pythondotorg,berkerpeksag/pythondotorg,demvher/pythondotorg,p...