conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Add index for image metainformation\n" }, { "from": "human", "value": "import uuid\n\nfrom django.conf import settings\nfrom django.contrib.postgres.fields import JSONField\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\nfro...
python
chosen
[ { "from": "system", "value": "Add basic test that only import simpleflow\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom simpleflow import simpleflow\n\ndef test_basic():\n assert 0, 'write me!'" }, { "from": "gpt", "value": "#!/usr/bin/en...
python
chosen
[ { "from": "system", "value": "Move master version to 0.1.2.\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n#\n# Copyright 2017 Kaede Hoshikawa\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": "Support nosetests, handle magic names (and_, or_, etc)\n" }, { "from": "human", "value": "# ElasticQuery\n# File: elasticquery/filterquery.py\n# Desc: The base query class & metaclass\n\nimport json\n\nfrom .util import make_dsl_object, unroll_definitions, unroll_st...
python
chosen
[ { "from": "system", "value": "[recipes] Remove deprecated (ignored) --use-bootstrap flag\n\nThis has been ignored for a long time, and I'd like to get rid of it.\n\nR=jchinlee@chromium.org, ef4933a197ef7b4b3f55f1bec4942aead3637a2a@chromium.org\n\nChange-Id: I240d59cc10a2882041ac2c8abfeb1894237516a6\nReviewe...
python
chosen
[ { "from": "system", "value": "Set a maximum to the number of elements that may be requested\n" }, { "from": "human", "value": "from collections import OrderedDict\nfrom django.utils.translation import ugettext_lazy as _\nfrom rest_framework.pagination import PageNumberPagination\nfrom rest_frame...
python
chosen
[ { "from": "system", "value": "Disable an externals tests on Py3.\n" }, { "from": "human", "value": "from django.test import TestCase\n\nfrom ..externals import External\n\ntry:\n from contextlib import GeneratorContextManager\nexcept ImportError:\n from contextlib import _GeneratorContextM...
python
chosen
[ { "from": "system", "value": "Use ternary operator for arg selection.\n" }, { "from": "human", "value": "from datetime import datetime, timedelta\nimport os\n\n\nclass cached(object):\n def __init__(self, *args, **kwargs):\n self.cached_function_responses = {}\n self.default_max...
python
chosen
[ { "from": "system", "value": "Update export items command for dataset\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.core.management.base import BaseCommand\nfrom django.db.models import Q\n\nfrom digest.management.commands.crea...
python
chosen
[ { "from": "system", "value": "Make sure we can search names with '\n" }, { "from": "human", "value": "import re\n\nfrom django.contrib.postgres.search import SearchQuery, SearchRank\nfrom django.db.models import Count, F\n\nfrom people.models import Person\n\n\ndef search_person_by_name(name, sy...
python
chosen
[ { "from": "system", "value": "Add config to local config to enable login to work\n" }, { "from": "human", "value": "DEBUG = True\n# GOOGLE_SERVICE_ACCOUNT_KEYFILE_PATH = '/home/vagrant/heltour/gspread.conf'\n# SLACK_API_TOKEN_FILE_PATH = '/home/vagrant/heltour/slack-token.conf'\n\nINTERNAL_IPS =...
python
chosen
[ { "from": "system", "value": "Add Geography Type to GeoAlchemy Backend\n\nThe current GeoAlchemy backend only works with geometry columns, and ignores geography columns (which are also supported by geoalchemy). This 1-word fix adds support for geography columns." }, { "from": "human", "value": ...
python
chosen
[ { "from": "system", "value": "Switch web node to web1\n" }, { "from": "human", "value": "\n\ndef activity_hosts():\n return [\"activity0\", \"activity1\", \"activity2\"]\n\n\ndef app_hosts():\n return [\"app0\", \"app1\", \"app2\", \"app3\"]\n\n\ndef etherpad_hosts():\n return [\"etherp...
python
chosen
[ { "from": "system", "value": "Address review comment: Document return type.\n" }, { "from": "human", "value": "# Copyright Hybrid Logic Ltd. See LICENSE file for details.\n\n\"\"\"\nCombine and retrieve current cluster state.\n\"\"\"\n\nfrom twisted.application.service import Service\n\nfrom ._...
python
chosen
[ { "from": "system", "value": "Set self.build_flow before calling the super __init__ method\n" }, { "from": "human", "value": "from cumulusci.core.config import YamlGlobalConfig\nfrom cumulusci.core.config import YamlProjectConfig\n\nclass MrbelvedereProjectConfig(YamlProjectConfig):\n def __i...
python
chosen
[ { "from": "system", "value": "Fix Tempest tests failing on gate-solum-devstack-dsvm\n\nDue to a new commit on tempest, all our devstack tests were\nfailing. This was due to an inheritance we have to RestClient\nfrom tempest. The signature of the constructor has changed.\n\nThis patch changes the signature o...
python
chosen
[ { "from": "system", "value": "Use exact version instead of latest in the migration dependencies\n\nChanged to use the latest migration of wagtail-blog v1.6.9.\n\nRefs\nhttps://github.com/thelabnyc/wagtail_blog/blob/5147d8129127102009c9bd63b1886e7665f6ccfb/blog/migrations/0005_auto_20151019_1121.py\n" }, ...
python
chosen
[ { "from": "system", "value": "Support new versions with django-gm2m\n" }, { "from": "human", "value": "\"\"\"GM2MField support for autocomplete fields.\"\"\"\n\n\nclass GM2MFieldMixin(object):\n \"\"\"GM2MField ror FutureModelForm.\"\"\"\n\n def value_from_object(self, instance, name):\n ...
python
chosen
[ { "from": "system", "value": "Bump the patch level version of distutils since there were a few bug fixes since\nthe 2.5.0 release.\n" }, { "from": "human", "value": "\"\"\"distutils\n\nThe main package for the Python Module Distribution Utilities. Normally\nused from a setup script as\n\n fro...
python
chosen
[ { "from": "system", "value": "Add default relay uri to the default config" }, { "from": "human", "value": "# Must be a mysql database!\ndatabase_uri = 'mysql://root@localhost/pushjet_api'\n\n# Are we debugging the server?\n# Do not turn this on when in production!\ndebug = True\n\n# Limit reques...
python
chosen
[ { "from": "system", "value": "Improve form_errors_to_json to handle multiple forms\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n djlime.forms.utils\n ~~~~~~~~~~~~~~~~~~\n\n Utilities for forms.\n\n :copyright: (c) 2012 by Andrey Voronov.\n :license: BSD, see...
python
chosen
[ { "from": "system", "value": "Set log with small message\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport sys\nfrom traceback import format_exception\n\nfrom pyramid.decorator import reify\nfrom pyramid.httpexceptions import HTTPInternalServerError\nfrom pyramid.interfaces im...
python
chosen
[ { "from": "system", "value": "Fix bug in temporary directory generation.\n" }, { "from": "human", "value": "from contextlib import contextmanager\nfrom tempfile import TemporaryDirectory\n\nfrom django.core.management import call_command\nfrom django.test import TestCase\n\nfrom django_archive i...
python
chosen
[ { "from": "system", "value": "Convert dict view to list for Py3\n" }, { "from": "human", "value": "import os\nimport json\n\nimport pytest\n\ndef test_add_single(identity_fixures, identity_store):\n for d in identity_fixures:\n identity = identity_store.add_identity(d)\n for key...
python
chosen
[ { "from": "system", "value": "Remove some indirection, set db password\n" }, { "from": "human", "value": "from pathlib import Path\nfrom hoover.site.settings.common import *\n\nINSTALLED_APPS = INSTALLED_APPS + [\n 'hoover.contrib.twofactor',\n 'django_otp',\n 'django_otp.plugins.otp_to...
python
chosen
[ { "from": "system", "value": "Update dsub version to 0.3.0.dev0\n\nPiperOrigin-RevId: 241419925\n" }, { "from": "human", "value": "# Copyright 2017 Google Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in comp...
python
chosen
[ { "from": "system", "value": "Handle Dash objects in to_json\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nimport plotly\nimport plotly.graph_objs as go\n\n\ndef validate_coerce_fig_to_dict(fig, validate, clone=True):\n from plotly.basedatatypes import BaseFigur...
python
chosen
[ { "from": "system", "value": "Adjust syntax detector to account for new ST3 default package name\n" }, { "from": "human", "value": "import sublime, sublime_plugin\nimport os\n\nclass JasmineCoffeeScriptDetectFileTypeCommand(sublime_plugin.EventListener):\n \"\"\" Detects current file type if th...
python
chosen
[ { "from": "system", "value": "Update a docstring to match the upstream odekro branch\n" }, { "from": "human", "value": "from django.core.management.base import BaseCommand, CommandError\n\nfrom odekro import data\n\n\nclass Command(BaseCommand):\n \"\"\"Read in an info page file and either cr...
python
chosen
[ { "from": "system", "value": "Add trailing slash to fake_s3_upload url" }, { "from": "human", "value": "from django.conf.urls import include, url\nfrom buckets.test import views\n\nurlpatterns = [\n url(r'^', include('buckets.urls')),\n url(r'^media/s3/uploads$', views.fake_s3_upload, name...
python
chosen
[ { "from": "system", "value": "Make sure we give people a download with the actual name of the file\n" }, { "from": "human", "value": "from flask.ext import restful\nfrom . import database\nfrom flask import abort, send_file\nfrom werkzeug import secure_filename\nimport os\n\n\nclass DownloadInst...
python
chosen
[ { "from": "system", "value": "Update discovery method for Wemo devices\n" }, { "from": "human", "value": "\"\"\" Discovers Belkin Wemo devices. \"\"\"\n\nfrom . import SSDPDiscoverable\n\n\nclass Discoverable(SSDPDiscoverable):\n \"\"\" Adds support for discovering Belkin WeMo platform device...
python
chosen
[ { "from": "system", "value": "Remove Ubuntu12 32 from may_fail_with_warning\n\nIt's empty now. TODO: Remove the functionality once we're sure we don't\nneed it.\n\nR=robertphillips@google.com\n\nReview URL: https://codereview.chromium.org/23545022\n\ngit-svn-id: 32fc27f4dcfb6c0385cd9719852b95fe6680452d@110...
python
chosen
[ { "from": "system", "value": "Update match-id to equal that used in compd.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os\nimport sys\nimport yaml\n\nimport score\n\ndef usage():\n print \"Usage: score-match.py MATCH_NUMBER\"\n print \" Scores the match file at matc...
python
chosen
[ { "from": "system", "value": "Remove box tests for non-existant functionality\n" }, { "from": "human", "value": "import pytest\nimport numpy as np\nimport mbuild as mb\nfrom mbuild.tests.base_test import BaseTest\n\n\nclass TestBox(BaseTest):\n\n def test_init_lengths(self):\n box = mb...
python
chosen
[ { "from": "system", "value": "Add pupular RC objects to index view.\n\nEarlier they was at context processor.\n" }, { "from": "human", "value": "from django.shortcuts import render, render_to_response\nfrom django.template import RequestContext\n\nfrom new_buildings.models import Builder, Reside...
python
chosen
[ { "from": "system", "value": "Index profiles in chunks and not altogether.\n" }, { "from": "human", "value": "from django.conf import settings\n\nimport cronjobs\n\nfrom celery.task.sets import TaskSet\nfrom elasticutils.contrib.django import get_es\n\nfrom mozillians.users.tasks import index_ob...
python
chosen
[ { "from": "system", "value": "Fix test_show_urls without admin api urls\n" }, { "from": "human", "value": "import django\nfrom django.core.management import call_command\nfrom django.test import TestCase\n\nfrom bananas.management.commands import show_urls\n\n\nclass CommandTests(TestCase):\n ...
python
chosen
[ { "from": "system", "value": "Remove name field from form\n" }, { "from": "human", "value": "from django import forms\n\nfrom .models import get_application_model\n\n\nclass AllowForm(forms.Form):\n allow = forms.BooleanField(required=False)\n redirect_uri = forms.CharField(widget=forms.Hi...
python
chosen
[ { "from": "system", "value": "Bump version as instructed by bamboo\n" }, { "from": "human", "value": "#-*- coding: utf-8 -*-\n# version string following pep-0396 and pep-0386\n__version__ = '0.9pbs.4' # pragma: nocover\n" }, { "from": "gpt", "value": "#-*- coding: utf-8 -*-\n# versi...
python
chosen
[ { "from": "system", "value": "Remove unused and commented parts\n" }, { "from": "human", "value": "from django import forms as newform\nfrom django.forms import ModelForm\nfrom people.models import Beneficiary, Donor\nfrom django.contrib.auth.models import User\nfrom django.utils.translation imp...
python
chosen
[ { "from": "system", "value": "Create base test case class for rupture\n" }, { "from": "human", "value": "from django.test import TestCase\nfrom breach.models import SampleSet, Victim, Target, Round\nfrom breach.analyzer import decide_next_world_state\n\n\nclass AnalyzerTestCase(TestCase):\n d...
python
chosen
[ { "from": "system", "value": "Use javascript to force focus on an element, because the action chains seems take no effect!\n\n" }, { "from": "human", "value": "\r\n#--IMPORT_ALL_FROM_FUTURE--#\r\n\r\n'''\r\n@date 2014-11-16\r\n@author Hong-she Liang <starofrainnight@gmail.com>\r\n'''\r\n\r\n# Im...
python
chosen
[ { "from": "system", "value": "Fix a deprecation warning; content_type replaces mimetype\n" }, { "from": "human", "value": "import json\nimport os\n\nfrom django.conf import settings\nfrom django.http import HttpResponse\nfrom django.views.decorators.cache import cache_page\n\nfrom .wordcloud imp...
python
chosen
[ { "from": "system", "value": "Add own tuple_index function to stay compatible with python 2.5\n" }, { "from": "human", "value": "from social_auth.backends import PIPELINE\nfrom social_auth.utils import setting\n\n\nPIPELINE_ENTRY = 'social_auth.backends.pipeline.misc.save_status_to_session'\n\n\...
python
chosen
[ { "from": "system", "value": "Change parse errors to standard format.\n" }, { "from": "human", "value": "# -*- coding: iso-8859-1 -*-\n\nfrom twisted.protocols.basic import Int32StringReceiver\n\nimport json\nimport apps\n\nclass JSONProtocol(Int32StringReceiver):\n app = apps.LoginApp\n\n ...
python
chosen
[ { "from": "system", "value": "Remove API key (it's for the wrong API version)\n" }, { "from": "human", "value": "import pymongo\nimport stackexchange\nimport time\n\nso = stackexchange.Site(stackexchange.StackOverflow, \"WNe2LOp*hdsbD5U7kp0bhg((\")\n\nso.be_inclusive()\n\nconnection = pymongo.Co...
python
chosen
[ { "from": "system", "value": "Include domains which have last_modified equal to None\n" }, { "from": "human", "value": "from django.core.management.base import BaseCommand\n\nfrom corehq.apps.domain.models import Domain\nfrom dimagi.utils.couch.database import iter_docs\n\n\nclass Command(BaseCo...
python
chosen
[ { "from": "system", "value": "Change the method get_query_set() to get_queryset() as required by django 1.7\n" }, { "from": "human", "value": "\"\"\"\nManagers of ``blog`` application.\n\"\"\"\nfrom django.db import models\n\n\nclass CategoryOnlineManager(models.Manager):\n \"\"\"\n Manage...
python
chosen
[ { "from": "system", "value": "Add more code to LpNorm unit tests\n" }, { "from": "human", "value": "\"\"\"\nTest LpNorm cost\n\"\"\"\nimport numpy\nimport theano\nfrom theano import tensor as T\nfrom nose.tools import raises\n\n\ndef test_shared_variables():\n '''\n LpNorm should handle sh...
python
chosen
[ { "from": "system", "value": "Rewrite inserting function. It can be a lot simpler now we know we're always dealing with up-to-date data.\n" }, { "from": "human", "value": "\ndef import_question(posts, namespaces, id, title, body, tags, last_activity_date, last_updated_date, score, answer_count, ...
python
chosen
[ { "from": "system", "value": "Add forge libraries to patch helper\n" }, { "from": "human", "value": "import os\nimport fileinput\n\ndef modify(path, build):\n config = os.path.join(path, 'config/forge.cfg')\n replacements = {\n 'removeErroringEntities=false': 'removeErroringEntities...
python
chosen
[ { "from": "system", "value": "Convert description in setup.py to rest format for better display in Cheeseshop\n\n--HG--\nextra : convert_revision : svn%3A77541ad4-5f01-0410-9ede-a1b63cd9a898/trunk%403340\n" }, { "from": "human", "value": "\"\"\"TurboGears project related information\"\"\"\nversi...
python
chosen
[ { "from": "system", "value": "Modify worker to requeue jobs if worker is killed\n" }, { "from": "human", "value": "from scoring_engine.celery_app import celery_app\nfrom celery.exceptions import SoftTimeLimitExceeded\nimport subprocess\n\nfrom scoring_engine.logger import logger\n\n\n@celery_app...
python
chosen
[ { "from": "system", "value": "Fix utf-8 encoding error when saving the file.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nfrom appkit.api.v0_2_8 import App\nfrom flask import render_template, request\nimport os\nimport sys\nimport codecs\n\napp = App(__name__)\n\ntry:\n file_na...
python
chosen
[ { "from": "system", "value": "Make Django 1.7 migrations compatible with Python3" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport django.utils.timezone\n\n\nclass Migration(migrations.Migration):...
python
chosen
[ { "from": "system", "value": "Revert \"Allow admin preview in minutes as well\"\n\nThis reverts commit f4806655\n" }, { "from": "human", "value": "from django.forms import ModelForm, Textarea, ChoiceField\nfrom django.urls import reverse_lazy\n\nfrom .models import Meeting, Folder\n\nMD_INPUT = ...
python
chosen
[ { "from": "system", "value": "Fix where db name should be used in db operations (name conflict!)\n" }, { "from": "human", "value": "import discord\nfrom modules.botModule import BotModule\n\nclass Karma(BotModule):\n name = 'karma'\n\n description = 'Monitors messages for reactions...
python
chosen
[ { "from": "system", "value": "Allow setting the HOSTNAME reported to the master via an env var; Stub and endpoint for tailing the log of a process assuming you know the path.\n\nI'd like to get this log processing a bit more automatic but I need to\nspend more time in Dadd's API.\n" }, { "from": "hu...
python
chosen
[ { "from": "system", "value": "Work around missing jcppy._version for local development\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# Copyright (c) 2017 Stanislav Ivochkin <isn@extrn.org>\n# License: MIT (see LICENSE for details)\n\nfrom jcppy._version impo...
python
chosen
[ { "from": "system", "value": "Add a fling-driven variant of SimpleMobileSites\n\nCreate a basic pageset that uses the newly supported fling interaction,\nparalleling the existing SimpleMobileSites pageset that uses smooth\nscrolling. This should allow basic comparisons between touch scrolling\nand fling per...
python
chosen
[ { "from": "system", "value": "Fix relative import (compatible with p3\n" }, { "from": "human", "value": "import os\nfrom binstar_client import errors\nfrom uploader import *\n\n\ndef parse(handle):\n \"\"\"\n Handle can take the form of:\n notebook\n path/to/notebook[.ipynb]\...
python
chosen
[ { "from": "system", "value": "Use `path` helper for URLConf\n" }, { "from": "human", "value": "import django.views.static\nfrom django.conf import settings\nfrom django.conf.urls import include, url\nfrom django.contrib import admin\nfrom django.contrib.staticfiles.urls import staticfiles_urlpat...
python
chosen
[ { "from": "system", "value": "Add columns and values to repr\n" }, { "from": "human", "value": "from django.db.models import Model, CharField, Field\n\n\nclass MaxLengthCharField(CharField):\n def __init__(self, *args, **kwargs):\n kwargs['max_length'] = 255\n super().__init__(*...
python
chosen
[ { "from": "system", "value": "Test the Description property of the registry's root\n" }, { "from": "human", "value": "PROPERTIES_IFACE = 'org.freedesktop.DBus.Properties'\nACCESSIBLE_IFACE = 'org.a11y.atspi.Accessible'\n\ndef test_accessible_iface_properties(registry, session_manager):\n val ...
python
chosen
[ { "from": "system", "value": "Convert css class of PasswordInput widget\n" }, { "from": "human", "value": "from django import template\n\nregister = template.Library()\n\nclass_converter = {\n \"textinput\":\"textinput textInput\",\n \"fileinput\":\"fileinput fileUpload\",\n \"passwordi...
python
chosen
[ { "from": "system", "value": "Fix typos in exception messages and use less specific exception in management commands.\n" }, { "from": "human", "value": "import logging\nl=logging.getLogger(__name__)\n\nfrom django.conf import settings\nfrom django.core.management.base import BaseCommand, Command...
python
chosen
[ { "from": "system", "value": "Test modelAdmin actions is present\n" }, { "from": "human", "value": "from django.test import TestCase\nfrom django.contrib.admin.sites import AdminSite\nfrom billjobs.admin import UserAdmin\n\nclass EmailExportTestCase(TestCase):\n \"\"\" Tests for email account...
python
chosen
[ { "from": "system", "value": "Add template tag to look up sponsor images\n" }, { "from": "human", "value": "from django import template\n\nfrom wafer.sponsors.models import Sponsor, SponsorshipPackage\n\nregister = template.Library()\n\n\n@register.inclusion_tag('wafer.sponsors/sponsors_block.ht...
python
chosen
[ { "from": "system", "value": "Revert a debugging change that slipped in.\n" }, { "from": "human", "value": "from django_evolution.db import evolver\n\ndef write_sql(sql):\n \"Output a list of SQL statements, unrolling parameters as required\"\n for statement in sql:\n if isinstance(...
python
chosen
[ { "from": "system", "value": "Fix syncdb in database router\n" }, { "from": "human", "value": "from .settings import CONNECTION_NAME\n\n\nclass Log4DjangoRouter(object):\n def db_for_read(self, model, **hints):\n if model._meta.app_label == 'log4django':\n return CONNECTION_...
python
chosen
[ { "from": "system", "value": "Add tests for enforce hostname middleware\n" }, { "from": "human", "value": "from basket.news.middleware import is_ip_address\n\n\ndef test_is_ip_address():\n assert is_ip_address('1.2.3.4')\n assert is_ip_address('192.168.1.1')\n assert not is_ip_address('...
python
chosen
[ { "from": "system", "value": "Order by create, don't filter\n" }, { "from": "human", "value": "from django.contrib import admin\n\nfrom .models import Region, City, GatheringCenter, Resource\n\nadmin.site.register(Region)\nadmin.site.register(City)\n\n\nclass PublishMixin(object):\n actions =...
python
chosen
[ { "from": "system", "value": "bug: Correct the character limit for descriptions\n" }, { "from": "human", "value": "from sqlalchemy import Column, ForeignKey, Integer, String\nfrom sqlalchemy.orm import relationship\n\nfrom models.base import Base\nfrom models.user import User\nfrom models.store ...
python
chosen
[ { "from": "system", "value": "Fix build exitting from make coverage\n" }, { "from": "human", "value": "from __future__ import absolute_import, division, print_function\nimport os, sys, tempfile\n\nsys.path.append(\"data/\")\nimport data\n\ntry:\n from urllib.request import urlopen\nexcept Imp...
python
chosen
[ { "from": "system", "value": "Fix django logger issue when error has no attached request object\n" }, { "from": "human", "value": "import copy\nimport logging\nimport traceback\n\n\ndef dump(obj):\n for attr in dir(obj):\n print(\"obj.%s = %r\" % (attr, getattr(obj, attr)))\n\n\ndef du...
python
chosen
[ { "from": "system", "value": "Tweak the tastypie resource configuration.\n" }, { "from": "human", "value": "from tastypie.resources import ModelResource\nfrom olcc.models import Product, ProductPrice, Store\n\nclass ProductResource(ModelResource):\n class Meta:\n queryset = Product.obj...
python
chosen
[ { "from": "system", "value": "Update main Lcd import and init, and fix help msg\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\nfrom getopt import getopt, GetoptError\nfrom .api import Server\nfrom .fake import FakeLcdApi\n\n\nUSAGE = \"\"\"\\\nUsage %s [-h|--help]\n\\t-h o...
python
chosen
[ { "from": "system", "value": "Update help_text in api_auth initial migration\n\nI'm updating the help_text in the original migration rather than\ncreating a new migration that doesn't affect the db, but does do a\nbunch of SQL stuff in the migration.\n" }, { "from": "human", "value": "# -*- codi...
python
chosen
[ { "from": "system", "value": "Use importlib.metadata to set __version__\n\nThis way we don't have to remember to update the version in two places\nevery release. The version will only need to be set in pyproject.toml\n" }, { "from": "human", "value": "# coding:utf-8\n\"\"\"\nFunction decoration...
python
chosen
[ { "from": "system", "value": "Add Network Traffic module tests\n" }, { "from": "human", "value": "import pytest\n\npytest.importorskip(\"psutil\")\n\npytest.importorskip(\"netifaces\")\n\ndef test_load_module():\n __import__(\"modules.contrib.network_traffic\")\n\n" }, { "from": "gpt"...
python
chosen
[ { "from": "system", "value": "Use `if __name__` and argparse\n" }, { "from": "human", "value": "from __future__ import absolute_import, print_function\nfrom readme_renderer.rst import render\nimport sys\n\n\nif len(sys.argv) == 2:\n with open(sys.argv[1]) as fp:\n out = render(fp.read(...
python
chosen
[ { "from": "system", "value": "Update tests to deal with changeset 41943013, in which the Royal Academy of Arts was changed to a museum.\n" }, { "from": "human", "value": "# http://www.openstreetmap.org/node/2026996113\nassert_has_feature(\n 16, 10485, 25328, 'pois',\n { 'id': 2026996113, '...
python
chosen
[ { "from": "system", "value": "[Python] Refactor for code to roll many times\n" }, { "from": "human", "value": "import unittest\nfrom game import Game\n\nclass BowlingGameTest(unittest.TestCase):\n\n def setUp(self):\n self.g = Game()\n\n def tearDown(self):\n self.g = None\n\...
python
chosen
[ { "from": "system", "value": "Use new jinja templating system.\n" }, { "from": "human", "value": "#! /usr/bin/env python\nfrom .writers.c import CWriter\n\n\ndef main():\n import argparse\n\n parser = argparse.ArgumentParser()\n parser.add_argument('file', type=argparse.FileType('r'), h...
python
chosen
[ { "from": "system", "value": "Convert int to string for printing\n" }, { "from": "human", "value": "birth_year = raw_input(\"What is the birth year for the milestones?\")\n# raw_input always gives strings, so convert to int\nbirth_year = int(birth_year)\n\n# Calculate milestone years\ndriving_ye...
python
chosen
[ { "from": "system", "value": "Use in-memory db for all tests\n" }, { "from": "human", "value": "# Second half of the postfix_io tests.\n# If the authentication host is unreachable, postfix\n# should have a 400 error returned. This tests for it.\n# This test also works if the local machine is off...
python
chosen
[ { "from": "system", "value": "Refactor python version of Simple Calculate\n" }, { "from": "human", "value": "import sys\n\ns = 0.0\n\nfor line in sys.stdin:\n a, b, c = line.split()\n a, b, c = int(a), int(b), float(c)\n s += c * b\n\nprint(f'VALOR A PAGAR: R$ {s:.2f}')\n" }, { ...
python
chosen
[ { "from": "system", "value": "Add id in the result in the command bandwidth-pools\n" }, { "from": "human", "value": "\"\"\"Displays information about the accounts bandwidth pools\"\"\"\n# :license: MIT, see LICENSE for more details.\nimport click\n\nfrom SoftLayer.CLI import environment\nfrom So...
python
chosen
[ { "from": "system", "value": "Put try/except around ASDF import in init file\n" }, { "from": "human", "value": "# Licensed under a 3-clause BSD style license - see LICENSE.rst\n# -*- coding: utf-8 -*-\n\"\"\"\nThe **asdf** subpackage contains code that is used to serialize astropy types\nso that...
python
chosen
[ { "from": "system", "value": "Set up form to use special widget for tags\n" }, { "from": "human", "value": "from django import forms\nfrom django.forms.models import inlineformset_factory\n\nfrom .models import Knot, Link\n\n\nclass KnotForm(forms.ModelForm):\n class Meta:\n model = Kn...
python
chosen
[ { "from": "system", "value": "Bump new dev version to 0.3.0\n" }, { "from": "human", "value": "import os\n\n__version__ = (0, 1, 1, 'alpha', 1)\n\n\ndef get_fancypages_paths(path):\n \"\"\" Get absolute paths for *path* relative to the project root \"\"\"\n return [os.path.join(os.path.dir...
python
chosen
[ { "from": "system", "value": "[enh] Make possible to define a sort in simple_search_shortcut tt\n" }, { "from": "human", "value": "from django.core.urlresolvers import reverse\nfrom django.template.defaultfilters import urlencode\nfrom django import template\n\nfrom dynamiq.utils import get_adva...
python
chosen
[ { "from": "system", "value": "Fix issue with manager (error w cut and paste)\n" }, { "from": "human", "value": "from django.db import models\n\ntry:\n from django.utils import timezone\nexcept ImportError:\n from datetime import datetime as timezonefrom logicaldelete import managers\n\n\nc...
python
chosen
[ { "from": "system", "value": "Add try except for keyboard interrupts\n" }, { "from": "human", "value": "from App import App\n\n#try:\napp = App()\napp.run()\n#except:\n# print('')" }, { "from": "gpt", "value": "from App import App\n\ntry:\n app = App()\n app.run()\nexcept Ke...
python
chosen
[ { "from": "system", "value": "Fix invalid error code format for Axes\n\nSigned-off-by: Aleksi Häkli <44cb6a94c0d20644d531e2be44779b52833cdcd2@iki.fi>\n" }, { "from": "human", "value": "from django.core.checks import Error, Tags, register\n\nfrom axes.conf import settings\n\n\nclass Messages:\n ...
python
chosen
[ { "from": "system", "value": "Add non-breaking space and fix error\n" }, { "from": "human", "value": "from data_types.hook import Hook\nfrom data_types.repository import Repository\nfrom data_types.user import User\nfrom .base import EventBase\n\n\nclass EventWatch(EventBase):\n\n def __init_...
python
chosen
[ { "from": "system", "value": "Add functions to generate python numpy datastructure and write it into generated python file.\n" }, { "from": "human", "value": "import os\nimport json\nimport sys\nfrom pprint import pprint\n\ndef loadJSON(fInput):\n with open(fInput) as f:\n return json....
python
chosen
[ { "from": "system", "value": "CLEAN TEMPLATE Clean up the project template further still\n" }, { "from": "human", "value": "from src import create\nfrom src import count\nfrom src import thefile\nfrom src import execute\n\n\n\ndef main(x, y, file):\n #Create it\n seats = create.new_2d(x, y...
python
chosen
[ { "from": "system", "value": "Use updated catchment tools import\n" }, { "from": "human", "value": "import os\nimport numpy as np\n\nfrom catchment_cutter import get_grid_cells\n\ndef create_grids(catchments, in_directory, out_directory, grid_file):\n \"\"\"\n Create grid files for the...
python
chosen