conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Add js error position SUBSTITUTE\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport re\n\npre_patterns = [\n (\n r'(\\d{16}-[-\\w]*\\b)',\n r'REQUEST_ID_SUBSTITUTE',\n ),\n (\n # r'([\\dA-F]){8}-[\\dA-F]{4}-4[\\dA-F]{3}-...
python
chosen
[ { "from": "system", "value": "Add easy access to close and sync methods of nc files\n" }, { "from": "human", "value": "\"\"\"\neasync.py - easier access to netCDF4 files\n\n\"\"\"\n\nimport netCDF4 \n \nclass EasyGroup(object):\n def __repr__(self):\n return \"Eas...
python
chosen
[ { "from": "system", "value": "Add py solution for 554. Brick Wall\n\n554. Brick Wall: https://leetcode.com/problems/brick-wall/\n\nApproach2:\n O(n_brick): Count # of every length can formed by any row\n" }, { "from": "human", "value": "import heapq\nclass Solution(object):\n def leastBric...
python
chosen
[ { "from": "system", "value": "Bump release version in source\n" }, { "from": "human", "value": "# Copyright 2015-2016 Rackspace US, Inc.\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...
python
chosen
[ { "from": "system", "value": "Support byte-swapped dbhash (bsddb) files. Found by Ben Sayer.\n" }, { "from": "human", "value": "\"\"\"Guess which db package to use to open a db file.\"\"\"\n\nimport struct\n\ndef whichdb(filename):\n \"\"\"Guess which db package to use to open a db file.\n\n...
python
chosen
[ { "from": "system", "value": "Fix flake8 errors for build.\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom __future__ import print_function\n\nimport logging\n\nfrom kale import task\n\nlogger = logging.getLogger(__name__)\n\n\nclass FibonacciTask(task.Task):\n\n ...
python
chosen
[ { "from": "system", "value": "Use default host when not specified\n" }, { "from": "human", "value": "import sys\nimport argparse\n\nfrom elasticsearch import Elasticsearch\n\nfrom annotator.reindexer import Reindexer\n\ndescription = \"\"\"\nReindex an elasticsearch index.\n\nWARNING: Documents ...
python
chosen
[ { "from": "system", "value": "Make minor improvements for CI.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom graphql.type.directives import specified_directives as default_directives\n\nfrom .date import *\nfrom .list import *\nfrom .numbers import *\nfrom .string import *\n\na...
python
chosen
[ { "from": "system", "value": "Switch to OpsGenie API V2\n" }, { "from": "human", "value": "import requests\nimport json\n\nfrom amon.apps.notifications.models import notifications_model\n \ndef send_opsgenie_notification(message=None, auth=None):\n sent = False\n url = \"https://api...
python
chosen
[ { "from": "system", "value": "Fix simple typo: occured -> occurred\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport os\nimport sys\nfrom contextlib import contextmanager\n\nfrom click._compat import isatty\n\nWIN = sys.platform.startswith(\"win\")\nenv = os.environ\n\n\n@contex...
python
chosen
[ { "from": "system", "value": "Improve code in l10n_ro_vat_on_payment and l10n_ro_stock.\n" }, { "from": "human", "value": "# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n\n{\n \"name\": \"Romania - Partner Create by VAT\",\n \"category\": \"Localization\",\n \"sum...
python
chosen
[ { "from": "system", "value": "Make the log work when deploy Zaqar with uwsgi\n\nThe zaqar-wsgi runs under uwsgi by devstack can't\nprint any WARNING, DEBUG, ERROR or INFO log now.\n\nThis path add the log initialization for uwsgi boot.\n\nChange-Id: Ifcd6be908442275d2acbde2562e593b2ca87b277\nCloese-bug: #16...
python
chosen
[ { "from": "system", "value": "Make dictify similar in flow to listify\n" }, { "from": "human", "value": "def listify(obj):\n if not isinstance(obj, list):\n return [obj]\n return obj\n\n\ndef dictify(obj, key):\n if isinstance(obj, dict):\n return obj\n return {key: obj...
python
chosen
[ { "from": "system", "value": "Allow changing what object is returned from Command instances.\n" }, { "from": "human", "value": "\"\"\"\nCommands helpers.\n\"\"\"\nimport functools\n\nfrom curious.commands.command import Command\n\n\ndef command(*args, **kwargs):\n \"\"\"\n A decorator to m...
python
chosen
[ { "from": "system", "value": "LILY-1809: Fix tests generating invalid email addresses\n" }, { "from": "human", "value": "from factory.declarations import LazyAttribute\nfrom factory.django import DjangoModelFactory\nfrom factory.fuzzy import FuzzyChoice\nfrom faker.factory import Factory\n\nfrom...
python
chosen
[ { "from": "system", "value": "Remove broken telemetry policy check\n\nThe reference to telemetry policy is no longer needed as well\nas broken causing the admin dashboard to show up inappropriately.\n\nCloses-Bug: #1643009\nChange-Id: I07406f5d6c23b0fcc34df00a29b573ffc2c900e7\n" }, { "from": "human"...
python
chosen
[ { "from": "system", "value": "Adhocracy-service: Change API to get single external static page\n" }, { "from": "human", "value": "import requests\n\nfrom pylons import config\n\n\nclass RESTAPI(object):\n \"\"\"Helper to work with the adhocarcy_service rest api\n (adhocracy_kotti.mediac...
python
chosen
[ { "from": "system", "value": "Add Combined DataFrame by Merging Train/Test Sets\n\nBefore merging, a new column was assigned to both sets with discrete values ['Train'/'Test'] that correspond to the set an observation is inclusive of.\n" }, { "from": "human", "value": "# coding=utf-8\n\n# Import...
python
chosen
[ { "from": "system", "value": "Fix migrations after django-avatar drop\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\ndef migrate_avatar(apps, schema_editor):\n Avatar = apps.get_model(\"avata...
python
chosen
[ { "from": "system", "value": "Throw exception instead of returning false.\n" }, { "from": "human", "value": "from st2actions.runners.pythonrunner import Action\nfrom bs4 import BeautifulSoup\n\nclass ParseGithubRepos(Action):\n def run(self, content):\n try:\n soup = BeautifulSoup(conte...
python
chosen
[ { "from": "system", "value": "Make database connection error more descriptive\n" }, { "from": "human", "value": "# coding: utf-8\nimport time\n\nfrom django.core.management.base import BaseCommand, CommandError\nfrom django.db import connection\nfrom django.db.utils import OperationalError\n\n\n...
python
chosen
[ { "from": "system", "value": "Add file sorting in the example script\n" }, { "from": "human", "value": "#!/bin/python\n\n# installation:\n# pip install pytz pyuploadcare~=2.1.0\n\nimport pytz\nfrom datetime import timedelta, datetime\nimport time\nfrom pyuploadcare import conf\nfrom pyuploadcare...
python
chosen
[ { "from": "system", "value": "Use a proper international format for Ukrainian phone numbers\n\nThe third digit should always be '0'." }, { "from": "human", "value": "# coding=utf-8\nfrom __future__ import unicode_literals\nfrom .. import Provider as PhoneNumberProvider\n\n\nclass Provider(PhoneN...
python
chosen
[ { "from": "system", "value": "Fix missing post group defaults for Burkina Faso\n" }, { "from": "human", "value": "from candidates.static_data import (\n BaseMapItData, BasePartyData, BaseAreaPostData\n)\n\n\nclass MapItData(BaseMapItData):\n pass\n\n\nclass PartyData(BasePartyData):\n d...
python
chosen
[ { "from": "system", "value": "tests/basics: Add more tests for unwind jumps from within a try-finally.\n\nThese tests excercise cases that are fixed by the previous two commits.\n" }, { "from": "human", "value": "# Test various loop types, some may be implemented/optimized differently\nwhile Tru...
python
chosen
[ { "from": "system", "value": "Modify unit test framework to delete db during setup\n" }, { "from": "human", "value": "from scoring_engine.db import session, engine\nfrom scoring_engine.models.base import Base\nfrom scoring_engine.models.setting import Setting\n\n\nclass UnitTest(object):\n de...
python
chosen
[ { "from": "system", "value": "Implement rule filtering by phoneme.\n" }, { "from": "human", "value": "import random\n\nfrom collections import namedtuple\n\nRule = namedtuple('Rule', ['changes', 'environments'])\n\nsonorization = Rule({'p': 'b', 't': 'd', 'ʈ': 'ɖ', 'c':'ɟ', 'k': 'g', 'q': 'ɢ'},\...
python
chosen
[ { "from": "system", "value": "Enable debug logging for xmpppy\n" }, { "from": "human", "value": "#!/usr/bin/env python2.7\n# coding: utf-8\n\nimport inspect\nimport logging\nlogging.basicConfig()\nimport time\nimport uuid\n\nfrom comicsbot import ComicsBot\nfrom dokuwiki import DokuWiki\nfrom ro...
python
chosen
[ { "from": "system", "value": "Fix pkg resources declare namespace\n" }, { "from": "human", "value": "# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages\ntry:\n __import__('pkg_resources').declare_namespace(__name__)\nexcept ImportError:\n from pkgutil import extend...
python
chosen
[ { "from": "system", "value": "Add print statement to send invite command\n" }, { "from": "human", "value": "import datetime\n\nfrom django.core.mail.message import EmailMultiAlternatives\nfrom django.core.management.base import BaseCommand\nfrom django.template import Context\nfrom django.templa...
python
chosen
[ { "from": "system", "value": "Add test for sorting with category natural key\n" }, { "from": "human", "value": "# coding=utf-8\nfrom __future__ import absolute_import, unicode_literals\n\nfrom tracpro.test.cases import TracProTest\n\nfrom .. import utils\n\n\nclass TestExtractWords(TracProTest):...
python
chosen
[ { "from": "system", "value": "Allow injecting a lock, or arbitrary context managers into LockedMachine\n" }, { "from": "human", "value": "from ..core import Machine, Transition, Event\n\nfrom threading import RLock\nimport inspect\n\n\nclass LockedMethod:\n\n def __init__(self, lock, func):\n...
python
chosen
[ { "from": "system", "value": "Use app in app module\n" }, { "from": "human", "value": "from app.plugin import app\nfrom app.route import build_route\n\nif __name__ == '__main__':\n build_route(app)\n app.run()\n" }, { "from": "gpt", "value": "from app.app import app\nfrom app.r...
python
chosen
[ { "from": "system", "value": "Remove protected class access, add module docstrings.\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nimport unittest\nfrom flask import Flask\n\nfrom .. import config\n\napp = Flask('__config_test')\n\n\nclass GetFuncsTest(unittest.Test...
python
chosen
[ { "from": "system", "value": "Return a list for objects on pb widget" }, { "from": "human", "value": "import json\n\nfrom django import forms\n\nfrom .models import PublicBody\n\n\nclass PublicBodySelect(forms.Widget):\n input_type = \"text\"\n template_name = 'publicbody/_chooser.html'\n ...
python
chosen
[ { "from": "system", "value": "Add is_active to the list of keys to be dumped as json\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom random import SystemRandom\nfrom django.conf import settings\nimport string\n\n\n# Note: the code in th...
python
chosen
[ { "from": "system", "value": "Remove version number from Python shebang.\n\nOn special request from someone trying to purge python2.2 from code indexed\ninternally at Google.\n\n\ngit-svn-id: http://src.chromium.org/svn/trunk/src@7071 4ff67af0-8c30-449e-8e8b-ad334ec8d88c\n\nFormer-commit-id: 6b204b6013b516c...
python
chosen
[ { "from": "system", "value": "Move module level import to top of file\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n__author__ = 'Raphael Pierzina'\n__email__ = 'raphael@hackebrot.de'\n__version__ = '0.1.0'\n\nfrom .parser import parse_string\n\n__all__ = ['parse_string']\n" },...
python
chosen
[ { "from": "system", "value": "Add __float__ operator to TimeOnce\n" }, { "from": "human", "value": "import time\n\n\nclass TimeOnce:\n \"\"\"Time a sequence of code, allowing access to the time difference in seconds.\n\n Example without exception:\n\n elapsed = TimeOnce()\n w...
python
chosen
[ { "from": "system", "value": "Fix error with saving credentials in python 2.7\n\nThis fixes #102\n" }, { "from": "human", "value": "import getpass\nimport os\n\nfrom appdirs import user_cache_dir\n\nCONFIG_FILE_NAME = os.path.join(\n user_cache_dir(appname='spoppy'), '.creds'\n)\n\n\ndef get_...
python
chosen
[ { "from": "system", "value": "Put main bot setup code inside main function\n" }, { "from": "human", "value": "import argparse\n\nimport discord\nfrom discord.ext import commands\n\nimport config\nfrom cmd import general, emotes\n\n\n_DESCRIPTION = '''quack'''\n\n\ndef parse_arguments():\n par...
python
chosen
[ { "from": "system", "value": "Add row between third party library and standard library import\n" }, { "from": "human", "value": "import re\nimport unidecode\n\nfrom datetime import datetime\nfrom flask.ext.wtf import regexp\n\nis_name = regexp(\n # not using \\w since it allows for unlimited ...
python
chosen
[ { "from": "system", "value": "Change to user select widget\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom baseframe import __\nimport baseframe.forms as forms\nfrom baseframe.forms.sqlalchemy import AvailableName\n\n__all__ = ['UserGroupForm']\n\n\nclass UserGroupForm(forms.F...
python
chosen
[ { "from": "system", "value": "Update for changes in alchemist.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals, absolute_import, division\nfrom armet.connectors.flask import resources as flask_resources\nfrom armet.connectors.sqlalchemy import ...
python
chosen
[ { "from": "system", "value": "judge: Print running task, language and checker as INFO\n" }, { "from": "human", "value": "import asyncio\nimport logging\n\nlogger = logging.getLogger(__name__)\n\nclass TaskRunner:\n def __init__(self, sandbox_pool, languages, checkers):\n self.sandbox_p...
python
chosen
[ { "from": "system", "value": "Add optional callbacks for call buffer\n" }, { "from": "human", "value": "from constants import *\nimport collections\nimport uuid\n\nclass CallBuffer():\n def __init__(self):\n self.waiters = set()\n self.cache = collections.deque(maxlen=CALL_CACHE...
python
chosen
[ { "from": "system", "value": "Update benchmarks to Pyton 3.\n" }, { "from": "human", "value": "import re\nimport urllib\nimport random\nimport unittest\nfrom funkload.FunkLoadTestCase import FunkLoadTestCase\n\n\nclass Benchmark(FunkLoadTestCase):\n \"\"\"This test uses a configuration file B...
python
chosen
[ { "from": "system", "value": "Add filename to square masks\n" }, { "from": "human", "value": "from PIL import Image\nimport glob\n\n\ndef _get_masks():\n TRAIN_MASKS = './data/train/*_mask.tif'\n return [Image.open(file_name) for file_name in glob.glob(TRAIN_MASKS)]\n\n\ndef _get_rectangle...
python
chosen
[ { "from": "system", "value": "Allow trailing slash in URL\n" }, { "from": "human", "value": "import importlib\n\nfrom flask import render_template\nfrom werkzeug.exceptions import NotFound\n\nfrom . import main\n\n\nDATA_QUALITY_ROUTE = '/data-quality/'\n\n\n@main.route('/')\ndef index():\n r...
python
chosen
[ { "from": "system", "value": "Change distribution script to support python 3.5\n" }, { "from": "human", "value": "import subprocess\n\n\ndef load_configuration(environment):\n configuration = {\n \"project\": \"nimp\",\n \"project_version\": { \"identifier\": \"0.9.6\" },\n ...
python
chosen
[ { "from": "system", "value": "Add newline in docstring to separate summary.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n headlines \n ~~~~~~~~~\n\n A Flask powered news aggregation web app.\n :copyright: (c) 2017, John Alcher\n :license: MIT, see LICENSE fo...
python
chosen
[ { "from": "system", "value": "Fix bug that appears when a reference file model is created from scratch\nwhere the dq_def member exists, but has no rows.\n\n\n\ngit-svn-id: 7ab1303e5df1b63f74144546e35d3203cc1d26c5@3127 560b4ebf-6bc0-4cc5-b8e0-b136f69d22d4\n" }, { "from": "human", "value": "import...
python
chosen
[ { "from": "system", "value": "Fix `TypeError: 'bool' object is not callable`\n\n…when attempting to download an export\n" }, { "from": "human", "value": "# coding: utf-8\nfrom rest_framework.request import Request as DRFRequest\nfrom rest_framework.settings import api_settings\n\n\ndef superuser...
python
chosen
[ { "from": "system", "value": "Change Skia master ports again\n\nBUG=393690\n\nReview URL: https://codereview.chromium.org/390903004\n\ngit-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@283235 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": "human", "value": "# Copyright 2013 The Chromium...
python
chosen
[ { "from": "system", "value": "Add absolute imports in init\n" }, { "from": "human", "value": "from point import Point # noqa\nfrom generator import Generator # noqa\nfrom arraygenerator import ArrayGenerator # noqa\nfrom compoundgenerator import CompoundGenerator # noqa\nfrom linegenerator i...
python
chosen
[ { "from": "system", "value": "Add support for Markdown extensions via plugin settings." }, { "from": "human", "value": "from .txt import TextPlugin\n\n\nclass MarkdownPlugin(TextPlugin):\n\n ext = 'md'\n\n def render(self, data):\n # TODO: Handle markdown import error\n impor...
python
chosen
[ { "from": "system", "value": "feature/oop-api-refactoring: Fix and cast path to `str`\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom pathlib import Path\n\nimport logging\nfrom logging.config import fileConfig\n\n\nclass Logger:\n\n loggers = {}\n\n @staticmethod\n d...
python
chosen
[ { "from": "system", "value": "Add line to spike prob\n" }, { "from": "human", "value": "### Spike Probability\n\nSpikeDB.plotClear()\nfiles = SpikeDB.getFiles(True)\nfor f in files:\n\tmeans = []\n\terr = []\n\tx = []\n\traw = []\n\tfor t in f['trials']:\n\t\tcount = []\n\t\tx.append(t['xvalue']...
python
chosen
[ { "from": "system", "value": "Fix encoding (thanks to Yasushi Masuda)\n\n\ngit-svn-id: 305ad3fa995f01f9ce4b4f46c2a806ba00a97020@433 3777fadb-0f44-0410-9e7f-9d8fa6171d72\n" }, { "from": "human", "value": "#$HeadURL$\r\n#$LastChangedDate$\r\n#$LastChangedRevision$\r\nimport sys\r\nfrom reportlab.p...
python
chosen
[ { "from": "system", "value": "Add new exception class for ssh tunnel logic\n" }, { "from": "human", "value": "class PanoplyException(Exception):\n def __init__(self, args=None, retryable=True):\n super(PanoplyException, self).__init__(args)\n self.retryable = retryable\n" }, ...
python
chosen
[ { "from": "system", "value": "Make sure that the reslicer does not ommit any image data.\n" }, { "from": "human", "value": "\"\"\"\nDataTransformer\n\n:Authors:\n\tBerend Klein Haneveld\n\"\"\"\n\nfrom vtk import vtkImageReslice\n\n\nclass DataTransformer(object):\n\t\"\"\"DataTransformer is a c...
python
chosen
[ { "from": "system", "value": "Update patrol launcher to recent changes\n" }, { "from": "human", "value": "#!/usr/bin/python\n\"\"\"\nCyril Robin -- LAAS-CNRS -- 2014\n\nTODO Descriptif\n\"\"\"\n\nfrom mission import *\nfrom constant import *\n\nfrom sys import argv, exit\nfrom timer import Timer...
python
chosen
[ { "from": "system", "value": "Use nifty filter widget for selecting questions for an assignment.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.contrib import admin\nfrom django.utils.translation import ugettext_lazy as _\nfrom ...
python
chosen
[ { "from": "system", "value": "Make config-helper decorator more generic\n\nInstead of only pulling 'coinrpc.svc' from app.config, pull out any\nnumber of items.\n" }, { "from": "human", "value": "import bottle, jsonrpc, sys\n\ndef with_rpc(orig_func):\n '''Function decorator to provide RPC se...
python
chosen
[ { "from": "system", "value": "Remove GET options in url\n" }, { "from": "human", "value": "from flask import Flask\nfrom flask import request\nfrom flask import jsonify\n\nfrom y_text_recommender_system.recommender import recommend\n\napp = Flask(__name__)\n\n\nclass InvalidUsage(Exception):\n ...
python
chosen
[ { "from": "system", "value": "Update community to use new lib namespace\n" }, { "from": "human", "value": "import sys\n\nfrom core import Tokenizer\nfrom utilities import url_to_json\n\n\ndef run(project_id, repo_path, cursor, **options):\n t_sub = options.get('sub')\n t_star = options.get...
python
chosen
[ { "from": "system", "value": "Use : for loading classes in entry_points\n" }, { "from": "human", "value": "\n# Copyright 2013 Red Hat, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may ob...
python
chosen
[ { "from": "system", "value": "Fix the importlib_only test decorator to work again; don't capture the flag variable as it might change later.\n" }, { "from": "human", "value": "import functools\nimport importlib\nimport importlib._bootstrap\nimport unittest\n\n\nusing___import__ = False\n\n\ndef ...
python
chosen
[ { "from": "system", "value": "Mark test_type_inference test as expected failure" }, { "from": "human", "value": "from __future__ import print_function\nfrom numba import vectorize, jit, bool_, double, int_, float_, typeof, int8\nimport numba.unittest_support as unittest\nimport numpy as np\n\n\n...
python
chosen
[ { "from": "system", "value": "FIX coreg bin: add parser" }, { "from": "human", "value": "#!/usr/bin/env python\n# Authors: Christian Brodbeck <christianbrodbeck@nyu.edu>\n\n\"\"\" Open the coregistration GUI.\n\nexample usage: $ mne coreg\n\n\"\"\"\n\nimport os\nimport sys\n\nimport mne\n\n\ni...
python
chosen
[ { "from": "system", "value": "Fix argument name in TestCase constructor\n\n" }, { "from": "human", "value": "\"\"\"\nModule with the TestCase model.\n\"\"\"\n\nfrom launch_control.utils.json.pod import PlainOldData\n\n\nclass TestCase(PlainOldData):\n \"\"\"\n TestCase model.\n\n Curren...
python
chosen
[ { "from": "system", "value": "Fix implementation of overlapping rectangles\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom collections import namedtuple\n\nSize = namedtuple(\"Size\", [\"width\", \"height\"])\n\nclass Rectangle(namedtuple(\"Rectangle\", [\"x0\", \"y0\", \"x1\", ...
python
chosen
[ { "from": "system", "value": "Fix data migration for user display names\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\ndef populate_usernames(apps, schema_editor):\n User = apps.get_model('ma...
python
chosen
[ { "from": "system", "value": "Ch23: Add Profile name to UserAdmin list.\n" }, { "from": "human", "value": "from django.contrib import admin\n\nfrom .models import User\n\n\n@admin.register(User)\nclass UserAdmin(admin.ModelAdmin):\n # list view\n list_display = (\n 'email',\n ...
python
chosen
[ { "from": "system", "value": "Make 'schema' value readonly after creation.\nInject SchemaUser into UserAdmin inlines.\n" }, { "from": "human", "value": "from django.contrib import admin\nfrom models import Schema\n\nclass SchemaAdmin(admin.ModelAdmin):\n pass\n\nadmin.site.register(Schema, Sc...
python
chosen
[ { "from": "system", "value": "Make to_unicode work in Python 3\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n# The following two variables and the is_unicode function are there to bridge string types across Python 2 & 3\nunicode_type = u\"\".__class__\nbasestring_type = (b\"\".__...
python
chosen
[ { "from": "system", "value": "Remove log chown step from post-deployment process.\n" }, { "from": "human", "value": "import os\n\nfrom fabric.api import task, run, local, sudo, cd, env\n\n\nenv.hosts = [\n os.environ['TWWEB_HOST'],\n]\n\n\ndef virtualenv(command, user=None):\n run('source ...
python
chosen
[ { "from": "system", "value": "Switch TextInput for Textarea for RichText widget base class\n" }, { "from": "human", "value": "##\n# Copyright (C) 2017 Jessica Tallon & Matt Molyneaux\n#\n# This file is part of Inboxen.\n#\n# Inboxen is free software: you can redistribute it and/or modif...
python
chosen
[ { "from": "system", "value": "MAINT: Update to changed zeit.cms test browser setup API\n" }, { "from": "human", "value": "import mock\nimport zeit.brightcove.convert\nimport zeit.brightcove.testing\nimport zeit.cms.testing\nimport zope.testbrowser.testing\n\n\nclass NotificationTest(zeit.cms.tes...
python
chosen
[ { "from": "system", "value": "Fix escape sequence formatting linter errors\n" }, { "from": "human", "value": "import pytest\nfrom girder.utility import path\n\n\n@pytest.mark.parametrize('raw,encoded', [\n ('abcd', 'abcd'),\n ('/', '\\/'),\n ('\\\\', '\\\\\\\\'),\n ('/\\\\', '\\/\\\\...
python
chosen
[ { "from": "system", "value": "Remove infobox, can be re-added if necessary\n" }, { "from": "human", "value": "from django.core.urlresolvers import reverse\nfrom bs4 import BeautifulSoup\n\ndef process_wiki_page_html(html):\n \"\"\"Process the html of a wikipedia page to be used in ReadMore.\"...
python
chosen
[ { "from": "human", "value": "Add tests of pandas backend\n" }, { "from": "gpt", "value": "# Licensed under a 3-clause BSD style license - see LICENSE.rst\n\nfrom io import StringIO\n\nimport pytest\nimport numpy as np\n\nfrom astropy.io import ascii\nfrom astropy.table import Table, QTable\nfrom...
python
chosen
[ { "from": "system", "value": "Add remote commands for vagrant and ec2\n" }, { "from": "human", "value": "# Simple Tasks\n\ndef hello():\n print 'Hello ThaiPy!'\n\n\ndef hi(name='Kan'):\n print 'Hi ' + name\n\n\n# Local Commands\n\nfrom fabric.api import local, lcd\n\n\ndef deploy_fizzbuzz(...
python
chosen
[ { "from": "system", "value": "Add quotes to values htmlified\n\n" }, { "from": "human", "value": "def getHTML(tag, contents=None, newLine=True, **parameters):\n\tconstruct = \"<\" + tag\n\tfor paramName, paramContent in parameters.items():\n\t\tconstruct += \" \" + paramName + \"=\" + paramConte...
python
chosen
[ { "from": "system", "value": "Add file to create all files to higher education.\n" }, { "from": "human", "value": "import os\nimport commands\nimport time\nimport logging\nimport sys\n\nif len(sys.argv) != 3 or (sys.argv[1:][0] not in ['pt', 'en']):\n print \"ERROR! Use:\\n python scripts/dat...
python
chosen
[ { "from": "system", "value": "Replace / with - in image domain names\n" }, { "from": "human", "value": "from dock import client\r\n\r\n\r\ndef fmt(container):\r\n image, name = ns(container)\r\n return '[{image}/{name}]'.format(image=image, name=name)\r\n\r\n\r\ndef ns(container):\r\n i...
python
chosen
[ { "from": "system", "value": "Remove self argument from _get_card_from_zone\n" }, { "from": "human", "value": "\"\"\" Utility functions for GTR.\n\"\"\"\n\ndef _get_card_from_zone(self, card, l):\n \"\"\" Wrapper around the possible exception caused by trying to \n find a non-existent card in ...
python
chosen
[ { "from": "system", "value": "Check that each module is valid before trying to import.\n" }, { "from": "human", "value": "\"\"\"Database Toolkit\n\nThis package contains a framework for creating and running scripts designed to\ndownload published ecological data, and store the data in a database...
python
chosen
[ { "from": "system", "value": "fix: Use better help for --elb-subnet\n\nSee also: PSOBAT-1359\n" }, { "from": "human", "value": "\"\"\"Create DNS record.\"\"\"\nimport argparse\nimport logging\n\nfrom ..args import add_debug\nfrom ..consts import LOGGING_FORMAT\nfrom .create_dns import SpinnakerD...
python
chosen
[ { "from": "system", "value": "Define the pushkey attribute for XMPP push\n\ngit-svn-id: b8a2ed21f1aafe1ee9fc65e616c668cc51cd004a@7731 e27351fd-9f3e-4f54-a53b-843176b1656c\n" }, { "from": "human", "value": "##\n# Copyright (c) 2007-2009 Apple Inc. All rights reserved.\n#\n# Licensed under the Apa...
python
chosen
[ { "from": "system", "value": "Make sure sys is available for sys.exit() call on failure\n" }, { "from": "human", "value": "from __future__ import print_function\n\nimport subprocess\n\ndef get_version_from_git():\n cmd = [\"git\", \"describe\", \"--tags\", \"--always\"]\n\n proc = subproce...
python
chosen
[ { "from": "system", "value": "Fix str index of range in some case\n" }, { "from": "human", "value": "import PyICU\n\nSEPARATER = \" \"\nclass Segmenter:\n\n def isThai(self, chr):\n cVal = ord(chr)\n if (cVal >= 3584 and cVal <= 3711):\n return True\n return Fa...
python
chosen
[ { "from": "system", "value": "Fix additional fullstop on accepted upload formatter\n\nSigned-off-by: Chris Lamb <711c73f64afdce07b7e38039a96d2224209e9a6c@chris-lamb.co.uk>\n" }, { "from": "human", "value": "\nfrom DebianChangesBot import Formatter\nfrom DebianChangesBot.datasources import NewQue...
python
chosen
[ { "from": "system", "value": "Add more datagen test cases.\n" }, { "from": "human", "value": "\nfrom unittest import TestCase\nfrom unittest.mock import patch\n\nfrom openrcv.datagen import gen_random_list\n\n\nclass ModuleTest(TestCase):\n\n def make_randint(self, values):\n values = ...
python
chosen
[ { "from": "system", "value": "Add student name and grade\n" }, { "from": "human", "value": "# File: grade_school.py\n# Purpose: Write a small archiving program that stores students' names along with the grade that they are in.\n# Programmer: Amal Shehu\n# Course: Exercism\n# Da...
python
chosen
[ { "from": "system", "value": "Update HistoryIndeView - listdir is working.\n" }, { "from": "human", "value": "from .view import View\n\nfrom errno import ENOENT\nfrom stat import S_IFDIR\n\nfrom gitfs import FuseMethodNotImplemented, FuseOSError\nfrom log import log\n\n\nclass HistoryIndexView(...
python
chosen
[ { "from": "system", "value": "Add test that db.insert is called when add is called\n" }, { "from": "human", "value": "from unittest import TestCase\nfrom lib import web\nfrom mock import Mock\n\nimport main\nimport framework.file_server as file_server\n\nclass BaseFileServerTests (TestCase):\n\n...
python
chosen
[ { "from": "system", "value": "Use i_latest_revision to ensure we get the latest revision.\n" }, { "from": "human", "value": "\"\"\"Name output plugin\n\n\"\"\"\n\nimport optparse\n\nfrom pyang import plugin\n\ndef pyang_plugin_init():\n plugin.register_plugin(NamePlugin())\n\nclass NamePlugin...
python
chosen
[ { "from": "system", "value": "Tweak WSGI module to use docker settings\n" }, { "from": "human", "value": "\"\"\"\nWSGI config for gamecraft project.\n\nIt exposes the WSGI callable as a module-level variable named ``application``.\n\nFor more information on this file, see\nhttps://docs.djangopro...
python
chosen
[ { "from": "system", "value": "Test ignoring duplicates and order\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport os\nimport unittest\n\nimport speech_recognition as sr\n\n\nclass TestSpecialFeatures(unittest.TestCase):\n def setUp(self):\n s...
python
chosen