conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Revert \"Enforce valid captcha only if required, so tests can relax captcha requirement\"\n\nThis reverts commit c3c450b1a7070a1dd1b808e55371e838dd297857. It wasn't\nsuch a great idea.\n" }, { "from": "human", "value": "from django.conf import settings\nfrom django ...
python
chosen
[ { "from": "system", "value": "Add package argument to deploy-ticket\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom .command import Command\nfrom matador import utils\n\n\nclass DeployTicket(Command):\n\n def _add_arguments(self, parser):\n parser.prog = 'matador deploy-...
python
chosen
[ { "from": "system", "value": "Use a bool sensor for testing, and query the API instead of models\n" }, { "from": "human", "value": "from django.test import TestCase\nfrom spiff.api.tests import APITestMixin, withPermission\nimport models\n\nclass SensorTest(APITestMixin):\n def setUp(self):\n ...
python
chosen
[ { "from": "system", "value": "Create an output directory unless it exists\n" }, { "from": "human", "value": "__author__ = 'Maksim Dmitriev'\n\nimport argparse\n\nif __name__ == \"__main__\":\n parser = argparse.ArgumentParser()\n parser.add_argument('--foo', help='foo help', required=True)...
python
chosen
[ { "from": "system", "value": "Use buffer() to try and avoid memory copies\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport errno\nimport collections\nfrom savate import writev\n\n# FIXME: should this be a method of BufferEvent below ?\n# FIXME: handle Python2.x/Python3k compa...
python
chosen
[ { "from": "system", "value": "Add print_ip method for debugging\n" }, { "from": "human", "value": "import socks\nimport socket\nfrom stem.control import Controller\nfrom stem import Signal\n\n\nclass Tor(object):\n \"\"\"Tor class for socks proxy and controller\"\"\"\n def __init__(self, s...
python
chosen
[ { "from": "system", "value": "Make an exception for debian in tests.test_correct_os_version\n\nThis is because of a known issue where downburst gives us 7.1 when we\nask for 7.0. We're ok with this behavior for now. See: issue #10878\n\nSigned-off-by: Andrew Schoen <1bb641dc23c3a93cce4eee683bcf4b2bea7903a3...
python
chosen
[ { "from": "system", "value": "Fix api key call to be renmamed key\n" }, { "from": "human", "value": "# Copyright 2015, Google, Inc.\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use\n# this file except in compliance with the License. You may obtain a copy of th...
python
chosen
[ { "from": "system", "value": "Revert unintend change. Fixes bug.\n" }, { "from": "human", "value": "# A context carrying the loaded configuration.\n\nfrom libcloud.compute.types import Provider\nfrom libcloud.compute.providers import get_driver\n\nimport config\n\nclass ConfigContext(object):\n...
python
chosen
[ { "from": "system", "value": "Use service client factory method for resource group command\n" }, { "from": "human", "value": "from msrest import Serializer\nfrom ..commands import command, description\nfrom .._profile import Profile\n\n@command('resource group list')\n@description('List resource...
python
chosen
[ { "from": "system", "value": "Allow deletion of figshare drafts\n" }, { "from": "human", "value": "from website.util.sanitize import escape_html\nfrom website.addons.base.exceptions import AddonEnrichmentError\n\n\nclass FigshareIsDraftError(AddonEnrichmentError):\n\n def __init__(self, file_...
python
chosen
[ { "from": "system", "value": "Include ashist in the general namespace by default\n" }, { "from": "human", "value": "\n#__all__ = [\"hists\", \"binning\"]\n\nfrom .hists import *\n#from .converter import ashist" }, { "from": "gpt", "value": "\n#__all__ = [\"hists\", \"binning\"]\n\nfr...
python
chosen
[ { "from": "system", "value": "Remove unused modules, fix HTML response\n" }, { "from": "human", "value": "#!/usr/bin/python\n\n# Based on examples from\n# http://www.tutorialspoint.com/python/python_cgi_programming.htm\n\nimport sys\nimport cgi\nimport os\nimport cgitb\ncgitb.enable()\n\nCSV_DIR...
python
chosen
[ { "from": "system", "value": "Make it work with Python 3.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n__author__ = 'Ardy Dedase'\n__email__ = 'ardy.dedase@skyscanner.net'\n__version__ = '0.1.0'\n\nfrom skyscanner import Flights, FlightsCache, Hotels, CarHire" }, { "from":...
python
chosen
[ { "from": "system", "value": "Remove name, url and email from comment form\n" }, { "from": "human", "value": "from django.shortcuts import render_to_response, get_object_or_404\nfrom django.template import RequestContext\nfrom django.contrib.auth.decorators import login_required\nfrom django.uti...
python
chosen
[ { "from": "system", "value": "Add support for channels in the spec\n" }, { "from": "human", "value": "from __future__ import absolute_import\nimport sys\n\nfrom conda.cli import common\nfrom conda import plan\n\n\ndef install(prefix, specs, args, data):\n # TODO: do we need this?\n common....
python
chosen
[ { "from": "system", "value": "Add gradient background to GraphScheme\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\nfrom PySide import QtGui\n\nclass GraphScheme( QtGui.QGraphicsScene):\n \"\"\" Graph scheme drawing class\n \n This class inherits from QtGui.QGraphic...
python
chosen
[ { "from": "system", "value": "Add enum for different rulesets\n" }, { "from": "human", "value": "# Copyright 2022 Google\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 obtain a copy of the Lic...
python
chosen
[ { "from": "system", "value": "Set default taking access for GradingProjectSurvey to org.\n\nThis will allow Mentors and Org Admins to take GradingProjectSurveys in case that an Org Admin has no Mentor roles.\n" }, { "from": "human", "value": "#!/usr/bin/python2.5\n#\n# Copyright 2009 the Melange...
python
chosen
[ { "from": "system", "value": "Add Server Port and PID to the X-Server-Machine header\n\nFixes hhucn/adhocracy.hhu_theme#429\n" }, { "from": "human", "value": "\nimport platform\n\n\nclass IncludeMachineName(object):\n\n def __init__(self, app, config):\n self.app = app\n self.co...
python
chosen
[ { "from": "system", "value": "Build closure for TRIPS ontology\n" }, { "from": "human", "value": "import os\nfrom indra.preassembler.hierarchy_manager import HierarchyManager\n\n# Make a TRIPS ontology\n_fname = os.path.join(os.path.dirname(__file__), 'trips_ontology.rdf')\ntrips_ontology = Hier...
python
chosen
[ { "from": "system", "value": "Fix query result list having an empty list default parameter (default parameters get initialized only once!)\n" }, { "from": "human", "value": "from query_result_document import QueryResultDocument\n\n\nclass QueryResultList:\n def __init__(self, query, result_docu...
python
chosen
[ { "from": "system", "value": "Use an https URL rather than http.\n\nFound by sphinx's linkcheck.\n" }, { "from": "human", "value": "\"\"\"\nRISC-V Target\n-------------\n\n`RISC-V <http://riscv.org/>`_ is an open instruction set architecture\noriginally developed at UC Berkeley. It is a RISC-sty...
python
chosen
[ { "from": "system", "value": "Change to connect to Stratisd on the system bus\n\nStratisd is changing to use the system bus, so naturally we need to\nalso change in order to continue working.\n\nSigned-off-by: Andy Grover <b7d524d2f5cc5aebadb6b92b08d3ab26911cde33@redhat.com>\n" }, { "from": "human",...
python
chosen
[ { "from": "system", "value": "Fix artifact spec for deploy-job." }, { "from": "human", "value": "#!/usr/bin/env python\nimport json\nimport os\nimport subprocess\nimport sys\nfrom tempfile import NamedTemporaryFile\n\n\ndef main():\n revision_build = os.environ['revision_build']\n job_name...
python
chosen
[ { "from": "system", "value": "Add integration test for `pkgpanda add`\n" }, { "from": "human", "value": "import os\n\nfrom pkgpanda.util import expect_fs\nfrom util import run\n\nfetch_output = \"\"\"\\rFetching: mesos--0.22.0\\rFetched: mesos--0.22.0\\n\"\"\"\n\n\ndef test_fetch(tmpdir):\n #...
python
chosen
[ { "from": "system", "value": "Introduce base party form, limit `archived` flag to update form\n" }, { "from": "human", "value": "\"\"\"\nbyceps.blueprints.admin.party.forms\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Copyright: 2006-2019 Jochen Kupperschmidt\n:License: Modified BSD, see LICENSE for...
python
chosen
[ { "from": "system", "value": "Fix uploader when there is nothing to upload\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtai...
python
chosen
[ { "from": "system", "value": "Use kernel32 with ST2 on Windows to get unicode environmental variable values\n" }, { "from": "human", "value": "# coding: utf-8\nfrom __future__ import unicode_literals, division, absolute_import, print_function\n\nimport os\nimport locale\n\nfrom ._types import st...
python
chosen
[ { "from": "system", "value": "Fix failing test caused by view rename\n" }, { "from": "human", "value": "from django.test import TestCase\nfrom django.urls import reverse\n\n\nclass SmokeTest(TestCase):\n def test_landing(self):\n url = reverse('static:home')\n resp = self.client...
python
chosen
[ { "from": "system", "value": "Add shebang to main script.\n" }, { "from": "human", "value": "from been.couch import CouchStore\nfrom flask import Flask, render_template\n\napp = Flask(__name__)\napp.jinja_env.trim_blocks = True\n\nstore = CouchStore()\nstore.load()\n\n@app.route('/')\ndef wake()...
python
chosen
[ { "from": "system", "value": "Add timeout to Icecast status request\n" }, { "from": "human", "value": "from api.streams.models import StreamConfiguration\nfrom django.http import JsonResponse\nfrom django.http.request import HttpRequest\nimport requests\n\ndef get_stream_status(request: HttpRequ...
python
chosen
[ { "from": "system", "value": "Handle None returned from poll()\n" }, { "from": "human", "value": "\"\"\"\nPrimary entrypoint for applications wishing to implement Python Kafka Streams\n\n\"\"\"\n\nimport logging\n\nimport confluent_kafka as kafka\n\nlog = logging.getLogger(__name__)\n\nclass Kaf...
python
chosen
[ { "from": "system", "value": "Add a test for the get_thumb function.\n" }, { "from": "human", "value": "# -*- coding:utf-8 -*-\n\nimport os\n\ntry:\n import unittest2 as unittest\nexcept ImportError:\n import unittest # NOQA\n\nfrom sigal.settings import read_settings\n\n\nclass TestSetti...
python
chosen
[ { "from": "system", "value": "[HOTFIX] Update url for new term\n\nThere's a new term, I have to make this configurable" }, { "from": "human", "value": "import requests\nfrom bs4 import BeautifulSoup\nimport pickle\nimport os\n\ndef save_meps():\n url = \"http://www.votewatch.eu//en/term8-euro...
python
chosen
[ { "from": "system", "value": "Make it work when executed from a different directory" }, { "from": "human", "value": "#! /usr/bin/env python\n'''\nSimplistic chain discovery\n'''\n\nimport sys\nsys.path.append('../..')\n\nfrom playtag.cables.digilent import Jtagger\nfrom playtag.jtag.discover imp...
python
chosen
[ { "from": "system", "value": "Change name of output file in example\n\n--HG--\nextra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401549\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nExample using the NetworkX ego_gra...
python
chosen
[ { "from": "system", "value": "Fix a py3 bug in reference compatibility\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\ntry:\n from __builtins__ import ReferenceError\nexcept (NameError, ImportError): # pragma: no cover\n from weakref import ReferenceError\n\n__all__ = ['Refer...
python
chosen
[ { "from": "system", "value": "Fix missing import. Add method to get all nodes with a particular attribute\n" }, { "from": "human", "value": "\"\"\"\nRegistry class and global node registry.\n\"\"\"\n\nclass NotRegistered(KeyError):\n pass\n\n\n__all__ = [\"NodeRegistry\", \"nodes\"]\n\n\ncla...
python
chosen
[ { "from": "system", "value": "Add test for correct error for nonexistent routes\n" }, { "from": "human", "value": "\"\"\"Tests for the Wallace API.\"\"\"\n\nimport subprocess\nimport re\nimport os\nimport requests\n\n\nclass TestHeroku(object):\n\n \"\"\"The Heroku test class.\"\"\"\n\n sa...
python
chosen
[ { "from": "system", "value": "Fix permission-denied error in read-only context\n" }, { "from": "human", "value": "from hb_res.storage import ExplanationStorage\n\n__author__ = 'skird'\n\nimport codecs\nfrom hb_res.explanations.Explanation import Explanation\n\n\nclass FileExplanationStorage(Expl...
python
chosen
[ { "from": "system", "value": "Add code to send sms\n" }, { "from": "human", "value": "'''\nThis module will send SMS reminders periodically, using Twilio.\nThe aim is to encourage user to code, commit and push to GitHub everyday\n'''\n\nimport requests\n\ndef set_configuration():\n '''\n S...
python
chosen
[ { "from": "system", "value": "Fix bug in python loader.\n" }, { "from": "human", "value": "import os.path\nimport sys\n\nfrom .loader import Loader, I18nFileLoadError\n\nclass PythonLoader(Loader):\n \"\"\"class to load python files\"\"\"\n def __init__(self):\n super(PythonLoader, ...
python
chosen
[ { "from": "system", "value": "Update destination endpoint tests to work with new version of peewee\n" }, { "from": "human", "value": "import unittest\n\nfrom peewee import SqliteDatabase\nfrom playhouse.test_utils import test_database\n\nimport api.tests.helpers as helpers\nfrom api.destinations...
python
chosen
[ { "from": "system", "value": "Apply parentheses for group import\n" }, { "from": "human", "value": "# encoding: utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\n# Import the models we want directly available through the root module\nfrom .models import...
python
chosen
[ { "from": "system", "value": "Add silverline environment to nginx\n" }, { "from": "human", "value": "\nfrom kokki import *\n\nPackage(\"nginx\")\n\nDirectory(env.config.nginx.log_dir,\n mode = 0755,\n owner = env.config.nginx.user,\n action = 'create')\n\nfor nxscript in ('nxensite', 'n...
python
chosen
[ { "from": "system", "value": "Add unit test for report formatter [WAL-905]\n" }, { "from": "human", "value": "from django.test import TestCase\n\nfrom nodeconductor_assembly_waldur.invoices.tasks import format_invoice_csv\n\nfrom .. import models\nfrom . import fixtures\n\n\nclass TestReportForm...
python
chosen
[ { "from": "system", "value": "Fix uses of file objects" }, { "from": "human", "value": "import os.path\nimport json\n\n\nPACKAGE_DIR = os.path.dirname(os.path.realpath(__file__))\nwith open(os.path.join(PACKAGE_DIR, 'data/smartphone_dev_id.json')) as f:\n SMARTPHONE_DEV_IDS = json.load(open(f...
python
chosen
[ { "from": "system", "value": "Add option to run async tasks only on at a time\n\nThis is implemented with a simple lock like mechanism using redis.\n" }, { "from": "human", "value": "from utils.redis_store import store\n\n\ndef data_from_async_task(task_func, task_args, task_kwargs, store_key, r...
python
chosen
[ { "from": "system", "value": "Check for number of modules in haddock-checking script\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"\nTiny utility script to check that coverage statistics output by stack haddock\nare all 100%.\n\"\"\"\nimport sys\nimport re\n\ndef main():\n \...
python
chosen
[ { "from": "system", "value": "Add app_name for django < 1.7 compatibility\n" }, { "from": "human", "value": "\n\nfrom django.db import models\nfrom django.conf import settings\nfrom django.utils.translation import ugettext_lazy as _\n\n\nDEFAULT_ICEBERG_ENV = getattr(settings, 'ICEBERG_DEFAULT_E...
python
chosen
[ { "from": "system", "value": "Fix processing of empty lines.\n" }, { "from": "human", "value": "from __future__ import division, absolute_import, print_function\n\n__all__ = ['Cartfile']\n\nimport re\nfrom pathlib2 import Path\nfrom .basic_types import *\nfrom .errors import *\n\n\nclass Cartfil...
python
chosen
[ { "from": "system", "value": "Remove last good URL for tryserver.chromium\n\nThe expected behavior of this change is that the tryserver master no longer tries\nto resolve revisions to LKGR when trying jobs.\n\nBUG=372499, 386667\n\nReview URL: https://codereview.chromium.org/394653002\n\ngit-svn-id: 239fca9...
python
chosen
[ { "from": "system", "value": "Return an \"empty sequence\" character instead of an empty list for empty select fields\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"Jinja environment filters for Pynuts.\"\"\"\n\nfrom flask import escape\nfrom flask.ext.wtf import (\n Quer...
python
chosen
[ { "from": "system", "value": "Add reverse action to importing default lot types\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.3 on 2017-07-18 02:15\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\ndef load_data(app...
python
chosen
[ { "from": "system", "value": "Fix partner project serializer. (The comment was outdated btw)\n" }, { "from": "human", "value": "from bluebottle.bluebottle_drf2.serializers import ImageSerializer\nfrom bluebottle.projects.models import PartnerOrganization\nfrom bluebottle.projects.serializers imp...
python
chosen
[ { "from": "system", "value": "Add documentation and fix pop\n" }, { "from": "human", "value": "class DepthFirstSearchStrategy:\n\n def __init__(self, content, max_depth):\n self.content = content\n self.max_depth = max_depth\n\n def __iter__(self):\n return self\n\n ...
python
chosen
[ { "from": "system", "value": "bii: Make _bii_deps_in_place actually behave like a context manager\n" }, { "from": "human", "value": "# /ciscripts/coverage/bii/coverage.py\n#\n# Submit coverage totals for a bii project to coveralls\n#\n# See /LICENCE.md for Copyright information\n\"\"\"Submit cov...
python
chosen
[ { "from": "system", "value": "Initialize ChatterBot in django view module instead of settings.\n" }, { "from": "human", "value": "from django.views.generic import View\nfrom django.http import JsonResponse\nfrom django.conf import settings\n\n\nclass ChatterBotView(View):\n\n def post(self, r...
python
chosen
[ { "from": "system", "value": "Fix up path to runtime library directory.\n" }, { "from": "human", "value": "from . import tokenizer, ast, codegen\nimport sys, os, subprocess\n\nTRIPLES = {\n\t'darwin': 'x86_64-apple-darwin11.0.0',\n\t'linux2': 'x86_64-pc-linux-gnu',\n}\n\ndef llir(fn, full=True):...
python
chosen
[ { "from": "system", "value": "Add a function for removing & finding independent columns from an array\n" }, { "from": "human", "value": "def remove_low_variance(X, low_variance_threshold=1e-4, axis=0):\n low_variance = X.var(axis=axis) < low_variance_threshold\n X[:, ~low_variance]\n re...
python
chosen
[ { "from": "system", "value": "Add prop structure and performance models\n" }, { "from": "human", "value": "\" propeller model \"\nfrom numpy import pi\nfrom gpkit import Model, parse_variables, SignomialsEnabled, SignomialEquality\n\nclass Propeller(Model):\n \"\"\" Propeller Model\n\n Var...
python
chosen
[ { "from": "system", "value": "Fix filter_ method calling parent method bug\n" }, { "from": "human", "value": "import numpy as np\nimport cv2\nfrom core import KpFilter\n\n\nclass Ransac(KpFilter):\n def __init__(self, data):\n KpFilter.__init__(self, data)\n\n def __good_pts(self, k...
python
chosen
[ { "from": "system", "value": "Fix bug in download links\n" }, { "from": "human", "value": "import copy\n\nfrom django import template\nfrom django.conf import settings\n\nfrom games import models\n\nregister = template.Library()\n\n\ndef get_links(user_agent):\n systems = ['ubuntu', 'fedora',...
python
chosen
[ { "from": "system", "value": "Update resource group unit test\n" }, { "from": "human", "value": "from cloudbridge.cloud.providers.azure.test.helpers import ProviderTestBase\n\n\nclass AzureResourceGroupTestCase(ProviderTestBase):\n def test_resource_group_create(self):\n resource_group...
python
chosen
[ { "from": "system", "value": "Add logging to thumbnail creation task.\n" }, { "from": "human", "value": "from io import BytesIO\n\nfrom django.conf import settings\nfrom django.core.files.base import ContentFile\n\nfrom PIL import Image\n\nfrom chmvh_website import celery_app\n\n\n@celery_app.ta...
python
chosen
[ { "from": "system", "value": "Update GStreamer software mixer to use new output API\n" }, { "from": "human", "value": "import multiprocessing\n\nfrom mopidy.mixers import BaseMixer\nfrom mopidy.utils.process import pickle_connection\n\nclass GStreamerSoftwareMixer(BaseMixer):\n \"\"\"Mixer wh...
python
chosen
[ { "from": "system", "value": "Fix of shuffle. There should be random swap of leading zero with one from nine (non-zero) positions.\n" }, { "from": "human", "value": "\"\"\" How to generate a random 4 digit number not starting with 0 and having unique digits in python? \"\"\"\n\nimport random\nl ...
python
chosen
[ { "from": "system", "value": "Remove somore more lines related to email\n" }, { "from": "human", "value": "import smtplib\n\n\ndef send_email(msg):\n # Send the message via our own SMTP server.\n with smtplib.SMTP_SSL('smtp.gmail.com', 465) as s:\n # s.starttls()\n s.set_debu...
python
chosen
[ { "from": "system", "value": "Remove kludge from setup_logging as no longer necessary\n" }, { "from": "human", "value": "import os\nimport json\nimport logging\nimport logging.config\n\n\ndef setup_logging(log_path, settings_path=\"logging.json\", default_level=logging.INFO):\n \"\"\"Setup lo...
python
chosen
[ { "from": "system", "value": "BUG: Write concern bug fix in constantly deleting DB. It's on by default and w=1 does nothing.\n" }, { "from": "human", "value": "\"\"\"Delete all documents every second forever\"\"\"\n\n__author__ = 'tunnell'\n\nimport sys\nimport time\nimport json\n\nimport pymon...
python
chosen
[ { "from": "system", "value": "Rename Markdown source to MarkdownDirectory.\n" }, { "from": "human", "value": "from been.core import DirectorySource, source_registry\n\nclass Markdown(DirectorySource):\n kind = 'markdown'\n def process_event(self, event):\n lines = event['content'].s...
python
chosen
[ { "from": "system", "value": "Add infos about MAP file\n" }, { "from": "human", "value": "# csv2map.py -- Convert .csv into a .map format\n# Description of MAP format: http://pngu.mgh.harvard.edu/~purcell/plink/data.shtml#map\n#\n# jean-daniel.granet@mines-paristech.fr\n\nimport sys\nimport ar...
python
chosen
[ { "from": "human", "value": "Build system doesn't approve of empty files\n\n\ngit-svn-id: 81e381228600e5752b80483efd2b45b26c451ea2@6616 e27351fd-9f3e-4f54-a53b-843176b1656c\n" }, { "from": "gpt", "value": "##\n# Copyright (c) 2005-2007 Apple Inc. All rights reserved.\n#\n# Licensed under the Apa...
python
chosen
[ { "from": "system", "value": "Remove field duplication from migrations(nc-301)\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport django_fsm\n\n\nclass Migration(migrations.Migration):\n\n dep...
python
chosen
[ { "from": "system", "value": "Use source key instead of meta and detail fields\n" }, { "from": "human", "value": "\nfrom rest_framework import status\nfrom rest_framework.exceptions import APIException\n\n\ndef json_api_exception_handler(exc, context):\n \"\"\" Custom exception handler that r...
python
chosen
[ { "from": "system", "value": "Use mtgox as data source\n" }, { "from": "human", "value": "# -*- encoding: utf-8 -*-\nfrom __future__ import unicode_literals, print_function, division\n\n\ndef command_btc(bot, user, channel, args):\n \"\"\"Display BTC exchange rates\"\"\"\n\n r = bot.get_ur...
python
chosen
[ { "from": "system", "value": "Include the new Subscriptions stub" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\n\nfrom .mws import MWS, MWSError\nfrom .apis import Feeds, Finances, InboundShipments, Inventory, MerchantFulfillment,\\\n ...
python
chosen
[ { "from": "system", "value": "Load template from `cherrypy.request.template` in handler.\n" }, { "from": "human", "value": "import cherrypy\nfrom mako.lookup import TemplateLookup\n\n\nclass Tool(cherrypy.Tool):\n _lookups = {}\n\n def __init__(self):\n cherrypy.Tool.__init__(self, ...
python
chosen
[ { "from": "system", "value": "examples: Test Python support for arguments.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n# Copyright 2017 Stanford University\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance wi...
python
chosen
[ { "from": "system", "value": "Rework test runner to generate coverage stats correctly.\n\nNose seems to pick up argv automatically - which is annoying. Will need\nto look into at some point.\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\nimport logging\nfrom optparse impo...
python
chosen
[ { "from": "system", "value": "Include contrib.sites when running tests; needed for sitemaps in Django >= 1.2.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nfrom os.path import dirname, abspath\nimport sys\n\nfrom django.conf import settings\n\nif not settings.configured:\n from ...
python
chosen
[ { "from": "system", "value": "Use new extension setup() API\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nimport os\n\nfrom mopidy import config, ext\n\n\n__version__ = '0.2.2'\n\n\nclass GMusicExtension(ext.Extension):\n\n dist_name = 'Mopidy-GMusic'\n ext_...
python
chosen
[ { "from": "system", "value": "Correct six local import for python3 compatibility" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nThis is the only interface that you should ever need to get a **user** logged in, get\n**his/her** info and credentials, deserialize the credentials\...
python
chosen
[ { "from": "system", "value": "Add support for files.upload API call.\n\nCloses #64, #88.\n" }, { "from": "human", "value": "import json\n\nimport requests\nimport six\n\n\nclass SlackRequest(object):\n\n @staticmethod\n def do(token, request=\"?\", post_data=None, domain=\"slack.com\"):\n ...
python
chosen
[ { "from": "system", "value": "Use is instead of == for types.\n" }, { "from": "human", "value": "from nolang.error import AppError\nfrom nolang.objects.root import W_Root\n\n\nclass W_ListObject(W_Root):\n def __init__(self, w_items):\n self._w_items = w_items\n\n def str(self, spac...
python
chosen
[ { "from": "system", "value": "Truncate ROI-smoothing Gaussian at 2 STD per default.\n" }, { "from": "human", "value": "import scipy.ndimage as ndim\nfrom skimage.filters import gaussian\n\n\ndef patch_up_roi(roi, sigma=0.5):\n \"\"\"\n After being non-linearly transformed, ROIs tend to hav...
python
chosen
[ { "from": "system", "value": "Change single quote to double quote to make it run -.-\n" }, { "from": "human", "value": "print \"Let's practice everything.\"\nprint 'You\\'d need to know \\'bout escapes with \\\\ that do \\n newlines and \\t tabs.\"\n\npoem = \"\"\"\n\\t the lovely world\nwtih lo...
python
chosen
[ { "from": "system", "value": "Replace text files with database access.\n" }, { "from": "human", "value": "import random, os\n\nglobal adjectives, animals, rares\n\nwith open(os.path.join(os.path.dirname(__file__), 'adjectives.txt')) as f:\n adjectives = f.readlines()\n\nwith open(os.path.join...
python
chosen
[ { "from": "system", "value": "Convert custom properties before checking for serializability\n" }, { "from": "human", "value": "import json\n\n\ndef _is_serializable(value):\n try:\n json.dumps(value)\n return True\n except TypeError:\n return False\n\n\n_IGNORED_CUSTOM...
python
chosen
[ { "from": "system", "value": "Make category an optional field for an entry.\n\nIncome entries should not have a category. So the field should\nbe made optional.\n" }, { "from": "human", "value": "from app import db\nfrom app.mod_auth.model import User\n\nclass Category(db.Document):\n # The n...
python
chosen
[ { "from": "system", "value": "Print progress from the indexing script\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n\nimport os, sys\nsys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib'))\n\nimport glob, json\nimport numpy as np\n\nimport task_usage\n\ndef main(data_...
python
chosen
[ { "from": "system", "value": "Add a method to generate random names for testing." }, { "from": "human", "value": "import os\n\nfrom unittest2 import TestCase\n\nfrom chef.api import ChefAPI\n\nTEST_ROOT = os.path.dirname(os.path.abspath(__file__))\n\ndef test_chef_api():\n return ChefAPI('htt...
python
chosen
[ { "from": "system", "value": "Use proper domain for AZURE_MEDIA_STORAGE_HOSTNAME\n\nWe can't access docs.dev.readthedocs.io from celery container because\nthat domain points to 127.0.0.1 and we don't have the storage in that\nIP. So, we need to override the AZURE_MEDIA_STORAGE_HOSTNAME in the\ncelery contai...
python
chosen
[ { "from": "system", "value": "Change version number to 0.2.1\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n#\n# Copyright © 2013 Spyder Project Contributors\n# Licensed under the terms of the MIT License\n# (see LICENSE.txt for details)\n\n__version__ = '0.2.1.dev0'\n\n# ==========...
python
chosen
[ { "from": "system", "value": "Add the `get` command to the CLI.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"Console script for nyucal.\n\nSee click documentation at http://click.pocoo.org/\n\"\"\"\n\nimport io\n\nimport click\n\nfrom nyucal import nyucal\nimport requests\...
python
chosen
[ { "from": "system", "value": "Update fri dump script to delete docs\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom __future__ import unicode_literals\nfrom couchexport.export import export_raw\nfrom custom.fri.models import FRIMessageBankMessage, FRIRandomizedMes...
python
chosen
[ { "from": "system", "value": "[AC-5010] Create List of Model Attribute API Calls That Require Snake Case\n\nThis commit creates a list of models that use attributes. Those calls have snake case in their model definition, and were breaking when converted back to camel case. This may not be the most efficie...
python
chosen
[ { "from": "system", "value": "Develop the Regex grammar slightly further\n" }, { "from": "human", "value": "#!/usr/bin/python3\n\nimport sys, os\nimport nltk\n\nif len(sys.argv) < 2:\n print(\"Please supply a filename.\")\n sys.exit(1)\n\nfilename = sys.argv[1]\n\nwith open(filename, 'r') ...
python
chosen
[ { "from": "system", "value": "Add constant for complaint documents\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom openprocurement.tender.core.adapters import TenderConfigurator\nfrom openprocurement.tender.openeu.models import Tender\nfrom openprocurement.tender.openua.constant...
python
chosen