conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Add call subprocess and print output\n" }, { "from": "human", "value": "\"\"\"\nDemo of calling subprocesses.\n\n\nLinks\n-----\n\n- https://docs.python.org/3/library/io.html\n\n- https://docs.python.org/3/library/subprocess.html\n\"\"\"\n\nfrom subprocess import ca...
python
chosen
[ { "from": "system", "value": "Use Sauce Labs for selenium testing when available\n" }, { "from": "human", "value": "\"\"\"Unit test module for Selenium testing\"\"\"\nfrom selenium import webdriver\n\nfrom flask.ext.testing import LiveServerTestCase\n\nfrom tests import TestCase\nfrom pages impo...
python
chosen
[ { "from": "system", "value": "Allow to pass security_groups from marketplace to Rancher plugin.\n" }, { "from": "human", "value": "from waldur_mastermind.marketplace import processors\nfrom waldur_rancher import views as rancher_views\n\n\nclass RancherCreateProcessor(processors.BaseCreateResour...
python
chosen
[ { "from": "system", "value": "Add migration to backfill recipient counts\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('...
python
chosen
[ { "from": "system", "value": "Fix bug on sign in page when invalid credentials are given\n\n" }, { "from": "human", "value": "from django import forms\nfrom django.contrib.auth import authenticate\n\nfrom .models import *\n\nclass SignInForm(forms.Form):\n\tusername = forms.CharField(max_length=...
python
chosen
[ { "from": "system", "value": "Remove comma turning dict to tuple without my consent\n" }, { "from": "human", "value": "from django import forms\n\nfrom .models import Content\n\n\nclass ContentForm(forms.ModelForm):\n\n class Meta:\n model = Content\n widgets = {\n # ...
python
chosen
[ { "from": "system", "value": "Update test_connect to read password from env. variable\n" }, { "from": "human", "value": "# unitary test for the pyrpl module\n\nimport unittest\nimport os\n\nfrom pyrpl import RedPitaya\n\n\nclass RedPitayaTestCases(unittest.TestCase):\n\n def setUp(self):\n ...
python
chosen
[ { "from": "system", "value": "Remove parameter support (due to unittest module) and modify to print parameters on each run.\n" }, { "from": "human", "value": "# Initialization code. Placed in a separate Python package from the main\n# app, this code allows the app created to be imported into any...
python
chosen
[ { "from": "system", "value": "Remove trailing slashes from routes.\n" }, { "from": "human", "value": "import StringIO\nimport base64\nimport signal\n\nimport flask\n\nfrom quiver.plotter import FieldPlotter\n\napp = flask.Flask(__name__)\n\n@app.route('/')\ndef quiver():\n '''Route for homepa...
python
chosen
[ { "from": "system", "value": "Check if comment body contains misspelling, reply if so\n" }, { "from": "human", "value": "import praw, time\n\n# replace with your username/password\nusername, password = USERNAME, PASSWORD\n\nr = praw.Reddit(user_agent='A \"tomorrow\"-misspelling corrector by /u/t...
python
chosen
[ { "from": "system", "value": "Remove hiro timeline context in redis test\n" }, { "from": "human", "value": "import unittest\nimport datetime\nimport hiro\nimport redis\nfrom sifr.span import Minute, Day\nfrom sifr.storage import MemoryStorage, RedisStorage\n\n\nclass RedisStorageTests(unittest.T...
python
chosen
[ { "from": "system", "value": "Add test for YouTube playlist\n" }, { "from": "human", "value": "import os\nimport pytest\n\nfrom ricecooker.utils.youtube_cache import YouTubeVideoCache \n\n\n\n\"\"\" *********** YouTube Cache FIXTURES *********** \"\"\"\n\n@pytest.fixture\ndef youtube_video_cache...
python
chosen
[ { "from": "system", "value": "Make ConfigurationError also a ClickException\n" }, { "from": "human", "value": "import click\nfrom click import ClickException\n\n\nclass APIError(ClickException):\n def __init__(self, response):\n super(APIError, self).__init__(response.text)\n se...
python
chosen
[ { "from": "system", "value": "Add splitlines method to substitute_keywords\n" }, { "from": "human", "value": "import logging\nimport subprocess\nimport re\n\n\ndef substitute_keywords(text, repo_folder, commit):\n substitutions = {\n 'version': commit,\n 'date': subprocess.check...
python
chosen
[ { "from": "system", "value": "Fix bug in like validator\n" }, { "from": "human", "value": "def is_quick_button(messaging_event):\n if 'message' not in messaging_event:\n return False\n if 'quick_reply' not in messaging_event['message']:\n return False\n return True\n\n\nde...
python
chosen
[ { "from": "system", "value": "Purge should always be attempted\n\nSince the original is very volatile (in memcache), its absence shouldn't\nprevent the thumbnails from being purged.\n\nFurthermore, knowing whether the item was there beforehand isn't\nvery useful.\n\nChange-Id: I014df0bce00983031b9dec9d48126...
python
chosen
[ { "from": "system", "value": "Refactor AJAX search to use member model methods\n" }, { "from": "human", "value": "from ajax_select import register, LookupChannel\nfrom members.models import *\nfrom django.utils.html import escape\n\n@register('member')\nclass MemberLookup(LookupChannel):\n\n ...
python
chosen
[ { "from": "system", "value": "Change where we're saving the datapackage\n" }, { "from": "human", "value": "import os\nimport copy\n\nfrom datapackage_pipelines.wrapper import process\nfrom os_package_registry import PackageRegistry\n\nES_ADDRESS = os.environ.get('ELASTICSEARCH_ADDRESS')\n\n\ndef...
python
chosen
[ { "from": "system", "value": "Fix test to properly compare chart types\n\nA variable was being compared to itself\n" }, { "from": "human", "value": "\"\"\"For testing\"\"\"\nimport visram.chart\nimport unittest\n\n\nclass TestVisram(unittest.TestCase):\n\n def _test_chart_type(self, chart_typ...
python
chosen
[ { "from": "system", "value": "Fix unicode error in series" }, { "from": "human", "value": "import simplejson\nfrom django.utils.html import escape\n\n\ndef render_highcharts_options(render_to, categories, series, title, x_axis_title, y_axis_title, series_name):\n \"\"\"Accepts the parameters ...
python
chosen
[ { "from": "system", "value": "Allow story location and section to be null\n" }, { "from": "human", "value": "import marshmallow\n\n\nclass StorySchema(marshmallow.Schema):\n id = marshmallow.fields.Int(dump_only=True)\n title = marshmallow.fields.Str(required=True)\n created = marshmall...
python
chosen
[ { "from": "system", "value": "Refactor following storage's api backend change\n" }, { "from": "human", "value": "# Copyright (C) 2015 The Software Heritage developers\n# See the AUTHORS file at the top-level directory of this distribution\n# License: GNU General Public License version 3, or any...
python
chosen
[ { "from": "system", "value": "Fix __unicode__() method in Response\n" }, { "from": "human", "value": "from django.db import models\n\nclass Query(models.Model):\n query_text = models.CharField(max_length=200)\n def __unicode__(self):\n return u'%s' % (self.query_text)\n\nclass Respo...
python
chosen
[ { "from": "system", "value": "Fix directory tests, __file__ may return relative path and now it is\ntaken into consideration\n" }, { "from": "human", "value": "import unittest\nimport tempfile\nimport os\nfrom shellpython.helpers import Dir\n\n\nclass TestDirectory(unittest.TestCase):\n\n def...
python
chosen
[ { "from": "system", "value": "Update format to produce a valid link\n" }, { "from": "human", "value": "from django.core.mail import EmailMessage\nfrom emaillist.models import EmailExclusion\n\ndef send_mail(subject, body, from_email, recipient_list, fail_silently=False):\n to = [addr for addr...
python
chosen
[ { "from": "system", "value": "Add user functionality to Pig Latin class\n" }, { "from": "human", "value": "class Pig_latin(object):\n vowels = [\"a\", \"e\" , \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"]\n\n def __init__(self, sentence):\n self.sentence = sentence\n print self...
python
chosen
[ { "from": "system", "value": "Update get_time to handle connection errors.\n" }, { "from": "human", "value": "\"\"\" app.py \"\"\"\n\nfrom flask import Flask, render_template\nimport requests\n\n\napp = Flask(__name__)\n\n\ndef get_time():\n response = requests.get('http://localhouse:3001/tim...
python
chosen
[ { "from": "system", "value": "Use six.BytesIO for Python3 compatibility\n" }, { "from": "human", "value": "import base64\nimport cStringIO\n\nimport requests\n\n\nclass Camera(object):\n def __init__(self, host):\n self.host = host\n\n def get_image(self):\n \"\"\"\n G...
python
chosen
[ { "from": "system", "value": "Update mini_installer test wrapper script.\n\nThis tracks changes made to the script in r286837.\n\nBUG=264859,399511\nR=robertshield@chromium.org\n\nReview URL: https://codereview.chromium.org/437593008\n\ngit-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@286999 0039d316-1c...
python
chosen
[ { "from": "system", "value": "Add login endpoint to URLs\n" }, { "from": "human", "value": "\"\"\"social_website_django_angular URL Configuration\n\nThe `urlpatterns` list routes URLs to views. For more information please see:\n https://docs.djangoproject.com/en/1.10/topics/http/urls/\nExampl...
python
chosen
[ { "from": "system", "value": "Implement an Optional Element function\n" }, { "from": "human", "value": "# coding=utf-8\n\nimport lxml\n\nE = lxml.objectify.ElementMaker(annotate=False)\n\nfrom openprovider.modules import customer\nfrom openprovider.modules import domain\nfrom openprovider.module...
python
chosen
[ { "from": "system", "value": "Add test for NaN input values\n" }, { "from": "human", "value": "\"\"\"\nTest the nifti_masker module\n\"\"\"\n# Author: Gael Varoquaux\n# License: simplified BSD\n\n\nimport numpy as np\n\nfrom nibabel import Nifti1Image\n\nfrom ..nifti_masker import NiftiMasker\n\...
python
chosen
[ { "from": "system", "value": "Use c-version of the selective compilation\n" }, { "from": "human", "value": "import _psyco\nimport sys\n\nticks = 0\ndepth = 10\nfuncs = {}\n\ndef f(frame, event, arg):\n if event != 'call': return\n c = frame.f_code.co_code\n fn = frame.f_code.co_name\n ...
python
chosen
[ { "from": "system", "value": "Add support for cwl1 task outputs so the name is preloaded.\nAdd preloaded file type for task outputs.\n" }, { "from": "human", "value": "from sevenbridges.models.file import File\n\n\ndef map_input_output(item, api):\n \"\"\"\n Maps item to appropriate sevebr...
python
chosen
[ { "from": "system", "value": "Add function to return URL\n" }, { "from": "human", "value": "\"\"\"handles webhook\"\"\"\nfrom typing import Any, List, Dict\n\n\nclass Handler(object):\n \"\"\"wraps webhook data\"\"\"\n\n def __init__(self: Handler, data: Dict[str, Any]) -> None:\n s...
python
chosen
[ { "from": "system", "value": "Remove an aborted test and add a docstring explaining why this test-less testcase is still here.\n" }, { "from": "human", "value": "from mock import Mock\nimport testify as T\n\nimport create_service\n\n\nclass SrvReaderWriterTestCase(T.TestCase):\n @T.setup\n ...
python
chosen
[ { "from": "system", "value": "Disable reloader. It messes with plugins.\n" }, { "from": "human", "value": "#!/usr/bin/python\nfrom optparse import OptionParser\nfrom sys import stderr\nimport pytz\nfrom werkzeug import script\nfrom werkzeug.script import make_runserver\n\nfrom firmant.wsgi impo...
python
chosen
[ { "from": "system", "value": "Fix opps template engine (name list) on DetailView\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django.core.exceptions import ImproperlyConfigured\nfrom django.views.generic.detail import DetailView as DjangoDetailView\nfro...
python
chosen
[ { "from": "system", "value": "Make the destination directory if it does not exist\n" }, { "from": "human", "value": "\nfrom subprocess import check_call\nimport urllib\nimport json\nimport os\nimport os.path\n\ndef install():\n with open('.bowerrc') as f:\n bowerrc = json.load(f)\n ...
python
chosen
[ { "from": "system", "value": "Make the FetchedValue marked as for_update\n\nSQLAlchemy is currently unable to determine between a FetchedValue\ninside of a server_default and one inside of a server_onupdate\ncausing the one in server_onupdate to override the func.now()\nin server_default.\n\nSee: http://www...
python
chosen
[ { "from": "system", "value": "Return None on missing object\n" }, { "from": "human", "value": "from tornado.concurrent import return_future\nfrom gcloud import storage\nfrom collections import defaultdict\n\nbuckets = defaultdict(dict)\n\n@return_future\ndef load(context, path, callback):\n b...
python
chosen
[ { "from": "system", "value": "Fix bad syntax in query\n\nthe query is not correct because of semicolon\n" }, { "from": "human", "value": "# Copyright 2019 Eficent <http://www.eficent.com>\n# Copyright 2019 Tecnativa - Pedro M. Baeza\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl....
python
chosen
[ { "from": "system", "value": "Check for some required settings\n" }, { "from": "human", "value": "import logging\nlog = logging.getLogger(__name__)\n\nfrom pyramid.config import Configurator\nfrom sqlalchemy import engine_from_config\n\n\n\ndef main(global_config, **settings):\n \"\"\" This f...
python
chosen
[ { "from": "system", "value": "Add a failing, coverage-increasing test\n" }, { "from": "human", "value": "\nfrom fastats.core.decorator import fs\nfrom tests import cube\n\n\ndef child(x):\n return x * x\n\n\n@fs\ndef parent(a):\n b = 2 * a\n result = child(b)\n return result\n\n\ndef...
python
chosen
[ { "from": "system", "value": "Fix courses by user url\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Copyright 2012-2013 UNED\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 obta...
python
chosen
[ { "from": "system", "value": "Use the response.context to check the provided start and end\n" }, { "from": "human", "value": "import django.test\nfrom search.models import Project\n\nclass NonJavascriptSearch(django.test.TestCase):\n fixtures = ['bugs-for-two-projects.json']\n\n def testSe...
python
chosen
[ { "from": "system", "value": "Fix and add tests for datastore.inmemory\n" }, { "from": "human", "value": "import unittest\n\nfrom ..inmemory import (\n DataValueInMemory, DataStreamInMemory, DataStoreNestableInMemory)\nfrom .mixintestcase import (\n MixInValueTestCase, MixInStreamTestCase,...
python
chosen
[ { "from": "system", "value": "Put in a try for shares function\n" }, { "from": "human", "value": "import requests\n\ndef tweets(url):\n api = \"http://urls.api.twitter.com/1/urls/count.json?url=\"\n respobj = requests.get(api + url)\n adict = respobj.json()\n return adict[\"count\"]\n\ndef p...
python
chosen
[ { "from": "system", "value": "Fix http->https for the API\n" }, { "from": "human", "value": "import slumber\nimport json\nimport logging\n\nfrom django.conf import settings\n\nlog = logging.getLogger(__name__)\n\nUSER = getattr(settings, 'SLUMBER_USERNAME', None)\nPASS = getattr(settings, 'SLUMB...
python
chosen
[ { "from": "system", "value": "Fix for non-DRMAA cluster run\n" }, { "from": "human", "value": "\nimport pubrunner\nimport os\nimport shlex\nimport subprocess\n\ndef launchSnakemake(snakeFilePath,useCluster=True,parameters={}):\n\tglobalSettings = pubrunner.getGlobalSettings()\n\t\n\tclusterFlags...
python
chosen
[ { "from": "system", "value": "Fix migration to work with flows with no base_language\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.5 on 2017-04-19 14:53\nfrom __future__ import unicode_literals\n\nimport json\nimport temba.utils.models\n\nfrom django.cont...
python
chosen
[ { "from": "system", "value": " Correct style of wheels exercise\n" }, { "from": "human", "value": "\"\"\"Simple exercise file where the kid must write code.\n\nControl the LED light in the finch robot with this small exercise. The code\ndoesn't run as it is because a kid is supposed to complete ...
python
chosen
[ { "from": "system", "value": "Add test for year_to_now with non-integer values" }, { "from": "human", "value": "from datetime import date\nfrom django.test import TestCase\nfrom django.core.exceptions import ValidationError\nfrom contacts.validators import year_to_now\n\n\ntoday = date.today()\n...
python
chosen
[ { "from": "system", "value": "Implement validation for structure and topology\nfiles." }, { "from": "human", "value": "from rest_framework import serializers\nfrom django.contrib.auth.models import User\nfrom .models import Job, Result\n\n\nclass ResultSerializer(serializers.HyperlinkedModelSeri...
python
chosen
[ { "from": "system", "value": "Add last_updated field to RSSContent\n" }, { "from": "human", "value": "from django.db import models\nfrom django.utils.safestring import mark_safe\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.template.loader import render_to_string\n\nimpor...
python
chosen
[ { "from": "system", "value": "Increase version number to 0.4.0 - fix\n" }, { "from": "human", "value": "from unittest import TestCase\n\nfrom sacredboard.app.sacredboard import Sacredboard\n\n\nclass TestSacredboard(TestCase):\n def test_get_version(self):\n assert Sacredboard.get_vers...
python
chosen
[ { "from": "system", "value": "Update the version to 1.7.1\n" }, { "from": "human", "value": "__version_info__ = {\n 'major': 1,\n 'minor': 7,\n 'micro': 0,\n 'releaselevel': 'final',\n 'serial': 1\n}\n\n\ndef get_version(short=False):\n assert __version_info__['releaselevel'] i...
python
chosen
[ { "from": "system", "value": "Fix missed plugin code update.\n\nThis `Meta` business is from an earlier draft.\n" }, { "from": "human", "value": "import requests\nfrom collections import defaultdict\nfrom requests.exceptions import RequestException\n\nfrom django.conf import settings\nfrom djang...
python
chosen
[ { "from": "human", "value": "Add copyright notice, skip docstring checks" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\r\n#\r\n# Copyright © 2017 Spyder Project Contributors\r\n# Licensed under the terms of the MIT License\r\n# (see LICENSE.txt for details)\r\n\r\n# noqa: D104\r\n" } ...
python
chosen
[ { "from": "system", "value": "Add initial resize and rotate, no tests yet\n" }, { "from": "human", "value": "\"\"\"\n\"\"\"\n\n\ndef resize(parameters):\n pass\n\n\ndef rotate(parameters):\n pass\n\n\n" }, { "from": "gpt", "value": "\"\"\"Geometric transformations on arrays. Th...
python
chosen
[ { "from": "system", "value": "Update EchoServer to keep connection open until client shutsdown connection in order to collect all requests\n" }, { "from": "human", "value": "import socket\n\n\nclass EchoServer(object):\n \"\"\"a simple EchoServer\"\"\"\n def __init__(self, ip=u'127.0.0.1',...
python
chosen
[ { "from": "system", "value": "Modify Hero :: Life + 2\n" }, { "from": "human", "value": "#-*- coding: utf-8 -*-\n\nfrom lib.base_entity import BaseEntity\nfrom lib.base_animation import BaseAnimation\nfrom pygame.locals import K_UP as UP\n\n\nclass HeroAnimation(BaseAnimation):\n \"\"\"Custom...
python
chosen
[ { "from": "system", "value": "Make compatible with Django 1.9\n" }, { "from": "human", "value": "from django.conf.urls import patterns, url\n\nfrom .views import NoticeSettingsView\n\n\nurlpatterns = patterns(\n \"\",\n url(r\"^settings/$\", NoticeSettingsView.as_view(), name=\"notificatio...
python
chosen
[ { "from": "system", "value": "Work around a minor bug in ConsoleEchoer - yield before sending a\ncomplete message.\n" }, { "from": "human", "value": "from Axon.Component import component\nfrom Axon.Ipc import producerFinished, shutdownMicroprocess, shutdown\n\nclass DataSource(component):\n d...
python
chosen
[ { "from": "system", "value": "Add support for absolute URL in request\n" }, { "from": "human", "value": "from ..darkobject import DarkObject\nfrom bs4 import BeautifulSoup\nimport logging\nimport time\n\n\nfrom urllib.request import urlopen\n\n\nclass Scrubber(DarkObject):\n def __init__(self...
python
chosen
[ { "from": "system", "value": "Sort keys in JSON fetcher for consistent results" }, { "from": "human", "value": "import json\n\nimport requests\n\n\ndef simple(conf):\n url = conf['url']\n output_format = conf.get('format', 'html')\n response = requests.get(url)\n if output_format == ...
python
chosen
[ { "from": "system", "value": "Update KolibriTagNavigationTestCase to handle new redirect method\n" }, { "from": "human", "value": "from __future__ import absolute_import, print_function, unicode_literals\n\nfrom django.core.urlresolvers import reverse\nfrom rest_framework.test import APITestCase...
python
chosen
[ { "from": "system", "value": "Set sleep times to zero for tests\n" }, { "from": "human", "value": "import logging\n\nfrom autostew_back.tests.test_assets import prl_s4_r2_zolder_casual\n\nlogging.getLogger().setLevel(logging.INFO)\nlogging.getLogger('django.db.backends').setLevel(logging.INFO)\n...
python
chosen
[ { "from": "system", "value": "Allow custom session object for the requests backend.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport requests\n\n\nclass HttpClient(object):\n \"\"\"A HTTP client using requests\"\"\"\n\n default_options = dict(verify=False, allow_redirects...
python
chosen
[ { "from": "system", "value": "Update for api change with linter_configs.\n" }, { "from": "human", "value": "from imhotep.tools import Tool\nfrom collections import defaultdict\nimport re\n\n\nclass JSL(Tool):\n regex = re.compile(\n r'^(?P<type>[WE]) '\n r'(?P<filename>.*?) L(?P...
python
chosen
[ { "from": "system", "value": "Support an option to ignore zeros while calculating thresholds\n\nBased on the results, the default should be to ignore\n" }, { "from": "human", "value": "# Techniques for outlier detection of speeds. Each of these returns a speed threshold that \n# can be used with...
python
chosen
[ { "from": "system", "value": "Add the missing data for ichimoku with additional data fed\n" }, { "from": "human", "value": "import pandas as pd\nimport numpy as np\nimport os\n#from ta import ichimoku\nfrom util import get_data, plot_data\n\nfrom pandas import DataFrame, Series\nfrom technical_a...
python
chosen
[ { "from": "system", "value": "Move lockfile to root datadir.\n" }, { "from": "human", "value": "DATADIR = \"data/\"\nTRACKDIR = DATADIR + \"tracks/\"\nLOCKFILE = TRACKDIR + \"current_experiment.lock\"\nPLOTDIR = DATADIR + \"plots/\"\nARCHIVEDIR = DATADIR + \"tracks_archive/\"\nDBGFRAMEDIR = DATA...
python
chosen
[ { "from": "system", "value": "Add IMF to the fetchers\n" }, { "from": "human", "value": "#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\nfrom . import eurostat, insee, world_bank\n" }, { "from": "gpt", "value": "#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\nfrom . import eurost...
python
chosen
[ { "from": "system", "value": "Create session if one doesn't exist\n" }, { "from": "human", "value": "from lightning import Lightning\n\n\ndef viztype(VizType):\n\n def plotter(self, *args, **kwargs):\n viz = VizType.baseplot(self.session, VizType._name, *args, **kwargs)\n self.s...
python
chosen
[ { "from": "system", "value": "Remove unused org member in factory\n" }, { "from": "human", "value": "import factory\n\nfrom bluebottle.organizations.models import OrganizationContact, Organization, OrganizationMember\nfrom .geo import CountryFactory\nfrom .accounts import BlueBottleUserFactory\n...
python
chosen
[ { "from": "system", "value": "Make logger sort by date\n" }, { "from": "human", "value": "import sys\nimport os\nimport logging\nimport time\n\nif not os.path.exists(os.path.expanduser(\"~/.chatserver\")):\n os.makedirs(os.path.expanduser(\"~/.chatserver\"))\nlogging.basicConfig(filename=os.p...
python
chosen
[ { "from": "system", "value": "Use PostGenerationMethodCall instead of _prepare.\n" }, { "from": "human", "value": "import factory\n\nfrom django.contrib.auth import get_user_model\n\n\nclass UserFactory(factory.DjangoModelFactory):\n FACTORY_FOR = get_user_model()\n name = factory.Sequence...
python
chosen
[ { "from": "system", "value": "Stop exception if someone calls timeouts from a timeout.\n" }, { "from": "human", "value": "import sys\nfrom collections import defaultdict\nimport time\n\n\ntimeouts = defaultdict(list)\ntop_timeout_id = 0\ncancelled_timeouts = set()\n\n\ndef windows(*args, **kwarg...
python
chosen
[ { "from": "system", "value": "Change mobile's HTTP port to 13000 and TCP port to 13001" }, { "from": "human", "value": "CAMERA_NETWORK_IP = '0.0.0.0'\nCAMERA_NETWORK_TCP_PORT = 9090\n\nMOBILE_NETWORK_IP = '0.0.0.0'\nMOBILE_NETWORK_HTTP_PORT = 80\nMOBILE_NETWORK_TCP_PORT = 13000\n" }, { "...
python
chosen
[ { "from": "system", "value": "Add url for media files\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\n\n# Uncomment the next two lines to enable the admin:\nfrom django.contrib import admin\nadmin.autodiscover()\n\nurlpatterns = patterns('',\n # Example...
python
chosen
[ { "from": "system", "value": "Update to use new RSF `append-entry` format\n" }, { "from": "human", "value": "import sys\nfrom datetime import datetime\nimport json\nimport hashlib\n\n\ndef print_rsf(item, key_field):\n key = item[key_field]\n timestamp = datetime.utcnow().strftime('%Y-%m-%...
python
chosen
[ { "from": "system", "value": "[IMP] Rename state of SO according to LO and Cost Estimate\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom openerp.osv import orm, fields\n\n\nclass sale_order(orm.Model):\n _inherit = 'sale.order'\n\n _columns = {\n # override only t...
python
chosen
[ { "from": "system", "value": "Add string and snowflake identifier union.\n" }, { "from": "human", "value": "class SnowflakeID(int):\n \"\"\"\n Represents a Discord Snowflake ID.\n \"\"\"\n pass\n" }, { "from": "gpt", "value": "from typing import Union\n\n\nclass Snowflake...
python
chosen
[ { "from": "system", "value": "Clean up the template tags module a bit.\n" }, { "from": "human", "value": "from django import template\n\nfrom soapbox.models import Message\n\n\nregister = template.Library()\n\n\nclass MessagesForPageNode(template.Node):\n def __init__(self, url, varname):\n ...
python
chosen
[ { "from": "system", "value": "Sort new cmd: allow empty separator\n" }, { "from": "human", "value": "from cudatext import *\n\ndef _sort(s, sep_k, sep_v):\n\n if not sep_k in s:\n return s\n key, val = s.split(sep_k, 1)\n vals = sorted(val.split(sep_v))\n return key+sep_k+sep_...
python
chosen
[ { "from": "system", "value": "[AC-5625] Remove dead code and minor refactor\n" }, { "from": "human", "value": "# MIT License\n# Copyright (c) 2017 MassChallenge, Inc.\n\nfrom django.db.models import Q\nfrom impact.v1.helpers.criterion_helper import CriterionHelper\n\n\nclass MatchingCriterionHel...
python
chosen
[ { "from": "system", "value": "Rename FLASH_CONFIG to match common convention\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os\nfrom app import create_app\nfrom flask.ext.script import Manager, Server\n\napplication = create_app(os.getenv('FLASH_CONFIG') or 'default')\nmanage...
python
chosen
[ { "from": "system", "value": "Disable ip_forward in the Pax Mininet node class\n\n" }, { "from": "human", "value": "# coding: latin-1\n\n\"\"\"\npax_mininet_node.py: Defines PaxNode which allows Pax to behave as the sole packet hander on a node.\n\"\"\"\n\nfrom mininet.node import Node\nfrom min...
python
chosen
[ { "from": "system", "value": "Add response if no topics are set\n" }, { "from": "human", "value": "import logging\nimport time\nimport os\n\nimport boto3\nfrom boto3.dynamodb.conditions import Key, Attr\n\ndynamodb = boto3.resource('dynamodb')\n\ndef build_response(message):\n topics = \"\"\n...
python
chosen
[ { "from": "system", "value": "Add option tu run piped commands\n" }, { "from": "human", "value": "import os\nimport subprocess\nimport errno\n\ndef cmd_pwd(*args):\n return subprocess.check_output(['pwd'])\n\ndef cmd_ls(*args):\n return subprocess.check_output(*args)\n\ndef cmd_cd(*args):\...
python
chosen
[ { "from": "system", "value": "Add CSV and JSON parsing.\n" }, { "from": "human", "value": "\"\"\" Send messages via an HTTP API (nostream) conversation. \"\"\"\n\nimport click\n\nfrom go_http.send import HttpApiSender\n\n\n@click.option(\n '--conversation', '-c',\n help='HTTP API conversat...
python
chosen
[ { "from": "system", "value": "Print encrypted records for debugging.\n" }, { "from": "human", "value": "#! /usr/bin/env python3\n\nimport sqlite3\nimport bcrypt\nimport hashlib\nfrom Crypto.Cipher import AES\nimport codecs\nimport json\nfrom password import encrypt, decrypt, toHex, fromHex\n\npw...
python
chosen
[ { "from": "system", "value": "Rename list_flavors flavors in example\n\nChange-Id: Idf699774484a29fa9e9bb1bf654ed00d6ca9907d\n" }, { "from": "human", "value": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. ...
python
chosen
[ { "from": "system", "value": "Allow for \":\" in argument values (only split args on first occurence of \":\".\n" }, { "from": "human", "value": "from collections import defaultdict\n\n\n\n# get_args_dict()\n#_______________________________________________________________________________________...
python
chosen
[ { "from": "system", "value": "Fix a couple of PEP8 issues\n" }, { "from": "human", "value": "import os\nimport csv\n\nclass CSVFile(object):\n def __init__(self, path, values):\n self.path = path\n self.values = values\n\n def write(self, results):\n field_names = self...
python
chosen
[ { "from": "system", "value": "Prepend “Mc” to expected exception name\n" }, { "from": "human", "value": "from nose.tools import assert_raises\n\nfrom mediawords.db.schema.version import *\n\n\ndef test_schema_version_from_lines():\n assert_raises(SchemaVersionFromLinesException, schema_versio...
python
chosen
[ { "from": "system", "value": "Fix the travis issues 2\n" }, { "from": "human", "value": "#\n# linter.py\n# Linter for SublimeLinter3, a code checking framework for Sublime Text 3\n#\n# Written by Tomas Krehlik\n# Copyright (c) 2014 Tomas Krehlik\n#\n# License: MIT\n#\n\n\"\"\"This module exports...
python
chosen
[ { "from": "system", "value": "MarkdownBear: Add test to check message for error\n\nA better test for MarkdownBear to check the exact message\nof the result for a maximum line length error.\n\nRelated to https://github.com/coala/coala-bears/issues/1235\n" }, { "from": "human", "value": "from bear...
python
chosen
[ { "from": "system", "value": "Use dominate to render comments as well.\n" }, { "from": "human", "value": "from flask import current_app\n\nfrom dominate import tags\nfrom visitor import Visitor\n\n\nclass BaseRenderer(Visitor):\n def visit_object(self, node):\n if current_app.debug:\n ...
python
chosen