conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Use raw string notation for regular expression.\n" }, { "from": "human", "value": "from django.contrib.admin.views.decorators import staff_member_required\nfrom django.urls import re_path\nfrom flatblocks.views import edit\n\nurlpatterns = [\n re_path(\"^edit/(?P...
python
chosen
[ { "from": "system", "value": "Enable library paths to be explicitly specified.\n\nAll shared libraries loaded through the load_library function\ncan bow be specified explicitly through a suitable environmental\nvariable\n\n PYFR_<LIB>_LIBRARY_PATH=/path/to/lib.here\n\nwhere <LIB> corresponds to the name of...
python
chosen
[ { "from": "system", "value": "Improve unicode method. Whitespace cleanup\n" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.auth.models import User\nfrom tagging.fields import TagField\nimport tagging\n# OCR model, erm, model\n\n\nclass OcrModel(models.Model):\...
python
chosen
[ { "from": "system", "value": "Add some detail text to assertion.\n" }, { "from": "human", "value": "import argparse\nimport logging\n\nfrom . import init_logging\n\n\nclass BaseCLI(object):\n\n def __init__(self, description, epilog, version=None):\n assert version\n self.versio...
python
chosen
[ { "from": "system", "value": "Fix evaluation date & test period\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom nose.tools import assert_equal\n\nfrom openfisca_france.model.prelevements_obligatoires.prelevements_sociaux.cotisations_sociales.allegements import *\nfrom openfisc...
python
chosen
[ { "from": "system", "value": "Allow case-insensitive email addresses when doing authentication\n\n(imported from commit b52e39c7f706a2107b5d86e8e18293a46ed9e6ff)\n" }, { "from": "human", "value": "from django.contrib.auth.models import User\n\nclass EmailAuthBackend(object):\n \"\"\"\n Ema...
python
chosen
[ { "from": "system", "value": "Order devices by manufacturer and model.\n" }, { "from": "human", "value": "from django.db import models\n\n\nclass Device(models.Model):\n \"\"\"Model for FfxOS devices data.\"\"\"\n\n model = models.CharField(max_length=120)\n manufacturer = models.CharFi...
python
chosen
[ { "from": "system", "value": "Raise TestSkipped, not ImportError.\nHonesty's the best policy.\n" }, { "from": "human", "value": "from test_support import verbose, findfile, TestFailed\nimport linuxaudiodev\nimport errno\nimport os\n\ndef play_sound_file(path):\n fp = open(path, 'r')\n data...
python
chosen
[ { "from": "system", "value": "Add index on file tags field\n" }, { "from": "human", "value": "# Indices that need to be added manually:\n#\n# invoke shell --no-transaction\n\nfrom pymongo import ASCENDING, DESCENDING\n\n\ndb['user'].create_index([\n ('emails', ASCENDING),\n])\n\ndb['user'].cr...
python
chosen
[ { "from": "system", "value": "Switch to generating REST end points from docker image\n" }, { "from": "human", "value": "import os\n\nfrom girder.utility.webroot import Webroot\n\nfrom .rest_slicer_cli import(\n genRESTEndPointsForSlicerCLIsInSubDirs,\n genRESTEndPointsForSlicerCLIsInDocker...
python
chosen
[ { "from": "system", "value": "Remove unnecessary __init__ from functionaltests\n\nThe __init__ just passes the same arguments, so it is not necessary\nto implement it. This patch removes it for the cleanup.\n\nChange-Id: Ib465356c47d06bfc66bef69126b089be24d19474\n" }, { "from": "human", "value":...
python
chosen
[ { "from": "system", "value": "Rewrite Flickr to use the new scope selection system\n" }, { "from": "human", "value": "import foauth.providers\n\n\nclass Flickr(foauth.providers.OAuth1):\n # General info about the provider\n provider_url = 'http://www.flickr.com/'\n docs_url = 'http://ww...
python
chosen
[ { "from": "system", "value": "Fix test runner to accept 1 arg\n" }, { "from": "human", "value": "#!/usr/bin/python\nimport optparse\nimport sys\n# Install the Python unittest2 package before you run this script.\nimport unittest2\n\nUSAGE = \"\"\"%prog SDK_PATH\nRun unit tests for App Engine app...
python
chosen
[ { "from": "system", "value": "Update the 503 error message.\n" }, { "from": "human", "value": "import httpx\n\nfrom linguee_api.downloaders.interfaces import DownloaderError, IDownloader\n\n\nclass HTTPXDownloader(IDownloader):\n \"\"\"\n Real downloader.\n\n Sends request to linguee.co...
python
chosen
[ { "from": "system", "value": "Read Neo4j config from ENV if present\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom django.apps import AppConfig\nfrom django.conf import settings\nfrom django.db.models.signals import m2m_changed, post_migrate, post_save, pre_delete\n\nfrom neo...
python
chosen
[ { "from": "system", "value": "Add “Start Minecraft” menu item\n\nFrom https://github.com/matryer/bitbar-plugins/blob/master/Games/minecraftplayers.1m.py\n" }, { "from": "human", "value": "#!/usr/local/bin/python3\n\nimport requests\n\npeople = requests.get('https://api.wurstmineberg.de/v2/people...
python
chosen
[ { "from": "system", "value": "Update to latest version of ODM: Join queries with `&`, not `,`\n" }, { "from": "human", "value": "from website.app import init_app\nfrom website.models import Node, User\nfrom framework import Q\nfrom framework.analytics import piwik\n\napp = init_app(\"website.set...
python
chosen
[ { "from": "system", "value": "Increment minor version for new feature release.\n" }, { "from": "human", "value": "__version__ = '1.5.2'\n__author__ = 'Cameron Higby-Naquin'\n" }, { "from": "gpt", "value": "__version__ = '1.6.0'\n__author__ = 'Cameron Higby-Naquin'\n" } ]
python
chosen
[ { "from": "system", "value": "Clear the SERVER_RESTART_REQUIRED flag automatically when the server reloads\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom django.apps import AppConfig\n\n\nclass CommonConfig(AppConfig):\n name = 'common'\n\n def ready(self):\n pas...
python
chosen
[ { "from": "system", "value": "Convert everything to unicode strings before inserting to DB" }, { "from": "human", "value": "#-*- coding: utf-8 -*-\nfrom email.MIMEBase import MIMEBase\nfrom django.core.mail.backends.base import BaseEmailBackend\nfrom database_email_backend.models import Email, A...
python
chosen
[ { "from": "system", "value": "Remove comment from previous migration\n\nThe migration was using a comment from the first one.\n\nChange-Id: I25dc9ca79f30f156bfc4296c44e141991119635e\n" }, { "from": "human", "value": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# ...
python
chosen
[ { "from": "system", "value": "Allow refresh materialized view in DEMO_MODE.\n" }, { "from": "human", "value": "\"\"\"\nSettings for DEMO_MODE.\n\nMust set DEMO_MODE = True in local_settings.py.\n\"\"\"\n\n# Views that are visible in demo mode.\nDEMO_SAFE_VIEWS = [\n 'main.views.home_view',\n ...
python
chosen
[ { "from": "system", "value": "Make sure that the admin widget also supports Django 2\n" }, { "from": "human", "value": "from django.forms.widgets import Input, ClearableFileInput\nfrom django.template.loader import render_to_string\n\n\nclass CIImgWidget(ClearableFileInput):\n\n def render(se...
python
chosen
[ { "from": "system", "value": "Refactor error data extraction from JSON\n" }, { "from": "human", "value": "class PardotAPIError(Exception):\n \"\"\"\n Basic exception class for errors encountered in API post and get requests. Takes the json response and parses out\n the error code and me...
python
chosen
[ { "from": "system", "value": "Add a template tag to get the latest news posts.\n" }, { "from": "human", "value": "from django import template\nfrom blanc_basic_news.news.models import Category, Post\n\nregister = template.Library()\n\n\n@register.assignment_tag\ndef get_news_categories():\n r...
python
chosen
[ { "from": "system", "value": "Remove obsolete pk_key in test\n" }, { "from": "human", "value": "from datetime import timedelta\n\nimport pytest\nfrom rest_framework_json_api.serializers import DurationField, IntegerField\n\nfrom timed.serializers import DictObjectSerializer\n\n\nclass MyPkDictSe...
python
chosen
[ { "from": "system", "value": "Set 'no_role' if role is not given\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\n\nfrom serf_master import SerfHandlerProxy\nfrom base_handler import BaseHandler\ntry:\n from my_handler import MyHandler\nexcept ImportError:\n print \"Cou...
python
chosen
[ { "from": "system", "value": "Remove artefact from earlier left mouse button selection\n\nYou used to be able to select with the left mouse button and then right click.\nYou can't now.\n" }, { "from": "human", "value": "import sublime, sublime_plugin\nimport os\nfrom .Mouse import MouseCommand\n...
python
chosen
[ { "from": "system", "value": "Set created time with default callback\n\nauto_now is evil, as any editing and overriding is\nalmost completely impossible (e.g. unittesting)\n" }, { "from": "human", "value": "from django.contrib.auth.models import User\nfrom django.db import models\nfrom django.db...
python
chosen
[ { "from": "system", "value": "Allow to override the top-level slug.\n" }, { "from": "human", "value": "from shutil import copytree, rmtree\n\nfrom foliant.utils import spinner\nfrom foliant.backends.base import BaseBackend\n\n\nclass Backend(BaseBackend):\n '''Backend that just applies its pr...
python
chosen
[ { "from": "system", "value": "Clean up input and output." }, { "from": "human", "value": "#!/usr/bin/python\nimport os\nimport sys\nimport json\nimport getpass\nimport tempfile\nimport subprocess\nimport aesjsonfile\n\ndef editfile(fn, password):\n db = aesjsonfile.load(fn, password)\n f =...
python
chosen
[ { "from": "system", "value": "Fix mock import for Python 3\n" }, { "from": "human", "value": "\"\"\"Tests for github_webhook.webhook\"\"\"\n\nfrom __future__ import print_function\n\nimport unittest\nfrom mock import Mock\n\nfrom github_webhook.webhook import Webhook\n\n\nclass TestWebhook(unitt...
python
chosen
[ { "from": "system", "value": "Add log statement if REST API can't be accessed\n" }, { "from": "human", "value": "import requests\nimport json\nfrom subprocess import Popen, PIPE\nimport tempfile\nimport os\n\nconfig = {}\nwith open ('../config/conversion.json') as fp:\n config = json.load(fp)\n...
python
chosen
[ { "from": "system", "value": "Make hangout rename itself after setchatname is called\n" }, { "from": "human", "value": "\"\"\"Allows the user to configure the bot to watch for hangout renames\nand change the name back to a default name accordingly\"\"\"\n\ndef setchatname(bot, event, *args):\n ...
python
chosen
[ { "from": "system", "value": "[client] Use only msecs of dacapo output.\n\nSigned-off-by: Michael Markert <5eb998b7ac86da375651a4cd767b88c9dad25896@googlemail.com>\n" }, { "from": "human", "value": "import re\n\nBENCHMARKS = set(( 'avrora'\n , 'batik'\n , 'ecl...
python
chosen
[ { "from": "system", "value": "Add caching to HGNC client\n" }, { "from": "human", "value": "import urllib2\nimport xml.etree.ElementTree as et\n\nhgnc_url = 'http://rest.genenames.org/fetch/'\n\ndef get_hgnc_name(hgnc_id):\n xml_tree = get_hgnc_entry(hgnc_id)\n if xml_tree is None:\n ...
python
chosen
[ { "from": "system", "value": "Set Access-Control-Allow-Credentials for all responses\n\nIn order to inform the browser to set the Cookie header on requests, this\nheader must be set otherwise the session is reset on every request.\n" }, { "from": "human", "value": "from warnings import warn\nfro...
python
chosen
[ { "from": "system", "value": "Fix linter complaint and append rather than cat lists.\n" }, { "from": "human", "value": "import django.contrib.auth.views as auth_views\nfrom django.conf import settings\nfrom django.conf.urls import include, url\nfrom django.conf.urls.static import static\nfrom dj...
python
chosen
[ { "from": "system", "value": "Remove unique_together on the model; the key length was too long on wide-character MySQL installs.\n" }, { "from": "human", "value": "from django.db import models\n\nclass MigrationHistory(models.Model):\n app_name = models.CharField(max_length=255)\n migratio...
python
chosen
[ { "from": "system", "value": "Change the superclass for admin DataList widget\n\nThis adds an additional class so it displays the same as other\ntext fields in the admin interface.\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nfrom itertools import chain\n\nfrom d...
python
chosen
[ { "from": "system", "value": "Change units on graph y-axis\n" }, { "from": "human", "value": "import graphs\nimport star\n\n\ndef main():\n \"\"\"\n Plots graph of black body emission wavelengths against amplitudes, then UBVR magnitudes of a star.\n \"\"\"\n graph = graphs.FunctionsG...
python
chosen
[ { "from": "system", "value": "Reconfigure SiteConfigFactory to use JPG - removes pillow's libjpeg-dev dependency\n" }, { "from": "human", "value": "import factory\n\nfrom django.contrib.sites.models import Site\n\nfrom connect.config.models import SiteConfig\n\n\nclass SiteFactory(factory.django...
python
chosen
[ { "from": "system", "value": "Define simulation time for linear and circular trajectories\n\n" }, { "from": "human", "value": "#!/usr/bin/env python\nSIMULATION_TIME_IN_SECONDS = 40\nDELTA_T = 0.1 # this is the sampling time\nSTEPS = int(SIMULATION_TIME_IN_SECONDS / DELTA_T)\nK_V = 0.90\nK_W = 0...
python
chosen
[ { "from": "system", "value": "cm: Make invoke tasks work with the new version of invoke.\n" }, { "from": "human", "value": "from invoke import task, run\n\n\n@task\ndef makerelease(version, local_only=False):\n if not version:\n raise Exception(\"You must specify a version!\")\n\n #...
python
chosen
[ { "from": "system", "value": "Fix the reading files test.\n" }, { "from": "human", "value": "from os import path\nfrom indra.tools.reading.read_files import read_files, get_readers\n\nfrom nose.plugins.attrib import attr\n\n\n@attr('slow', 'nonpublic')\ndef test_read_files():\n \"Test that th...
python
chosen
[ { "from": "system", "value": "Remove TODO -- handlers have been cleaned up.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n#\n# Copyright 2010 Hunter Freyer and Michael Kelly\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in...
python
chosen
[ { "from": "system", "value": "Add `__str__` method to support Python 3\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom cms.models import CMSPlugin\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass Plaintext(CMSPlugin):\n body = ...
python
chosen
[ { "from": "system", "value": "[doc] Add autodoc for msm user-API\n" }, { "from": "human", "value": "r\"\"\"\n\n============================================\nmsm - Markov state models (:mod:`pyemma.msm`)\n============================================\n\n.. currentmodule:: pyemma.msm\n\nUser-API\n-...
python
chosen
[ { "from": "system", "value": "Use only absolute imports for python 3\n" }, { "from": "human", "value": "\"\"\"This package contains interface adapters for pandas.\n\nOn import, this package detects if pandas is installed. If it is installed,\nthen the contained modules are imported to register ...
python
chosen
[ { "from": "system", "value": "Access envvars using standard dictionary access isntead of get method to ensure missing vars cause an exception to be raised\n" }, { "from": "human", "value": "import os\n\nfrom dotenv import load_dotenv, find_dotenv\n\nload_dotenv(find_dotenv())\n\nOPS_KEY = os.env...
python
chosen
[ { "from": "system", "value": "Handle adding and removing relations from Roles.\n\nThis adds addRelation and removeRelation capabilities to Role, making it possible to add users to the users column and roles to the roles column in a Role object, for example. This prevents the error of Role not having the att...
python
chosen
[ { "from": "system", "value": "Fix typo retrieving vendor prefix\n\nProperly get the OSCAR_SAGEPAY_TX_CODE_PREFIX from the project settings\n" }, { "from": "human", "value": "from django.conf import settings\n\n\nVPS_PROTOCOL = getattr(settings, 'OSCAR_SAGEPAY_VPS_PROTOCOL', '3.0')\nVENDOR = sett...
python
chosen
[ { "from": "human", "value": "Update project version and other metadata from previous\n" }, { "from": "gpt", "value": "# Project Version and Author Information\n__author__ = \"EUL Systems\"\n__copyright__ = \"Copyright 2010, Emory University General Library\"\n__credits__ = [\"Rebecca Koeser\", \...
python
chosen
[ { "from": "system", "value": "Add a few functions to Socket class\n" }, { "from": "human", "value": "\nimport socket\n\n\nclass Socket:\n\n\tTCP = 0\n\tUDP = 1\n\n\tdef __init__(self, type):\n\t\tif type == self.TCP:\n\t\t\tself.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROT...
python
chosen
[ { "from": "system", "value": "Add district feed to match score notification\n" }, { "from": "human", "value": "from consts.notification_type import NotificationType\nfrom helpers.model_to_dict import ModelToDict\nfrom notifications.base_notification import BaseNotification\n\n\nclass MatchScoreN...
python
chosen
[ { "from": "system", "value": "Change from rpc to amqp backend\n\nOtherwise retrieving result are problematic\n" }, { "from": "human", "value": "from kombu import Exchange, Queue\nimport os\nBROKER_URL = os.environ['CELERY_BROKER']\nCELERY_RESULT_BACKEND='rpc://'\nCELERY_RESULT_PERSISTENT = True\...
python
chosen
[ { "from": "system", "value": "Remove decorator 'skip_in_ci' from test_files\n\nBecause implement stub of capture engine, 'Output slides pdf' test can run in CircleCI\n" }, { "from": "human", "value": "import os\nimport shutil\nimport deck2pdf\nfrom pytest import raises\nfrom . import (\n curr...
python
chosen
[ { "from": "system", "value": "Add unit to the test directories\n" }, { "from": "human", "value": "\"\"\"\nSimple test runner to separate out the functional tests and the unit tests.\n\"\"\"\nimport os\nimport subprocess\n\nPLATFORMS = ['bsd', 'linux', 'nt']\n\n# Detect what platform we are on\nt...
python
chosen
[ { "from": "system", "value": "Implement a test specifically for abbreviations\n" }, { "from": "human", "value": "from cookiecutter.main import is_repo_url\n\n\ndef test_is_repo_url():\n \"\"\"Verify is_repo_url works.\"\"\"\n assert is_repo_url('gitolite@server:team/repo') is True\n ass...
python
chosen
[ { "from": "system", "value": "Fix imports for void tests\n" }, { "from": "human", "value": "\"\"\"test_void.py\n\nTest the parsing of VoID dump files.\n\n\"\"\"\n\nimport RDF\n\nfrom glharvest import util\n\n\ndef test_returns_none_if_the_registry_file_is_not_found():\n m = util.load_file_int...
python
chosen
[ { "from": "system", "value": "Check HMAC digests in webhook notifications before handling them.\n\nBump #1\n" }, { "from": "human", "value": "from django.views.decorators.csrf import csrf_exempt\nfrom django.http import HttpResponse, HttpResponseNotFound\n\n\ndef handle_ping(request, repo):\n ...
python
chosen
[ { "from": "system", "value": "Add note about str.isalpha() method as an alternative\n" }, { "from": "human", "value": "from string import ascii_lowercase\n\n\nLOWERCASE = set(ascii_lowercase)\n\n\ndef is_isogram(s):\n chars = [c for c in s.lower() if c in LOWERCASE]\n return len(chars) == ...
python
chosen
[ { "from": "system", "value": "Replace double quotes with single quotes\n" }, { "from": "human", "value": "__all__ = [\n 'create_engine',\n]\n\nimport sqlalchemy\n\n\ndef create_engine(\n db_uri, *,\n check_same_thread=False,\n echo=False,\n pragmas=()):\n\n engi...
python
chosen
[ { "from": "system", "value": "Extend code references with external repos\n" }, { "from": "human", "value": "from django.core.exceptions import ObjectDoesNotExist\n\nfrom db.models.repos import CodeReference\n\n\ndef get_project_code_reference(project, commit=None):\n if not project.has_code:\...
python
chosen
[ { "from": "system", "value": "[BUG] Update import for access changes\n" }, { "from": "human", "value": "from access import fca\nfrom access import raam\nfrom access import weights\nfrom access import helpers\nfrom access.datasets import datasets\nfrom access import access_log_stream\nfrom access...
python
chosen
[ { "from": "system", "value": "Add fileio.TextFile and use it when reading and writing text files in RDD and Context.\n" }, { "from": "human", "value": "from __future__ import absolute_import, unicode_literals\n\nimport logging\nfrom io import StringIO\n\nfrom . import codec\nfrom .file import Fi...
python
chosen
[ { "from": "system", "value": "Use upsert to reduce chance of duplicates\n" }, { "from": "human", "value": "'''\nAbstraction of TinyDB table for storing config\n'''\nfrom tinydb import Query\n\n\nclass KeyValueTable:\n \"\"\"Wrapper around a TinyDB table.\n\n \"\"\"\n\n def __init__(self...
python
chosen
[ { "from": "system", "value": "Reword the permissions for Disqus\n" }, { "from": "human", "value": "from oauthlib.oauth2.draft25 import utils\nimport foauth.providers\n\n\ndef token_uri(service, token, r):\n params = [((u'access_token', token)), ((u'api_key', service.client_id))]\n r.url = ...
python
chosen
[ { "from": "system", "value": "Fix rediss ssl eventlet sslerror bug\n\nThis is the same as [^1].\n\nI did a test deploy to double check that Redis on PaaS doesn't work\nwithout this.\n\n[^1]: https://github.com/alphagov/notifications-api/pull/3508/commits/a2cbe2032565c61b971659aed28ebd4b096ea87d\n" }, { ...
python
chosen
[ { "from": "system", "value": "Add newline to a file\n" }, { "from": "human", "value": "from PIL import Image\nimport stepic\nimport sys\nimport os\n\nfrom moviepy.editor import *\nimport moviepy.editor as mpy \nfrom moviepy.editor import VideoFileClip\n\nos.chdir(\"videos\")\n\ndef encrypt_video...
python
chosen
[ { "from": "system", "value": "Add links to previous and next month\n" }, { "from": "human", "value": "from datetime import date\nfrom django.shortcuts import render_to_response\n\ndef month (request, year, month):\n month = date(int(year), int(month), 1)\n\n return render_to_response('events/e...
python
chosen
[ { "from": "system", "value": "Change PAM stack back to login\n" }, { "from": "human", "value": "AUTHENTICATION_BACKENDS = (\n 'django.contrib.auth.backends.ModelBackend',\n 'lib.pam_backend.PamBackend',\n)\n\nAUTH_USER_MODEL = 'accounts.User'\n\nLOGIN_URL = '/login'\n\nPAM_SERVICES = {\n ...
python
chosen
[ { "from": "system", "value": "Disable R0924 check on PlanForm\n\nThis check fails on Django 1.4 but not Django 1.5\n" }, { "from": "human", "value": "from django import forms\n\nfrom payments.settings import PLAN_CHOICES\n\n\nclass PlanForm(forms.Form):\n \n plan = forms.ChoiceField(choice...
python
chosen
[ { "from": "system", "value": "Fix errors in set_welcome and update for http_client\n" }, { "from": "human", "value": "from http_client import HttpClient\n\nclass Bot():\n \"\"\"\n @brief Facebook messenger bot\n \"\"\"\n\n def __init__(self, token):\n self.api_token = token\n ...
python
chosen
[ { "from": "system", "value": "Use format string. Readability. ValueError.\n" }, { "from": "human", "value": "import json\n\nfrom six import StringIO\nfrom six import string_types\nfrom six import integer_types\n\n\ndef _to_text(text, obj):\n if isinstance(obj, dict):\n for key in sorte...
python
chosen
[ { "from": "system", "value": "Increment version number to 0.16.1\n" }, { "from": "human", "value": "\"\"\"Configuration for Django system.\"\"\"\n\n__version__ = \"0.16.0\"\n__version_info__ = tuple(\n [\n int(num) if num.isdigit() else num\n for num in __version__.replace(\"-\"...
python
chosen
[ { "from": "system", "value": "Use byte strings after serializing with serde\n\nThe pymemcache client will return a byte string, so we'll do the same to test that the deserializer works as expected.\n\nThis currently fails with Python 3.\n" }, { "from": "human", "value": "from unittest import Tes...
python
chosen
[ { "from": "system", "value": "Add calculation to the lexicon\n" }, { "from": "human", "value": "import os\nimport shlex\n\n\nclass Clues:\n DEFAULT_FILENAME = os.getcwd() + os.sep + 'subjectivity_clues' + os.sep + 'subjclueslen1-HLTEMNLP05.tff'\n\n def __init__(self, filename=DEFAULT_FILEN...
python
chosen
[ { "from": "system", "value": "Use github's `clone_url` instead of mandating ssh.\n" }, { "from": "human", "value": "from collections import namedtuple\n\nRemote = namedtuple('Remote', ('name', 'url'))\nCommitInfo = namedtuple(\"CommitInfo\",\n ('commit', 'origin', 'remote_...
python
chosen
[ { "from": "system", "value": "Use versioneer for ./lib version\n\n- Allows the version to be obtained without khmer being installed.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\" Extracts the version of the khmer project. \"\"\"\n\nimport sys\nimport pkg_resources\n\ntry:\n ...
python
chosen
[ { "from": "system", "value": "Create additional options for default_logging function\n" }, { "from": "human", "value": "import logging\n\ndef default_logging(grab_log='/tmp/grab.log'):\n \"\"\"\n Customize logging output to display all log messages\n except grab network logs.\n\n Red...
python
chosen
[ { "from": "system", "value": "Add a title attribute to the SearchIndex for pages.\n\nThis is useful when displaying a list of search results because we\ncan display the title of the result without hitting the database to\nactually pull the page.\n" }, { "from": "human", "value": "\"\"\"Django ha...
python
chosen
[ { "from": "system", "value": "Bump version: 0.1.8 → 0.1.9\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*\n\"\"\"\n`grappa` provides two different testing styles: `should` and `expect`.\n\nshould\n------\n\nExample using ``should`` style::\n\n from grappa import should\n\n should...
python
chosen
[ { "from": "system", "value": "Update tests for new API.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport hummus\nfrom tempfile import NamedTemporaryFile\nimport os\n\n\ndef assert_pdf(filename):\n with open(filename, 'rb') as stream:\n assert stream.read(4) == b'%PDF'...
python
chosen
[ { "from": "system", "value": "Replace %(module)s with %(pathname)s in DEFAULT_KVP_FORMAT\n\nThe pathname gives more context in large projects that contains repeated module\nnames (eg models, base, etc).\n" }, { "from": "human", "value": "\nDEFAULT_LOGGING_CONF = {\n 'version': 1,\n 'disabl...
python
chosen
[ { "from": "system", "value": "Repair version, beta needs a number.\n" }, { "from": "human", "value": "from __future__ import unicode_literals\nDEBUG_MODULES = [\n # 'pytui',\n]\n\nVERSION = '0.3.1b'\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\nDEBUG_MO...
python
chosen
[ { "from": "system", "value": "Add ppc64le tarball rc force builder\n" }, { "from": "human", "value": "# Add a manual scheduler for building release candidates\nrc_scheduler = ForceScheduler(\n name=\"rc build\",\n builderNames=[\"package_osx10.9-x64\", \"package_win6.2-x64\", \"package_win...
python
chosen
[ { "from": "system", "value": "Add East Riding of Yorkshire Council to migration\n" }, { "from": "human", "value": "\"\"\"empty message\n\nRevision ID: 0165_another_letter_org\nRevises: 0164_add_organisation_to_service\nCreate Date: 2017-06-29 12:44:16.815039\n\n\"\"\"\n\n# revision identifiers, ...
python
chosen
[ { "from": "system", "value": "Revert \"Fix the location path of OpenIPSL\"\n\nThis reverts commit 5b3af4a6c1c77c651867ee2b5f5cef5100944ba6.\n" }, { "from": "human", "value": "import sys\nfrom CITests import CITests\n\n# Libs in Application Examples\nappExamples = {\n#\"KundurSMIB\":\"/Applicatio...
python
chosen
[ { "from": "system", "value": "Change chromhost to use normal sockets\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport socket\n\nimport struct\nimport sys\n\n\ndef send_to_chrome(message):\n # Write message size.\n sys.stdout.write(struct.pack('I', len(message)))\n # Writ...
python
chosen
[ { "from": "system", "value": "Set up list of needed pieces on init\n" }, { "from": "human", "value": "import collections\nfrom stock import Stock\n\n# simple structure to keep track of a specific piece\nPiece = collections.namedtuple('Piece', 'id, length')\n\nclass Planner(object):\n\n def __...
python
chosen
[ { "from": "system", "value": "Allow Jenkins to actually report build failures\n" }, { "from": "human", "value": "\"\"\"Python script to run all tests\"\"\"\nimport pytest\n\nif __name__ == '__main__':\n pytest.main()\n" }, { "from": "gpt", "value": "\"\"\"Python script to run all ...
python
chosen
[ { "from": "system", "value": "Add i18n test for humanize.ordinal\n" }, { "from": "human", "value": "import datetime as dt\n\nimport humanize\n\n\ndef test_i18n():\n three_seconds = dt.timedelta(seconds=3)\n\n assert humanize.naturaltime(three_seconds) == \"3 seconds ago\"\n\n humanize.i...
python
chosen
[ { "from": "system", "value": "Fix to deal with invalid commands.\n" }, { "from": "human", "value": "# coding: utf-8\n\n\"\"\"\nMission simulation.\n\"\"\"\n\nfrom rover import Plateau, Rover, Heading, Command\n\n\nif __name__ == '__main__':\n instructions = open('instructions.txt', 'r')\n\n ...
python
chosen
[ { "from": "system", "value": "Print the character without Rhyme if it is not on the Rhyme Dictionary\n" }, { "from": "human", "value": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport sys\nimport re\nimport codecs\n\nping = re.compile(u'.平')\nshang = re.compile(u'上聲')\nru = re.compile(u'入')...
python
chosen
[ { "from": "system", "value": "Change API url prefix to 'v2'\n" }, { "from": "human", "value": "from django.conf import settings\nfrom django.conf.urls import include, url\n# from django.contrib import admin\nfrom django.conf.urls.static import static\n\n\nfrom . import views\n\n\nurlpatterns = [...
python
chosen
[ { "from": "system", "value": "Use index name matching the current naming schema\n" }, { "from": "human", "value": "\"\"\"Added end_date to full text index events\n\nRevision ID: 573faf4ac644\nRevises: 342fa3076650\nCreate Date: 2015-03-06 17:26:54.718493\n\"\"\"\n\nimport sqlalchemy as sa\nfrom ...
python
chosen
[ { "from": "system", "value": "Make use of Django's hashcompat module." }, { "from": "human", "value": "from django.conf import settings\n\ndef generate_secret_delimiter():\n try:\n from hashlib import sha1\n except ImportError:\n from sha import sha as sha1\n return sha1(g...
python
chosen
[ { "from": "system", "value": "Create new model for debts and loans\n" }, { "from": "human", "value": "from django.contrib.auth.models import User\nfrom django.db import models\nfrom django.db.models import fields\nfrom django.utils import timezone\n\n\nclass Transaction(models.Model):\n EXPEN...
python
chosen
[ { "from": "system", "value": "Remove Parser from __all__ (from pronto import *)\n" }, { "from": "human", "value": "# coding: utf-8\n\"\"\"\n**pronto**: a Python frontend to ontologies\n===========================================\n\n\"\"\"\n\nfrom __future__ import absolute_import\n\n__all__ = [\...
python
chosen