text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: ateska/striga path: /components/devel/views/loaderdep.py
import logging as L
import striga.server.application
###
def main(ctx):
app = striga.server.application.GetInstance()
<|fim_suffix|> ctx.res.Write('\tLoadable%d [shape=record, color=%s, style=bold, label="%s"];\n' % (id(loadable) , sta... | code_fim | hard | {
"lang": "python",
"repo": "ateska/striga",
"path": "/components/devel/views/loaderdep.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for key, tloadable in app.Services.Loader.IterLoaderCache():
for sloadable in tloadable.GetDependants():
ctx.res.Write('\tLoadable%d -> Loadable%d;\n' % (id(sloadable), id(tloadable)))
ctx.res.Write('}')<|fim_prefix|># repo: ateska/striga path: /components/devel/views/loaderdep.py
import logging ... | code_fim | hard | {
"lang": "python",
"repo": "ateska/striga",
"path": "/components/devel/views/loaderdep.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: manchandagaurav/ALL-Flask path: /lin.py
import ass
symTable = ass.symTable
globTable = ass.globTable
filelen = ass.filelen
externtable = {}
finalsymTable = {}
def getLoc(exter, fileNames):
for fileName in fileNames:
fileName = fileName.split('.')[0]
for vari in globTable[fileName]:
# pr... | code_fim | hard | {
"lang": "python",
"repo": "manchandagaurav/ALL-Flask",
"path": "/lin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> outFile = open(fileNames[0].split('.')[0]+'.ls','w')
linkCode = []
progCount = 0
for fileName in fileNames :
fileName = fileName.split('.')[0]
inputFile = open(fileName+'.loaded','r')
code = inputFile.read()
lines = code.split('\n')
for line in lines :
line = line.lstrip().rstrip()
if ... | code_fim | hard | {
"lang": "python",
"repo": "manchandagaurav/ALL-Flask",
"path": "/lin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hephaestus9/Ironworks path: /modules_lib/freePBX/bootstrap.py
# -*- coding: utf-8 -*-
# License for all code of this FreePBX module can be found in the license file inside the module directory
# Copyright 2013 Schmooze Com Inc.
#
# *
# * Bootstrap Settings:
# *
# * bootstrap_settings['skip_astma... | code_fim | hard | {
"lang": "python",
"repo": "hephaestus9/Ironworks",
"path": "/modules_lib/freePBX/bootstrap.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
self.bootstrap_settings['astman_config']
except:
self.bootstrap_settings['astman_config'] = ""
try:
self.bootstrap_settings['astman_options']
if len(self.bootstrap_settings['astman_options']) > 0:
pass
... | code_fim | hard | {
"lang": "python",
"repo": "hephaestus9/Ironworks",
"path": "/modules_lib/freePBX/bootstrap.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inmagik/contento path: /contento/meta.py
import re
import json
from django.utils.module_loading import import_string
from contento.settings import CONTENTO_TEXT_PROCESSORS, CONTENTO_RENDERERS
from django.template import loader
from contento import renderers as core_renderers
<|fim_suffix|> fo... | code_fim | hard | {
"lang": "python",
"repo": "inmagik/contento",
"path": "/contento/meta.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rs = get_contento_renderers()
out = {}
for r in rs:
klass = import_string(r)
json_schema = getattr(klass, "json_schema")
if json_schema:
out[r] = json_schema
return out<|fim_prefix|># repo: inmagik/contento path: /contento/meta.py
import re
import json
... | code_fim | hard | {
"lang": "python",
"repo": "inmagik/contento",
"path": "/contento/meta.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return obj.user.email
def full_name(self, obj):
return obj.user.get_full_name()
@admin.register(models.Course)
class CourseAdmin(admin.ModelAdmin):
list_display = ('code', 'full_name', 'name', 'start_time', 'location')
list_filter = ('name', )
search_fields = (
'... | code_fim | hard | {
"lang": "python",
"repo": "tndatacommons/tndata_backend",
"path": "/tndata_backend/officehours/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@admin.register(models.Course)
class CourseAdmin(admin.ModelAdmin):
list_display = ('code', 'full_name', 'name', 'start_time', 'location')
list_filter = ('name', )
search_fields = (
'name', 'user__email', 'user__first_name', 'user__last_name', 'code'
)
raw_id_fields = ('user',... | code_fim | medium | {
"lang": "python",
"repo": "tndatacommons/tndata_backend",
"path": "/tndata_backend/officehours/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tndatacommons/tndata_backend path: /tndata_backend/officehours/admin.py
from django.contrib import admin
from . import models
@admin.register(models.OfficeHours)
class OfficeHoursAdmin(admin.ModelAdmin):
list_display = (
'email', 'full_name', '__str__',
'expires_on', 'creat... | code_fim | medium | {
"lang": "python",
"repo": "tndatacommons/tndata_backend",
"path": "/tndata_backend/officehours/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> oaipmh_cache_dir = os.path.join('/', 'static', 'oaipmh-cache')
if verb=='ListRecords':
d = os.path.join(oaipmh_cache_dir,'datacite4')
f = 'listrecords.xml'
return flask.send_from_directory(d, f, as_attachment=False)
elif verb=='GetRecord':
identifier = flask.re... | code_fim | hard | {
"lang": "python",
"repo": "research-software-directory/research-software-directory",
"path": "/frontend/app/application.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: research-software-directory/research-software-directory path: /frontend/app/application.py
from dateutil import parser
from datetime import datetime
import json
import flask
import markdown
import requests
import htmlmin
import ago
import os
from flask import request
application = flask.Flask(__... | code_fim | hard | {
"lang": "python",
"repo": "research-software-directory/research-software-directory",
"path": "/frontend/app/application.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inasafe/inasafe-fba path: /fixtures/tests/scraper/arcgis_rest_api.py
import json
import os
import requests
from urllib.parse import urlparse, urljoin
class ArcGISRESTAPIWrapper:
def __init__(
self,
endpoint=None,
credentials=None,
params=Non... | code_fim | hard | {
"lang": "python",
"repo": "inasafe/inasafe-fba",
"path": "/fixtures/tests/scraper/arcgis_rest_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # find total records
if advanced_query_capabilities.get('supportsPagination', False):
params = {
'f': 'json',
'where': '1 = 1',
'returnCountOnly': 'true'
}
params.update(self.params)
query_endp... | code_fim | hard | {
"lang": "python",
"repo": "inasafe/inasafe-fba",
"path": "/fixtures/tests/scraper/arcgis_rest_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> min_records = min(
self.total_records, fetch_limit or self.total_records)
limit = count_per_page or self.limit
# in case result exceed max record count
if min_records > limit:
num_page = min_records // limit
num_page += 1 if min_records ... | code_fim | hard | {
"lang": "python",
"repo": "inasafe/inasafe-fba",
"path": "/fixtures/tests/scraper/arcgis_rest_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>import barbot.audio
cfg = json.loads(sys.stdin.read())
try:
barbot.audio.tts(**cfg)
except Exception as e:
print(e)
sys.exit(1)<|fim_prefix|># repo: arafat877/Barbot-11 path: /server/bin/googleTTS.py
#!/usr/bin/python3
import sys, os, logging, json
sys.path.append(os.path.dirname(os.path.d... | code_fim | medium | {
"lang": "python",
"repo": "arafat877/Barbot-11",
"path": "/server/bin/googleTTS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arafat877/Barbot-11 path: /server/bin/googleTTS.py
#!/usr/bin/python3
import sys, os, logging, json
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import barbot.config
config = barbot.config.load()
import barbot.logging
<|fim_suffix|>cfg = json.loads(sys.stdin.... | code_fim | easy | {
"lang": "python",
"repo": "arafat877/Barbot-11",
"path": "/server/bin/googleTTS.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>cfg = json.loads(sys.stdin.read())
try:
barbot.audio.tts(**cfg)
except Exception as e:
print(e)
sys.exit(1)<|fim_prefix|># repo: arafat877/Barbot-11 path: /server/bin/googleTTS.py
#!/usr/bin/python3
import sys, os, logging, json
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspat... | code_fim | easy | {
"lang": "python",
"repo": "arafat877/Barbot-11",
"path": "/server/bin/googleTTS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> The Anonymous User will also make best effort to create all attributes
that should be present on a User class, though these attributes are
statically generated based on `keystonemiddleware.auth_token` 's
documentation (Though all attributes will be set to an empty string).
"""
def... | code_fim | hard | {
"lang": "python",
"repo": "Rackspace-DOT/flask_keystone",
"path": "/flask_keystone/anonymous.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rackspace-DOT/flask_keystone path: /flask_keystone/anonymous.py
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unle... | code_fim | hard | {
"lang": "python",
"repo": "Rackspace-DOT/flask_keystone",
"path": "/flask_keystone/anonymous.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: varunswarup0/HackerRank_Solutions path: /python/04_sets/01_introductiontosets.py
# Solution to [Introduction to Sets](https://www.hackerrank.com/challenges/py-introduction-to-sets)
def average(array):
"""Returns the average of distinct heights."""
unique_vals = set(array)
return sum(... | code_fim | easy | {
"lang": "python",
"repo": "varunswarup0/HackerRank_Solutions",
"path": "/python/04_sets/01_introductiontosets.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().split()))
result = average(arr)
print(result)<|fim_prefix|># repo: varunswarup0/HackerRank_Solutions path: /python/04_sets/01_introductiontosets.py
# Solution to [Introduction to Sets](https://www.hackerrank.com/chall... | code_fim | easy | {
"lang": "python",
"repo": "varunswarup0/HackerRank_Solutions",
"path": "/python/04_sets/01_introductiontosets.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huamichaelchen/grpc path: /src/python/interop/interop/test_pb2.py
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: test/cpp/interop/test.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _desc... | code_fim | hard | {
"lang": "python",
"repo": "huamichaelchen/grpc",
"path": "/src/python/interop/interop/test_pb2.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise NotImplementedError()
HalfDuplexCall.async = None
class _TestServiceStub(TestServiceStub):
def __init__(self, face_stub, default_timeout):
self._face_stub = face_stub
self._default_timeout = default_timeout
stub_self = self
class EmptyCall(object):
def __call__(self, ar... | code_fim | hard | {
"lang": "python",
"repo": "huamichaelchen/grpc",
"path": "/src/python/interop/interop/test_pb2.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> painting_image = painting_to_image(best_painting)
painting_image = cv2.cvtColor(painting_image, cv2.COLOR_RGB2BGR)
cv2.imwrite(config.output, painting_image)<|fim_prefix|># repo: temur-kh/generated-painting path: /service/generator.py
from service.methods import *
import copy
import cv2
imp... | code_fim | hard | {
"lang": "python",
"repo": "temur-kh/generated-painting",
"path": "/service/generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> population = ageing_algorithm(config, population, n)
population = select(population, n, MAX_SELECTION)
if config.logging_every != -1 and epoch % config.logging_every == 0:
print(f'Epoch #{epoch}: Evolution Best Score = {best_painting.score}, Population Best Score = {bes... | code_fim | hard | {
"lang": "python",
"repo": "temur-kh/generated-painting",
"path": "/service/generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: temur-kh/generated-painting path: /service/generator.py
from service.methods import *
import copy
import cv2
import matplotlib.pyplot as plt
def generate_painting(config):
random.seed(config.seed)
epochs = config.epochs
n = config.population_size
m = n // 3
o = config.n_mu... | code_fim | hard | {
"lang": "python",
"repo": "temur-kh/generated-painting",
"path": "/service/generator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: radmerti/scikit-assist path: /skassist-docs/python/doc_definitions.py
# -*- coding: utf-8 -*-
# ______________________________________________________________________________
def boolean_func(experiment):
"""Function that returns True when an experiment matches and False otherwise.
... | code_fim | hard | {
"lang": "python",
"repo": "radmerti/scikit-assist",
"path": "/skassist-docs/python/doc_definitions.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """The scoring function takes a model, the true labels and the prediction
and calculates one or more scores. These are returned in a dictionary which
:func:`~skassist.Model.calc_results` uses to commit them to permanent storage.
Args:
scoring_function (:func:`function`):
... | code_fim | medium | {
"lang": "python",
"repo": "radmerti/scikit-assist",
"path": "/skassist-docs/python/doc_definitions.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
scoring_function (:func:`function`):
A python function for calculating the results given the true labels
and the predictions. See :func:`~skassist.Model.scoring_function`.
skf (:obj:`numpy.ndarray`):
An array containing arrays of splits. E.g... | code_fim | hard | {
"lang": "python",
"repo": "radmerti/scikit-assist",
"path": "/skassist-docs/python/doc_definitions.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.fixture(scope="function")
def batch(data_path):
"""Define a batch for the KrasHras dataset."""
train, _, _ = get_datasets(
data_path=data_path,
nb_nodes=7,
task_type="classification",
nb_classes=2,
split=None,
k_fold=None,
seed=1234,... | code_fim | hard | {
"lang": "python",
"repo": "Tianbiao-Yang/gcn-prot",
"path": "/tests/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Path to KrasHras experiment data."""
return join(dirname(__file__), pardir, "new_data", "graph")
@pytest.fixture(scope="function")
def adj_batch():
"""Define stacked adjacency matrix for 2 proteins."""
return torch.Tensor([[[1, 3], [3, 1]], [[7, 8], [8, 7]]])
@pytest.fixture(scope="... | code_fim | hard | {
"lang": "python",
"repo": "Tianbiao-Yang/gcn-prot",
"path": "/tests/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tianbiao-Yang/gcn-prot path: /tests/conftest.py
"""Instantiate fixtures."""
from os.path import dirname, join, pardir
import pytest
import torch
from gcn_prot.data import get_datasets
from gcn_prot.models import GCN_simple
@pytest.fixture
def data_path(scope="session"):
<|fim_suffix|>
@pytes... | code_fim | hard | {
"lang": "python",
"repo": "Tianbiao-Yang/gcn-prot",
"path": "/tests/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return '<' + str(self.x) + ', ' + str(self.y) + '>'
#Page 202, Figure 13.2
class Field(object):
def __init__(self):
self.drunks = {}
def addDrunk(self, drunk, loc):
if drunk in self.drunks:
raise ValueError('Duplicate drunk'... | code_fim | hard | {
"lang": "python",
"repo": "jasonhuayen91/Introduction_to_Computing_and_Programming_Using_Python",
"path": "/ch13/code13_8.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jasonhuayen91/Introduction_to_Computing_and_Programming_Using_Python path: /ch13/code13_8.py
import random, pylab
#Page 179, Figure 12.4
def stdDev(X):
"""X を数のリストとする
Xの標準偏差を出力する"""
mean = float(sum(X))/len(X)
tot = 0.0
for x in X:
tot += (x - mean)**2
return (... | code_fim | hard | {
"lang": "python",
"repo": "jasonhuayen91/Introduction_to_Computing_and_Programming_Using_Python",
"path": "/ch13/code13_8.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jincao2013/paperspider-manyusers path: /setup.py
from setuptools import setup
from paperspider.version import __version__, __author__, __email__
<|fim_suffix|>setup(
name='paperspider',
version=__version__,
include_package_data=True,
packages=packages_paperspider,
# packages=... | code_fim | medium | {
"lang": "python",
"repo": "jincao2013/paperspider-manyusers",
"path": "/setup.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>setup(
name='paperspider',
version=__version__,
include_package_data=True,
packages=packages_paperspider,
# packages=setuptools.find_packages(),
url='https://github.com/jincao2013/paperspider-manyusers',
license='Apache License, Version 2.0',
author=__author__,
author_e... | code_fim | medium | {
"lang": "python",
"repo": "jincao2013/paperspider-manyusers",
"path": "/setup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if hasattr(fn, "variable"): # if GradAccumulator
u = fn.variable
node_name = "Variable\n " + size_to_str(u.size())
dot.node(str(id(u)), node_name, fillcolor="lightblue")
else:
assert fn in fn_dict, fn
... | code_fim | hard | {
"lang": "python",
"repo": "ikshovon/rail-stgcnn",
"path": "/cargonet/models/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def make_dot():
node_attr = dict(
style="filled",
shape="box",
align="left",
fontsize="12",
ranksep="0.1",
height="0.2",
)
dot = Digraph(node_attr=node_attr, graph_attr=dict(size="12,12"))
def size... | code_fim | hard | {
"lang": "python",
"repo": "ikshovon/rail-stgcnn",
"path": "/cargonet/models/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ikshovon/rail-stgcnn path: /cargonet/models/utils.py
import numpy as np
import torch
from collections import defaultdict
from graphviz import Digraph
from torch.autograd import Function, Variable
def num_params(params):
total_params, trainable = 0, 0
for param in params:
count =... | code_fim | hard | {
"lang": "python",
"repo": "ikshovon/rail-stgcnn",
"path": "/cargonet/models/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Error
Store exceptions for future review.
"""
__tablename__ = 'errors'
id = db.Column(db.Integer, primary_key=True, nullable=False)
error_message = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
updated_at = db.Column(db.DateTime, d... | code_fim | hard | {
"lang": "python",
"repo": "jayrav13/presidency",
"path": "/presidency/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jayrav13/presidency path: /presidency/models.py
from presidency import app, db
import datetime
class WhiteHouse(db.Model):
"""
WhiteHouse
All Briefing Room releases by the White House.
"""
__tablename__ = 'wh_documents'
id = db.Column(db.Integer, primary_key=True, nullable=False)
title... | code_fim | hard | {
"lang": "python",
"repo": "jayrav13/presidency",
"path": "/presidency/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RichardBruskiewich/RTX path: /code/ARAX/ARAXQuery/ARAX_query.py
put = 'STDERR'
#### Set the query based on the supplied example_number
if params.example_number == 1:
query = { 'message': { 'query_type_id': 'Q0', 'terms': { 'term': 'lovastatin' } } }
#query = { "query_type... | code_fim | hard | {
"lang": "python",
"repo": "RichardBruskiewich/RTX",
"path": "/code/ARAX/ARAXQuery/ARAX_query.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>], kp=ARAX/KG1)",
"overlay(action=fisher_exact_test, source_qnode_id=n01, virtual_relation_label=FET, target_qnode_id=n02, cutoff=0.05)",
"resultify()",
"return(message=true, store=false)"
]}}
elif params.example_number == 6232: # chunyu testing #623, this ... | code_fim | hard | {
"lang": "python",
"repo": "RichardBruskiewich/RTX",
"path": "/code/ARAX/ARAXQuery/ARAX_query.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RichardBruskiewich/RTX path: /code/ARAX/ARAXQuery/ARAX_query.py
.log = response.messages
return response
#### Immediately after resultify, run the experimental ranker
if action['command'] == 'resultify':
response.info(f"... | code_fim | hard | {
"lang": "python",
"repo": "RichardBruskiewich/RTX",
"path": "/code/ARAX/ARAXQuery/ARAX_query.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def chunk_bytes(buf):
"""Segments bytes in 16-byte chunks; generates a stream of (chunk,
original_byte_size). The original_byte_size is always CHUNK_SIZE,
except for the last chunk, which may be short.
When the input is shorter than 16 bytes, we convert it to a
16-byte chunk by readi... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/umash",
"path": "/umash_reference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Mixes each chunk in block."""
mixed = list()
lrc = (0, 0) # we generate an additional chunk by xoring everything together
for i, chunk in enumerate(block):
ka = key[2 * i]
kb = key[2 * i + 1]
xa, xb = struct.unpack("<QQ", chunk)
lrc = (lrc[0] ^ (ka ^ xa)... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/umash",
"path": "/umash_reference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/umash path: /umash_reference.py
s $\mathbb{F}$ as a
## subfield: $2^{64} - 8 = 8 \cdot(2^{61} - 1).$ This cannot worsen
## the collision probability, since we could always reduce the result
## mod $2^{61} - 1$ after the fact.
##
## The last step is a finalizer that reversibly mixes th... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/umash",
"path": "/umash_reference.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Function to get Categoria's short form. just a subset of categoria's properties
:param kwargs: form properties
:return: Form
"""
return CategoriaShortForm(**kwargs)
def categoria_public_form(**kwargs):
"""
Function to get Categoria'spublic form. just a subset of catego... | code_fim | hard | {
"lang": "python",
"repo": "renzon/fatec-script",
"path": "/backend/apps/categoria_app/facade.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: renzon/fatec-script path: /backend/apps/categoria_app/facade.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from gaegraph.business_base import NodeSearch, DeleteNode
from categoria_app.commands import ListCategoriaCommand, SaveCategoriaCommand, UpdateCategoria... | code_fim | hard | {
"lang": "python",
"repo": "renzon/fatec-script",
"path": "/backend/apps/categoria_app/facade.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Find categoria by her id
:param categoria_id: the categoria id
:return: Command
"""
return NodeSearch(categoria_id)
def delete_categoria_cmd(categoria_id):
"""
Construct a command to delete a Categoria
:param categoria_id: categoria's id
:return: Command
"... | code_fim | medium | {
"lang": "python",
"repo": "renzon/fatec-script",
"path": "/backend/apps/categoria_app/facade.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with asdf.open(file_path) as af:
assert (af["angle"] == angle).all()<|fim_prefix|># repo: astropy/asdf-astropy path: /asdf_astropy/converters/coordinates/tests/test_angle.py
import asdf
import numpy as np
import pytest
from astropy import units as u
from astropy.coordinates import Angle, Lati... | code_fim | hard | {
"lang": "python",
"repo": "astropy/asdf-astropy",
"path": "/asdf_astropy/converters/coordinates/tests/test_angle.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: astropy/asdf-astropy path: /asdf_astropy/converters/coordinates/tests/test_angle.py
import asdf
import numpy as np
import pytest
from astropy import units as u
from astropy.coordinates import Angle, Latitude, Longitude
def create_angles():
return [
Angle(100, u.deg),
Angle([... | code_fim | medium | {
"lang": "python",
"repo": "astropy/asdf-astropy",
"path": "/asdf_astropy/converters/coordinates/tests/test_angle.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize("angle", create_angles())
def test_serialization(angle, tmp_path):
file_path = tmp_path / "test.asdf"
with asdf.AsdfFile() as af:
af["angle"] = angle
af.write_to(file_path)
with asdf.open(file_path) as af:
assert (af["angle"] == angle).all()<|f... | code_fim | hard | {
"lang": "python",
"repo": "astropy/asdf-astropy",
"path": "/asdf_astropy/converters/coordinates/tests/test_angle.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>f = open('sigSimMatrix.csv')
f.readline()
array = f.readlines()
array = map(lambda x: map(lambda y: float(y), x.strip().split(',')[1:]), array)
array = scipy.array(array)
mesh = pyplot.pcolormesh(array)
pyplot.show()<|fim_prefix|># repo: vaginessa/droidlegacy path: /scripts/makeVisualMatrix.py
#Copyright... | code_fim | medium | {
"lang": "python",
"repo": "vaginessa/droidlegacy",
"path": "/scripts/makeVisualMatrix.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vaginessa/droidlegacy path: /scripts/makeVisualMatrix.py
#Copyright 2013 Software Research Lab, University of Louisiana at Lafayette
#
#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 L... | code_fim | medium | {
"lang": "python",
"repo": "vaginessa/droidlegacy",
"path": "/scripts/makeVisualMatrix.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: infosmith/dj-contentmodel path: /dj_contentmodel/admin.py
# -*- coding: utf-8 -*-
"""
Group is the only required AdminManager.
-If Sitemap, Collection, or Page models<|fim_suffix|>TTAdmin
from .models import Role
admin.site.register(
Role,
DraggableMPTTAdmin,
list_display=(
... | code_fim | medium | {
"lang": "python",
"repo": "infosmith/dj-contentmodel",
"path": "/dj_contentmodel/admin.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'tree_actions',
'indented_title',
),
list_display_links=(
'indented_title',
),
)<|fim_prefix|># repo: infosmith/dj-contentmodel path: /dj_contentmodel/admin.py
# -*- coding: utf-8 -*-
"""
Group is the only required AdminManager.
-If Sitemap, Collection, or Page models ... | code_fim | medium | {
"lang": "python",
"repo": "infosmith/dj-contentmodel",
"path": "/dj_contentmodel/admin.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># apply the four point tranform to obtain a "birds eye view" of
# the image
warped = four_point_transform(image, pts)
# show the original and warped images
cv2.imshow("Original", image)
cv2.imshow("Warped", warped)
cv2.waitKey(0)<|fim_prefix|># repo: elcano/elcano path: /Vision/LaneDetection/bird_eye.py... | code_fim | hard | {
"lang": "python",
"repo": "elcano/elcano",
"path": "/Vision/LaneDetection/bird_eye.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elcano/elcano path: /Vision/LaneDetection/bird_eye.py
# import the necessary packages
from transform import four_point_transform
import numpy as np
import argparse
import cv2
<|fim_suffix|># show the original and warped images
cv2.imshow("Original", image)
cv2.imshow("Warped", warped)
cv2.waitKe... | code_fim | hard | {
"lang": "python",
"repo": "elcano/elcano",
"path": "/Vision/LaneDetection/bird_eye.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: guptavidya/suspend-non-users path: /suspend_non_users.py
import os
import sys
from github3 import enterprise_login
from requests import put
class Suspender:
def __init__(self, url, access_token, should_verify=False):
self.ghe_url = url
self.token = access_token
sel... | code_fim | hard | {
"lang": "python",
"repo": "guptavidya/suspend-non-users",
"path": "/suspend_non_users.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 0 == (user_detail.disk_usage +
user_detail.public_repos_count +
user_detail.public_gists +
user_detail.total_private_repos +
user_detail.total_private_gists)
def suspend_user(self, user):
return... | code_fim | hard | {
"lang": "python",
"repo": "guptavidya/suspend-non-users",
"path": "/suspend_non_users.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
should_verify = False
usage = 'usage: suspend_non_users.py <ghe_url> [option]\n\nOptions:\n-i\tVerify before suspending each user'
if len(sys.argv) < 2:
print usage
sys.exit(1)
ghe_url = sys.argv[1]
token = os.environ.get('GHE_ACCESS_TOKEN')
... | code_fim | hard | {
"lang": "python",
"repo": "guptavidya/suspend-non-users",
"path": "/suspend_non_users.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: open-mmlab/mmdeploy path: /tests/test_codebase/test_mmdet3d/data/cyclic-20e.py
# Copyright (c) OpenMMLab. All rights reserved.
# For nuScenes dataset, we usually evaluate the model at the end of training.
# Since the models are trained by 24 epochs by default, we set evaluation
# interval to be 2... | code_fim | medium | {
"lang": "python",
"repo": "open-mmlab/mmdeploy",
"path": "/tests/test_codebase/test_mmdet3d/data/cyclic-20e.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Default setting for scaling LR automatically
# - `enable` means enable scaling LR automatically
# or not by default.
# - `base_batch_size` = (8 GPUs) x (4 samples per GPU).
auto_scale_lr = dict(enable=False, base_batch_size=32)<|fim_prefix|># repo: open-mmlab/mmdeploy path: /tests/test_codeba... | code_fim | medium | {
"lang": "python",
"repo": "open-mmlab/mmdeploy",
"path": "/tests/test_codebase/test_mmdet3d/data/cyclic-20e.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route('/', methods = ['POST'])
def reg():
dict = json.loads(request.get_data())
a = [1, 2, 3, 4]
return json.dumps(a)
if __name__ == '__main__':
app.run(debug=False)<|fim_prefix|># repo: gitwillsky/learn_dl path: /webapp/app.py
import json
from flask import Flask
from flask import r... | code_fim | easy | {
"lang": "python",
"repo": "gitwillsky/learn_dl",
"path": "/webapp/app.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gitwillsky/learn_dl path: /webapp/app.py
import json
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/', methods = ['POST'])
def reg():
<|fim_suffix|>if __name__ == '__main__':
app.run(debug=False)<|fim_middle|> dict = json.loads(request.get_data())... | code_fim | medium | {
"lang": "python",
"repo": "gitwillsky/learn_dl",
"path": "/webapp/app.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Straor/Prog path: /Python/prog23.py
# -*- coding: utf-8 -*-
#programme pour apprendre les fonctions
<|fim_suffix|>chaine=input("donner la vitesse du véhicule")
vitesse=int(chaine)
dars=calcul_distance(vitesse,0.8)
darm=calcul_distance(vitesse,0.4)
print("votre distance d'arret est de ",dars,"m ... | code_fim | medium | {
"lang": "python",
"repo": "Straor/Prog",
"path": "/Python/prog23.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("votre distance d'arret est de ",dars,"m sur route sèche et de ",darm,"sur route mouillée")<|fim_prefix|># repo: Straor/Prog path: /Python/prog23.py
# -*- coding: utf-8 -*-
#programme pour apprendre les fonctions
<|fim_middle|>def calcul_distance(vitesse,coefficient):
resultat = vitesse/3.6 + vit... | code_fim | hard | {
"lang": "python",
"repo": "Straor/Prog",
"path": "/Python/prog23.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samuelclark907/data-structures-and-algorithms path: /python/ll_zip/test_ll_zip.py
from linked_list.linked_list import LinkedList
from ll_zip import zipLists
def test_import():
<|fim_suffix|>def test_same_length():
ll1 = LinkedList()
ll1.append(1)
ll1.append(3)
ll1.append(5)
l... | code_fim | medium | {
"lang": "python",
"repo": "samuelclark907/data-structures-and-algorithms",
"path": "/python/ll_zip/test_ll_zip.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_same_length():
ll1 = LinkedList()
ll1.append(1)
ll1.append(3)
ll1.append(5)
ll2 = LinkedList()
ll2.append(2)
ll2.append(4)
ll2.append(6)
actual = str(zipLists(ll1,ll2))
expected = "{1}->{2}->{3}->{4}->{5}->{6}->None"
assert actual == expected
def te... | code_fim | medium | {
"lang": "python",
"repo": "samuelclark907/data-structures-and-algorithms",
"path": "/python/ll_zip/test_ll_zip.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, август.")
elif n == 4:
print("Время года: осень. Месяцы: сентябрь, октябрь, ноябрь.")
else:
print("Ошибка! Допустимы только номера от 1 до 4.")
exit(1)<|fim_prefix|># repo: gor-dimm/lr3 path: /1.py
# С клавиатуры вводится цифра (от 1 до 4). Вывести на экран названия месяцев,
# соответствующих в... | code_fim | medium | {
"lang": "python",
"repo": "gor-dimm/lr3",
"path": "/1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gor-dimm/lr3 path: /1.py
# С клавиатуры вводится цифра (от 1 до 4). Вывести на экран названия месяцев,
# соответствующих времени года с номером (считать зиму временем года № 1).
if __na<|fim_suffix|>, август.")
elif n == 4:
print("Время года: осень. Месяцы: сентябрь, октябрь, ноябрь.")
else:... | code_fim | hard | {
"lang": "python",
"repo": "gor-dimm/lr3",
"path": "/1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ds = random_text_classification_dataset(10)
loader = dataloader(ds, 3, kimcnn_collate_fn, train=False)
self.assertTrue(isinstance(loader.sampler, BatchSampler))
self.assertTrue(isinstance(loader.sampler.sampler, SequentialSampler))
self.assertTrue(isinstance(loader... | code_fim | hard | {
"lang": "python",
"repo": "webis-de/small-text",
"path": "/tests/unit/small_text/integrations/pytorch/utils/test_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_get_class_weights_binary(self):
y = np.array([0, 1, 1, 1, 1])
class_weights = get_class_weights(y, 2)
assert_array_equal(np.array([4.0, 1.0]), class_weights.cpu().numpy())
def test_get_class_weights_multiclass(self):
y = np.array([0, 1, 1, 1, 1, 2, 3, 3])... | code_fim | medium | {
"lang": "python",
"repo": "webis-de/small-text",
"path": "/tests/unit/small_text/integrations/pytorch/utils/test_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webis-de/small-text path: /tests/unit/small_text/integrations/pytorch/utils/test_data.py
import unittest
import numpy as np
import pytest
import torch
from numpy.testing import assert_array_almost_equal, assert_array_equal
from scipy.sparse import csr_matrix
from small_text.integrations.pytorch... | code_fim | hard | {
"lang": "python",
"repo": "webis-de/small-text",
"path": "/tests/unit/small_text/integrations/pytorch/utils/test_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FirebirdSQL/firebird-qa path: /tests/bugs/core_1167_test.py
#coding:utf-8
"""
ID: issue-1590
ISSUE: 1590
TITLE: CHARACTER SET GBK is not installed
DESCRIPTION:
Default character set is GBK
Create Table T1(ID integer, FName Varchar(20); -- OK
Commit; ---Error Message: C... | code_fim | hard | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/core_1167_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout<|fim_prefix|># repo: FirebirdSQL/firebird-qa path: /tests/bugs/core_1167_test.py
#coding:utf-8
"""
ID: issue-1590
ISSUE: ... | code_fim | hard | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/core_1167_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_new_forgiving_factor():
"""Tests forgiving factor."""
delta_p = 8.0
delta_n = 8.0
rate = 2.0
stress = 1.0
input_bits = 8
output_bits = 8
ref_bits = 8
config = {
"QDense": ["parameters", "activations"],
"Dense": ["parameters", "activations"],
"QConv2D": ["param... | code_fim | hard | {
"lang": "python",
"repo": "google/qkeras",
"path": "/qkeras/autoqkeras/tests/test_forgiving_factor.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google/qkeras path: /qkeras/autoqkeras/tests/test_forgiving_factor.py
# ==============================================================================
# Copyright 2020 Google LLC
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance... | code_fim | hard | {
"lang": "python",
"repo": "google/qkeras",
"path": "/qkeras/autoqkeras/tests/test_forgiving_factor.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JuliaDiff/ForwardDiff.jl path: /benchmarks/py/algopy_benchmarks.py
import numpy, algopy, timeit #, os, pickle
################
# AD functions #
################
def gradient(f):
def gradf(x):
y = algopy.UTPM.init_jacobian(x)
return algopy.UTPM.extract_jacobian(f(y))
retur... | code_fim | hard | {
"lang": "python",
"repo": "JuliaDiff/ForwardDiff.jl",
"path": "/benchmarks/py/algopy_benchmarks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#############################
# Benchmark utility methods #
#############################
def bench(f, x, repeat):
def wrapf():
return f(x)
return min(timeit.repeat(wrapf, number=1, repeat=repeat))<|fim_prefix|># repo: JuliaDiff/ForwardDiff.jl path: /benchmarks/py/algopy_benchmarks.py
im... | code_fim | hard | {
"lang": "python",
"repo": "JuliaDiff/ForwardDiff.jl",
"path": "/benchmarks/py/algopy_benchmarks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: firstmover/hmr path: /helpers/save_pose_visualization.py
list[idx][1]], c='grey', marker='x', s=25)
if gt_point_list[idx][0] > 0 and gt_point_list[idx][1] > 0:
axeslist.ravel()[idx].scatter(
y=[gt_point_list[idx][0]], x=[gt_point_list[idx][1]], c='white', marke... | code_fim | hard | {
"lang": "python",
"repo": "firstmover/hmr",
"path": "/helpers/save_pose_visualization.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: firstmover/hmr path: /helpers/save_pose_visualization.py
is to seperate gt from pred.
xs = [pose[i][0] - 10 for i in range(14) if pose[i][2] > 0]
# TODO: why upside down? It is designed upsided-down.
ys = [60 - pose[i][1] for i in range(14) if pose[i][2] > 0]
zs = ... | code_fim | hard | {
"lang": "python",
"repo": "firstmover/hmr",
"path": "/helpers/save_pose_visualization.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if verbose and t % 10 == 0:
print("t: {}".format(t))
nr_channel = len(hor)
# feature map without cropping
path_hor = os.path.join(file_dir, image_tag.format(h_v="hor", time=base_time + t) + ".png")
path_ver = os.path.join(file_dir, image_tag.format(h_v="ver", time=base_time +... | code_fim | hard | {
"lang": "python",
"repo": "firstmover/hmr",
"path": "/helpers/save_pose_visualization.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: muknerd/scrapy-training path: /unit5/spiders/spider_3_quotes_selenium.py
import scrapy
from selenium import webdriver
class QuotesJsSpider(scrapy.Spider):
name = 'quotes-js'
start_urls = [
'http://quotes.toscrape.com/js'
]
<|fim_suffix|> self.driver.get(response.url)... | code_fim | hard | {
"lang": "python",
"repo": "muknerd/scrapy-training",
"path": "/unit5/spiders/spider_3_quotes_selenium.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.driver.get(response.url)
sel = scrapy.Selector(text=self.driver.page_source)
for quote in sel.css('div.quote'):
yield {
'text': quote.css('span.text::text').extract_first(),
'author': quote.css('span small::text').extract_first(),
... | code_fim | medium | {
"lang": "python",
"repo": "muknerd/scrapy-training",
"path": "/unit5/spiders/spider_3_quotes_selenium.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def parse(self, response):
self.driver.get(response.url)
sel = scrapy.Selector(text=self.driver.page_source)
for quote in sel.css('div.quote'):
yield {
'text': quote.css('span.text::text').extract_first(),
'author': quote.css('span sm... | code_fim | hard | {
"lang": "python",
"repo": "muknerd/scrapy-training",
"path": "/unit5/spiders/spider_3_quotes_selenium.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gaocegege/treadmill path: /treadmill/cli/aws.py
"""Admin Cell CLI module"""
import logging
# import os
# import errno
# import sys
import click
# from ansible.cli.playbook import PlaybookCLI
# from distutils.dir_util import copy_tree
_LOGGER = logging.getLogger(__name__)
# TODO: this should... | code_fim | hard | {
"lang": "python",
"repo": "gaocegege/treadmill",
"path": "/treadmill/cli/aws.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @aws.command(name='node')
@click.option('--create',
required=False,
is_flag=True,
help='Create a new treadmill node',)
@click.option('--playbook',
'node.yml',
help='Playbok file',)
@click.option('--in... | code_fim | hard | {
"lang": "python",
"repo": "gaocegege/treadmill",
"path": "/treadmill/cli/aws.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Manage treadmill node"""
pass
# if create:
# playbook_cli = PlaybookCLI([
# 'ansible-playbook',
# '-i',
# inventory,
# playbook,
# '--key-file',
# key_file,
# ... | code_fim | hard | {
"lang": "python",
"repo": "gaocegege/treadmill",
"path": "/treadmill/cli/aws.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NREL/ditto path: /ditto/writers/json/write.py
# coding: utf8
from __future__ import absolute_import, division, print_function
from builtins import super, range, zip, round, map
import os
import json_tricks
from datetime import datetime
from ditto.writers.abstract_writer import AbstractWriter
f... | code_fim | hard | {
"lang": "python",
"repo": "NREL/ditto",
"path": "/ditto/writers/json/write.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif isinstance(v, Winding):
json_dump["model"][-1][key]["value"].append(
{"class": "Winding"}
)
for kkk, vvv in v._trait_values.items():
... | code_fim | hard | {
"lang": "python",
"repo": "NREL/ditto",
"path": "/ditto/writers/json/write.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def write(self, model):
"""
Write a given DiTTo model to a JSON file.
The output file is configured in the constructor.
"""
# Initialize json_dump
json_dump = {"model": [], "metadata": {}}
# Set timestamp in metadata
json_dump["metadata... | code_fim | hard | {
"lang": "python",
"repo": "NREL/ditto",
"path": "/ditto/writers/json/write.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = {
'code': access_token,
'clientId': client_id,
'redirectUri': redirect_uri
}
return client.token('github', data)<|fim_prefix|># repo: alerta/python-alerta-client path: /alertaclient/auth/github.py
import webbrowser
from uuid import uuid4
from alertaclient.auth.... | code_fim | hard | {
"lang": "python",
"repo": "alerta/python-alerta-client",
"path": "/alertaclient/auth/github.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alerta/python-alerta-client path: /alertaclient/auth/github.py
import webbrowser
from uuid import uuid4
from alertaclient.auth.token import TokenHandler
<|fim_suffix|> data = {
'code': access_token,
'clientId': client_id,
'redirectUri': redirect_uri
}
return ... | code_fim | hard | {
"lang": "python",
"repo": "alerta/python-alerta-client",
"path": "/alertaclient/auth/github.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> webbrowser.open(url, new=0, autoraise=True)
auth = TokenHandler()
access_token = auth.get_access_token(xsrf_token)
data = {
'code': access_token,
'clientId': client_id,
'redirectUri': redirect_uri
}
return client.token('github', data)<|fim_prefix|># repo: a... | code_fim | hard | {
"lang": "python",
"repo": "alerta/python-alerta-client",
"path": "/alertaclient/auth/github.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.writer.write(f'SERVER_ERROR {msg}\r\n'.encode())
self.data = b''
self.closed = True
def _client_error(self, msg: str) -> None:
self.writer.write(f'CLIENT_ERROR {msg}\r\n'.encode())
self.data = b''
self.closed = True
def _error(self) -> None:
... | code_fim | hard | {
"lang": "python",
"repo": "lighttpd/lighttpd2",
"path": "/tests/run-memcached.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lighttpd/lighttpd2 path: /tests/run-memcached.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import socket
import time
import random
import traceback
import typing
class MemcacheEntry:
def __init__(self, flags: bytes, exptime: bytes, data: bytes, cas: bytes):
self... | code_fim | hard | {
"lang": "python",
"repo": "lighttpd/lighttpd2",
"path": "/tests/run-memcached.py",
"mode": "psm",
"license": "CC0-1.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.