uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
902cf02a5211c7de693d7e3d | train | class | class RawTransactionsTest(BitcoinTestFramework):
def __init__(self):
super().__init__()
self.setup_clean_chain = True
self.num_nodes = 3
def setup_network(self, split=False):
super().setup_network()
connect_nodes_bi(self.nodes,0,2)
def run_test(self):
#pre... | class RawTransactionsTest(BitcoinTestFramework):
| def __init__(self):
super().__init__()
self.setup_clean_chain = True
self.num_nodes = 3
def setup_network(self, split=False):
super().setup_network()
connect_nodes_bi(self.nodes,0,2)
def run_test(self):
#prepare some coins for multiple *rawtransaction comma... | #!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Copyright (c) Flo Developers 2013-2018
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the rawtranscation RPCs.
Test the following RPCs:
- c... | 149 | 256 | 2,850 | 9 | 140 | blockledgerltd/SKBL | test/functional/rawtransactions.py | Python | RawTransactionsTest | RawTransactionsTest | 20 | 224 | 20 | 21 | 43fa7c86391cdea2805df6c256548e93a8309d0b | bigcode/the-stack | train |
a9a1cd96c60bca273350110b | train | function | def split(args):
if args.output is None:
args.output = args.input.rsplit('.fastq', 1)[0]
forward_barcodes_ = [(hdr, seq.lower(), get_seeds(seq.lower(), args.seed_size))
for hdr, seq in FastaEntryIterator(args.barcodes)]
reverse_barcodes_ = [(hdr, reverse_complement(seq.lowe... | def split(args):
| if args.output is None:
args.output = args.input.rsplit('.fastq', 1)[0]
forward_barcodes_ = [(hdr, seq.lower(), get_seeds(seq.lower(), args.seed_size))
for hdr, seq in FastaEntryIterator(args.barcodes)]
reverse_barcodes_ = [(hdr, reverse_complement(seq.lower()), get_seeds(r... | import multiprocessing
import os
import sys
from collections import Counter
from lhc.io.fasta.fasta import FastaEntryIterator
from lhc.binf.sequence.reverse_complement import reverse_complement
from lhc.misc.string import hamming
from .iterator import FastqEntryIterator
def split(args):
| 64 | 64 | 204 | 4 | 59 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | split | split | 14 | 28 | 14 | 14 | 521c4ed86b9561b469ff3c4d32f41d23c5444f9d | bigcode/the-stack | train |
fa5f7b2d1d57cad3125eafde | train | function | def init_worker(forward_barcodes_, reverse_barcodes_, mismatch_=0):
global mismatch
global forward_barcodes
global reverse_barcodes
mismatch = mismatch_
forward_barcodes = forward_barcodes_
reverse_barcodes = reverse_barcodes_
| def init_worker(forward_barcodes_, reverse_barcodes_, mismatch_=0):
| global mismatch
global forward_barcodes
global reverse_barcodes
mismatch = mismatch_
forward_barcodes = forward_barcodes_
reverse_barcodes = reverse_barcodes_
| get_seeds(s, k):
return [s[i:i + k] for i in range(len(s) - k)]
mismatch = 0
forward_barcodes = None
reverse_barcodes = None
def init_worker(forward_barcodes_, reverse_barcodes_, mismatch_=0):
| 64 | 64 | 63 | 18 | 45 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | init_worker | init_worker | 83 | 90 | 83 | 83 | 3e30884b0ac600150f6e9d1b7625a0499e3fa40e | bigcode/the-stack | train |
b20042205ac3f85c8a21dd58 | train | function | def find_barcodes_paired(entries):
forward, reverse = entries
forward_hdrs = find_barcodes(forward, forward_barcodes)
reverse_hdrs = find_barcodes(reverse, reverse_barcodes)
return sorted(set(forward_hdrs + reverse_hdrs))
| def find_barcodes_paired(entries):
| forward, reverse = entries
forward_hdrs = find_barcodes(forward, forward_barcodes)
reverse_hdrs = find_barcodes(reverse, reverse_barcodes)
return sorted(set(forward_hdrs + reverse_hdrs))
| _
def find_barcodes_single(entry):
forward_hdrs = find_barcodes(entry, forward_barcodes)
reverse_hdrs = find_barcodes(entry, reverse_barcodes)
return sorted(set(forward_hdrs + reverse_hdrs))
def find_barcodes_paired(entries):
| 64 | 64 | 62 | 9 | 55 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | find_barcodes_paired | find_barcodes_paired | 99 | 103 | 99 | 99 | abdd180ccce824c96b2d485ffc6e42165b1a2f20 | bigcode/the-stack | train |
aba35f29d3d7618b05d4d905 | train | function | def split_paired(forward, reverse, pool, output, simultaneous_entries):
pool_iterator = zip(FastqEntryIterator(forward), FastqEntryIterator(reverse))
forward_iterator = FastqEntryIterator(forward)
reverse_iterator = FastqEntryIterator(reverse)
out_fhndls = {}
it = zip(pool.imap(find_barcodes_paired,... | def split_paired(forward, reverse, pool, output, simultaneous_entries):
| pool_iterator = zip(FastqEntryIterator(forward), FastqEntryIterator(reverse))
forward_iterator = FastqEntryIterator(forward)
reverse_iterator = FastqEntryIterator(reverse)
out_fhndls = {}
it = zip(pool.imap(find_barcodes_paired, pool_iterator, simultaneous_entries),
forward_i... | if hdr not in out_fhndls:
fname = '{}.fastq'.format(hdr)
out_fhndls[hdr] = open(os.path.join(output, fname), 'w')
out_fhndls[hdr].write(str(entry))
sys.exit(1)
for out_fhndl in out_fhndls.values():
out_fhndl.close()
def split_paired(forward, reverse, ... | 99 | 99 | 332 | 16 | 83 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | split_paired | split_paired | 46 | 72 | 46 | 46 | b9c2014e9e4a73458a54d9b3c83ba547d6459b7f | bigcode/the-stack | train |
bd30a7134f4b47a7ecc2cefa | train | function | def find_barcodes_single(entry):
forward_hdrs = find_barcodes(entry, forward_barcodes)
reverse_hdrs = find_barcodes(entry, reverse_barcodes)
return sorted(set(forward_hdrs + reverse_hdrs))
| def find_barcodes_single(entry):
| forward_hdrs = find_barcodes(entry, forward_barcodes)
reverse_hdrs = find_barcodes(entry, reverse_barcodes)
return sorted(set(forward_hdrs + reverse_hdrs))
| _, reverse_barcodes_, mismatch_=0):
global mismatch
global forward_barcodes
global reverse_barcodes
mismatch = mismatch_
forward_barcodes = forward_barcodes_
reverse_barcodes = reverse_barcodes_
def find_barcodes_single(entry):
| 63 | 64 | 53 | 8 | 55 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | find_barcodes_single | find_barcodes_single | 93 | 96 | 93 | 93 | f6049233104633dd102b2c84a71a871b22a92a6a | bigcode/the-stack | train |
035e8e51de0987eaf68f4545 | train | function | def split_single(reads, pool, output, simultaneous_entries):
pool_iterator = FastqEntryIterator(reads)
iterator = FastqEntryIterator(reads)
out_fhndls = {}
for hdrs, entry in zip(pool.imap(find_barcodes_single, pool_iterator, simultaneous_entries), iterator):
for hdr in hdrs:
if hdr ... | def split_single(reads, pool, output, simultaneous_entries):
| pool_iterator = FastqEntryIterator(reads)
iterator = FastqEntryIterator(reads)
out_fhndls = {}
for hdrs, entry in zip(pool.imap(find_barcodes_single, pool_iterator, simultaneous_entries), iterator):
for hdr in hdrs:
if hdr not in out_fhndls:
fname = '{}.fastq'.format(... | hasattr(args, 'reverse_reads'):
split_paired(args.forward_reads, args.reverse_reads, pool, args.output, args.simultaneous_entries)
else:
split_single(args.forward_reads, pool, args.output, args.simultaneous_entries)
def split_single(reads, pool, output, simultaneous_entries):
| 64 | 64 | 158 | 13 | 51 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | split_single | split_single | 31 | 43 | 31 | 31 | 66ec720daa709af0db080ca7e8cfe21845db0369 | bigcode/the-stack | train |
0b878435507840946d06a130 | train | function | def define_parser(parser):
add_arg = parser.add_argument
add_arg('forward_reads',
help='Fastq containing forward reads.')
add_arg('reverse_reads', nargs='?',
help='Fastq containing reverse reads (optional).')
add_arg('barcodes',
help='Fasta file of barcode sequences')... | def define_parser(parser):
| add_arg = parser.add_argument
add_arg('forward_reads',
help='Fastq containing forward reads.')
add_arg('reverse_reads', nargs='?',
help='Fastq containing reverse reads (optional).')
add_arg('barcodes',
help='Fasta file of barcode sequences')
add_arg('-c', '--cpus'... | (barcode)], barcode)
if d <= mismatch:
hdrs.append(hdr)
except ValueError:
pass
return hdrs
def main():
args = get_parser().parse_args()
args.func(args)
def get_parser():
return define_parser(argparse.ArgumentParser())
def define_pars... | 67 | 67 | 226 | 5 | 62 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | define_parser | define_parser | 136 | 155 | 136 | 136 | 5bb7031a1e42c2ba19144e15725508a30d95f5f3 | bigcode/the-stack | train |
4f9739d0c56994f69a610d14 | train | function | def get_parser():
return define_parser(argparse.ArgumentParser())
| def get_parser():
| return define_parser(argparse.ArgumentParser())
| amming(template[idx - i:idx - i + len(barcode)], barcode)
if d <= mismatch:
hdrs.append(hdr)
except ValueError:
pass
return hdrs
def main():
args = get_parser().parse_args()
args.func(args)
def get_parser():
| 64 | 64 | 13 | 4 | 60 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | get_parser | get_parser | 132 | 133 | 132 | 132 | 02674f553b1690ab21e168fc246a1cbb3307d1d7 | bigcode/the-stack | train |
7ffa3f2fb00463f26ee416b3 | train | function | def main():
args = get_parser().parse_args()
args.func(args)
| def main():
| args = get_parser().parse_args()
args.func(args)
| enumerate(seeds):
try:
idx = template.index(seed)
d = hamming(template[idx - i:idx - i + len(barcode)], barcode)
if d <= mismatch:
hdrs.append(hdr)
except ValueError:
pass
return hdrs
def main():
| 64 | 64 | 17 | 3 | 60 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | main | main | 127 | 129 | 127 | 127 | aca10ad4393fbf0f753b328fcb922324966f46ef | bigcode/the-stack | train |
dd560706c646d93e5b54329a | train | function | def get_seeds(s, k):
return [s[i:i + k] for i in range(len(s) - k)]
| def get_seeds(s, k):
| return [s[i:i + k] for i in range(len(s) - k)]
| ndls.values():
out_fhndl[0].close()
out_fhndl[1].close()
for n_barcodes, n_reads in cnt.items():
print('{} reads had {} barcodes'.format(n_reads, n_barcodes))
def get_seeds(s, k):
| 63 | 64 | 27 | 8 | 55 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | get_seeds | get_seeds | 75 | 76 | 75 | 75 | bd5f9a24e504fb05d8b25e1f4c70933931dc840a | bigcode/the-stack | train |
92b8e36ec0f820583beb8289 | train | function | def find_barcodes(entry, barcodes):
template = entry.seq.lower()
## String find
if mismatch == 0:
return [hdr for hdr, barcode, seeds in barcodes if template.find(barcode) >= 0]
## Hamming with seed
hdrs = []
for hdr, barcode, seeds in barcodes:
for i, seed in enumerate(seeds):... | def find_barcodes(entry, barcodes):
| template = entry.seq.lower()
## String find
if mismatch == 0:
return [hdr for hdr, barcode, seeds in barcodes if template.find(barcode) >= 0]
## Hamming with seed
hdrs = []
for hdr, barcode, seeds in barcodes:
for i, seed in enumerate(seeds):
try:
id... | ):
forward, reverse = entries
forward_hdrs = find_barcodes(forward, forward_barcodes)
reverse_hdrs = find_barcodes(reverse, reverse_barcodes)
return sorted(set(forward_hdrs + reverse_hdrs))
def find_barcodes(entry, barcodes):
| 64 | 64 | 142 | 10 | 54 | EnjoyLifeFund/macHighSierra-py36-pkgs | lhc/io/fastq/split.py | Python | find_barcodes | find_barcodes | 106 | 124 | 106 | 106 | c6ba97830579c5965a6e3a7a74d0003ffaca19d3 | bigcode/the-stack | train |
dc715bbe8e3ad2de0ec26983 | train | class | class DisableWalletTest (BitcoinTestFramework):
def __init__(self):
super().__init__()
self.setup_clean_chain = True
self.num_nodes = 1
self.extra_args = [["-disablewallet"]]
def run_test (self):
# Make sure wallet is really disabled
assert_raises_jsonrpc(-32601... | class DisableWalletTest (BitcoinTestFramework):
| def __init__(self):
super().__init__()
self.setup_clean_chain = True
self.num_nodes = 1
self.extra_args = [["-disablewallet"]]
def run_test (self):
# Make sure wallet is really disabled
assert_raises_jsonrpc(-32601, 'Method not found', self.nodes[0].getwalletinfo... | MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test a node with the -disablewallet option.
- Test that validateaddress RPC works when running with -disablewallet
- Test that it is not possible to mine to an invalid address.
"""
from test_framework.... | 88 | 88 | 294 | 9 | 79 | aixinwang/atc | test/functional/disablewallet.py | Python | DisableWalletTest | DisableWalletTest | 15 | 34 | 15 | 16 | 95a5c4ab947c64e6b759189a5c937cc30afe7fdd | bigcode/the-stack | train |
830f0b7757e64b01f1f8247d | train | class | class Attention(nn.Module):
"""
Compute 'Scaled Dot Product Attention
"""
def forward(self, query, key, value, mask=None, dropout=None):
scores = torch.matmul(query, key.transpose(-2, -1)) \
/ math.sqrt(query.size(-1))
if mask is not None:
scores = ... | class Attention(nn.Module):
| """
Compute 'Scaled Dot Product Attention
"""
def forward(self, query, key, value, mask=None, dropout=None):
scores = torch.matmul(query, key.transpose(-2, -1)) \
/ math.sqrt(query.size(-1))
if mask is not None:
scores = scores.masked_fill(mask == 0... | import torch.nn as nn
import torch.nn.functional as F
import torch
import math
class Attention(nn.Module):
| 24 | 64 | 131 | 5 | 18 | Annelise2019/DeepLearning_Project | model/attention/single.py | Python | Attention | Attention | 7 | 23 | 7 | 7 | a4ea25385cc0063b6b54f184017bc4a2055f8f84 | bigcode/the-stack | train |
7cd50531e8d374266b27b5b4 | train | function | def readme():
"""Returns the contents of the README without the header image."""
header = '======\nGimbal\n======\n'
with open('README.rst', 'r') as f:
f.readline()
return header + f.read()
| def readme():
| """Returns the contents of the README without the header image."""
header = '======\nGimbal\n======\n'
with open('README.rst', 'r') as f:
f.readline()
return header + f.read()
| """
Setup script for the Gimbal package
"""
from setuptools import setup
from setuptools import find_packages
def readme():
| 25 | 64 | 56 | 4 | 20 | ryjmacdonell/geomtools | setup.py | Python | readme | readme | 8 | 13 | 8 | 8 | 995bead12bf75f10bc263b4f7b1fc7ad7acbb197 | bigcode/the-stack | train |
b002d7609820eeb3f2e194c9 | train | function | def requirements():
"""Returns the requirement list."""
with open('requirements.txt', 'r') as f:
return [line.strip() for line in f.readlines()]
| def requirements():
| """Returns the requirement list."""
with open('requirements.txt', 'r') as f:
return [line.strip() for line in f.readlines()]
| setuptools import find_packages
def readme():
"""Returns the contents of the README without the header image."""
header = '======\nGimbal\n======\n'
with open('README.rst', 'r') as f:
f.readline()
return header + f.read()
def requirements():
| 64 | 64 | 35 | 3 | 61 | ryjmacdonell/geomtools | setup.py | Python | requirements | requirements | 16 | 19 | 16 | 16 | 7728c32bd619d4f8822acff97cbecc689a0f6d06 | bigcode/the-stack | train |
c9631727a13065b669d9f24c | train | class | class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Country',
fields=[
('iso_3166_1_a2', models.CharField(verbose_name='ISO 3166-1 alpha-2',... | class Migration(migrations.Migration):
| dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Country',
fields=[
('iso_3166_1_a2', models.CharField(verbose_name='ISO 3166-1 alpha-2', primary_key=True, serialize=False, max_... | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import oscar.models.fields
from django.conf import settings
class Migration(migrations.Migration):
| 43 | 256 | 881 | 7 | 35 | nosrevi/django-oscar | oscar/apps/address/migrations/0001_initial.py | Python | Migration | Migration | 9 | 71 | 9 | 10 | cac73594b1ce4a31467c6acb98cfa6dd8bb6708f | bigcode/the-stack | train |
19efad115176c767fc7edaf5 | train | function | def Main():
host = '127.0.0.1'
port = 5001
server = ('127.0.0.1',5000)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
message = input("-> ")
while message != 'q':
s.sendto(message.encode('utf-8'), server)
data, addr = s.recvfrom(1024)
dat... | def Main():
| host = '127.0.0.1'
port = 5001
server = ('127.0.0.1',5000)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
message = input("-> ")
while message != 'q':
s.sendto(message.encode('utf-8'), server)
data, addr = s.recvfrom(1024)
data = data.dec... | import socket
def Main():
| 6 | 64 | 131 | 3 | 2 | averyli290/Pygame-Splendor | socketTest/udpClient.py | Python | Main | Main | 3 | 19 | 3 | 3 | 41903305c393ddf79cd3612f6c103b1505c5bdbd | bigcode/the-stack | train |
6cb9cd8c51361ee5fd5179ff | train | function | def main():
if len(sys.argv) > 1:
args = parse_args()
try:
args.func(args)
except Exception as e:
logger.error(str(e))
sys.exit(1)
else:
logger.error('error: no arguments passed: use -h to help')
| def main():
| if len(sys.argv) > 1:
args = parse_args()
try:
args.func(args)
except Exception as e:
logger.error(str(e))
sys.exit(1)
else:
logger.error('error: no arguments passed: use -h to help')
| deb package')
parser_build.add_argument('-f', '--file', help='Yaml config file path', default='config.yaml')
parser_build.add_argument('-r', '--revision', help='Revision package', default='1')
parser_build.set_defaults(func=build)
return parser.parse_args()
def main():
| 64 | 64 | 64 | 3 | 61 | Frodox/Nginx-builder | main.py | Python | main | main | 93 | 102 | 93 | 93 | 616b4a3dec12466a2c84ef9323dc6acecbc21005 | bigcode/the-stack | train |
4842e5acb89534dc829d77a1 | train | function | def build_rpm(config, revision):
"""
Сборка rpm пакета
:param config:
:param revision:
:return:
"""
downloader.download_package_scripts_rpm()
downloader.download_source_rpm(config["nginx_version"])
downloaded_modules = downloader.download_modules(config["modules"])
downloader.dow... | def build_rpm(config, revision):
| """
Сборка rpm пакета
:param config:
:param revision:
:return:
"""
downloader.download_package_scripts_rpm()
downloader.download_source_rpm(config["nginx_version"])
downloaded_modules = downloader.download_modules(config["modules"])
downloader.download_dependencies_rpm(config["mo... | modules"])
package_name = builder.build_deb(
config["nginx_version"],
src_archive_name,
downloaded_modules,
scripts_archive_name,
config["control"],
revision,
config['configure_params'],
patches
)
return package_name
def build_rpm(config, revi... | 64 | 64 | 111 | 8 | 55 | Frodox/Nginx-builder | main.py | Python | build_rpm | build_rpm | 58 | 76 | 58 | 58 | b93c6a6322f33c479afd621a27887e5841eed914 | bigcode/the-stack | train |
eacdf9d30e25961b2cc8afd1 | train | function | def parse_args():
"""
Парсинг передаваемых параметров запуска
:return parser.parse_args():
"""
parser = argparse.ArgumentParser(description="Nginx builder")
subparsers = parser.add_subparsers()
parser_build = subparsers.add_parser('build', help='build deb package')
parser_build.add_argum... | def parse_args():
| """
Парсинг передаваемых параметров запуска
:return parser.parse_args():
"""
parser = argparse.ArgumentParser(description="Nginx builder")
subparsers = parser.add_subparsers()
parser_build = subparsers.add_parser('build', help='build deb package')
parser_build.add_argument('-f', '--file'... | inx_version"])
downloaded_modules = downloader.download_modules(config["modules"])
downloader.download_dependencies_rpm(config["modules"])
package_name = builder.build_rpm(
config["nginx_version"],
downloaded_modules,
revision,
config['configure_params']
)
return pac... | 64 | 64 | 126 | 4 | 59 | Frodox/Nginx-builder | main.py | Python | parse_args | parse_args | 79 | 90 | 79 | 79 | 0c31cb514d1b5a152b7b9e3333ee61424ff4d2e9 | bigcode/the-stack | train |
c49f591e05c39768d83a71a1 | train | function | def build(args):
"""
Обработчик команды build
:return:
"""
config = config_parser.parse_yaml(args.file)
package_name = None
if config["output_package"] == "deb":
package_name = build_deb(config, args.revision)
elif config["output_package"] == "rpm":
package_name = build_r... | def build(args):
| """
Обработчик команды build
:return:
"""
config = config_parser.parse_yaml(args.file)
package_name = None
if config["output_package"] == "deb":
package_name = build_deb(config, args.revision)
elif config["output_package"] == "rpm":
package_name = build_rpm(config, args.r... | argparse
import sys
from src import config_parser
from src import downloader
from src import builder
from src import publicator
import logging
logging.basicConfig(format='%(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger("builder")
def build(args):
| 64 | 64 | 111 | 4 | 60 | Frodox/Nginx-builder | main.py | Python | build | build | 15 | 29 | 15 | 15 | bf748b3a9a662cdf3a8d84c557798a3a6754d610 | bigcode/the-stack | train |
0626aa2fcc93b1f7c51e6a24 | train | function | def build_deb(config, revision):
"""
Сборка deb пакета
:param config:
:param revision:
:return:
"""
scripts_archive_name = downloader.download_package_scripts_deb(config["nginx_version"])
src_archive_name = downloader.download_source(config["nginx_version"])
downloaded_modules = down... | def build_deb(config, revision):
| """
Сборка deb пакета
:param config:
:param revision:
:return:
"""
scripts_archive_name = downloader.download_package_scripts_deb(config["nginx_version"])
src_archive_name = downloader.download_source(config["nginx_version"])
downloaded_modules = downloader.download_modules(config["m... | args.revision)
elif config["output_package"] == "rpm":
package_name = build_rpm(config, args.revision)
else:
logger.error("Output package type is not valid")
sys.exit(1)
publicator.public_local(package_name)
def build_deb(config, revision):
| 64 | 64 | 152 | 8 | 56 | Frodox/Nginx-builder | main.py | Python | build_deb | build_deb | 32 | 55 | 32 | 32 | 541ceb6b5551c2be92982fb372d3633cdd1370cd | bigcode/the-stack | train |
e0680ed96e041a379dc9b978 | train | function | @click.command()
@click.option("--detailed", "-d", show_default=True, is_flag=True, help="Show also AMI info.")
@click.option("--profile", "-p", help="AWS profile name. Use profiles in ~/.aws if not specified.")
@click.option("--region", "-r", default="ap-southeast-2", show_default=True, help="AWS Region. Use 'all' for... | @click.command()
@click.option("--detailed", "-d", show_default=True, is_flag=True, help="Show also AMI info.")
@click.option("--profile", "-p", help="AWS profile name. Use profiles in ~/.aws if not specified.")
@click.option("--region", "-r", default="ap-southeast-2", show_default=True, help="AWS Region. Use 'all' for... | Helper(detailed).start(profile, region, "emr", {})
| @click.command()
@click.option("--detailed", "-d", show_default=True, is_flag=True, help="Show also AMI info.")
@click.option("--profile", "-p", help="AWS profile name. Use profiles in ~/.aws if not specified.")
@click.option("--region", "-r", default="ap-southeast-2", show_default=True, help="AWS Region. Use 'all' for... | 94 | 64 | 109 | 94 | 0 | terratenney/aws-tools | EMR/list_emr.py | Python | main | main | 20 | 25 | 20 | 24 | ad4bb5975e6e880b4be35b8be49b4d6d65e62dcc | bigcode/the-stack | train |
f36570e48d2a3f6211cd4eae | train | class | class Helper(AwsApiHelper):
def __init__(self, detailed):
super().__init__()
self._detailed = detailed
def process_request(self, session, account_id, region, kwargs):
client = session.client("emr", region_name=region)
for item in self.paginate(client, "list_clusters", kwargs):
... | class Helper(AwsApiHelper):
| def __init__(self, detailed):
super().__init__()
self._detailed = detailed
def process_request(self, session, account_id, region, kwargs):
client = session.client("emr", region_name=region)
for item in self.paginate(client, "list_clusters", kwargs):
print(item)
| import logging
import click
from helper.aws import AwsApiHelper
logging.getLogger().setLevel(logging.DEBUG)
class Helper(AwsApiHelper):
| 30 | 64 | 77 | 7 | 23 | terratenney/aws-tools | EMR/list_emr.py | Python | Helper | Helper | 9 | 17 | 9 | 9 | bbea7380d2153c1241a2df759e3c9cc59a1ad63c | bigcode/the-stack | train |
1f466c322e036cca3f937939 | train | function | def register_mesos_root(_, __, value, ___):
register_path_detector(MesosPathDetector(root=value))
| def register_mesos_root(_, __, value, ___):
| register_path_detector(MesosPathDetector(root=value))
| LogOptions
from apache.aurora.executor.common.path_detector import MesosPathDetector
from apache.thermos.cli.common import register_path_detector
from apache.thermos.cli.main import register_commands, register_options
register_commands(app)
register_options(app)
def register_mesos_root(_, __, value, ___):
| 64 | 64 | 24 | 12 | 52 | brinick/aurora | src/main/python/apache/aurora/tools/thermos.py | Python | register_mesos_root | register_mesos_root | 28 | 29 | 28 | 28 | 68b310c3e4cbe594e27fb9edf6af1419836424ce | bigcode/the-stack | train |
d6034356b641dbfa64feb519 | train | function | def clock_stream(period, num_periods, name='clock_stream'):
clock_stream = Stream(name)
period_number = 0
def tick(period_number):
clock_stream.append(time.time())
period_number += 1
if period_number < num_periods:
scheduler.enter(period, 1, tick, (period_number,))
sc... | def clock_stream(period, num_periods, name='clock_stream'):
| clock_stream = Stream(name)
period_number = 0
def tick(period_number):
clock_stream.append(time.time())
period_number += 1
if period_number < num_periods:
scheduler.enter(period, 1, tick, (period_number,))
scheduler.enter(period, 1, tick, (period_number,))
return ... |
sys.path.append( path.dirname( path.dirname( path.abspath(__file__))))
from Stream import *
from example_element_single_in_single_out_stateless import *
import sched
import time
scheduler = sched.scheduler(time.time, time.sleep)
def clock_stream(period, num_periods, name='clock_stream'):
| 64 | 64 | 90 | 14 | 50 | AnomalyInc/StreamPy | StreamPy/TestExamplesListToStreams/ClockAgent.py | Python | clock_stream | clock_stream | 22 | 31 | 22 | 22 | 3f57293467e06e12d51479d118dcad25126e8f0e | bigcode/the-stack | train |
0fd805d8541b1e11306a4e4e | train | function | def main():
## print_stream(clock_stream(0.25, 2))
example()
scheduler.run()
| def main():
## print_stream(clock_stream(0.25, 2))
| example()
scheduler.run()
| tick, (period_number,))
scheduler.enter(period, 1, tick, (period_number,))
return clock_stream
def example():
x = clock_stream(0.25, 2)
print_stream(x)
def main():
## print_stream(clock_stream(0.25, 2))
| 63 | 64 | 24 | 17 | 46 | AnomalyInc/StreamPy | StreamPy/TestExamplesListToStreams/ClockAgent.py | Python | main | main | 37 | 40 | 37 | 38 | 70e92d8489fbadbf1069988c79a1076c03f8ac25 | bigcode/the-stack | train |
3109b56134645e542f275b92 | train | function | def example():
x = clock_stream(0.25, 2)
print_stream(x)
| def example():
| x = clock_stream(0.25, 2)
print_stream(x)
| def tick(period_number):
clock_stream.append(time.time())
period_number += 1
if period_number < num_periods:
scheduler.enter(period, 1, tick, (period_number,))
scheduler.enter(period, 1, tick, (period_number,))
return clock_stream
def example():
| 64 | 64 | 21 | 3 | 60 | AnomalyInc/StreamPy | StreamPy/TestExamplesListToStreams/ClockAgent.py | Python | example | example | 33 | 35 | 33 | 33 | 9402d6b6f375836f9c316c071a94b75204243424 | bigcode/the-stack | train |
1620d8f3696689dc122e542a | train | function | def run():
factors = []
idx = 1
triangle_number = 0
while len(factors) < 500:
triangle_number = get_triangle_number(idx)
factors = get_factors(triangle_number, True)
idx += 1
return triangle_number
| def run():
| factors = []
idx = 1
triangle_number = 0
while len(factors) < 500:
triangle_number = get_triangle_number(idx)
factors = get_factors(triangle_number, True)
idx += 1
return triangle_number
| : 1,2,4,7,14,28
# We can see that 28 is the first triangle number to have over five divisors.
#
# What is the value of the first triangle number to have over five hundred divisors?
#
# Answer: 76576500
def run():
| 64 | 64 | 62 | 3 | 60 | tgetzoya/project-euler-python | problems/pe12.py | Python | run | run | 24 | 32 | 24 | 24 | 17bf7d617b29de3f68d36c0c5c6b272aa3d52f35 | bigcode/the-stack | train |
333ec09226ddb5fe726e5d1c | train | function | def fdr_threshold_norm_right(x, skip_percentile=99, fdr=0.1):
"""Get the outlier threshold (right-sided test)
by fitting a normal distribution to the core (skipping 1% of outliers)
estimating the p-value and using Benjamini-Hochberg FDR correction
Args:
x: np.array with values of interest
"""... | def fdr_threshold_norm_right(x, skip_percentile=99, fdr=0.1):
| """Get the outlier threshold (right-sided test)
by fitting a normal distribution to the core (skipping 1% of outliers)
estimating the p-value and using Benjamini-Hochberg FDR correction
Args:
x: np.array with values of interest
"""
from statsmodels.stats.multitest import fdrcorrection
... | import numpy as np
import pandas as pd
from scipy.stats import entropy
def fdr_threshold_norm_right(x, skip_percentile=99, fdr=0.1):
| 37 | 64 | 185 | 21 | 15 | mlweilert/bpnet | bpnet/stats.py | Python | fdr_threshold_norm_right | fdr_threshold_norm_right | 6 | 24 | 6 | 6 | aab433d7013240a01034b698de1404b36ffe5894 | bigcode/the-stack | train |
27d10903fbc48542f2053e40 | train | function | def permute_array(arr, axis=0):
"""Permute array along a certain axis
Args:
arr: numpy array
axis: axis along which to permute the array
"""
if axis == 0:
return np.random.permutation(arr)
else:
return np.random.permutation(arr.swapaxes(0, axis)).swapaxes(0, axis)
| def permute_array(arr, axis=0):
| """Permute array along a certain axis
Args:
arr: numpy array
axis: axis along which to permute the array
"""
if axis == 0:
return np.random.permutation(arr)
else:
return np.random.permutation(arr.swapaxes(0, axis)).swapaxes(0, axis)
| s.values[:, np.newaxis]
vals_by_row = tnc * np.ones_like(tnc).T
# np.fill_diagonal(vals_by_row, 1)
return pd.DataFrame(vals_by_row, index=s.index, columns=s.index)
def permute_array(arr, axis=0):
| 64 | 64 | 82 | 10 | 54 | mlweilert/bpnet | bpnet/stats.py | Python | permute_array | permute_array | 149 | 159 | 149 | 149 | 59a1fd989c0992b8651956fdde68548e3fc22b12 | bigcode/the-stack | train |
a2b5f833e6e5023bd74607eb | train | function | def ols_formula(df, dependent_var, *excluded_cols):
'''
Generates the R style formula for statsmodels (patsy) given
the dataframe, dependent variable and optional excluded columns
as strings
'''
df_columns = list(df.columns.values)
df_columns.remove(dependent_var)
for col in excluded_col... | def ols_formula(df, dependent_var, *excluded_cols):
| '''
Generates the R style formula for statsmodels (patsy) given
the dataframe, dependent variable and optional excluded columns
as strings
'''
df_columns = list(df.columns.values)
df_columns.remove(dependent_var)
for col in excluded_cols:
df_columns.remove(col)
return depende... | 50., 60., 70., 80., 90., 100.])
"""
from statsmodels.distributions.empirical_distribution import ECDF
return ECDF(x)(x) * 100
def ols_formula(df, dependent_var, *excluded_cols):
| 64 | 64 | 94 | 13 | 50 | mlweilert/bpnet | bpnet/stats.py | Python | ols_formula | ols_formula | 79 | 89 | 79 | 79 | 2c66f5788ac0b3355ad6c0dd08ab9752b5bef232 | bigcode/the-stack | train |
cd8ac477545afbb117a77328 | train | function | def tidy_ols(results):
smry = results.summary()
coef = smry.tables[1]
return pd.DataFrame(coef.data[1:], columns=coef.data[0])
| def tidy_ols(results):
| smry = results.summary()
coef = smry.tables[1]
return pd.DataFrame(coef.data[1:], columns=coef.data[0])
| variable and optional excluded columns
as strings
'''
df_columns = list(df.columns.values)
df_columns.remove(dependent_var)
for col in excluded_cols:
df_columns.remove(col)
return dependent_var + ' ~ ' + ' + '.join(df_columns)
def tidy_ols(results):
| 64 | 64 | 40 | 6 | 58 | mlweilert/bpnet | bpnet/stats.py | Python | tidy_ols | tidy_ols | 92 | 95 | 92 | 92 | 2940c45c4c5d6cbf019914425885fd2dba68185a | bigcode/the-stack | train |
64e7ca4fb791cd7d9ca81cd5 | train | function | def low_medium_high(p):
"""Stratify the vector of probabilities into
low, medium and high categories
"""
return pd.cut(p, [0, 0.33, 0.66, 1],
labels=['low', 'medium', 'high'],
include_lowest=True, right=True)
| def low_medium_high(p):
| """Stratify the vector of probabilities into
low, medium and high categories
"""
return pd.cut(p, [0, 0.33, 0.66, 1],
labels=['low', 'medium', 'high'],
include_lowest=True, right=True)
| )
# quantiles = np.sort(pd.Series(norm_x).quantile(np.arange(0, 1+step, step)).unique())
out = pd.cut(x,
quantiles,
labels=labels,
include_lowest=True, right=True)
return out
def low_medium_high(p):
| 64 | 64 | 69 | 6 | 57 | mlweilert/bpnet | bpnet/stats.py | Python | low_medium_high | low_medium_high | 59 | 65 | 59 | 59 | fc7cafca616c182d964678a52aaf6087f0dde742 | bigcode/the-stack | train |
a6eb1a7744903c3d7e33fe5c | train | function | def get_metric(metric):
from scipy.stats import entropy, wasserstein_distance
if isinstance(metric, str):
if metric == 'simmetric_kl':
metric = simmetric_kl
elif metric == 'symmetric_kl':
metric = symmetric_kl
elif metric == 'kl':
metric = entropy
... | def get_metric(metric):
| from scipy.stats import entropy, wasserstein_distance
if isinstance(metric, str):
if metric == 'simmetric_kl':
metric = simmetric_kl
elif metric == 'symmetric_kl':
metric = symmetric_kl
elif metric == 'kl':
metric = entropy
elif metric == 'was... | (ref, alt):
from scipy.stats import entropy
return (entropy(ref, alt) + entropy(alt, ref)) / 2
# Old typo
simmetric_kl = symmetric_kl
all_metrics = ['symmetric_kl', 'kl', 'wasserstein']
def get_metric(metric):
| 64 | 64 | 113 | 5 | 59 | mlweilert/bpnet | bpnet/stats.py | Python | get_metric | get_metric | 112 | 127 | 112 | 112 | 3f8e73c4920dda1516818fe552ac63cb6f99a897 | bigcode/the-stack | train |
a6617dfc7280311e229aa645 | train | function | def quantile_norm(x, norm_x, step=0.01):
"""Get the quantile values w.r.t. the other empirical distribution
Args:
x: values for which to compute the percentiles
norm_x: empirical distribution w.r.t. which to compute the percentiles
Returns:
pd.Series of the same length as x
"""
x... | def quantile_norm(x, norm_x, step=0.01):
| """Get the quantile values w.r.t. the other empirical distribution
Args:
x: values for which to compute the percentiles
norm_x: empirical distribution w.r.t. which to compute the percentiles
Returns:
pd.Series of the same length as x
"""
x = np.minimum(x, norm_x.max()) # truncat... | _percentile)
loc, scale = norm.fit(x[(x < upper)])
# p-values
p = norm.cdf(x, loc, scale)
keep, padj = fdrcorrection(1 - p, alpha=fdr)
return x[~keep].max()
def quantile_norm(x, norm_x, step=0.01):
| 75 | 75 | 251 | 15 | 60 | mlweilert/bpnet | bpnet/stats.py | Python | quantile_norm | quantile_norm | 27 | 56 | 27 | 27 | 6480fdbc61589f3e990359a2f92bc1001ac182a2 | bigcode/the-stack | train |
e9cc816e2d9d4be0e82394cb | train | function | def symmetric_kl(ref, alt):
from scipy.stats import entropy
return (entropy(ref, alt) + entropy(alt, ref)) / 2
| def symmetric_kl(ref, alt):
| from scipy.stats import entropy
return (entropy(ref, alt) + entropy(alt, ref)) / 2
| + ' ~ ' + ' + '.join(df_columns)
def tidy_ols(results):
smry = results.summary()
coef = smry.tables[1]
return pd.DataFrame(coef.data[1:], columns=coef.data[0])
# ----------------------------------------
def symmetric_kl(ref, alt):
| 63 | 64 | 34 | 8 | 55 | mlweilert/bpnet | bpnet/stats.py | Python | symmetric_kl | symmetric_kl | 100 | 102 | 100 | 100 | 72d04610d59b879afa5d2f3b811e6d0b978159cd | bigcode/the-stack | train |
927c0b3a8659a513f3025f58 | train | function | def norm_matrix(s):
"""Create the normalization matrix
Example:
print(norm_matrix(pd.Series([1,3,5])).to_string())
0 1 2
0 1 1 1
1 3 3 3
2 5 5 5
Args:
s: pandas series
"""
tnc = s.values[:, np.newaxis]
vals_by_row = tnc * np.ones_like(tnc).T
# np.fil... | def norm_matrix(s):
| """Create the normalization matrix
Example:
print(norm_matrix(pd.Series([1,3,5])).to_string())
0 1 2
0 1 1 1
1 3 3 3
2 5 5 5
Args:
s: pandas series
"""
tnc = s.values[:, np.newaxis]
vals_by_row = tnc * np.ones_like(tnc).T
# np.fill_diagonal(vals_by_r... | symmetric_kl
elif metric == 'kl':
metric = entropy
elif metric == 'wasserstein':
metric = wasserstein_distance
else:
# Get the metric as a string
raise NotImplemented(f"unknown metric: {metric}")
return metric
def norm_matrix(s):
| 64 | 64 | 149 | 5 | 58 | mlweilert/bpnet | bpnet/stats.py | Python | norm_matrix | norm_matrix | 130 | 146 | 130 | 130 | 1d50b42bf35562a83d81e50c2c93050cb57c586c | bigcode/the-stack | train |
ddf4a0d78a8598668d6cfc15 | train | function | def perc(x):
"""get the percentile values (ECDF * 100)
>>> perc(np.arange(10))
array([ 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.])
"""
from statsmodels.distributions.empirical_distribution import ECDF
return ECDF(x)(x) * 100
| def perc(x):
| """get the percentile values (ECDF * 100)
>>> perc(np.arange(10))
array([ 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.])
"""
from statsmodels.distributions.empirical_distribution import ECDF
return ECDF(x)(x) * 100
| atify the vector of probabilities into
low, medium and high categories
"""
return pd.cut(p, [0, 0.33, 0.66, 1],
labels=['low', 'medium', 'high'],
include_lowest=True, right=True)
def perc(x):
| 64 | 64 | 94 | 4 | 60 | mlweilert/bpnet | bpnet/stats.py | Python | perc | perc | 68 | 76 | 68 | 68 | 6c9a0155b7e5ecd02d155dd2a7054d318ea53376 | bigcode/the-stack | train |
c386cb62413801dc6bb8b406 | train | class | class Settings(object):
def __init__(self):
self.syntax = Setting("syntax")
self.scheme = Setting("color_scheme")
| class Settings(object):
| def __init__(self):
self.syntax = Setting("syntax")
self.scheme = Setting("color_scheme")
| import sublime
import sublime_plugin
import pydoc
from User.dejlib import Setting
class Settings(object):
| 24 | 64 | 27 | 4 | 19 | dejbug/pineapple-sublime | QuickTempSetSyntaxCommand.py | Python | Settings | Settings | 8 | 12 | 8 | 9 | 36faaf667e1e3ace5d888d9724b08d69909d6c2d | bigcode/the-stack | train |
081c06c11fc9afc9d1094417 | train | class | class QuickTempSetSyntaxCommand(sublime_plugin.TextCommand):
def run(self, edit, action="reset", syntax=None, scheme=None):
assert action in ("reset", "set", "toggle")
settings = Settings()
print(settings.syntax.get())
print(settings.scheme.get())
if action == "reset":
settings.syntax.reset... | class QuickTempSetSyntaxCommand(sublime_plugin.TextCommand):
| def run(self, edit, action="reset", syntax=None, scheme=None):
assert action in ("reset", "set", "toggle")
settings = Settings()
print(settings.syntax.get())
print(settings.scheme.get())
if action == "reset":
settings.syntax.reset()
settings.scheme.reset()
elif action == "set":
if... | import sublime
import sublime_plugin
import pydoc
from User.dejlib import Setting
class Settings(object):
def __init__(self):
self.syntax = Setting("syntax")
self.scheme = Setting("color_scheme")
class QuickTempSetSyntaxCommand(sublime_plugin.TextCommand):
| 60 | 64 | 159 | 13 | 47 | dejbug/pineapple-sublime | QuickTempSetSyntaxCommand.py | Python | QuickTempSetSyntaxCommand | QuickTempSetSyntaxCommand | 15 | 42 | 15 | 16 | 84fa83bb2a8661a03d1b054c1fde6a4f5a0dc89b | bigcode/the-stack | train |
cbdcb378362d1ce5aed0717f | train | function | def getNuitkaVersion():
"""Return Nuitka version as a string.
This should not be used for >= comparisons directly.
"""
return version_string.split()[1][1:]
| def getNuitkaVersion():
| """Return Nuitka version as a string.
This should not be used for >= comparisons directly.
"""
return version_string.split()[1][1:]
| See the License for the specific language governing permissions and
# limitations under the License.
#
""" Nuitka version related stuff.
"""
version_string = """\
Nuitka V0.6.14rc4
Copyright (C) 2021 Kay Hayen."""
def getNuitkaVersion():
| 63 | 64 | 40 | 7 | 56 | pkulev/Nuitka | nuitka/Version.py | Python | getNuitkaVersion | getNuitkaVersion | 27 | 32 | 27 | 27 | 4df0f0d3800170391f214c78f0e829035bdfabc7 | bigcode/the-stack | train |
f7483096fbc58080198d435c | train | function | def getNuitkaVersionYear():
""" The year of Nuitka copyright for use in generations. """
return int(version_string.split()[4])
| def getNuitkaVersionYear():
| """ The year of Nuitka copyright for use in generations. """
return int(version_string.split()[4])
| rc4
Copyright (C) 2021 Kay Hayen."""
def getNuitkaVersion():
"""Return Nuitka version as a string.
This should not be used for >= comparisons directly.
"""
return version_string.split()[1][1:]
def getNuitkaVersionYear():
| 63 | 64 | 31 | 8 | 55 | pkulev/Nuitka | nuitka/Version.py | Python | getNuitkaVersionYear | getNuitkaVersionYear | 35 | 38 | 35 | 35 | c0c883ce81108207927dbaa87d8d893ad9aea000 | bigcode/the-stack | train |
c247fc48a3b3bf7f38029ba7 | train | class | class DDDOrNumberIsNull(Exception):
pass
| class DDDOrNumberIsNull(Exception):
| pass
| class DDDOrNumberIsNull(Exception):
| 9 | 64 | 12 | 9 | 0 | bonetou/clean-architecture-python | src/domain/school/exceptions/phone.py | Python | DDDOrNumberIsNull | DDDOrNumberIsNull | 1 | 2 | 1 | 1 | 88d80f4e6fa8e45bdd933961fff2e2bfc907bb38 | bigcode/the-stack | train |
5672cd95bbd301b64ea0d086 | train | class | class DDDIsNotValid(Exception):
pass
| class DDDIsNotValid(Exception):
| pass
| class DDDOrNumberIsNull(Exception):
pass
class DDDIsNotValid(Exception):
| 20 | 64 | 11 | 8 | 11 | bonetou/clean-architecture-python | src/domain/school/exceptions/phone.py | Python | DDDIsNotValid | DDDIsNotValid | 5 | 6 | 5 | 5 | 8cd89f61c5381af6be9e11628f6bbfff02e04dca | bigcode/the-stack | train |
6416e7196844825b657e3585 | train | class | class NumberIsNotValid(Exception):
pass
| class NumberIsNotValid(Exception):
| pass
| class DDDOrNumberIsNull(Exception):
pass
class DDDIsNotValid(Exception):
pass
class NumberIsNotValid(Exception):
| 30 | 64 | 10 | 7 | 22 | bonetou/clean-architecture-python | src/domain/school/exceptions/phone.py | Python | NumberIsNotValid | NumberIsNotValid | 9 | 10 | 9 | 9 | 551cadf73416ad781652ae55eef01c87388fa7ad | bigcode/the-stack | train |
e4be75308d04d5a1d28d80d2 | train | class | class DistanceSensor(Device):
"""Distance sensor
:param port: Port of device
:raises DeviceError: Occurs if there is no distance sensor attached to port
"""
def __init__(self, port, threshold_distance=100):
"""
Initialise distance sensor
:param port: Port of device
... | class DistanceSensor(Device):
| """Distance sensor
:param port: Port of device
:raises DeviceError: Occurs if there is no distance sensor attached to port
"""
def __init__(self, port, threshold_distance=100):
"""
Initialise distance sensor
:param port: Port of device
:param threshold_distance: Op... | """Distance sensor handling functionality"""
from threading import Condition
from .devices import Device
from .exc import DistanceSensorError
class DistanceSensor(Device):
| 30 | 256 | 1,052 | 5 | 24 | mutesplash/python-build-hat | buildhat/distance.py | Python | DistanceSensor | DistanceSensor | 9 | 167 | 9 | 9 | cd152e517d6f95e2a58a731a456aade47f8d6d07 | bigcode/the-stack | train |
951c71657146daf239e1c5f1 | train | class | class BlockchainTest(AFCOTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
self.supports_cli = False
def run_test(self):
self.mine_chain()
self.restart_node(0, extra_args=['-stopatheight=207', '-prune=1']) # Set extra args with ... | class BlockchainTest(AFCOTestFramework):
| def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
self.supports_cli = False
def run_test(self):
self.mine_chain()
self.restart_node(0, extra_args=['-stopatheight=207', '-prune=1']) # Set extra args with pruning after rescan is complete
... | 4-2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test RPCs related to blockchainstate.
Test the following RPCs:
- getblockchaininfo
- gettxoutsetinfo
- getdifficulty
- getbestbl... | 256 | 256 | 3,681 | 8 | 248 | afco2021/afco_sourcecode | test/functional/rpc_blockchain.py | Python | BlockchainTest | BlockchainTest | 48 | 365 | 48 | 48 | 9aefb94bced283283e809fb144f54063a91fe0b8 | bigcode/the-stack | train |
aee710849b12fee1e2b250a7 | train | function | def get_user_company():
return g.user.company
| def get_user_company():
| return g.user.company
| from flask import g
from flask_appbuilder import ModelView
from flask_appbuilder.models.sqla.filters import FilterEqualFunction
from flask_appbuilder.models.sqla.interface import SQLAInterface
from . import appbuilder
from .models import Company, Contact, ContactGroup
def get_user_company():
| 63 | 64 | 11 | 5 | 57 | NeolithEra/Flask-AppBuilder | examples/extendsecurity/app/views.py | Python | get_user_company | get_user_company | 10 | 11 | 10 | 10 | 1c3bd82c5ea914843b6d9f3000e1f3ce4af4f536 | bigcode/the-stack | train |
ad7378bd25832e44f94311c4 | train | class | class GroupModelView(ModelView):
datamodel = SQLAInterface(ContactGroup)
related_views = [ContactModelView]
| class GroupModelView(ModelView):
| datamodel = SQLAInterface(ContactGroup)
related_views = [ContactModelView]
| _order = ("name", "asc")
base_filters = [["created_by.company", FilterEqualFunction, get_user_company]]
appbuilder.add_view(
ContactModelView, "List Contacts", icon="fa-envelope", category="Contacts"
)
appbuilder.add_separator("Contacts")
class GroupModelView(ModelView):
| 64 | 64 | 26 | 7 | 57 | NeolithEra/Flask-AppBuilder | examples/extendsecurity/app/views.py | Python | GroupModelView | GroupModelView | 51 | 53 | 51 | 51 | 3a245ccc2245c31019bab9a0f5e08774df52968b | bigcode/the-stack | train |
ef9cba3a8bbb8cba83e4ffbd | train | class | class ContactModelView(ModelView):
datamodel = SQLAInterface(Contact)
list_columns = [
"name",
"personal_celphone",
"birthday",
"contact_group.name",
"created_by.username",
]
add_columns = [
"name",
"address",
"birthday",
"personal_... | class ContactModelView(ModelView):
| datamodel = SQLAInterface(Contact)
list_columns = [
"name",
"personal_celphone",
"birthday",
"contact_group.name",
"created_by.username",
]
add_columns = [
"name",
"address",
"birthday",
"personal_phone",
"personal_celphone"... |
from flask_appbuilder.models.sqla.filters import FilterEqualFunction
from flask_appbuilder.models.sqla.interface import SQLAInterface
from . import appbuilder
from .models import Company, Contact, ContactGroup
def get_user_company():
return g.user.company
class ContactModelView(ModelView):
| 64 | 64 | 157 | 7 | 56 | NeolithEra/Flask-AppBuilder | examples/extendsecurity/app/views.py | Python | ContactModelView | ContactModelView | 14 | 42 | 14 | 14 | 4e3e6e913cd0bb44195a8d54bf6ad1a0658c2f10 | bigcode/the-stack | train |
66f655262bd301f782ad88ba | train | class | class CompanyModelView(ModelView):
datamodel = SQLAInterface(Company)
| class CompanyModelView(ModelView):
| datamodel = SQLAInterface(Company)
| View):
datamodel = SQLAInterface(ContactGroup)
related_views = [ContactModelView]
appbuilder.add_view(
GroupModelView,
"List Groups",
icon="fa-folder-open-o",
category="Contacts",
category_icon="fa-envelope",
)
class CompanyModelView(ModelView):
| 64 | 64 | 17 | 7 | 57 | NeolithEra/Flask-AppBuilder | examples/extendsecurity/app/views.py | Python | CompanyModelView | CompanyModelView | 65 | 66 | 65 | 65 | e070fb231e16a2ae7918b0f226e082118fb6bacf | bigcode/the-stack | train |
f2004ec871f448062de0f7dc | train | function | def lazy_import():
from pinecone.core.client.model.query_vector import QueryVector
globals()['QueryVector'] = QueryVector
| def lazy_import():
| from pinecone.core.client.model.query_vector import QueryVector
globals()['QueryVector'] = QueryVector
| cached_property,
change_keys_js_to_python,
convert_js_args_to_python_args,
date,
datetime,
file_type,
none_type,
validate_get_composed_info,
)
from ..model_utils import OpenApiModel
from pinecone.core.client.exceptions import ApiAttributeError
def lazy_import():
| 64 | 64 | 27 | 4 | 59 | amourao/pinecone-python-client | pinecone/core/client/model/query_request.py | Python | lazy_import | lazy_import | 37 | 39 | 37 | 37 | 932bef9d6774f129c2c977110143140b11756920 | bigcode/the-stack | train |
f4035fa5e4d049c6fbf4447d | train | class | class QueryRequest(ModelNormal):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
Attributes:
allowed_values (dict): The key is the tuple path to the attribute
and the for var_name this is (var_name,). The v... | class QueryRequest(ModelNormal):
| """NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
Attributes:
allowed_values (dict): The key is the tuple path to the attribute
and the for var_name this is (var_name,). The value is a dict
with a c... | #
# Copyright (c) 2020-2021 Pinecone Systems Inc. All right reserved.
#
"""
Pinecone API
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: version not set
Contact: support@pinecone.io
Gener... | 236 | 256 | 2,464 | 6 | 229 | amourao/pinecone-python-client | pinecone/core/client/model/query_request.py | Python | QueryRequest | QueryRequest | 42 | 300 | 42 | 42 | f164c4422c64444dda5a2ba56f65485ed3a9aaac | bigcode/the-stack | train |
fd01e2e53201215acd770a37 | train | class | class ModelList(MutableSequence):
"""
Implements the "models" attribute of a model group.
It offers a list-like interface to the models included in a ModelGroup.
"""
__slots__ = ("_data", "_group")
group: "ModelGroup" = property(lambda self: self._group())
_data: list
def __init__(se... | class ModelList(MutableSequence):
| """
Implements the "models" attribute of a model group.
It offers a list-like interface to the models included in a ModelGroup.
"""
__slots__ = ("_data", "_group")
group: "ModelGroup" = property(lambda self: self._group())
_data: list
def __init__(self, group: "ModelGroup", data: lis... | from collections import MutableSequence
from typing import TYPE_CHECKING
from weakref import ref
if TYPE_CHECKING:
from .model_group import ModelGroup
class ModelList(MutableSequence):
| 40 | 120 | 402 | 7 | 32 | PyDemic/pydemic | pydemic/model_group/model_list.py | Python | ModelList | ModelList | 9 | 64 | 9 | 9 | 25a55297129ef8f0c8f1973626b5acd8f9a40942 | bigcode/the-stack | train |
e7a15aa13e7dbc22852b9c50 | train | class | class WiggleWriter(object):
def __init__(self, track_str, fh):
self._fh = fh
self._fh.write(("track type=wiggle_0 name=\"%s\"\n" % (track_str)))
def write_replicons_coverages(
self, replicon_str, coverages, discard_zeros=True, factor=1.0):
self._fh.write("variableStep c... | class WiggleWriter(object):
| def __init__(self, track_str, fh):
self._fh = fh
self._fh.write(("track type=wiggle_0 name=\"%s\"\n" % (track_str)))
def write_replicons_coverages(
self, replicon_str, coverages, discard_zeros=True, factor=1.0):
self._fh.write("variableStep chrom=%s span=1\n" % (replicon... | class WiggleWriter(object):
| 6 | 71 | 239 | 6 | 0 | Tillsa/READemption | reademptionlib/wiggle.py | Python | WiggleWriter | WiggleWriter | 1 | 21 | 1 | 2 | f98d0eee8850f9fc4ddc28c1fcdae535bd40f619 | bigcode/the-stack | train |
b0c15cd71494393dd907728c | train | class | class CPartialMerkleTree:
__slots__ = ("nTransactions", "vBits", "vHash")
def __init__(self):
self.nTransactions = 0
self.vHash = []
self.vBits = []
def deserialize(self, f):
self.nTransactions = struct.unpack("<i", f.read(4))[0]
self.vHash = deser_uint256_vector(f)... | class CPartialMerkleTree:
| __slots__ = ("nTransactions", "vBits", "vHash")
def __init__(self):
self.nTransactions = 0
self.vHash = []
self.vBits = []
def deserialize(self, f):
self.nTransactions = struct.unpack("<i", f.read(4))[0]
self.vHash = deser_uint256_vector(f)
vBytes = deser_st... | += ser_uint256(self.blockhash)
if with_witness:
r += ser_vector(self.transactions, "serialize_with_witness")
else:
r += ser_vector(self.transactions, "serialize_without_witness")
return r
def __repr__(self):
return "BlockTransactions(hash=%064x transactions=... | 86 | 86 | 289 | 7 | 79 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CPartialMerkleTree | CPartialMerkleTree | 895 | 922 | 895 | 895 | b298058d0e0a4256a3d238efca29f8b864efd529 | bigcode/the-stack | train |
b4fb17e8b103ec52c450bc67 | train | class | class HeaderAndShortIDs:
__slots__ = ("header", "nonce", "prefilled_txn", "shortids", "use_witness")
def __init__(self, p2pheaders_and_shortids = None):
self.header = CBlockHeader()
self.nonce = 0
self.shortids = []
self.prefilled_txn = []
self.use_witness = False
... | class HeaderAndShortIDs:
| __slots__ = ("header", "nonce", "prefilled_txn", "shortids", "use_witness")
def __init__(self, p2pheaders_and_shortids = None):
self.header = CBlockHeader()
self.nonce = 0
self.shortids = []
self.prefilled_txn = []
self.use_witness = False
if p2pheaders_and_shor... | " % (repr(self.header), self.nonce, self.shortids_length, repr(self.shortids), self.prefilled_txn_length, repr(self.prefilled_txn))
# P2P version of the above that will use witness serialization (for compact
# block version 2)
class P2PHeaderAndShortWitnessIDs(P2PHeaderAndShortIDs):
__slots__ = ()
def seriali... | 207 | 207 | 693 | 6 | 201 | minblock/workcoin | test/functional/test_framework/messages.py | Python | HeaderAndShortIDs | HeaderAndShortIDs | 767 | 827 | 767 | 767 | c961bf3c979175151b29d78e526baacaa1098c5f | bigcode/the-stack | train |
90dc62958dc3cf39a67bdeb6 | train | class | class msg_witness_block(msg_block):
__slots__ = ()
def serialize(self):
r = self.block.serialize(with_witness=True)
return r
| class msg_witness_block(msg_block):
| __slots__ = ()
def serialize(self):
r = self.block.serialize(with_witness=True)
return r
| __ = ("command", "data")
def __init__(self, command, data=None):
self.command = command
self.data = data
def serialize(self):
return self.data
def __repr__(self):
return "msg_generic()"
class msg_witness_block(msg_block):
| 64 | 64 | 34 | 8 | 55 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_witness_block | msg_witness_block | 1,161 | 1,165 | 1,161 | 1,161 | dc9481ff664d3c7bcd3277698fa6c0d9f0a9422a | bigcode/the-stack | train |
32c9ebd2bc000d0726a55fe4 | train | class | class msg_sendcmpct:
__slots__ = ("announce", "version")
command = b"sendcmpct"
def __init__(self):
self.announce = False
self.version = 1
def deserialize(self, f):
self.announce = struct.unpack("<?", f.read(1))[0]
self.version = struct.unpack("<Q", f.read(8))[0]
d... | class msg_sendcmpct:
| __slots__ = ("announce", "version")
command = b"sendcmpct"
def __init__(self):
self.announce = False
self.version = 1
def deserialize(self, f):
self.announce = struct.unpack("<?", f.read(1))[0]
self.version = struct.unpack("<Q", f.read(8))[0]
def serialize(self):
... | ))[0]
def serialize(self):
r = b""
r += struct.pack("<Q", self.feerate)
return r
def __repr__(self):
return "msg_feefilter(feerate=%08x)" % self.feerate
class msg_sendcmpct:
| 64 | 64 | 157 | 6 | 57 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_sendcmpct | msg_sendcmpct | 1,377 | 1,396 | 1,377 | 1,377 | 36862e1925d3c6165c838ac280477af22e18adaa | bigcode/the-stack | train |
94cd392536280d8b52c6795a | train | class | class P2PHeaderAndShortWitnessIDs(P2PHeaderAndShortIDs):
__slots__ = ()
def serialize(self):
return super(P2PHeaderAndShortWitnessIDs, self).serialize(with_witness=True)
| class P2PHeaderAndShortWitnessIDs(P2PHeaderAndShortIDs):
| __slots__ = ()
def serialize(self):
return super(P2PHeaderAndShortWitnessIDs, self).serialize(with_witness=True)
| self.shortids_length, repr(self.shortids), self.prefilled_txn_length, repr(self.prefilled_txn))
# P2P version of the above that will use witness serialization (for compact
# block version 2)
class P2PHeaderAndShortWitnessIDs(P2PHeaderAndShortIDs):
| 64 | 64 | 48 | 17 | 47 | minblock/workcoin | test/functional/test_framework/messages.py | Python | P2PHeaderAndShortWitnessIDs | P2PHeaderAndShortWitnessIDs | 753 | 756 | 753 | 753 | d14795bb426edb5178e0c9137f0252f7f21a1611 | bigcode/the-stack | train |
74c69533a6842ad2fcecbfaa | train | class | class msg_addr:
__slots__ = ("addrs",)
command = b"addr"
def __init__(self):
self.addrs = []
def deserialize(self, f):
self.addrs = deser_vector(f, CAddress)
def serialize(self):
return ser_vector(self.addrs)
def __repr__(self):
return "msg_addr(addrs=%s)" % (... | class msg_addr:
| __slots__ = ("addrs",)
command = b"addr"
def __init__(self):
self.addrs = []
def deserialize(self, f):
self.addrs = deser_vector(f, CAddress)
def serialize(self):
return ser_vector(self.addrs)
def __repr__(self):
return "msg_addr(addrs=%s)" % (repr(self.addrs)... | :
__slots__ = ()
command = b"verack"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_verack()"
class msg_addr:
| 64 | 64 | 90 | 4 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_addr | msg_addr | 1,023 | 1,037 | 1,023 | 1,023 | dbd0f328f98a80d9f17fbb268cefb6213bf70959 | bigcode/the-stack | train |
15fe003effdbf851f572000d | train | class | class CScriptWitness:
__slots__ = ("stack",)
def __init__(self):
# stack is a vector of strings
self.stack = []
def __repr__(self):
return "CScriptWitness(%s)" % \
(",".join([bytes_to_hex_str(x) for x in self.stack]))
def is_null(self):
if self.stack:
... | class CScriptWitness:
| __slots__ = ("stack",)
def __init__(self):
# stack is a vector of strings
self.stack = []
def __repr__(self):
return "CScriptWitness(%s)" % \
(",".join([bytes_to_hex_str(x) for x in self.stack]))
def is_null(self):
if self.stack:
return False... | )
return r
def __repr__(self):
return "CTxOut(nValue=%i.%08i scriptPubKey=%s)" \
% (self.nValue // COIN, self.nValue % COIN,
bytes_to_hex_str(self.scriptPubKey))
class CScriptWitness:
| 64 | 64 | 89 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CScriptWitness | CScriptWitness | 350 | 364 | 350 | 350 | 72f07357a6cae023025faedf42f9e3ebcdf8a419 | bigcode/the-stack | train |
ac5f519c7c331745f2931a50 | train | function | def ser_string(s):
return ser_compact_size(len(s)) + s
| def ser_string(s):
| return ser_compact_size(len(s)) + s
| struct.unpack("<I", f.read(4))[0]
elif nit == 255:
nit = struct.unpack("<Q", f.read(8))[0]
return nit
def deser_string(f):
nit = deser_compact_size(f)
return f.read(nit)
def ser_string(s):
| 64 | 64 | 17 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | ser_string | ser_string | 90 | 91 | 90 | 90 | 5309412d59ce6a2ef284a2e13835aefd25c7ef86 | bigcode/the-stack | train |
1a5567b7ac64fe21a113f5c0 | train | class | class CTxInWitness:
__slots__ = ("scriptWitness",)
def __init__(self):
self.scriptWitness = CScriptWitness()
def deserialize(self, f):
self.scriptWitness.stack = deser_string_vector(f)
def serialize(self):
return ser_string_vector(self.scriptWitness.stack)
def __repr__(se... | class CTxInWitness:
| __slots__ = ("scriptWitness",)
def __init__(self):
self.scriptWitness = CScriptWitness()
def deserialize(self, f):
self.scriptWitness.stack = deser_string_vector(f)
def serialize(self):
return ser_string_vector(self.scriptWitness.stack)
def __repr__(self):
return ... | self.stack = []
def __repr__(self):
return "CScriptWitness(%s)" % \
(",".join([bytes_to_hex_str(x) for x in self.stack]))
def is_null(self):
if self.stack:
return False
return True
class CTxInWitness:
| 64 | 64 | 93 | 6 | 57 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CTxInWitness | CTxInWitness | 367 | 383 | 367 | 367 | da68a4a05859819f9797c65288e5f32ef6362570 | bigcode/the-stack | train |
0f4a03c007bf4913dc70681c | train | function | def FromHex(obj, hex_string):
obj.deserialize(BytesIO(hex_str_to_bytes(hex_string)))
return obj
| def FromHex(obj, hex_string):
| obj.deserialize(BytesIO(hex_str_to_bytes(hex_string)))
return obj
| )
r.append(t)
return r
def ser_string_vector(l):
r = ser_compact_size(len(l))
for sv in l:
r += ser_string(sv)
return r
# Deserialize from a hex string representation (eg from RPC)
def FromHex(obj, hex_string):
| 64 | 64 | 24 | 8 | 56 | minblock/workcoin | test/functional/test_framework/messages.py | Python | FromHex | FromHex | 179 | 181 | 179 | 179 | f7229e9e7c5e72dacd9979fe2f3c6885ff0a4f40 | bigcode/the-stack | train |
f5f95dacdb5168fa6833f236 | train | class | class COutPoint:
__slots__ = ("hash", "n")
def __init__(self, hash=0, n=0):
self.hash = hash
self.n = n
def deserialize(self, f):
self.hash = deser_uint256(f)
self.n = struct.unpack("<I", f.read(4))[0]
def serialize(self):
r = b""
r += ser_uint256(self.... | class COutPoint:
| __slots__ = ("hash", "n")
def __init__(self, hash=0, n=0):
self.hash = hash
self.n = n
def deserialize(self, f):
self.hash = deser_uint256(f)
self.n = struct.unpack("<I", f.read(4))[0]
def serialize(self):
r = b""
r += ser_uint256(self.hash)
r +... | struct.pack("<i", self.nVersion)
r += ser_uint256_vector(self.vHave)
return r
def __repr__(self):
return "CBlockLocator(nVersion=%i vHave=%s)" \
% (self.nVersion, repr(self.vHave))
class COutPoint:
| 64 | 64 | 139 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | COutPoint | COutPoint | 276 | 294 | 276 | 276 | 9b9b1ce1d0d7d56e0127c632e3732e0abf29d24f | bigcode/the-stack | train |
115282fb71ad8700d2fde802 | train | class | class BlockTransactionsRequest:
__slots__ = ("blockhash", "indexes")
def __init__(self, blockhash=0, indexes = None):
self.blockhash = blockhash
self.indexes = indexes if indexes is not None else []
def deserialize(self, f):
self.blockhash = deser_uint256(f)
indexes_length ... | class BlockTransactionsRequest:
| __slots__ = ("blockhash", "indexes")
def __init__(self, blockhash=0, indexes = None):
self.blockhash = blockhash
self.indexes = indexes if indexes is not None else []
def deserialize(self, f):
self.blockhash = deser_uint256(f)
indexes_length = deser_compact_size(f)
... | tx[i].calc_sha256(with_witness=True)
self.shortids.append(calculate_shortid(k0, k1, tx_hash))
def __repr__(self):
return "HeaderAndShortIDs(header=%s, nonce=%d, shortids=%s, prefilledtxn=%s" % (repr(self.header), self.nonce, repr(self.shortids), repr(self.prefilled_txn))
class BlockTransact... | 89 | 89 | 299 | 5 | 84 | minblock/workcoin | test/functional/test_framework/messages.py | Python | BlockTransactionsRequest | BlockTransactionsRequest | 830 | 868 | 830 | 830 | 2d40f43b9567d2d0b2d6755fe4536cb6fad46d79 | bigcode/the-stack | train |
70b0963e93b75780714ce661 | train | function | def deser_uint256_vector(f):
nit = deser_compact_size(f)
r = []
for i in range(nit):
t = deser_uint256(f)
r.append(t)
return r
| def deser_uint256_vector(f):
| nit = deser_compact_size(f)
r = []
for i in range(nit):
t = deser_uint256(f)
r.append(t)
return r
| ).
def ser_vector(l, ser_function_name=None):
r = ser_compact_size(len(l))
for i in l:
if ser_function_name:
r += getattr(i, ser_function_name)()
else:
r += i.serialize()
return r
def deser_uint256_vector(f):
| 64 | 64 | 45 | 7 | 56 | minblock/workcoin | test/functional/test_framework/messages.py | Python | deser_uint256_vector | deser_uint256_vector | 146 | 152 | 146 | 146 | e2da6cca1a5e001d90e693ae42bb7e4245485078 | bigcode/the-stack | train |
9a84abc3d8fe4a804f38c9ad | train | function | def ser_string_vector(l):
r = ser_compact_size(len(l))
for sv in l:
r += ser_string(sv)
return r
| def ser_string_vector(l):
| r = ser_compact_size(len(l))
for sv in l:
r += ser_string(sv)
return r
| in l:
r += ser_uint256(i)
return r
def deser_string_vector(f):
nit = deser_compact_size(f)
r = []
for i in range(nit):
t = deser_string(f)
r.append(t)
return r
def ser_string_vector(l):
| 64 | 64 | 34 | 6 | 57 | minblock/workcoin | test/functional/test_framework/messages.py | Python | ser_string_vector | ser_string_vector | 171 | 175 | 171 | 171 | 5a41ca47fb6eef35bdb0a3a44942d40eb03d2033 | bigcode/the-stack | train |
7bab366c5336d6dcdc5b965b | train | class | class msg_verack:
__slots__ = ()
command = b"verack"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_verack()"
| class msg_verack:
| __slots__ = ()
command = b"verack"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_verack()"
| nStartingHeight=%i nRelay=%i)' \
% (self.nVersion, self.nServices, time.ctime(self.nTime),
repr(self.addrTo), repr(self.addrFrom), self.nNonce,
self.strSubVer, self.nStartingHeight, self.nRelay)
class msg_verack:
| 64 | 64 | 64 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_verack | msg_verack | 1,006 | 1,020 | 1,006 | 1,006 | d43af41def6fc323d3be4bc14e162ca3b457297f | bigcode/the-stack | train |
dbf557c0c439c764f1b18f49 | train | function | def ser_uint256(u):
rs = b""
for i in range(8):
rs += struct.pack("<I", u & 0xFFFFFFFF)
u >>= 32
return rs
| def ser_uint256(u):
| rs = b""
for i in range(8):
rs += struct.pack("<I", u & 0xFFFFFFFF)
u >>= 32
return rs
| act_size(len(s)) + s
def deser_uint256(f):
r = 0
for i in range(8):
t = struct.unpack("<I", f.read(4))[0]
r += t << (i * 32)
return r
def ser_uint256(u):
| 64 | 64 | 45 | 6 | 57 | minblock/workcoin | test/functional/test_framework/messages.py | Python | ser_uint256 | ser_uint256 | 101 | 106 | 101 | 101 | ad9b01fd823e67b41f45a68ee674e9e16b9daaa3 | bigcode/the-stack | train |
bc4a0c5a296b9f6ba448fbff | train | class | class msg_block:
__slots__ = ("block",)
command = b"block"
def __init__(self, block=None):
if block is None:
self.block = CBlock()
else:
self.block = block
def deserialize(self, f):
self.block.deserialize(f)
def serialize(self):
return self.... | class msg_block:
| __slots__ = ("block",)
command = b"block"
def __init__(self, block=None):
if block is None:
self.block = CBlock()
else:
self.block = block
def deserialize(self, f):
self.block.deserialize(f)
def serialize(self):
return self.block.serialize(w... | ):
return self.tx.serialize_without_witness()
def __repr__(self):
return "msg_tx(tx=%s)" % (repr(self.tx))
class msg_witness_tx(msg_tx):
__slots__ = ()
def serialize(self):
return self.tx.serialize_with_witness()
class msg_block:
| 64 | 64 | 102 | 4 | 60 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_block | msg_block | 1,125 | 1,142 | 1,125 | 1,125 | bc39b495d077446371a80d25853f542e3d0b1ef8 | bigcode/the-stack | train |
f2f2c39185859c32e92393bf | train | function | def deser_uint256(f):
r = 0
for i in range(8):
t = struct.unpack("<I", f.read(4))[0]
r += t << (i * 32)
return r
| def deser_uint256(f):
| r = 0
for i in range(8):
t = struct.unpack("<I", f.read(4))[0]
r += t << (i * 32)
return r
| :
nit = struct.unpack("<Q", f.read(8))[0]
return nit
def deser_string(f):
nit = deser_compact_size(f)
return f.read(nit)
def ser_string(s):
return ser_compact_size(len(s)) + s
def deser_uint256(f):
| 64 | 64 | 50 | 6 | 57 | minblock/workcoin | test/functional/test_framework/messages.py | Python | deser_uint256 | deser_uint256 | 93 | 98 | 93 | 93 | 29b391a33e2abf0e99e3f8b2a85c2d8a503d57b0 | bigcode/the-stack | train |
6d9d2e63e2c69bcb65df018a | train | class | class msg_getblocktxn:
__slots__ = ("block_txn_request",)
command = b"getblocktxn"
def __init__(self):
self.block_txn_request = None
def deserialize(self, f):
self.block_txn_request = BlockTransactionsRequest()
self.block_txn_request.deserialize(f)
def serialize(self):
... | class msg_getblocktxn:
| __slots__ = ("block_txn_request",)
command = b"getblocktxn"
def __init__(self):
self.block_txn_request = None
def deserialize(self, f):
self.block_txn_request = BlockTransactionsRequest()
self.block_txn_request.deserialize(f)
def serialize(self):
r = b""
r ... | ids.deserialize(f)
def serialize(self):
r = b""
r += self.header_and_shortids.serialize()
return r
def __repr__(self):
return "msg_cmpctblock(HeaderAndShortIDs=%s)" % repr(self.header_and_shortids)
class msg_getblocktxn:
| 64 | 64 | 125 | 6 | 58 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_getblocktxn | msg_getblocktxn | 1,419 | 1,436 | 1,419 | 1,419 | f5a544938d4de92a37cc342ea17ee45739c1f86e | bigcode/the-stack | train |
62647ae58504e132b801f30f | train | class | class msg_sendheaders:
__slots__ = ()
command = b"sendheaders"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_sendheaders()"
| class msg_sendheaders:
| __slots__ = ()
command = b"sendheaders"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_sendheaders()"
| self.vec = vec or []
def deserialize(self, f):
self.vec = deser_vector(f, CInv)
def serialize(self):
return ser_vector(self.vec)
def __repr__(self):
return "msg_notfound(vec=%s)" % (repr(self.vec))
class msg_sendheaders:
| 64 | 64 | 64 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_sendheaders | msg_sendheaders | 1,257 | 1,271 | 1,257 | 1,257 | a0b16d25b3b8c3ead3a04ceda5c63cdb4ffdfc1f | bigcode/the-stack | train |
a052a4534d8953fa46e21fa1 | train | function | def sha256(s):
return hashlib.new('sha256', s).digest()
| def sha256(s):
| return hashlib.new('sha256', s).digest()
| = (1 << 3)
NODE_NETWORK_LIMITED = (1 << 10)
MSG_TX = 1
MSG_BLOCK = 2
MSG_WITNESS_FLAG = 1 << 30
MSG_TYPE_MASK = 0xffffffff >> 2
# Serialization/deserialization tools
def sha256(s):
| 64 | 64 | 17 | 5 | 58 | minblock/workcoin | test/functional/test_framework/messages.py | Python | sha256 | sha256 | 58 | 59 | 58 | 58 | d856fa315d3189b434c52c9b9666fcbc8c1d528c | bigcode/the-stack | train |
640bd2e0ff5680674752d934 | train | class | class PrefilledTransaction:
__slots__ = ("index", "tx")
def __init__(self, index=0, tx = None):
self.index = index
self.tx = tx
def deserialize(self, f):
self.index = deser_compact_size(f)
self.tx = CTransaction()
self.tx.deserialize(f)
def serialize(self, with... | class PrefilledTransaction:
| __slots__ = ("index", "tx")
def __init__(self, index=0, tx = None):
self.index = index
self.tx = tx
def deserialize(self, f):
self.index = deser_compact_size(f)
self.tx = CTransaction()
self.tx.deserialize(f)
def serialize(self, with_witness=True):
r = ... | nTime=%s nBits=%08x nNonce=%08x vtx=%s)" \
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot,
time.ctime(self.nTime), self.nBits, self.nNonce, repr(self.vtx))
class PrefilledTransaction:
| 64 | 64 | 196 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | PrefilledTransaction | PrefilledTransaction | 677 | 705 | 677 | 677 | 423ce7e3cea7c9e2122c7ac9e9b31d7e96750cc7 | bigcode/the-stack | train |
08e733c0f9a25edd6f0ec9ce | train | function | def deser_string(f):
nit = deser_compact_size(f)
return f.read(nit)
| def deser_string(f):
| nit = deser_compact_size(f)
return f.read(nit)
| .unpack("<H", f.read(2))[0]
elif nit == 254:
nit = struct.unpack("<I", f.read(4))[0]
elif nit == 255:
nit = struct.unpack("<Q", f.read(8))[0]
return nit
def deser_string(f):
| 64 | 64 | 21 | 5 | 58 | minblock/workcoin | test/functional/test_framework/messages.py | Python | deser_string | deser_string | 86 | 88 | 86 | 86 | 528b93c5ba25eed124ba00dea862cf54614ca9b4 | bigcode/the-stack | train |
a846c409a49c69381749e9ef | train | class | class msg_getaddr:
__slots__ = ()
command = b"getaddr"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_getaddr()"
| class msg_getaddr:
| __slots__ = ()
command = b"getaddr"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_getaddr()"
|
def serialize(self):
return self.data
def __repr__(self):
return "msg_generic()"
class msg_witness_block(msg_block):
__slots__ = ()
def serialize(self):
r = self.block.serialize(with_witness=True)
return r
class msg_getaddr:
| 64 | 64 | 64 | 5 | 58 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_getaddr | msg_getaddr | 1,168 | 1,182 | 1,168 | 1,168 | b9b38f0b82b7ebb759a763a1b5626bae84eaecb7 | bigcode/the-stack | train |
4aa971e1bc8b23c80e7b9dcb | train | function | def uint256_from_str(s):
r = 0
t = struct.unpack("<IIIIIIII", s[:32])
for i in range(8):
r += t[i] << (i * 32)
return r
| def uint256_from_str(s):
| r = 0
t = struct.unpack("<IIIIIIII", s[:32])
for i in range(8):
r += t[i] << (i * 32)
return r
| t << (i * 32)
return r
def ser_uint256(u):
rs = b""
for i in range(8):
rs += struct.pack("<I", u & 0xFFFFFFFF)
u >>= 32
return rs
def uint256_from_str(s):
| 64 | 64 | 51 | 7 | 56 | minblock/workcoin | test/functional/test_framework/messages.py | Python | uint256_from_str | uint256_from_str | 109 | 114 | 109 | 109 | 1542beb9f545ee20bd3180690796d7e47d01324f | bigcode/the-stack | train |
56b940605db048f91810b054 | train | class | class msg_notfound:
__slots__ = ("vec", )
command = b"notfound"
def __init__(self, vec=None):
self.vec = vec or []
def deserialize(self, f):
self.vec = deser_vector(f, CInv)
def serialize(self):
return ser_vector(self.vec)
def __repr__(self):
return "msg_notfo... | class msg_notfound:
| __slots__ = ("vec", )
command = b"notfound"
def __init__(self, vec=None):
self.vec = vec or []
def deserialize(self, f):
self.vec = deser_vector(f, CInv)
def serialize(self):
return ser_vector(self.vec)
def __repr__(self):
return "msg_notfound(vec=%s)" % (repr... | slots__ = ()
command = b"mempool"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_mempool()"
class msg_notfound:
| 64 | 64 | 92 | 5 | 58 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_notfound | msg_notfound | 1,240 | 1,254 | 1,240 | 1,240 | d65d3a3fc4390443d8f3905d8be1d6a678b0e2f1 | bigcode/the-stack | train |
510968fb85e17a36e230635d | train | class | class msg_getblocks:
__slots__ = ("locator", "hashstop")
command = b"getblocks"
def __init__(self):
self.locator = CBlockLocator()
self.hashstop = 0
def deserialize(self, f):
self.locator = CBlockLocator()
self.locator.deserialize(f)
self.hashstop = deser_uint25... | class msg_getblocks:
| __slots__ = ("locator", "hashstop")
command = b"getblocks"
def __init__(self):
self.locator = CBlockLocator()
self.hashstop = 0
def deserialize(self, f):
self.locator = CBlockLocator()
self.locator.deserialize(f)
self.hashstop = deser_uint256(f)
def seriali... | inv is not None else []
def deserialize(self, f):
self.inv = deser_vector(f, CInv)
def serialize(self):
return ser_vector(self.inv)
def __repr__(self):
return "msg_getdata(inv=%s)" % (repr(self.inv))
class msg_getblocks:
| 64 | 64 | 150 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_getblocks | msg_getblocks | 1,077 | 1,098 | 1,077 | 1,077 | fc5e7f777b84a731d7a7ea4c302e89ed3cbac9fa | bigcode/the-stack | train |
acce697d629eb8166c4706f0 | train | class | class msg_ping:
__slots__ = ("nonce",)
command = b"ping"
def __init__(self, nonce=0):
self.nonce = nonce
def deserialize(self, f):
self.nonce = struct.unpack("<Q", f.read(8))[0]
def serialize(self):
r = b""
r += struct.pack("<Q", self.nonce)
return r
d... | class msg_ping:
| __slots__ = ("nonce",)
command = b"ping"
def __init__(self, nonce=0):
self.nonce = nonce
def deserialize(self, f):
self.nonce = struct.unpack("<Q", f.read(8))[0]
def serialize(self):
r = b""
r += struct.pack("<Q", self.nonce)
return r
def __repr__(self... | :
__slots__ = ()
command = b"getaddr"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_getaddr()"
class msg_ping:
| 64 | 64 | 112 | 4 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_ping | msg_ping | 1,185 | 1,201 | 1,185 | 1,185 | 0bc7df72f44fa0b77e97c0d0506f0d56ec560185 | bigcode/the-stack | train |
5890af24d25b2937ee97b33e | train | class | class msg_headers:
__slots__ = ("headers",)
command = b"headers"
def __init__(self, headers=None):
self.headers = headers if headers is not None else []
def deserialize(self, f):
# comment in bitcoind indicates these should be deserialized as blocks
blocks = deser_vector(f, CBl... | class msg_headers:
| __slots__ = ("headers",)
command = b"headers"
def __init__(self, headers=None):
self.headers = headers if headers is not None else []
def deserialize(self, f):
# comment in bitcoind indicates these should be deserialized as blocks
blocks = deser_vector(f, CBlock)
for x ... | _uint256(self.hashstop)
return r
def __repr__(self):
return "msg_getheaders(locator=%s, stop=%064x)" \
% (repr(self.locator), self.hashstop)
# headers message has
# <count> <vector of block headers>
class msg_headers:
| 64 | 64 | 137 | 4 | 60 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_headers | msg_headers | 1,304 | 1,322 | 1,304 | 1,304 | 375253118e7f8dc1112b43fd7ffd94c08a214a4d | bigcode/the-stack | train |
c96974e7d03a23bb4aef9ba6 | train | class | class CMerkleBlock:
__slots__ = ("header", "txn")
def __init__(self):
self.header = CBlockHeader()
self.txn = CPartialMerkleTree()
def deserialize(self, f):
self.header.deserialize(f)
self.txn.deserialize(f)
def serialize(self):
r = b""
r += self.header... | class CMerkleBlock:
| __slots__ = ("header", "txn")
def __init__(self):
self.header = CBlockHeader()
self.txn = CPartialMerkleTree()
def deserialize(self, f):
self.header.deserialize(f)
self.txn.deserialize(f)
def serialize(self):
r = b""
r += self.header.serialize()
... | += ser_string(bytes(vBytesArray))
return r
def __repr__(self):
return "CPartialMerkleTree(nTransactions=%d, vHash=%s, vBits=%s)" % (self.nTransactions, repr(self.vHash), repr(self.vBits))
class CMerkleBlock:
| 64 | 64 | 126 | 6 | 58 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CMerkleBlock | CMerkleBlock | 925 | 943 | 925 | 925 | 908242e34fbdfe1fc3b23efd436356bf788bea51 | bigcode/the-stack | train |
c96103bee9601ef299658c56 | train | class | class msg_blocktxn:
__slots__ = ("block_transactions",)
command = b"blocktxn"
def __init__(self):
self.block_transactions = BlockTransactions()
def deserialize(self, f):
self.block_transactions.deserialize(f)
def serialize(self):
r = b""
r += self.block_transaction... | class msg_blocktxn:
| __slots__ = ("block_transactions",)
command = b"blocktxn"
def __init__(self):
self.block_transactions = BlockTransactions()
def deserialize(self, f):
self.block_transactions.deserialize(f)
def serialize(self):
r = b""
r += self.block_transactions.serialize(with_wit... | _request.deserialize(f)
def serialize(self):
r = b""
r += self.block_txn_request.serialize()
return r
def __repr__(self):
return "msg_getblocktxn(block_txn_request=%s)" % (repr(self.block_txn_request))
class msg_blocktxn:
| 64 | 64 | 104 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_blocktxn | msg_blocktxn | 1,439 | 1,455 | 1,439 | 1,439 | da52248eac5e52a3d8c7b9bd189807f8a00dc6a9 | bigcode/the-stack | train |
07ece7f669448e7737c68c00 | train | function | def ser_vector(l, ser_function_name=None):
r = ser_compact_size(len(l))
for i in l:
if ser_function_name:
r += getattr(i, ser_function_name)()
else:
r += i.serialize()
return r
| def ser_vector(l, ser_function_name=None):
| r = ser_compact_size(len(l))
for i in l:
if ser_function_name:
r += getattr(i, ser_function_name)()
else:
r += i.serialize()
return r
| = c()
t.deserialize(f)
r.append(t)
return r
# ser_function_name: Allow for an alternate serialization function on the
# entries in the vector (we use this for serializing the vector of transactions
# for a witness block).
def ser_vector(l, ser_function_name=None):
| 64 | 64 | 56 | 10 | 54 | minblock/workcoin | test/functional/test_framework/messages.py | Python | ser_vector | ser_vector | 136 | 143 | 136 | 136 | 19e4aecdc931c8630409a2c9d479d717469ab4ba | bigcode/the-stack | train |
04ff6869aeafb236c22be2c3 | train | class | class BlockTransactions:
__slots__ = ("blockhash", "transactions")
def __init__(self, blockhash=0, transactions = None):
self.blockhash = blockhash
self.transactions = transactions if transactions is not None else []
def deserialize(self, f):
self.blockhash = deser_uint256(f)
... | class BlockTransactions:
| __slots__ = ("blockhash", "transactions")
def __init__(self, blockhash=0, transactions = None):
self.blockhash = blockhash
self.transactions = transactions if transactions is not None else []
def deserialize(self, f):
self.blockhash = deser_uint256(f)
self.transactions = de... | .indexes:
absolute_indexes.append(x+last_index+1)
last_index = absolute_indexes[-1]
return absolute_indexes
def __repr__(self):
return "BlockTransactionsRequest(hash=%064x indexes=%s)" % (self.blockhash, repr(self.indexes))
class BlockTransactions:
| 64 | 64 | 177 | 4 | 60 | minblock/workcoin | test/functional/test_framework/messages.py | Python | BlockTransactions | BlockTransactions | 871 | 892 | 871 | 871 | fa4565dcb37a34d361d4455e645b5fc0397f03cc | bigcode/the-stack | train |
ec0f269a4713fd30e1b38f94 | train | function | def ser_compact_size(l):
r = b""
if l < 253:
r = struct.pack("B", l)
elif l < 0x10000:
r = struct.pack("<BH", 253, l)
elif l < 0x100000000:
r = struct.pack("<BI", 254, l)
else:
r = struct.pack("<BQ", 255, l)
return r
| def ser_compact_size(l):
| r = b""
if l < 253:
r = struct.pack("B", l)
elif l < 0x10000:
r = struct.pack("<BH", 253, l)
elif l < 0x100000000:
r = struct.pack("<BI", 254, l)
else:
r = struct.pack("<BQ", 255, l)
return r
| NESS_FLAG = 1 << 30
MSG_TYPE_MASK = 0xffffffff >> 2
# Serialization/deserialization tools
def sha256(s):
return hashlib.new('sha256', s).digest()
def hash256(s):
return sha256(sha256(s))
def ser_compact_size(l):
| 64 | 64 | 97 | 7 | 57 | minblock/workcoin | test/functional/test_framework/messages.py | Python | ser_compact_size | ser_compact_size | 64 | 74 | 64 | 64 | 0fd42c0eb00457f0aa992da1600c4d7a1b83176d | bigcode/the-stack | train |
5926e838ccd1e6ed0130fa46 | train | class | class CInv:
__slots__ = ("hash", "type")
typemap = {
0: "Error",
1: "TX",
2: "Block",
1|MSG_WITNESS_FLAG: "WitnessTx",
2|MSG_WITNESS_FLAG : "WitnessBlock",
4: "CompactBlock"
}
def __init__(self, t=0, h=0):
self.type = t
self.hash = h
... | class CInv:
| __slots__ = ("hash", "type")
typemap = {
0: "Error",
1: "TX",
2: "Block",
1|MSG_WITNESS_FLAG: "WitnessTx",
2|MSG_WITNESS_FLAG : "WitnessBlock",
4: "CompactBlock"
}
def __init__(self, t=0, h=0):
self.type = t
self.hash = h
def deseria... | += socket.inet_aton(self.ip)
r += struct.pack(">H", self.port)
return r
def __repr__(self):
return "CAddress(nServices=%i ip=%s port=%i)" % (self.nServices,
self.ip, self.port)
class CInv:
| 64 | 64 | 206 | 4 | 60 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CInv | CInv | 223 | 251 | 223 | 223 | 5572c678b4de8b63d16746801530fd71045f7bf4 | bigcode/the-stack | train |
7028db1b01c9b7fc1bdcbcce | train | function | def calculate_shortid(k0, k1, tx_hash):
expected_shortid = siphash256(k0, k1, tx_hash)
expected_shortid &= 0x0000ffffffffffff
return expected_shortid
| def calculate_shortid(k0, k1, tx_hash):
| expected_shortid = siphash256(k0, k1, tx_hash)
expected_shortid &= 0x0000ffffffffffff
return expected_shortid
| IDs):
__slots__ = ()
def serialize(self):
return super(P2PHeaderAndShortWitnessIDs, self).serialize(with_witness=True)
# Calculate the BIP 152-compact blocks shortid for a given transaction hash
def calculate_shortid(k0, k1, tx_hash):
| 64 | 64 | 49 | 13 | 50 | minblock/workcoin | test/functional/test_framework/messages.py | Python | calculate_shortid | calculate_shortid | 759 | 762 | 759 | 759 | dd6d35ee418faf4d18b997b8834e1cf7606bb321 | bigcode/the-stack | train |
30bffd7fbcf46e28cad6859d | train | function | def deser_compact_size(f):
nit = struct.unpack("<B", f.read(1))[0]
if nit == 253:
nit = struct.unpack("<H", f.read(2))[0]
elif nit == 254:
nit = struct.unpack("<I", f.read(4))[0]
elif nit == 255:
nit = struct.unpack("<Q", f.read(8))[0]
return nit
| def deser_compact_size(f):
| nit = struct.unpack("<B", f.read(1))[0]
if nit == 253:
nit = struct.unpack("<H", f.read(2))[0]
elif nit == 254:
nit = struct.unpack("<I", f.read(4))[0]
elif nit == 255:
nit = struct.unpack("<Q", f.read(8))[0]
return nit
| r = struct.pack("<BH", 253, l)
elif l < 0x100000000:
r = struct.pack("<BI", 254, l)
else:
r = struct.pack("<BQ", 255, l)
return r
def deser_compact_size(f):
| 64 | 64 | 92 | 7 | 56 | minblock/workcoin | test/functional/test_framework/messages.py | Python | deser_compact_size | deser_compact_size | 76 | 84 | 76 | 76 | dedae7345a74cc649c750e8a983214460f73a205 | bigcode/the-stack | train |
96e206fefd11bd6d3d4c9c3d | train | class | class CBlockLocator:
__slots__ = ("nVersion", "vHave")
def __init__(self):
self.nVersion = MY_VERSION
self.vHave = []
def deserialize(self, f):
self.nVersion = struct.unpack("<i", f.read(4))[0]
self.vHave = deser_uint256_vector(f)
def serialize(self):
r = b""
... | class CBlockLocator:
| __slots__ = ("nVersion", "vHave")
def __init__(self):
self.nVersion = MY_VERSION
self.vHave = []
def deserialize(self, f):
self.nVersion = struct.unpack("<i", f.read(4))[0]
self.vHave = deser_uint256_vector(f)
def serialize(self):
r = b""
r += struct.pa... | ""
r += struct.pack("<i", self.type)
r += ser_uint256(self.hash)
return r
def __repr__(self):
return "CInv(type=%s hash=%064x)" \
% (self.typemap[self.type], self.hash)
class CBlockLocator:
| 64 | 64 | 147 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CBlockLocator | CBlockLocator | 254 | 273 | 254 | 254 | e230771abe2de26ef4522043d8e7c8a443c04f51 | bigcode/the-stack | train |
662ac81ac212adb83f8bd094 | train | class | class msg_cmpctblock:
__slots__ = ("header_and_shortids",)
command = b"cmpctblock"
def __init__(self, header_and_shortids = None):
self.header_and_shortids = header_and_shortids
def deserialize(self, f):
self.header_and_shortids = P2PHeaderAndShortIDs()
self.header_and_shortids... | class msg_cmpctblock:
| __slots__ = ("header_and_shortids",)
command = b"cmpctblock"
def __init__(self, header_and_shortids = None):
self.header_and_shortids = header_and_shortids
def deserialize(self, f):
self.header_and_shortids = P2PHeaderAndShortIDs()
self.header_and_shortids.deserialize(f)
d... | r += struct.pack("<?", self.announce)
r += struct.pack("<Q", self.version)
return r
def __repr__(self):
return "msg_sendcmpct(announce=%s, version=%lu)" % (self.announce, self.version)
class msg_cmpctblock:
| 64 | 64 | 138 | 6 | 58 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_cmpctblock | msg_cmpctblock | 1,399 | 1,416 | 1,399 | 1,399 | c9b6eded8c482a8ffa6596e26f1937d3d1855320 | bigcode/the-stack | train |
d444fe620f556c19cfd68955 | train | class | class CAddress:
__slots__ = ("ip", "nServices", "pchReserved", "port", "time")
def __init__(self):
self.time = 0
self.nServices = 1
self.pchReserved = b"\x00" * 10 + b"\xff" * 2
self.ip = "0.0.0.0"
self.port = 0
def deserialize(self, f, with_time=True):
if w... | class CAddress:
| __slots__ = ("ip", "nServices", "pchReserved", "port", "time")
def __init__(self):
self.time = 0
self.nServices = 1
self.pchReserved = b"\x00" * 10 + b"\xff" * 2
self.ip = "0.0.0.0"
self.port = 0
def deserialize(self, f, with_time=True):
if with_time:
... | # Deserialize from a hex string representation (eg from RPC)
def FromHex(obj, hex_string):
obj.deserialize(BytesIO(hex_str_to_bytes(hex_string)))
return obj
# Convert a binary-serializable object to hex (eg for submission via RPC)
def ToHex(obj):
return bytes_to_hex_str(obj.serialize())
# Objects that map... | 88 | 88 | 294 | 4 | 83 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CAddress | CAddress | 190 | 220 | 190 | 190 | fb4bfbc85635f6cdc0bb6d10c21117fb2f3562e4 | bigcode/the-stack | train |
c2d4820ad947052949575e86 | train | class | class CTxOut:
__slots__ = ("nValue", "scriptPubKey")
def __init__(self, nValue=0, scriptPubKey=b""):
self.nValue = nValue
self.scriptPubKey = scriptPubKey
def deserialize(self, f):
self.nValue = struct.unpack("<q", f.read(8))[0]
self.scriptPubKey = deser_string(f)
def ... | class CTxOut:
| __slots__ = ("nValue", "scriptPubKey")
def __init__(self, nValue=0, scriptPubKey=b""):
self.nValue = nValue
self.scriptPubKey = scriptPubKey
def deserialize(self, f):
self.nValue = struct.unpack("<q", f.read(8))[0]
self.scriptPubKey = deser_string(f)
def serialize(self... | ("<I", self.nSequence)
return r
def __repr__(self):
return "CTxIn(prevout=%s scriptSig=%s nSequence=%i)" \
% (repr(self.prevout), bytes_to_hex_str(self.scriptSig),
self.nSequence)
class CTxOut:
| 64 | 64 | 180 | 5 | 59 | minblock/workcoin | test/functional/test_framework/messages.py | Python | CTxOut | CTxOut | 327 | 347 | 327 | 327 | d84fc23aeee55f761c9b7eb8271555d02ebacdac | bigcode/the-stack | train |
9488fa3369aa1f1498b5570a | train | class | class msg_mempool:
__slots__ = ()
command = b"mempool"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_mempool()"
| class msg_mempool:
| __slots__ = ()
command = b"mempool"
def __init__(self):
pass
def deserialize(self, f):
pass
def serialize(self):
return b""
def __repr__(self):
return "msg_mempool()"
| f.read(8))[0]
def serialize(self):
r = b""
r += struct.pack("<Q", self.nonce)
return r
def __repr__(self):
return "msg_pong(nonce=%08x)" % self.nonce
class msg_mempool:
| 64 | 64 | 67 | 6 | 57 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_mempool | msg_mempool | 1,223 | 1,237 | 1,223 | 1,223 | b6fdc030b46589114d0cc313b7419cf87b9512de | bigcode/the-stack | train |
d89654045760adb29f4b96e0 | train | class | class msg_witness_tx(msg_tx):
__slots__ = ()
def serialize(self):
return self.tx.serialize_with_witness()
| class msg_witness_tx(msg_tx):
| __slots__ = ()
def serialize(self):
return self.tx.serialize_with_witness()
| ()):
self.tx = tx
def deserialize(self, f):
self.tx.deserialize(f)
def serialize(self):
return self.tx.serialize_without_witness()
def __repr__(self):
return "msg_tx(tx=%s)" % (repr(self.tx))
class msg_witness_tx(msg_tx):
| 64 | 64 | 28 | 8 | 56 | minblock/workcoin | test/functional/test_framework/messages.py | Python | msg_witness_tx | msg_witness_tx | 1,118 | 1,122 | 1,118 | 1,118 | 8c21874ebc6d46ae2c321ae63e16841bc01d55bf | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.