text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>urlpatterns += [ path('<int:pk>/<slug:slug>/', include([ path('', ListCategory.as_view(), name='list_subcategory'), path('threads/', ListDescendantCategoryThread.as_view(), name='list_thread'), ])) ]<|fim_prefix|># repo: adepeter/sleekforum-docker path: /src/flyapps/categories/url...
code_fim
medium
{ "lang": "python", "repo": "adepeter/sleekforum-docker", "path": "/src/flyapps/categories/urls/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: adepeter/sleekforum-docker path: /src/flyapps/categories/urls/__init__.py from django.urls import include, path from ..views import ( ListBaseCategory, ListCategory, ListDescendantCategoryThread, SearchCategory, ) <|fim_suffix|>urlpatterns += [ path('<int:pk>/<slug:slug>/', i...
code_fim
medium
{ "lang": "python", "repo": "adepeter/sleekforum-docker", "path": "/src/flyapps/categories/urls/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: wtomin/SteerablePyramid_Torch_TF_Numpy path: /examples/example_tf.py # MIT License # # Copyright (c) 2020 Didan Deng # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software w...
code_fim
hard
{ "lang": "python", "repo": "wtomin/SteerablePyramid_Torch_TF_Numpy", "path": "/examples/example_tf.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ############################################################################ # Visualization # Just extract a single example from the batch # Also moves the example to CPU and NumPy coeff = utils.extract_from_batch(coeff, 0) if config.visualize: import cv2 coeff_g...
code_fim
hard
{ "lang": "python", "repo": "wtomin/SteerablePyramid_Torch_TF_Numpy", "path": "/examples/example_tf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if config.visualize: import cv2 coeff_grid = utils.make_grid_coeff(coeff, normalize=True) cv2.imshow('image', (im_batch_numpy[0,0,]*255.).astype(np.uint8)) cv2.imshow('coeff', coeff_grid) k = cv2.waitKey(0) if k == 27: # wait for ESC key to exit ...
code_fim
hard
{ "lang": "python", "repo": "wtomin/SteerablePyramid_Torch_TF_Numpy", "path": "/examples/example_tf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nazrulworld/fhir.resources path: /fhir/resources/STU3/tests/test_chargeitem.py # -*- coding: utf-8 -*- """ Profile: http://hl7.org/fhir/StructureDefinition/ChargeItem Release: STU3 Version: 3.0.2 Revision: 11917 Last updated: 2019-10-24T11:53:00+11:00 """ from pydantic.validators import bytes_val...
code_fim
hard
{ "lang": "python", "repo": "nazrulworld/fhir.resources", "path": "/fhir/resources/STU3/tests/test_chargeitem.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """No. 1 tests collection for ChargeItem. Test File: chargeitem-example.json """ filename = base_settings["unittest_data_dir"] / "chargeitem-example.json" inst = chargeitem.ChargeItem.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Char...
code_fim
hard
{ "lang": "python", "repo": "nazrulworld/fhir.resources", "path": "/fhir/resources/STU3/tests/test_chargeitem.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Abjad/abjad-ext-nauert path: /abjadext/nauert/gracehandlers.py import abc import typing import abjad from .qevents import PitchedQEvent, QEvent, SilentQEvent class GraceHandler(abc.ABC): """ Abstract grace-handler. Determines what pitch, if any, will be selected from a list of ...
code_fim
hard
{ "lang": "python", "repo": "Abjad/abjad-ext-nauert", "path": "/abjadext/nauert/gracehandlers.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Boolean of whether to discard grace rests or not. """ return self._discard_grace_rest @property def grace_duration(self) -> abjad.Duration: """ Grace duration of concantenating grace handler. """ return self._grace_duration ...
code_fim
hard
{ "lang": "python", "repo": "Abjad/abjad-ext-nauert", "path": "/abjadext/nauert/gracehandlers.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: acgrid/bilibili-show-dump path: /utils.py import requests import json import os import re import datetime from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry from openpyxl import Workbook from openpyxl.utils import get_column_letter def requests_retry_session( ret...
code_fim
hard
{ "lang": "python", "repo": "acgrid/bilibili-show-dump", "path": "/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result = match_single(data, regexp) return datetime.datetime.strptime(result, '%Y-%m-%d %H:%M') if result else None def set_columns_width(sheet, columns_width): for index, width in enumerate(columns_width): sheet.column_dimensions[get_column_letter(index + 1)].width = width<|fim_pref...
code_fim
hard
{ "lang": "python", "repo": "acgrid/bilibili-show-dump", "path": "/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> val = 0.0 if abs(x)<0.5: val = 1.0 return val def init_random(x): return np.random.rand(1) def step_wave(t): c = 1.0 # wave speed if t<2: print( 'stability:', (c*dt/dx)**2 ) # set initial condition for i in range(0,nx): u[t,i] = 0....
code_fim
hard
{ "lang": "python", "repo": "dianafprieto/SS_2017", "path": "/scripts/08_PDE_part1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dianafprieto/SS_2017 path: /scripts/08_PDE_part1.py import numpy as np import math import matplotlib.pyplot as plt from matplotlib import animation, rc # define the discretization grid dx = 0.1 # space increment (default 0.1) dt = 0.01 # time increment (default 0.01) tmin = 0.0 # initial ...
code_fim
hard
{ "lang": "python", "repo": "dianafprieto/SS_2017", "path": "/scripts/08_PDE_part1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>.command, name='command'), path('interaction', views.interaction, name='interaction'), ]<|fim_prefix|># repo: whatsupmike/homie path: /slack_integration/urls.py from django.urls import path from . import vi<|fim_middle|>ews urlpatterns = [ path('command', views
code_fim
easy
{ "lang": "python", "repo": "whatsupmike/homie", "path": "/slack_integration/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: whatsupmike/homie path: /slack_integration/urls.py from django.urls import path from . import views urlpatterns = [ path('command', views<|fim_suffix|>on', views.interaction, name='interaction'), ]<|fim_middle|>.command, name='command'), path('interacti
code_fim
easy
{ "lang": "python", "repo": "whatsupmike/homie", "path": "/slack_integration/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for id_, repl in matched.items(): if not repl: continue ref = Ref.get(id_, default=None) if ref is None: continue Config.add_replacement(ref, repl, session=DBSession, model=Source) DBSession.delete(ref) i...
code_fim
hard
{ "lang": "python", "repo": "kublaj/glottolog3", "path": "/glottolog3/scripts/match_obsolete_refs.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # # TODO: # - create bibtex file containing all refs to be removed! # - # matched = args.data_file(args.version, 'obsolete_refs_matched.json') if matched.exists(): with open(matched) as fp: matched = json.load(fp) ...
code_fim
hard
{ "lang": "python", "repo": "kublaj/glottolog3", "path": "/glottolog3/scripts/match_obsolete_refs.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kublaj/glottolog3 path: /glottolog3/scripts/match_obsolete_refs.py # -*- coding: utf-8 -*- import json import transaction from clld.scripts.util import parsed_args from clld.db.meta import DBSession from clld.db.models.common import Config, Source from glottolog3.scripts.util import match_obsol...
code_fim
hard
{ "lang": "python", "repo": "kublaj/glottolog3", "path": "/glottolog3/scripts/match_obsolete_refs.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sassoftware/catalog-service path: /catalogService/rest/models/serviceInfo.py #!/usr/bin/python # # Copyright (c) SAS Institute Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the...
code_fim
medium
{ "lang": "python", "repo": "sassoftware/catalog-service", "path": "/catalogService/rest/models/serviceInfo.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> serviceInfoClass = ServiceInfo def __init__(self): xmllib.DataBinder.__init__(self) for cls in [ self.serviceInfoClass, ]: self.registerType(cls, cls.tag)<|fim_prefix|># repo: sassoftware/catalog-service path: /catalogService/rest/models/serviceInfo.py #!/usr/bin/pytho...
code_fim
hard
{ "lang": "python", "repo": "sassoftware/catalog-service", "path": "/catalogService/rest/models/serviceInfo.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jhosteny/iglu-python-client path: /tests/test_core.py import pytest from iglu_client.core import SchemaKey, SchemaVer, IgluError class TestSchemaKey: def test_parse_iglu_uri(self): assert ( SchemaKey.parse_key( "iglu:com.snowplowanalytics.snowplow/event/...
code_fim
hard
{ "lang": "python", "repo": "jhosteny/iglu-python-client", "path": "/tests/test_core.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with pytest.raises(IgluError): SchemaKey.parse_key("com.snowplowanalytics.snowplow/event/jsonschema/1-0-1") def test_parse_schema_key_invalid_version(self): with pytest.raises(IgluError): SchemaKey.parse_key("com.snowplowanalytics.snowplow/event/jsonschema/1-a-...
code_fim
hard
{ "lang": "python", "repo": "jhosteny/iglu-python-client", "path": "/tests/test_core.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with open('test_result.txt', 'w+') as f: for sen, sen_tag, sen_pre in zip(sentences, labels, pre_tags): for i in range(len(sen)): f.write('{}\t{}\t{}\n'.format(sen[i], sen_tag[i], sen_pre[i])) f.write('\n') print('Test finished!') if __name__ == '...
code_fim
medium
{ "lang": "python", "repo": "VictorJiangXin/Linear-CRF", "path": "/src/test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: VictorJiangXin/Linear-CRF path: /src/test.py import os import sys import codecs from crf import LinearCRF def test_file(model_path, test_file_path): """Test model test file format 今 B 晚 E 月 B 色 E 真 S 美 S 。 S <MUST SEPERATE BY SPACE LINE> ...
code_fim
hard
{ "lang": "python", "repo": "VictorJiangXin/Linear-CRF", "path": "/src/test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: puilp0502/fzypy path: /src/fzy/search.py """An utility module that provides simple search method. This module provides a thin wrapper around the underlying fzy.choices module. This module is provided only for user convenience; users are encouraged to used fzy.choices module directly. """ from fz...
code_fim
medium
{ "lang": "python", "repo": "puilp0502/fzypy", "path": "/src/fzy/search.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Fuzzy search from provided `candidates` with query `search`. :param search: search query :param candidates: list (or iterable) of candidate strings :return: list of (candidate, score) tuples """ choicer = choices.Choice() for candidate in candidates: choicer.add(cand...
code_fim
medium
{ "lang": "python", "repo": "puilp0502/fzypy", "path": "/src/fzy/search.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> vaddr = int(phdr.p_vaddr) offset = int(phdr.p_offset) flags = int(phdr.p_flags) ptype = int(phdr.p_type) memsz += pwndbg.lib.memory.page_offset(vaddr) memsz = pwndbg.lib.memory.page_size_align(memsz) vaddr = pwndbg.lib.memory.page_align(vaddr) ...
code_fim
hard
{ "lang": "python", "repo": "pwndbg/pwndbg", "path": "/pwndbg/gdblib/elf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pwndbg/pwndbg path: /pwndbg/gdblib/elf.py """ This file declares types and methods useful for enumerating all of the address spaces and permissions of an ELF file in memory. This is necessary for when access to /proc is restricted, or when working on a BSD system which simply does not have /proc...
code_fim
hard
{ "lang": "python", "repo": "pwndbg/pwndbg", "path": "/pwndbg/gdblib/elf.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # For each page described by this program header for page_addr in range(vaddr, vaddr + memsz, pwndbg.lib.memory.PAGE_SIZE): if page_addr in pages: page = pages[pages.index(page_addr)] # type: ignore[arg-type] # Don't ever remove the execute fla...
code_fim
hard
{ "lang": "python", "repo": "pwndbg/pwndbg", "path": "/pwndbg/gdblib/elf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dockerizeme/dockerizeme path: /hard-gists/1710122/snippet.py """Flask extension utility.""" from flask.sessions import SessionInterface, SessionMixin from werkzeug.contrib.cache import MemcachedCache import memcache # Use https://code.launchpad.net/~songofacandy/python-memcached/mixin-threadin...
code_fim
medium
{ "lang": "python", "repo": "dockerizeme/dockerizeme", "path": "/hard-gists/1710122/snippet.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> cache = app.cache _key = session._session_key cache.set(_key, session, timeout=0) # Example: # app.config.update(MEMCACHED_SERVERS='localhost:11211 localhost:11212', # MEMCACHED_PREFIX ='app32-', # ) # setup_cache(app) # app.session_interface =...
code_fim
medium
{ "lang": "python", "repo": "dockerizeme/dockerizeme", "path": "/hard-gists/1710122/snippet.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> SessionInterface.__init__(self) self._key_func = key self._prefix = prefix def open_session(self, app, request): cache = app.cache try: _key = self._prefix + self._key_func(request) except Exception: return None obj = cac...
code_fim
hard
{ "lang": "python", "repo": "dockerizeme/dockerizeme", "path": "/hard-gists/1710122/snippet.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ingram7/SourceCodeOfBook path: /第7章/program/example_fake_ajax.py import json import requests import re url = 'http://exercise.kingname.info/exercise_ajax_2.html' html = requests.get(url).content.decode() <|fim_suffix|># html_json = '{"code": "\u884c\u52a8\u4ee3\u53f7\uff1a\u5929\u738b\u76d6\u57...
code_fim
medium
{ "lang": "python", "repo": "Ingram7/SourceCodeOfBook", "path": "/第7章/program/example_fake_ajax.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># html_json = '{"code": "\u884c\u52a8\u4ee3\u53f7\uff1a\u5929\u738b\u76d6\u5730\u864e"}' # html_dict = json.loads(html_json) # print(html_dict)<|fim_prefix|># repo: Ingram7/SourceCodeOfBook path: /第7章/program/example_fake_ajax.py import json import requests import re url = 'http://exercise.kingname.info...
code_fim
medium
{ "lang": "python", "repo": "Ingram7/SourceCodeOfBook", "path": "/第7章/program/example_fake_ajax.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gilsonaureliano/Python-aulas path: /python_aulas/desaf068_break_sorteio.py from random import randint c = 0 while True: computador = randint(0, 10) print('+='*12) print('Vamos jogar par ou ímpar?') print('+='*12) jogador = int(input('Digite seu valor: '<|fim_suffix|>Venceu!!')...
code_fim
hard
{ "lang": "python", "repo": "gilsonaureliano/Python-aulas", "path": "/python_aulas/desaf068_break_sorteio.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> r = 'DEU IMPAR' p2 = 'I' print(f'O computador jogou {computador} e você jogou {jogador} ,total {computador + jogador} - {r}') if pi == p2: print('+='*12) print('Você Venceu!!') print('Vamos jogar novamente') c = c + 1 else: print('+=' * 12) ...
code_fim
medium
{ "lang": "python", "repo": "gilsonaureliano/Python-aulas", "path": "/python_aulas/desaf068_break_sorteio.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Parthi10/django-DefectDojo path: /dojo/management/commands/validatededupeconfig.py from django.core.management.base import BaseCommand from django.conf import settings import logging <|fim_suffix|> help = 'Validate deduplication logic in settings' def handle(self, *args, **options): ...
code_fim
medium
{ "lang": "python", "repo": "Parthi10/django-DefectDojo", "path": "/dojo/management/commands/validatededupeconfig.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> class Command(BaseCommand): help = 'Validate deduplication logic in settings' def handle(self, *args, **options): for scanner in settings.HASHCODE_FIELDS_PER_SCANNER: for field in settings.HASHCODE_FIELDS_PER_SCANNER.get(scanner): if field not in settings.HASH...
code_fim
medium
{ "lang": "python", "repo": "Parthi10/django-DefectDojo", "path": "/dojo/management/commands/validatededupeconfig.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def handle(self, *args, **options): for scanner in settings.HASHCODE_FIELDS_PER_SCANNER: for field in settings.HASHCODE_FIELDS_PER_SCANNER.get(scanner): if field not in settings.HASHCODE_ALLOWED_FIELDS: deduplicationLogger.error(f"Configuration e...
code_fim
medium
{ "lang": "python", "repo": "Parthi10/django-DefectDojo", "path": "/dojo/management/commands/validatededupeconfig.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: nansencenter/DAPPER path: /dapper/mods/Lorenz96/sakov2008.py """Settings as in `bib.sakov2008deterministic`. This HMM is used (with small variations) in many DA papers, for example `bib.bocquet2011ensemble`, `bib.sakov2012iterative`, `bib.bocquet2015expanding`, `bib.bocquet2013joint`. """ impo...
code_fim
hard
{ "lang": "python", "repo": "nansencenter/DAPPER", "path": "/dapper/mods/Lorenz96/sakov2008.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#################### # Suggested tuning #################### # Reproduce Table1 of sakov2008deterministic # Expected rmse.a: # -------------------------------------------------------------------------------- # xps += EnKF('PertObs' ,N=40, infl=1.06) # 0.22 # xps += EnKF('DEnKF...
code_fim
hard
{ "lang": "python", "repo": "nansencenter/DAPPER", "path": "/dapper/mods/Lorenz96/sakov2008.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>HMM.liveplotters = LPs(jj) #################### # Suggested tuning #################### # Reproduce Table1 of sakov2008deterministic # Expected rmse.a: # -------------------------------------------------------------------------------- # xps += EnKF('PertObs' ,N=40, infl=1.06) ...
code_fim
hard
{ "lang": "python", "repo": "nansencenter/DAPPER", "path": "/dapper/mods/Lorenz96/sakov2008.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Read config file into `c`. Variables in config file are formatted as `KEY=VALUE`. """ c = {} with open(filename, "r") as f: for line in f: key, val = line.split("=") key = key.strip() val = val.strip() c[key] = val re...
code_fim
medium
{ "lang": "python", "repo": "HDI-Project/FeatureHub", "path": "/deploy/deploy_util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: HDI-Project/FeatureHub path: /deploy/deploy_util.py import os def get_config(): # load config vars c = {} script_dir = os.path.dirname(__file__) c.update(_read_config(os.path.join(script_dir,".env"))) c.update(_read_config(os.path.join(script_dir,".env.local"))) return c...
code_fim
medium
{ "lang": "python", "repo": "HDI-Project/FeatureHub", "path": "/deploy/deploy_util.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> c = {} with open(filename, "r") as f: for line in f: key, val = line.split("=") key = key.strip() val = val.strip() c[key] = val return c<|fim_prefix|># repo: HDI-Project/FeatureHub path: /deploy/deploy_util.py import os def get_config(...
code_fim
medium
{ "lang": "python", "repo": "HDI-Project/FeatureHub", "path": "/deploy/deploy_util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> file_tokens = self.get_qa_file_tokens() errors = [] errors += get_trailing_comma_errors(file_tokens) errors += get_inline_comment_errors(file_tokens) # sort the errors by line numbers errors.sort(key=lambda x: x["line"]) for e in errors: ...
code_fim
hard
{ "lang": "python", "repo": "truveris/flake8-truveris", "path": "/flake8_truveris/check_truveris.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: truveris/flake8-truveris path: /flake8_truveris/check_truveris.py import tokenize try: from flake8.engine import pep8 stdin_get_value = pep8.stdin_get_value readlines = pep8.readlines except ImportError: from flake8 import utils import pycodestyle stdin_get_value = utils....
code_fim
hard
{ "lang": "python", "repo": "truveris/flake8-truveris", "path": "/flake8_truveris/check_truveris.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> errors += get_trailing_comma_errors(file_tokens) errors += get_inline_comment_errors(file_tokens) # sort the errors by line numbers errors.sort(key=lambda x: x["line"]) for e in errors: yield ( e["line"], e["col"], ...
code_fim
hard
{ "lang": "python", "repo": "truveris/flake8-truveris", "path": "/flake8_truveris/check_truveris.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Create a display object d = Display(BOARD_SIZE, BOARD_SIZE) # Read a chunk's worth of data data = sound.readframes(chunk_size) # While music is playing while(data != ''): # play music data_out.write(data) # Get the max, min, and average levels levels_max, levels_avg, levels_min = t...
code_fim
hard
{ "lang": "python", "repo": "SArehalli/SimpleLED", "path": "/demoItUp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: SArehalli/SimpleLED path: /demoItUp.py from display import Display import alsaaudio as aa import numpy as np from struct import unpack import wave import audioop BOARD_SIZE = 32 def normalize(data): """ limit the range of an array to be between 0 and BOARD_SIZE """ norm_matrix = np.int_...
code_fim
hard
{ "lang": "python", "repo": "SArehalli/SimpleLED", "path": "/demoItUp.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Read a chunk's worth of data data = sound.readframes(chunk_size) # While music is playing while(data != ''): # play music data_out.write(data) # Get the max, min, and average levels levels_max, levels_avg, levels_min = transform_to_levels(data, ...
code_fim
hard
{ "lang": "python", "repo": "SArehalli/SimpleLED", "path": "/demoItUp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> :param _links: :type _links: :class:`ReferenceLinks <release.v4_0.models.ReferenceLinks>` :param attempt: :type attempt: int :param conditions: :type conditions: list of :class:`Condition <release.v4_0.models.Condition>` :param definition_environment_id: :type definition_en...
code_fim
hard
{ "lang": "python", "repo": "kenkuo/azure-devops-python-api", "path": "/vsts/vsts/release/v4_0/models/deployment.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kenkuo/azure-devops-python-api path: /vsts/vsts/release/v4_0/models/deployment.py # -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the pro...
code_fim
hard
{ "lang": "python", "repo": "kenkuo/azure-devops-python-api", "path": "/vsts/vsts/release/v4_0/models/deployment.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Slava715/sova-tts-tps path: /tps/modules/ssml/elements.py import math from typing import Union class Text: _valid_prosody = ["pitch", "rate", "volume"] def __init__(self, text, pitch=1.0, rate=1.0, volume=1.0): self.value = text self.pitch = parse_pitch(pitch) ...
code_fim
hard
{ "lang": "python", "repo": "Slava715/sova-tts-tps", "path": "/tps/modules/ssml/elements.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def parse_volume(value: Union[str, int, float]) -> Union[int, float]: if isinstance(value, str): if value.endswith("dB"): factor = float(value.replace("dB", "")) # -6.0dB elif value in _volume_map: factor = _volume_map[value] else: raise Val...
code_fim
hard
{ "lang": "python", "repo": "Slava715/sova-tts-tps", "path": "/tps/modules/ssml/elements.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def parse_pitch(value: Union[str, float, int]) -> float: if isinstance(value, str): if value.endswith("%"): factor = float(value.replace("%", "")) # -15.2% factor = 1 + factor / 100 elif value.endswith("st"): factor = float(value.replace("st", "")) #...
code_fim
hard
{ "lang": "python", "repo": "Slava715/sova-tts-tps", "path": "/tps/modules/ssml/elements.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def get_labels(prms, setName='train'): grps = su.get_groups_all(prms, setName=setName) lbNums = [] for (i,l) in enumerate(prms.labelNames): if l == 'nrml': lbNums.append(6 * len(grps)) elif l == 'pose': lbNums.append(25 * len(grps)) elif l == 'ptch': lbInfo = prms.labels[i] num = i...
code_fim
hard
{ "lang": "python", "repo": "pulkitag/egomotion", "path": "/old_code/street_labels.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: pulkitag/egomotion path: /old_code/street_labels.py ## @package street_labels # Contains function for reading and parsing labels # #Self imports import street_params as sp import street_utils as su #Other imports import pickle import numpy as np from os import path as osp import my_pycaffe_io a...
code_fim
hard
{ "lang": "python", "repo": "pulkitag/egomotion", "path": "/old_code/street_labels.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def get_labels(prms, setName='train'): grps = su.get_groups_all(prms, setName=setName) lbNums = [] for (i,l) in enumerate(prms.labelNames): if l == 'nrml': lbNums.append(6 * len(grps)) elif l == 'pose': lbNums.append(25 * len(grps)) elif l == 'ptch': lbInfo = prms.labels[i] num = in...
code_fim
hard
{ "lang": "python", "repo": "pulkitag/egomotion", "path": "/old_code/street_labels.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # Plot kmeans groups by coded class fig, axs = plt.subplots(1, 2, figsize=(10, 8)) fig.suptitle(f'Subplots of KMeans Group Distribution Within Assigned Classes: {name.upper()}') user_class = user_df['class'].tolist() user_class.sort() for i, cl in enumerate...
code_fim
hard
{ "lang": "python", "repo": "sarahmk125/twitter-analyzer", "path": "/app/lib/embedding_analysis_plotter.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> print(f'[EmbeddingAnalysisPlotter] Visualizing MDS on users for {name}...') self._plot_mds(mds_array, name, user_list, True) print(f'[EmbeddingAnalysisPlotter] Visualizing KMeans on users for {name}...') if type(kmeans_groups) != list: kmeans_groups = [kmeans_g...
code_fim
hard
{ "lang": "python", "repo": "sarahmk125/twitter-analyzer", "path": "/app/lib/embedding_analysis_plotter.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: sarahmk125/twitter-analyzer path: /app/lib/embedding_analysis_plotter.py import matplotlib.pyplot as plt class EmbeddingAnalysisPlotter(object): def __init__(self): pass def _plot_mds(self, mds_array, name, labels=None, label_flag=False): # Plotting first 50 documents w...
code_fim
hard
{ "lang": "python", "repo": "sarahmk125/twitter-analyzer", "path": "/app/lib/embedding_analysis_plotter.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> opening_from = max([dt_begin, opening_from_tz]) opening_to = min([dt_end, opening_to_tz]) sponsor.is_in_opening_hours = opening_from <= now_tz < opening_to @api.depends('partner_id.country_id.image_url') def _compute_country_flag_url(self): ...
code_fim
hard
{ "lang": "python", "repo": "SHIVJITH/Odoo_Machine_Test", "path": "/addons/website_event_track_exhibitor/models/event_sponsor.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: SHIVJITH/Odoo_Machine_Test path: /addons/website_event_track_exhibitor/models/event_sponsor.py # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from datetime import datetime from pytz import timezone, utc from odoo import api, fields, models fro...
code_fim
hard
{ "lang": "python", "repo": "SHIVJITH/Odoo_Machine_Test", "path": "/addons/website_event_track_exhibitor/models/event_sponsor.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> joints = approach_grabing_pose #The empty joints array is stores the joint values of the appraoch_grabing_pose arm_move(move_group, joints) #The arm_move(move_group, joints) function will move the joints position time.sleep(3) #The COBOTTA will wait 5 seconds before moving on joints = grabin...
code_fim
hard
{ "lang": "python", "repo": "DENSO-2DLab/COBOTTA_OSS_MOVEIT_Samples", "path": "/Pick_and_Place_Electric_Gripper.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DENSO-2DLab/COBOTTA_OSS_MOVEIT_Samples path: /Pick_and_Place_Electric_Gripper.py #Pick and Place Simulation in Python #!/usr/bin/env python import os import sys import rospy import actionlib import math import moveit_commander import rosservice import geometry_msgs.msg from denso_cobotta_gripper....
code_fim
hard
{ "lang": "python", "repo": "DENSO-2DLab/COBOTTA_OSS_MOVEIT_Samples", "path": "/Pick_and_Place_Electric_Gripper.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> joints = approach_placing_pose #The empty joints array is stores the joint values of the appraoch_placing_pose arm_move(move_group, joints) #The arm_move(move_group, joints) function will move the joints position time.sleep(3) #The COBOTTA will wait 5 seconds before moving on joints = middle...
code_fim
hard
{ "lang": "python", "repo": "DENSO-2DLab/COBOTTA_OSS_MOVEIT_Samples", "path": "/Pick_and_Place_Electric_Gripper.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jakesant/dsa-assignment path: /q11.py #Write a function that computes cosine or sine by taking the first n terms of the appropriate series expansion #To evaluate the value of sin and cos, we can make use of MacLaurin's Theorem #f(x) = f(0) + f'(0)x+ f''(0)/2! x^2 + f'''0/3! x^3 ... def cos(n): ...
code_fim
hard
{ "lang": "python", "repo": "jakesant/dsa-assignment", "path": "/q11.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return result def fact(n): if (n == 0): return 1.0 else: return n * fact(n-1) print("%0.12f" %sin(2.68)) print("%0.12f" %sin(20)) print("%0.12f" %sin(90)) print("%0.12f" %cos(2.68)) print("%0.12f" %cos(20)) print("%0.12f" %cos(90))<|fim_prefix|># repo: jakesant/dsa-assignment...
code_fim
hard
{ "lang": "python", "repo": "jakesant/dsa-assignment", "path": "/q11.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rezaramadhan/GrafikaOpenGL path: /phone/phone.py from OpenGLContext import testingcontext BaseContext = testingcontext.getInteractive() from OpenGL.GL import * import time import numpy try: from PIL.Image import open, FLIP_TOP_BOTTOM except ImportError, err: from Image import open class...
code_fim
hard
{ "lang": "python", "repo": "rezaramadhan/GrafikaOpenGL", "path": "/phone/phone.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def Render( self, mode): """Render scene geometry""" BaseContext.Render( self, mode ) glDisable( GL_LIGHTING) # context lights by default glTranslatef(0,0.0,-3.0); glRotated( time.time()%(8.0)/8 * -360, 1,1,0) self.setupTexture() self.drawCube() ...
code_fim
hard
{ "lang": "python", "repo": "rezaramadhan/GrafikaOpenGL", "path": "/phone/phone.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> hive = 0 initial = sticks while True: #A hex pair has 11 sticks pairs = sticks // 11 #The remaining sticks sticks = sticks % 11 #If no pairs if pairs == 0: #With 4 sticks we have a new hex hive += sticks//4 ...
code_fim
medium
{ "lang": "python", "repo": "deepak1214/CompetitiveCode", "path": "/Misc/HiveMaker/solution_1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: deepak1214/CompetitiveCode path: /Misc/HiveMaker/solution_1.py # The idea is that except if we have less than 11 sticks where the solution is trivial # in every other case we create as much pairs of hexagons as possible. The addition of # two pairs provides the best solution and also return to us...
code_fim
hard
{ "lang": "python", "repo": "deepak1214/CompetitiveCode", "path": "/Misc/HiveMaker/solution_1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return [hive, initial-sticks, sticks] print(HiveMaker(7)) print(HiveMaker(19)) print(HiveMaker(23)) print(HiveMaker(54))<|fim_prefix|># repo: deepak1214/CompetitiveCode path: /Misc/HiveMaker/solution_1.py # The idea is that except if we have less than 11 sticks where the solution is trivial # in eve...
code_fim
hard
{ "lang": "python", "repo": "deepak1214/CompetitiveCode", "path": "/Misc/HiveMaker/solution_1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: retaincc/py-retain path: /tests/__init__.py import httpretty from sure import expect from retain import Retaincc @httpretty.activate def test_create_user(): httpretty.register_uri( httpretty.POST, "https://app.retain.cc/api/v1/users", body='{"user_id": 10}', content...
code_fim
hard
{ "lang": "python", "repo": "retaincc/py-retain", "path": "/tests/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@httpretty.activate def test_delete_user(): httpretty.register_uri( httpretty.DELETE, "https://app.retain.cc/api/v1/users?user_id=10", body='true', content_type="application/json") response = Retaincc.delete_user(user_id=10) expect(response).to.equal(True)<|fim_prefix|...
code_fim
hard
{ "lang": "python", "repo": "retaincc/py-retain", "path": "/tests/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: MzZak/Geretongers path: /__scan_bug_untuk_internet_gratis__.py ############################ # Coder : Mr.Tr3v!0n # # Di Buat : 7-5-2018. # # Team : Black Coder Crush # # Slam Anak Bangsa. # ############################ import marshal exec(marshal.loads('''c\x00\x00\x00\x00\x00\x...
code_fim
hard
{ "lang": "python", "repo": "MzZak/Geretongers", "path": "/__scan_bug_untuk_internet_gratis__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>1m[\x1b[32;1m+\x1b[39;1m] \x1b[39;1mMasukan Bug\x1b[31;1m: \x1b[39;1mi\x01\x00\x00\x00(\x11\x00\x00\x00t\x03\x00\x00\x00syst\x04\x00\x00\x00timeR\x04\x00\x00\x00t\x08\x00\x00\x00platformR\x00\x00\x00\x00R\x05\x00\x00\x00t\x01\x00\x00\x00rt\x01\x00\x00\x00gt\x01\x00\x00\x00yR\x06\x00\x00\x00t\x01\x00\x00\x...
code_fim
hard
{ "lang": "python", "repo": "MzZak/Geretongers", "path": "/__scan_bug_untuk_internet_gratis__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>a)) plt.savefig('./tmp/base/{0:5s},{1:5d}.png'.format(a,j), dpi=100) plt.close() for i in range(16): plt.subplot(4,4,i+1) plt.imshow(solver.net.blobs['conv1'].data[0,i,:,:]) plt.axis('off') plt.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9,hspace=0, wspace=0.05) a="conv1" ...
code_fim
hard
{ "lang": "python", "repo": "wujiyang/FaceDataSetTools", "path": "/show_feature_map_during_training.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: wujiyang/FaceDataSetTools path: /show_feature_map_during_training.py import caffe import numpy as np import matplotlib.pyplot as plt caffe.set_device(1) caffe.set_mode_gpu() solver = caffe.SGDSolver('./gait.prototxt') #solver.net.copy_from('kenel256_att_iter_2000.caffemodel') for j in range(150...
code_fim
hard
{ "lang": "python", "repo": "wujiyang/FaceDataSetTools", "path": "/show_feature_map_during_training.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: phiradet/torchtext-th path: /torchtext_th/utils.py import os import math from glob import glob from collections import defaultdict from typing import List, Optional, Dict, Any, Iterator import torch import numpy as np def generate_best_dataset_index(corpus_dir: str, ...
code_fim
hard
{ "lang": "python", "repo": "phiradet/torchtext-th", "path": "/torchtext_th/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def get_params(model: torch.nn.Module, requires_grad: Optional[bool] = None): return [p for p in model.parameters() if requires_grad is None or p.requires_grad == requires_grad] def get_summary_writer(log_dir: Optional[str] = None): try: import os import pytz ...
code_fim
hard
{ "lang": "python", "repo": "phiradet/torchtext-th", "path": "/torchtext_th/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rene84/cfn-python-lint path: /src/cfnlint/rules/templates/ApproachingLimitDescription.py """ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0 """ from cfnlint.rules import CloudFormationLintRule from cfnlint.rules import RuleMatch from cfnlint.help...
code_fim
medium
{ "lang": "python", "repo": "rene84/cfn-python-lint", "path": "/src/cfnlint/rules/templates/ApproachingLimitDescription.py", "mode": "psm", "license": "MIT-0", "source": "the-stack-v2" }
<|fim_suffix|> """Basic Matching""" matches = [] description = cfn.template.get('Description', '') if LIMITS['threshold'] * LIMITS['template']['description'] < len(description) <= LIMITS['template']['description']: message = 'The template description ({0} bytes) is approaching...
code_fim
hard
{ "lang": "python", "repo": "rene84/cfn-python-lint", "path": "/src/cfnlint/rules/templates/ApproachingLimitDescription.py", "mode": "spm", "license": "MIT-0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ArtyomMoiseev/ButtonsUrfuProject path: /src/tg.py # -*- coding: utf-8 -*- import os import time import tgdraws import rrdtool import buttonsrrd import telebot from telebot import types rrd_path = "weather.rrd" bot = telebot.TeleBot("") @bot.message_handler(commands=['start', 'help']) def send_...
code_fim
hard
{ "lang": "python", "repo": "ArtyomMoiseev/ButtonsUrfuProject", "path": "/src/tg.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> markup = types.ReplyKeyboardMarkup(row_width=1) itembtn1 = types.KeyboardButton('Экспорт базы данных') itembtn2 = types.KeyboardButton('⭐ Умный экспорт') itembtn3 = types.KeyboardButton('Назад') markup.add(itembtn1,itembtn2,itembtn3) bot.send_message(message.from_user.id, "Выберите...
code_fim
hard
{ "lang": "python", "repo": "ArtyomMoiseev/ButtonsUrfuProject", "path": "/src/tg.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@bot.message_handler(regexp="Погода за сегодня") def handle_message(message): graph_temp = open("day_graph_temp",'rb') graph_hum = open("day_graph_hum",'rb') graph_pressure = open("day_graph_pressure",'rb') bot.send_photo(message.from_user.id, graph_temp) bot.send_photo(message.from_us...
code_fim
hard
{ "lang": "python", "repo": "ArtyomMoiseev/ButtonsUrfuProject", "path": "/src/tg.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: S3Infosoft/mvr-insights path: /app/activities/tasks.py from . import utils from schedules.models import Schedule from django.core.mail import EmailMessage from background_task import background from datetime import datetime import json import requests @background(schedule=1) def get_ota_dat...
code_fim
hard
{ "lang": "python", "repo": "S3Infosoft/mvr-insights", "path": "/app/activities/tasks.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@background(schedule=1) def email_report(subject, message, sender, recipient, s_day, s_month, s_year, e_day, e_month, e_year, model): start_date = datetime(year=s_year, month=s_month, day=s_day).date() end_date = datetime(year=e_year, month=e_month, day=e_day).date() email =...
code_fim
hard
{ "lang": "python", "repo": "S3Infosoft/mvr-insights", "path": "/app/activities/tasks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Data PreProc app. Args: image: Image to use entrypoint: User script to launch output_path: Url-like path to save the processes compressed images input_path: Url-like path to fetch the imagenet dataset input_md5: Hash of the input imagenet dataset file ...
code_fim
hard
{ "lang": "python", "repo": "bowangbj/torchx", "path": "/examples/apps/datapreproc/component.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: bowangbj/torchx path: /examples/apps/datapreproc/component.py #!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ D...
code_fim
medium
{ "lang": "python", "repo": "bowangbj/torchx", "path": "/examples/apps/datapreproc/component.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.root = None def traverse_breadth_first(self, fn): """Traverse the tree breadth first, executing the specified function on each node.""" queue = deque([self.root]) while len(queue) > 0: node = queue.popleft() fn(node) queue.exte...
code_fim
medium
{ "lang": "python", "repo": "danielhgasparin/algorithms-python", "path": "/algorithms/tree.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: danielhgasparin/algorithms-python path: /algorithms/tree.py """Tree module.""" from collections import deque class Node: """Node of a tree.""" def __init__(self, value): self.value = value self.children = [] <|fim_suffix|> def remove(self, value): """Remove...
code_fim
medium
{ "lang": "python", "repo": "danielhgasparin/algorithms-python", "path": "/algorithms/tree.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: blogsley/blogsley-flask path: /server/blogsley_flask/jwt.py import jwt import json import datetime from loguru import logger from __blogsley__ import app from blogsley_flask.user import User <|fim_suffix|> for key, value in kwargs.items(): payload[key] = value return jwt.encode(...
code_fim
medium
{ "lang": "python", "repo": "blogsley/blogsley-flask", "path": "/server/blogsley_flask/jwt.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> token = decode_auth_token(info.context) logger.debug(f"token: {token}") return User.query.get(token['id']) def decode_auth_token(request): auth_token = request.headers.get('Authorization') if not auth_token or auth_token == 'null': return None logger.debug(f"auth_token: {a...
code_fim
medium
{ "lang": "python", "repo": "blogsley/blogsley-flask", "path": "/server/blogsley_flask/jwt.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> validate(instance=input_config, schema=schema)<|fim_prefix|># repo: cszelesbbs/servicecatalogenabler2 path: /test_validate_input_file.py import json import yaml from jsonschema import validate import os <|fim_middle|>configuration_file = os.environ['SC_ENABLER_CONF'] with open(configuration_file, '...
code_fim
hard
{ "lang": "python", "repo": "cszelesbbs/servicecatalogenabler2", "path": "/test_validate_input_file.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_input_params(): validate(instance=input_config, schema=schema)<|fim_prefix|># repo: cszelesbbs/servicecatalogenabler2 path: /test_validate_input_file.py import json import yaml from jsonschema import validate import os configuration_file = os.environ['SC_ENABLER_CONF'] <|fim_middle|>with ...
code_fim
medium
{ "lang": "python", "repo": "cszelesbbs/servicecatalogenabler2", "path": "/test_validate_input_file.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: cszelesbbs/servicecatalogenabler2 path: /test_validate_input_file.py import json import yaml from jsonschema import validate import os <|fim_suffix|>def test_input_params(): validate(instance=input_config, schema=schema)<|fim_middle|>configuration_file = os.environ['SC_ENABLER_CONF'] with o...
code_fim
hard
{ "lang": "python", "repo": "cszelesbbs/servicecatalogenabler2", "path": "/test_validate_input_file.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jcoffi/FuturesAndOptionsTradingSimulation path: /scripts/downloadCmeSettlementFiles.py #!/usr/bin/python import os import urllib3 from urllib3 import PoolManager from urllib.parse import urlparse from ftplib import FTP import shutil from datetime import date #DEFINE SUPPORTING FUNCTIONS def get...
code_fim
hard
{ "lang": "python", "repo": "jcoffi/FuturesAndOptionsTradingSimulation", "path": "/scripts/downloadCmeSettlementFiles.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#RENAME TEMP DIRECTORY BASED ON FIRST DATA FILE url = url_list[0].strip().split(',')[0] file_name = temp_dir + '/' + url.split('/')[-1] newPath = '../settlement_data_files/' + getDateFromFirstLineOfDataFile_YYYYMMDD(file_name) if os.path.exists(newPath): shutil.rmtree(newPath) os.rename(temp_dir,newPath)<...
code_fim
hard
{ "lang": "python", "repo": "jcoffi/FuturesAndOptionsTradingSimulation", "path": "/scripts/downloadCmeSettlementFiles.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }