text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: johndpope/bondster-bco path: /bbtest/helpers/statsd.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import socket
import threading
import time
import re
class StatsdHelper(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.__cancel = threading.Event()
... | code_fim | hard | {
"lang": "python",
"repo": "johndpope/bondster-bco",
"path": "/bbtest/helpers/statsd.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@blog_blueprint.route('/post/<url_title>')
def post(url_title):
single_post = Post.query.filter_by(url=url_title).first_or_404()
return render_template('blog/post.html', post=single_post)
@blog_blueprint.context_processor
def popular_tags():
tags = db\
.session\
.query(func.... | code_fim | medium | {
"lang": "python",
"repo": "tomasfarias/fariasweb",
"path": "/app/blog/routes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomasfarias/fariasweb path: /app/blog/routes.py
from flask import render_template, request, redirect, url_for
from flask_login import current_user
from sqlalchemy.sql.functions import func
from . import blog_blueprint
from app import db
from app.models import Post, tag_association_table, Tag
fro... | code_fim | medium | {
"lang": "python",
"repo": "tomasfarias/fariasweb",
"path": "/app/blog/routes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(result_file, "a") as f:
f.write('{timestep}\t{mean}\t{median}\n'.format(
timestep=timestep, mean=mean, median=median))
def start_training(args):
print('training started')
test_env = build_test_env(args)
print('action space... | code_fim | hard | {
"lang": "python",
"repo": "yuishihara/chainer-ppo",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yuishihara/chainer-ppo path: /main.py
from OpenGL import GL
import argparse
import numpy as np
import os
import roboschool
import gym
from ppo_actor import PPOActor
import numpy as np
from models.ppo_mujoco_model import PPOMujocoModel
from models.ppo_atari_model import PPOAtariModel
impor... | code_fim | hard | {
"lang": "python",
"repo": "yuishihara/chainer-ppo",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NekoApocalypse/leetcode-collection path: /15_threeSum/solution.py
class Solution:
def threeSum(self, nums):
nums = sorted(nums)
ans = []
for i, n1 in enumerate(nums):
if n1 > 0:
break
if i > 0 and n1 == nums[i - 1]:
... | code_fim | hard | {
"lang": "python",
"repo": "NekoApocalypse/leetcode-collection",
"path": "/15_threeSum/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sol = Solution()
cases = [
[-1, 0, 1, 2, -1, -4],
[],
[-1, 0, 0, 1, 1, 2, -1, -2, -4],
[-1, 0, 0, 0, 1, 1, 2, -1, -2, -4]
]
for case in cases:
print(case)
print(sol.threeSum(case))
print('------------------')
if __name__ == '__main_... | code_fim | hard | {
"lang": "python",
"repo": "NekoApocalypse/leetcode-collection",
"path": "/15_threeSum/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def setUpClass(cls):
cls.file_format = grammar.detect_format(os.path.join(TEST_DATA_PATH, 'testscalar.am'))
cls.header = grammar.get_header(os.path.join(TEST_DATA_PATH, 'testscalar.am'), cls.file_format)
cls.parsed_header = grammar.parse_header(cls.header)
... | code_fim | medium | {
"lang": "python",
"repo": "emdb-empiar/ahds",
"path": "/ahds/tests/test_grammar.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emdb-empiar/ahds path: /ahds/tests/test_grammar.py
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import unittest
from ahds import grammar
from ahds.tests import TEST_DATA_PATH
class TestGrammar(unittest.TestCase):
@classmethod
def setUpClass(cls):
<|fim_suffi... | code_fim | hard | {
"lang": "python",
"repo": "emdb-empiar/ahds",
"path": "/ahds/tests/test_grammar.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_detect_format(self):
self.assertIn(self.file_format, ['AmiraMesh', 'HyperSurface'])
def test_get_header(self):
self.assertTrue(len(self.header) > 0)
def test_parse_header(self):
self.assertTrue(len(self.parsed_header) > 0)<|fim_prefix|># repo: emdb-empiar/ahd... | code_fim | hard | {
"lang": "python",
"repo": "emdb-empiar/ahds",
"path": "/ahds/tests/test_grammar.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def calc():
n = int(sys.stdin.readline())
m = { 'Emperor Penguin' : 0, 'Little Penguin' : 0, 'Macaroni Penguin' : 0 }
for line in sys.stdin:
if (n <= 0):
break;
line = line.strip('\r\n')
m[line] = m[line] + 1
n = n - 1
c = 0
r = ''
for k... | code_fim | medium | {
"lang": "python",
"repo": "matrixjoeq/timus_solutions",
"path": "/1585/slu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> n = int(sys.stdin.readline())
m = { 'Emperor Penguin' : 0, 'Little Penguin' : 0, 'Macaroni Penguin' : 0 }
for line in sys.stdin:
if (n <= 0):
break;
line = line.strip('\r\n')
m[line] = m[line] + 1
n = n - 1
c = 0
r = ''
for k, v in m.ite... | code_fim | medium | {
"lang": "python",
"repo": "matrixjoeq/timus_solutions",
"path": "/1585/slu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matrixjoeq/timus_solutions path: /1585/slu.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
1585. Penguins
Time limit: 1.0 second
Memory limit: 64 MB
[Description]
Programmer Denis has been dreaming of visiting Antarctica since his childhood.
However, there are no regular flights to Antarctica ... | code_fim | hard | {
"lang": "python",
"repo": "matrixjoeq/timus_solutions",
"path": "/1585/slu.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SeanSyue/SklearnReferences path: /MachineLearning/project/project_main/Project_modified.py
import pandas as pd
import time
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.tree import DecisionTreeClassifier
from sklearn.neural_network import MLPClassifier
fr... | code_fim | hard | {
"lang": "python",
"repo": "SeanSyue/SklearnReferences",
"path": "/MachineLearning/project/project_main/Project_modified.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def model_selector(model_name):
model_selected = {'TREE': DecisionTreeClassifier(criterion='entropy', max_depth=5),
'MLP': MLPClassifier(activation='logistic', hidden_layer_sizes=(60,), max_iter=1000),
'BNB': BernoulliNB(),
... | code_fim | hard | {
"lang": "python",
"repo": "SeanSyue/SklearnReferences",
"path": "/MachineLearning/project/project_main/Project_modified.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>elderwood = Tree()
n1 = TreeNode(3)
n2 = TreeNode(5)
n3 = TreeNode(22)
n4 = TreeNode(1)
n5 = TreeNode(0)
n6 = TreeNode(-7)
n7 = TreeNode(8)
n8 = TreeNode(100)
n9 = TreeNode(-50)
elderwood.addnode(n1)
elderwood.addnode(n2)
elderwood.addnode(n3)
elderwood.addnode(n4)
elderwood.addnode(n5)
elderwood.addn... | code_fim | hard | {
"lang": "python",
"repo": "spencerzhang91/coconuts-on-fire",
"path": "/DSA/simpletree.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spencerzhang91/coconuts-on-fire path: /DSA/simpletree.py
# create a simple tree data structure with python
# First of all: a class implemented to present tree node
class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class Tree:
... | code_fim | hard | {
"lang": "python",
"repo": "spencerzhang91/coconuts-on-fire",
"path": "/DSA/simpletree.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def Inorder(root):
if root != None:
Inorder(root.left)
print(root.val, end=" ")
Inorder(root.right)
elderwood = Tree()
n1 = TreeNode(3)
n2 = TreeNode(5)
n3 = TreeNode(22)
n4 = TreeNode(1)
n5 = TreeNode(0)
n6 = TreeNode(-7)
n7 = TreeNode(8)
n8 = TreeNode(100)
n9 = TreeNode(... | code_fim | hard | {
"lang": "python",
"repo": "spencerzhang91/coconuts-on-fire",
"path": "/DSA/simpletree.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.snd_warn = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sounds/snd_warn.wav')
self.snd_notify = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sounds/snd_notify.wav')
def soft(self):
self.snd_warn = os.path.join(os.path.abspath(os.... | code_fim | hard | {
"lang": "python",
"repo": "Majorjjamo5/edr",
"path": "/edr/audiofeedback.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.snd_warn = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sounds/snd_warn_soft.wav')
self.snd_notify = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sounds/snd_notify_soft.wav')
def loud(self):
self.snd_warn = os.path.join(os.path.a... | code_fim | hard | {
"lang": "python",
"repo": "Majorjjamo5/edr",
"path": "/edr/audiofeedback.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Majorjjamo5/edr path: /edr/audiofeedback.py
from sys import platform
import os.path
if platform == 'darwin':
from AppKit import NSSound
class AudioFeedback(object):
def __init__(self):
self.snd_warn = NSSound.alloc().initWithContentsOfFile_byReference_(os.path.join... | code_fim | hard | {
"lang": "python",
"repo": "Majorjjamo5/edr",
"path": "/edr/audiofeedback.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> duration_in_seconds = 0
video_info = {}
video_duration = 0
file_format = file.split('.')[-1]
meta_file_name = file.replace(file_format, "csv")
source_url = url
if file_format == 'mp4':
video = moviepy.editor.VideoFileClip(file_dir + "/" + file)
duration_in_secon... | code_fim | hard | {
"lang": "python",
"repo": "sajeelsam/data-acquisition-pipeline",
"path": "/selenium_youtube_crawler/metadata_extractor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sajeelsam/data-acquisition-pipeline path: /selenium_youtube_crawler/metadata_extractor.py
import moviepy.editor
import pandas as pd
def get_config():
return {
'mode': 'complete',
'audio_id': None,
'cleaned_duration': None,
'num_of_speakers': None,
'la... | code_fim | hard | {
"lang": "python",
"repo": "sajeelsam/data-acquisition-pipeline",
"path": "/selenium_youtube_crawler/metadata_extractor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> metadata = create_metadata(video_info, yml)
metadata["source"] = source
return metadata
def extract_metadata(file_dir, file, url, source):
duration_in_seconds = 0
video_info = {}
video_duration = 0
file_format = file.split('.')[-1]
meta_file_name = file.replace(file_forma... | code_fim | hard | {
"lang": "python",
"repo": "sajeelsam/data-acquisition-pipeline",
"path": "/selenium_youtube_crawler/metadata_extractor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert df['col1'].loc[0] == 2 and df['col2'].loc[0] == 3<|fim_prefix|># repo: futotta-risu/JABA path: /tests/service/visualization/maps/numeric/test_GroupByCountMap.py
import pytest
from service.visualization.maps.numeric.GroupByCountMap import GroupByCountMap
import pandas as pd
def test_group_by... | code_fim | hard | {
"lang": "python",
"repo": "futotta-risu/JABA",
"path": "/tests/service/visualization/maps/numeric/test_GroupByCountMap.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_group_by_count_map_apply():
df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 3]})
map = GroupByCountMap({'variable': 'col2'})
df = map.apply(df)
assert df['col1'].loc[0] == 2 and df['col2'].loc[0] == 3<|fim_prefix|># repo: futotta-risu/JABA path: /tests/service/visualization/maps... | code_fim | medium | {
"lang": "python",
"repo": "futotta-risu/JABA",
"path": "/tests/service/visualization/maps/numeric/test_GroupByCountMap.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: futotta-risu/JABA path: /tests/service/visualization/maps/numeric/test_GroupByCountMap.py
import pytest
from service.visualization.maps.numeric.GroupByCountMap import GroupByCountMap
import pandas as pd
<|fim_suffix|> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 3]})
map = GroupByCoun... | code_fim | hard | {
"lang": "python",
"repo": "futotta-risu/JABA",
"path": "/tests/service/visualization/maps/numeric/test_GroupByCountMap.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
if not self.queue_exists:
self.queue.create_queue()
record.hostname = self.meta['hostname']
self.queue.send_message(
self.format(record)
)
except (KeyboardInterrupt, SystemExit):
raise
... | code_fim | hard | {
"lang": "python",
"repo": "jetavator/jetavator-databricks",
"path": "/jetavator_databricks_local/jetavator_databricks_local/logging/azure_queue_logging.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jetavator/jetavator-databricks path: /jetavator_databricks_local/jetavator_databricks_local/logging/azure_queue_logging.py
import logging
import os
import socket
from azure.core.exceptions import ResourceNotFoundError
class AzureQueueHandler(logging.Handler):
<|fim_suffix|> def emit(self, r... | code_fim | hard | {
"lang": "python",
"repo": "jetavator/jetavator-databricks",
"path": "/jetavator_databricks_local/jetavator_databricks_local/logging/azure_queue_logging.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def emit(self, record):
try:
if not self.queue_exists:
self.queue.create_queue()
record.hostname = self.meta['hostname']
self.queue.send_message(
self.format(record)
)
except (KeyboardInterrupt, SystemExit)... | code_fim | hard | {
"lang": "python",
"repo": "jetavator/jetavator-databricks",
"path": "/jetavator_databricks_local/jetavator_databricks_local/logging/azure_queue_logging.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> player_value = player_value - item_value
item_value = item_value + item_lvl_value
player_value = player_value + item_value
print("Your " + item_name + " now has " + str(item_value) + " " + value_name)
return player_value<|fim_prefix|># repo: micro164/AdvGame path: /Augment/Augment.py
from Classes.Cl... | code_fim | medium | {
"lang": "python",
"repo": "micro164/AdvGame",
"path": "/Augment/Augment.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: micro164/AdvGame path: /Augment/Augment.py
from Classes.Classes import Player
def augment(player_value, item_value, item_lvl_value, item_name, value_name):
<|fim_suffix|> player_value = player_value - item_value
item_value = item_value + item_lvl_value
player_value = player_value + item_value... | code_fim | medium | {
"lang": "python",
"repo": "micro164/AdvGame",
"path": "/Augment/Augment.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: machinezone/cobra path: /cobras/bavarde/client/encryption.py
'''256 bits AES encryption
Copyright (c) 2020 Machine Zone, Inc. All rights reserved.
'''
import base64
import pyaes
<|fim_suffix|> if key is None:
return f'<cannot decrypt: {ciphertext} -> Missing password>'
key = ... | code_fim | hard | {
"lang": "python",
"repo": "machinezone/cobra",
"path": "/cobras/bavarde/client/encryption.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> key = key.zfill(32)
aes = pyaes.AESModeOfOperationCTR(key.encode())
try:
binary = base64.b64decode(ciphertext)
plaintext = aes.decrypt(binary).decode()
return plaintext
except Exception as e:
return f'<cannot decrypt: {ciphertext} -> {e}>'<|fim_prefix|># rep... | code_fim | hard | {
"lang": "python",
"repo": "machinezone/cobra",
"path": "/cobras/bavarde/client/encryption.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if key is None:
return f'<cannot decrypt: {ciphertext} -> Missing password>'
key = key.zfill(32)
aes = pyaes.AESModeOfOperationCTR(key.encode())
try:
binary = base64.b64decode(ciphertext)
plaintext = aes.decrypt(binary).decode()
return plaintext
except ... | code_fim | medium | {
"lang": "python",
"repo": "machinezone/cobra",
"path": "/cobras/bavarde/client/encryption.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HBinhCT/Q-project path: /hackerearth/Data Structures/Arrays/Multi-dimensional/Submatrix Updates/solution.py
from sys import stdin
n, m, k = map(int, stdin.readline().strip().split())
matrix = []
for _ in range(n):
matrix.append(list(map(int, stdin<|fim_suffix|>[i][j] -= d
for i in range(n):
... | code_fim | hard | {
"lang": "python",
"repo": "HBinhCT/Q-project",
"path": "/hackerearth/Data Structures/Arrays/Multi-dimensional/Submatrix Updates/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>[i][j] -= d
for i in range(n):
tot = 0
for j in range(m):
tot += applying[i][j]
matrix[i][j] += tot
print(*matrix[i])<|fim_prefix|># repo: HBinhCT/Q-project path: /hackerearth/Data Structures/Arrays/Multi-dimensional/Submatrix Updates/solution.py
from sys import stdin
n, m, k... | code_fim | hard | {
"lang": "python",
"repo": "HBinhCT/Q-project",
"path": "/hackerearth/Data Structures/Arrays/Multi-dimensional/Submatrix Updates/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># set of mixed datatypes
# my_set = {1.0, "Hello", (1, 2, 3)}
# sprint(my_set)<|fim_prefix|># repo: krishnamanchikalapudi/examples.py path: /PythonTutor/session-8/sets.py
"""
Session: 8
Topic: Set: unique
"""
# set of integers
<|fim_middle|>my_set = {5, 6, 1, 2, 3, 4}
print(my_set)
my_set.add(1)
print... | code_fim | medium | {
"lang": "python",
"repo": "krishnamanchikalapudi/examples.py",
"path": "/PythonTutor/session-8/sets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>my_set.add(1)
print('after add 1 is {}'.format(my_set))
# set of mixed datatypes
# my_set = {1.0, "Hello", (1, 2, 3)}
# sprint(my_set)<|fim_prefix|># repo: krishnamanchikalapudi/examples.py path: /PythonTutor/session-8/sets.py
"""
Session: 8
Topic: Set: unique
"""
<|fim_middle|># set of integers
my_s... | code_fim | medium | {
"lang": "python",
"repo": "krishnamanchikalapudi/examples.py",
"path": "/PythonTutor/session-8/sets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: krishnamanchikalapudi/examples.py path: /PythonTutor/session-8/sets.py
"""
Session: 8
Topic: Set: unique
"""
<|fim_suffix|>my_set = {5, 6, 1, 2, 3, 4}
print(my_set)
my_set.add(1)
print('after add 1 is {}'.format(my_set))
# set of mixed datatypes
# my_set = {1.0, "Hello", (1, 2, 3)}
# sprint(m... | code_fim | easy | {
"lang": "python",
"repo": "krishnamanchikalapudi/examples.py",
"path": "/PythonTutor/session-8/sets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pulumi/pulumi-aws-native path: /sdk/python/pulumi_aws_native/codedeploy/get_application.py
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import copy
import warnings
import pu... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-aws-native",
"path": "/sdk/python/pulumi_aws_native/codedeploy/get_application.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param str application_name: A name for the application. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the application name.
"""
__args__ = dict()
__args__['applicationName'] = application_name
opts = pulumi.InvokeOptions.merge(_uti... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-aws-native",
"path": "/sdk/python/pulumi_aws_native/codedeploy/get_application.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetApplicationResult]:
"""
The AWS::CodeDeploy::Application resource creates an AWS CodeDeploy application
:param str application_name: A name for the application. If you don't specify a name, AWS CloudF... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-aws-native",
"path": "/sdk/python/pulumi_aws_native/codedeploy/get_application.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sqlalchemy/alembic path: /tests/test_autogen_indexes.py
q_(diffs[1][1].unique, True)
def test_mismatch_db_named_col_flag(self):
m1 = MetaData()
m2 = MetaData()
Table(
"item",
m1,
Column("x", Integer),
UniqueConstraint("x... | code_fim | hard | {
"lang": "python",
"repo": "sqlalchemy/alembic",
"path": "/tests/test_autogen_indexes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sqlalchemy/alembic path: /tests/test_autogen_indexes.py
int("x", name="SomeCasingConvention")
Table(
"new_idx",
m1,
Column("id1", Integer, primary_key=True),
Column("x", String(20)),
uq1,
)
uq2 = UniqueConstraint... | code_fim | hard | {
"lang": "python",
"repo": "sqlalchemy/alembic",
"path": "/tests/test_autogen_indexes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> eq_({diffs[0][1].name, diffs[1][1].name}, {"xy_idx", "y_idx"})
def test_add_ix_on_table_create(self):
m1 = MetaData()
m2 = MetaData()
Table("add_ix", m2, Column("x", String(50), index=True))
diffs = self._fixture(m1, m2)
eq_(diffs[0][0], "add_table")
... | code_fim | hard | {
"lang": "python",
"repo": "sqlalchemy/alembic",
"path": "/tests/test_autogen_indexes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> gpio_relay.setValue(GARAGE_STATE_OPEN_VALUE)
time.sleep(1)
gpio_relay.setValue(GARAGE_STATE_CLOSE_VALUE)<|fim_prefix|># repo: bikegriffith/onion-omega2-garage-door-webcam path: /app/main.py
import time
from flask import Flask, render_template
from onionGpio import OnionGpio
GARAGE_STATE_PIN ... | code_fim | hard | {
"lang": "python",
"repo": "bikegriffith/onion-omega2-garage-door-webcam",
"path": "/app/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bikegriffith/onion-omega2-garage-door-webcam path: /app/main.py
import time
from flask import Flask, render_template
from onionGpio import OnionGpio
GARAGE_STATE_PIN = 1
GARAGE_RELAY_PIN = 11
GARAGE_STATE_OPEN_VALUE = 1
GARAGE_STATE_CLOSE_VALUE = 0
GARAGE_RELAY_OPEN_VALUE = 0
GARAGE_RELAY_CLOSE... | code_fim | hard | {
"lang": "python",
"repo": "bikegriffith/onion-omega2-garage-door-webcam",
"path": "/app/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _status():
return int(gpio_state.getValue())
def _toggle():
gpio_relay.setValue(GARAGE_STATE_OPEN_VALUE)
time.sleep(1)
gpio_relay.setValue(GARAGE_STATE_CLOSE_VALUE)<|fim_prefix|># repo: bikegriffith/onion-omega2-garage-door-webcam path: /app/main.py
import time
from flask import Flas... | code_fim | hard | {
"lang": "python",
"repo": "bikegriffith/onion-omega2-garage-door-webcam",
"path": "/app/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> access_token = None
if 'Authorization' in request.headers:
auth_header = request.headers.get('Authorization')
access_token = auth_header.split(" ")[1]
if not access_token:
return error.unauthorized("Please login to perform this action")
u... | code_fim | medium | {
"lang": "python",
"repo": "hoslack/Book-A-Meal_API",
"path": "/app/decorators/decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @wraps(f)
def decorated(*args, **kwargs):
access_token = None
if 'Authorization' in request.headers:
auth_header = request.headers.get('Authorization')
access_token = auth_header.split(" ")[1]
if not access_token:
return error.unauthorize... | code_fim | medium | {
"lang": "python",
"repo": "hoslack/Book-A-Meal_API",
"path": "/app/decorators/decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hoslack/Book-A-Meal_API path: /app/decorators/decorators.py
from functools import wraps
from flask import request
from app.models.models import User
from app.custom_http_respones.responses import Success, Error
success = Success()
error = Error()
<|fim_suffix|> @wraps(f)
def decorated(*... | code_fim | hard | {
"lang": "python",
"repo": "hoslack/Book-A-Meal_API",
"path": "/app/decorators/decorators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>RUE", "0", "0", "0", "FALSE", "FALSE", "FALSE", "0", "TRUE"),
("80", "3794", "Bertha Torres-Harris", "TRUE", "FALSE", "TRUE", "0", "0", "0", "FALSE", "FALSE", "FALSE", "0", "TRUE"),
("81", "4223", "Eric Harthan", "TRUE", "FALSE", "TRUE", "0", "0", "0", "FALSE", "FALSE", "FALSE", "0", "TRUE"),
("82", "1727... | code_fim | hard | {
"lang": "python",
"repo": "kbrohkahn/kevin.broh-kahn.com",
"path": "/power-grid/current_results.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kbrohkahn/kevin.broh-kahn.com path: /power-grid/current_results.py
#!/usr/bin/env python
with open("../templates/header.html", "r") as header:
print header.read()
with open("../templates/navbar.html", "r") as navbar:
print navbar.read()
print """
<h1>WBC Power Grid Results</h1>
<p>Please view ... | code_fim | hard | {
"lang": "python",
"repo": "kbrohkahn/kevin.broh-kahn.com",
"path": "/power-grid/current_results.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = models.LegPresidedOverBy
fields = ['li_li_po']
def __init__(self, *args, **kwargs):
super(LegPresidedOverByForm, self).__init__(*args, **kwargs)
self.fields['li_li_po'] = forms.ModelChoiceField(queryset=models.CfgPresidingOfficers.objects,
... | code_fim | hard | {
"lang": "python",
"repo": "nhieckqo/lei",
"path": "/main/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nhieckqo/lei path: /main/forms.py
from django import forms
from . import models
class LegislativeInfoForm(forms.ModelForm):
class Meta:
model = models.LegislativeInfo
fields = ['record_no', 'series', 'approved_date', 'title', 'summary', 'body_text',]
<|fim_suffix|>
cl... | code_fim | hard | {
"lang": "python",
"repo": "nhieckqo/lei",
"path": "/main/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Generate a secure hash for this record with the email of the recipient with whom the record have been shared.
This is used to determine who is opening the link
to be able for the recipient to post messages on the document's portal view.
:param str email:
Em... | code_fim | hard | {
"lang": "python",
"repo": "SHIVJITH/Odoo_Machine_Test",
"path": "/addons/portal/models/mail_thread.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SHIVJITH/Odoo_Machine_Test path: /addons/portal/models/mail_thread.py
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import hashlib
import hmac
from odoo import api, fields, models, _
class MailThread(models.AbstractModel):
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "SHIVJITH/Odoo_Machine_Test",
"path": "/addons/portal/models/mail_thread.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># putting images in the directory
for img in img_tag:
try:
url = img[src']
response = rqts.get(url)
if response.status_code == 200:
with(open('image_' + str(va) + '.png', 'wb') as f:
f.write(rqts.get(url).content)
va+=1
except:
pass<|fim_prefix|># repo: carlinhosm... | code_fim | hard | {
"lang": "python",
"repo": "carlinhosmugiwara/twitter_bot",
"path": "/scraping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carlinhosmugiwara/twitter_bot path: /scraping.py
# scraping for the twitter bot
import os
import requests as rqts
from bs4 import BeautifulSoup as btsp # library to do the actual scraping
# site that has the images that will be used
url = 'examplesite.com/images'
# parsing of the page
page = r... | code_fim | medium | {
"lang": "python",
"repo": "carlinhosmugiwara/twitter_bot",
"path": "/scraping.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bkdwei/kdGUI path: /test/t17.py
'''
Created on 2019年6月3日
@author: bkd
'''
from collections import OrderedDict
import random
from tkinter import *
from tkintertable import TableCanvas, TableModel
from tkintertable.Testing import sampledata
# data = {'rec1': {'col1': 99.88, 'col2': 108.79, 'labe... | code_fim | medium | {
"lang": "python",
"repo": "bkdwei/kdGUI",
"path": "/test/t17.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.parent = parent
Frame.__init__(self)
self.main = self.master
self.main.geometry('800x500+200+100')
self.main.title('Test')
f = Frame(self.main)
f.pack(fill=BOTH, expand=1)
table = TableCanvas(f, data=data)
# table.importCSV('test... | code_fim | medium | {
"lang": "python",
"repo": "bkdwei/kdGUI",
"path": "/test/t17.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hamng/hamnguyen-sources path: /python/one-liner/numpy_zeros_ones.py
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 6 22:20:05 2019
@author: Ham
HackerRanch Challenge: Zeros and Ones
zeros
The zeros tool returns a new array with a given shape and type filled with 0's.
import nump... | code_fim | hard | {
"lang": "python",
"repo": "Hamng/hamnguyen-sources",
"path": "/python/one-liner/numpy_zeros_ones.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>Sample Input 0
3 3 3
Sample Output 0
[[[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]]]
[[[1 1 1]
[1 1 1]
[1 1 1]]
[[1 1 1]
[1 1 1]
[1 1 1]]
[[1 1 1]
[1 1 1]
[1 1 1]]]
Explanation 0
Print the array built using... | code_fim | hard | {
"lang": "python",
"repo": "Hamng/hamnguyen-sources",
"path": "/python/one-liner/numpy_zeros_ones.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: simondorfman/hello_cb_pro path: /src/app/cbt/cb_api.py
import json
import os
import requests
rest_url = os.getenv("CB_REST_URL")
max_requests = int(os.getenv("MAX_REQUESTS"))
def cb_post(url, data, auth):
return requests.post(
url,
data=json.dumps(data),
auth=auth,... | code_fim | hard | {
"lang": "python",
"repo": "simondorfman/hello_cb_pro",
"path": "/src/app/cbt/cb_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if side == "buy":
print(
"The API call succeeded but you have insufficient funds! You just need to deposit some fake money in your CB sandbox account."
)
else:
print(
"The API call succeeded but you have insufficient BTC! You just need to buy some BT... | code_fim | hard | {
"lang": "python",
"repo": "simondorfman/hello_cb_pro",
"path": "/src/app/cbt/cb_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> payload = {
"client_oid": order_id,
"product_id": product,
"side": side,
"type": "market",
"funds": funds,
}
resp = cb_post(f"{rest_url}/orders", payload, auth)
if "Insufficient funds" in resp.text:
print_insufficient_funds(side)
elif re... | code_fim | hard | {
"lang": "python",
"repo": "simondorfman/hello_cb_pro",
"path": "/src/app/cbt/cb_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __get_or_create_package(self, package_name, package_count):
if package_name not in self.package_names:
self.package_names.add(package_name)
package = Package(package_name, package_count)
self.packages.append(package)
return package
el... | code_fim | hard | {
"lang": "python",
"repo": "github/codeql",
"path": "/misc/scripts/library-coverage/packages.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: github/codeql path: /misc/scripts/library-coverage/packages.py
import csv
class PackagePart:
"""
Represents a single package part with its count returned from the QL query, such as:
"android.util",1,"remote","source",16
"""
def __init__(self, package, kind, part, count):
... | code_fim | hard | {
"lang": "python",
"repo": "github/codeql",
"path": "/misc/scripts/library-coverage/packages.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xmadsen/brancher.io path: /tests/test_tree.py
import pytest
import os
from brancher.tree import Tree
from brancher.constants import TREE_SPECIES
from brancher.node import RootNode
@pytest.fixture
def test_tree():
return Tree(name="Testric Logston", species=TREE_SPECIES["Loblolly Pine"])
<... | code_fim | medium | {
"lang": "python",
"repo": "xmadsen/brancher.io",
"path": "/tests/test_tree.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_tree_loads_from_pickle(test_tree):
before_tree = test_tree
test_tree.save()
after_tree = Tree.load(".tree_Testric Logston.pkl")
assert before_tree == after_tree<|fim_prefix|># repo: xmadsen/brancher.io path: /tests/test_tree.py
import pytest
import os
from brancher.tree import ... | code_fim | medium | {
"lang": "python",
"repo": "xmadsen/brancher.io",
"path": "/tests/test_tree.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Megvii-BaseDetection/cvpods path: /cvpods/utils/file/download.py
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import shutil
from typing import Callable, Optional
from urllib import request
from loguru import logger
def download(
u... | code_fim | hard | {
"lang": "python",
"repo": "Megvii-BaseDetection/cvpods",
"path": "/cvpods/utils/file/download.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> last_b = [0]
def inner(
b: int, bsize: int, tsize: Optional[int] = None
) -> None:
if tsize is not None:
t.total = tsize
t.update((b - last_b[0]) * bsize) # type: ignore
... | code_fim | hard | {
"lang": "python",
"repo": "Megvii-BaseDetection/cvpods",
"path": "/cvpods/utils/file/download.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
tmp, _ = request.urlretrieve(url, filename=tmp)
statinfo = os.stat(tmp)
size = statinfo.st_size
if size == 0:
raise IOError("Downloaded an empty file from {}!".format(url))
# download to tmp first and move to fpath, to make this functio... | code_fim | hard | {
"lang": "python",
"repo": "Megvii-BaseDetection/cvpods",
"path": "/cvpods/utils/file/download.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>try: # Nose
from nose.plugins.skip import SkipTest
except ImportError: # Failsafe
class SkipTest(Exception):
pass<|fim_prefix|># repo: JoeConyers/SpotifyRemote path: /build/pyspotify/tests/__init__.py
try: # 2.7
# pylint: disable = E0611,F0401
from unittest.case im... | code_fim | medium | {
"lang": "python",
"repo": "JoeConyers/SpotifyRemote",
"path": "/build/pyspotify/tests/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoeConyers/SpotifyRemote path: /build/pyspotify/tests/__init__.py
try: # 2.7
# pylint: disable = E0611,F0401
from unittest.case im<|fim_suffix|>portError: # Failsafe
class SkipTest(Exception):
pass<|fim_middle|>port SkipTest
# pylint: enable = E0611,F0401
except Im... | code_fim | medium | {
"lang": "python",
"repo": "JoeConyers/SpotifyRemote",
"path": "/build/pyspotify/tests/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DarthThomas/poolvr.py path: /poolvr/table.py
import os.path
import logging
_logger = logging.getLogger(__name__)
import numpy as np
# TODO: pkgutils way
TEXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
os.path.pardir,
... | code_fim | hard | {
"lang": "python",
"repo": "DarthThomas/poolvr.py",
"path": "/poolvr/table.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> surface_material=None,
surface_technique=None,
cushion_material=None,
cushion_technique=None,
rail_material=None,
rail_technique=None):
from .gl_rendering import Mesh, Material
... | code_fim | hard | {
"lang": "python",
"repo": "DarthThomas/poolvr.py",
"path": "/poolvr/table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
def _get_example_vector_line_str(example_to_print, vector_names):
example_str = "Example ID: {}\n".format(example_to_print[0])
all_vector_values = enumerate(example_to_print[1:])
for vector_idx, vector_values in all_vector_values:
example... | code_fim | hard | {
"lang": "python",
"repo": "CampagneLaboratory/GenotypeTensors",
"path": "/src/org/campagnelab/dl/genotypetensors/VectorReader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.example_id = example_id
self.vector_lines = {}
self.vector_ids = vector_ids
self.sample_id = sample_id
def set_example_id(self, example_id):
self.example_id = example_id
def same_example(self, other_example_id):
return self.example_id == other... | code_fim | hard | {
"lang": "python",
"repo": "CampagneLaboratory/GenotypeTensors",
"path": "/src/org/campagnelab/dl/genotypetensors/VectorReader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CampagneLaboratory/GenotypeTensors path: /src/org/campagnelab/dl/genotypetensors/VectorReader.py
import argparse
import sys
import itertools
import threading
from org.campagnelab.dl.genotypetensors.VectorPropertiesReader import VectorPropertiesReader
from org.campagnelab.dl.genotypetensors.Vec... | code_fim | hard | {
"lang": "python",
"repo": "CampagneLaboratory/GenotypeTensors",
"path": "/src/org/campagnelab/dl/genotypetensors/VectorReader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AdvaitDhingra/formulate path: /tests/test_constants.py
# Licensed under a 3-clause BSD style license, see LICENSE.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import pytest
from formulate import from_numexpr, to_numexpr
from formu... | code_fim | hard | {
"lang": "python",
"repo": "AdvaitDhingra/formulate",
"path": "/tests/test_constants.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def create_constant_test(input_string, input_backend='root', numexpr_raises=None):
assert input_backend in ('root', 'numexpr'), 'Unrecognised backend specified'
input_from_method = {
'root': from_root,
'numexpr': from_numexpr,
}[input_backend]
def test_constant():
... | code_fim | hard | {
"lang": "python",
"repo": "AdvaitDhingra/formulate",
"path": "/tests/test_constants.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return test_constant
# Test basic numexpr constants
test_numexpr_true = create_constant_test('True', input_backend='numexpr')
test_numexpr_false = create_constant_test('False', input_backend='numexpr')
# Test basic ROOT constants
test_true = create_constant_test('true')
test_false = create_constant... | code_fim | hard | {
"lang": "python",
"repo": "AdvaitDhingra/formulate",
"path": "/tests/test_constants.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> ## LoadComponent reads xaml to fill in Window contents, creates
## NewGameDialog members for named elements in the xaml, and hooks up
## event handling methods.
wpf.LoadComponent(self, "NewGameDialog.xaml")
self.sizeText.Text = "19"
## For now we only h... | code_fim | hard | {
"lang": "python",
"repo": "billchiles/sgfeditor",
"path": "/sgfpy/newdialog.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ### stones_mouse_left_down handles stonesGrid clicks to add moves as if a
### game is in session, add adornments, and handle the current move
### adornment.
###
def okButton_click (self, button, e):
self.DialogResult = True<|fim_prefix|># repo: billchiles/sgfeditor path:... | code_fim | hard | {
"lang": "python",
"repo": "billchiles/sgfeditor",
"path": "/sgfpy/newdialog.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: billchiles/sgfeditor path: /sgfpy/newdialog.py
### newdialog.py is just that, the New Game dialog to get basic game info for
### the New button.
###
import wpf
import clr
### Don't need this now due to new wpf module, but left as documentation of
### usage.
###
### Needed for System.W... | code_fim | hard | {
"lang": "python",
"repo": "billchiles/sgfeditor",
"path": "/sgfpy/newdialog.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aossp/android-vts path: /extra_tools/stage_fright_gen.py
#!/usr/bin/python
"""
Stagefright PoC for https://android.googlesource.com/platform/frameworks/av/+/2b50b7aa7d16014ccf35db7a7b4b5e84f7b4027c
"""
from struct import pack
def create_box(atom_type, data):
return pack("!I", len(data)+4+4)... | code_fim | medium | {
"lang": "python",
"repo": "aossp/android-vts",
"path": "/extra_tools/stage_fright_gen.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>f = open('sf-itunes-poc.mp4', 'wb')
f.write(ftyp_atom + moov_atom)
f.write("A"*(3*1024*1024))
f.close()<|fim_prefix|># repo: aossp/android-vts path: /extra_tools/stage_fright_gen.py
#!/usr/bin/python
"""
Stagefright PoC for https://android.googlesource.com/platform/frameworks/av/+/2b50b7aa7d16014ccf35db... | code_fim | hard | {
"lang": "python",
"repo": "aossp/android-vts",
"path": "/extra_tools/stage_fright_gen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codenameyau/cultivate path: /test/test_scraper.py
"""
Cultivate - test_scraper.py
Apache License (c) 2015
https://github.com/codenameyau/cultivate
"""
from tatoeba import scraper
import unittest
<|fim_suffix|> """
Tests that languages are set correctly
"""
# Test f... | code_fim | hard | {
"lang": "python",
"repo": "codenameyau/cultivate",
"path": "/test/test_scraper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_set_language(self):
"""
Tests that languages are set correctly
"""
# Test for default languages
self.assertEqual(self.scraper.language_original, 'jpn')
self.assertEqual(self.scraper.language_translated, 'eng')
# Test after setting suppo... | code_fim | medium | {
"lang": "python",
"repo": "codenameyau/cultivate",
"path": "/test/test_scraper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Tests that languages are set correctly
"""
# Test for default languages
self.assertEqual(self.scraper.language_original, 'jpn')
self.assertEqual(self.scraper.language_translated, 'eng')
# Test after setting supported languages
self.scrap... | code_fim | medium | {
"lang": "python",
"repo": "codenameyau/cultivate",
"path": "/test/test_scraper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sreeaurovindh/code_sprint path: /linkedlist/single_list.py
class ListNode:
def __init__(self,val):
self.val = val
self.next = None
class SingleLinkedList:
def __init__(self):
<|fim_suffix|> if index <0 or index > self.size:
return
pred = self.... | code_fim | hard | {
"lang": "python",
"repo": "sreeaurovindh/code_sprint",
"path": "/linkedlist/single_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> to_add = ListNode(val)
to_add.next = pred.next
pred.next = to_add
def deleteAtIndex(self,index):
if index <0 or index > self.size:
return
pred = self.head
for _ in range(index):
pred = pred.next
pred.next = pred.next.n... | code_fim | medium | {
"lang": "python",
"repo": "sreeaurovindh/code_sprint",
"path": "/linkedlist/single_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = wtypes.wsattr(wtypes.text, mandatory=True)
"""Name of the script."""
data = wtypes.wsattr(wtypes.text, mandatory=False)
"""Data of the script."""
checksum = wtypes.wsattr(wtypes.text, mandatory=False, readonly=True)
"""Checksum of the script data."""
@classmethod
... | code_fim | medium | {
"lang": "python",
"repo": "openstack/cloudkitty",
"path": "/cloudkitty/rating/pyscripts/datamodels/script.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Type describing a script.
"""
script_id = wtypes.wsattr(ck_types.UuidType(), mandatory=False)
"""UUID of the script."""
name = wtypes.wsattr(wtypes.text, mandatory=True)
"""Name of the script."""
data = wtypes.wsattr(wtypes.text, mandatory=False)
"""Data of the scrip... | code_fim | medium | {
"lang": "python",
"repo": "openstack/cloudkitty",
"path": "/cloudkitty/rating/pyscripts/datamodels/script.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/cloudkitty path: /cloudkitty/rating/pyscripts/datamodels/script.py
# -*- coding: utf-8 -*-
# Copyright 2015 Objectif Libre
#
# 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 c... | code_fim | hard | {
"lang": "python",
"repo": "openstack/cloudkitty",
"path": "/cloudkitty/rating/pyscripts/datamodels/script.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danieleugenewilliams/cookdata path: /cookdata.py
# cook_data_scraper.py
# Contributors:
# @dewilliams
#########################################################
# web service to analyze real estate trends using publicly available docs
# Test scenario for Cook County, Illinois.
# 1. http://c... | code_fim | hard | {
"lang": "python",
"repo": "danieleugenewilliams/cookdata",
"path": "/cookdata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># set up webdriver and get url
driver = webdriver.Firefox()
driver.get(url)
print("url finished")
time.sleep(5)
# get the LIS PENDENS from the menu
action = ActionChains(driver)
search_menu = driver.find_element_by_id("Navigator1_SearchCriteria1_menuLabel")
action.move_to_element(search_menu)
... | code_fim | hard | {
"lang": "python",
"repo": "danieleugenewilliams/cookdata",
"path": "/cookdata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for row in range(1,row_count+1):
print("start of for loop, row_count: "+str(row_count)+", row: "+str(row))
time.sleep(3)
doc_list = driver.find_element_by_id("DocList1_WidgetContainer")
doc_list.find_element_by_xpath('//*[@id="DocList1_ContentContainer1"]/table/tbo... | code_fim | hard | {
"lang": "python",
"repo": "danieleugenewilliams/cookdata",
"path": "/cookdata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.