text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: tanupoo/tiny_http_server path: /logging_ssl_socket.py
import ssl
from socket import socket
class logging_ssl_socket(ssl.SSLSocket):
def default_logger(self, *args, **kwargs):
pass
def __init__(self, *args, **kwargs):
if "logger" in kwargs:
self.logger = kwar... | code_fim | hard | {
"lang": "python",
"repo": "tanupoo/tiny_http_server",
"path": "/logging_ssl_socket.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
modified ssl.SSLSocket.accept() of ssl.py.
'''
#import pdb; pdb.set_trace()
newsock, addr = socket.accept(self)
self.logger.debug("Connection from {}".format(addr))
self.logger.debug("begin SSL handshake")
newsock = self.context.wrap_sock... | code_fim | hard | {
"lang": "python",
"repo": "tanupoo/tiny_http_server",
"path": "/logging_ssl_socket.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s='''
[console_scripts]
compress_dataset=singl.scripts.compress_dataset:compress_dataset
'''
)<|fim_prefix|># repo: mpff/hpa-single-cell-classification path: /setup.py
from setuptools import find_packages, setup
setup(
name='singl',
packages=find_packages(),
version='0.1.... | code_fim | medium | {
"lang": "python",
"repo": "mpff/hpa-single-cell-classification",
"path": "/setup.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mpff/hpa-single-cell-classification path: /setup.py
from setuptools import find_packages, setup
setup(
name='singl',
packages=find_packages(),
version='0.1.0',
description='Scripts and modules for the HPA Single Cell Classification challenge on Kaggle.',
aut<|fim_suffix|>s=''... | code_fim | medium | {
"lang": "python",
"repo": "mpff/hpa-single-cell-classification",
"path": "/setup.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def install(self, spec, prefix):
symly_c = """
#include <stdio.h>
int main() {
printf("I'm just here to give the build system something to do...");
return 0;
}
"""
mkdirp("%s/symly" % self.stage.source_path)
with open("%s/symly/symly.c" % self.stage.source_path, "w") a... | code_fim | medium | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin.mock/packages/symly/package.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> printf("I'm just here to give the build system something to do...");
return 0;
}
"""
mkdirp("%s/symly" % self.stage.source_path)
with open("%s/symly/symly.c" % self.stage.source_path, "w") as f:
f.write(symly_c)
gcc = which("/usr/bin/gcc")
if sys.platfor... | code_fim | hard | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin.mock/packages/symly/package.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JayjeetAtGithub/spack path: /var/spack/repos/builtin.mock/packages/symly/package.py
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
<|fim_suffix|>i... | code_fim | hard | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin.mock/packages/symly/package.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: boxwise/boxwise-flask path: /boxwise_flask/models/usergroup_base_access.py
from peewee import CompositeKey, IntegerField
from ..db import db
class UsergroupBaseAccess(db.Model):
base_id = IntegerField(column_name="camp_id")
usergroup_id = IntegerField(column_name="cms_usergroups_id")
... | code_fim | medium | {
"lang": "python",
"repo": "boxwise/boxwise-flask",
"path": "/boxwise_flask/models/usergroup_base_access.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.name
@staticmethod
def get_all_base_id_for(usergroup_id):
return UsergroupBaseAccess.select(UsergroupBaseAccess.base_id).where(
UsergroupBaseAccess.usergroup_id == usergroup_id
)<|fim_prefix|># repo: boxwise/boxwise-flask path: /boxwise_flask/model... | code_fim | medium | {
"lang": "python",
"repo": "boxwise/boxwise-flask",
"path": "/boxwise_flask/models/usergroup_base_access.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hfchong/fold path: /tensorflow_fold/blocks/result_types_test.py
# Copyright 2017 Google Inc. All Rights Reserved.
#
# 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
#
# ... | code_fim | hard | {
"lang": "python",
"repo": "hfchong/fold",
"path": "/tensorflow_fold/blocks/result_types_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class TensorTypeTest(TypeTest):
def test_hash(self):
self.assertHashes(tdt.TensorType, (), 'int32')
self.assertHashes(tdt.TensorType, (1, 2, 3))
def test_conversion(self):
t = tdt.TensorType((1, 2), 'int32')
self.assertEqual(repr(t), 'TensorType((1, 2), \'int32\')')
self.assertEq... | code_fim | hard | {
"lang": "python",
"repo": "hfchong/fold",
"path": "/tensorflow_fold/blocks/result_types_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assumed_role_object = sts_client.assume_role(
RoleArn=role_arn, RoleSessionName="AssumeRoleSession1"
)
credentials = assumed_role_object["Credentials"]
return boto3.client(
resource,
aws_access_key_id=credentials["AccessKeyId"],
aws_secret_access_key=credent... | code_fim | easy | {
"lang": "python",
"repo": "h4l/storage-service",
"path": "/scripts/migrations/2020-10-miro-migration/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: h4l/storage-service path: /scripts/migrations/2020-10-miro-migration/common.py
import boto3
sts_client = boto3.client("sts")
<|fim_suffix|> assumed_role_object = sts_client.assume_role(
RoleArn=role_arn, RoleSessionName="AssumeRoleSession1"
)
credentials = assumed_role_objec... | code_fim | easy | {
"lang": "python",
"repo": "h4l/storage-service",
"path": "/scripts/migrations/2020-10-miro-migration/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cz-qq/bk-chatbot path: /adapter/api/sites/open/cmsi.py
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making
蓝鲸智云PaaS平台社区版 (BlueKing PaaSCommunity Edition) available.
Copyright (C) 2017-2018 THL A29 Limited,
a Tencent company. All rights reserved.
L... | code_fim | hard | {
"lang": "python",
"repo": "cz-qq/bk-chatbot",
"path": "/adapter/api/sites/open/cmsi.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class _CmsiApi(object):
def __init__(self):
try:
from config.domains import CMSI_API_ROOT
self.get_msg_type = DataAPI(
method="POST",
url=CMSI_API_ROOT + "get_msg_type/",
module="TOF",
description="支持发送消息... | code_fim | hard | {
"lang": "python",
"repo": "cz-qq/bk-chatbot",
"path": "/adapter/api/sites/open/cmsi.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JFincher42/arcade path: /tests/test_gui/test_ui_inputbox.py
import pytest
from arcade.gui import UIEvent, TEXT_INPUT, TEXT_MOTION
from arcade.gui.elements.inputbox import UIInputBox
from arcade.key import *
from tests.test_gui import T
@pytest.mark.skip('This is hard to test, we would have to ... | code_fim | hard | {
"lang": "python",
"repo": "JFincher42/arcade",
"path": "/tests/test_gui/test_ui_inputbox.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> inputbox = UIInputBox(center_x=30, center_y=30, width=40, height=40)
inputbox.text = 'Best Game Lib!'
inputbox.cursor_index = 5
inputbox.on_focus()
mock_mng.add_ui_element(inputbox)
inputbox.on_ui_event(UIEvent(TEXT_MOTION, motion=MOTION_BACKSPACE))
assert inputbox.text == 'B... | code_fim | hard | {
"lang": "python",
"repo": "JFincher42/arcade",
"path": "/tests/test_gui/test_ui_inputbox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adiptdevtomar/emotions_backend path: /app/emotions/serializers.py
from rest_framework import serializers
from emotions import models
<|fim_suffix|>
class Meta:
model = models.EmotionModel
fields = ['text']<|fim_middle|>class EmotionsSerializer(serializers.ModelSerializer):
| code_fim | easy | {
"lang": "python",
"repo": "adiptdevtomar/emotions_backend",
"path": "/app/emotions/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Meta:
model = models.EmotionModel
fields = ['text']<|fim_prefix|># repo: adiptdevtomar/emotions_backend path: /app/emotions/serializers.py
from rest_framework import serializers
from emotions import models
<|fim_middle|>
class EmotionsSerializer(serializers.ModelSerializer):
| code_fim | easy | {
"lang": "python",
"repo": "adiptdevtomar/emotions_backend",
"path": "/app/emotions/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matrixbegins/python-recipes path: /image-resize/bulk-image-resize-s3/bulk_img_conversion.py
import boto3, os
from PIL import Image
from io import BytesIO
from datetime import datetime, timedelta
aws_key_id = os.getenv('AWS_KEY_ID', 'KK' )
aws_access_key = os.getenv('AWS_ACCESS_KEY', 'ACC' )
de... | code_fim | hard | {
"lang": "python",
"repo": "matrixbegins/python-recipes",
"path": "/image-resize/bulk-image-resize-s3/bulk_img_conversion.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def png_to_jpg(img):
payload = BytesIO()
img.save( payload, format="jpeg",optimize=True, quality=80)
payload.seek(0)
return payload
def jpg_to_png(img):
payload = BytesIO()
img.save( payload, format="png",optimize=True )
payload.seek(0)
return payload
def processIm... | code_fim | hard | {
"lang": "python",
"repo": "matrixbegins/python-recipes",
"path": "/image-resize/bulk-image-resize-s3/bulk_img_conversion.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :type rng: numpy.random.RandomState
:param rng: a random number generator used to initialize weights
:type input: None
:type batch_size: image batch size
:type image_size: dimensions of the image
:type imag... | code_fim | medium | {
"lang": "python",
"repo": "Python3pkg/DeepLearningStack",
"path": "/DeepLearningStack/Input/Img.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Python3pkg/DeepLearningStack path: /DeepLearningStack/Input/Img.py
import os
import sys
import time
import numpy as np
import theano
import theano.tensor as T
# implementing Rectified linear unit
class Img(object):
""" Initialize from xml definition node """
def __init__(self,layer_de... | code_fim | hard | {
"lang": "python",
"repo": "Python3pkg/DeepLearningStack",
"path": "/DeepLearningStack/Input/Img.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: icorecool/CHN path: /config.py
},
latest={
'url': '/newest',
'saved': 'data/hn_latest.json',
#'max_page': 10,
'max_page': 3,
'login': False,
},
past={
'url': '/front',
'sa... | code_fim | hard | {
"lang": "python",
"repo": "icorecool/CHN",
"path": "/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ('space',
('https://www.reddit.com/r/space/',
'https://www.reddit.com/r/space/top/')),
('physics',
('https://www.reddit.com/r/Physics/',
'https://www.reddit.com/r/Physics/top/')),
('math',
('https://www.reddit... | code_fim | hard | {
"lang": "python",
"repo": "icorecool/CHN",
"path": "/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ('ai',
('https://www.reddit.com/r/artificial/',
'https://www.reddit.com/r/artificial/top/')),
('agi',
('https://www.reddit.com/r/agi/',
'https://www.reddit.com/r/agi/top/',
'https://www.reddit.com/r/GeneralAIChall... | code_fim | hard | {
"lang": "python",
"repo": "icorecool/CHN",
"path": "/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: morpframework/morpfw path: /morpfw/oauth.py
import base64
import functools
import secrets
import morepath
from jwt import InvalidTokenError
from more.jwtauth import JWTIdentityPolicy
from oauthlib.common import Request as OAuthRequest
from oauthlib.oauth2 import RequestValidator as BaseRequestVa... | code_fim | hard | {
"lang": "python",
"repo": "morpframework/morpfw",
"path": "/morpfw/oauth.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def response_from_return(self, headers, body, status):
return morepath.Response(body=body, headers=headers, status=status)
def response_from_error(self, e):
raise HTTPBadRequest()
# @App.json(model=OAuthRoot, name="authorize")
# def authorize(context, request):
# oauth = OAut... | code_fim | hard | {
"lang": "python",
"repo": "morpframework/morpfw",
"path": "/morpfw/oauth.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>java_test_corpus = list(read_corpus(java_files_path,java_pattern))
print("Java Test corpus size: %s" % len(java_test_corpus))
'''
Constructing model files for the different languages
'''
def write_model_to_file(model_pair,fname):
f = open(fname,'w')
lst = []
for x,v in model_pair:
... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/code-embeddings",
"path": "/alignment/model_preprocessing.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/code-embeddings path: /alignment/model_preprocessing.py
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 24 21:29:38 2018
@author: Arnaoty
"""
from gensim.models.doc2vec import Doc2Vec
from nltk.corpus import PlaintextCorpusReader
from gensim.models.doc2vec import TaggedDocument
impor... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/code-embeddings",
"path": "/alignment/model_preprocessing.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> cr = PlaintextCorpusReader(path,pattern)
for fid in cr.fileids():
code = cr.raw(fid)
try:
tokens = list(tokenize.generate_tokens(io.StringIO(code).readline))
tokens = [token for t in tokens if t.type == tokenize.NAME or t.type == tokenize.OP for token in t.s... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/code-embeddings",
"path": "/alignment/model_preprocessing.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ronaldoussoren/pyobjc path: /pyobjc-framework-Vision/PyObjCTest/test_vntrackingrequest.py
from PyObjCTools.TestSupport import TestCase, min_os_level
import Vision
<|fim_suffix|> self.assertResultIsBOOL(Vision.VNTrackingRequest.isLastFrame)
self.assertArgIsBOOL(Vision.VNTrackingReq... | code_fim | hard | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-Vision/PyObjCTest/test_vntrackingrequest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def testConstants(self):
self.assertEqual(Vision.VNRequestTrackingLevelAccurate, 0)
self.assertEqual(Vision.VNRequestTrackingLevelFast, 1)
@min_os_level("10.13")
def testMethods10_13(self):
self.assertResultIsBOOL(Vision.VNTrackingRequest.isLastFrame)
self.asse... | code_fim | medium | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-Vision/PyObjCTest/test_vntrackingrequest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: santiago-iturriaga/dolardo path: /src/dolardo/entities/moneda.py
'''
Created on Aug 15, 2009
@author: santiago
'''
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey, Unicode
from sqlalchemy.orm import relation, bac... | code_fim | medium | {
"lang": "python",
"repo": "santiago-iturriaga/dolardo",
"path": "/src/dolardo/entities/moneda.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> moneda_id = Column(Integer, primary_key=True)
nombre = Column(Unicode(50), nullable=False)
def __init__(self, nombre):
self.nombre = nombre
def __repr__(self):
return "<Moneda(%s,%s)>" % (self.moneda_id, self.nombre)
def __unicode__(self):
return ... | code_fim | medium | {
"lang": "python",
"repo": "santiago-iturriaga/dolardo",
"path": "/src/dolardo/entities/moneda.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, nombre):
self.nombre = nombre
def __repr__(self):
return "<Moneda(%s,%s)>" % (self.moneda_id, self.nombre)
def __unicode__(self):
return nombre<|fim_prefix|># repo: santiago-iturriaga/dolardo path: /src/dolardo/entities/moneda.py
'''
Cr... | code_fim | medium | {
"lang": "python",
"repo": "santiago-iturriaga/dolardo",
"path": "/src/dolardo/entities/moneda.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Shii2/youtube-dl path: /youtube_dl/extractor/douyin.py
# coding: utf-8
from __future__ import unicode_literals
import json
from .common import (
InfoExtractor,
compat_urllib_parse_unquote,
)
class DouyinIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?douyin\.com/video/(?P<id>... | code_fim | hard | {
"lang": "python",
"repo": "Shii2/youtube-dl",
"path": "/youtube_dl/extractor/douyin.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
# The video player and video source are rendered client-side, the data
# contains in a <script id="RENDER_DATA" type="application/json"> tag
# quoted, unquote the whole page content then ... | code_fim | medium | {
"lang": "python",
"repo": "Shii2/youtube-dl",
"path": "/youtube_dl/extractor/douyin.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> # video URLs are in this pattern {"src":"THE_URL"}, in json format,
# as a list of CDN urls, all serving the same file
urls = json.loads(
self._html_search_regex(r'"playAddr":(\[.*?\])', webpage, 'urls'))
return {
'id': video_id,
'title'... | code_fim | hard | {
"lang": "python",
"repo": "Shii2/youtube-dl",
"path": "/youtube_dl/extractor/douyin.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hitchcock717/Satellite path: /Satellite/IDataSearch/backdoor/es/ES_connect.py
#!/usr/bin/env python
# -*-coding:utf-8-*-
'''
目的: 公用类----连接ES
'''
<|fim_suffix|> # 无用户名密码状态
self.es = Elasticsearch([ip])
# 用户名密码状态
# self.es = Elasticsearch([ip],http_auth('elastic... | code_fim | hard | {
"lang": "python",
"repo": "Hitchcock717/Satellite",
"path": "/Satellite/IDataSearch/backdoor/es/ES_connect.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, index_name, ip):
"""
:param index_name: 索引名称
:param index_type: 索引类型
"""
self.index_name = index_name
# self.index_type = index_type ES7已经移除type
# 无用户名密码状态
self.es = Elasticsearch([ip])
# 用户名密码状态
# sel... | code_fim | medium | {
"lang": "python",
"repo": "Hitchcock717/Satellite",
"path": "/Satellite/IDataSearch/backdoor/es/ES_connect.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '.md', '.txt', 'license', '.png', '.jpg', '.jpeg')
) else func(path)<|fim_prefix|># repo: swiing/source-code-stats path: /src/ignore/blacklist.py
# decorator
def ignore(func):
""" ignores path if it matches the given exte<|fim_middle|>nsions """
return lambda path : None if path.lower... | code_fim | medium | {
"lang": "python",
"repo": "swiing/source-code-stats",
"path": "/src/ignore/blacklist.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: swiing/source-code-stats path: /src/ignore/blacklist.py
# decorator
def ignore(func):
""" ignores path if it matches the given exte<|fim_suffix|> '.md', '.txt', 'license', '.png', '.jpg', '.jpeg')
) else func(path)<|fim_middle|>nsions """
return lambda path : None if path.lower... | code_fim | medium | {
"lang": "python",
"repo": "swiing/source-code-stats",
"path": "/src/ignore/blacklist.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> whatever makes sense to the list
('.git',
'__pycache__',
'.md', '.txt', 'license', '.png', '.jpg', '.jpeg')
) else func(path)<|fim_prefix|># repo: swiing/source-code-stats path: /src/ignore/blacklist.py
# decorator
def ignore(func):
""" ignores path if it matches the... | code_fim | medium | {
"lang": "python",
"repo": "swiing/source-code-stats",
"path": "/src/ignore/blacklist.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: corbolais/CMS50Dplus path: /setup.py
from setuptools import setup, find_packages
setup(
name='cms50dplus',
version='1.2',
author='Asbjørn Brask',
url='https://github.com/atbrask/CMS50<|fim_suffix|> packages=find_packages(),
install_requires=['python-dateutil', 'pyserial']
)<|fim_m... | code_fim | medium | {
"lang": "python",
"repo": "corbolais/CMS50Dplus",
"path": "/setup.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>Dplus',
description='python interface for the cms50dplus pulse oximeter',
packages=find_packages(),
install_requires=['python-dateutil', 'pyserial']
)<|fim_prefix|># repo: corbolais/CMS50Dplus path: /setup.py
from setuptools import setup, find_packages
setup(
name='cms50dplus',
ve<|fim_mi... | code_fim | medium | {
"lang": "python",
"repo": "corbolais/CMS50Dplus",
"path": "/setup.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>import common.primes as prime
# PARAMETERS ##################################################################
TYPE = 100 # default: 100
MAX_NUMBER = 10**9 # default: 10**9
# SOLUTION ####################################################################
def solve() -> int:
# find all prime fa... | code_fim | medium | {
"lang": "python",
"repo": "curtislb/ProjectEuler",
"path": "/py/problem_204.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: curtislb/ProjectEuler path: /py/problem_204.py
#!/usr/bin/env python3
"""problem_204.py
Problem 204: Generalised Hamming Numbers
A Hamming number is a positive number which has no prime factor larger than 5.
So the first few Hamming numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15. There
are 110... | code_fim | hard | {
"lang": "python",
"repo": "curtislb/ProjectEuler",
"path": "/py/problem_204.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def solve() -> int:
# find all prime factors up to TYPE
prime_list = prime.primes_up_to(TYPE)
# generate all Hamming numbers <= MAX_NUMBER
ham_nums = {1}
for p in prime_list:
# multiply each number by p until it exceeds MAX_NUMBER
multiples = set()
for n in ham... | code_fim | medium | {
"lang": "python",
"repo": "curtislb/ProjectEuler",
"path": "/py/problem_204.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
main()<|fim_prefix|># repo: tartley/python-template path: /template/main.py
# I don't know how to make PyInstaller use the setuptools entry point (in
# __main__.py) This file exists to provide a top level script PyInstaller
# can operate on.
<|fim_middle|>from PROJNAME.__m... | code_fim | easy | {
"lang": "python",
"repo": "tartley/python-template",
"path": "/template/main.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tartley/python-template path: /template/main.py
# I don't know how to make PyInstaller use the setuptools entry point (in
# __main__.py) This file exists to provide a top level script PyInstaller
# can operate on.
<|fim_suffix|>if __name__ == '__main__':
main()<|fim_middle|>from PROJNAME.__m... | code_fim | easy | {
"lang": "python",
"repo": "tartley/python-template",
"path": "/template/main.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>logging.info('Loaded %i filters' % len(FILTERS_LIST))
# DSS_SERVER_PATH = os.path.join(MAIN_PATH, 'server', 'app-release.apk')
DSS_SERVER_PATH = os.path.join(MAIN_PATH, 'server', 'dss.apk')
DEBUG = False<|fim_prefix|># repo: 0x90/dexsim path: /dexsim/settings.py
import os
import sys
import logging
# ... | code_fim | hard | {
"lang": "python",
"repo": "0x90/dexsim",
"path": "/dexsim/settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 0x90/dexsim path: /dexsim/settings.py
import os
import sys
import logging
# MAIN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# with open(os.path.join(MAIN_PATH, 'datas', 'filters.txt')) as f:
# FILTERS = f.read().splitlines()
MAIN_PATH = os.path.abspath(os.path.di... | code_fim | medium | {
"lang": "python",
"repo": "0x90/dexsim",
"path": "/dexsim/settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> message as a string and pork chop will say it'
return example<|fim_prefix|># repo: danerwilliams/pork-chop path: /modules/example.py
def example_handler(message):
'''Be sure to update pork-chop.py, usage.py, and README.md to appropriately address any new modul<|fim_middle|>es'''
example = ... | code_fim | medium | {
"lang": "python",
"repo": "danerwilliams/pork-chop",
"path": "/modules/example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>es'''
example = 'This is an example module, return the desired message as a string and pork chop will say it'
return example<|fim_prefix|># repo: danerwilliams/pork-chop path: /modules/example.py
def example_handler(message):
'''Be sure to update pork-chop.<|fim_middle|>py, usage.py, and RE... | code_fim | medium | {
"lang": "python",
"repo": "danerwilliams/pork-chop",
"path": "/modules/example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danerwilliams/pork-chop path: /modules/example.py
def example_handler(message):
'''Be sure to update pork-chop.py, usage.py, and README.md to appropriately address any new modul<|fim_suffix|> message as a string and pork chop will say it'
return example<|fim_middle|>es'''
example = ... | code_fim | medium | {
"lang": "python",
"repo": "danerwilliams/pork-chop",
"path": "/modules/example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
with st.form(key='main_form'):
video_url = st.text_input("YouTube URL", "https://www.youtube.com/watch?v=dQw4w9WgXcQ")
search_query = st.text_input("Text input", "shadow on a beach")
submit= st.form_submit_button(label='Submit')
if submit:
with st.spinner("Submitted your request, wait a... | code_fim | hard | {
"lang": "python",
"repo": "shivgodhia/video-search-streamlit",
"path": "/frontend/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def displayResults(url, timestamps):
st.write(timestamps)
for timestamp in timestamps:
st.write(addTimestampToYoutubeURL(url, timestamp))
def timeExecution(start=True):
key = 'time'
if start:
st.session_state.time = time.perf_counter()
... | code_fim | medium | {
"lang": "python",
"repo": "shivgodhia/video-search-streamlit",
"path": "/frontend/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shivgodhia/video-search-streamlit path: /frontend/app.py
from typing import Sequence
import time
import streamlit as st
from helpers import *
st.title("Video Search Engine")
st.write("As this app is in beta, we are currently only providing search functionality in YouTube videos. Paste the link ... | code_fim | medium | {
"lang": "python",
"repo": "shivgodhia/video-search-streamlit",
"path": "/frontend/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: e-koch/Phys-595 path: /project_code/Spec Fitting/specfit.py
'''
Fit Gaussian models to the Hydrogen Balmer series for SDSS galaxy spectra.
'''
import numpy as np
from pyspeckit import Spectrum
from pyspeckit.mpfit.mpfit import mpfitException
from astropy.io import fits
from pandas import Series... | code_fim | hard | {
"lang": "python",
"repo": "e-koch/Phys-595",
"path": "/project_code/Spec Fitting/specfit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> line_and_par_names = []
for par in line_param_names:
for name in line_names:
line_and_par_names.append(name+" "+par)
# Return as a named series, which can be concatenated into a dataframe.
ser = Series(np.hstack([line_params, line_errs]).ravel(),
index... | code_fim | hard | {
"lang": "python",
"repo": "e-koch/Phys-595",
"path": "/project_code/Spec Fitting/specfit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, line in enumerate(lines):
line_props = line_dict[line]
num_lines = len(line_props) / 3
spec_line = spec.slice(start=line_props[1]-100,
stop=line_props[-2]+100,
units='Angstroms')
if verbose:
... | code_fim | hard | {
"lang": "python",
"repo": "e-koch/Phys-595",
"path": "/project_code/Spec Fitting/specfit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.settings.compiler == "Visual Studio" and self.settings.arch == "x86":
raise ConanInvalidConfiguration("Visual Studio x86 builds are not supported.")
if self.options.shared:
del self.options.fPIC
if self.settings.compiler.cppstd:
tools.c... | code_fim | hard | {
"lang": "python",
"repo": "ericLemanissier/conan-center-index",
"path": "/recipes/cppcommon/all/conanfile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ericLemanissier/conan-center-index path: /recipes/cppcommon/all/conanfile.py
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os
import glob
class CppCommon(ConanFile):
name = "cppcommon"
license = "MIT"
url = "https://github.com/... | code_fim | hard | {
"lang": "python",
"repo": "ericLemanissier/conan-center-index",
"path": "/recipes/cppcommon/all/conanfile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _configure_cmake(self):
if not self._cmake:
self._cmake = CMake(self)
self._cmake.definitions["CPPCOMMON_MODULE"] = "OFF"
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake
def build(self):
for patch in self... | code_fim | hard | {
"lang": "python",
"repo": "ericLemanissier/conan-center-index",
"path": "/recipes/cppcommon/all/conanfile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aleman778/substorm-prestudy path: /src/word2vec.py
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import matplotlib.pyplot as plt
import random
import data
# Word2Vec - Skip-gram version
#
# Input (1-hot) Hidden (embedding... | code_fim | hard | {
"lang": "python",
"repo": "Aleman778/substorm-prestudy",
"path": "/src/word2vec.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Setup dataset
setup_dataset("flashback_emails.csv");
# Create the word2vec model, optimizer and criterion
model = Word2Vec(vocab_size, embedding_size)
model = model.to(device)
optimizer = optim.Adam(model.parameters(), lr=learning_rate)
criterion = nn.CrossEntropyLoss()
... | code_fim | hard | {
"lang": "python",
"repo": "Aleman778/substorm-prestudy",
"path": "/src/word2vec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (epoch + 1) % 100 == 0:
print("Epoch: %d - loss: %.6f" % (epoch + 1, epoch_loss))
if epoch_loss < lowest_loss:
torch.save(model.embedding.state_dict(), filename)
lowest_loss = epoch_loss
print("Reached lower loss of %.6f at... | code_fim | hard | {
"lang": "python",
"repo": "Aleman778/substorm-prestudy",
"path": "/src/word2vec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> age = IntegerField('Возраст, лет', validators=[DataRequired()])
submit = SubmitField('Рассчитать ЧСС')<|fim_prefix|># repo: Gagramming/BeneFit_web path: /forms/heart_rate_calculator_form.py
from flask_wtf import FlaskForm
from wtforms import PasswordField, SubmitField, BooleanField, IntegerFiel... | code_fim | easy | {
"lang": "python",
"repo": "Gagramming/BeneFit_web",
"path": "/forms/heart_rate_calculator_form.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> submit = SubmitField('Рассчитать ЧСС')<|fim_prefix|># repo: Gagramming/BeneFit_web path: /forms/heart_rate_calculator_form.py
from flask_wtf import FlaskForm
from wtforms import PasswordField, SubmitField, BooleanField, IntegerField, SelectField
from wtforms.fields.html5 import EmailField
from wtform... | code_fim | medium | {
"lang": "python",
"repo": "Gagramming/BeneFit_web",
"path": "/forms/heart_rate_calculator_form.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Gagramming/BeneFit_web path: /forms/heart_rate_calculator_form.py
from flask_wtf import FlaskForm
from wtforms import PasswordField, SubmitField, BooleanField, IntegerField, SelectField
from wtforms.fields.html5 import EmailField
from wtforms.validators import DataRequired
<|fim_suffix|>
su... | code_fim | medium | {
"lang": "python",
"repo": "Gagramming/BeneFit_web",
"path": "/forms/heart_rate_calculator_form.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def dump_dataframe(df, path):
with smart_open.open(path, "w") as f:
df.to_csv(f, index=False)
def ensure_path_exists(path):
if "://" in path:
# Buckets like GS/S3 don't need to pre-create the prefix/folder
return
if not os.path.exists(path):
os.makedirs(path... | code_fim | hard | {
"lang": "python",
"repo": "tianyisuntt/lm-evaluation",
"path": "/lm_evaluation/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tianyisuntt/lm-evaluation path: /lm_evaluation/utils.py
import os
import smart_open
import json
import re
import urllib.request
def load_http_text(url):
with urllib.request.urlopen(url) as f:
return f.read().decode("utf-8")
def load_text(path):
if path.startswith("http://") or... | code_fim | medium | {
"lang": "python",
"repo": "tianyisuntt/lm-evaluation",
"path": "/lm_evaluation/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def load_json_lines(path):
return [json.loads(line) for line in load_text(path).split("\n") if line]
def dump_json(data, path):
with smart_open.open(path, "w") as f:
json.dump(data, f)
def dump_dataframe(df, path):
with smart_open.open(path, "w") as f:
df.to_csv(f, index=F... | code_fim | medium | {
"lang": "python",
"repo": "tianyisuntt/lm-evaluation",
"path": "/lm_evaluation/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aplopio/django_rip path: /tests/unit_tests/generic_steps/test_default_schema_validation.py
import unittest
from hamcrest.core import assert_that
from hamcrest.core.core.isequal import equal_to
from hamcrest.library.collection.issequence_containing import has_item, \
has_items
from rip.api_s... | code_fim | hard | {
"lang": "python",
"repo": "Aplopio/django_rip",
"path": "/tests/unit_tests/generic_steps/test_default_schema_validation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = {
'country': 'India'
}
request = request_factory.get_request(data=data,
context_params={
'crud_action': CrudActions.UPDATE_DETAIL})
return_request = self.validati... | code_fim | hard | {
"lang": "python",
"repo": "Aplopio/django_rip",
"path": "/tests/unit_tests/generic_steps/test_default_schema_validation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MisterZhouZhou/pythonLearn path: /suanfa/charu.py
'''
插入排序
'''
def insert_sort(a):
<|fim_suffix|>insert_sort([3,4,5,9,8,7,1,2,6])<|fim_middle|> count = len(a)
for i in range(count):
for j in range(i):
if a[i] < a[j]:
a.insert(j, a.pop(i))
... | code_fim | medium | {
"lang": "python",
"repo": "MisterZhouZhou/pythonLearn",
"path": "/suanfa/charu.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>insert_sort([3,4,5,9,8,7,1,2,6])<|fim_prefix|># repo: MisterZhouZhou/pythonLearn path: /suanfa/charu.py
'''
插入排序
'''
def insert_sort(a):
<|fim_middle|> count = len(a)
for i in range(count):
for j in range(i):
if a[i] < a[j]:
a.insert(j, a.pop(i))
... | code_fim | medium | {
"lang": "python",
"repo": "MisterZhouZhou/pythonLearn",
"path": "/suanfa/charu.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from django.core.validators import MinLengthValidator
from .models import *<|fim_prefix|># repo: tweeprint/api.tweeprint.com path: /core/forms.py
from django import forms
from django.c<|fim_middle|>ontrib.auth import authenticate, login | code_fim | easy | {
"lang": "python",
"repo": "tweeprint/api.tweeprint.com",
"path": "/core/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nLengthValidator
from .models import *<|fim_prefix|># repo: tweeprint/api.tweeprint.com path: /core/forms.py
from django import forms
from django.c<|fim_middle|>ontrib.auth import authenticate, login
from django.core.validators import Mi | code_fim | medium | {
"lang": "python",
"repo": "tweeprint/api.tweeprint.com",
"path": "/core/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tweeprint/api.tweeprint.com path: /core/forms.py
from django import forms
from django.contrib.auth import authenticate, login<|fim_suffix|>nLengthValidator
from .models import *<|fim_middle|>
from django.core.validators import Mi | code_fim | easy | {
"lang": "python",
"repo": "tweeprint/api.tweeprint.com",
"path": "/core/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __exit__(self, *a, **kw) -> None:
sys.stdin, sys.stdout, sys.stderr = self.queue.pop()
stdio = Stdio()<|fim_prefix|># repo: pwndbg/pwndbg path: /pwndbg/lib/stdio.py
"""
Provides functionality to circumvent GDB's hooks on sys.stdin and sys.stdout
which prevent output from appearing on-sc... | code_fim | medium | {
"lang": "python",
"repo": "pwndbg/pwndbg",
"path": "/pwndbg/lib/stdio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Stdio:
queue: list[tuple[TextIO, TextIO, TextIO]] = []
def __enter__(self, *a, **kw) -> None:
self.queue.append((sys.stdin, sys.stdout, sys.stderr))
sys.stdin = sys.__stdin__
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
def __exit__(self, *a... | code_fim | medium | {
"lang": "python",
"repo": "pwndbg/pwndbg",
"path": "/pwndbg/lib/stdio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pwndbg/pwndbg path: /pwndbg/lib/stdio.py
"""
Provides functionality to circumvent GDB's hooks on sys.stdin and sys.stdout
which prevent output from appearing on-screen inside of certain event handlers.
"""
<|fim_suffix|> queue: list[tuple[TextIO, TextIO, TextIO]] = []
def __enter__(self,... | code_fim | medium | {
"lang": "python",
"repo": "pwndbg/pwndbg",
"path": "/pwndbg/lib/stdio.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ung-it/UngIT path: /skalvi/migrations/0014_auto_20170315_1445.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-15 13:45
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
<|fim_suffix|> operations = [
migrat... | code_fim | medium | {
"lang": "python",
"repo": "ung-it/UngIT",
"path": "/skalvi/migrations/0014_auto_20170315_1445.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='activity',
name='date_end',
field=models.DateField(default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='activity',
... | code_fim | medium | {
"lang": "python",
"repo": "ung-it/UngIT",
"path": "/skalvi/migrations/0014_auto_20170315_1445.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return_value = pytest.main([str(self.test_file.file_name)])
if return_value > 0:
raise RuleException('Test failed.')
return 'Test result: OK'<|fim_prefix|># repo: spector-in-london/prodmodel path: /prodmodel/model/target/test_target.py
from typing import List
import pytest
from prodmo... | code_fim | hard | {
"lang": "python",
"repo": "spector-in-london/prodmodel",
"path": "/prodmodel/model/target/test_target.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(sources=[test_file], file_deps=file_deps, deps=[])
self.test_file = test_file
def execute(self):
return_value = pytest.main([str(self.test_file.file_name)])
if return_value > 0:
raise RuleException('Test failed.')
return 'Test result: OK'<|fim_prefix|># repo:... | code_fim | medium | {
"lang": "python",
"repo": "spector-in-london/prodmodel",
"path": "/prodmodel/model/target/test_target.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spector-in-london/prodmodel path: /prodmodel/model/target/test_target.py
from typing import List
import pytest
from prodmodel.model.files.input_file import InputFile
from prodmodel.model.target.target import Target
from prodmodel.util import RuleException
class TestTarget(Target):
<|fim_suffi... | code_fim | medium | {
"lang": "python",
"repo": "spector-in-london/prodmodel",
"path": "/prodmodel/model/target/test_target.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yjxsfyqzysxdysz/test path: /python/图片格式转换/convert.py
#!python3
import os
from PIL import Image
# 获取文件名列表
imgList = os.listdir("./")
# imgList = os.listdir("F:\\Downloads\\Chrome Downloads\\——")
# 函数:获取文件的后缀长度(例如 jpg 和 jpeg 的长度分别为 3 和 4 )
# def typeNameLengthCount(name):
# count = 0
# for i in ... | code_fim | hard | {
"lang": "python",
"repo": "yjxsfyqzysxdysz/test",
"path": "/python/图片格式转换/convert.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 移动原图片,此处用shutil.move( , ) 方法同样可行, 而且这个方法可以实现文件在磁盘间的移动
os.rename(name, "./SourceImage/%s" % name)
except IOError:
print("one file was ignored", file_name)<|fim_prefix|># repo: yjxsfyqzysxdysz/test path: /python/图片格式转换/convert.py
#!python3
import os
from PIL import Im... | code_fim | hard | {
"lang": "python",
"repo": "yjxsfyqzysxdysz/test",
"path": "/python/图片格式转换/convert.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trujunzhang/djzhang-targets path: /cwgoogleplay/cwgoogleplay/database/history_db.py
from cwgoogleplay.database.base_db import BaseDatabase
import pymongo
from scrapy.conf import settings
from scrapy.exceptions import DropItem
from scrapy import log
from datetime import datetime, time
from hash... | code_fim | hard | {
"lang": "python",
"repo": "trujunzhang/djzhang-targets",
"path": "/cwgoogleplay/cwgoogleplay/database/history_db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> item = {
'url': url,
'guid': CrawlUtils.get_guid(url),
'created_at': datetime.utcnow().replace(microsecond=0).isoformat(' '),
}
self.db[self.collection_name].insert(item)
log.msg("GooglePlayHistory added to MongoDB database!", level=log.... | code_fim | hard | {
"lang": "python",
"repo": "trujunzhang/djzhang-targets",
"path": "/cwgoogleplay/cwgoogleplay/database/history_db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: burakbayramli/books path: /programming_computer_vision_with_python/cvbook-contrib/ch01_ex03_quotim.py
from PIL import Image
from pylab import *
from scipy.ndimage import filters
from scipy import misc
import imtools
#im = array(Image.open('board.jpeg').convert('L'))
im = misc.lena()
im2, cdf = i... | code_fim | hard | {
"lang": "python",
"repo": "burakbayramli/books",
"path": "/programming_computer_vision_with_python/cvbook-contrib/ch01_ex03_quotim.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>figure()
title('equalized hist')
#hist(im2.flatten(), 128, cumulative=True, normed=True)
hist(im2.flatten(), 128, normed=True)
figure()
gray()
title('quotient image')
imshow(im3)
figure()
title('quotient hist')
hist(im3.flatten(), 128, normed=True)
show()<|fim_prefix|># repo: burakbayramli/books path:... | code_fim | hard | {
"lang": "python",
"repo": "burakbayramli/books",
"path": "/programming_computer_vision_with_python/cvbook-contrib/ch01_ex03_quotim.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>figure()
gray()
title('histogram-equalized')
imshow(im2)
figure()
title('equalized hist')
#hist(im2.flatten(), 128, cumulative=True, normed=True)
hist(im2.flatten(), 128, normed=True)
figure()
gray()
title('quotient image')
imshow(im3)
figure()
title('quotient hist')
hist(im3.flatten(), 128, normed=Tru... | code_fim | medium | {
"lang": "python",
"repo": "burakbayramli/books",
"path": "/programming_computer_vision_with_python/cvbook-contrib/ch01_ex03_quotim.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: felixtran39/computation_hist path: /djweb/dj_comp_hist/migrations/0009_auto_20190118_1957.py
# Generated by Django 2.1.5 on 2019-01-18 19:57
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('dj_comp_hist', '0008_auto_20190118_1951'),
]
operations =... | code_fim | medium | {
"lang": "python",
"repo": "felixtran39/computation_hist",
"path": "/djweb/dj_comp_hist/migrations/0009_auto_20190118_1957.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='document',
name='recipient',
),
migrations.AddField(
model_name='document',
name='recipient_organization',
field=models.ManyToManyField(blank=True, related_name='recip... | code_fim | medium | {
"lang": "python",
"repo": "felixtran39/computation_hist",
"path": "/djweb/dj_comp_hist/migrations/0009_auto_20190118_1957.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('dj_comp_hist', '0008_auto_20190118_1951'),
]
operations = [
migrations.RemoveField(
model_name='document',
name='recipient',
),
migrations.AddField(
model_name='document',
name='recipient_organ... | code_fim | medium | {
"lang": "python",
"repo": "felixtran39/computation_hist",
"path": "/djweb/dj_comp_hist/migrations/0009_auto_20190118_1957.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ReanGD/smart-home path: /etc/transport.py
from protocols.transport import TransportConfig
<|fim_suffix|> super().__init__('asr.yandex.net', 443)<|fim_middle|>
class HassTransportConfig(TransportConfig):
def __init__(self):
super().__init__('192.168.1.3', 8083)
class YanexTra... | code_fim | medium | {
"lang": "python",
"repo": "ReanGD/smart-home",
"path": "/etc/transport.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.