text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """Gets queue stats
:param req: Request instance ready to be sent.
:type req: `api.common.Request`
:return: resp: Response instance
:type: resp: `api.common.Response`
"""
project_id = req._headers.get('X-Project-ID')
queue_name = req._body.g... | code_fim | hard | {
"lang": "python",
"repo": "Embedded4development/zaqar",
"path": "/zaqar/api/v1_1/endpoints.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_detections(responce):
data = responce.json()
try:
detections = data['detections']
except:
print(data)
quit()
return detections
def test(args):
urls = [
'https://farm4.staticflickr.com/3491/4023151748_cb042e1794_z.jpg',
'https://farmha... | code_fim | medium | {
"lang": "python",
"repo": "ioangatop/yolo",
"path": "/server/client-server/tests/async_requests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ioangatop/yolo path: /server/client-server/tests/async_requests.py
import grequests as asynch
import argparse
import time
import os
def get_args():
parser = argparse.ArgumentParser(description="Inference Server")
parser.add_argument('--host', type=str, default='192.168.1.113', help='A... | code_fim | medium | {
"lang": "python",
"repo": "ioangatop/yolo",
"path": "/server/client-server/tests/async_requests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BingAds/BingAds-Python-SDK path: /bingads/v13/bulk/bulk_service_manager.py
suds options need to pass to suds client
"""
self._environment = environment
self._service_client = ServiceClient('BulkService', 13, authorization_data, environment, **suds_options)
self._a... | code_fim | hard | {
"lang": "python",
"repo": "BingAds/BingAds-Python-SDK",
"path": "/bingads/v13/bulk/bulk_service_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Upload bulk file specified in upload parameters to specified URL
:param url: The upload target URL.
:type url: str
:param upload_file_path: The fully qualified local path of the upload file.
:type upload_file_path: str
:param compress_upload_file: wheth... | code_fim | hard | {
"lang": "python",
"repo": "BingAds/BingAds-Python-SDK",
"path": "/bingads/v13/bulk/bulk_service_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BingAds/BingAds-Python-SDK path: /bingads/v13/bulk/bulk_service_manager.py
) Tracking the percent complete progress information for the bulk operation.
:type progress: BulkOperationProgressInfo -> None
:return: Bulk entity generator.
:rtype: generator[BulkEntity]
"... | code_fim | hard | {
"lang": "python",
"repo": "BingAds/BingAds-Python-SDK",
"path": "/bingads/v13/bulk/bulk_service_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
##==========================================================================================
##Get information for genome annotation.
##==========================================================================================
##=======================================================================... | code_fim | hard | {
"lang": "python",
"repo": "benjaminfang/stream",
"path": "/stream_v1/pgaa",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('-'*50)
#===============================================================================================
#===============================================================================================
#Get information for genome assembly.
print('-'*50)
print('Geting assembly configure information.... | code_fim | hard | {
"lang": "python",
"repo": "benjaminfang/stream",
"path": "/stream_v1/pgaa",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benjaminfang/stream path: /stream_v1/pgaa
#! /usr/bin/env python3
import os
import sys
import datetime
from lib.check_env import check_env
from lib.get_information import read_assembly_config_file, get_info_when_dir, hand_input_info
from lib.genome_assembly import genome_assembly
from lib.genome_... | code_fim | hard | {
"lang": "python",
"repo": "benjaminfang/stream",
"path": "/stream_v1/pgaa",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ronuchit/pddlstream path: /pddlstream/retired/successor_generator.py
from collections import defaultdict, deque
from pddlstream.algorithms.downward import literal_holds, get_derived_predicates, apply_action
from pddlstream.algorithms.instantiate_task import get_goal_instance
from pddlstream.algo... | code_fim | hard | {
"lang": "python",
"repo": "ronuchit/pddlstream",
"path": "/pddlstream/retired/successor_generator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.root.get_successors(self.fluent_order, state)
##################################################
def mark_axiom(queue, remaining_from_axiom, axiom, axiom_from_atom):
if not remaining_from_axiom[id(axiom)]:
axiom_from_atom[axiom.effect].append(axiom)
queue.append(a... | code_fim | hard | {
"lang": "python",
"repo": "ronuchit/pddlstream",
"path": "/pddlstream/retired/successor_generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(self.nodes) > 1:
self.join()
else:
self.logger.warn(f"Node already exists [{node.hostname}]")
def get_host(self) -> Node:
return self.host
def create_host(self) -> None:
host = Host()
node = Node(host.hostname)
... | code_fim | medium | {
"lang": "python",
"repo": "hisorange/scale",
"path": "/src/scale/network/map.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hisorange/scale path: /src/scale/network/map.py
from scale.host import Host
from scale.logger import create_logger
from scale.network.node import Node
from scale.vpn import VPNManager
class Map:
def __init__(self, config, vpn: VPNManager) -> None:
self.logger = create_logger(self.__... | code_fim | medium | {
"lang": "python",
"repo": "hisorange/scale",
"path": "/src/scale/network/map.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 17. Header.
# 18. Logical Screen Descriptor.
data = self.pops(Gif.FMT_HEADER, self.data)
self.header = data[0]
self.ls_width = data[1]
self.ls_height = data[2]
self.background_color = data[4]
self.aspect_ratio = data[5]
# flags fi... | code_fim | hard | {
"lang": "python",
"repo": "Dirk-Sandberg/kivy",
"path": "/kivy/core/image/img_gif.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dirk-Sandberg/kivy path: /kivy/core/image/img_gif.py
img_width = ls_width
left = top = 0
# reverse top to bottom and left to right
tmp_top = (ls_height - (img_height + top))
img_width_plus_left = (img_width + left)
ls_wi... | code_fim | hard | {
"lang": "python",
"repo": "Dirk-Sandberg/kivy",
"path": "/kivy/core/image/img_gif.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # useless!
flags[2], flags[1], flags[0] = get_bits(len(self.palette), bits=3)
return (self.left, self.top, self.width, self.height, pack_bits(flags))
header = property(fget=get_header)
class GifDecoder(Gif):
'''decodes a gif file into.. something.. else..'''
def __... | code_fim | hard | {
"lang": "python",
"repo": "Dirk-Sandberg/kivy",
"path": "/kivy/core/image/img_gif.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AdityaStark7/blockchain_backend path: /blockchain-env/Lib/site-packages/pubnub/endpoints/file_operations/send_file_asyncio.py
import aiohttp
from pubnub.endpoints.file_operations.send_file import SendFileNative
from pubnub.endpoints.file_operations.publish_file_message import PublishFileMessage
... | code_fim | medium | {
"lang": "python",
"repo": "AdityaStark7/blockchain_backend",
"path": "/blockchain-env/Lib/site-packages/pubnub/endpoints/file_operations/send_file_asyncio.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def options(self):
request_options = super(SendFileNative, self).options()
request_options.data = request_options.files
return request_options
async def future(self):
self._file_upload_envelope = await FetchFileUploadS3Data(self._pubnub).\
channel(self.... | code_fim | medium | {
"lang": "python",
"repo": "AdityaStark7/blockchain_backend",
"path": "/blockchain-env/Lib/site-packages/pubnub/endpoints/file_operations/send_file_asyncio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> request_options = super(SendFileNative, self).options()
request_options.data = request_options.files
return request_options
async def future(self):
self._file_upload_envelope = await FetchFileUploadS3Data(self._pubnub).\
channel(self._channel).\
... | code_fim | hard | {
"lang": "python",
"repo": "AdityaStark7/blockchain_backend",
"path": "/blockchain-env/Lib/site-packages/pubnub/endpoints/file_operations/send_file_asyncio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AlexRogalskiy/python path: /probability/self-writing-code-master/code_generation.py
from probability import with_probability
import random
def create_code_mutations(number_of_mutations):
code_mutations = []
for _ in range(number_of_mutations):
code_mutations.append(create_code())... | code_fim | hard | {
"lang": "python",
"repo": "AlexRogalskiy/python",
"path": "/probability/self-writing-code-master/code_generation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def whitespace(indents):
return indents * " "
def get_current_number_of_indents(code):
if len(code) > 0:
white_space_characters = len(code[-1]) - len(code[-1].lstrip(' '))
return white_space_characters / 4
else:
return 0
def last_command_is_pass(code):
if le... | code_fim | hard | {
"lang": "python",
"repo": "AlexRogalskiy/python",
"path": "/probability/self-writing-code-master/code_generation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('game', '0004_auto_20200214_2132'),
]
operations = [
migrations.AlterField(
model_name='company',
name='company_id',
field=models.IntegerField(default=328508396),
),
migrations.AlterField(
model... | code_fim | medium | {
"lang": "python",
"repo": "lhy0807/industry_simulator",
"path": "/game/migrations/0005_auto_20200214_2136.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='company',
name='company_id',
field=models.IntegerField(default=328508396),
),
migrations.AlterField(
model_name='game',
name='counter_time',
field=models.Da... | code_fim | medium | {
"lang": "python",
"repo": "lhy0807/industry_simulator",
"path": "/game/migrations/0005_auto_20200214_2136.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lhy0807/industry_simulator path: /game/migrations/0005_auto_20200214_2136.py
# Generated by Django 3.0.2 on 2020-02-15 02:36
import datetime
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
... | code_fim | medium | {
"lang": "python",
"repo": "lhy0807/industry_simulator",
"path": "/game/migrations/0005_auto_20200214_2136.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whyjz/CARST path: /extra/unused/ntf_overlap.py
#!/usr/bin/python
'''Overlap module for NTF (JPEG2000) files
Created by Andrew Melkonian, 2014'''
import os
import re;
import subprocess
import sys;
# Global variables
MIN_OVERLAP = 1.0 # [km^2]
UTM_ZONE = "41X";
if len(sys.argv) > 2:
imag... | code_fim | hard | {
"lang": "python",
"repo": "whyjz/CARST",
"path": "/extra/unused/ntf_overlap.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cmd = "\ngrdmask " + ice + " -Gice_mask.grd -I" + interval + "= " + R + " -NNaN/NaN/1 -m\n";
cmd += "\ngrdmath image1.grd ice_mask.grd OR = image1.grd\n";
cmd += "\ngrdmath image2.grd ice_mask.grd OR = image2.grd\n";
cmd += "\ngrdmath image1.grd image2.grd OR = image_overlap.grd\n";
su... | code_fim | hard | {
"lang": "python",
"repo": "whyjz/CARST",
"path": "/extra/unused/ntf_overlap.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: simlmx/pyvst path: /tests/test_host.py
import random
import pytest
from pyvst import SimpleHost
from pyvst.host import Transport
def test_transport():
transport = Transport(sample_rate=48000., tempo=120.)
block_size = 512
transport.step(block_size)
assert transport.has_change... | code_fim | hard | {
"lang": "python",
"repo": "simlmx/pyvst",
"path": "/tests/test_host.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_play_note_twice(host):
vel = 127
sound1 = host.play_note(note=64, min_duration=1., max_duration=2., note_duration=1.,
velocity=vel)
sound2 = host.play_note(note=65, min_duration=1., max_duration=2., note_duration=1.,
velocity=vel... | code_fim | hard | {
"lang": "python",
"repo": "simlmx/pyvst",
"path": "/tests/test_host.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model_file = model_path + self.task + '_' + str(oc) + '_pipeline.joblib'
if os.path.isfile(model_file):
model = joblib.load(model_file)
return model
return None
def save_all_models(self):
""" For each operative center saves all model... | code_fim | hard | {
"lang": "python",
"repo": "AndreaUrgolo/machinelearningwebservices",
"path": "/duration_prediction/ws/duration_prediction/model_api/libs/ml/ml_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AndreaUrgolo/machinelearningwebservices path: /duration_prediction/ws/duration_prediction/model_api/libs/ml/ml_manager.py
# -*- coding: utf-8 -*-
#Author: Andrea Urgolo @Space1
import sys
from os import path
import os.path
import pandas as pd
import random
import time
# from scipy.stats... | code_fim | hard | {
"lang": "python",
"repo": "AndreaUrgolo/machinelearningwebservices",
"path": "/duration_prediction/ws/duration_prediction/model_api/libs/ml/ml_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_model_pipeline_from_file(self, oc):
"""
Given an operative center id oc, returns the related model pipeline.
The data is loaded from file
"""
# Load model related files
model_path = self.config['DATA_PATH'] + self.config['CUSTOME... | code_fim | hard | {
"lang": "python",
"repo": "AndreaUrgolo/machinelearningwebservices",
"path": "/duration_prediction/ws/duration_prediction/model_api/libs/ml/ml_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstates/openstates.org path: /bundles/views.py
import csv
from collections import defaultdict
from django.shortcuts import render
from django.http import HttpResponse
from django.db.models import F
from utils.common import pretty_url
from .models import Bundle
def bundle_view(request, slug):... | code_fim | medium | {
"lang": "python",
"repo": "openstates/openstates.org",
"path": "/bundles/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> writer = csv.DictWriter(
response,
fieldnames=[
"state",
"session",
"identifier",
"title",
"introduced",
"latest_action_description",
"latest_action_date",
"openstates_url",
],
)... | code_fim | hard | {
"lang": "python",
"repo": "openstates/openstates.org",
"path": "/bundles/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Should be after groups.middleware.GroupAwareMiddleware
"""
def process_view(self, request, view, view_args, view_kwargs):
"""Raises PermissionDenied if user has not access to group."""
group = getattr(request, 'group', None)
if group is not None and getattr(group, 'priv... | code_fim | hard | {
"lang": "python",
"repo": "emacsway/pinax",
"path": "/pinax/middleware/security.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emacsway/pinax path: /pinax/middleware/security.py
from __future__ import absolute_import, unicode_literals
import re
from django.conf import settings
from django.contrib.auth.views import redirect_to_login
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import ... | code_fim | hard | {
"lang": "python",
"repo": "emacsway/pinax",
"path": "/pinax/middleware/security.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>LOGIN_REQUIRE_URL_EXCEPTIONS = getattr(
settings,
'LOGIN_REQUIRE_URL_EXCEPTIONS',
DEFAULT_LOGIN_REQUIRE_URL_EXCEPTIONS
)
LOGIN_REQUIRE_REGEXP_EXCEPTIONS = getattr(
settings,
'LOGIN_REQUIRE_REGEXP_EXCEPTIONS',
DEFAULT_LOGIN_REQUIRE_REGEXP_EXCEPTIONS
)
class HideSensistiveFieldsMi... | code_fim | hard | {
"lang": "python",
"repo": "emacsway/pinax",
"path": "/pinax/middleware/security.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> list_display = ['id','user','product','quantity']
@admin.register(OrderPlaced)
class OrderPlacedModelAdmin(admin.ModelAdmin):
list_display = ['id','user','customer','product','quantity','ordered_date','status']<|fim_prefix|># repo: Puisque/Book-Store path: /app/admin.py
from django.contrib impor... | code_fim | hard | {
"lang": "python",
"repo": "Puisque/Book-Store",
"path": "/app/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Puisque/Book-Store path: /app/admin.py
from django.contrib import admin
from .models import(
Customer,
Product,
Cart,
OrderPlaced,
Comment
)
admin.site.register(Comment)
@admin.register(Customer)
class CustomerModelAdmin(admin.ModelAdmin):
list_display = ['id','user','... | code_fim | hard | {
"lang": "python",
"repo": "Puisque/Book-Store",
"path": "/app/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@admin.register(OrderPlaced)
class OrderPlacedModelAdmin(admin.ModelAdmin):
list_display = ['id','user','customer','product','quantity','ordered_date','status']<|fim_prefix|># repo: Puisque/Book-Store path: /app/admin.py
from django.contrib import admin
from .models import(
Customer,
Produ... | code_fim | hard | {
"lang": "python",
"repo": "Puisque/Book-Store",
"path": "/app/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Get all links to Google Drive and try to download them.
def get_soup(soup):
logger.debug('Getting google drive links..')
ids = []
for link in soup.findAll('a'):
this_link = link.get('href')
if any(pattern in str(this_link).lower() for pattern in url_patterns):
id... | code_fim | hard | {
"lang": "python",
"repo": "anycorn/yiff_scraper",
"path": "/downloader/googledrive.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anycorn/yiff_scraper path: /downloader/googledrive.py
import logging
import requests
from downloader import download
logger = logging.getLogger('gdrive')
url_patterns = ['drive.google']
def get_link(link):
download_file_from_google_drive(_get_id(link))
# https://stackoverflow.com/questi... | code_fim | hard | {
"lang": "python",
"repo": "anycorn/yiff_scraper",
"path": "/downloader/googledrive.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ethanjperez/convince path: /ParlAI/parlai/tasks/empathetic_dialogues/agents.py
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
from par... | code_fim | hard | {
"lang": "python",
"repo": "ethanjperez/convince",
"path": "/ParlAI/parlai/tasks/empathetic_dialogues/agents.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fpath = os.path.join(
self.opt['datapath'], 'empatheticdialogues', 'empatheticdialogues',
fold + '.csv',
)
df = open(fpath).readlines()
self.data = []
dialog = []
for i in range(1, len(df)):
cparts = df[i-1].strip().spli... | code_fim | hard | {
"lang": "python",
"repo": "ethanjperez/convince",
"path": "/ParlAI/parlai/tasks/empathetic_dialogues/agents.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dialog.append((
contextt, label, prompt, sit, context_emb, cand_emb, ft_ctx,
ft_cand, inline_label_candidates,
))
else:
if len(dialog) > 0:
self.data.append(dialog)
dia... | code_fim | hard | {
"lang": "python",
"repo": "ethanjperez/convince",
"path": "/ParlAI/parlai/tasks/empathetic_dialogues/agents.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tures))}
print(feat_dict)
def transform(data, feat_dict):
return [feat_dict[c] for c in data]
print(feat_dict.keys())
new_data=['n','b','a']
print(transform(new_data, feat_dict))<|fim_prefix|># repo: crazyanhao/Python path: /99乘法表.py
import numpy as np
letters=np.array(list("qwertyuiopasdfghjklzxcvbn... | code_fim | medium | {
"lang": "python",
"repo": "crazyanhao/Python",
"path": "/99乘法表.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crazyanhao/Python path: /99乘法表.py
import numpy as np
letters=np.array(list("qwertyuiopasdfghjklzxcvbnm"))
data=letters[np.ra<|fim_suffix|>tures))}
print(feat_dict)
def transform(data, feat_dict):
return [feat_dict[c] for c in data]
print(feat_dict.keys())
new_data=['n','b','a']
print(transfor... | code_fim | medium | {
"lang": "python",
"repo": "crazyanhao/Python",
"path": "/99乘法表.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> subscription = current_user.subscriptions.filter_by(
channel_id=form.channel_id.data
).first_or_404()
tag = current_user.tags.filter_by(name=form.tag_name.data).first_or_404()
results = subscription.untag(tag.id)
response = {"success": results}
return jsonify(response)<|fi... | code_fim | medium | {
"lang": "python",
"repo": "TrendingTechnology/Tubee",
"path": "/tubee/routes/api_subscription.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TrendingTechnology/Tubee path: /tubee/routes/api_subscription.py
from flask import Blueprint, abort, jsonify
from flask_login import current_user, login_required
from tubee.forms import TagSubscriptionForm
api_subscription_blueprint = Blueprint("api_subscription", __name__)
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/Tubee",
"path": "/tubee/routes/api_subscription.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoshuaCochran/Undertiers path: /backend/undertier_api/undertiers/migrations/0020_auto_20190921_1355.py
# Generated by Django 2.2.2 on 2019-09-21 20:55
from django.db import migrations, models
<|fim_suffix|> dependencies = [
('undertiers', '0019_auto_20190811_0245'),
]
operat... | code_fim | medium | {
"lang": "python",
"repo": "JoshuaCochran/Undertiers",
"path": "/backend/undertier_api/undertiers/migrations/0020_auto_20190921_1355.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('undertiers', '0019_auto_20190811_0245'),
]
operations = [
migrations.AddField(
model_name='map',
name='early_game',
field=models.ManyToManyField(related_name='EarlyGame', to='undertiers.Unit'),
),
migration... | code_fim | medium | {
"lang": "python",
"repo": "JoshuaCochran/Undertiers",
"path": "/backend/undertier_api/undertiers/migrations/0020_auto_20190921_1355.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (os.path.exists(config['MP3_ROOT_FOLDER'] + "telegram_voice.wav")):
os.remove(config['MP3_ROOT_FOLDER'] + "telegram_voice.wav")
command = "opusdec " + ogg_file + " " + config['MP3_ROOT_FOLDER'] + "telegram_voice.wav"
executor.execute_block(command, "opusdec", False)
... | code_fim | medium | {
"lang": "python",
"repo": "davandev/davanserver",
"path": "/davan/util/converter_functions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davandev/davanserver path: /davan/util/converter_functions.py
'''
@author: davandev
'''
import os
import logging
import davan.util.cmd_executor as executor
global logger
logger = logging.getLogger(os.path.basename(__file__))
def ogg_to_wav(config, ogg_file):
if (not os.path.exists(... | code_fim | medium | {
"lang": "python",
"repo": "davandev/davanserver",
"path": "/davan/util/converter_functions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = Profile.objects.get(user=request.user.id)
neccesities = Establishment.objects.all().filter(hood=user.hood)
current_user = request.user
if request.method == 'POST':
hood = Hood.objects.get(name=user.hood)
form = AddEstablishment(request.POST, request.FILES)
if... | code_fim | hard | {
"lang": "python",
"repo": "Machel54/Neighbour-hood-Watch",
"path": "/neighbour/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@login_required(login_url='/accounts/login/')
def post_business(request):
current_user = request.user
if request.method == 'POST':
form = PostBusinessForm(request.POST, request.FILES)
if form.is_valid():
image = form.save(commit=False)
image.owner = current_... | code_fim | hard | {
"lang": "python",
"repo": "Machel54/Neighbour-hood-Watch",
"path": "/neighbour/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Machel54/Neighbour-hood-Watch path: /neighbour/views.py
from django.shortcuts import render,redirect
from django.http import HttpResponse
from .forms import *
from django.contrib.auth.decorators import login_required
# Create your views here.
@login_required(login_url='/accounts/login/')
def i... | code_fim | hard | {
"lang": "python",
"repo": "Machel54/Neighbour-hood-Watch",
"path": "/neighbour/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(sample())
main()<|fim_prefix|># repo: tuomasr/pazel path: /sample_app/xyz/abc1.py
from foo import sample # Import from foo's public interface.
from foo import foo # Import a module with the same name as the package.
<|fim_middle|>
def main():
| code_fim | easy | {
"lang": "python",
"repo": "tuomasr/pazel",
"path": "/sample_app/xyz/abc1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tuomasr/pazel path: /sample_app/xyz/abc1.py
from foo import sample # Import from foo's public interface.
from foo import foo # Import a module with the same name as the package.
<|fim_suffix|> print(sample())
main()<|fim_middle|>def main():
| code_fim | easy | {
"lang": "python",
"repo": "tuomasr/pazel",
"path": "/sample_app/xyz/abc1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def save_model(self, request, obj, form, change):
obj.user = request.user
super(IncidentAdmin, self).save_model(request, obj, form, change)<|fim_prefix|># repo: matthewjweaver/mechanical-checklist path: /mechanical_checklist/events/admin.py
from django.contrib import admin
from .model... | code_fim | hard | {
"lang": "python",
"repo": "matthewjweaver/mechanical-checklist",
"path": "/mechanical_checklist/events/admin.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matthewjweaver/mechanical-checklist path: /mechanical_checklist/events/admin.py
from django.contrib import admin
from .models import Event, Incident
@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
list_display = ["name"]
<|fim_suffix|> exclude = ["user"]
readonly_fields = ... | code_fim | medium | {
"lang": "python",
"repo": "matthewjweaver/mechanical-checklist",
"path": "/mechanical_checklist/events/admin.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> obj.user = request.user
super(IncidentAdmin, self).save_model(request, obj, form, change)<|fim_prefix|># repo: matthewjweaver/mechanical-checklist path: /mechanical_checklist/events/admin.py
from django.contrib import admin
from .models import Event, Incident
@admin.register(Event)
class... | code_fim | hard | {
"lang": "python",
"repo": "matthewjweaver/mechanical-checklist",
"path": "/mechanical_checklist/events/admin.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: angelsjiang/ismp path: /backend/api/blogpost/models.py
from django.db import models
from datetime import date
# Create your models here.
class Blogpost(models.Model):
# title = models.CharField(max_length=255, null=False)
# body = models.CharField(max_length=1000, null=False)
media_url = mode... | code_fim | hard | {
"lang": "python",
"repo": "angelsjiang/ismp",
"path": "/backend/api/blogpost/models.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def update(self, instance, validated_data):
instance.media_url = validated_data.get("media_url", instance.language)
instance.author_id = validated_data.get("author_id", instance.blogpost)
instance.posted_on = validated_data.get("posted_on", instance.title_content)
instance.save()
return instanc... | code_fim | medium | {
"lang": "python",
"repo": "angelsjiang/ismp",
"path": "/backend/api/blogpost/models.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Blogpost.objects.create(**validated_data)
def update(self, instance, validated_data):
instance.media_url = validated_data.get("media_url", instance.language)
instance.author_id = validated_data.get("author_id", instance.blogpost)
instance.posted_on = validated_data.get("posted_on", instan... | code_fim | medium | {
"lang": "python",
"repo": "angelsjiang/ismp",
"path": "/backend/api/blogpost/models.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if x == 0:
return 0
cur = x
while cur * cur > x:
cur = (cur + x / cur) / 2
return int(cur)<|fim_prefix|># repo: dylanlee101/leetcode path: /code_new_start_2021/homework/sqrt.py
'''
'''
class Solution:
def sqrtx(self,x):
if x== 0 or x... | code_fim | medium | {
"lang": "python",
"repo": "dylanlee101/leetcode",
"path": "/code_new_start_2021/homework/sqrt.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dylanlee101/leetcode path: /code_new_start_2021/homework/sqrt.py
'''
'''
class Solution:
def sqrtx(self,x):
if x== 0 or x == 1:
return x
left,right = 1,x
while left < right:
mid = left + (right - left) / 2
if mid * mid > x:
... | code_fim | medium | {
"lang": "python",
"repo": "dylanlee101/leetcode",
"path": "/code_new_start_2021/homework/sqrt.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_urls(self):
urls = [
url(r'^ticket/$', self.ticket_list_view.as_view(), name='ticket-list'),
url(r'^ticket/create/$', self.ticket_create_view.as_view(),
name='ticket-create'),
url(
r'^ticket/update/(?P<pk>[{0}]+)/$'.fo... | code_fim | hard | {
"lang": "python",
"repo": "SalahAdDin/django-oscar-support",
"path": "/oscar_support/dashboard/app.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SalahAdDin/django-oscar-support path: /oscar_support/dashboard/app.py
from django.conf.urls import url
from django.contrib.admin.views.decorators import staff_member_required
from shortuuid import get_alphabet
from oscar.core.application import DashboardApplication
from . import views
class ... | code_fim | hard | {
"lang": "python",
"repo": "SalahAdDin/django-oscar-support",
"path": "/oscar_support/dashboard/app.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> bpy.utils.unregister_module(__name__)
ui.unregister()
operators.unregister()
properties.unregister()
if load_handler in bpy.app.handlers.load_post:
bpy.app.handlers.load_post.remove(load_handler)<|fim_prefix|># repo: SkyLeach/BlenderPanda path: /__init__.py
bl_info = { # pylin... | code_fim | medium | {
"lang": "python",
"repo": "SkyLeach/BlenderPanda",
"path": "/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bpy.utils.register_module(__name__)
ui.register()
operators.register()
properties.register()
bpy.app.handlers.load_post.append(load_handler)
def unregister():
bpy.utils.unregister_module(__name__)
ui.unregister()
operators.unregister()
properties.unregister()
if l... | code_fim | medium | {
"lang": "python",
"repo": "SkyLeach/BlenderPanda",
"path": "/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SkyLeach/BlenderPanda path: /__init__.py
bl_info = { # pylint: disable=invalid-name
"name": "Panda3D Integration",
"author": "Mitchell Stokes",
"version": (0, 2, 0),
"blender": (2, 76, 0),
"location": "Info header, render engine menu",
"description": "Run Panda3D from insi... | code_fim | hard | {
"lang": "python",
"repo": "SkyLeach/BlenderPanda",
"path": "/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allure-framework/allure-python path: /tests/allure_pytest/acceptance/step/test_step_with_several_step_inside_thread.py
from hamcrest import assert_that
from tests.allure_pytest.pytest_runner import AllurePytestRunner
from allure_commons_test.report import has_test_case
from allure_commons_test.r... | code_fim | hard | {
"lang": "python",
"repo": "allure-framework/allure-python",
"path": "/tests/allure_pytest/acceptance/step/test_step_with_several_step_inside_thread.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_that(
allure_results,
has_test_case(
"test_thread",
has_step("thread 1"),
has_step("thread 2"),
has_step("thread 3"),
has_step(
"Reuse previous threads",
has_step("thread 1"),
... | code_fim | hard | {
"lang": "python",
"repo": "allure-framework/allure-python",
"path": "/tests/allure_pytest/acceptance/step/test_step_with_several_step_inside_thread.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_current_object(self):
model,tree_iter = self.tree.get_selection().get_selected()
if tree_iter!=None:
(fc_object_sid)=model.get(tree_iter, 2)
return FCObject(fc_object_sid)
else:
print("Nothing selected!")<|fim_prefix|># repo: vvladych... | code_fim | hard | {
"lang": "python",
"repo": "vvladych/forecastmgmt",
"path": "/src/forecastmgmt/ui/masterdata/fc_object_list_mask.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vvladych/forecastmgmt path: /src/forecastmgmt/ui/masterdata/fc_object_list_mask.py
'''
Created on 04.05.2015
@author: vvladych
'''
from gi.repository import Gtk
from masterdata_abstract_window import AbstractListMask
from forecastmgmt.model.fc_object import FCObject
<|fim_suffix|>
def get_c... | code_fim | hard | {
"lang": "python",
"repo": "vvladych/forecastmgmt",
"path": "/src/forecastmgmt/ui/masterdata/fc_object_list_mask.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: phantranggg/HumanBoxes path: /eda/eda.py
from utils_dir import my_utils
import os
import argparse
import math
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
sns.set()
def statistic_box_ratio_mot():
dataset_dir = "/home/quanc... | code_fim | hard | {
"lang": "python",
"repo": "phantranggg/HumanBoxes",
"path": "/eda/eda.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
parser = argparse.ArgumentParser()
parser.add_argument('--gt', required=True, help='path of ground truth file')
parser.add_argument('--dataset', default="mot", help='dataset name')
args = parser.parse_args()
gt_path = args.gt
gt_json = my_utils.load_json(gt_path... | code_fim | hard | {
"lang": "python",
"repo": "phantranggg/HumanBoxes",
"path": "/eda/eda.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: taalua/wagner_vad path: /nn_modules/cls_pcen.py
# -*- coding: utf-8 -*-
__author__ = 'S.I. Mimilakis'
__copyright__ = 'Fraunhofer IDMT'
# imports
import torch
import torch.nn as nn
class PCEN(nn.Module):
"""
A learnable per-channel energy normalization operation.
"""
def __... | code_fim | hard | {
"lang": "python",
"repo": "taalua/wagner_vad",
"path": "/nn_modules/cls_pcen.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> m = torch.autograd.Variable(torch.zeros(x.size()))
for t_index in range(self.T):
m_prv = m[:, t_index-1, :].clone()
m[:, t_index, :] = sigma * x[:, t_index, :] + (1. - sigma) * m_prv
pcen_out = (x / ((m + self.eps) ** alpha) + delta) ** rho - delta ** rho
... | code_fim | hard | {
"lang": "python",
"repo": "taalua/wagner_vad",
"path": "/nn_modules/cls_pcen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grusy/vpc-router path: /vpcrouter/plugin_framework/__init__.py
"""
Copyright 2017 Pani Networks Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org... | code_fim | hard | {
"lang": "python",
"repo": "grusy/vpc-router",
"path": "/vpcrouter/plugin_framework/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from vpcrouter.errors import PluginError
def load_plugin(plugin_name, default_plugin_module):
"""
Load a plugin plugin.
Supports loading of plugins that are part of the vpcrouter, as well as
external plugins: If the plugin name has a dotted notation then it
assumes it's an external... | code_fim | hard | {
"lang": "python",
"repo": "grusy/vpc-router",
"path": "/vpcrouter/plugin_framework/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jnorwood/NNEF-Tools path: /legacy/caffe/nnef_converters/caffe_converters/caffe_to_nnef/caffe_to_dog/converters.py
# Copyright (c) 2017 The Khronos Group Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Yo... | code_fim | hard | {
"lang": "python",
"repo": "jnorwood/NNEF-Tools",
"path": "/legacy/caffe/nnef_converters/caffe_converters/caffe_to_nnef/caffe_to_dog/converters.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> op.add_arg("pool", params.pool)
op.add_arg("pad", converter.get_size(params, "pad", spatial_rank,
size_suffix="", default_value=0, size_is_list=False))
op.add_arg("kernel_size", kernel_size)
op.add_arg("stride", converter.get_size(params, "stride", ... | code_fim | hard | {
"lang": "python",
"repo": "jnorwood/NNEF-Tools",
"path": "/legacy/caffe/nnef_converters/caffe_converters/caffe_to_nnef/caffe_to_dog/converters.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: filipecn/foam_tools path: /foam2houdini/io.py
from pyrr import Vector3
from foam2houdini.logging import *
def read_foam_poly_mesh_points(filename) -> [Vector3]:
log_info("[foam poly mesh] Reading points from %s" % filename)
points = []
with open(filename, 'r') as file:
lines... | code_fim | hard | {
"lang": "python",
"repo": "filipecn/foam_tools",
"path": "/foam2houdini/io.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def read_foam_poly_mesh_neighbor(filename) -> [int]:
log_info("[foam poly mesh] Reading neighbors from %s" % filename)
neighbors = []
with open(filename, 'r') as file:
lines = file.readlines()
offset = 19
face_count = int(lines[offset])
offset += 2
for i... | code_fim | hard | {
"lang": "python",
"repo": "filipecn/foam_tools",
"path": "/foam2houdini/io.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_invalid_hosts(self):
"""
return the expired pub keys.
"""
invalid_pub_key = []
for host in self.config.get("hosts"):
if datetime.strptime(str(host.get("expire_date")), "%Y%m%d") < datetime.now():
invalid_pub_key.append(host.ge... | code_fim | medium | {
"lang": "python",
"repo": "yJunS/application-operation",
"path": "/apps/ssh-key-killer/SshKeyKiller/builder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
return the expired pub keys.
"""
invalid_pub_key = []
for host in self.config.get("hosts"):
if datetime.strptime(str(host.get("expire_date")), "%Y%m%d") < datetime.now():
invalid_pub_key.append(host.get("pub_key"))
return inva... | code_fim | medium | {
"lang": "python",
"repo": "yJunS/application-operation",
"path": "/apps/ssh-key-killer/SshKeyKiller/builder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yJunS/application-operation path: /apps/ssh-key-killer/SshKeyKiller/builder.py
# -*- coding: utf-8 -*-
from datetime import datetime
from .authorized_keys import AuthorizedKeys
from .logger import logger
from .utils import load_config, scan_authorized_keys
class :
"""
Killer remove the... | code_fim | hard | {
"lang": "python",
"repo": "yJunS/application-operation",
"path": "/apps/ssh-key-killer/SshKeyKiller/builder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>PLANETS = [
[
"alpha",
3,
"#FF0000",
[[5, -2], [-3, 4], [-3, -1]],
[150, 100],
0
],
[
"beta",
5,
"#FF8000",
[[7, -3], [1, 3], [-6, 5], [-5, 0], [3, -5]],
[210, 130],
0.2
],
[
"gamma"... | code_fim | hard | {
"lang": "python",
"repo": "claudiobierig/doppeldenk",
"path": "/spacetrading/logic/gamesettings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: claudiobierig/doppeldenk path: /spacetrading/logic/gamesettings.py
"""
Consists of constants used throughout the game
"""
PLANET_ROTATION_TIME = 10
PLANET_ROTATION_MOVE = -5
OFFER_DEMAND_EVENT_TIMES = [40, 20, 15, 10]
OFFER_DEMAND_EVENT_MOVE = -6
FINISH_TIME = 80
MIDGAME_SCORING_TIME = FINISH_TI... | code_fim | hard | {
"lang": "python",
"repo": "claudiobierig/doppeldenk",
"path": "/spacetrading/logic/gamesettings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.category2
@pytest.mark.ipus(4)
def test_notebook_2():
notebook_filename = EXAMPLE_ROOT_DIR / "fashionmnist_torchvision.ipynb"
with open(notebook_filename) as f:
nb = nbformat.read(f, as_version=4)
ep = ExecutePreprocessor(timeout=600, kernel_name="python3")
ep.preproc... | code_fim | hard | {
"lang": "python",
"repo": "graphcore/examples",
"path": "/vision/cnns/pytorch-lightning/test/test_notebook.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: graphcore/examples path: /vision/cnns/pytorch-lightning/test/test_notebook.py
# Copyright (c) 2022 Graphcore Ltd. All rights reserved.
import pathlib
import nbformat
import pytest
from nbconvert.preprocessors import ExecutePreprocessor
<|fim_suffix|> notebook_filename = EXAMPLE_ROOT_DIR / "f... | code_fim | hard | {
"lang": "python",
"repo": "graphcore/examples",
"path": "/vision/cnns/pytorch-lightning/test/test_notebook.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: y-i/rfc5389-stun-server-python path: /rfc5389stunserver/stunattributes/nonce.py
import logging
from rfc5389stunserver.constants import AttrType
from rfc5389stunserver.saslprep import SASLprep
from rfc5389stunserver.stun_attribute import STUNAttribute
logging.basicConfig(level=logging.INFO)
logg... | code_fim | medium | {
"lang": "python",
"repo": "y-i/rfc5389-stun-server-python",
"path": "/rfc5389stunserver/stunattributes/nonce.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Nonce:
def __init__(self, value):
if len(SASLprep.saslprep(value)) >= 128:
logger.error('Too long nonce')
raise Exception('Too long nonce')
self.type = AttrType.NONCE
self.value = SASLprep.saslprep(value).encode('utf-8')
@property
def len... | code_fim | medium | {
"lang": "python",
"repo": "y-i/rfc5389-stun-server-python",
"path": "/rfc5389stunserver/stunattributes/nonce.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def len(self):
return len(self.value)<|fim_prefix|># repo: y-i/rfc5389-stun-server-python path: /rfc5389stunserver/stunattributes/nonce.py
import logging
from rfc5389stunserver.constants import AttrType
from rfc5389stunserver.saslprep import SASLprep
from rfc5389stunserver.stun... | code_fim | hard | {
"lang": "python",
"repo": "y-i/rfc5389-stun-server-python",
"path": "/rfc5389stunserver/stunattributes/nonce.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def tearDownClass(cls):
cls.domain.delete()
MALTRow.objects.all().delete()
ensure_index_deleted(XFORM_INDEX_INFO.index)
super(MaltGeneratorTest, cls).tearDownClass()
@classmethod
def _setup_domain_user(cls):
cls.domain = Domain(name=cls... | code_fim | hard | {
"lang": "python",
"repo": "dungeonmaster51/commcare-hq",
"path": "/corehq/apps/data_analytics/tests/test_malt_generator.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_wam_yes_malt_counts(self):
# 2 forms for WAM.YES app
self._assert_malt_row_exists({
'app_id': self.wam_app_id,
'num_of_forms': 2,
'wam': YES,
})
def test_wam_not_set_malt_counts(self):
# 3 forms from self.DEVICE_ID for W... | code_fim | hard | {
"lang": "python",
"repo": "dungeonmaster51/commcare-hq",
"path": "/corehq/apps/data_analytics/tests/test_malt_generator.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dungeonmaster51/commcare-hq path: /corehq/apps/data_analytics/tests/test_malt_generator.py
import datetime
from django.test import TestCase
from dimagi.utils.dates import DateSpan
from pillowtop.es_utils import initialize_index_and_mapping
from corehq.apps.app_manager.const import AMPLIFIES_YE... | code_fim | hard | {
"lang": "python",
"repo": "dungeonmaster51/commcare-hq",
"path": "/corehq/apps/data_analytics/tests/test_malt_generator.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: freelan-developers/plix path: /tests/test_display.py
"""
Test the displays.
"""
from __future__ import unicode_literals
from unittest import TestCase
from mock import (
MagicMock,
patch,
call,
)
from chromalog.colorizer import GenericColorizer
from plix.displays import (
BaseDi... | code_fim | hard | {
"lang": "python",
"repo": "freelan-developers/plix",
"path": "/tests/test_display.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_stream_display_py2_no_color(self):
stream = MagicMock()
del stream.isatty
del stream.buffer
display = StreamDisplay(stream=stream)
display.set_context(commands=["my command"])
self.assertEqual(stream, display.stream)
self.assertEqual(st... | code_fim | hard | {
"lang": "python",
"repo": "freelan-developers/plix",
"path": "/tests/test_display.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: biocommons/hgvs path: /misc/refalt-repr-examples.py
#!/usr/bin/env python
import hgvs
import hgvs.parser
from tabulate import tabulate
from six.moves import map
<|fim_suffix|> v = hp.parse_hgvs_variant(h)
return [h, v.posedit.edit.ref, v.posedit.edit.alt, v.posedit.edit.type, v.posedit.l... | code_fim | hard | {
"lang": "python",
"repo": "biocommons/hgvs",
"path": "/misc/refalt-repr-examples.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.