conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Fix non ascii symbols in json\n" }, { "from": "human", "value": "\"\"\" Data layer \"\"\"\n# pylint: disable=line-too-long\nimport json\nimport os\nfrom frontui.models import ChecklistInfo\n\n\nclass DataProvider:\n \"\"\" Data provider (objects, questions, etc) ...
python
chosen
[ { "from": "system", "value": "Support __in as operator for backwards comp\n" }, { "from": "human", "value": "\nEQUALS = 'equals'\nGT = 'gt'\nLT = 'lt'\n\nOPERATOR_SEPARATOR = '__'\nREVERSE_ORDER = '-'\n\nALL_OPERATORS = {EQUALS: 1, GT: 1, LT: 1}\n\n\ndef split_to_field_and_filter_type(filter_nam...
python
chosen
[ { "from": "system", "value": "Change sanitizer to normal model sanitizer, so it sends ids of parents.\n" }, { "from": "human", "value": "from rest_framework import serializers\nfrom .models import Animal\n\nclass AnimalSerializer(serializers.HyperlinkedModelSerializer):\n class Meta:\n ...
python
chosen
[ { "from": "system", "value": "Make gateway importable without django-oscar installed.\n" }, { "from": "human", "value": "from oscar.apps.payment.exceptions import PaymentError\n\n\nclass PayPalError(PaymentError):\n pass\n" }, { "from": "gpt", "value": "try:\n from oscar.apps.p...
python
chosen
[ { "from": "system", "value": "ZA: Add PlaceIndex to the Haystack EXCLUDED_INDEXES\n\nThis was a mistake in the earlier rearrangement of the settings\nmodules; PlaceIndex needed to be added to Haystack EXCLUDED_INDEXES\nin the south_africa module as well as tests_south_africa.\n" }, { "from": "human"...
python
chosen
[ { "from": "system", "value": "Fix bug in chunk arguments\n" }, { "from": "human", "value": "from django.conf import settings\nimport re\nimport sys\n\n\nclass DisposableEmailChecker():\n \"\"\"\n Check if an email is from a disposable\n email service\n \"\"\"\n \n def __init__(...
python
chosen
[ { "from": "system", "value": "Allow venv segment to be from Anaconda\n" }, { "from": "human", "value": "import os\n\ndef add_virtual_env_segment():\n env = os.getenv('VIRTUAL_ENV')\n if env is None:\n return\n\n env_name = os.path.basename(env)\n bg = Color.VIRTUAL_ENV_BG\n ...
python
chosen
[ { "from": "system", "value": "Fix ib_broker import from brokers\n" }, { "from": "human", "value": "#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http:...
python
chosen
[ { "from": "system", "value": "Fix issue with daylight saving time + utcnow\n\nFixes issue #2\n" }, { "from": "human", "value": "\"\"\"\npatched builtin time classes for use by :class:`hiro.Timeline`\n\"\"\"\nimport abc\nfrom datetime import date as realdate\nfrom datetime import datetime as real...
python
chosen
[ { "from": "system", "value": "Remove ununsed pickle code for instance methods\n" }, { "from": "human", "value": "\"\"\"\nSome extra picklers needed to gracefully dump and load a canvas.\n\"\"\"\n\nimport copyreg\nimport types\n\nimport cairo\nfrom future import standard_library\n\nstandard_libra...
python
chosen
[ { "from": "system", "value": "Improve url patterns structure, enable debugging common error pages while debugging\n" }, { "from": "human", "value": "\"\"\"{{project_name}} URL Configuration\n\nThe `urlpatterns` list routes URLs to views. For more information please see:\n https://docs.djangop...
python
chosen
[ { "from": "system", "value": "Change indentation to 2 spaces\n" }, { "from": "human", "value": "from constants import *\n\nclass Buffer:\n \"\"\"Stores data, buffers it and sends it to the Framer\"\"\"\n def __init__(self):\n self.buffer = []\n self.callback = None\n\n def...
python
chosen
[ { "from": "system", "value": "Fix for patterns() being deprecated and now removed in Django 1.10" }, { "from": "human", "value": "import os\n\nfrom django.conf.urls import patterns, url\n\nfrom .conf import settings\nfrom .views import index, page, edit, file_download, file_upload\n\nurlpatterns...
python
chosen
[ { "from": "system", "value": "Remove URL from Spotify response\n" }, { "from": "human", "value": "from plugins.util import command, get_url\nimport json\nimport re\n\nSPOTIFY_URI_REGEX = r\"(?<=spotify:)(?:track|album|artist):[a-zA-Z0-9]{22}\"\nENDPOINT = \"https://api.spotify.com/v1/{0}s/{1}\"\...
python
chosen
[ { "from": "system", "value": "Test Widget: added support for displaying raw json\n" }, { "from": "human", "value": "from django.contrib import admin\nfrom kinetic_widget.models import *\n\n\nadmin.site.register(TestWidgetSimple)\nadmin.site.register(TestWidgetMulti)\n" }, { "from": "gpt"...
python
chosen
[ { "from": "system", "value": "Bump statbot version to 0.4.0\n" }, { "from": "human", "value": "#\n# __init__.py\n#\n# statbot - Store Discord records for later analysis\n# Copyright (c) 2017 Ammon Smith\n#\n# statbot is available free of charge under the terms of the MIT\n# License. You are free...
python
chosen
[ { "from": "system", "value": "TMS-240: Allow search script to report the query & results.\n\nIn addition search conditions are now specified using a <field>:<term>\nnotation:\n\n $ work/zope/bin/search-solr --verbose \"authors:Klaus Mustermann\"\n $ work/zope/bin/search-elastic --verbose \"fulltext:Klaus ...
python
chosen
[ { "from": "system", "value": "Fix problem with repeating rows. Good data on 3x3.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2014 Google Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you ...
python
chosen
[ { "from": "system", "value": "Implement export data to json test\n" }, { "from": "human", "value": "from createCollection import createCollection\nfrom ObjectFactories.albumFactory import AlbumFactory\nfrom ObjectFactories.bookFactory import BookFactory\nfrom ObjectFactories.itemFactory import I...
python
chosen
[ { "from": "system", "value": "Fix detail in one of the common tests\n\nThe value returned by the submit will not necessarily be truish.\n" }, { "from": "human", "value": "from unittest import TestCase\nfrom lie2me import Field\n\n\nclass CommonTests(object):\n\n def get_instance(self):\n ...
python
chosen
[ { "from": "system", "value": "Add lots of useful default imports to ipython\n" }, { "from": "human", "value": "import scipy as sp\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\n" }, { "from": "gpt", "value": "from __future__ import division\nfrom __future_...
python
chosen
[ { "from": "system", "value": "Add option for name and path of cloudConfig.yml file\n\nThis change adds a command line option to the dns script to specify\nthe name and location of the `cloudConfig.yml` file.\n\nSigned-off-by: Nicolas Bock <4ad6fd604400c7892c7a2cb53bf674987bcaa405@suse.com>\n" }, { "...
python
chosen
[ { "from": "system", "value": "Add public API entties from 'bigquery.table'.\n" }, { "from": "human", "value": "# Copyright 2015 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 compliance with the Lice...
python
chosen
[ { "from": "system", "value": "Set size on wishlist line quantity form field\n\nThis doesn't actually work since there is an overriding CSS style. When\nissue #851 is resolved, this should start working.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django import forms\nfrom d...
python
chosen
[ { "from": "system", "value": "Remove redirect to avoid Chrome privacy error\n" }, { "from": "human", "value": "from flask import Flask, render_template, request, redirect\nimport requests\nimport pandas as pd\nfrom datetime import datetime\nfrom bokeh.plotting import figure, output_notebook, out...
python
chosen
[ { "from": "system", "value": "Tweak a test so it fails more usefully when mocking doesn't work, heh\n" }, { "from": "human", "value": "from invoke import ctask\n\n\n@ctask\ndef go(ctx):\n return ctx\n\n\n@ctask\ndef run(ctx):\n ctx.run('x')\n" }, { "from": "gpt", "value": "from...
python
chosen
[ { "from": "system", "value": "Remove requirement on presence of config file\n\nThe NipapConfig object required the presence of a configuration file. As\nit is benficial to be able to load the NipapConfig without a\nconfiguration file (for example when building docs using Sphinx), this\nrequirement has been ...
python
chosen
[ { "from": "system", "value": "Update unittest to check get_current_questions\n" }, { "from": "human", "value": "import unittest\nimport context\n\nfrom srvy.srvy import get_current_questions\n\n\nclass MyTest(unittest.TestCase):\n def setUp(self):\n self.questions = [\"Question 1?\", \...
python
chosen
[ { "from": "system", "value": "Update release version to 0.1.6\n" }, { "from": "human", "value": "\"\"\"\nA flat file database for json objects.\n\"\"\"\n\nfrom .db import Database\n\n__version__ = '0.1.5'\n__author__ = 'Gunther Cox'\n__email__ = 'gunthercx@gmail.com'\n__url__ = 'https://github.c...
python
chosen
[ { "from": "system", "value": "Load .so if not on Crap OS X\n" }, { "from": "human", "value": "import ctypes\n\n__all__ = [\"pbkdf2\"]\n\nlibssl = ctypes.CDLL(\"libssl.dylib\")\nlibssl.PKCS5_PBKDF2_HMAC_SHA1.restype = ctypes.c_int\n\ndef cBuf(data):\n\treturn ctypes.create_string_buffer(data, len...
python
chosen
[ { "from": "system", "value": "4: Create script to save documentation to a file \n\nTask-Url: http://github.com/stoeps13/ibmcnx2/issues/issue/4" }, { "from": "human", "value": "######\n# Create a file (html or markdown) with the output of\n# - JVMHeap\n# - LogFiles\n# - Ports\n# ...
python
chosen
[ { "from": "system", "value": "Add clean and travel to operate" }, { "from": "human", "value": "# coding=utf-8\n\nimport node_locate\nimport node_filter\n\nimport node_select\nimport node_update\nimport node_delete\nimport node_insert\nimport node_script\n\ndef select(node, path, action=None):\n ...
python
chosen
[ { "from": "system", "value": "Add tailing / to APT_REPO_BASE_URL\n" }, { "from": "human", "value": "#\n# Copyright 2012 Cisco Systems, Inc.\n#\n# Author: Soren Hansen <sorhanse@cisco.com>\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file...
python
chosen
[ { "from": "system", "value": "Test for expected flags with serde tests\n" }, { "from": "human", "value": "from unittest import TestCase\n\nfrom pymemcache.serde import (python_memcache_serializer,\n python_memcache_deserializer)\nimport pytest\nimport six\n\n\n@pytes...
python
chosen
[ { "from": "system", "value": "Add multi cursor test currently failed.\n" }, { "from": "human", "value": "from pymysql.tests import base\nfrom pymysql import util\n\n\nclass TestNextset(base.PyMySQLTestCase):\n\n def setUp(self):\n super(TestNextset, self).setUp()\n self.con = se...
python
chosen
[ { "from": "system", "value": "Handle errors in cron notifications\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django.core.management.base import BaseCommand, CommandError\nfrom api import models\nfrom web.utils import send_email\n\nclass Command(BaseCommand):\n can_import...
python
chosen
[ { "from": "system", "value": "fix(kakao): Handle case where email is not present\n\n" }, { "from": "human", "value": "from allauth.account.models import EmailAddress\nfrom allauth.socialaccount.providers.base import ProviderAccount\nfrom allauth.socialaccount.providers.oauth2.provider import OAu...
python
chosen
[ { "from": "system", "value": "Make the '--add-home-links' option work for any value that evaluates to a bool\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport logging\n\nfrom django.core.management.base import BaseCommand\n\nfrom wagtail.wagtailcore.models import Site\nfrom wagt...
python
chosen
[ { "from": "system", "value": "Change name of the wsgi-object to match what uwsgi\n" }, { "from": "human", "value": "#! /usr/bin/env python2.7\n\nimport cherrypy\nimport medlem\n\nwsgiapp = cherrypy.Application(medlem.Medlem(), '/', config=\"config/production.conf\")\n" }, { "from": "gpt"...
python
chosen
[ { "from": "system", "value": "Increase version number to update pipy\n" }, { "from": "human", "value": "import compare_mt.ngram_utils\nimport compare_mt.stat_utils\nimport compare_mt.corpus_utils\nimport compare_mt.sign_utils\nimport compare_mt.scorers\nimport compare_mt.bucketers\nimport compar...
python
chosen
[ { "from": "system", "value": "Update console module with new cli names\n" }, { "from": "human", "value": "from .info import main as info\nfrom .printer import main as printer\nfrom .shifty import main as shifty\nfrom .snifty import main as snifty\nfrom .status import main as status\n\n\n(\n i...
python
chosen
[ { "from": "system", "value": "DOC: Fix labeling on plots so it matches elements.\n" }, { "from": "human", "value": "\"\"\"\n================\nPlot `errorfill`\n================\n\nWhen you have continuous data measurement and errors associated with every data point, plotting error bars can get r...
python
chosen
[ { "from": "system", "value": "Revert \"Add own tuple_index function to stay compatible with python 2.5\"\n\nThis reverts commit 7e6af723e15a785b403010de4b44b49fce924e91.\n" }, { "from": "human", "value": "from social_auth.backends import PIPELINE\nfrom social_auth.utils import setting\n\n\nPIPEL...
python
chosen
[ { "from": "system", "value": "Fix user and attempts sqlalchemia request.\n" }, { "from": "human", "value": "# Copyright 2016 Mirantis, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may...
python
chosen
[ { "from": "system", "value": "Use XDG base directory specificiation\n" }, { "from": "human", "value": "\"\"\"\nThis module handles creation of the user-data area\n\"\"\"\nimport os\nimport tempfile\nimport atexit\n\n\nDATA_ROOT = None\nif os.getenv('ROOTPY_GRIDMODE') not in ('1', 'true'):\n D...
python
chosen
[ { "from": "system", "value": "Fix bug some log output showing on screen not present in log file by changing logging file handler mode from 'w' write to 'a' append.\n" }, { "from": "human", "value": "# https://docs.python.org/3.6/howto/logging.html#logging-basic-tutorial\nimport logging\nimport s...
python
chosen
[ { "from": "system", "value": "Add comments to Python version\n" }, { "from": "human", "value": "import sys, math, random\n\nif len(sys.argv) > 1:\n\tcandidate = eval(sys.argv[1])\nelse:\n\tcandidate = 221\n\nmodulo = candidate - 1\ns = -1\nquotient = modulo\nremainder = 0\nwhile remainder == 0:\...
python
chosen
[ { "from": "system", "value": "Add custom rangers to slider\n" }, { "from": "human", "value": "from unittest.mock import patch\n\nfrom rcfc import server, input_methods\nfrom test_helpers import IgnoredArgument\n\ninput_value = 0\n\n\ndef set_input_value(val):\n global input_value\n input_v...
python
chosen
[ { "from": "system", "value": "Fix bug in unit test (ignore header row in output csv file)\n" }, { "from": "human", "value": "import os\nimport numpy as np\nimport crepe\n\n\ndef test_sweep():\n # this data contains a sine sweep\n file = os.path.join(os.path.dirname(__file__), 'sweep.wav')\...
python
chosen
[ { "from": "system", "value": "Disable Django-CMS test on Django 1.10+\n\nSomeone with the time and inclination should set up the test to work with a Django-CMS version compatible with Django 1.10+, then try again\n" }, { "from": "human", "value": "from django.contrib.auth.models import Anonymous...
python
chosen
[ { "from": "system", "value": "Remove pymvpa from documentation build.\n\ngit-svn-id: 24f545668198cdd163a527378499f2123e59bf9f@931 ead46cd0-7350-4e37-8683-fc4c6f79bf00\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"Script to auto-generate our API docs.\n\"\"\"\n# stdlib imports\n...
python
chosen
[ { "from": "system", "value": "Add simple tests for matrix operands for distance measure.\n" }, { "from": "human", "value": "import numpy as np\n\nimport nearpy.distances\n\n\nclass MatrixCosineDistance(nearpy.distances.CosineDistance):\n \"\"\"\n A distance measure for calculating the cosi...
python
chosen
[ { "from": "system", "value": "Tests: Enhance construct test to avoid local variable optimization.\n" }, { "from": "human", "value": "# Copyright 2015, Kay Hayen, mailto:kay.hayen@gmail.com\n#\n# Python test originally created or extracted from other peoples work. The\n# parts from me...
python
chosen
[ { "from": "system", "value": "Add group/job info to job dashboard\n\nSigned-off-by: Salim Alam <18ae4dd1e3db1d49a738226169e3b099325c79a0@chef.io>\n" }, { "from": "human", "value": "import time\nfrom datetime import datetime\n\ndef my_log_parser(logger, line):\n if line.count(',') >= 6:\n ...
python
chosen
[ { "from": "system", "value": "Make sure the aggregate service only using the IDirectoryService interface when interactive with its sub-services.\n\n\ngit-svn-id: 81e381228600e5752b80483efd2b45b26c451ea2@10781 e27351fd-9f3e-4f54-a53b-843176b1656c\n" }, { "from": "human", "value": "##\n# Copyright...
python
chosen
[ { "from": "system", "value": "Fix bug in copy_glob when destination directory already has files\n" }, { "from": "human", "value": "import glob\nimport shutil\nimport os\n\nif os.name == \"nt\":\n from .ntcommonpath import commonpath\nelse:\n from .posixcommonpath import commonpath\n\ndef m...
python
chosen
[ { "from": "system", "value": "Use command-line arguments for paths.\n" }, { "from": "human", "value": "#!/usr/bin/python\n\nfrom pyspark import SparkContext\nfrom pyspark.sql import SQLContext, Row\nfrom pyspark.sql.functions import asc, desc\n\nif __name__ == \"__main__\":\n sc = SparkContext(...
python
chosen
[ { "from": "system", "value": "Replace placeholders with actual app name\n" }, { "from": "human", "value": "# encoding: utf-8\nimport datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\nclass Migration(SchemaMigration):\n\n def forwards(self...
python
chosen
[ { "from": "system", "value": "Fix Invoke doc intersphinx path (and tweak formatting)\n" }, { "from": "human", "value": "# Obtain shared config values\nimport os, sys\nfrom os.path import abspath, join, dirname\nsys.path.append(abspath(join(dirname(__file__), '..')))\nsys.path.append(abspath(join...
python
chosen
[ { "from": "system", "value": "Change ordering to FeaturedRep model.\n" }, { "from": "human", "value": "from django.contrib.auth.models import User\nfrom django.db import models\nfrom django.dispatch import receiver\n\nfrom south.signals import post_migrate\n\nfrom remo.base.utils import add_perm...
python
chosen
[ { "from": "system", "value": "Fix download link , again\n" }, { "from": "human", "value": "import copy\n\nfrom django import template\nfrom django.conf import settings\n\nfrom games import models\n\nregister = template.Library()\n\n\ndef get_links(user_agent):\n systems = ['ubuntu', 'fedora',...
python
chosen
[ { "from": "system", "value": "Add check for args which are already quotes\n" }, { "from": "human", "value": "\"\"\"\nWindows-related compatibility helpers.\n\"\"\"\nimport re\n\n_find_unsafe = re.compile(r'[\\s<>|&^]').search\n\n\ndef quote_arg(s):\n \"\"\"Based on shlex.quote in the standard...
python
chosen
[ { "from": "system", "value": "Move this to the bottom...\n" }, { "from": "human", "value": "from django.contrib import admin\nfrom django.contrib.auth.models import Group\n\nfrom .models import Editor\n\n\nclass ContributorMixin(admin.ModelAdmin):\n def save_model(self, request, obj, form, ch...
python
chosen
[ { "from": "system", "value": "Increase max transaction period due to more networking tasks\n" }, { "from": "human", "value": "import contextlib\nimport logging\nimport time\nimport os\n\n\nlogger = logging.getLogger('network')\n\n\n@contextlib.contextmanager\ndef logNetwork(message):\n transa...
python
chosen
[ { "from": "system", "value": "Fix \"import star\" feature support\n\n`dict.keys()` returns `dict_keys` object in py3,\nwhich does not support indexing.\n" }, { "from": "human", "value": "import sys\nfrom functools import partial, update_wrapper\nfrom django.utils import six\n\n\ndef proxy(attr, ...
python
chosen
[ { "from": "system", "value": "Add missing routes to API.\n" }, { "from": "human", "value": "#!/usr/bin/python\n\nfrom flask import Flask\nfrom flask.ext.pymongo import PyMongo\n\napp = Flask(__name__)\n\n@app.route(\"/\")\ndef hello():\n return \"Hello World!\"\n\n@app.route(\"/recent\")\ndef...
python
chosen
[ { "from": "system", "value": "Allow program termination using SIGINT\n\nIt's a rather crude method, but it works.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom bot import Bot\n\nif __name__ == \"__main__\":\n bot = Bot()\n bot.start()" }, { ...
python
chosen
[ { "from": "system", "value": "Fix the usage of dict object\n\nFix this error:\r\n\r\n```sh\r\npi@raspberrypi:~/Pi-GPIO-Server $ !sudo\r\nsudo python pi_gpio_server.py\r\nTraceback (most recent call last):\r\n File \"/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py\", line 327, in run\r\n result...
python
chosen
[ { "from": "system", "value": "Add first attempt of ActualDepartureQueryApi\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\nimport requests\n\nfrom bs4 import BeautifulSoup\n\nfrom bvggrabber.api import QueryApi,...
python
chosen
[ { "from": "system", "value": "Refactor the test for the method test_filter inside class FullCaseViewSet and create a new test that allows you to test for just ASCII characters\n" }, { "from": "human", "value": "import unittest\n\nfrom django.contrib.auth.models import User\nfrom django.core.urlr...
python
chosen
[ { "from": "system", "value": "Fix snippet URL rules to use mountpoints' endpoint suffix\n" }, { "from": "human", "value": "\"\"\"\nbyceps.blueprints.snippet.init\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Copyright: 2006-2019 Jochen Kupperschmidt\n:License: Modified BSD, see LICENSE for details.\n\"\"\...
python
chosen
[ { "from": "system", "value": "Add docstrings to 'sudo' and 'make'." }, { "from": "human", "value": "\nfrom brutal.core.plugin import BotPlugin, cmd, event, match, threaded\n\n\n@cmd\ndef ping(event):\n \"\"\"Responds 'pong' to your 'ping'.\"\"\"\n\n return 'pong'\n\n\n@cmd\ndef echo(event)...
python
chosen
[ { "from": "system", "value": "Allow parsing of option arguments and basic GPIO testing.\n" }, { "from": "human", "value": "import RPi.GPIO as GPIO\nimport time\nimport os\n\n#sets the Input Pin for your Button\n#in this case it is GPIO24 or HardwarePin 19\nbuttonPin = 19\n#sets GPIO Mode to use ...
python
chosen
[ { "from": "system", "value": "Make dict updates more dense\n" }, { "from": "human", "value": "# Import python libs\nimport logging\n\n# Import salt libs\nimport salt.utils\n\nlog = logging.getLogger(__name__)\n\n\ndef held(name):\n '''\n Set package in 'hold' state, meaning it will not be ...
python
chosen
[ { "from": "system", "value": "Return exeption if cannot get the site config in event\n" }, { "from": "human", "value": "\"\"\"\nUtility functions for event tracking processing.\n\"\"\"\n\nfrom django.core.exceptions import MultipleObjectsReturned\n\nfrom . import exceptions\n\n\ndef get_site_con...
python
chosen
[ { "from": "system", "value": "Use PkgResources helper to load response templates.\n" }, { "from": "human", "value": "import re\n\nfrom twisted.web.template import Element, renderer, XMLFile\nfrom twisted.python.filepath import FilePath\n\n\nclass ResponseParser(object):\n\n HEADER_PATTERN = r...
python
chosen
[ { "from": "system", "value": "Add failsafe mongo calls [ci skip]\n" }, { "from": "human", "value": "from datetime import datetime\nimport logging\nfrom motor.motor_asyncio import AsyncIOMotorClient\nfrom pymongo.errors import AutoReconnect\n\n\nlog = logging.getLogger(__name__)\n\n\nclass MongoB...
python
chosen
[ { "from": "system", "value": "Move from Gist to GitHub" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"\nusage: python -m sha1 <filename>\n\"\"\"\nimport sys\nimport hashlib\n\n# --- these fields are required for packaging\n__version__ = '1.0'\n__author__ = 'anatoly techtonik <tech...
python
chosen
[ { "from": "system", "value": "Use passed url argument in get_best_match\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\n__all__ = ['app']\n\nfrom ConfigParser import SafeConfigParser as ConfigParser\nfrom urlparse import urlparse, urlunparse\n\nfrom flask import Flas...
python
chosen
[ { "from": "system", "value": "Add comments and typing annotations\n" }, { "from": "human", "value": "import json\n\nclass ETK(object):\n\n def __init__(self):\n pass\n\n def get_glossary(self, file_path):\n res = dict()\n with open(file_path) as fp:\n line =...
python
chosen
[ { "from": "system", "value": "Use Q object instead of empty queryset\n" }, { "from": "human", "value": "from django.db.models import Q\nfrom le_utils.constants import content_kinds\n\nfrom kolibri.core.content.hooks import ContentRendererHook\nfrom kolibri.core.content.models import ContentNode\...
python
chosen
[ { "from": "system", "value": "Remove gaps from individual genomes\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom __future__ import print_function, absolute_import, division\nimport screed\nimport docopt\n\nCLI = \"\"\"\nUSAGE:\n fasplit <fasta> <prefix>\n\"\"\"\n\nopts = docop...
python
chosen
[ { "from": "system", "value": "Refactor test to not use global variable\n" }, { "from": "human", "value": "from django.test import TestCase\nfrom casexml.apps.case.mock import CaseFactory\nfrom casexml.apps.case.signals import cases_received\nfrom casexml.apps.case.xform import process_cases_with...
python
chosen
[ { "from": "system", "value": "Increase Gubernator's url fetch deadline -- 5 seconds is too fast!\n\nThis should avoid a lot of refreshes because some directory listing or\ndownload takes slightly too long.\n" }, { "from": "human", "value": "# Copyright 2016 The Kubernetes Authors All rights rese...
python
chosen
[ { "from": "system", "value": "Add error handling to main game loop\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport sys\n\nfrom board import Board, BoardView\nfrom utils import clear, getch\n\n\ndef main():\n board = Board(19, 19)\n view = BoardView(board)\n\n def move...
python
chosen
[ { "from": "system", "value": "Use the new url pattern\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# vim: set ts=4\n\n# Copyright 2014 Rémi Duraffort\n# This file is part of Artifactorial.\n#\n# Artifactorial is free software: you can redistribute it and/or modify\n# it under the ...
python
chosen
[ { "from": "system", "value": "Update to reflect some small re-factoring.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n__all__ = [\"csiro\", \"extras\"]\n__authors__ = 'Filipe Fernandes'\n__created_ = \"14-Jan-2010\"\n__email__ = \"ocefpaf@gmail.com\"\n__license__ = \"MIT\"\n__ma...
python
chosen
[ { "from": "system", "value": "Revert \"Fixed up some things.\"\n\nThis reverts commit 2d3d6c1b569e1f35faf9cd79a369862651c008ff.\n" }, { "from": "human", "value": "DEBUG = True\nDEBUG_TEMPLATE = True\nSITE_ID = 1\nDATABASE_ENGINE = 'sqlite3'\nDATABASE_NAME = '/tmp/asgard-blog-devel.db'\nINSTALLED...
python
chosen
[ { "from": "system", "value": "Move use_cases into the class\n" }, { "from": "human", "value": "import simuvex\n\n######################################\n# NoReturnUnconstrained\n# Use in places you would put ReturnUnconstrained as a default action\n# But the function shouldn't actually return\n#...
python
chosen
[ { "from": "system", "value": "Create functional test for data import\n" }, { "from": "human", "value": "# coding: utf-8\nimport pkg_resources\n\nfrom django.test.testcases import TransactionTestCase\nfrom homophony import BrowserTestCase, Browser\n\n\ndef import_pages(directory):\n pass\n\n\n...
python
chosen
[ { "from": "system", "value": "Fix table names in flask-admin\n" }, { "from": "human", "value": "from flask import Flask\nfrom flask_login import LoginManager\nfrom flask_bcrypt import Bcrypt\nfrom flask_admin import Admin\nfrom flask_admin.contrib.peewee import ModelView\nfrom playhouse.flask_ut...
python
chosen
[ { "from": "system", "value": "Use relative paths in golden_dict_media\n" }, { "from": "human", "value": "import aqt\n\nfrom golden_dict_media.AddonInitializer import init_addon\n\nif aqt.mw is not None:\n init_addon()\n" }, { "from": "gpt", "value": "import aqt\n\nfrom .AddonIniti...
python
chosen
[ { "from": "system", "value": "Fix issue on multi-line comment\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\n\nfrom rply import LexerGenerator\n\nop_map = {\n 'NUMBER': r'\\d[\\d\\s]*',\n 'PLUS': r'\\+',\n 'MINUS': r'-',\n 'MUL': r...
python
chosen
[ { "from": "system", "value": "game/quests: Implement getObjective and tooltip objective\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nQuests\n - questcache.wdb\n\"\"\"\n\nfrom .. import *\n\n\nclass Quest(Model):\n\tdef getTooltip(self):\n\t\treturn QuestTooltip(self)\n\ncl...
python
chosen
[ { "from": "system", "value": "Update sample to also fetch the object, and delete the object and bucket.\n" }, { "from": "human", "value": "# Copyright 2013. Amazon Web Services, Inc. All Rights Reserved.\n# \n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use ...
python
chosen
[ { "from": "system", "value": "Increase version number to 0.4.3\n" }, { "from": "human", "value": "# Copyright (c) 2017 \"Shopify inc.\" All rights reserved.\n# Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.\nfrom __future__ import unicode_litera...
python
chosen
[ { "from": "system", "value": "Fix snippet parser for Italian.\n\n\nFormer-commit-id: bb8d10f5f8301fbcd4f4232612bf722d380a3d10" }, { "from": "human", "value": "#-*- encoding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom core import *\n\ndef handle_bandiera(template):\n return tem...
python
chosen
[ { "from": "system", "value": "Fix neutron server crash introduced by trunk code\n\nWhen running pre-stable/ocata neutron code the networking_cisco trunk\ncode was crashing due to incorrect backwards_compatibility implementation.\n\nChange-Id: I8188f8d16313166418d207c99124e2763eb669a1\n" }, { "from":...
python
chosen
[ { "from": "system", "value": "Add ``get_domain`` test fixture factory.\n\nHelpful to test the ``Domain``.\n" }, { "from": "human", "value": "from us_ignite.apps.models import Application, ApplicationMembership, Page\nfrom us_ignite.profiles.tests.fixtures import get_user\n\n\ndef get_application...
python
chosen
[ { "from": "system", "value": "Fix bug when directory is created on watched path\n" }, { "from": "human", "value": "from threading import Thread\nfrom watchdog.events import FileSystemEventHandler\nfrom watchdog.observers import Observer\nimport os\nimport requests\nimport time\n\nFRAMES_PATH = o...
python
chosen