conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Add django-extensions in the dev settings\n" }, { "from": "human", "value": "from pycon.settings import *\n\nDEFAULT_URL_PREFIX='http://localhost:8000'\nDEBUG=True\n\nPAYPAL_TEST = True\n\nTEMPLATES[0]['OPTIONS']['debug'] = True" }, { "from": "gpt", "val...
python
chosen
[ { "from": "system", "value": "Set the sip QDate API for enaml interop.\n" }, { "from": "human", "value": "#------------------------------------------------------------------------------\n# Copyright (c) 2010, Enthought Inc\n# All rights reserved.\n#\n# This software is provided without warranty ...
python
chosen
[ { "from": "system", "value": "Update solution to handle numbers\n" }, { "from": "human", "value": "from collections import Counter\nimport string\nimport sys\n\n\ndef beautiful_strings(line):\n line = line.rstrip()\n if line:\n beauty = 0\n count = Counter(''.join(letter for ...
python
chosen
[ { "from": "system", "value": "Load model dynamically via envvar 'SIPA_MODEL'\n" }, { "from": "human", "value": "import model.wu.user\nfrom model.wu.user import User\n\n\ndef init_context(app):\n model.wu.user.init_context(app)\n\n# todo evaluate a parameter and decide which package to use (wu...
python
chosen
[ { "from": "system", "value": "Update url username matching to match regex allowed by Django." }, { "from": "human", "value": "from django.conf.urls.defaults import *\n\nurlpatterns = patterns('relationships.views',\n url(r'^$', 'relationship_redirect', name='relationship_list_base'),\n url...
python
chosen
[ { "from": "system", "value": "Add queryset attribute to NestedCommentDetail view\n" }, { "from": "human", "value": "# Django\nfrom django.shortcuts import get_object_or_404\nfrom django.views.generic import *\n\n# Third party apps\nfrom django_filters.rest_framework import DjangoFilterBackend\nf...
python
chosen
[ { "from": "system", "value": "Fix importing InstanceInfoCache during register_all()\n\nRelated to blueprint unified-object-model\n\nChange-Id: Ib5edd0d0af46d9ba9d0fcaa14c9601ad75b8d50d\n" }, { "from": "human", "value": "# Copyright 2013 IBM Corp.\n#\n# Licensed under the Apache License, Ve...
python
chosen
[ { "from": "system", "value": "Fix installation of numarray headers on Windows.\n\ngit-svn-id: 77a43f9646713b91fea7788fad5dfbf67e151ece@7048 94b884b6-d6fd-0310-90d3-974f1d3f35e1\n" }, { "from": "human", "value": "from os.path import join\n\ndef configuration(parent_package='',top_path=None):\n ...
python
chosen
[ { "from": "system", "value": "Add tests for 404 on invalid routes\n" }, { "from": "human", "value": "# coding: utf-8\n\nfrom findaconf import app, db\nfrom unittest import TestCase\nfrom findaconf.tests.config import set_app, unset_app\n\n\nclass TestAutoCompleteRoutes(TestCase):\n\n def setU...
python
chosen
[ { "from": "system", "value": "Remove 1.8 warning about redirect\n" }, { "from": "human", "value": "\"\"\"opencraft URL Configuration\n\"\"\"\nfrom django.conf.urls import include, url\nfrom django.contrib import admin\nfrom django.views.generic.base import RedirectView\n\n\nurlpatterns = [\n ...
python
chosen
[ { "from": "system", "value": "FIX: Remove brain example [skip azp] [skip actions]\n" }, { "from": "human", "value": "\"\"\"\n.. _ex-eeg-on-scalp:\n\n=================================\nPlotting EEG sensors on the scalp\n=================================\n\nIn this example, digitized EEG sensor lo...
python
chosen
[ { "from": "system", "value": "Add some docs to PMT time slewing\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n\n==================\nPMT Time Slewing\n==================\n\nShow different variants of PMT time slewing calculations.\n\nVariant 3 is currently (as of 2020-10-16)...
python
chosen
[ { "from": "system", "value": "Check for valid currencies in a file\n" }, { "from": "human", "value": "import urllib.parse\nfrom bs4 import BeautifulSoup\nimport re\nimport syscmd\n\ndef currency( self ):\n\t\n\tamount = 1\n\tfrm = \"eur\"\n\tto = \"usd\"\n\t\n\tif len(self.msg) < 7:\n\t\tself.se...
python
chosen
[ { "from": "system", "value": "Update to the new API and small cosmetic changes." }, { "from": "human", "value": "\"\"\"Tests for the hdc1008 module\"\"\"\n\nimport pyb\nfrom hdc1008 import HDC1008\n\ni2c = pyb.I2C(2)\ni2c.init(pyb.I2C.MASTER, baudrate=400000)\n\nhdc = HDC1008(i2c)\nhdc.reset()\n...
python
chosen
[ { "from": "system", "value": "Use ParticleData class in file reader\n\nFile reader now creates lists of ParticleData objects.\n\nSigned-off-by: Jussi Auvinen <16b8c81f9479dec4f5eedf7ae5a2413c6a10bc13@phy.duke.edu>\n" }, { "from": "human", "value": "#!/usr/bin/python\n\n# Functions for reading hy...
python
chosen
[ { "from": "system", "value": "Remove unnecessary check, used to re functions returning different types\n" }, { "from": "human", "value": "import json\nimport os\nimport re\n\nIP_REGEX = re.compile(r'(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})')\n\n\ndef find_ips(filename):\...
python
chosen
[ { "from": "system", "value": "Rename references to \"testsite\" to \"testapp\".\n" }, { "from": "human", "value": "\"\"\"\nWSGI config for testsite project.\n\nIt exposes the WSGI callable as a module-level variable named ``application``.\n\nFor more information on this file, see\nhttps://docs.d...
python
chosen
[ { "from": "system", "value": "Make 'from pokr.models import ~' possible\n" }, { "from": "human", "value": "import assembly\nimport bill\nimport bill_feed\nimport bill_keyword\nimport bill_review\nimport bill_status\nimport bill_withdrawal\nimport candidacy\nimport cosponsorship\nimport election\...
python
chosen
[ { "from": "system", "value": "Correct coding error - need to return coding from property function or it'll cache None.\n" }, { "from": "human", "value": "from .coding import Coding\nfrom .lazy import lazyprop\nfrom ..system_uri import IETF_LANGUAGE_TAG\n\n\nclass LocaleConstants(object):\n \"...
python
chosen
[ { "from": "system", "value": "Support finding licenses with pip>=19.3\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport json\nimport sys\n\ntry:\n from pip._internal.req import parse_requirements\nexcept ImportError:\n from pip.req import parse_requirements\ntry:\n...
python
chosen
[ { "from": "system", "value": "Switch to more optimal non-generator solution\n" }, { "from": "human", "value": "def sieve(n):\n return list(primes(n))\n\n\ndef primes(n):\n if n < 2:\n raise StopIteration\n yield 2\n not_prime = set()\n for i in range(3, n+1, 2):\n if...
python
chosen
[ { "from": "system", "value": "Increase version number due to usable Ipv4 class\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom ip import Ip\nfrom ipv4 import Ipv4\nfrom ipv6 import Ipv6\n\n__name__ = 'ip'\n__version__ = '0.1'\n__description__ = \"Foxfluff's IPv4 and IPv6 datat...
python
chosen
[ { "from": "system", "value": "Add additional parameters into CotextFree.is_grammar_generating method\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 23.06.2017 16:39\n:Licence GNUv3\nPart of grammpy-transforms\n\n\"\"\"\n\nfrom grammpy import G...
python
chosen
[ { "from": "system", "value": "Make sure we have a recipient before sending notification" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.contrib.contenttypes import generic\nfrom django.db.models.signals import...
python
chosen
[ { "from": "system", "value": "Add static URL to development settings\n" }, { "from": "human", "value": "\n#for a development machine\nDEBUG = True\n\nTEMPLATE_DEBUG = DEBUG\n\n#this is nice for development\nDATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.sqlite3',\n ...
python
chosen
[ { "from": "system", "value": "Tweak thumbnail processor a little\n" }, { "from": "human", "value": "import logging\n\n\nlogger = logging.getLogger(__name__)\n\ndef crop_corners(image, box=None, **kwargs):\n \"\"\"\n Crop corners to the selection defined by image_cropping\n\n `box` is a ...
python
chosen
[ { "from": "system", "value": "Replace console output for raw txt\n" }, { "from": "human", "value": "import requests\nimport os\n\nfrom pprint import pprint\nfrom tabulate import tabulate\n\nOMDB_URL = 'http://www.omdbapi.com/?type=movie&plot=short&tomatoes=true&t={}&y={}'\n\n\ndef request_data(t...
python
chosen
[ { "from": "system", "value": "Use more succinct syntax to filter in database query.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\nbyceps.blueprints.ticket.service\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Copyright: 2006-2016 Jochen Kupperschmidt\n:License: Modified BSD, see ...
python
chosen
[ { "from": "system", "value": "Update dsub version to 0.4.3.dev0\n\nPiperOrigin-RevId: 337359189\n" }, { "from": "human", "value": "# Copyright 2017 Google Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in comp...
python
chosen
[ { "from": "system", "value": "Use newer package import syntax for Flask\n" }, { "from": "human", "value": "# Application models\n#\n# Copyright (c) 2016, Alexandre Hamelin <alexandre.hamelin gmail.com>\n\n\nimport os, os.path\nfrom datetime import datetime\nfrom flask.ext.sqlalchemy import SQLAl...
python
chosen
[ { "from": "system", "value": "Remove session info and driver info of webdriverexception.\n" }, { "from": "human", "value": "__author__ = 'karl.gong'\n\n\nclass EasyiumException(Exception):\n def __init__(self, msg=None, context=None):\n self.msg = msg\n self.message = self.msg\n...
python
chosen
[ { "from": "system", "value": "Adjust log prefix in tests for Python 2.4" }, { "from": "human", "value": "import unittest\nimport logging\nfrom yaml_server.YamlReader import YamlReader\nfrom yaml_server.YamlServerException import YamlServerException\n\n\nclass Test(unittest.TestCase):\n \n ...
python
chosen
[ { "from": "system", "value": "Fix migration 211 to handle lack of data.\n" }, { "from": "human", "value": "\"\"\"\nAll the forum canned responses are stored in KB articles. There is a\ncategory for them now. Luckily they follow a simple pattern of slugs, so\nthey are easy to find.\n\nThis could ...
python
chosen
[ { "from": "system", "value": "Raise throttle limit for anon users\n" }, { "from": "human", "value": "REST_FRAMEWORK = {\n 'DEFAULT_THROTTLE_CLASSES': (\n 'rest_framework.throttling.AnonRateThrottle',\n ),\n 'DEFAULT_THROTTLE_RATES': {\n 'anon': '50/day',\n }\n}\n" }, ...
python
chosen
[ { "from": "system", "value": "Add logging helper. (exception, error, warning, info, debug)\n" }, { "from": "human", "value": "#\n#\tdp for Tornado\n#\t\tYoungYong Park (youngyongpark@gmail.com)\n#\t\t2014.10.23\n#\t\t\n\nfrom .singleton import Singleton\n\n\nclass Logger(object, metaclass=Single...
python
chosen
[ { "from": "system", "value": "Add Selenium test for basic logic.\n" }, { "from": "human", "value": "import os\n\nimport testinfra.utils.ansible_runner\n\ntestinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')\n\ndef test_service_ela...
python
chosen
[ { "from": "system", "value": "Fix reading in for layer_colors.\n" }, { "from": "human", "value": "def read(filename):\n \"\"\"\n Reads in a corestick file and returns a dictionary keyed by core_id.\n Layer interface depths are positive and are relative to the lake bottom.\n depths ar...
python
chosen
[ { "from": "system", "value": "Add safety check for non-existent style.\n" }, { "from": "human", "value": "from pygments.token import Token\nfrom pygments.style import Style\nimport pygments.styles\n\n\ndef style_factory(name):\n class PGStyle(Style):\n styles = {\n Token...
python
chosen
[ { "from": "system", "value": "Exclude Enhance-o Mechano from its own buff targets\n" }, { "from": "human", "value": "from ..utils import *\n\n\n##\n# Minions\n\n# Hobgoblin\nclass GVG_104:\n\tevents = [\n\t\tOWN_MINION_PLAY.on(\n\t\t\tlambda self, player, card, *args: card.atk == 1 and [Buff(car...
python
chosen
[ { "from": "system", "value": "Make short unit extraction script idempotent\n" }, { "from": "human", "value": "import os\nimport sys\nsys.path.insert(1, os.path.join(sys.path[0], '../..'))\nimport owid_grapher.wsgi\nfrom grapher_admin.models import Variable\n\n# use this script to extract and wri...
python
chosen
[ { "from": "system", "value": "Allow \".\" in project names.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django.conf.urls.defaults import patterns, url, include\n\nurlpatterns = patterns(\"\",\n # Simple PyPI\n url(r'^/?$', \"djangopypi.views.simple\",\n name=\"d...
python
chosen
[ { "from": "system", "value": "Set prod server as config default.\n" }, { "from": "human", "value": "CURATORS = \"https://auth.globus.org/6265343a-52e3-11e7-acd7-22000b100078\"\n\nDEFAULT_CONFIG = {\n \"server\": {\n \"protocol\": \"https\",\n \"host\": \"\",\n \"catalog_id\": 1\n },\n...
python
chosen
[ { "from": "system", "value": "Set password in user ini\n" }, { "from": "human", "value": "from google.appengine.ext import db\n\nimport bcrypt\n\nclass User(db.Model):\n email = db.EmailProperty()\n first_name = db.StringProperty()\n last_name = db.StringProperty()\n password_hash = db.Strin...
python
chosen
[ { "from": "system", "value": "Fix tests for nbgrader extensions\n" }, { "from": "human", "value": "import os\n\nimport nbgrader\n\n\ndef test_nbextension():\n from nbgrader import _jupyter_nbextension_paths\n nbexts = _jupyter_nbextension_paths()\n assert len(nbexts) == 3\n assert nb...
python
chosen
[ { "from": "system", "value": "Tweak for better backward compatibility w/ master repository.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"\nConvenience module to use:\n\n python -m behave args...\n\n\"\"\"\n\nfrom __future__ import absolute_import\nimport sys\n\nif __name__ ...
python
chosen
[ { "from": "system", "value": "Bring some test which need to be finished\n" }, { "from": "human", "value": "import numpy as np\n\nfrom numpy.testing import assert_almost_equal\nfrom numpy.testing import assert_array_equal\nfrom numpy.testing import assert_array_almost_equal\nfrom numpy.testing im...
python
chosen
[ { "from": "system", "value": "Return Vector is in decreasing order of origal length.\n" }, { "from": "human", "value": "import torch\n\n'''Utility for Padding Sequences to feed to RNN/LSTM.'''\n\n\ndef pad_single_sequence(single_tensor, length):\n padding_vec_dim = (length - single_tensor.siz...
python
chosen
[ { "from": "system", "value": "Use tuples of attnames instead of lists\n" }, { "from": "human", "value": "VERSION = (0, 2)\n__version__ = '.'.join(map(str, VERSION))\n\n\nfrom django.db.models import Model\nfrom django.db.models.base import ModelState\ntry:\n from itertools import izip\nexcept...
python
chosen
[ { "from": "system", "value": "Fix the rootfactory for no matchdict so we can get a 404 back out\n" }, { "from": "human", "value": "from pyramid.authentication import AuthTktAuthenticationPolicy\nfrom pyramid.authorization import ACLAuthorizationPolicy\nfrom pyramid.config import Configurator\nfr...
python
chosen
[ { "from": "system", "value": "Add __str__/__bytes__ Python 2.7 compatibility\n" }, { "from": "human", "value": "try:\n from urllib.parse import urlencode\nexcept ImportError:\n from urllib import urlencode\n\n\nclass Request:\n def __init__(self, config, **kwargs):\n self.config ...
python
chosen
[ { "from": "system", "value": "Use sure in violations bases tests\n" }, { "from": "human", "value": "from django.test import TestCase\nfrom ..base import ViolationsLibrary\nfrom ..exceptions import ViolationDoesNotExists\n\n\nclass ViolationsLibraryCase(TestCase):\n \"\"\"Violations library ca...
python
chosen
[ { "from": "system", "value": "Enforce ordering on cluster nodes endpoint\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom datetime import datetime, timedelta\nfrom flask.ext.restful import reqparse\n\nfrom changes.api.base import APIView\nfrom changes.models impo...
python
chosen
[ { "from": "system", "value": "Fix contact form recipient email address\n\nSince Celery is configured differently now we can't reach in and\ngrab config values outside of Celery.\n" }, { "from": "human", "value": "from lib.flask_mailplus import send_template_message\nfrom snakeeyes.app import cre...
python
chosen
[ { "from": "system", "value": "Correct imports for new directory structure\n" }, { "from": "human", "value": "\"\"\"An Edition reflects a base install, the default being BioLinux.\n\nEditions are shared between multiple projects. To specialize an edition, create\na Flavor instead.\n\nOther editio...
python
chosen
[ { "from": "system", "value": "Fix exception string for missing project\n" }, { "from": "human", "value": "import sys\nimport pytoml as toml\n\nfrom proppy.exceptions import InvalidCommand, InvalidConfiguration\nfrom proppy.proposal import Proposal\nfrom proppy.render import to_pdf\n\n\ndef main(...
python
chosen
[ { "from": "system", "value": "test: Set the locale to en_US.UTF-8\n" }, { "from": "human", "value": "import locale\n\n# The test fixtures can break if the locale is non-US.\nlocale.setlocale(locale.LC_ALL, 'en_US')\n" }, { "from": "gpt", "value": "import locale\n\n# The test fixtures...
python
chosen
[ { "from": "system", "value": "Create credentials fixture for inactive project\n" }, { "from": "human", "value": "\"\"\"\nConfiguration, plugins and fixtures for `pytest`.\n\"\"\"\n\nimport os\n\nimport pytest\n\nfrom tests.utils import VuforiaServerCredentials\n\n\n@pytest.fixture()\ndef vuforia...
python
chosen
[ { "from": "system", "value": "Add the action required to fix the issue to the warning\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport os\nimport warnings\n\nimport pytest\n\npytest_plugins = 'pytester'\n\n\n@pytest.fixture(scope='session', autouse=True)\ndef verify_target_path...
python
chosen
[ { "from": "system", "value": "Reset file to pass style checks\n" }, { "from": "human", "value": "\"\"\"Views for the general application.\"\"\"\n\nfrom django.views.generic import TemplateView\nfrom django.http import HttpResponse\n\n\nclass GeneralIndexView(TemplateView):\n \"\"\"View for th...
python
chosen
[ { "from": "system", "value": "Add deleter to Conversation properties\n" }, { "from": "human", "value": "def error_on_kwarg(func, kwargs):\n if kwargs:\n message = \"{0}() got an unexpected keyword argument {1!r}\"\n raise TypeError(message.format(func.__name__, next(iter(kwargs)...
python
chosen
[ { "from": "system", "value": "Add test for imperfect imports as well\n" }, { "from": "human", "value": "\"\"\"Tests the isort API module\"\"\"\nimport pytest\n\nfrom isort import api, exceptions\n\n\ndef test_sort_file_invalid_syntax(tmpdir) -> None:\n \"\"\"Test to ensure file encoding is re...
python
chosen
[ { "from": "system", "value": "Store output instead of calculating it each time\n" }, { "from": "human", "value": "from random import random\n\n\nclass Neuron:\n def __init__(self, parents=[]):\n self.parents = parents\n self.weights = [random() for parent in parents]\n\n def ...
python
chosen
[ { "from": "system", "value": "Use BigAutoField as the default ID" }, { "from": "human", "value": "from django.apps import AppConfig\n\nfrom fcm_django.settings import FCM_DJANGO_SETTINGS as SETTINGS\n\n\nclass FcmDjangoConfig(AppConfig):\n name = \"fcm_django\"\n verbose_name = SETTINGS[\"...
python
chosen
[ { "from": "system", "value": "Use Pyaudio when available, ffplay as fallback\n" }, { "from": "human", "value": "import subprocess\nfrom tempfile import NamedTemporaryFile\nfrom .utils import get_player_name\n\nPLAYER = get_player_name()\n\ndef play(audio_segment):\n with NamedTemporaryFile(\"...
python
chosen
[ { "from": "system", "value": "Exclude missing ephem from coverage\n" }, { "from": "human", "value": "from .parser import GcvsParser\n\ntry:\n import ephem\nexcept ImportError:\n ephem = None\n\n\ndef read_gcvs(filename):\n \"\"\"\n Reads variable star data in `GCVS format`_.\n\n :...
python
chosen
[ { "from": "human", "value": "Add friendly error message targeted at South users\n" }, { "from": "gpt", "value": "\"\"\"\nDjango migrations for email_log app\n\nThis package does not contain South migrations. South migrations can be found\nin the ``south_migrations`` package.\n\"\"\"\n\nSOUTH_ER...
python
chosen
[ { "from": "system", "value": "Change parameters of tests to remove big output\n" }, { "from": "human", "value": "from settings import * # noqa\n\n# Comment this line for turn on debug on tests\nLOGGING = {}\nDEBUG = 0\nTEST_RUNNER = 'django_nose.NoseTestSuiteRunner'\nNOSE_ARGS = [\n '--verbo...
python
chosen
[ { "from": "system", "value": "Use env variable for settings.py\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nimport sys\n\nsys.path.insert(0, os.path.abspath(os.path.pardir))\n\nif __name__ == \"__main__\":\n from django.core.management import execute_from_command_line\...
python
chosen
[ { "from": "system", "value": "Comment out database connection until database is set up\n" }, { "from": "human", "value": "import os\nfrom flask import Flask, render_template\nfrom pymongo import MongoClient\n\ntmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')\napp ...
python
chosen
[ { "from": "system", "value": "Add npm install to the fabric script\n" }, { "from": "human", "value": "from __future__ import with_statement\nfrom fabric.api import run, cd\nfrom fabric.context_managers import prefix\n\nBASE_DIR = \"/srv/dochub/source\"\nACTIVATE = 'source ../ve/bin/activate'\n\n...
python
chosen
[ { "from": "system", "value": "Add test to check Solutions sub-tags names\n" }, { "from": "human", "value": "from __future__ import absolute_import, unicode_literals\n\nfrom corehq import toggles\nfrom corehq.toggles import ALL_TAGS\n\n\ndef test_toggle_properties():\n \"\"\"\n Check toggle...
python
chosen
[ { "from": "system", "value": "Add a pragma and in the future we need to fix the function, because it's a duplicata\n" }, { "from": "human", "value": "# -*- coding: UTF-8 -*-\nimport urllib\nimport httplib\nimport simplejson\n\nG = 'maps.google.com'\n\ndef geocode(address, key, country):\n \"\...
python
chosen
[ { "from": "system", "value": "Remove unnecessary heading from docstring\n" }, { "from": "human", "value": "import re\nfrom .utils import validator\n\n\nregex = (\n r'^[a-z]+://([^/:]+{tld}|([0-9]{{1,3}}\\.)'\n r'{{3}}[0-9]{{1,3}})(:[0-9]+)?(\\/.*)?$'\n)\n\npattern_with_tld = re.compile(reg...
python
chosen
[ { "from": "system", "value": "Change search and list fields\n" }, { "from": "human", "value": "# coding: utf-8\nfrom django.contrib import admin\nfrom .models import Report\n\nclass ReportAdmin(admin.ModelAdmin):\n list_display = ('addressed_to', 'reported_from', 'content', 'signed_from', 'ge...
python
chosen
[ { "from": "system", "value": "Make get_readable_list process tuples, too\n" }, { "from": "human", "value": "def get_readable_list(passed_list, sep=', ', end=''):\n\toutput = \"\"\n\tif isinstance(passed_list, list):\n\t\tfor i, item in enumerate(passed_list):\n\t\t\tif len(passed_list) is 1:\n\t...
python
chosen
[ { "from": "system", "value": "Add command to update dependencies.\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nimport argparse\n\ndef run():\n \"\"\" Reuse the Procfile to start the dev server \"\"\"\n with open(\"Procfile\", \"r\") as f:\n command = f.read()...
python
chosen
[ { "from": "system", "value": "Add explicit method signature to custom filters\n\nThis changeset adds an explicit method signature to the Ansible custom filters.\n" }, { "from": "human", "value": "class FilterModule(object):\n ''' Additional filters for use within Ansible. '''\n\n def filte...
python
chosen
[ { "from": "system", "value": "Use Django simple_tag instead of classytags because there were no context in template rendering." }, { "from": "human", "value": "from classytags.helpers import InclusionTag\nfrom django import template\nfrom django.template.loader import render_to_string\n\n\nregis...
python
chosen
[ { "from": "system", "value": "[nixio] Change filename for NIXRawIO tests\n" }, { "from": "human", "value": "import unittest\nfrom neo.rawio.nixrawio import NIXRawIO\nfrom neo.rawio.tests.common_rawio_test import BaseTestRawIO\n\n\ntestfname = \"neoraw.nix\"\n\nclass TestNixRawIO(BaseTestRawIO, u...
python
chosen
[ { "from": "system", "value": "Remove pooling suggestion from Heroku doco\n" }, { "from": "human", "value": "from .settings import *\n\nimport dj_database_url\nDATABASES['default'] = dj_database_url.config()\n\n# Enable Connection Pooling\nDATABASES['default']['ENGINE'] = 'django_postgrespool'\n...
python
chosen
[ { "from": "system", "value": "Fix broken tests in django master\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nimport contextlib\n\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestCase\nfrom rest_framework.test import APIClient\nfrom rest_...
python
chosen
[ { "from": "system", "value": "Address issue where process might not fully start\n\nI've tried less than 0.1 seconds and it doesn't routinely pass. This\nappears to pass all the time.\n" }, { "from": "human", "value": "from contextlib import contextmanager\nfrom multiprocessing import Process\n\...
python
chosen
[ { "from": "system", "value": "Fix name and description of ARTS tests." }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"Testing the functions in typhon.arts.\n\"\"\"\nimport shutil\n\nimport pytest\n\nfrom typhon import arts\n\n\nclass TestPlots:\n \"\"\"Testing the plot functio...
python
chosen
[ { "from": "system", "value": "Remove horrible debug wrapper, oops.\n\nSigned-off-by: Chris Lamb <711c73f64afdce07b7e38039a96d2224209e9a6c@playfire.com>\n" }, { "from": "human", "value": "from django.http import HttpResponseRedirect\nfrom django.conf import settings\nfrom django.contrib import au...
python
chosen
[ { "from": "system", "value": "Change openerp --> odoo in hook.py\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# © 2017 Ecosoft (ecosoft.co.th).\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\nimport ast\nfrom openerp import api, SUPERUSER_ID\n\n\ndef post_in...
python
chosen
[ { "from": "system", "value": "Update common auth user registration form to show all potential Groups\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom django import forms\nfrom django.db.models import Q\nfrom django.contrib.auth.models import Group\n\nfrom admin.c...
python
chosen
[ { "from": "system", "value": "Update in outputs and fix spaces and names.\n\nSigned-off-by: messiasthi <8562fc1efba9a3c99753c749fdfb1b6932b70fbf@gmail.com>\n" }, { "from": "human", "value": "# The client of DDuplicated tool.\nfrom os import path as opath, getcwd\nfrom sys import argv\n\nfrom ddu...
python
chosen
[ { "from": "system", "value": "Implement One-eyed Cheat, Iron Sensei and Trade Prince Gallywix\n" }, { "from": "human", "value": "from ..utils import *\n\n\n##\n# Minions\n\n# Goblin Auto-Barber\nclass GVG_023:\n\taction = buffWeapon(\"GVG_023a\")\n\n\n##\n# Spells\n\n# Tinker's Sharpsword Oil\nc...
python
chosen
[ { "from": "system", "value": "Fix bug: file encoding is GBK on windows system.\n" }, { "from": "human", "value": "from flask_script import Manager\nimport mockserver\nfrom mockserver.database import database\nimport json\nimport codecs\nimport os\n\n\nmanager = Manager(mockserver.get_app())\n\n\...
python
chosen
[ { "from": "human", "value": "Add connect_to_region/region functions for beanstalk\n" }, { "from": "gpt", "value": "# Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software ...
python
chosen
[ { "from": "system", "value": "Add possibility to return the event object as well\n" }, { "from": "human", "value": "import logging\n\nfrom hestia.tz_utils import now\n\nfrom kubernetes import watch\n\nfrom ocular.processor import get_pod_state\n\nlogger = logging.getLogger('ocular')\n\n\ndef mon...
python
chosen
[ { "from": "system", "value": "Change path of sysctl to /sbin for ubuntu on azure\n" }, { "from": "human", "value": "import subprocess\nimport uuid\n\n\ndef test_if_default_systctls_are_set(dcos_api_session):\n \"\"\"This test verifies that default sysctls are set for tasks.\n\n We use a `m...
python
chosen
[ { "from": "system", "value": "Switch back to a single proxy for ProxyFix\n" }, { "from": "human", "value": "from flask import Flask\nfrom werkzeug.middleware.proxy_fix import ProxyFix\n\nfrom .webauth import apply_webauth_blueprint\nfrom .webhooks import apply_webhooks_blueprint\nfrom .webapi im...
python
chosen
[ { "from": "system", "value": "Use insert_text instead of changed\n\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport gtk\n\nfrom kiwi.controllers import BaseController\nfrom kiwi.ui.views import BaseView\nfrom kiwi.ui.gadgets import quit_if_last\n\nclass FarenControl(BaseControlle...
python
chosen
[ { "from": "system", "value": "Add main block to handle CodeEval inputs\n" }, { "from": "human", "value": "\nclass Node(object):\n def __init__(self, value=None, next_node=None):\n self.value = value\n self.next_node = next_node\n\n\nclass Stack(object):\n def __init__(self, h...
python
chosen
[ { "from": "system", "value": "Add a stop thread - may be needed for loss of heartbeat case\n" }, { "from": "human", "value": "import logsupport\nfrom logsupport import ConsoleWarning\n\nHelperThreads = {}\n\nclass ThreadItem(object):\n\tdef __init__(self, name, start, restart):\n\t\tself.name = ...
python
chosen
[ { "from": "system", "value": "Remove loading config from \".passpie/.config\" if db set\n" }, { "from": "human", "value": "import click\n\nfrom .history import clone\nfrom . import config\n\n\ndef validate_remote(ctx, param, value):\n if value:\n try:\n remote, branch = valu...
python
chosen
[ { "from": "system", "value": "Determine GPU presence on workers based on instance metadata\n" }, { "from": "human", "value": "\"\"\"\nGrab worker configuration from GCloud instance attributes.\n\"\"\"\nimport json\nimport requests\n\n\nMANAGER_URL_METADATA_URL = \"http://metadata.google.internal...
python
chosen
[ { "from": "system", "value": "Convert every datetime field into float.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport time\n\nfrom copy import copy\nfrom datetime import datetime\nfrom eve.utils import config\nfrom py2neo import Node\n\n\ndef node_to_dict(node):\n node = d...
python
chosen
[ { "from": "system", "value": "Remove sqlalchemy test db setup\n" }, { "from": "human", "value": "import pytest\n\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.orm import sessionmaker\n\nfrom scrapi.linter.document import NormalizedDocument, RawDocument\n\nfrom scrapi.processing.postgres...
python
chosen