conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add MOBIB Basic reader script\n" }, { "from": "gpt", "value": "#!/bin/env python3\n\nimport sys\n\nfrom smartcard.System import readers\n\nCALYPSO_CLA = [0x94]\nSELECT_INS = [0xA4]\nREAD_RECORD_INS = [0xB2]\nGET_RESPONSE_INS = [0xC0]\nTICKETING_COUNTERS_FILE_ID = [0x...
python
chosen
[ { "from": "human", "value": "Test we can approve Flutterwave bank accounts\n" }, { "from": "gpt", "value": "from bluebottle.files.tests.factories import PrivateDocumentFactory\nfrom bluebottle.funding.tests.factories import FundingFactory, PlainPayoutAccountFactory, \\\n BudgetLineFactory\nfr...
python
chosen
[ { "from": "human", "value": "feat: Add a script which use the iterative parsing to process the map file and find out not only what tags are there, but also how many, to get the feeling on how much of which data you can expect to have in the map.\n" }, { "from": "gpt", "value": "#!/usr/bin/env py...
python
chosen
[ { "from": "human", "value": "Add test to ensure no mutable default arguments\n" }, { "from": "gpt", "value": "import importlib\nimport inspect\nimport pkgutil\nimport types\n\nimport six\nimport unittest\n\nimport chainer\nfrom chainer import testing\n\n\ndef walk_modules():\n root = chainer....
python
chosen
[ { "from": "human", "value": "Move log related functions over to this file\n\nMeant for global use in SpicyTwitch\n" }, { "from": "gpt", "value": "# Imports-----------------------------------------------------------------------\nimport logging\nimport os\nfrom inspect import stack, getmodulename\...
python
chosen
[ { "from": "human", "value": "Add simple unit tests to validate all configs\n\nSummary: Add simple unit tests to validate all configs: as demonstrated by the previous diff, this can not hurt :)\n\nReviewed By: vkhalidov\n\nDifferential Revision: D20491383\n\nfbshipit-source-id: 1c7b82dfbf9cde43d38ece64a5fb16...
python
chosen
[ { "from": "human", "value": "Add tests for language api\n" }, { "from": "gpt", "value": "import json\nfrom server.tests.helpers import FlaskTestCase, fixtures\n\n\nclass TestLanguageAPI(FlaskTestCase):\n\n @fixtures('base.json')\n def test_get_empty_languages(self):\n \"\"\"Test GET...
python
chosen
[ { "from": "human", "value": "Add in team id spider\n" }, { "from": "gpt", "value": "import scrapy\n\nclass TeamSpider(scrapy.Spider):\n\tname = \"team\"\n\tstart_urls = [\n\t\t'http://www.espn.com/mens-college-basketball/teams',\n\t]\n\n\tdef parse(self, response):\n\t\tfor conf in response.css(...
python
chosen
[ { "from": "human", "value": "Add functional test for cluster check recover\n\nChange-Id: Icb4ef7f754ba3b5764cf8f6d8f5999f0e2d2f3c2\n" }, { "from": "gpt", "value": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the Licen...
python
chosen
[ { "from": "human", "value": "Add partial simple greedy algorithm (baseline).\n" }, { "from": "gpt", "value": "import networkx as nx\r\nfrom sys import argv\r\n\r\ndef main():\r\n # G = nx.read_gml(argv[1])\r\n G = nx.read_gml(\"steiner-small.gml\")\r\n\t\r\n T = [] # terminals\r\n for v,d in...
python
chosen
[ { "from": "human", "value": "Solve the most wanted letter problem.\n" }, { "from": "gpt", "value": "def checkio(word):\n word = word.lower()\n arr = dict()\n for i in range(len(word)):\n char = word[i]\n if not str.isalpha(char):\n continue\n if not arr._...
python
chosen
[ { "from": "human", "value": "Add Fibonacci Series Using Recursion\n" }, { "from": "gpt", "value": "# Fibonacci Sequence Using Recursion\n\ndef recur_fibo(n):\n if n <= 1:\n return n\n else:\n return(recur_fibo(n-1) + recur_fibo(n-2))\n \nlimit = int(input(\"How many terms to i...
python
chosen
[ { "from": "human", "value": "Add a proper unit test for xreload.py.\n" }, { "from": "gpt", "value": "\"\"\"Doctests for module reloading.\n\n>>> from xreload import xreload\n>>> from test.test_xreload import make_mod\n>>> make_mod()\n>>> import x\n>>> C = x.C\n>>> Cfoo = C.foo\n>>> Cbar = C.bar\...
python
chosen
[ { "from": "human", "value": "Add a coupld tests to create exception classes from error code names\n" }, { "from": "gpt", "value": "# Copyright (c) 2014 Amazon.com, Inc. or its affiliates.\n# All Rights Reserved\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy...
python
chosen
[ { "from": "human", "value": "Implement ArgumentSelector for overload disambiguation\n" }, { "from": "gpt", "value": "import collections\nimport copy\n\nfrom thinglang.compiler.errors import NoMatchingOverload\nfrom thinglang.lexer.values.identifier import Identifier\n\nSymbolOption = collections...
python
chosen
[ { "from": "human", "value": "Add Python-based opcode enum parser\n" }, { "from": "gpt", "value": "import os\n\nimport re\n\nBASE_DIR = os.path.dirname(os.path.abspath(__file__))\nENUM_PARSER = re.compile(r'(.*)\\s*?=\\s*?(\\d+)')\n\ndef read_opcodes():\n with open(os.path.join(BASE_DIR, '..',...
python
chosen
[ { "from": "human", "value": "Add utils for graph visualization.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport itertools\nimport os\nimport tempfile\n\nimport conn\nimport matplotlib.pyplot as plt\nimport networkx as nx\n\ndef imdisp(f):\n \"\"\"\n Display the specified i...
python
chosen
[ { "from": "human", "value": "Test that specific Failures are caught before parent Failures\n" }, { "from": "gpt", "value": "from twisted.trial import unittest\n\nimport ooni.errors\n\nclass TestErrors(unittest.TestCase):\n\n def test_catch_child_failures_before_parent_failures(self):\n ...
python
chosen
[ { "from": "system", "value": "Taskwiki: Update tasks and evaluate viewports on saving\n" }, { "from": "human", "value": "import sys\nimport re\nimport vim\n\nfrom tasklib.task import TaskWarrior, Task\n\n# Insert the taskwiki on the python path\nsys.path.insert(0, vim.eval(\"s:plugin_path\") + '...
python
chosen
[ { "from": "human", "value": "auth: Add abstract class for HAP channels\n\nRelates to #1255\n" }, { "from": "gpt", "value": "\"\"\"Base class for HAP based channels (connections).\"\"\"\nfrom abc import ABC, abstractmethod\nimport asyncio\nimport logging\nfrom typing import Callable, Tuple, cast\...
python
chosen
[ { "from": "human", "value": "Add GDB plugin for printing ABC values\n" }, { "from": "gpt", "value": "deadbeef = 0xdeadbeefdeadbeef\n\nabc_any = gdb.lookup_type(\"union any\")\n\ndef color(s, c):\n return \"\\x1b[\" + str(c) + \"m\" + s + \"\\x1b[0m\"\n\ndef gray(s):\n return color(s, 90)\n...
python
chosen
[ { "from": "human", "value": "Add Classical multidimensional scaling algorithm.\n" }, { "from": "gpt", "value": "\"\"\"\nSimple implementation of classical MDS.\nSee http://www.stat.cmu.edu/~ryantibs/datamining/lectures/09-dim3-marked.pdf for more details.\n\"\"\"\n\nimport numpy as np\nimport nu...
python
chosen
[ { "from": "human", "value": "Add workup vebose name change migration.\n" }, { "from": "gpt", "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 ('worku...
python
chosen
[ { "from": "human", "value": "Add middleware for static serving\n" }, { "from": "gpt", "value": "import wsgi_server\nimport os\nfrom werkzeug.wsgi import SharedDataMiddleware\n\napplication = SharedDataMiddleware(wsgi_server.application, {\n '/static': os.path.join(os.path.dirname(__file__), '...
python
chosen
[ { "from": "human", "value": "Add command to dump and restore user pointers.\n\nFor use in database migrations.\n\n(imported from commit f06ae569fe986da5e7d144c277bf27be534c04f9)\n" }, { "from": "gpt", "value": "from optparse import make_option\nfrom django.core.management.base import BaseCommand...
python
chosen
[ { "from": "human", "value": "Add `OrganizationOption` tests based on `ProjectOption`.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import\n\nfrom sentry.models import OrganizationOption\nfrom sentry.testutils import TestCase\n\n\nclass OrganizationO...
python
chosen
[ { "from": "human", "value": "Test our new happenings-by-year view.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport datetime\nimport pytest\n\nfrom django.core.urlresolvers import reverse\n\nfrom components.people.factories import GroupFactory, IdolFactory\n\n\n@pytest.mark.djang...
python
chosen
[ { "from": "human", "value": "Add a couple unit tests for teuthology.parallel\n\nSigned-off-by: Zack Cerza <f801c831581d4150a2793939287636221d62131e@inktank.com>\n" }, { "from": "gpt", "value": "from ..parallel import parallel\n\n\ndef identity(item, input_set=None, remove=False):\n if input_s...
python
chosen
[ { "from": "human", "value": "Add test coverage for rdopkg.guess version2tag and tag2version\n\nadding coverage unittest, there are some not well handled input cases\nbut better to capture existing behavior and update tests and code to\nhandle things better\n\nChange-Id: I16dfb60886a1ac5ddfab86100e08ac23f8cf...
python
chosen
[ { "from": "human", "value": "Add create image functional negative tests\n\nThe negative tests of create image API are not covered enough\nin functional tests. We want to add the conflict tests of\nwhen the create image API runs in the unexpected state\n(e.g. not ACTIVE) of server.\n\nChange-Id: I0c0b9e4d9ef...
python
chosen
[ { "from": "human", "value": "Add http directory listing with content display\n" }, { "from": "gpt", "value": "#!/bin/env python3\nimport http.server\nimport string\nimport click\nimport pathlib\nimport urllib.parse\nimport os\n\n\n@click.command()\n@click.argument(\"port\", required=False)\n@cli...
python
chosen
[ { "from": "human", "value": "Add tests for get_uid() method for common DB models.\n" }, { "from": "gpt", "value": "# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding copyright ownership.\n# The ASF licenses this file to You u...
python
chosen
[ { "from": "human", "value": "Add first pass at integration style tests\n\nIn order to better prevent regressions (such as related to concurrency),\nAdd a integration test framework to simulate running flake8 with\narguments.\n" }, { "from": "gpt", "value": "from __future__ import with_statement\...
python
chosen
[ { "from": "human", "value": "Add migration for latitute and longitude of event\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.5 on 2016-06-17 13:50\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migra...
python
chosen
[ { "from": "human", "value": "Add unit test for protonate.py\n" }, { "from": "gpt", "value": "import propka.atom\nimport propka.protonate\n\n\ndef test_protonate_atom():\n atom = propka.atom.Atom(\n \"HETATM 4479 V VO4 A1578 -19.097 16.967 0.500 1.00 17.21 V \"\n ...
python
chosen
[ { "from": "human", "value": "Add Diagonal Difference HackerRank Problem\n\n* https://www.hackerrank.com/challenges/diagonal-difference\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\ndef get_matrix_row_from_input():\n return [int(index) for index in input().strip().split(' ')]\n\n...
python
chosen
[ { "from": "system", "value": "[Android] Refactor buildbot tests so that they can be used downstream.\n\nI refactored in the wrong way in r211209 (https://chromiumcodereview.appspot.com/18325030/). This CL fixes that. Note that r211209 is not broken; it is just not usable downstream.\n\nBUG=249997\nNOTRY=Tru...
python
chosen
[ { "from": "human", "value": "Add flask api app creation to init\n" }, { "from": "gpt", "value": "from flask_sqlalchemy import SQLAlchemy\nimport connexion\n\nfrom config import config\n\ndb = SQLAlchemy()\n\n\ndef create_app(config_name):\n app = connexion.FlaskApp(__name__, specification_dir...
python
chosen
[ { "from": "human", "value": "Add helper-lib for json object conversion and split dicts\n" }, { "from": "gpt", "value": "#! /usr/bin/env python2.7\n\nimport datetime\n\ndef typecast_json(o):\n\tif isinstance(o, datetime.datetime) or isinstance(o, datetime.date):\n\t\treturn o.isoformat()\n\telse:...
python
chosen
[ { "from": "human", "value": "Coffee: Add symbol translator to make utf-8 variables compilable\n" }, { "from": "gpt", "value": "\"\"\"Translation table from utf-8 to greek variable names, taken from:\nhttps://gist.github.com/piquadrat/765262#file-greek_alphabet-py\n\"\"\"\n\n\ndef translate_symbo...
python
chosen
[ { "from": "human", "value": "Enforce unique paths and names\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9 on 2015-12-15 02:12\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n...
python
chosen
[ { "from": "human", "value": "Add script to create overlays\n" }, { "from": "gpt", "value": "\"\"\"Varcan smart tool.\"\"\"\n\nimport click\n\nfrom dtoolcore import DataSet\n\n\n@click.command()\n@click.argument('dataset_uri')\n@click.option('--config-path', type=click.Path(exists=True))\ndef mai...
python
chosen
[ { "from": "human", "value": "Add test for water polygon name dropping.\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\nfrom . import FixtureTest\n\n\nclass WaterLayerTooBigTest(FixtureTest):\n\n def test_drop_label(self):\n from tilequeue.tile import calc_meters_per_pixel_a...
python
chosen
[ { "from": "human", "value": "Add management command to list installed spiders\n" }, { "from": "gpt", "value": "from django.core.management import BaseCommand\nfrom raw.utils import list_spiders\n\n\nclass Command(BaseCommand):\n help = 'List installed spiders'\n\n def handle(self, *args, *...
python
chosen
[ { "from": "human", "value": "Solve Code Fights lineup problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Lineup Problem\n\n\ndef lineUp(commands):\n aligned, tmp = 0, 0\n com_dict = {\"L\": 1, \"A\": 0, \"R\": -1}\n for c in commands:\n tmp += com_dic...
python
chosen
[ { "from": "human", "value": "Add download apikey test case\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestCase\nfrom tastypie.test import ResourceTestCase\nfrom django.test.client import Client\n\nfrom django....
python
chosen
[ { "from": "human", "value": "Add unittest for QInputDialog.getXXX() methods\n" }, { "from": "gpt", "value": "import unittest\n\nfrom PySide import QtCore, QtGui\nfrom helper import UsesQApplication, TimedQApplication\n\nclass TestInputDialog(TimedQApplication):\n\n def testGetDouble(self):\n ...
python
chosen
[ { "from": "human", "value": "Add mocked tests for activation\n" }, { "from": "gpt", "value": "from unittest import mock\nfrom django.test import TestCase\n\nfrom viewflow import activation, flow\nfrom viewflow.models import Task\n\n\nclass TestActivations(TestCase):\n def test_start_activatio...
python
chosen
[ { "from": "human", "value": "Test module for Predictor class.\n" }, { "from": "gpt", "value": "#! /usr/env/bin python\nimport numpy as np\n\nfrom pyboas import predictor, models\n\n# Build random 3-parameter normal posterior.\nposterior = np.random.randn(100, 3)\n\n\ndef toy_model(param, time):\...
python
chosen
[ { "from": "human", "value": "Add tool to create combined smart contract files\n\nUseful for various cases where a single source file is needed e.g. when\nverifying contracts on etherscan.\n" }, { "from": "gpt", "value": "import os\n\nimport click\nimport re\nfrom click.types import File\n\nIMPOR...
python
chosen
[ { "from": "human", "value": "Add migration to remove models.\n" }, { "from": "gpt", "value": "# Generated by Django 2.1.4 on 2019-03-04 18:13\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('server', '0087_auto_20190301_1424'),\n ...
python
chosen
[ { "from": "human", "value": "Add script to delete unused users on JupyterHub\n\nNote that this doesn't actually delete their home directories\nor any data - just the entry in the JupyterHub DB. As soon as\nthey log in again, a new entry is created.\n\nThis is really just a performance optimization.\n" }, ...
python
chosen
[ { "from": "human", "value": "Add migration for license change\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.5 on 2017-12-15 08:53\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration)...
python
chosen
[ { "from": "human", "value": "Add simple windows registry read/write functions\n" }, { "from": "gpt", "value": "import _winreg\n\nkeyName = \"myKey\"\n\n\ndef write_to_registry():\n try:\n key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, \"Software\\\\\" + keyName)\n _winreg.Se...
python
chosen
[ { "from": "human", "value": "Solve Code Fights addition without carrying problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Addition Without Carrying Problem\n\n\ndef additionWithoutCarrying(param1, param2):\n s1, s2 = str(param1), str(param2)\n shorter = s1 if...
python
chosen
[ { "from": "human", "value": "Add management command to set SoftwareSecure verification status.\n" }, { "from": "gpt", "value": "\"\"\"\nManually set Software Secure verification status.\n\"\"\"\n\nimport sys\n\nfrom django.core.management.base import BaseCommand\nfrom verify_student.models impor...
python
chosen
[ { "from": "human", "value": "Add Find Command MCEdit filter\n" }, { "from": "gpt", "value": "# MCEdit filter\n\nfrom albow import alert\n\ndisplayName = \"Find Command\"\n\ninputs = (\n (\"Command:\", (\"string\", \"value=\")),\n)\n\ndef perform(level, box, options):\n command = options[\"...
python
chosen
[ { "from": "human", "value": "Add sample of scheduler using celery\n" }, { "from": "gpt", "value": "from celery import Celery\n\n# The host in which RabbitMQ is running\nHOST = 'amqp://guest@localhost'\n\napp = Celery('pages_celery', broker=HOST)\n\n@app.task\ndef work(msg):\n print msg\n\n# T...
python
chosen
[ { "from": "human", "value": "Solve the Longest Lines challenge using Python3\n" }, { "from": "gpt", "value": "# Longest Lines\n#\n# https://www.codeeval.com/open_challenges/2/\n#\n# Challenge Description: Write a program which reads a file and prints to \n# stdout the specified number of the lon...
python
chosen
[ { "from": "human", "value": "Bring back the Root URL config\n\nThe file was probably deleted by a mistake, we need it, so took it back.\n" }, { "from": "gpt", "value": "__author__ = 'ankesh'\nfrom django.conf.urls import patterns, include, url\nfrom django.http import HttpResponseRedirect\n\n# U...
python
chosen
[ { "from": "human", "value": "Create Video Stream program for webcam\n" }, { "from": "gpt", "value": "import cv2\r\nimport numpy as np\r\n\r\ncap = cv2.VideoCapture(0)\r\n\r\nprint('Beginning Capture Device opening...\\n')\r\nprint('Capture device opened?', cap.isOpened())\r\n\r\nwhile True:\r\n\...
python
chosen
[ { "from": "human", "value": "Add a new script to clean up a habitica user given user email\n\n- Looks up uuid\n- uses that to lookup password\n- calls delete method\n\nSimple!\n" }, { "from": "gpt", "value": "import argparse\nimport sys\nimport logging\n\nimport emission.core.get_database as edb...
python
chosen
[ { "from": "human", "value": "Add forgotten font leader lib\n" }, { "from": "gpt", "value": "import os\nimport sys\nimport logging\n\nFONT_FILE_NAME_LIST = (\n \"fontawesome-webfont.ttf\",\n )\n\nFONT_DIRECTORY = \"share\"\nFONT_DIRECTORY_SYSTEM = \"/usr/share/fonts\"\nFONT_DIRECTOR...
python
chosen
[ { "from": "human", "value": "Add test case for list invoice\n" }, { "from": "gpt", "value": "import httpretty\n\nfrom paystackapi.tests.base_test_case import BaseTestCase\nfrom paystackapi.invoice import Invoice\n\n\nclass TestInvoice(BaseTestCase):\n\n @httpretty.activate\n def test_creat...
python
chosen
[ { "from": "human", "value": "Add test for file creation of low level library\n" }, { "from": "gpt", "value": "import os\n\nfrom cffitsio._cfitsio import ffi, lib\n\n\ndef test_create_file(tmpdir):\n filename = str(tmpdir.join('test.fits'))\n f = ffi.new('fitsfile **')\n status = ffi.new...
python
chosen
[ { "from": "human", "value": "Implement utility for colored, tabular output using fabric's color controls.\n" }, { "from": "gpt", "value": "\"\"\"\nPretty table generation.\n\"\"\"\nfrom itertools import cycle\nfrom string import capwords\nfrom fabric.colors import red, green, blue, magenta, whit...
python
chosen
[ { "from": "human", "value": "Add tests for pylama isort\n" }, { "from": "gpt", "value": "import os\n\nfrom isort.pylama_isort import Linter\n\n\nclass TestLinter:\n instance = Linter()\n\n def test_allow(self):\n assert not self.instance.allow(\"test_case.pyc\")\n assert not ...
python
chosen
[ { "from": "human", "value": "Add py solution for 459. Repeated Substring Pattern\n\n459. Repeated Substring Pattern: https://leetcode.com/problems/repeated-substring-pattern/\n" }, { "from": "gpt", "value": "class Solution(object):\n def repeatedSubstringPattern(self, s):\n \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Add a slow bot to test timeout feature\n" }, { "from": "gpt", "value": "import random\nimport asyncio\n\nimport sc2\nfrom sc2 import Race, Difficulty\nfrom sc2.constants import *\nfrom sc2.player import Bot, Computer\n\nfrom proxy_rax import ProxyRaxBot\n\nclass Slow...
python
chosen
[ { "from": "human", "value": "Add pebble sdk version for detecting sdk features\n" }, { "from": "gpt", "value": "from waflib.Configure import conf\n\n\n@conf\ndef compare_sdk_version(ctx, platform, version):\n target_env = ctx.all_envs[platform] if platform in ctx.all_envs else ctx.env\n ta...
python
chosen
[ { "from": "human", "value": "Add tests for JsonBackend __init__ and commit methods\n" }, { "from": "gpt", "value": "import pytest\n\nfrom shadho.backend.base.tests.test_db import TestBaseBackend\nfrom shadho.backend.json.db import JsonBackend\n\nimport json\nimport os\nimport shutil\n\n\nclass T...
python
chosen
[ { "from": "human", "value": "Add some generic python utilities as a basis for scripts\n" }, { "from": "gpt", "value": "from __future__ import print_function\n\nimport os\n\ndef game_root_path():\n file_path = os.path.dirname(os.path.abspath(__file__))\n return os.path.abspath(os.path.join(...
python
chosen
[ { "from": "system", "value": "Revert escape nickname, desc, etc in user profile\n" }, { "from": "human", "value": "# encoding: utf-8\nfrom django import forms\nfrom django.utils.html import escape\n\nfrom seahub.profile.models import Profile, DetailedProfile\n\nclass ProfileForm(forms.Form):\n ...
python
chosen
[ { "from": "system", "value": "Fix JSON serialisation problem with AJAX basket\n\nsix.moves.map returns itertools.imap which won't serialize to JSON.\nThis commit unpacks the list into a normal list of strings to circumvent\nthe issue.\n" }, { "from": "human", "value": "import six\nfrom django.co...
python
chosen
[ { "from": "human", "value": "Create script to transform shapefile into csv distance matrix\n" }, { "from": "gpt", "value": "\"\"\"Create a csv matrix of distances between shapefile geometry objects.\n\nRequirements: fiona, shapely\n\nWritten by: Taylor Denouden\nDate: November 25, 2015\n\"\"\"\n...
python
chosen
[ { "from": "human", "value": "Print the trending Python repos on GitHub" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport bs4\nimport requests\n\nurl = 'https://github.com/trending?l=Python'\nsoup = bs4.BeautifulSoup(requests.get(url).content, 'lxml') # or 'html5lib'\nrepos = soup....
python
chosen
[ { "from": "human", "value": "Add function to create view for Span candidate subclasses\n" }, { "from": "gpt", "value": "\n\ndef create_serialized_candidate_view(session, C, verbose=True):\n \"\"\"Creates a view in the database for a Candidate sub-class C defined over\n Span contexts, which...
python
chosen
[ { "from": "human", "value": "Add commands for cases and variants\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport logging\nimport click\n\nfrom . import base_command\n\nlogger = logging.getLogger(__name__)\n\n@base_command.command()\n@click.option('-c' ,'--case-id', \n ...
python
chosen
[ { "from": "human", "value": "Add a utility class to normalize input\n" }, { "from": "gpt", "value": "from unidecode import unidecode\n\n\nclass Normalizer:\n\n def normalize(text):\n text = Normalizer.remove_extra_whitespaces(text)\n text = Normalizer.replace_hyphens(text)\n ...
python
chosen
[ { "from": "human", "value": "Add next traversal util function\n" }, { "from": "gpt", "value": "\"\"\"\nscrapple.utils.config\n~~~~~~~~~~~~~~~~~~~~~\n\nFunctions related to traversing the configuration file\n\"\"\"\n\nfrom __future__ import print_function\n\n\ndef traverse_next(page, next, result...
python
chosen
[ { "from": "human", "value": "Add test for stack outputs\n\nAdd test for output list and output show\n\nDepends-On: I1bc1cee1c78ecf0c9a18ecc0a871d38e4141e0f7\nChange-Id: I1ee226494b5b04ec2d43edf0c03ab31e452fedf0\n" }, { "from": "gpt", "value": "# Licensed under the Apache License, Version 2.0 ...
python
chosen
[ { "from": "human", "value": "Add missing migration related to django-simple-history update\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.2 on 2017-06-13 09:41\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Mi...
python
chosen
[ { "from": "human", "value": "Add helper enums for type encodings\n" }, { "from": "gpt", "value": "REDIS_ENCODING_ID_RAW = 0\nREDIS_ENCODING_ID_INT = 1\nREDIS_ENCODING_ID_EMBSTR = 2\nREDIS_ENCODING_ID_HASHTABLE = 3\nREDIS_ENCODING_ID_ZIPLIST = 4\nREDIS_ENCODING_ID_LINKEDLIST = 5\nREDIS_ENCODING_I...
python
chosen
[ { "from": "human", "value": "Add first version of the code\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport re\nfrom collections import OrderedDict\nimport codecs\n\nclass BibEntry:\n \n def __init__(self, **kwargs):\n self.data = {}\n ...
python
chosen
[ { "from": "human", "value": "[Crawler] Add youtube-dl library sample of operation\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n#-*- coding: utf-8 -*-\n\nimport sys\nimport youtube_dl\n\n\ndef main():\n if len(sys.argv) < 2:\n print(\"Usage: youtube_dl_op_sample.py URL\")\n ...
python
chosen
[ { "from": "human", "value": "Add tool to fix links.\n\nSigned-off-by: Jason Kuster <68c46a606457643eab92053c1c05574abb26f861@google.com>\n" }, { "from": "gpt", "value": "\"\"\"Script to fix the links in the staged website.\nFinds all internal links which do not have index.html at the end and app...
python
chosen
[ { "from": "human", "value": "Add missing migrations in develop branch\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.25 on 2019-10-07 10:27\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.M...
python
chosen
[ { "from": "human", "value": "Add tests for Generic Interface.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\nfrom __future__ import print_function\nfrom typing import Any\n\nimport mock\nimport json\n\nfrom requests.models import Response\nfrom ...
python
chosen
[ { "from": "human", "value": "Add py solution for 575. Distribute Candies\n\n575. Distribute Candies: https://leetcode.com/problems/distribute-candies/\n" }, { "from": "gpt", "value": "class Solution(object):\n def distributeCandies(self, candies):\n \"\"\"\n :type candies: List[...
python
chosen
[ { "from": "human", "value": "Add Chuanping Yu's solutions to Problem02" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\n\"\"\"This script is written by Chuanping Yu, on Jul 24, 2017,\nfor the Assignment#1 in IDEaS workshop\"\"\"\n\n#Problem 2\nFIB = []\nF = 1\nS = 0\nFIB.append(F)\nFIB.a...
python
chosen
[ { "from": "human", "value": "Create foundation for input file generation (csv for connectivity table, etc.)\n" }, { "from": "gpt", "value": "import csv\nimport argparse\nimport itertools\n\nfrom thermo_utils import csv_row_writer, read_csv_rows\n\n# Read input/output arguments\nparser = argparse...
python
chosen
[ { "from": "human", "value": "Make sure setUpModule is called by the test framework. We brought in pytest-2.4.0.dev8 for that specific functionality. However, one time we regressed, and our tests started misbehaving. So, this test is here to keep us honest.\n" }, { "from": "gpt", "value": "#!/usr...
python
chosen
[ { "from": "human", "value": "Add worker to send queue mails\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Copyright (c) 2016 Aladom SAS & Hosting Dvpt SAS\nfrom django.core.management.base import BaseCommand\n\nfrom ...utils import send_queued_mails\nimport time\n\nclass Command(Ba...
python
chosen
[ { "from": "human", "value": "Add migration to add authtokens for existing users\n\n* NB: Depending on how many users there are, this migration could be pretty RAM\n intensive...\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db i...
python
chosen
[ { "from": "human", "value": "Add some code to auto-remove Ltac\n" }, { "from": "gpt", "value": "import re\n\n__all__ = [\"recursively_remove_ltac\"]\n\nLTAC_REG = re.compile(r'^\\s*(?:Local\\s+|Global\\s+)?Ltac\\s+([^\\s]+)', re.MULTILINE)\n\ndef recursively_remove_ltac(statements, exclude_n=3):...
python
chosen
[ { "from": "human", "value": "Add solution to exercise 3.3.\n" }, { "from": "gpt", "value": "# 3-3 Your Own List\ntransportation = [\"mountainbike\", \"teleportation\", \"Citroën DS3\"]\n\nprint(\"A \" + transportation[0] + \" is good when exercising in the woods.\\n\")\nprint(\"The ultimate form...
python
chosen
[ { "from": "human", "value": "Add test for pixel CLI\n" }, { "from": "gpt", "value": "\"\"\" Test ``yatsm line``\n\"\"\"\nimport os\n\nfrom click.testing import CliRunner\nimport pytest\n\nfrom yatsm.cli.main import cli\n\n\n@pytest.mark.skipif(\"DISPLAY\" not in os.environ, reason=\"requires dis...
python
chosen
[ { "from": "human", "value": "Create a test for re-evaluating external tasks while a workflow is running.\n" }, { "from": "gpt", "value": "# Copyright (c) 2015\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the Licens...
python
chosen
[ { "from": "human", "value": "Add a few behavior tests for selection\n" }, { "from": "gpt", "value": "import os\nimport pytest\nimport yaml\n\nfrom photoshell.selection import Selection\n\n\n@pytest.fixture\ndef sidecar(tmpdir):\n tmpdir.join(\"test.sidecar\").write(yaml.dump({\n 'devel...
python
chosen
[ { "from": "human", "value": "Add fields to privatemessage for network invitations.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.9 on 2018-02-26 22:09\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.mod...
python
chosen