text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>if "VIRTUAL_ENV" not in os.environ:
print("*****************************************************")
print(" WARNING: You are not installing in a virtual")
print(" environment. This configuration is not supported!!!")
print(" Expect breakage.")
print("*******************************************... | code_fim | hard | {
"lang": "python",
"repo": "google/grr",
"path": "/grr/config/grr_response_templates/setup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> sdist.make_release_tree(self, base_dir, files)
sdist_version_ini = os.path.join(base_dir, "version.ini")
if os.path.exists(sdist_version_ini):
os.unlink(sdist_version_ini)
shutil.copy(
os.path.join(THIS_DIRECTORY, "../../../version.ini"), sdist_version_ini)
def find_data_fi... | code_fim | hard | {
"lang": "python",
"repo": "google/grr",
"path": "/grr/config/grr_response_templates/setup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vmuriart/python-sql path: /src/sql/operators.py
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011-2016, Cédric Krier
# Copyright (c) 2011-2016, B2CK
# Copyright (c) 2016-2016, Victor Uriarte
# and contributors. See AUTHORS for more details.
# All rights reserved.
#
# Redistribution and use in source... | code_fim | hard | {
"lang": "python",
"repo": "vmuriart/python-sql",
"path": "/src/sql/operators.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> params = []
for operand in operands:
if isinstance(operand, (Expression, Select, CombiningQuery)):
params.extend(operand.params)
elif isinstance(operand, (list, tuple)):
params.extend(convert(operand))
... | code_fim | hard | {
"lang": "python",
"repo": "vmuriart/python-sql",
"path": "/src/sql/operators.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> __slots__ = ()
_operator = '*'
class Div(BinaryOperator):
__slots__ = ()
_operator = '/'
class Mod(BinaryOperator):
__slots__ = ()
@property
def _operator(self):
# '%' must be escaped with format paramstyle
return '%%' if Flavor.get().paramstyle == 'format'... | code_fim | hard | {
"lang": "python",
"repo": "vmuriart/python-sql",
"path": "/src/sql/operators.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># 2.使用 ?
content2 = re.sub('\d?', '', content)
print(content2)<|fim_prefix|># repo: LiuJunb/PythonStudy path: /Python3网络爬虫/section3-基本库使用/06-正则/04-sub-replace/01-所有数字都去掉.py
import re
# ? 0 或者 1 个
# * 0 或者 多个
# + 1 或者多个
content = '54aK54yr5oiR54ix5L2g'
<|fim_middle|># 1.使用 +
content1 = re.sub(... | code_fim | medium | {
"lang": "python",
"repo": "LiuJunb/PythonStudy",
"path": "/Python3网络爬虫/section3-基本库使用/06-正则/04-sub-replace/01-所有数字都去掉.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LiuJunb/PythonStudy path: /Python3网络爬虫/section3-基本库使用/06-正则/04-sub-replace/01-所有数字都去掉.py
import re
# ? 0 或者 1 个
# * 0 或者 多个
# + 1 或者多个
content = '54aK54yr5oiR54ix5L2g'
<|fim_suffix|># 2.使用 ?
content2 = re.sub('\d?', '', content)
print(content2)<|fim_middle|>
# 1.使用 +
content1 = re.sub(... | code_fim | medium | {
"lang": "python",
"repo": "LiuJunb/PythonStudy",
"path": "/Python3网络爬虫/section3-基本库使用/06-正则/04-sub-replace/01-所有数字都去掉.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # The merge of the nested operation should have been called once.
assert operation_1.mergeWith.call_count == 1
# Number of operations should still be the same.
assert merged_operation.getNumChildrenOperations() == 1<|fim_prefix|># repo: flight7788/3d-printing-with-moveo-1 path: /Cura/Ura... | code_fim | hard | {
"lang": "python",
"repo": "flight7788/3d-printing-with-moveo-1",
"path": "/Cura/Uranium/tests/Operations/TestGroupedOperation.py",
"mode": "spm",
"license": "LGPL-3.0-only",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flight7788/3d-printing-with-moveo-1 path: /Cura/Uranium/tests/Operations/TestGroupedOperation.py
from unittest.mock import MagicMock
from UM.Math.Vector import Vector
from UM.Operations.GroupedOperation import GroupedOperation
import pytest
from UM.Operations.Operation import Operation
from UM.... | code_fim | hard | {
"lang": "python",
"repo": "flight7788/3d-printing-with-moveo-1",
"path": "/Cura/Uranium/tests/Operations/TestGroupedOperation.py",
"mode": "psm",
"license": "LGPL-3.0-only",
"source": "the-stack-v2"
} |
<|fim_suffix|> # The base operation always says it can't be merged (so one child says it can't be merged). This should result
# in the parent (grouped) operation also failing.
assert not group_operation_3.mergeWith(group_operation_1)
group_operation_2.addOperation(operation_2)
merged_operation = gro... | code_fim | hard | {
"lang": "python",
"repo": "flight7788/3d-printing-with-moveo-1",
"path": "/Cura/Uranium/tests/Operations/TestGroupedOperation.py",
"mode": "spm",
"license": "LGPL-3.0-only",
"source": "the-stack-v2"
} |
<|fim_suffix|>
urlpatterns = (
[re_path(r'^results/$', ScannerResultView.as_view(), name='scanner-results')]
if settings.INTERNAL_ROUTES_ALLOWED
else []
)<|fim_prefix|># repo: mozilla/addons-server path: /src/olympia/scanners/api_urls.py
from django.conf import settings
from django.urls import re_path
<|f... | code_fim | easy | {
"lang": "python",
"repo": "mozilla/addons-server",
"path": "/src/olympia/scanners/api_urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = (
[re_path(r'^results/$', ScannerResultView.as_view(), name='scanner-results')]
if settings.INTERNAL_ROUTES_ALLOWED
else []
)<|fim_prefix|># repo: mozilla/addons-server path: /src/olympia/scanners/api_urls.py
from django.conf import settings
from django.urls import re_path
<|fi... | code_fim | easy | {
"lang": "python",
"repo": "mozilla/addons-server",
"path": "/src/olympia/scanners/api_urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mozilla/addons-server path: /src/olympia/scanners/api_urls.py
from django.conf import settings
from django.urls import re_path
<|fim_suffix|>urlpatterns = (
[re_path(r'^results/$', ScannerResultView.as_view(), name='scanner-results')]
if settings.INTERNAL_ROUTES_ALLOWED
else []
)<|fi... | code_fim | easy | {
"lang": "python",
"repo": "mozilla/addons-server",
"path": "/src/olympia/scanners/api_urls.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: billygarrison/python-teos path: /test/teos/unit/test_block_processor.py
import pytest
from teos.watcher import InvalidTransactionFormat
from test.teos.conftest import generate_blocks
from test.teos.unit.conftest import get_random_value_hex, fork
hex_tx = (
"0100000001c997a5e56e104102fa209c6... | code_fim | hard | {
"lang": "python",
"repo": "billygarrison/python-teos",
"path": "/test/teos/unit/test_block_processor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Mine some blocks up to the target distance
generate_blocks(target_distance)
# Check if the distance is properly computed
assert block_processor.get_distance_to_tip(target_block) == target_distance
def test_is_block_in_best_chain(block_processor):
best_block_hash = block_processor.... | code_fim | hard | {
"lang": "python",
"repo": "billygarrison/python-teos",
"path": "/test/teos/unit/test_block_processor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> target_block = block_processor.get_best_block_hash()
# Generate some blocks and store the hash in a list
missed_blocks = generate_blocks(5)
# Check what we've missed
assert block_processor.get_missed_blocks(target_block) == missed_blocks
# We can see how it does not work if we r... | code_fim | hard | {
"lang": "python",
"repo": "billygarrison/python-teos",
"path": "/test/teos/unit/test_block_processor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aphearin/halotools path: /halotools/empirical_models/composite_models/hod_models/__init__.py
from .zheng07 import *
from .cacciato09 import<|fim_suffix|>lbaum15 import *
from .zu_mandelbaum16 import *<|fim_middle|> *
from .leauthaud11 import *
from .tinker13 import *
from .hearin15 import *
from ... | code_fim | medium | {
"lang": "python",
"repo": "aphearin/halotools",
"path": "/halotools/empirical_models/composite_models/hod_models/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>lbaum15 import *
from .zu_mandelbaum16 import *<|fim_prefix|># repo: aphearin/halotools path: /halotools/empirical_models/composite_models/hod_models/__init__.py
from .zheng07 import *
from .cacciato09 import<|fim_middle|> *
from .leauthaud11 import *
from .tinker13 import *
from .hearin15 import *
from ... | code_fim | medium | {
"lang": "python",
"repo": "aphearin/halotools",
"path": "/halotools/empirical_models/composite_models/hod_models/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> conv_client.assert_has_calls([
mock.call.message(context={'send_no_input': 'no', 'email': None, 'logged_in': False},
message_input={'text': 'this is a test'},
workspace_id=mock.ANY)
])
slack_client.assert_has_calls([
mock.call... | code_fim | hard | {
"lang": "python",
"repo": "uwitzig/default-toolchain-1489153714966",
"path": "/tests/test_watson_online_store.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uwitzig/default-toolchain-1489153714966 path: /tests/test_watson_online_store.py
from watsononlinestore import watson_online_store
import mock
def test_0():
conv_client = mock.Mock()
conv_client.message.return_value = {
'context': {'send_no_input': 'no'},
'output': {'te... | code_fim | hard | {
"lang": "python",
"repo": "uwitzig/default-toolchain-1489153714966",
"path": "/tests/test_watson_online_store.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if expected:
self.log.info("Expectation met")
else:
self.log.error("Expectation not met. %s" % failure_message)
assert expected, failure_message
return result<|fim_prefix|># repo: relaxdiego/auto path: /tflib/test_case.py
import inspect
import app... | code_fim | hard | {
"lang": "python",
"repo": "relaxdiego/auto",
"path": "/tflib/test_case.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: relaxdiego/auto path: /tflib/test_case.py
import inspect
import app
from tflib.mixins.loggable import LoggableMixin
class TestCase(object, LoggableMixin):
def setup(self):
<|fim_suffix|> def step(self, step, expect, **expect_kwargs):
if inspect.isclass(step):
step =... | code_fim | hard | {
"lang": "python",
"repo": "relaxdiego/auto",
"path": "/tflib/test_case.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = step.execute(self.app)
self.log.info("Step returned result: %r" % result)
self.undo_stack.append(step)
self.log.info("Validating expectation '%s'" % expect)
expectation = step.get_expectation(expect)
expected, failure_message = expectation(**expec... | code_fim | hard | {
"lang": "python",
"repo": "relaxdiego/auto",
"path": "/tflib/test_case.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> handleLightSwitch(TURN_OFF)
return render_template('toggle_switch.html')
# ---------------------------------------------------------
# Run the server
if __name__ == "__main__":
app.run(debug=True)<|fim_prefix|># repo: amy-xiang/XIOT_egypt path: /Toggle On-Off Switch/Helen/toggle_requests.py... | code_fim | hard | {
"lang": "python",
"repo": "amy-xiang/XIOT_egypt",
"path": "/Toggle On-Off Switch/Helen/toggle_requests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Home page
@app.route("/")
def index():
return render_template('home.html')
# ---------------------------------------------------------
# LIGHT BULB SWITCH
# The Simple Switch page
@app.route("/light")
def chooseLight():
return render_template('toggle_switch.html')
# If the user turns the light... | code_fim | medium | {
"lang": "python",
"repo": "amy-xiang/XIOT_egypt",
"path": "/Toggle On-Off Switch/Helen/toggle_requests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amy-xiang/XIOT_egypt path: /Toggle On-Off Switch/Helen/toggle_requests.py
from flask import Flask, render_template, request
import sys
sys.path.insert(0, '../../')
from make_requests import handleLightSwitch, handleOutletSwitch
<|fim_suffix|> handleLightSwitch(TURN_ON)
return render_temp... | code_fim | hard | {
"lang": "python",
"repo": "amy-xiang/XIOT_egypt",
"path": "/Toggle On-Off Switch/Helen/toggle_requests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edmw/site-backup path: /backup/thinning.py
# coding: utf-8
"""
######## ## ## #### ## ## ## ## #### ## ## ######
## ## ## ## ### ## ### ## ## ### ## ## ##
## ## ## ## #### ## #### ## ## #### ## ##
## ######### ## ## ##... | code_fim | hard | {
"lang": "python",
"repo": "edmw/site-backup",
"path": "/backup/thinning.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __execute__(self, dates, attr=None, fix=None):
assert isinstance(dates, Iterable)
assert fix is not None
fix = fix.replace(microsecond=0, second=0, minute=0, hour=0)
logging.info("THINNING BY THIN OUT DAILY FOR {} DAYS".format(self.days))
logging.info("THI... | code_fim | hard | {
"lang": "python",
"repo": "edmw/site-backup",
"path": "/backup/thinning.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sammcgeown/vra-sdk-go path: /hack/fix_iaas_swagger
#!/usr/bin/env python3
import argparse
import json
# This is the location of the IaaS swagger
old_filename = "swagger/vra-iaas.json"
new_filename = "swagger/vra-iaas-fixed.json"
def replace_value(d, k, v, new):
if k in d and d[k] == v:
... | code_fim | medium | {
"lang": "python",
"repo": "sammcgeown/vra-sdk-go",
"path": "/hack/fix_iaas_swagger",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # read in the swagger spec
swagger = json.loads(open(old_filename).read())
rename_iaas_models(swagger)
# Overwrite the swagger spec
f = open(new_filename, "w")
f.write(json.dumps(swagger, sort_keys=False, indent=2))
f.write('\n')<|fim_prefix|># repo: sammcgeown/vra-sdk-go pa... | code_fim | hard | {
"lang": "python",
"repo": "sammcgeown/vra-sdk-go",
"path": "/hack/fix_iaas_swagger",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: James4Deutschland/lazer path: /multilingual/rockstar/newdawn/info_gather-v0/wizard/Module/simpleClass.py
from storeADill import storeAList
from testR import jokeMeUp
class Person:
<|fim_suffix|> self.name = name
# self.age = age
joke=Person(jokeMeUp)
#print("--","sample:",joke.name(5),joke... | code_fim | easy | {
"lang": "python",
"repo": "James4Deutschland/lazer",
"path": "/multilingual/rockstar/newdawn/info_gather-v0/wizard/Module/simpleClass.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>joke=Person(jokeMeUp)
#print("--","sample:",joke.name(5),joke.age(4),"--")
joke.name()
storeAList(joke)<|fim_prefix|># repo: James4Deutschland/lazer path: /multilingual/rockstar/newdawn/info_gather-v0/wizard/Module/simpleClass.py
from storeADill import storeAList
from testR import jokeMeUp
class Person:
... | code_fim | easy | {
"lang": "python",
"repo": "James4Deutschland/lazer",
"path": "/multilingual/rockstar/newdawn/info_gather-v0/wizard/Module/simpleClass.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> records = Forwards.objects.count()
forwards = stub.ForwardingHistory(ln.ForwardingHistoryRequest(start_time=1420070400, index_offset=records, num_max_events=100)).forwarding_events
for forward in forwards:
incoming_peer_alias = Channels.objects.filter(chan_id=forward.chan_id_in)[0].ali... | code_fim | hard | {
"lang": "python",
"repo": "GordianLN/lndg",
"path": "/jobs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Onchain.objects.filter(block_height=0).delete()
last_block = 0 if Onchain.objects.aggregate(Max('block_height'))['block_height__max'] == None else Onchain.objects.aggregate(Max('block_height'))['block_height__max'] + 1
onchain_txs = stub.GetTransactions(ln.GetTransactionsRequest(start_height=l... | code_fim | hard | {
"lang": "python",
"repo": "GordianLN/lndg",
"path": "/jobs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GordianLN/lndg path: /jobs.py
import django
from django.conf import settings
from django.db.models import Max
from pathlib import Path
from datetime import datetime
from gui.lnd_deps import lightning_pb2 as ln
from gui.lnd_deps import lightning_pb2_grpc as lnrpc
from gui.lnd_deps.lnd_connect impo... | code_fim | hard | {
"lang": "python",
"repo": "GordianLN/lndg",
"path": "/jobs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: StephanM87/Sofie-Herrmann-Praktikum path: /Old/longtable.py
from pylatex import Document, LongTable, MultiColumn
def genenerate_longtabu():
geometry_options = {
"margin": "2.54cm",
"includeheadfoot": True
}
doc = Document(page_numbers=True, geometry_options=geometry_... | code_fim | hard | {
"lang": "python",
"repo": "StephanM87/Sofie-Herrmann-Praktikum",
"path": "/Old/longtable.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e'),))
data_table.add_hline()
data_table.end_table_last_footer()
row = ["Content1", "9", "Longer String"]
for i in range(150):
data_table.add_row(row)
doc.generate_pdf("longtable",compiler="pdflatex", clean_tex=False)
genenerate_longtab... | code_fim | hard | {
"lang": "python",
"repo": "StephanM87/Sofie-Herrmann-Praktikum",
"path": "/Old/longtable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JeanChristopheMorinPerso/rez path: /src/rez/vendor/version/test.py
en_string()
return self.make_token(s)
def _create_random_version(self):
ver_str = '.'.join(self.make_token.create_random_token_string()
for i in range(random.randint(0, 6)))
... | code_fim | hard | {
"lang": "python",
"repo": "JeanChristopheMorinPerso/rez",
"path": "/src/rez/vendor/version/test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JeanChristopheMorinPerso/rez path: /src/rez/vendor/version/test.py
def __init__(self, fn):
unittest.TestCase.__init__(self, fn)
def _test_strict_weak_ordering(self, a, b):
self.assertTrue(a == a)
self.assertTrue(b == b)
e = (a == b)
ne = ... | code_fim | hard | {
"lang": "python",
"repo": "JeanChristopheMorinPerso/rez",
"path": "/src/rez/vendor/version/test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # optimised cases
_eq("3|3", "3")
_eq("3|1", "1|3")
_eq("5|3|1", "1|3|5")
_eq("1|1_", "1+<1__")
_eq("1|1_|1__", "1+,<1___")
_eq("|", "")
_eq("||", "||||||||")
_eq("1|1_+", "1+")
_eq("<1|1", "<1_")
_eq("1+<3|3+<5", "1+<... | code_fim | hard | {
"lang": "python",
"repo": "JeanChristopheMorinPerso/rez",
"path": "/src/rez/vendor/version/test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jan-g/hacking-the-cryptic path: /parsing/parsing_test.py
import pytest
import re
@pytest.mark.parametrize("given,then", [
(r'a=1 b=2 c=hello d="hello world" e="\""',
{"a":"1", "b":"2", "c":"hello", "d": "hello world", "e": '"'}),
])
def test_parse(given, then):
<|fim_suffix|>R = re.comp... | code_fim | medium | {
"lang": "python",
"repo": "jan-g/hacking-the-cryptic",
"path": "/parsing/parsing_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> while (m := R.match(s)) is not None:
print(m)
res[m.group(1)] = m.group(2) or m.group(3).replace(r'\"', r'"')
s = s[m.end():]
print(s)
return res<|fim_prefix|># repo: jan-g/hacking-the-cryptic path: /parsing/parsing_test.py
import pytest
import re
@pytest.mark.pa... | code_fim | medium | {
"lang": "python",
"repo": "jan-g/hacking-the-cryptic",
"path": "/parsing/parsing_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Imports the module with the given name.
Returns None if the module doesn't exist, but propagates any import errors.
"""
try:
return __import__(module_label, fromlist=classnames)
except ImportError:
# There are 2 reasons why there could be an ImportError:
... | code_fim | hard | {
"lang": "python",
"repo": "umarmughal824/django-oscar-docdata",
"path": "/oscar_docdata/utils/load.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Based on code from django-oscar:
def _import_module(module_label, classnames=()):
"""
Imports the module with the given name.
Returns None if the module doesn't exist, but propagates any import errors.
"""
try:
return __import__(module_label, fromlist=classnames)
except I... | code_fim | hard | {
"lang": "python",
"repo": "umarmughal824/django-oscar-docdata",
"path": "/oscar_docdata/utils/load.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: umarmughal824/django-oscar-docdata path: /oscar_docdata/utils/load.py
import traceback
import sys
from django.core.exceptions import ImproperlyConfigured
def import_class(import_path, setting_name=None):
"""
Import a class by name.
"""
mod_name, class_name = import_path.rsplit('... | code_fim | hard | {
"lang": "python",
"repo": "umarmughal824/django-oscar-docdata",
"path": "/oscar_docdata/utils/load.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> should_not_match = [
'https://1plus1.video/',
'https://1plus1.video/tvguide/1plus1/online',
'https://1plus1.video/tvguide/1plus1in/online',
'https://1plus1.video/tvguide/2plus2/online',
'https://1plus1.video/tvguide/tet/online',
... | code_fim | hard | {
"lang": "python",
"repo": "unlocKing/plugins",
"path": "/tests/test_ovvatv.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: unlocKing/plugins path: /tests/test_ovvatv.py
import unittest
from plugins.ovvatv import ovvaTV
class TestPluginovvaTV(unittest.TestCase):
def test_can_handle_url(self):
<|fim_suffix|> should_not_match = [
'https://1plus1.video/',
'https://1plus1.video/tvgui... | code_fim | hard | {
"lang": "python",
"repo": "unlocKing/plugins",
"path": "/tests/test_ovvatv.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google/oss-fuzz path: /projects/soupsieve/fuzz_closest.py
#!/usr/bin/python3
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:/... | code_fim | medium | {
"lang": "python",
"repo": "google/oss-fuzz",
"path": "/projects/soupsieve/fuzz_closest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
elems = list(sv.select(soupsieve_str, the_soup))
for elem in elems:
sv.closest('div', elem)
except sv.SelectorSyntaxError:
pass
except RecursionError:
# Not interesting
# Fixes, e.g. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54288
pass
except NotImple... | code_fim | hard | {
"lang": "python",
"repo": "google/oss-fuzz",
"path": "/projects/soupsieve/fuzz_closest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Code4SA/za-parliament-scrapers path: /za_parliament_scrapers/questions.py
+: 'O' for oral, or 'W' for written
* :house +str+: 'N' for NA, C for NCOP
* :oral_number +str+: oral number (may be null)
* :written_number +str+: written number (may be null)
* :president_n... | code_fim | hard | {
"lang": "python",
"repo": "Code4SA/za-parliament-scrapers",
"path": "/za_parliament_scrapers/questions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def correct_minister_title(self, minister_title):
corrections = {
"Minister President of the Republic":
"President of the Republic",
"Minister in The Presidency National Planning Commission":
"Minister in the Presidency: National Planning... | code_fim | hard | {
"lang": "python",
"repo": "Code4SA/za-parliament-scrapers",
"path": "/za_parliament_scrapers/questions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return questions
def correct_minister_title(self, minister_title):
corrections = {
"Minister President of the Republic":
"President of the Republic",
"Minister in The Presidency National Planning Commission":
"Minister in the Pre... | code_fim | hard | {
"lang": "python",
"repo": "Code4SA/za-parliament-scrapers",
"path": "/za_parliament_scrapers/questions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__=="__main__":
if len(sys.argv) < 2:
print( "{0} <length> <fix>".format( sys.argv[0] ) )
sys.exit(0)
P = permutation( int(sys.argv[1]), int(sys.argv[2]) if len(sys.argv) > 2 else 0 )
print( P )
#print( '\n'.join( [ str(v) for v in P ] ) )<|fim_prefix|># repo: IlyaLab/kramtools path: /pa... | code_fim | hard | {
"lang": "python",
"repo": "IlyaLab/kramtools",
"path": "/pairwise/test/permute.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IlyaLab/kramtools path: /pairwise/test/permute.py
"""
Generate a permutation of length <length>, possibly leaving the first
<fix> items in place. That is, if the second optional argument is present
then a permutation is generated that only permutes the last <length>-<fix>
items.
"""
import sys
... | code_fim | medium | {
"lang": "python",
"repo": "IlyaLab/kramtools",
"path": "/pairwise/test/permute.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prkumar/uplink-protobuf path: /uplink_protobuf/__init__.py
from uplink_protobuf.__about__ import __version__
from uplink_protobuf import json_options
from uplink_protobuf.convert<|fim_suffix|>on__",
"json_options",
"ProtocolBuffersConverter",
]<|fim_middle|>er import ProtocolBuffersConver... | code_fim | medium | {
"lang": "python",
"repo": "prkumar/uplink-protobuf",
"path": "/uplink_protobuf/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>er import ProtocolBuffersConverter
__all__ = [
"__version__",
"json_options",
"ProtocolBuffersConverter",
]<|fim_prefix|># repo: prkumar/uplink-protobuf path: /uplink_protobuf/__init__.py
from uplink_protobuf.__about__ import __version__
from upli<|fim_middle|>nk_protobuf import json_options... | code_fim | medium | {
"lang": "python",
"repo": "prkumar/uplink-protobuf",
"path": "/uplink_protobuf/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # search with box size 64 * 2.5 = 160
ystart = 500
ystop = 700
scale = 2.5
self.draw_sliding_windows(TEST_OUT_DIR+"windows_3.png", img, ystart, ystop, scale)
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: MarkBroerkens/Car... | code_fim | hard | {
"lang": "python",
"repo": "MarkBroerkens/CarND-Vehicle-Detection",
"path": "/tests/test_sliding_windows.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarkBroerkens/CarND-Vehicle-Detection path: /tests/test_sliding_windows.py
import unittest
import matplotlib
matplotlib.use('Agg')
import matplotlib.image as mpimg
import os
import sys
import numpy as np
import cv2
import pickle
from scipy.ndimage.measurements import label
sys.path.append("..")... | code_fim | hard | {
"lang": "python",
"repo": "MarkBroerkens/CarND-Vehicle-Detection",
"path": "/tests/test_sliding_windows.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_sliding_windows_1(self) :
imgs = image_util.loadImagesRGB(IMG_FILE_DIR)
for img in imgs:
# search with box size 64 * 1 = 64
ystart = 380
ystop = 480
scale = 1.0
self.draw_sliding_windows(TEST_OUT_DIR+"windows_1.png", ... | code_fim | hard | {
"lang": "python",
"repo": "MarkBroerkens/CarND-Vehicle-Detection",
"path": "/tests/test_sliding_windows.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amoshyc/ccu-data-engineering path: /hw2/course/main.py
from collections import defaultdict
data = []
while True:
try:
data.append(input())
except:
break
<|fim_suffix|>res = list([(-v, k) for k, v in cnt.items()])
res = sorted(res)
for (v, k) in res:
print('{} {}'.for... | code_fim | medium | {
"lang": "python",
"repo": "amoshyc/ccu-data-engineering",
"path": "/hw2/course/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>res = list([(-v, k) for k, v in cnt.items()])
res = sorted(res)
for (v, k) in res:
print('{} {}'.format(-v, k))<|fim_prefix|># repo: amoshyc/ccu-data-engineering path: /hw2/course/main.py
from collections import defaultdict
data = []
while True:
try:
data.append(input())
except:
... | code_fim | medium | {
"lang": "python",
"repo": "amoshyc/ccu-data-engineering",
"path": "/hw2/course/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>outFile = open(outputFileName, 'w')
outFile.write(header)
for t in treatment_postfixes:
for r in reps:
for p in partners:
fname = p + "Vals" + "_Seed" + str(r) + "_VT" + "0.1" + "_MS" + t + ".data"
uid = t + "_" + str(r)
curFile = open(fname, 'r')
... | code_fim | medium | {
"lang": "python",
"repo": "piperwelch/Dirty-Transmission-Hypothesis-Paper",
"path": "/Analysis/munge_data2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: piperwelch/Dirty-Transmission-Hypothesis-Paper path: /Analysis/munge_data2.py
import os.path
import gzip
folder = 'vt_1.0/'
#treatment_postfixes = ['000000_0.000000', '000000_0.100000', '000000_0.300000', '000000_0.400000', '000000_0.500000']
treatment_postfixes = ['0.002', '0.06', '0.14', '1.0... | code_fim | medium | {
"lang": "python",
"repo": "piperwelch/Dirty-Transmission-Hypothesis-Paper",
"path": "/Analysis/munge_data2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for t in treatment_postfixes:
for r in reps:
for p in partners:
fname = p + "Vals" + "_Seed" + str(r) + "_VT" + "0.1" + "_MS" + t + ".data"
uid = t + "_" + str(r)
curFile = open(fname, 'r')
for line in curFile:
if (line[0] != "u"... | code_fim | medium | {
"lang": "python",
"repo": "piperwelch/Dirty-Transmission-Hypothesis-Paper",
"path": "/Analysis/munge_data2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wichmannpas/VersionInferrer path: /definitions/gitlab.py
from backends.software_package import SoftwarePackage
from definitions.definition import SoftwareDefinition
from providers.DebRepositoryProvider import DebRepositoryProvider
<|fim_suffix|> software_package = SoftwarePackage(
na... | code_fim | hard | {
"lang": "python",
"repo": "wichmannpas/VersionInferrer",
"path": "/definitions/gitlab.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class GitlabCommunityEdition(SoftwareDefinition):
software_package = SoftwarePackage(
name='Gitlab Community Edition',
vendor='Gitlab Inc.')
provider = DebRepositoryProvider(
software_package=software_package,
repo_base_url='https://packages.gitlab.com/gitlab/gitlab... | code_fim | hard | {
"lang": "python",
"repo": "wichmannpas/VersionInferrer",
"path": "/definitions/gitlab.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>reaction = ade.Reaction('C=CC=C.C=C>>C1C=CCCC1', name='diels_alder')
reaction.calculate_reaction_profile()<|fim_prefix|># repo: jdelev/autodE path: /examples/diels_alder.py
import autode as ade
<|fim_middle|>ade.Config.n_cores = 8
| code_fim | easy | {
"lang": "python",
"repo": "jdelev/autodE",
"path": "/examples/diels_alder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jdelev/autodE path: /examples/diels_alder.py
import autode as ade
<|fim_suffix|>reaction = ade.Reaction('C=CC=C.C=C>>C1C=CCCC1', name='diels_alder')
reaction.calculate_reaction_profile()<|fim_middle|>ade.Config.n_cores = 8
| code_fim | easy | {
"lang": "python",
"repo": "jdelev/autodE",
"path": "/examples/diels_alder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: micaherne/unidexter-py path: /micaherne/unidexter/tests/tb.py
class Engine():
r = None # rank: direction (1, 0)
f = None # file: direction (0, 1)
d1 = None # diagonals a1h8 (1, 1)
d2 = None # diagonals a8h1 (1, -1)
set = None
wtm = None
castling = None
halfmove = None
fullmo... | code_fim | hard | {
"lang": "python",
"repo": "micaherne/unidexter-py",
"path": "/micaherne/unidexter/tests/tb.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pieces = [None] * 32
epmarker = None
space = None
def __init__(self):
self.resetPieces()
def getUnusedPiece(self, pieceType, colour):
for p in self.pieces:
if p.pieceType == pieceType and p.colour == colour:
if p.f == None:
return p
# TODO: Return promoted pawns if necessary
... | code_fim | hard | {
"lang": "python",
"repo": "micaherne/unidexter-py",
"path": "/micaherne/unidexter/tests/tb.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mathux/Visualization-of-CNN path: /code/visualize.py
# Import necessary libraries
import numpy as np
import sys
import time
from PIL import Image
import tensorflow as tf
from tensorflow import keras
from keras.layers import (
Input,
InputLayer,
Flatten,
Activation,... | code_fim | hard | {
"lang": "python",
"repo": "Mathux/Visualization-of-CNN",
"path": "/code/visualize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for sample in range(input.shape[0]):
for dim in range(input.shape[3]):
for row in range(out_shape[1]):
for col in range(out_shape[2]):
patch = input[sample,
row * row_poolsize : (row + 1) * row... | code_fim | hard | {
"lang": "python",
"repo": "Mathux/Visualization-of-CNN",
"path": "/code/visualize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cr1901/symbiflow-arch-defs path: /utils/vpr_place_constraints.py
from __future__ import print_function
from collections import OrderedDict, namedtuple
import lxml.etree as ET
PlaceConstraint = namedtuple('PlaceConstraint', 'name x y z comment')
HEADER_TEMPLATE = """\
#{name:<{nl}} x y z ... | code_fim | hard | {
"lang": "python",
"repo": "cr1901/symbiflow-arch-defs",
"path": "/utils/vpr_place_constraints.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> An instance is marked as used when the XML element relative to the instance name has
children tags.
E.g.:
<block name="idelayctrl_block" instance="IDELAYCTRL[0]">
<inputs>
<port name="REFCLK">refclk</port>
</inputs>
... | code_fim | hard | {
"lang": "python",
"repo": "cr1901/symbiflow-arch-defs",
"path": "/utils/vpr_place_constraints.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Create a dword at the given offset in the IDB"""
self.ret = idaapi.create_dword(offset, 4)
return self.ret
@QtCore.pyqtSlot(object)
def make_word(self, offset):
"""Create a word at the given offset in the IDB"""
self.ret = idaapi.create_word(offset, 2)
... | code_fim | hard | {
"lang": "python",
"repo": "thurday/pe_tree",
"path": "/pe_tree_ida.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @QtCore.pyqtSlot(object)
def get_segment_name(self, offset):
"""Get segment name for offset from IDB"""
self.ret = idc.get_segm_name(offset)
return self.ret
@QtCore.pyqtSlot(object)
def is_writable(self, offset):
"""Determine if memory address is writable""... | code_fim | hard | {
"lang": "python",
"repo": "thurday/pe_tree",
"path": "/pe_tree_ida.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thurday/pe_tree path: /pe_tree_ida.py
#
# Copyright (c) 2020 BlackBerry Limited. 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": "thurday/pe_tree",
"path": "/pe_tree_ida.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> user_input = input("Do you want to continue playing?")
if user_input == "no":
keepplaying = False<|fim_prefix|># repo: athallam/Roulette path: /Roulette.py
import random
keepplaying = True
while keepplaying == True:
myInput = input("Bet your color Type: Red or Black:")
myInput = myInput.lo... | code_fim | hard | {
"lang": "python",
"repo": "athallam/Roulette",
"path": "/Roulette.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: athallam/Roulette path: /Roulette.py
import random
keepplaying = True
while keepplaying == True:
myInput = input("Bet your color Type: Red or Black:")
myInput = myInput.lower()
computerInput = random.randint(1,2)
<|fim_suffix|> if computerSelection == myInput:
print("You win!")
... | code_fim | medium | {
"lang": "python",
"repo": "athallam/Roulette",
"path": "/Roulette.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>alse,
[
_MetaInfoClassMember('interface-tracking-info', REFERENCE_LIST, 'InterfaceTrackingInfo' , 'ydk.models.cisco_ios_xr.Cisco_IOS_XR_manageability_object_tracking_oper', 'ObjectTracking.TrackTypeRtrReachability.TrackInfo.TrackingInteraces.InterfaceTrackingInfo',
... | code_fim | hard | {
"lang": "python",
"repo": "111pontes/ydk-py",
"path": "/cisco-ios-xr/ydk/models/cisco_ios_xr/_meta/_Cisco_IOS_XR_manageability_object_tracking_oper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 111pontes/ydk-py path: /cisco-ios-xr/ydk/models/cisco_ios_xr/_meta/_Cisco_IOS_XR_manageability_object_tracking_oper.py
se,
[
_MetaInfoClassMember('object-name', ATTRIBUTE, 'str' , None, None,
[(0, 33)], [],
''' Object Name
... | code_fim | hard | {
"lang": "python",
"repo": "111pontes/ydk-py",
"path": "/cisco-ios-xr/ydk/models/cisco_ios_xr/_meta/_Cisco_IOS_XR_manageability_object_tracking_oper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: deepchem/simdna path: /simdna/__init__.py
from pkg_resources import resource_filename
ENCODE_MOTIFS_PATH = resource_filename('simdna.resources', 'encode_motifs.tx<|fim_suffix|>urces', 'HOCOMOCOv10_HUMAN_mono_homer_format_0.001.motif.gz')<|fim_middle|>t.gz')
HOCOMOCO_MOTIFS_PATH = resource_filenam... | code_fim | medium | {
"lang": "python",
"repo": "deepchem/simdna",
"path": "/simdna/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>t.gz')
HOCOMOCO_MOTIFS_PATH = resource_filename('simdna.resources', 'HOCOMOCOv10_HUMAN_mono_homer_format_0.001.motif.gz')<|fim_prefix|># repo: deepchem/simdna path: /simdna/__init__.py
from pkg_resources import resource_filename
ENCODE_MOTIFS_PA<|fim_middle|>TH = resource_filename('simdna.resources', 'en... | code_fim | medium | {
"lang": "python",
"repo": "deepchem/simdna",
"path": "/simdna/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #printing the subdataframes
print(groups_state_temp)
print(groups_state_visitorstype_temp)
print(groups_state_visitorstype)
print(groups_workcenter_temp)
print(groups_workcenter_visitorstype)
print(groups_avg_visitors_per_state)
print(groups_avg_visitors_visitorstype_per_mo... | code_fim | hard | {
"lang": "python",
"repo": "joethecoderr/challenge-prework-ds",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joethecoderr/challenge-prework-ds path: /main.py
"""Importante librerias a usar"""
import tkinter as tk
from tkinter.filedialog import askopenfile
import pandas as pd
import numpy as np
import plotly.express as px
"""graficar_stackeds, using plotly lib
takes the dataframe, axis x, y, label a... | code_fim | hard | {
"lang": "python",
"repo": "joethecoderr/challenge-prework-ds",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bitsonforfun/flask-coffee path: /app/jobs.py
# -*- coding: utf-8 -*-
"""
jobs
~~~~~~~~~~~~~~
Jobs defined here.
:copyright: (c) 2016 by fengweimin.
:date: 16/8/12
"""
import os
import threading
import time
from collections import Counter
import schedule
<|fim_suffix|>
def... | code_fim | hard | {
"lang": "python",
"repo": "bitsonforfun/flask-coffee",
"path": "/app/jobs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def init_schedule(app):
"""
Init.
"""
# http://stackoverflow.com/questions/9449101/how-to-stop-flask-from-initialising-twice-in-debug-mode/
app.logger.info('Try to init schedule, current app status is %s/%s/%s' % (
app.debug, app.env, os.environ.get('WERKZEUG_RUN_MAIN')))
... | code_fim | hard | {
"lang": "python",
"repo": "bitsonforfun/flask-coffee",
"path": "/app/jobs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(value, str):
typename, value = value, {}
else:
typename = value.get('typename')
if not typename:
return value
alias = alias_lists.get_alias(typename, ISOLATE)
if alias:
if DEPRECATE_OLD_ALIASES:
log.warning('Aliases th... | code_fim | hard | {
"lang": "python",
"repo": "davidtinman/BiblioPixel",
"path": "/bibliopixel/project/aliases.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise ValueError('Do not understand alias %s' % part)
def resolve(value):
if isinstance(value, str):
typename, value = value, {}
else:
typename = value.get('typename')
if not typename:
return value
alias = alias_lists.get_alias(typename, ISOLATE)
... | code_fim | medium | {
"lang": "python",
"repo": "davidtinman/BiblioPixel",
"path": "/bibliopixel/project/aliases.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidtinman/BiblioPixel path: /bibliopixel/project/aliases.py
import re
from .. util import log
from . importer import import_symbol
from . import alias_lists
ALIAS_MARKER = '$'
SEPARATORS = re.compile(r'[./#]|[^./#]+')
DEPRECATE_OLD_ALIASES = False
# This can set from the commamnd line with --... | code_fim | medium | {
"lang": "python",
"repo": "davidtinman/BiblioPixel",
"path": "/bibliopixel/project/aliases.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def text_render( text , posx , posy , color = ( 0 , 0 , 0 ) , size = 24 ):
font = pygame.font.Font( pygame.font.get_default_font() , size )
surface = pygame.font.Font.render(font, text, 1, color)
rect = surface.get_rect()
rect.centerx = posx
rect.centery = posy
return surface,... | code_fim | medium | {
"lang": "python",
"repo": "SaulHormazabal/PyVora",
"path": "/graphics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SaulHormazabal/PyVora path: /graphics.py
# -*- coding: utf-8 -*-
import pygame
def load_image( path , transparent = False , pixel = ( 0 , 0 ) ):
<|fim_suffix|> rect.centerx = posx
rect.centery = posy
return surface, rect<|fim_middle|>
try:
image = pygame.image.load(path)... | code_fim | hard | {
"lang": "python",
"repo": "SaulHormazabal/PyVora",
"path": "/graphics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cinnamonbreakfast/flcd path: /lab3/main.py
from SymbolTable import SymbolTable
from PIF import PIF
import re
reserved_words = ['array', 'const', 'do', 'else', 'if', 'int', 'elif', 'while', 'for', 'range', 'class', 'struct', 'string', 'float', 'char', 'boolean', 'input', 'WRITE', 'READ', 'fun', '... | code_fim | hard | {
"lang": "python",
"repo": "cinnamonbreakfast/flcd",
"path": "/lab3/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> line_data = list(filter(None, line_data))
line_data = map(lambda e: e.strip(), line_data)
line_data = list(filter(None, line_data))
print(list(line_data))
for e in line_data:
if(is_reserved(e)):
pif.add(e, 0)
elif is_ident_const(e):
index = 0
... | code_fim | hard | {
"lang": "python",
"repo": "cinnamonbreakfast/flcd",
"path": "/lab3/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #---------------------------#
# Previously tested models.
#---------------------------#
# Model_1 -> SpeechRecognizer
# hidden_size = 100
# nlayers = 3
# bidirectional = False
# dropout = 0
# Model_2 -> SpeechRecognizer
# hidden_size = 100
# nlayers = 3
# b... | code_fim | hard | {
"lang": "python",
"repo": "Abhishikta-Ujjain/speech_phoneme_prediction",
"path": "/unaligned/Code/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Abhishikta-Ujjain/speech_phoneme_prediction path: /unaligned/Code/main.py
import os
import csv
import copy
import time
import nltk
import torch
import argparse
import ctcdecode
import numpy as np
import torch.nn as nn
from phoneme_list import *
import torch.optim as optim
import torch.nn.function... | code_fim | hard | {
"lang": "python",
"repo": "Abhishikta-Ujjain/speech_phoneme_prediction",
"path": "/unaligned/Code/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LaplaceKorea/sml-compiler path: /benchmark.py
import os
import subprocess
last = 0
def new_name(s):
global last
last += 1
return s + str(last)
<|fim_suffix|> while total < 10000:
s = text
s = s.replace('merge', new_name('merge'))
s = s.replace('type_chec... | code_fim | medium | {
"lang": "python",
"repo": "LaplaceKorea/sml-compiler",
"path": "/benchmark.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>open('long.sml', 'w').write(long)
subprocess.run(["cargo", "build", "--release"])
bench = subprocess.run(["target/release/sml-driver.exe", "--measure", "long.sml"], capture_output=True)
print(bench.stdout.decode("utf-8"))
os.remove('long.sml')<|fim_prefix|># repo: LaplaceKorea/sml-compiler path: /benchma... | code_fim | medium | {
"lang": "python",
"repo": "LaplaceKorea/sml-compiler",
"path": "/benchmark.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while total < 10000:
s = text
s = s.replace('merge', new_name('merge'))
s = s.replace('type_check', new_name('type_check'))
long += s
total += lines
open('long.sml', 'w').write(long)
subprocess.run(["cargo", "build", "--release"])
bench = subprocess.run(["targ... | code_fim | medium | {
"lang": "python",
"repo": "LaplaceKorea/sml-compiler",
"path": "/benchmark.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: django-helpdesk/django-helpdesk path: /helpdesk/templatetags/in_list.py
"""
django-helpdesk - A Django powered ticket tracker for small enterprise.
(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details.
templatetags/in_list.py - Very simple template tag to allow us to use the
... | code_fim | medium | {
"lang": "python",
"repo": "django-helpdesk/django-helpdesk",
"path": "/helpdesk/templatetags/in_list.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.