conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Use `reducer` to replace `prepare`\n" }, { "from": "human", "value": "__all__ = []\n\nfrom lib.exp.featx.base import Feats\nfrom lib.exp.tools.slider import Slider\nfrom lib.exp.tools.video import Video\nfrom lib.exp.prepare import Prepare\n\n\nclass Featx(Feats):\n...
python
chosen
[ { "from": "system", "value": "Update current parse, add alt parse frame\n" }, { "from": "human", "value": "#!/bin/env python3\n\nfrom sys import argv\n\ndef main():\n parseArgs()\n print(\"Nope.\")\n print(argv)\n\ndef parseArgs():\n if len(argv) > 1:\n time = argv[1].split('h...
python
chosen
[ { "from": "system", "value": "Implement part 2 of day 3 Python solution.\n" }, { "from": "human", "value": "import sys\n\n\ndef read_sides(line):\n return map(int, line.split())\n\n\ndef valid_triangle((a, b, c)):\n return a + b > c and b + c > a and a + c > b\n\n\nif __name__ == '__main__...
python
chosen
[ { "from": "system", "value": "Check whether Montage commands are available\n" }, { "from": "human", "value": "from commands import *\nfrom wrappers import *\n\n__version__ = '0.9.1'\n" }, { "from": "gpt", "value": "from commands import *\nfrom wrappers import *\n\n__version__ = '0.9....
python
chosen
[ { "from": "system", "value": "Add intermediary variables in cache blacklist\n" }, { "from": "human", "value": "# When using openfisca for a large population, having too many variables in cache make openfisca performances drop.\n# The following variables are intermadiate results and do not need t...
python
chosen
[ { "from": "system", "value": "Bump version number on dev to 0.7\n" }, { "from": "human", "value": "__version_info__ = (0, 6, 0, None)\n\n# Dot-connect all but the last. Last is dash-connected if not None.\n__version__ = '.'.join([str(i) for i in __version_info__[:-1]])\nif __version_info__[-1] i...
python
chosen
[ { "from": "system", "value": "Allow for a wildcard address\n" }, { "from": "human", "value": "import sys\nprint(sys.version_info)\nimport random\nimport time\n\nimport networkzero as nw0\n\nquotes = [\n \"Humpty Dumpty sat on a wall\",\n \"Hickory Dickory Dock\",\n \"Baa Baa Black Sheep...
python
chosen
[ { "from": "system", "value": "Use setup_logger properly in tests.\n" }, { "from": "human", "value": "# Copyright 2011-2016 Josh Kearney\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may o...
python
chosen
[ { "from": "system", "value": "[FIX] Define UTC as tz in get_working_days_of_date method\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# See README.rst file on addon root folder for license details\n\nfrom openerp import models, api\nfrom datetime import datetime, timedelta\n\n\ncla...
python
chosen
[ { "from": "system", "value": "Check if there are associated acts before querying for them" }, { "from": "human", "value": "from artgraph.node import NodeTypes\nfrom artgraph.plugins import Plugin\n\nclass InfoboxPlugin(Plugin):\n def __init__(self, node):\n self._node = node\n \n ...
python
chosen
[ { "from": "system", "value": "Allow auto-commit option for Mysql Operator\n" }, { "from": "human", "value": "import logging\n\nfrom airflow.hooks import MySqlHook\nfrom airflow.models import BaseOperator\nfrom airflow.utils import apply_defaults\n\n\nclass MySqlOperator(BaseOperator):\n \"\"\...
python
chosen
[ { "from": "system", "value": "Fix unit test failing on case sensitivity\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\nimport types\nfrom os.path import abspath, dirname, join\nfrom epubcheck import utils, samples\n\n\nTEST_DIR = abspath(dirn...
python
chosen
[ { "from": "system", "value": "Return LTA files to use as argument in main thread code\n" }, { "from": "human", "value": "def lta_to_uvfits():\n\tlta_files = glob.glob('*.lta*')\n\t#flag_files = glob.glob('*.FLAGS*')\n\tfor i in range(len(lta_files)):\n\t\tlta_file_name = lta_files[i]\n\t\tuvfits...
python
chosen
[ { "from": "system", "value": "Allow PEM format keys through validation\n" }, { "from": "human", "value": "from django.conf import settings\nfrom django.db import models\nfrom django.contrib.auth.models import User\nfrom django.core.exceptions import ValidationError\nfrom cryptography.hazmat.prim...
python
chosen
[ { "from": "system", "value": "Update server url with https\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\ncomo.settings - some global variables\n\"\"\"\n\nimport os\n\nfrom paxo.util import DEBUG_MODE\n\nLOCATION_CODES = [\n '1C', '2Z', '4H', '5K', '8H', '5D', '7J', 'CK',...
python
chosen
[ { "from": "system", "value": "Use HyperlinkedIdentityField for entries in ProjectDetailSerializer\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n#\n# (c) 2014 Bjoern Ricks <bjoern.ricks@gmail.com>\n#\n# See LICENSE comming with the source of 'trex' for details.\n#\n\nfrom rest_frame...
python
chosen
[ { "from": "system", "value": "Use smart_str and include artist in results\n" }, { "from": "human", "value": "from gdata.youtube.service import YouTubeService, YouTubeVideoQuery\n\nclass YoutubeMusic:\n def __init__(self):\n self.service = YouTubeService()\n\n def search(self, artist...
python
chosen
[ { "from": "system", "value": "Move SpanishDefaults out of Language class, for pickle\n" }, { "from": "human", "value": "# coding: utf8\nfrom __future__ import unicode_literals\n\nfrom .tokenizer_exceptions import TOKENIZER_EXCEPTIONS\nfrom .tag_map import TAG_MAP\nfrom .stop_words import STOP_WO...
python
chosen
[ { "from": "system", "value": "Improve unicode for motivational texts\n" }, { "from": "human", "value": "from django.db import models\nfrom patient.models import Patient\nfrom django.utils.encoding import smart_unicode\n\n\nclass MotivationText(models.Model):\n patient = models.ForeignKey(Pati...
python
chosen
[ { "from": "system", "value": "Add a neattime custom filter to give me pretty times." }, { "from": "human", "value": "import json\n\ndef strslice(s, length):\n if not isinstance(s, basestring):\n s = str(s)\n return s[:length]\n\ndef urlencode(s):\n if isinstance(s, unicode):\n ...
python
chosen
[ { "from": "system", "value": "Add a constructor to SendwithusError that stores content\n" }, { "from": "human", "value": "class SendwithusError(Exception):\n \"\"\"Base class for Sendwithus API errors\"\"\"\n\n\nclass AuthenticationError(SendwithusError):\n \"\"\"API Authentication Failed\...
python
chosen
[ { "from": "system", "value": "Use localhost:5000 for the dev server by default.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Flask application default config:\n# http://flask.pocoo.org/docs/config/#configuring-from-files\n# https://github.com/mbr/flask-...
python
chosen
[ { "from": "system", "value": "Use default seed for the test.\n" }, { "from": "human", "value": "import random\nimport time\nfrom PIL import Image # Depends on the Pillow lib\n\nfrom opensimplex import OpenSimplexNoise\n\nWIDTH = 512\nHEIGHT = 512\nFEATURE_SIZE = 24\n\ndef main():\n random.see...
python
chosen
[ { "from": "system", "value": "Update archan provider for archan 3.0\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"dependenpy plugins module.\"\"\"\n\ntry:\n from archan import Provider, Argument, DSM as ArchanDSM\n from .dsm import DSM as DependenpyDSM\n from .help...
python
chosen
[ { "from": "system", "value": "Fix Hobgoblin to trigger only on cards played\n" }, { "from": "human", "value": "from ..utils import *\n\n\n##\n# Minions\n\n# Hobgoblin\nclass GVG_104:\n\tdef OWN_MINION_SUMMON(self, minion):\n\t\tif minion.atk == 1:\n\t\t\treturn [Buff(minion, \"GVG_104a\")]\n" ...
python
chosen
[ { "from": "system", "value": "Change to vanilla namespace package\n" }, { "from": "human", "value": "try:\n __import__('pkg_resources').declare_namespace(__name__)\nexcept ImportError:\n from pkgutil import extend_path\n __path__ = extend_path(__path__, __name__)\n" }, { "from":...
python
chosen
[ { "from": "system", "value": "Fix style on migration - waste of time, but whatever\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2019-03-20 18:55\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migratio...
python
chosen
[ { "from": "system", "value": "Fix celery config to respect the host configured on settings\n" }, { "from": "human", "value": "import os\n\nREDIS_PORT = os.getenv('DBAAS_NOTIFICATION_BROKER_PORT', '6379')\nBROKER_URL = os.getenv(\n 'DBAAS_NOTIFICATION_BROKER_URL', 'redis://localhost:%s/0' % RE...
python
chosen
[ { "from": "system", "value": "Split basetype of DddDatatype into basetype,bitsize,signed" }, { "from": "human", "value": "'''\nCreated on 24.04.2016\n\n@author: killian\n'''\nfrom objects import dddobject,DataObject\nfrom conversions import DddConversion\n\n\n@dddobject('datatype')\nclass DddDat...
python
chosen
[ { "from": "system", "value": "Make sure our CachedModelMixin.delete() also returns the collector results\n" }, { "from": "human", "value": "from django.core.cache import cache\n\n\nclass CachedModelMixin(object):\n \"\"\"\n Mixin to add cache expiration to a model.\n \"\"\"\n clear_c...
python
chosen
[ { "from": "system", "value": "Update structure of Sheldon class\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\n@author: Lises team\n@contact: zhidkovseva@gmail.com\n@license: The MIT license\n\nCopyright (C) 2015\n\"\"\"\n\n__author__ = 'Lises team'\n__version__ = '0.1'\n_...
python
chosen
[ { "from": "system", "value": "Fix wrong module names and lower poll interval to 50 ms\n" }, { "from": "human", "value": "import pyb\n\nfrom mid.midiin import MidiIn\n\n\ndef midi_printer(msg):\n print(tuple(msg))\n\ndef loop(midiin):\n while True:\n midiin.poll()\n pyb.udelay...
python
chosen
[ { "from": "system", "value": "Improve unit test for HashableDict\n\nWe have HashableDict introduced to network info storing, but hash\nfunction of this implementation was never tested in unit tests.\n\nChange-Id: Id48c9172ca63e19b397dc131d85ed631874142cd\n" }, { "from": "human", "value": "# Copy...
python
chosen
[ { "from": "system", "value": "Add --dev command line arg\n\n" }, { "from": "human", "value": "import coloredlogs\nimport logging.handlers\n\nfrom argparse import ArgumentParser\n\n\ndef get_args():\n\n parser = ArgumentParser()\n\n parser.add_argument(\n \"-H\", \"--host\",\n ...
python
chosen
[ { "from": "system", "value": "Use Whoosh in prod for now.\n" }, { "from": "human", "value": "from django_website.settings.www import *\n\nPREPEND_WWW = False\nAPPEND_SLASH = True\nTEMPLATE_CONTEXT_PROCESSORS += [\"django.core.context_processors.request\"]\nROOT_URLCONF = 'django_website.urls.doc...
python
chosen
[ { "from": "system", "value": "Fix py3 'relative' import error.\n" }, { "from": "human", "value": "from influxdbclient import InfluxDBClient, InfluxDBClientError, DooblrInfluxDBError\n\n__all__ = [\"InfluxDBClient\", \"InfluxDBClientError\", \"DooblrInfluxDBError\"]\n" }, { "from": "gpt",...
python
chosen
[ { "from": "system", "value": "Update WiFi firmware update script.\n" }, { "from": "human", "value": "# WINC Firmware Update Script.\n#\n# This script updates the ATWINC1500 WiFi module firmware.\n# Copy the firmware image to uSD card before running this script.\n# NOTE: Firmware version 19.5.2 d...
python
chosen
[ { "from": "system", "value": "Swap the test-file assertion, to make output more sensible.\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nimport glob\nimport os.path\n\nimport pytest\n\nfrom scss import Scss\n\nHERE = os.path.join(os.path.split(__file__)[0], 'files')...
python
chosen
[ { "from": "system", "value": "Correct typo in help string\n" }, { "from": "human", "value": "import logging\n\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.core.management.base import BaseCommand\n\nfrom oscar.apps.customer.alerts import utils\n\nlogger = logging.getLogge...
python
chosen
[ { "from": "system", "value": "Define the default policy file\n\nThis change ensures that the default policy file for Manila API access\nis defined by default, so that operators can deploy their own policy\nmore easily.\n\nChange-Id: Ie890766ea2a274791393304cdfe532e024171195\n" }, { "from": "human", ...
python
chosen
[ { "from": "system", "value": "WebRTC: Make trybots use HEAD instead of LKGR\n\nIt's about time we make this change, which turned out\nto be very simple.\n\nReview URL: https://codereview.chromium.org/776233003\n\ngit-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@293261 0039d316-1c4b-4281-b951-d872f2087c9...
python
chosen
[ { "from": "system", "value": "Enable a 'now' property for the PollingDataStream\n" }, { "from": "human", "value": "import logging\n\nfrom datetime import timedelta\nfrom twisted.internet.task import LoopingCall\n\nfrom moksha.hub.hub import MokshaHub\n\nlog = logging.getLogger('moksha.hub')\n\nc...
python
chosen
[ { "from": "system", "value": "Add create and delete permissions to mysql user in wordpress example\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport sys\nimport os\nimport simplejson as json\n\nf = open(\"bootconf.json\", \"r\")\nvals_dict = json.load(f)\nf.close()\n\nos.putenv(...
python
chosen
[ { "from": "system", "value": "Fix a busted import statement in our TemplateController\n" }, { "from": "human", "value": "from ${package}.lib.base import *\n\nclass TemplateController(BaseController):\n\n def view(self, url):\n \"\"\"By default, the final controller tried to fulfill the...
python
chosen
[ { "from": "system", "value": "Fix error in Creator migration\n\nDue to manually tweaking old migrations.\nTests in django-hines were complaining about the migration trying\nto add Creator.slug a second time.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11 o...
python
chosen
[ { "from": "system", "value": "book-store: Use book price constant in calculation\n\n" }, { "from": "human", "value": "BOOK_PRICE = 8\n\n\ndef _group_price(size):\n discounts = [0, .05, .1, .2, .25]\n if not (0 < size <= 5):\n raise ValueError('size must be in 1..' + len(discounts))\...
python
chosen
[ { "from": "system", "value": "Increase timeout for satrapy name lookups\n" }, { "from": "human", "value": "from astropy.table import Table\nfrom astropy.coordinates import ICRS, name_resolve\nfrom astropy import units as u\n\nTABLE_NAME = 'feder_object_list.csv'\nMAX_SEP = 5 # arcsec\n\n\ndef t...
python
chosen
[ { "from": "system", "value": "Add a workaround for the AppConfig autodiscovery crashes with Django 3.2\n" }, { "from": "human", "value": "# flake8: noqa\n\nfrom feincms.content.application.models import *\n" }, { "from": "gpt", "value": "def __getattr__(key):\n # Work around Djang...
python
chosen
[ { "from": "system", "value": "Revert \"Update version to 0.2.2\"\n\nThis reverts commit 028a8722df2f6df6ca308430c672e651a57bd771.\n" }, { "from": "human", "value": "# -*- coding:utf-8 -*-\n\n\"\"\"\nInformation about this package.\n\"\"\"\n\n__author__ = 'Yan QiDong'\n__version__ = '0.2.2'\n__em...
python
chosen
[ { "from": "system", "value": "Add parsing for adding message\n" }, { "from": "human", "value": "import rethinkdb as r\n\nclass Commander:\n\n def process_message(self, message):\n return \"I got your message\"\n" }, { "from": "gpt", "value": "import re\n\nimport rethinkdb a...
python
chosen
[ { "from": "system", "value": "Use logging. Remove hardcoded settings\n" }, { "from": "human", "value": "from control_milight.utils import process_automatic_trigger\nfrom django.conf import settings\nfrom django.core.management.base import BaseCommand, CommandError\nimport serial\nimport time\n\n...
python
chosen
[ { "from": "system", "value": "Remove conversion to json string\n" }, { "from": "human", "value": "from attachment import Button\nimport json \n\nclass Template(object):\n \"\"\"\n Facebook Messenger message\n model for structured messages\n \"\"\"\n\n button_type = 'button'\n g...
python
chosen
[ { "from": "system", "value": "Fix PEP8: E126 continuation line over-indented\n\nfor hanging indent\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom wiki.core.plugins.base import BasePlugin\nfrom wiki.core.plugins import registry as plugin_registry\n\nfrom course_wiki.plugins.ma...
python
chosen
[ { "from": "system", "value": "Fix metric expression test name.\n" }, { "from": "human", "value": "from datetime import datetime\nimport json\nimport unittest\n\nfrom pypercube.cube import Cube\nfrom pypercube.cube import Query\nfrom pypercube.metric import Metric\nfrom pypercube.expression impor...
python
chosen
[ { "from": "system", "value": "Fix reference to new StepsLibrary object\n" }, { "from": "human", "value": "import pytest\n\nfrom nlppln import WorkflowGenerator\n\n\nclass TestWFGenerator(object):\n @pytest.fixture\n def wf(self):\n return WorkflowGenerator()\n\n def test_steps_in...
python
chosen
[ { "from": "system", "value": "Remove virtualenv setup from WSGI entrypoint\n\nHandle it in front end server instead.\n" }, { "from": "human", "value": "import os\nimport sys\nimport site\n\nVIRTUALENV=\"venv\"\n\n# Get site root from this file's location:\nSITE_ROOT=os.path.abspath(os.path.dirna...
python
chosen
[ { "from": "system", "value": "Fix test suite on travis (restore previous path config)\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nServer used for tests\n\"\"\"\nimport sys\nimport os\n# ensure sys knows about pyqode.core in the test env\nsys.path.in...
python
chosen
[ { "from": "system", "value": "Refactor out a bare except: statement\n\nIt now catches `Redirect.DoesNotExist`, returning the normal 404 page if\nno redirect is found. Any other exception should not be caught here.\n" }, { "from": "human", "value": "from django import http\n\nfrom wagtail.wagtail...
python
chosen
[ { "from": "system", "value": "Add foreign keys for form and route in Fdb Gcn Seq in carepoint cph\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# © 2015-TODAY LasLabs Inc.\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n\nfrom carepoint import Carepoint\nfrom...
python
chosen
[ { "from": "system", "value": "Allow Control of Interval and Observers\n" }, { "from": "human", "value": "import sys\n\nfrom src.TemperatureMonitor import TemperatureMonitor\nfrom src.temperature import TemperatureSensor\n\nSENSOR_ADDRESS = 0x48\n\ntempMonitor = TemperatureMonitor(TemperatureSens...
python
chosen
[ { "from": "system", "value": "Update Bug for Normal Genrator\n" }, { "from": "human", "value": "import mxnet as mx\nimport mxnet.ndarray as nd\n\n\nfor i in range(1000):\n noise = mx.random.normal(0,10,(i,i),ctx=mx.gpu())" }, { "from": "gpt", "value": "import mxnet as mx\nmx.rando...
python
chosen
[ { "from": "system", "value": "FIX only post message if a partner is existent\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n##############################################################################\n#\n# Copyright (C) 2014-2015 Compassion CH (http://www.compassion.ch)\n# ...
python
chosen
[ { "from": "system", "value": "Write warning to std err instead.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport os\n\nISIS_ROOT = os.environ.get('ISISROOT')\nif ISIS_ROOT is None:\n print 'Warning! ISISROOT is not defined. Bitch.'\n\n (ISIS_VERSION, ISIS_VERSION_MAJOR, I...
python
chosen
[ { "from": "system", "value": "Update due to changes in LOOKUP.\n" }, { "from": "human", "value": "import pytest\n\nfrom pyroSAR._dev_config import Storage, LOOKUP, URL, STORAGE\n\n\nclass TestStorage:\n def test_insert(self):\n storage = Storage(a=1, b=2)\n assert storage.a == 1...
python
chosen
[ { "from": "system", "value": "Allow for authenticated non super users to create posts and topics\n" }, { "from": "human", "value": "from pybb.permissions import DefaultPermissionHandler\n\n\nclass ForumPermissionHandler(DefaultPermissionHandler):\n def may_post_as_admin(self, user):\n ...
python
chosen
[ { "from": "system", "value": "Use Xlib instead of gtk to get screen width and screen height\nThis limit dependances\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding:utf-8 -*-\n\n__author__ = 'Olivier Larrieu'\n\nfrom gtk import gdk\n\n\nclass ScreenProperties(object):\n ...
python
chosen
[ { "from": "system", "value": "Use threshold for time boundary in manager\n" }, { "from": "human", "value": "from dateutil.relativedelta import relativedelta\nfrom django.apps import apps\nfrom django.utils import timezone\n\n\nuser_deletion_config = apps.get_app_config('user_deletion')\n\n\nclas...
python
chosen
[ { "from": "system", "value": "Upgrade code to Python 3.6+, Django 2.2 and remove deprecations\n" }, { "from": "human", "value": "from django.conf.urls import url\nfrom django.views.generic import TemplateView\n\nurlpatterns = [\n url(r\"^$\", TemplateView.as_view(template_name=\"homepage.html...
python
chosen
[ { "from": "system", "value": "Fix type annotation for Model.train()\n" }, { "from": "human", "value": "import abc\nimport tensorflow as tf\n\n\n\nclass Model(metaclass=abc.ABCMeta):\n @abc.astractmethod\n def __init__(self, **hyperparameters_and_initial_parameters):\n return NotImplemented\...
python
chosen
[ { "from": "system", "value": "mrp: Add tvOS 13.4 build number\n" }, { "from": "human", "value": "\"\"\"Lookup methods for device data.\"\"\"\n\nimport re\n\nfrom pyatv.const import DeviceModel\n\n\n_MODEL_LIST = {\n \"AppleTV2,1\": DeviceModel.Gen2,\n \"AppleTV3,1\": DeviceModel.Gen3,\n ...
python
chosen
[ { "from": "system", "value": "Add licensing info in source file.\n\n[H102 H103] Source code should be licensed under the Apache 2.0 license.\nAll source files should have the licensing header.\n\nChange-Id: I4f9ead44b5efa3616086f5a62a2e0e68854baf44\n" }, { "from": "human", "value": "from sahara_...
python
chosen
[ { "from": "system", "value": "Add test for no HTTP_AUTHORIZATION header at all\n" }, { "from": "human", "value": "from utils.testcase import EndpointTestCase\nfrom rest_framework import status\nfrom rest_framework.test import APIClient\n\nfrom django.utils.translation import ugettext_lazy as _\n...
python
chosen
[ { "from": "system", "value": "Test case for parsing invalid data.\n" }, { "from": "human", "value": "import json\n\nfrom django.test import TestCase\nfrom io import BytesIO\nfrom rest_framework_json_api.parsers import JSONParser\n\n\nclass TestJSONParser(TestCase):\n\n def setUp(self):\n ...
python
chosen
[ { "from": "system", "value": "Remove comment from check nslookup\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport logging\nfrom util import full_stack\nfrom util import check_nslookup\nfrom util import get_credentials_for\nfrom dbaas_dnsapi.models import DatabaseInfraDNSList\nf...
python
chosen
[ { "from": "system", "value": "[fix] Set null values to '0' before changing column type\n" }, { "from": "human", "value": "import frappe\nfrom frappe.model.utils.rename_field import rename_field\n\ndef execute():\n\tfrappe.reload_doc(\"hr\", \"doctype\", \"leave_type\")\n\tfrappe.db.sql_ddl(\"\"\...
python
chosen
[ { "from": "system", "value": "Hide StreamAnalyzer and OsGuesser from the API docs.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# Generates the *public* API documentation.\n# Remember to hide your private parts, people!\nimport os, re, sys\n\nproject = 'Exscript'\nbase_dir = os.pat...
python
chosen
[ { "from": "system", "value": "Raise Parse Error if request data is not a dictionary\n" }, { "from": "human", "value": "from rest_framework.parsers import JSONParser\n\nfrom api.base.renderers import JSONAPIRenderer\nfrom api.base.exceptions import JSONAPIException\n\nclass JSONAPIParser(JSONPars...
python
chosen
[ { "from": "system", "value": "Update quickstart project to use AUTO_*\n" }, { "from": "human", "value": "from __future__ import absolute_import, print_function, unicode_literals\n\nfrom collections import Counter\nfrom streamparse.bolt import Bolt\n\nclass WordCounter(Bolt):\n\n def initializ...
python
chosen
[ { "from": "system", "value": "Add import ActionOption and MessageClassOption to __all__\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n\n'''aiospamc package.\n\nAn asyncio-based library to communicate with SpamAssassin's SPAMD service.'''\n\nfrom aiospamc.client import Client\n\n__al...
python
chosen
[ { "from": "system", "value": "Append messages if message view is currently open\n" }, { "from": "human", "value": "import sublime\nimport sublime_plugin\n\nPANEL_NAME = \"SublimeLinter Messages\"\nOUTPUT_PANEL = \"output.\" + PANEL_NAME\n\n\ndef plugin_unloaded():\n for window in sublime.wind...
python
chosen
[ { "from": "system", "value": "Fix monkey patching to pass kwargs required by Python 3.4\n" }, { "from": "human", "value": "import xml.etree.ElementTree as E\n\nfrom authorize.configuration import Configuration\nfrom authorize.address import Address\nfrom authorize.bank_account import BankAccount...
python
chosen
[ { "from": "system", "value": "Fix check for cls attribute\n\n* If resolved_view has a cls attribute then view should already be a\n class.\n" }, { "from": "human", "value": "import warnings\n\nfrom django.core.urlresolvers import resolve, reverse\nfrom django.test import TestCase\n\n\nclass URL...
python
chosen
[ { "from": "system", "value": "Create do_requestion function to be used by other methods.\n" }, { "from": "human", "value": "import requests\n\nclass Api(object):\n def __init__(self, server='http://localhost/zabbix'):\n self.session = requests.Session()\n self.session.headers.up...
python
chosen
[ { "from": "system", "value": "Fix rmdup handling in wrapper script.\n" }, { "from": "human", "value": "#!python\n\n# Load libraries\nimport sys, getopt\n\nimport pysam\n\nimport libPipeline\n\n# Set constants\nhelpMsg ='''\nSYNOPSIS\nparseSAMOutput\nparseSAMOutput [OPTIONS] SAMFILE\n#\nDESCRIPTI...
python
chosen
[ { "from": "system", "value": "FIX schema type not object\n" }, { "from": "human", "value": "import jsonschema\n\n\ndef validate(data, schema):\n try:\n jsonschema.validate(data, schema)\n except jsonschema.exceptions.ValidationError:\n return False\n\n if schema[\"type\"] ...
python
chosen
[ { "from": "system", "value": "Implement secure RBAC for the network IP availability\n\nThis commit updates the network IP availability policies to understand scope\nchecking and account for a read-only role. This is part of a broader series of\nchanges across OpenStack to provide a consistent RBAC experienc...
python
chosen
[ { "from": "system", "value": "Add test to clarify equality/is behavior\n" }, { "from": "human", "value": "import Transaction\n\nimport unittest\n\nclass TestTransaction(unittest.TestCase) :\n\n def setUp(self) :\n self.test_object = Transaction.Transaction()\n\n def tearDown(self) :...
python
chosen
[ { "from": "system", "value": "Add OrderedSet mutation tests. Refactor tests.\n\nRefactored the tests to rely less on setUp because I've got to test\nmutating the objects.\n" }, { "from": "human", "value": "from twisted.trial import unittest\n\nfrom better_od import OrderedSet\n\n\nclass TestOrde...
python
chosen
[ { "from": "system", "value": "Add missing pytest DB marker\n" }, { "from": "human", "value": "\"\"\"\nTests that migrations are not missing\n\"\"\"\n\ntry:\n from io import StringIO\nexcept ImportError:\n from StringIO import StringIO\n\nimport pytest\n\nfrom django.core.management import ...
python
chosen
[ { "from": "system", "value": "Move NullFile and NullStream to monty\n\n\nFormer-commit-id: 5492c3519fdfc444fd8cbb92cbf4b9c67c8a0883 [formerly 4aa6714284cb45a2747cea8e0f38e8fbcd8ec0bc]\nFormer-commit-id: e6119512027c605a8277d0a99f37a6ab0d73b6c7" }, { "from": "human", "value": "# coding: utf-8\n\n...
python
chosen
[ { "from": "system", "value": "Fix relative portion of link.\n" }, { "from": "human", "value": "from pyshelf.cloud.stream_iterator import StreamIterator\nfrom flask import Response\n\n\nclass ArtifactListManager(object):\n def __init__(self, container):\n self.container = container\n\n ...
python
chosen
[ { "from": "system", "value": "Test added. Program should be complete.\n" }, { "from": "human", "value": "# Asks the user for input of the word and makes it lower case.\nnormStr = raw_input(\"Enter the word:\\n\").lower();\n# Inverts the string so it can compare it with the original input.\ninver...
python
chosen
[ { "from": "system", "value": "Add missing auth middleware for 1.7 tests\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\nfrom os.path import abspath, dirname\n\nimport django\nfrom django.conf import settings\n\n\nsys.path.insert(0, abspath(dirname(__file__)))\n\n\nif not se...
python
chosen
[ { "from": "system", "value": "Update password functions for Django 1.8\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\n\n# Uncomment the next two lines to enable the admin:\nfrom django.contrib import admin\nadmin.autodiscover()\n\nurlpatterns = patterns('...
python
chosen
[ { "from": "system", "value": "Make official google imports actually work.\n" }, { "from": "human", "value": "# Offer forward compatible imports of datastore_rpc and datastore_query.\n\nimport logging\n\ntry:\n from google.appengine.datastore import datastore_rpc\n from google.appengine.datasto...
python
chosen
[ { "from": "system", "value": "Add before_request and it works for this bug\n\nCheck if the signature exists. Redirect to the login page if it doesn't. I took `rrd/view/index.py` as the reference\n" }, { "from": "human", "value": "#-*- coding:utf-8 -*-\nimport os\nfrom flask import Flask\n\n#-- c...
python
chosen
[ { "from": "system", "value": "Use app.extensions to get perm reference.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom flask import Blueprint, render_template, current_app, url_for, redirect, request, flash\n\nbp = Blueprint('perm-admin', __name__, template_folder='templates'...
python
chosen
[ { "from": "system", "value": "Make changes to default to Python3\n\nSince we have undoubtedly moved to Python3 for the most part within the community, this should be Python3 by default. We make Python2 users work harder now.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# Password Ha...
python
chosen
[ { "from": "system", "value": "Update post view sorting (so latest comes first)\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom flask import current_app\nfrom flask_admin.contrib.fileadmin import FileAdmin\nfrom flask_admin import AdminIndexView, expose, Admin\nfrom flask_admin...
python
chosen
[ { "from": "system", "value": "Update to pet model for provisioner\n" }, { "from": "human", "value": "from google.appengine.ext import ndb\n\n# This is to store alternate linart versions of the same pets\nclass SpeciesVersion(ndb.Model):\n name = ndb.StringProperty()\n base_image = ndb.Stri...
python
chosen