repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
numba/llvmlite | llvmlite/ir/builder.py | IRBuilder.asm | def asm(self, ftype, asm, constraint, args, side_effect, name=''):
"""
Inline assembler.
"""
asm = instructions.InlineAsm(ftype, asm, constraint, side_effect)
return self.call(asm, args, name) | python | def asm(self, ftype, asm, constraint, args, side_effect, name=''):
"""
Inline assembler.
"""
asm = instructions.InlineAsm(ftype, asm, constraint, side_effect)
return self.call(asm, args, name) | [
"def",
"asm",
"(",
"self",
",",
"ftype",
",",
"asm",
",",
"constraint",
",",
"args",
",",
"side_effect",
",",
"name",
"=",
"''",
")",
":",
"asm",
"=",
"instructions",
".",
"InlineAsm",
"(",
"ftype",
",",
"asm",
",",
"constraint",
",",
"side_effect",
... | Inline assembler. | [
"Inline",
"assembler",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/builder.py#L829-L834 | train |
numba/llvmlite | llvmlite/ir/builder.py | IRBuilder.extract_element | def extract_element(self, vector, idx, name=''):
"""
Returns the value at position idx.
"""
instr = instructions.ExtractElement(self.block, vector, idx, name=name)
self._insert(instr)
return instr | python | def extract_element(self, vector, idx, name=''):
"""
Returns the value at position idx.
"""
instr = instructions.ExtractElement(self.block, vector, idx, name=name)
self._insert(instr)
return instr | [
"def",
"extract_element",
"(",
"self",
",",
"vector",
",",
"idx",
",",
"name",
"=",
"''",
")",
":",
"instr",
"=",
"instructions",
".",
"ExtractElement",
"(",
"self",
".",
"block",
",",
"vector",
",",
"idx",
",",
"name",
"=",
"name",
")",
"self",
".",... | Returns the value at position idx. | [
"Returns",
"the",
"value",
"at",
"position",
"idx",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/builder.py#L872-L878 | train |
numba/llvmlite | llvmlite/ir/module.py | Module.functions | def functions(self):
"""
A list of functions declared or defined in this module.
"""
return [v for v in self.globals.values()
if isinstance(v, values.Function)] | python | def functions(self):
"""
A list of functions declared or defined in this module.
"""
return [v for v in self.globals.values()
if isinstance(v, values.Function)] | [
"def",
"functions",
"(",
"self",
")",
":",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"globals",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"v",
",",
"values",
".",
"Function",
")",
"]"
] | A list of functions declared or defined in this module. | [
"A",
"list",
"of",
"functions",
"declared",
"or",
"defined",
"in",
"this",
"module",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/module.py#L120-L125 | train |
numba/llvmlite | llvmlite/ir/module.py | Module.add_global | def add_global(self, globalvalue):
"""
Add a new global value.
"""
assert globalvalue.name not in self.globals
self.globals[globalvalue.name] = globalvalue | python | def add_global(self, globalvalue):
"""
Add a new global value.
"""
assert globalvalue.name not in self.globals
self.globals[globalvalue.name] = globalvalue | [
"def",
"add_global",
"(",
"self",
",",
"globalvalue",
")",
":",
"assert",
"globalvalue",
".",
"name",
"not",
"in",
"self",
".",
"globals",
"self",
".",
"globals",
"[",
"globalvalue",
".",
"name",
"]",
"=",
"globalvalue"
] | Add a new global value. | [
"Add",
"a",
"new",
"global",
"value",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/module.py#L140-L145 | train |
numba/llvmlite | docs/gh-pages.py | sh2 | def sh2(cmd):
"""Execute command in a subshell, return stdout.
Stderr is unbuffered from the subshell.x"""
p = Popen(cmd, stdout=PIPE, shell=True, env=sub_environment())
out = p.communicate()[0]
retcode = p.returncode
if retcode:
raise CalledProcessError(retcode, cmd)
else:
... | python | def sh2(cmd):
"""Execute command in a subshell, return stdout.
Stderr is unbuffered from the subshell.x"""
p = Popen(cmd, stdout=PIPE, shell=True, env=sub_environment())
out = p.communicate()[0]
retcode = p.returncode
if retcode:
raise CalledProcessError(retcode, cmd)
else:
... | [
"def",
"sh2",
"(",
"cmd",
")",
":",
"p",
"=",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"PIPE",
",",
"shell",
"=",
"True",
",",
"env",
"=",
"sub_environment",
"(",
")",
")",
"out",
"=",
"p",
".",
"communicate",
"(",
")",
"[",
"0",
"]",
"retcode"... | Execute command in a subshell, return stdout.
Stderr is unbuffered from the subshell.x | [
"Execute",
"command",
"in",
"a",
"subshell",
"return",
"stdout",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/docs/gh-pages.py#L53-L63 | train |
numba/llvmlite | docs/gh-pages.py | sh3 | def sh3(cmd):
"""Execute command in a subshell, return stdout, stderr
If anything appears in stderr, print it out to sys.stderr"""
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True,
env=sub_environment())
out, err = p.communicate()
retcode = p.returncode
if retcode:
rais... | python | def sh3(cmd):
"""Execute command in a subshell, return stdout, stderr
If anything appears in stderr, print it out to sys.stderr"""
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True,
env=sub_environment())
out, err = p.communicate()
retcode = p.returncode
if retcode:
rais... | [
"def",
"sh3",
"(",
"cmd",
")",
":",
"p",
"=",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"PIPE",
",",
"shell",
"=",
"True",
",",
"env",
"=",
"sub_environment",
"(",
")",
")",
"out",
",",
"err",
"=",
"p",
".",
"communic... | Execute command in a subshell, return stdout, stderr
If anything appears in stderr, print it out to sys.stderr | [
"Execute",
"command",
"in",
"a",
"subshell",
"return",
"stdout",
"stderr"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/docs/gh-pages.py#L66-L77 | train |
numba/llvmlite | docs/gh-pages.py | init_repo | def init_repo(path):
"""clone the gh-pages repo if we haven't already."""
sh("git clone %s %s"%(pages_repo, path))
here = os.getcwd()
cd(path)
sh('git checkout gh-pages')
cd(here) | python | def init_repo(path):
"""clone the gh-pages repo if we haven't already."""
sh("git clone %s %s"%(pages_repo, path))
here = os.getcwd()
cd(path)
sh('git checkout gh-pages')
cd(here) | [
"def",
"init_repo",
"(",
"path",
")",
":",
"sh",
"(",
"\"git clone %s %s\"",
"%",
"(",
"pages_repo",
",",
"path",
")",
")",
"here",
"=",
"os",
".",
"getcwd",
"(",
")",
"cd",
"(",
"path",
")",
"sh",
"(",
"'git checkout gh-pages'",
")",
"cd",
"(",
"her... | clone the gh-pages repo if we haven't already. | [
"clone",
"the",
"gh",
"-",
"pages",
"repo",
"if",
"we",
"haven",
"t",
"already",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/docs/gh-pages.py#L80-L86 | train |
numba/llvmlite | docs/source/user-guide/examples/ll_fpadd.py | create_execution_engine | def create_execution_engine():
"""
Create an ExecutionEngine suitable for JIT code generation on
the host CPU. The engine is reusable for an arbitrary number of
modules.
"""
# Create a target machine representing the host
target = llvm.Target.from_default_triple()
target_machine = targe... | python | def create_execution_engine():
"""
Create an ExecutionEngine suitable for JIT code generation on
the host CPU. The engine is reusable for an arbitrary number of
modules.
"""
# Create a target machine representing the host
target = llvm.Target.from_default_triple()
target_machine = targe... | [
"def",
"create_execution_engine",
"(",
")",
":",
"# Create a target machine representing the host",
"target",
"=",
"llvm",
".",
"Target",
".",
"from_default_triple",
"(",
")",
"target_machine",
"=",
"target",
".",
"create_target_machine",
"(",
")",
"# And an execution eng... | Create an ExecutionEngine suitable for JIT code generation on
the host CPU. The engine is reusable for an arbitrary number of
modules. | [
"Create",
"an",
"ExecutionEngine",
"suitable",
"for",
"JIT",
"code",
"generation",
"on",
"the",
"host",
"CPU",
".",
"The",
"engine",
"is",
"reusable",
"for",
"an",
"arbitrary",
"number",
"of",
"modules",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/docs/source/user-guide/examples/ll_fpadd.py#L26-L38 | train |
numba/llvmlite | docs/source/user-guide/examples/ll_fpadd.py | compile_ir | def compile_ir(engine, llvm_ir):
"""
Compile the LLVM IR string with the given engine.
The compiled module object is returned.
"""
# Create a LLVM module object from the IR
mod = llvm.parse_assembly(llvm_ir)
mod.verify()
# Now add the module and make sure it is ready for execution
en... | python | def compile_ir(engine, llvm_ir):
"""
Compile the LLVM IR string with the given engine.
The compiled module object is returned.
"""
# Create a LLVM module object from the IR
mod = llvm.parse_assembly(llvm_ir)
mod.verify()
# Now add the module and make sure it is ready for execution
en... | [
"def",
"compile_ir",
"(",
"engine",
",",
"llvm_ir",
")",
":",
"# Create a LLVM module object from the IR",
"mod",
"=",
"llvm",
".",
"parse_assembly",
"(",
"llvm_ir",
")",
"mod",
".",
"verify",
"(",
")",
"# Now add the module and make sure it is ready for execution",
"en... | Compile the LLVM IR string with the given engine.
The compiled module object is returned. | [
"Compile",
"the",
"LLVM",
"IR",
"string",
"with",
"the",
"given",
"engine",
".",
"The",
"compiled",
"module",
"object",
"is",
"returned",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/docs/source/user-guide/examples/ll_fpadd.py#L41-L53 | train |
numba/llvmlite | llvmlite/binding/targets.py | get_default_triple | def get_default_triple():
"""
Return the default target triple LLVM is configured to produce code for.
"""
with ffi.OutputString() as out:
ffi.lib.LLVMPY_GetDefaultTargetTriple(out)
return str(out) | python | def get_default_triple():
"""
Return the default target triple LLVM is configured to produce code for.
"""
with ffi.OutputString() as out:
ffi.lib.LLVMPY_GetDefaultTargetTriple(out)
return str(out) | [
"def",
"get_default_triple",
"(",
")",
":",
"with",
"ffi",
".",
"OutputString",
"(",
")",
"as",
"out",
":",
"ffi",
".",
"lib",
".",
"LLVMPY_GetDefaultTargetTriple",
"(",
"out",
")",
"return",
"str",
"(",
"out",
")"
] | Return the default target triple LLVM is configured to produce code for. | [
"Return",
"the",
"default",
"target",
"triple",
"LLVM",
"is",
"configured",
"to",
"produce",
"code",
"for",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/targets.py#L72-L78 | train |
numba/llvmlite | llvmlite/binding/targets.py | TargetData.get_element_offset | def get_element_offset(self, ty, position):
"""
Get byte offset of type's ty element at the given position
"""
offset = ffi.lib.LLVMPY_OffsetOfElement(self, ty, position)
if offset == -1:
raise ValueError("Could not determined offset of {}th "
"el... | python | def get_element_offset(self, ty, position):
"""
Get byte offset of type's ty element at the given position
"""
offset = ffi.lib.LLVMPY_OffsetOfElement(self, ty, position)
if offset == -1:
raise ValueError("Could not determined offset of {}th "
"el... | [
"def",
"get_element_offset",
"(",
"self",
",",
"ty",
",",
"position",
")",
":",
"offset",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_OffsetOfElement",
"(",
"self",
",",
"ty",
",",
"position",
")",
"if",
"offset",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"... | Get byte offset of type's ty element at the given position | [
"Get",
"byte",
"offset",
"of",
"type",
"s",
"ty",
"element",
"at",
"the",
"given",
"position"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/targets.py#L136-L146 | train |
numba/llvmlite | llvmlite/binding/targets.py | Target.create_target_machine | def create_target_machine(self, cpu='', features='',
opt=2, reloc='default', codemodel='jitdefault',
jitdebug=False, printmc=False):
"""
Create a new TargetMachine for this target and the given options.
Specifying codemodel='default' w... | python | def create_target_machine(self, cpu='', features='',
opt=2, reloc='default', codemodel='jitdefault',
jitdebug=False, printmc=False):
"""
Create a new TargetMachine for this target and the given options.
Specifying codemodel='default' w... | [
"def",
"create_target_machine",
"(",
"self",
",",
"cpu",
"=",
"''",
",",
"features",
"=",
"''",
",",
"opt",
"=",
"2",
",",
"reloc",
"=",
"'default'",
",",
"codemodel",
"=",
"'jitdefault'",
",",
"jitdebug",
"=",
"False",
",",
"printmc",
"=",
"False",
")... | Create a new TargetMachine for this target and the given options.
Specifying codemodel='default' will result in the use of the "small"
code model. Specifying codemodel='jitdefault' will result in the code
model being picked based on platform bitness (32="small", 64="large"). | [
"Create",
"a",
"new",
"TargetMachine",
"for",
"this",
"target",
"and",
"the",
"given",
"options",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/targets.py#L217-L249 | train |
numba/llvmlite | llvmlite/binding/targets.py | TargetMachine._emit_to_memory | def _emit_to_memory(self, module, use_object=False):
"""Returns bytes of object code of the module.
Args
----
use_object : bool
Emit object code or (if False) emit assembly code.
"""
with ffi.OutputString() as outerr:
mb = ffi.lib.LLVMPY_TargetMac... | python | def _emit_to_memory(self, module, use_object=False):
"""Returns bytes of object code of the module.
Args
----
use_object : bool
Emit object code or (if False) emit assembly code.
"""
with ffi.OutputString() as outerr:
mb = ffi.lib.LLVMPY_TargetMac... | [
"def",
"_emit_to_memory",
"(",
"self",
",",
"module",
",",
"use_object",
"=",
"False",
")",
":",
"with",
"ffi",
".",
"OutputString",
"(",
")",
"as",
"outerr",
":",
"mb",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_TargetMachineEmitToMemory",
"(",
"self",
",",
"... | Returns bytes of object code of the module.
Args
----
use_object : bool
Emit object code or (if False) emit assembly code. | [
"Returns",
"bytes",
"of",
"object",
"code",
"of",
"the",
"module",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/targets.py#L285-L305 | train |
numba/llvmlite | llvmlite/binding/module.py | parse_assembly | def parse_assembly(llvmir, context=None):
"""
Create Module from a LLVM IR string
"""
if context is None:
context = get_global_context()
llvmir = _encode_string(llvmir)
strbuf = c_char_p(llvmir)
with ffi.OutputString() as errmsg:
mod = ModuleRef(
ffi.lib.LLVMPY_Pa... | python | def parse_assembly(llvmir, context=None):
"""
Create Module from a LLVM IR string
"""
if context is None:
context = get_global_context()
llvmir = _encode_string(llvmir)
strbuf = c_char_p(llvmir)
with ffi.OutputString() as errmsg:
mod = ModuleRef(
ffi.lib.LLVMPY_Pa... | [
"def",
"parse_assembly",
"(",
"llvmir",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"get_global_context",
"(",
")",
"llvmir",
"=",
"_encode_string",
"(",
"llvmir",
")",
"strbuf",
"=",
"c_char_p",
"(",
"llvmir"... | Create Module from a LLVM IR string | [
"Create",
"Module",
"from",
"a",
"LLVM",
"IR",
"string"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L12-L27 | train |
numba/llvmlite | llvmlite/binding/module.py | ModuleRef.as_bitcode | def as_bitcode(self):
"""
Return the module's LLVM bitcode, as a bytes object.
"""
ptr = c_char_p(None)
size = c_size_t(-1)
ffi.lib.LLVMPY_WriteBitcodeToString(self, byref(ptr), byref(size))
if not ptr:
raise MemoryError
try:
assert... | python | def as_bitcode(self):
"""
Return the module's LLVM bitcode, as a bytes object.
"""
ptr = c_char_p(None)
size = c_size_t(-1)
ffi.lib.LLVMPY_WriteBitcodeToString(self, byref(ptr), byref(size))
if not ptr:
raise MemoryError
try:
assert... | [
"def",
"as_bitcode",
"(",
"self",
")",
":",
"ptr",
"=",
"c_char_p",
"(",
"None",
")",
"size",
"=",
"c_size_t",
"(",
"-",
"1",
")",
"ffi",
".",
"lib",
".",
"LLVMPY_WriteBitcodeToString",
"(",
"self",
",",
"byref",
"(",
"ptr",
")",
",",
"byref",
"(",
... | Return the module's LLVM bitcode, as a bytes object. | [
"Return",
"the",
"module",
"s",
"LLVM",
"bitcode",
"as",
"a",
"bytes",
"object",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L62-L75 | train |
numba/llvmlite | llvmlite/binding/module.py | ModuleRef.verify | def verify(self):
"""
Verify the module IR's correctness. RuntimeError is raised on error.
"""
with ffi.OutputString() as outmsg:
if ffi.lib.LLVMPY_VerifyModule(self, outmsg):
raise RuntimeError(str(outmsg)) | python | def verify(self):
"""
Verify the module IR's correctness. RuntimeError is raised on error.
"""
with ffi.OutputString() as outmsg:
if ffi.lib.LLVMPY_VerifyModule(self, outmsg):
raise RuntimeError(str(outmsg)) | [
"def",
"verify",
"(",
"self",
")",
":",
"with",
"ffi",
".",
"OutputString",
"(",
")",
"as",
"outmsg",
":",
"if",
"ffi",
".",
"lib",
".",
"LLVMPY_VerifyModule",
"(",
"self",
",",
"outmsg",
")",
":",
"raise",
"RuntimeError",
"(",
"str",
"(",
"outmsg",
... | Verify the module IR's correctness. RuntimeError is raised on error. | [
"Verify",
"the",
"module",
"IR",
"s",
"correctness",
".",
"RuntimeError",
"is",
"raised",
"on",
"error",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L110-L116 | train |
numba/llvmlite | llvmlite/binding/module.py | ModuleRef.data_layout | def data_layout(self):
"""
This module's data layout specification, as a string.
"""
# LLVMGetDataLayout() points inside a std::string managed by LLVM.
with ffi.OutputString(owned=False) as outmsg:
ffi.lib.LLVMPY_GetDataLayout(self, outmsg)
return str(outm... | python | def data_layout(self):
"""
This module's data layout specification, as a string.
"""
# LLVMGetDataLayout() points inside a std::string managed by LLVM.
with ffi.OutputString(owned=False) as outmsg:
ffi.lib.LLVMPY_GetDataLayout(self, outmsg)
return str(outm... | [
"def",
"data_layout",
"(",
"self",
")",
":",
"# LLVMGetDataLayout() points inside a std::string managed by LLVM.",
"with",
"ffi",
".",
"OutputString",
"(",
"owned",
"=",
"False",
")",
"as",
"outmsg",
":",
"ffi",
".",
"lib",
".",
"LLVMPY_GetDataLayout",
"(",
"self",
... | This module's data layout specification, as a string. | [
"This",
"module",
"s",
"data",
"layout",
"specification",
"as",
"a",
"string",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L130-L137 | train |
numba/llvmlite | llvmlite/binding/module.py | ModuleRef.triple | def triple(self):
"""
This module's target "triple" specification, as a string.
"""
# LLVMGetTarget() points inside a std::string managed by LLVM.
with ffi.OutputString(owned=False) as outmsg:
ffi.lib.LLVMPY_GetTarget(self, outmsg)
return str(outmsg) | python | def triple(self):
"""
This module's target "triple" specification, as a string.
"""
# LLVMGetTarget() points inside a std::string managed by LLVM.
with ffi.OutputString(owned=False) as outmsg:
ffi.lib.LLVMPY_GetTarget(self, outmsg)
return str(outmsg) | [
"def",
"triple",
"(",
"self",
")",
":",
"# LLVMGetTarget() points inside a std::string managed by LLVM.",
"with",
"ffi",
".",
"OutputString",
"(",
"owned",
"=",
"False",
")",
"as",
"outmsg",
":",
"ffi",
".",
"lib",
".",
"LLVMPY_GetTarget",
"(",
"self",
",",
"out... | This module's target "triple" specification, as a string. | [
"This",
"module",
"s",
"target",
"triple",
"specification",
"as",
"a",
"string",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L146-L153 | train |
numba/llvmlite | llvmlite/binding/module.py | ModuleRef.global_variables | def global_variables(self):
"""
Return an iterator over this module's global variables.
The iterator will yield a ValueRef for each global variable.
Note that global variables don't include functions
(a function is a "global value" but not a "global variable" in
LLVM pa... | python | def global_variables(self):
"""
Return an iterator over this module's global variables.
The iterator will yield a ValueRef for each global variable.
Note that global variables don't include functions
(a function is a "global value" but not a "global variable" in
LLVM pa... | [
"def",
"global_variables",
"(",
"self",
")",
":",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_ModuleGlobalsIter",
"(",
"self",
")",
"return",
"_GlobalsIterator",
"(",
"it",
",",
"dict",
"(",
"module",
"=",
"self",
")",
")"
] | Return an iterator over this module's global variables.
The iterator will yield a ValueRef for each global variable.
Note that global variables don't include functions
(a function is a "global value" but not a "global variable" in
LLVM parlance) | [
"Return",
"an",
"iterator",
"over",
"this",
"module",
"s",
"global",
"variables",
".",
"The",
"iterator",
"will",
"yield",
"a",
"ValueRef",
"for",
"each",
"global",
"variable",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L171-L181 | train |
numba/llvmlite | llvmlite/binding/module.py | ModuleRef.functions | def functions(self):
"""
Return an iterator over this module's functions.
The iterator will yield a ValueRef for each function.
"""
it = ffi.lib.LLVMPY_ModuleFunctionsIter(self)
return _FunctionsIterator(it, dict(module=self)) | python | def functions(self):
"""
Return an iterator over this module's functions.
The iterator will yield a ValueRef for each function.
"""
it = ffi.lib.LLVMPY_ModuleFunctionsIter(self)
return _FunctionsIterator(it, dict(module=self)) | [
"def",
"functions",
"(",
"self",
")",
":",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_ModuleFunctionsIter",
"(",
"self",
")",
"return",
"_FunctionsIterator",
"(",
"it",
",",
"dict",
"(",
"module",
"=",
"self",
")",
")"
] | Return an iterator over this module's functions.
The iterator will yield a ValueRef for each function. | [
"Return",
"an",
"iterator",
"over",
"this",
"module",
"s",
"functions",
".",
"The",
"iterator",
"will",
"yield",
"a",
"ValueRef",
"for",
"each",
"function",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L184-L190 | train |
numba/llvmlite | llvmlite/binding/module.py | ModuleRef.struct_types | def struct_types(self):
"""
Return an iterator over the struct types defined in
the module. The iterator will yield a TypeRef.
"""
it = ffi.lib.LLVMPY_ModuleTypesIter(self)
return _TypesIterator(it, dict(module=self)) | python | def struct_types(self):
"""
Return an iterator over the struct types defined in
the module. The iterator will yield a TypeRef.
"""
it = ffi.lib.LLVMPY_ModuleTypesIter(self)
return _TypesIterator(it, dict(module=self)) | [
"def",
"struct_types",
"(",
"self",
")",
":",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_ModuleTypesIter",
"(",
"self",
")",
"return",
"_TypesIterator",
"(",
"it",
",",
"dict",
"(",
"module",
"=",
"self",
")",
")"
] | Return an iterator over the struct types defined in
the module. The iterator will yield a TypeRef. | [
"Return",
"an",
"iterator",
"over",
"the",
"struct",
"types",
"defined",
"in",
"the",
"module",
".",
"The",
"iterator",
"will",
"yield",
"a",
"TypeRef",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L193-L199 | train |
numba/llvmlite | llvmlite/binding/options.py | set_option | def set_option(name, option):
"""
Set the given LLVM "command-line" option.
For example set_option("test", "-debug-pass=Structure") would display
all optimization passes when generating code.
"""
ffi.lib.LLVMPY_SetCommandLine(_encode_string(name),
_encode_strin... | python | def set_option(name, option):
"""
Set the given LLVM "command-line" option.
For example set_option("test", "-debug-pass=Structure") would display
all optimization passes when generating code.
"""
ffi.lib.LLVMPY_SetCommandLine(_encode_string(name),
_encode_strin... | [
"def",
"set_option",
"(",
"name",
",",
"option",
")",
":",
"ffi",
".",
"lib",
".",
"LLVMPY_SetCommandLine",
"(",
"_encode_string",
"(",
"name",
")",
",",
"_encode_string",
"(",
"option",
")",
")"
] | Set the given LLVM "command-line" option.
For example set_option("test", "-debug-pass=Structure") would display
all optimization passes when generating code. | [
"Set",
"the",
"given",
"LLVM",
"command",
"-",
"line",
"option",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/options.py#L6-L14 | train |
numba/llvmlite | llvmlite/ir/types.py | Type._get_ll_pointer_type | def _get_ll_pointer_type(self, target_data, context=None):
"""
Convert this type object to an LLVM type.
"""
from . import Module, GlobalVariable
from ..binding import parse_assembly
if context is None:
m = Module()
else:
m = Module(contex... | python | def _get_ll_pointer_type(self, target_data, context=None):
"""
Convert this type object to an LLVM type.
"""
from . import Module, GlobalVariable
from ..binding import parse_assembly
if context is None:
m = Module()
else:
m = Module(contex... | [
"def",
"_get_ll_pointer_type",
"(",
"self",
",",
"target_data",
",",
"context",
"=",
"None",
")",
":",
"from",
".",
"import",
"Module",
",",
"GlobalVariable",
"from",
".",
".",
"binding",
"import",
"parse_assembly",
"if",
"context",
"is",
"None",
":",
"m",
... | Convert this type object to an LLVM type. | [
"Convert",
"this",
"type",
"object",
"to",
"an",
"LLVM",
"type",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/types.py#L35-L48 | train |
numba/llvmlite | llvmlite/ir/types.py | BaseStructType.structure_repr | def structure_repr(self):
"""
Return the LLVM IR for the structure representation
"""
ret = '{%s}' % ', '.join([str(x) for x in self.elements])
return self._wrap_packed(ret) | python | def structure_repr(self):
"""
Return the LLVM IR for the structure representation
"""
ret = '{%s}' % ', '.join([str(x) for x in self.elements])
return self._wrap_packed(ret) | [
"def",
"structure_repr",
"(",
"self",
")",
":",
"ret",
"=",
"'{%s}'",
"%",
"', '",
".",
"join",
"(",
"[",
"str",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"elements",
"]",
")",
"return",
"self",
".",
"_wrap_packed",
"(",
"ret",
")"
] | Return the LLVM IR for the structure representation | [
"Return",
"the",
"LLVM",
"IR",
"for",
"the",
"structure",
"representation"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/types.py#L477-L482 | train |
numba/llvmlite | llvmlite/ir/types.py | IdentifiedStructType.get_declaration | def get_declaration(self):
"""
Returns the string for the declaration of the type
"""
if self.is_opaque:
out = "{strrep} = type opaque".format(strrep=str(self))
else:
out = "{strrep} = type {struct}".format(
strrep=str(self), struct=self.st... | python | def get_declaration(self):
"""
Returns the string for the declaration of the type
"""
if self.is_opaque:
out = "{strrep} = type opaque".format(strrep=str(self))
else:
out = "{strrep} = type {struct}".format(
strrep=str(self), struct=self.st... | [
"def",
"get_declaration",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_opaque",
":",
"out",
"=",
"\"{strrep} = type opaque\"",
".",
"format",
"(",
"strrep",
"=",
"str",
"(",
"self",
")",
")",
"else",
":",
"out",
"=",
"\"{strrep} = type {struct}\"",
".",
"... | Returns the string for the declaration of the type | [
"Returns",
"the",
"string",
"for",
"the",
"declaration",
"of",
"the",
"type"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/types.py#L563-L572 | train |
numba/llvmlite | llvmlite/binding/ffi.py | ObjectRef.close | def close(self):
"""
Close this object and do any required clean-up actions.
"""
try:
if not self._closed and not self._owned:
self._dispose()
finally:
self.detach() | python | def close(self):
"""
Close this object and do any required clean-up actions.
"""
try:
if not self._closed and not self._owned:
self._dispose()
finally:
self.detach() | [
"def",
"close",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"self",
".",
"_closed",
"and",
"not",
"self",
".",
"_owned",
":",
"self",
".",
"_dispose",
"(",
")",
"finally",
":",
"self",
".",
"detach",
"(",
")"
] | Close this object and do any required clean-up actions. | [
"Close",
"this",
"object",
"and",
"do",
"any",
"required",
"clean",
"-",
"up",
"actions",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/ffi.py#L226-L234 | train |
numba/llvmlite | llvmlite/binding/ffi.py | ObjectRef.detach | def detach(self):
"""
Detach the underlying LLVM resource without disposing of it.
"""
if not self._closed:
del self._as_parameter_
self._closed = True
self._ptr = None | python | def detach(self):
"""
Detach the underlying LLVM resource without disposing of it.
"""
if not self._closed:
del self._as_parameter_
self._closed = True
self._ptr = None | [
"def",
"detach",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_closed",
":",
"del",
"self",
".",
"_as_parameter_",
"self",
".",
"_closed",
"=",
"True",
"self",
".",
"_ptr",
"=",
"None"
] | Detach the underlying LLVM resource without disposing of it. | [
"Detach",
"the",
"underlying",
"LLVM",
"resource",
"without",
"disposing",
"of",
"it",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/ffi.py#L236-L243 | train |
numba/llvmlite | llvmlite/binding/dylib.py | load_library_permanently | def load_library_permanently(filename):
"""
Load an external library
"""
with ffi.OutputString() as outerr:
if ffi.lib.LLVMPY_LoadLibraryPermanently(
_encode_string(filename), outerr):
raise RuntimeError(str(outerr)) | python | def load_library_permanently(filename):
"""
Load an external library
"""
with ffi.OutputString() as outerr:
if ffi.lib.LLVMPY_LoadLibraryPermanently(
_encode_string(filename), outerr):
raise RuntimeError(str(outerr)) | [
"def",
"load_library_permanently",
"(",
"filename",
")",
":",
"with",
"ffi",
".",
"OutputString",
"(",
")",
"as",
"outerr",
":",
"if",
"ffi",
".",
"lib",
".",
"LLVMPY_LoadLibraryPermanently",
"(",
"_encode_string",
"(",
"filename",
")",
",",
"outerr",
")",
"... | Load an external library | [
"Load",
"an",
"external",
"library"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/dylib.py#L23-L30 | train |
numba/llvmlite | ffi/build.py | find_win32_generator | def find_win32_generator():
"""
Find a suitable cmake "generator" under Windows.
"""
# XXX this assumes we will find a generator that's the same, or
# compatible with, the one which was used to compile LLVM... cmake
# seems a bit lacking here.
cmake_dir = os.path.join(here_dir, 'dummy')
... | python | def find_win32_generator():
"""
Find a suitable cmake "generator" under Windows.
"""
# XXX this assumes we will find a generator that's the same, or
# compatible with, the one which was used to compile LLVM... cmake
# seems a bit lacking here.
cmake_dir = os.path.join(here_dir, 'dummy')
... | [
"def",
"find_win32_generator",
"(",
")",
":",
"# XXX this assumes we will find a generator that's the same, or",
"# compatible with, the one which was used to compile LLVM... cmake",
"# seems a bit lacking here.",
"cmake_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"here_dir",
"... | Find a suitable cmake "generator" under Windows. | [
"Find",
"a",
"suitable",
"cmake",
"generator",
"under",
"Windows",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/ffi/build.py#L48-L84 | train |
numba/llvmlite | llvmlite/ir/values.py | _escape_string | def _escape_string(text, _map={}):
"""
Escape the given bytestring for safe use as a LLVM array constant.
"""
if isinstance(text, str):
text = text.encode('ascii')
assert isinstance(text, (bytes, bytearray))
if not _map:
for ch in range(256):
if ch in _VALID_CHARS:
... | python | def _escape_string(text, _map={}):
"""
Escape the given bytestring for safe use as a LLVM array constant.
"""
if isinstance(text, str):
text = text.encode('ascii')
assert isinstance(text, (bytes, bytearray))
if not _map:
for ch in range(256):
if ch in _VALID_CHARS:
... | [
"def",
"_escape_string",
"(",
"text",
",",
"_map",
"=",
"{",
"}",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"text",
"=",
"text",
".",
"encode",
"(",
"'ascii'",
")",
"assert",
"isinstance",
"(",
"text",
",",
"(",
"bytes",
",",... | Escape the given bytestring for safe use as a LLVM array constant. | [
"Escape",
"the",
"given",
"bytestring",
"for",
"safe",
"use",
"as",
"a",
"LLVM",
"array",
"constant",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L20-L38 | train |
numba/llvmlite | llvmlite/ir/values.py | _ConstOpMixin.bitcast | def bitcast(self, typ):
"""
Bitcast this pointer constant to the given type.
"""
if typ == self.type:
return self
op = "bitcast ({0} {1} to {2})".format(self.type, self.get_reference(),
typ)
return FormattedConsta... | python | def bitcast(self, typ):
"""
Bitcast this pointer constant to the given type.
"""
if typ == self.type:
return self
op = "bitcast ({0} {1} to {2})".format(self.type, self.get_reference(),
typ)
return FormattedConsta... | [
"def",
"bitcast",
"(",
"self",
",",
"typ",
")",
":",
"if",
"typ",
"==",
"self",
".",
"type",
":",
"return",
"self",
"op",
"=",
"\"bitcast ({0} {1} to {2})\"",
".",
"format",
"(",
"self",
".",
"type",
",",
"self",
".",
"get_reference",
"(",
")",
",",
... | Bitcast this pointer constant to the given type. | [
"Bitcast",
"this",
"pointer",
"constant",
"to",
"the",
"given",
"type",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L46-L54 | train |
numba/llvmlite | llvmlite/ir/values.py | _ConstOpMixin.inttoptr | def inttoptr(self, typ):
"""
Cast this integer constant to the given pointer type.
"""
if not isinstance(self.type, types.IntType):
raise TypeError("can only call inttoptr() on integer constants, not '%s'"
% (self.type,))
if not isinstance(... | python | def inttoptr(self, typ):
"""
Cast this integer constant to the given pointer type.
"""
if not isinstance(self.type, types.IntType):
raise TypeError("can only call inttoptr() on integer constants, not '%s'"
% (self.type,))
if not isinstance(... | [
"def",
"inttoptr",
"(",
"self",
",",
"typ",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"type",
",",
"types",
".",
"IntType",
")",
":",
"raise",
"TypeError",
"(",
"\"can only call inttoptr() on integer constants, not '%s'\"",
"%",
"(",
"self",
".",
... | Cast this integer constant to the given pointer type. | [
"Cast",
"this",
"integer",
"constant",
"to",
"the",
"given",
"pointer",
"type",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L56-L70 | train |
numba/llvmlite | llvmlite/ir/values.py | _ConstOpMixin.gep | def gep(self, indices):
"""
Call getelementptr on this pointer constant.
"""
if not isinstance(self.type, types.PointerType):
raise TypeError("can only call gep() on pointer constants, not '%s'"
% (self.type,))
outtype = self.type
... | python | def gep(self, indices):
"""
Call getelementptr on this pointer constant.
"""
if not isinstance(self.type, types.PointerType):
raise TypeError("can only call gep() on pointer constants, not '%s'"
% (self.type,))
outtype = self.type
... | [
"def",
"gep",
"(",
"self",
",",
"indices",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"type",
",",
"types",
".",
"PointerType",
")",
":",
"raise",
"TypeError",
"(",
"\"can only call gep() on pointer constants, not '%s'\"",
"%",
"(",
"self",
".",
... | Call getelementptr on this pointer constant. | [
"Call",
"getelementptr",
"on",
"this",
"pointer",
"constant",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L72-L90 | train |
numba/llvmlite | llvmlite/ir/values.py | Constant.literal_array | def literal_array(cls, elems):
"""
Construct a literal array constant made of the given members.
"""
tys = [el.type for el in elems]
if len(tys) == 0:
raise ValueError("need at least one element")
ty = tys[0]
for other in tys:
if ty != othe... | python | def literal_array(cls, elems):
"""
Construct a literal array constant made of the given members.
"""
tys = [el.type for el in elems]
if len(tys) == 0:
raise ValueError("need at least one element")
ty = tys[0]
for other in tys:
if ty != othe... | [
"def",
"literal_array",
"(",
"cls",
",",
"elems",
")",
":",
"tys",
"=",
"[",
"el",
".",
"type",
"for",
"el",
"in",
"elems",
"]",
"if",
"len",
"(",
"tys",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"need at least one element\"",
")",
"ty",
"="... | Construct a literal array constant made of the given members. | [
"Construct",
"a",
"literal",
"array",
"constant",
"made",
"of",
"the",
"given",
"members",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L147-L158 | train |
numba/llvmlite | llvmlite/ir/values.py | Constant.literal_struct | def literal_struct(cls, elems):
"""
Construct a literal structure constant made of the given members.
"""
tys = [el.type for el in elems]
return cls(types.LiteralStructType(tys), elems) | python | def literal_struct(cls, elems):
"""
Construct a literal structure constant made of the given members.
"""
tys = [el.type for el in elems]
return cls(types.LiteralStructType(tys), elems) | [
"def",
"literal_struct",
"(",
"cls",
",",
"elems",
")",
":",
"tys",
"=",
"[",
"el",
".",
"type",
"for",
"el",
"in",
"elems",
"]",
"return",
"cls",
"(",
"types",
".",
"LiteralStructType",
"(",
"tys",
")",
",",
"elems",
")"
] | Construct a literal structure constant made of the given members. | [
"Construct",
"a",
"literal",
"structure",
"constant",
"made",
"of",
"the",
"given",
"members",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L161-L166 | train |
numba/llvmlite | llvmlite/ir/values.py | Function.insert_basic_block | def insert_basic_block(self, before, name=''):
"""Insert block before
"""
blk = Block(parent=self, name=name)
self.blocks.insert(before, blk)
return blk | python | def insert_basic_block(self, before, name=''):
"""Insert block before
"""
blk = Block(parent=self, name=name)
self.blocks.insert(before, blk)
return blk | [
"def",
"insert_basic_block",
"(",
"self",
",",
"before",
",",
"name",
"=",
"''",
")",
":",
"blk",
"=",
"Block",
"(",
"parent",
"=",
"self",
",",
"name",
"=",
"name",
")",
"self",
".",
"blocks",
".",
"insert",
"(",
"before",
",",
"blk",
")",
"return... | Insert block before | [
"Insert",
"block",
"before"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L622-L627 | train |
numba/llvmlite | llvmlite/ir/values.py | Block.replace | def replace(self, old, new):
"""Replace an instruction"""
if old.type != new.type:
raise TypeError("new instruction has a different type")
pos = self.instructions.index(old)
self.instructions.remove(old)
self.instructions.insert(pos, new)
for bb in self.paren... | python | def replace(self, old, new):
"""Replace an instruction"""
if old.type != new.type:
raise TypeError("new instruction has a different type")
pos = self.instructions.index(old)
self.instructions.remove(old)
self.instructions.insert(pos, new)
for bb in self.paren... | [
"def",
"replace",
"(",
"self",
",",
"old",
",",
"new",
")",
":",
"if",
"old",
".",
"type",
"!=",
"new",
".",
"type",
":",
"raise",
"TypeError",
"(",
"\"new instruction has a different type\"",
")",
"pos",
"=",
"self",
".",
"instructions",
".",
"index",
"... | Replace an instruction | [
"Replace",
"an",
"instruction"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L796-L806 | train |
numba/llvmlite | llvmlite/binding/analysis.py | get_function_cfg | def get_function_cfg(func, show_inst=True):
"""Return a string of the control-flow graph of the function in DOT
format. If the input `func` is not a materialized function, the module
containing the function is parsed to create an actual LLVM module.
The `show_inst` flag controls whether the instructions... | python | def get_function_cfg(func, show_inst=True):
"""Return a string of the control-flow graph of the function in DOT
format. If the input `func` is not a materialized function, the module
containing the function is parsed to create an actual LLVM module.
The `show_inst` flag controls whether the instructions... | [
"def",
"get_function_cfg",
"(",
"func",
",",
"show_inst",
"=",
"True",
")",
":",
"assert",
"func",
"is",
"not",
"None",
"if",
"isinstance",
"(",
"func",
",",
"ir",
".",
"Function",
")",
":",
"mod",
"=",
"parse_assembly",
"(",
"str",
"(",
"func",
".",
... | Return a string of the control-flow graph of the function in DOT
format. If the input `func` is not a materialized function, the module
containing the function is parsed to create an actual LLVM module.
The `show_inst` flag controls whether the instructions of each block
are printed. | [
"Return",
"a",
"string",
"of",
"the",
"control",
"-",
"flow",
"graph",
"of",
"the",
"function",
"in",
"DOT",
"format",
".",
"If",
"the",
"input",
"func",
"is",
"not",
"a",
"materialized",
"function",
"the",
"module",
"containing",
"the",
"function",
"is",
... | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/analysis.py#L14-L29 | train |
numba/llvmlite | llvmlite/binding/analysis.py | view_dot_graph | def view_dot_graph(graph, filename=None, view=False):
"""
View the given DOT source. If view is True, the image is rendered
and viewed by the default application in the system. The file path of
the output is returned. If view is False, a graphviz.Source object is
returned. If view is False and t... | python | def view_dot_graph(graph, filename=None, view=False):
"""
View the given DOT source. If view is True, the image is rendered
and viewed by the default application in the system. The file path of
the output is returned. If view is False, a graphviz.Source object is
returned. If view is False and t... | [
"def",
"view_dot_graph",
"(",
"graph",
",",
"filename",
"=",
"None",
",",
"view",
"=",
"False",
")",
":",
"# Optionally depends on graphviz package",
"import",
"graphviz",
"as",
"gv",
"src",
"=",
"gv",
".",
"Source",
"(",
"graph",
")",
"if",
"view",
":",
"... | View the given DOT source. If view is True, the image is rendered
and viewed by the default application in the system. The file path of
the output is returned. If view is False, a graphviz.Source object is
returned. If view is False and the environment is in a IPython session,
an IPython image objec... | [
"View",
"the",
"given",
"DOT",
"source",
".",
"If",
"view",
"is",
"True",
"the",
"image",
"is",
"rendered",
"and",
"viewed",
"by",
"the",
"default",
"application",
"in",
"the",
"system",
".",
"The",
"file",
"path",
"of",
"the",
"output",
"is",
"returned"... | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/analysis.py#L32-L67 | train |
numba/llvmlite | llvmlite/binding/value.py | TypeRef.element_type | def element_type(self):
"""
Returns the pointed-to type. When the type is not a pointer,
raises exception.
"""
if not self.is_pointer:
raise ValueError("Type {} is not a pointer".format(self))
return TypeRef(ffi.lib.LLVMPY_GetElementType(self)) | python | def element_type(self):
"""
Returns the pointed-to type. When the type is not a pointer,
raises exception.
"""
if not self.is_pointer:
raise ValueError("Type {} is not a pointer".format(self))
return TypeRef(ffi.lib.LLVMPY_GetElementType(self)) | [
"def",
"element_type",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_pointer",
":",
"raise",
"ValueError",
"(",
"\"Type {} is not a pointer\"",
".",
"format",
"(",
"self",
")",
")",
"return",
"TypeRef",
"(",
"ffi",
".",
"lib",
".",
"LLVMPY_GetElementT... | Returns the pointed-to type. When the type is not a pointer,
raises exception. | [
"Returns",
"the",
"pointed",
"-",
"to",
"type",
".",
"When",
"the",
"type",
"is",
"not",
"a",
"pointer",
"raises",
"exception",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/value.py#L64-L71 | train |
numba/llvmlite | llvmlite/binding/value.py | ValueRef.add_function_attribute | def add_function_attribute(self, attr):
"""Only works on function value
Parameters
-----------
attr : str
attribute name
"""
if not self.is_function:
raise ValueError('expected function value, got %s' % (self._kind,))
attrname = str(attr)
... | python | def add_function_attribute(self, attr):
"""Only works on function value
Parameters
-----------
attr : str
attribute name
"""
if not self.is_function:
raise ValueError('expected function value, got %s' % (self._kind,))
attrname = str(attr)
... | [
"def",
"add_function_attribute",
"(",
"self",
",",
"attr",
")",
":",
"if",
"not",
"self",
".",
"is_function",
":",
"raise",
"ValueError",
"(",
"'expected function value, got %s'",
"%",
"(",
"self",
".",
"_kind",
",",
")",
")",
"attrname",
"=",
"str",
"(",
... | Only works on function value
Parameters
-----------
attr : str
attribute name | [
"Only",
"works",
"on",
"function",
"value"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/value.py#L181-L196 | train |
numba/llvmlite | llvmlite/binding/value.py | ValueRef.attributes | def attributes(self):
"""
Return an iterator over this value's attributes.
The iterator will yield a string for each attribute.
"""
itr = iter(())
if self.is_function:
it = ffi.lib.LLVMPY_FunctionAttributesIter(self)
itr = _AttributeListIterator(it... | python | def attributes(self):
"""
Return an iterator over this value's attributes.
The iterator will yield a string for each attribute.
"""
itr = iter(())
if self.is_function:
it = ffi.lib.LLVMPY_FunctionAttributesIter(self)
itr = _AttributeListIterator(it... | [
"def",
"attributes",
"(",
"self",
")",
":",
"itr",
"=",
"iter",
"(",
"(",
")",
")",
"if",
"self",
".",
"is_function",
":",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_FunctionAttributesIter",
"(",
"self",
")",
"itr",
"=",
"_AttributeListIterator",
"(",
... | Return an iterator over this value's attributes.
The iterator will yield a string for each attribute. | [
"Return",
"an",
"iterator",
"over",
"this",
"value",
"s",
"attributes",
".",
"The",
"iterator",
"will",
"yield",
"a",
"string",
"for",
"each",
"attribute",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/value.py#L218-L240 | train |
numba/llvmlite | llvmlite/binding/value.py | ValueRef.blocks | def blocks(self):
"""
Return an iterator over this function's blocks.
The iterator will yield a ValueRef for each block.
"""
if not self.is_function:
raise ValueError('expected function value, got %s' % (self._kind,))
it = ffi.lib.LLVMPY_FunctionBlocksIter(sel... | python | def blocks(self):
"""
Return an iterator over this function's blocks.
The iterator will yield a ValueRef for each block.
"""
if not self.is_function:
raise ValueError('expected function value, got %s' % (self._kind,))
it = ffi.lib.LLVMPY_FunctionBlocksIter(sel... | [
"def",
"blocks",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_function",
":",
"raise",
"ValueError",
"(",
"'expected function value, got %s'",
"%",
"(",
"self",
".",
"_kind",
",",
")",
")",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_FunctionBlocksI... | Return an iterator over this function's blocks.
The iterator will yield a ValueRef for each block. | [
"Return",
"an",
"iterator",
"over",
"this",
"function",
"s",
"blocks",
".",
"The",
"iterator",
"will",
"yield",
"a",
"ValueRef",
"for",
"each",
"block",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/value.py#L243-L253 | train |
numba/llvmlite | llvmlite/binding/value.py | ValueRef.arguments | def arguments(self):
"""
Return an iterator over this function's arguments.
The iterator will yield a ValueRef for each argument.
"""
if not self.is_function:
raise ValueError('expected function value, got %s' % (self._kind,))
it = ffi.lib.LLVMPY_FunctionArgum... | python | def arguments(self):
"""
Return an iterator over this function's arguments.
The iterator will yield a ValueRef for each argument.
"""
if not self.is_function:
raise ValueError('expected function value, got %s' % (self._kind,))
it = ffi.lib.LLVMPY_FunctionArgum... | [
"def",
"arguments",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_function",
":",
"raise",
"ValueError",
"(",
"'expected function value, got %s'",
"%",
"(",
"self",
".",
"_kind",
",",
")",
")",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_FunctionArgu... | Return an iterator over this function's arguments.
The iterator will yield a ValueRef for each argument. | [
"Return",
"an",
"iterator",
"over",
"this",
"function",
"s",
"arguments",
".",
"The",
"iterator",
"will",
"yield",
"a",
"ValueRef",
"for",
"each",
"argument",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/value.py#L256-L266 | train |
numba/llvmlite | llvmlite/binding/value.py | ValueRef.instructions | def instructions(self):
"""
Return an iterator over this block's instructions.
The iterator will yield a ValueRef for each instruction.
"""
if not self.is_block:
raise ValueError('expected block value, got %s' % (self._kind,))
it = ffi.lib.LLVMPY_BlockInstruct... | python | def instructions(self):
"""
Return an iterator over this block's instructions.
The iterator will yield a ValueRef for each instruction.
"""
if not self.is_block:
raise ValueError('expected block value, got %s' % (self._kind,))
it = ffi.lib.LLVMPY_BlockInstruct... | [
"def",
"instructions",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_block",
":",
"raise",
"ValueError",
"(",
"'expected block value, got %s'",
"%",
"(",
"self",
".",
"_kind",
",",
")",
")",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_BlockInstructio... | Return an iterator over this block's instructions.
The iterator will yield a ValueRef for each instruction. | [
"Return",
"an",
"iterator",
"over",
"this",
"block",
"s",
"instructions",
".",
"The",
"iterator",
"will",
"yield",
"a",
"ValueRef",
"for",
"each",
"instruction",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/value.py#L269-L279 | train |
numba/llvmlite | llvmlite/binding/value.py | ValueRef.operands | def operands(self):
"""
Return an iterator over this instruction's operands.
The iterator will yield a ValueRef for each operand.
"""
if not self.is_instruction:
raise ValueError('expected instruction value, got %s'
% (self._kind,))
... | python | def operands(self):
"""
Return an iterator over this instruction's operands.
The iterator will yield a ValueRef for each operand.
"""
if not self.is_instruction:
raise ValueError('expected instruction value, got %s'
% (self._kind,))
... | [
"def",
"operands",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_instruction",
":",
"raise",
"ValueError",
"(",
"'expected instruction value, got %s'",
"%",
"(",
"self",
".",
"_kind",
",",
")",
")",
"it",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_Instruc... | Return an iterator over this instruction's operands.
The iterator will yield a ValueRef for each operand. | [
"Return",
"an",
"iterator",
"over",
"this",
"instruction",
"s",
"operands",
".",
"The",
"iterator",
"will",
"yield",
"a",
"ValueRef",
"for",
"each",
"operand",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/value.py#L282-L293 | train |
numba/llvmlite | llvmlite/ir/transforms.py | replace_all_calls | def replace_all_calls(mod, orig, repl):
"""Replace all calls to `orig` to `repl` in module `mod`.
Returns the references to the returned calls
"""
rc = ReplaceCalls(orig, repl)
rc.visit(mod)
return rc.calls | python | def replace_all_calls(mod, orig, repl):
"""Replace all calls to `orig` to `repl` in module `mod`.
Returns the references to the returned calls
"""
rc = ReplaceCalls(orig, repl)
rc.visit(mod)
return rc.calls | [
"def",
"replace_all_calls",
"(",
"mod",
",",
"orig",
",",
"repl",
")",
":",
"rc",
"=",
"ReplaceCalls",
"(",
"orig",
",",
"repl",
")",
"rc",
".",
"visit",
"(",
"mod",
")",
"return",
"rc",
".",
"calls"
] | Replace all calls to `orig` to `repl` in module `mod`.
Returns the references to the returned calls | [
"Replace",
"all",
"calls",
"to",
"orig",
"to",
"repl",
"in",
"module",
"mod",
".",
"Returns",
"the",
"references",
"to",
"the",
"returned",
"calls"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/transforms.py#L58-L64 | train |
rm-hull/luma.oled | luma/oled/device/color.py | color_device.display | def display(self, image):
"""
Renders a 24-bit RGB image to the Color OLED display.
:param image: The image to render.
:type image: PIL.Image.Image
"""
assert(image.mode == self.mode)
assert(image.size == self.size)
image = self.preprocess(image)
... | python | def display(self, image):
"""
Renders a 24-bit RGB image to the Color OLED display.
:param image: The image to render.
:type image: PIL.Image.Image
"""
assert(image.mode == self.mode)
assert(image.size == self.size)
image = self.preprocess(image)
... | [
"def",
"display",
"(",
"self",
",",
"image",
")",
":",
"assert",
"(",
"image",
".",
"mode",
"==",
"self",
".",
"mode",
")",
"assert",
"(",
"image",
".",
"size",
"==",
"self",
".",
"size",
")",
"image",
"=",
"self",
".",
"preprocess",
"(",
"image",
... | Renders a 24-bit RGB image to the Color OLED display.
:param image: The image to render.
:type image: PIL.Image.Image | [
"Renders",
"a",
"24",
"-",
"bit",
"RGB",
"image",
"to",
"the",
"Color",
"OLED",
"display",
"."
] | 76055aa2ca486dc2f9def49754b74ffbccdc5491 | https://github.com/rm-hull/luma.oled/blob/76055aa2ca486dc2f9def49754b74ffbccdc5491/luma/oled/device/color.py#L68-L96 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/target.py | events_for_onchain_secretreveal | def events_for_onchain_secretreveal(
target_state: TargetTransferState,
channel_state: NettingChannelState,
block_number: BlockNumber,
block_hash: BlockHash,
) -> List[Event]:
""" Emits the event for revealing the secret on-chain if the transfer
can not be settled off-chain.
... | python | def events_for_onchain_secretreveal(
target_state: TargetTransferState,
channel_state: NettingChannelState,
block_number: BlockNumber,
block_hash: BlockHash,
) -> List[Event]:
""" Emits the event for revealing the secret on-chain if the transfer
can not be settled off-chain.
... | [
"def",
"events_for_onchain_secretreveal",
"(",
"target_state",
":",
"TargetTransferState",
",",
"channel_state",
":",
"NettingChannelState",
",",
"block_number",
":",
"BlockNumber",
",",
"block_hash",
":",
"BlockHash",
",",
")",
"->",
"List",
"[",
"Event",
"]",
":",... | Emits the event for revealing the secret on-chain if the transfer
can not be settled off-chain. | [
"Emits",
"the",
"event",
"for",
"revealing",
"the",
"secret",
"on",
"-",
"chain",
"if",
"the",
"transfer",
"can",
"not",
"be",
"settled",
"off",
"-",
"chain",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L59-L98 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/target.py | handle_inittarget | def handle_inittarget(
state_change: ActionInitTarget,
channel_state: NettingChannelState,
pseudo_random_generator: random.Random,
block_number: BlockNumber,
) -> TransitionResult[TargetTransferState]:
""" Handles an ActionInitTarget state change. """
transfer = state_change.tran... | python | def handle_inittarget(
state_change: ActionInitTarget,
channel_state: NettingChannelState,
pseudo_random_generator: random.Random,
block_number: BlockNumber,
) -> TransitionResult[TargetTransferState]:
""" Handles an ActionInitTarget state change. """
transfer = state_change.tran... | [
"def",
"handle_inittarget",
"(",
"state_change",
":",
"ActionInitTarget",
",",
"channel_state",
":",
"NettingChannelState",
",",
"pseudo_random_generator",
":",
"random",
".",
"Random",
",",
"block_number",
":",
"BlockNumber",
",",
")",
"->",
"TransitionResult",
"[",
... | Handles an ActionInitTarget state change. | [
"Handles",
"an",
"ActionInitTarget",
"state",
"change",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L101-L164 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/target.py | handle_offchain_secretreveal | def handle_offchain_secretreveal(
target_state: TargetTransferState,
state_change: ReceiveSecretReveal,
channel_state: NettingChannelState,
pseudo_random_generator: random.Random,
block_number: BlockNumber,
) -> TransitionResult[TargetTransferState]:
""" Validates and handles... | python | def handle_offchain_secretreveal(
target_state: TargetTransferState,
state_change: ReceiveSecretReveal,
channel_state: NettingChannelState,
pseudo_random_generator: random.Random,
block_number: BlockNumber,
) -> TransitionResult[TargetTransferState]:
""" Validates and handles... | [
"def",
"handle_offchain_secretreveal",
"(",
"target_state",
":",
"TargetTransferState",
",",
"state_change",
":",
"ReceiveSecretReveal",
",",
"channel_state",
":",
"NettingChannelState",
",",
"pseudo_random_generator",
":",
"random",
".",
"Random",
",",
"block_number",
":... | Validates and handles a ReceiveSecretReveal state change. | [
"Validates",
"and",
"handles",
"a",
"ReceiveSecretReveal",
"state",
"change",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L167-L212 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/target.py | handle_onchain_secretreveal | def handle_onchain_secretreveal(
target_state: TargetTransferState,
state_change: ContractReceiveSecretReveal,
channel_state: NettingChannelState,
) -> TransitionResult[TargetTransferState]:
""" Validates and handles a ContractReceiveSecretReveal state change. """
valid_secret = is_valid... | python | def handle_onchain_secretreveal(
target_state: TargetTransferState,
state_change: ContractReceiveSecretReveal,
channel_state: NettingChannelState,
) -> TransitionResult[TargetTransferState]:
""" Validates and handles a ContractReceiveSecretReveal state change. """
valid_secret = is_valid... | [
"def",
"handle_onchain_secretreveal",
"(",
"target_state",
":",
"TargetTransferState",
",",
"state_change",
":",
"ContractReceiveSecretReveal",
",",
"channel_state",
":",
"NettingChannelState",
",",
")",
"->",
"TransitionResult",
"[",
"TargetTransferState",
"]",
":",
"val... | Validates and handles a ContractReceiveSecretReveal state change. | [
"Validates",
"and",
"handles",
"a",
"ContractReceiveSecretReveal",
"state",
"change",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L215-L238 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/target.py | handle_unlock | def handle_unlock(
target_state: TargetTransferState,
state_change: ReceiveUnlock,
channel_state: NettingChannelState,
) -> TransitionResult[TargetTransferState]:
""" Handles a ReceiveUnlock state change. """
balance_proof_sender = state_change.balance_proof.sender
is_valid, events,... | python | def handle_unlock(
target_state: TargetTransferState,
state_change: ReceiveUnlock,
channel_state: NettingChannelState,
) -> TransitionResult[TargetTransferState]:
""" Handles a ReceiveUnlock state change. """
balance_proof_sender = state_change.balance_proof.sender
is_valid, events,... | [
"def",
"handle_unlock",
"(",
"target_state",
":",
"TargetTransferState",
",",
"state_change",
":",
"ReceiveUnlock",
",",
"channel_state",
":",
"NettingChannelState",
",",
")",
"->",
"TransitionResult",
"[",
"TargetTransferState",
"]",
":",
"balance_proof_sender",
"=",
... | Handles a ReceiveUnlock state change. | [
"Handles",
"a",
"ReceiveUnlock",
"state",
"change",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L241-L279 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/target.py | handle_block | def handle_block(
target_state: TargetTransferState,
channel_state: NettingChannelState,
block_number: BlockNumber,
block_hash: BlockHash,
) -> TransitionResult[TargetTransferState]:
""" After Raiden learns about a new block this function must be called to
handle expiration of th... | python | def handle_block(
target_state: TargetTransferState,
channel_state: NettingChannelState,
block_number: BlockNumber,
block_hash: BlockHash,
) -> TransitionResult[TargetTransferState]:
""" After Raiden learns about a new block this function must be called to
handle expiration of th... | [
"def",
"handle_block",
"(",
"target_state",
":",
"TargetTransferState",
",",
"channel_state",
":",
"NettingChannelState",
",",
"block_number",
":",
"BlockNumber",
",",
"block_hash",
":",
"BlockHash",
",",
")",
"->",
"TransitionResult",
"[",
"TargetTransferState",
"]",... | After Raiden learns about a new block this function must be called to
handle expiration of the hash time lock. | [
"After",
"Raiden",
"learns",
"about",
"a",
"new",
"block",
"this",
"function",
"must",
"be",
"called",
"to",
"handle",
"expiration",
"of",
"the",
"hash",
"time",
"lock",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L282-L322 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/target.py | state_transition | def state_transition(
target_state: Optional[TargetTransferState],
state_change: StateChange,
channel_state: NettingChannelState,
pseudo_random_generator: random.Random,
block_number: BlockNumber,
) -> TransitionResult[TargetTransferState]:
""" State machine for the target no... | python | def state_transition(
target_state: Optional[TargetTransferState],
state_change: StateChange,
channel_state: NettingChannelState,
pseudo_random_generator: random.Random,
block_number: BlockNumber,
) -> TransitionResult[TargetTransferState]:
""" State machine for the target no... | [
"def",
"state_transition",
"(",
"target_state",
":",
"Optional",
"[",
"TargetTransferState",
"]",
",",
"state_change",
":",
"StateChange",
",",
"channel_state",
":",
"NettingChannelState",
",",
"pseudo_random_generator",
":",
"random",
".",
"Random",
",",
"block_numbe... | State machine for the target node of a mediated transfer. | [
"State",
"machine",
"for",
"the",
"target",
"node",
"of",
"a",
"mediated",
"transfer",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L352-L426 | train |
raiden-network/raiden | raiden/encoding/messages.py | wrap | def wrap(data):
""" Try to decode data into a message, might return None if the data is invalid. """
try:
cmdid = data[0]
except IndexError:
log.warning('data is empty')
return None
try:
message_type = CMDID_MESSAGE[cmdid]
except KeyError:
log.error('unknown ... | python | def wrap(data):
""" Try to decode data into a message, might return None if the data is invalid. """
try:
cmdid = data[0]
except IndexError:
log.warning('data is empty')
return None
try:
message_type = CMDID_MESSAGE[cmdid]
except KeyError:
log.error('unknown ... | [
"def",
"wrap",
"(",
"data",
")",
":",
"try",
":",
"cmdid",
"=",
"data",
"[",
"0",
"]",
"except",
"IndexError",
":",
"log",
".",
"warning",
"(",
"'data is empty'",
")",
"return",
"None",
"try",
":",
"message_type",
"=",
"CMDID_MESSAGE",
"[",
"cmdid",
"]... | Try to decode data into a message, might return None if the data is invalid. | [
"Try",
"to",
"decode",
"data",
"into",
"a",
"message",
"might",
"return",
"None",
"if",
"the",
"data",
"is",
"invalid",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/encoding/messages.py#L286-L306 | train |
raiden-network/raiden | raiden/utils/solc.py | solidity_resolve_address | def solidity_resolve_address(hex_code, library_symbol, library_address):
""" Change the bytecode to use the given library address.
Args:
hex_code (bin): The bytecode encoded in hexadecimal.
library_name (str): The library that will be resolved.
library_address (str): The address of the ... | python | def solidity_resolve_address(hex_code, library_symbol, library_address):
""" Change the bytecode to use the given library address.
Args:
hex_code (bin): The bytecode encoded in hexadecimal.
library_name (str): The library that will be resolved.
library_address (str): The address of the ... | [
"def",
"solidity_resolve_address",
"(",
"hex_code",
",",
"library_symbol",
",",
"library_address",
")",
":",
"if",
"library_address",
".",
"startswith",
"(",
"'0x'",
")",
":",
"raise",
"ValueError",
"(",
"'Address should not contain the 0x prefix'",
")",
"try",
":",
... | Change the bytecode to use the given library address.
Args:
hex_code (bin): The bytecode encoded in hexadecimal.
library_name (str): The library that will be resolved.
library_address (str): The address of the library.
Returns:
bin: The bytecode encoded in hexadecimal with the ... | [
"Change",
"the",
"bytecode",
"to",
"use",
"the",
"given",
"library",
"address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/solc.py#L8-L32 | train |
raiden-network/raiden | raiden/utils/solc.py | solidity_library_symbol | def solidity_library_symbol(library_name):
""" Return the symbol used in the bytecode to represent the `library_name`. """
# the symbol is always 40 characters in length with the minimum of two
# leading and trailing underscores
length = min(len(library_name), 36)
library_piece = library_name[:leng... | python | def solidity_library_symbol(library_name):
""" Return the symbol used in the bytecode to represent the `library_name`. """
# the symbol is always 40 characters in length with the minimum of two
# leading and trailing underscores
length = min(len(library_name), 36)
library_piece = library_name[:leng... | [
"def",
"solidity_library_symbol",
"(",
"library_name",
")",
":",
"# the symbol is always 40 characters in length with the minimum of two",
"# leading and trailing underscores",
"length",
"=",
"min",
"(",
"len",
"(",
"library_name",
")",
",",
"36",
")",
"library_piece",
"=",
... | Return the symbol used in the bytecode to represent the `library_name`. | [
"Return",
"the",
"symbol",
"used",
"in",
"the",
"bytecode",
"to",
"represent",
"the",
"library_name",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/solc.py#L48-L60 | train |
raiden-network/raiden | raiden/utils/solc.py | compile_files_cwd | def compile_files_cwd(*args, **kwargs):
"""change working directory to contract's dir in order to avoid symbol
name conflicts"""
# get root directory of the contracts
compile_wd = os.path.commonprefix(args[0])
# edge case - compiling a single file
if os.path.isfile(compile_wd):
compile_w... | python | def compile_files_cwd(*args, **kwargs):
"""change working directory to contract's dir in order to avoid symbol
name conflicts"""
# get root directory of the contracts
compile_wd = os.path.commonprefix(args[0])
# edge case - compiling a single file
if os.path.isfile(compile_wd):
compile_w... | [
"def",
"compile_files_cwd",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# get root directory of the contracts",
"compile_wd",
"=",
"os",
".",
"path",
".",
"commonprefix",
"(",
"args",
"[",
"0",
"]",
")",
"# edge case - compiling a single file",
"if",
"... | change working directory to contract's dir in order to avoid symbol
name conflicts | [
"change",
"working",
"directory",
"to",
"contract",
"s",
"dir",
"in",
"order",
"to",
"avoid",
"symbol",
"name",
"conflicts"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/solc.py#L76-L104 | train |
raiden-network/raiden | raiden/accounts.py | AccountManager.get_privkey | def get_privkey(self, address: AddressHex, password: str) -> PrivateKey:
"""Find the keystore file for an account, unlock it and get the private key
Args:
address: The Ethereum address for which to find the keyfile in the system
password: Mostly for testing purposes. A password ... | python | def get_privkey(self, address: AddressHex, password: str) -> PrivateKey:
"""Find the keystore file for an account, unlock it and get the private key
Args:
address: The Ethereum address for which to find the keyfile in the system
password: Mostly for testing purposes. A password ... | [
"def",
"get_privkey",
"(",
"self",
",",
"address",
":",
"AddressHex",
",",
"password",
":",
"str",
")",
"->",
"PrivateKey",
":",
"address",
"=",
"add_0x_prefix",
"(",
"address",
")",
".",
"lower",
"(",
")",
"if",
"not",
"self",
".",
"address_in_keystore",
... | Find the keystore file for an account, unlock it and get the private key
Args:
address: The Ethereum address for which to find the keyfile in the system
password: Mostly for testing purposes. A password can be provided
as the function argument here. If it's no... | [
"Find",
"the",
"keystore",
"file",
"for",
"an",
"account",
"unlock",
"it",
"and",
"get",
"the",
"private",
"key"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L135-L155 | train |
raiden-network/raiden | raiden/accounts.py | Account.load | def load(cls, path: str, password: str = None) -> 'Account':
"""Load an account from a keystore file.
Args:
path: full path to the keyfile
password: the password to decrypt the key file or `None` to leave it encrypted
"""
with open(path) as f:
keystor... | python | def load(cls, path: str, password: str = None) -> 'Account':
"""Load an account from a keystore file.
Args:
path: full path to the keyfile
password: the password to decrypt the key file or `None` to leave it encrypted
"""
with open(path) as f:
keystor... | [
"def",
"load",
"(",
"cls",
",",
"path",
":",
"str",
",",
"password",
":",
"str",
"=",
"None",
")",
"->",
"'Account'",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"keystore",
"=",
"json",
".",
"load",
"(",
"f",
")",
"if",
"not",
"chec... | Load an account from a keystore file.
Args:
path: full path to the keyfile
password: the password to decrypt the key file or `None` to leave it encrypted | [
"Load",
"an",
"account",
"from",
"a",
"keystore",
"file",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L186-L197 | train |
raiden-network/raiden | raiden/accounts.py | Account.dump | def dump(self, include_address=True, include_id=True) -> str:
"""Dump the keystore for later disk storage.
The result inherits the entries `'crypto'` and `'version`' from `account.keystore`, and
adds `'address'` and `'id'` in accordance with the parameters `'include_address'` and
`'incl... | python | def dump(self, include_address=True, include_id=True) -> str:
"""Dump the keystore for later disk storage.
The result inherits the entries `'crypto'` and `'version`' from `account.keystore`, and
adds `'address'` and `'id'` in accordance with the parameters `'include_address'` and
`'incl... | [
"def",
"dump",
"(",
"self",
",",
"include_address",
"=",
"True",
",",
"include_id",
"=",
"True",
")",
"->",
"str",
":",
"d",
"=",
"{",
"'crypto'",
":",
"self",
".",
"keystore",
"[",
"'crypto'",
"]",
",",
"'version'",
":",
"self",
".",
"keystore",
"["... | Dump the keystore for later disk storage.
The result inherits the entries `'crypto'` and `'version`' from `account.keystore`, and
adds `'address'` and `'id'` in accordance with the parameters `'include_address'` and
`'include_id`'.
If address or id are not known, they are not added, ev... | [
"Dump",
"the",
"keystore",
"for",
"later",
"disk",
"storage",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L199-L220 | train |
raiden-network/raiden | raiden/accounts.py | Account.unlock | def unlock(self, password: str):
"""Unlock the account with a password.
If the account is already unlocked, nothing happens, even if the password is wrong.
Raises:
ValueError: (originating in ethereum.keys) if the password is wrong
(and the account is locked)
""... | python | def unlock(self, password: str):
"""Unlock the account with a password.
If the account is already unlocked, nothing happens, even if the password is wrong.
Raises:
ValueError: (originating in ethereum.keys) if the password is wrong
(and the account is locked)
""... | [
"def",
"unlock",
"(",
"self",
",",
"password",
":",
"str",
")",
":",
"if",
"self",
".",
"locked",
":",
"self",
".",
"_privkey",
"=",
"decode_keyfile_json",
"(",
"self",
".",
"keystore",
",",
"password",
".",
"encode",
"(",
"'UTF-8'",
")",
")",
"self",
... | Unlock the account with a password.
If the account is already unlocked, nothing happens, even if the password is wrong.
Raises:
ValueError: (originating in ethereum.keys) if the password is wrong
(and the account is locked) | [
"Unlock",
"the",
"account",
"with",
"a",
"password",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L222-L235 | train |
raiden-network/raiden | raiden/accounts.py | Account.uuid | def uuid(self, value):
"""Set the UUID. Set it to `None` in order to remove it."""
if value is not None:
self.keystore['id'] = value
elif 'id' in self.keystore:
self.keystore.pop('id') | python | def uuid(self, value):
"""Set the UUID. Set it to `None` in order to remove it."""
if value is not None:
self.keystore['id'] = value
elif 'id' in self.keystore:
self.keystore.pop('id') | [
"def",
"uuid",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"self",
".",
"keystore",
"[",
"'id'",
"]",
"=",
"value",
"elif",
"'id'",
"in",
"self",
".",
"keystore",
":",
"self",
".",
"keystore",
".",
"pop",
"(",
"'... | Set the UUID. Set it to `None` in order to remove it. | [
"Set",
"the",
"UUID",
".",
"Set",
"it",
"to",
"None",
"in",
"order",
"to",
"remove",
"it",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L289-L294 | train |
raiden-network/raiden | raiden/storage/migrations/v21_to_v22.py | recover_chain_id | def recover_chain_id(storage: SQLiteStorage) -> ChainID:
"""We can reasonably assume, that any database has only one value for `chain_id` at this point
in time.
"""
action_init_chain = json.loads(storage.get_state_changes(limit=1, offset=0)[0])
assert action_init_chain['_type'] == 'raiden.transfer.... | python | def recover_chain_id(storage: SQLiteStorage) -> ChainID:
"""We can reasonably assume, that any database has only one value for `chain_id` at this point
in time.
"""
action_init_chain = json.loads(storage.get_state_changes(limit=1, offset=0)[0])
assert action_init_chain['_type'] == 'raiden.transfer.... | [
"def",
"recover_chain_id",
"(",
"storage",
":",
"SQLiteStorage",
")",
"->",
"ChainID",
":",
"action_init_chain",
"=",
"json",
".",
"loads",
"(",
"storage",
".",
"get_state_changes",
"(",
"limit",
"=",
"1",
",",
"offset",
"=",
"0",
")",
"[",
"0",
"]",
")"... | We can reasonably assume, that any database has only one value for `chain_id` at this point
in time. | [
"We",
"can",
"reasonably",
"assume",
"that",
"any",
"database",
"has",
"only",
"one",
"value",
"for",
"chain_id",
"at",
"this",
"point",
"in",
"time",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v21_to_v22.py#L366-L373 | train |
raiden-network/raiden | tools/scenario-player/scenario_player/runner.py | ScenarioRunner.determine_run_number | def determine_run_number(self) -> int:
"""Determine the current run number.
We check for a run number file, and use any number that is logged
there after incrementing it.
"""
run_number = 0
run_number_file = self.data_path.joinpath('run_number.txt')
if run_number... | python | def determine_run_number(self) -> int:
"""Determine the current run number.
We check for a run number file, and use any number that is logged
there after incrementing it.
"""
run_number = 0
run_number_file = self.data_path.joinpath('run_number.txt')
if run_number... | [
"def",
"determine_run_number",
"(",
"self",
")",
"->",
"int",
":",
"run_number",
"=",
"0",
"run_number_file",
"=",
"self",
".",
"data_path",
".",
"joinpath",
"(",
"'run_number.txt'",
")",
"if",
"run_number_file",
".",
"exists",
"(",
")",
":",
"run_number",
"... | Determine the current run number.
We check for a run number file, and use any number that is logged
there after incrementing it. | [
"Determine",
"the",
"current",
"run",
"number",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/runner.py#L125-L137 | train |
raiden-network/raiden | tools/scenario-player/scenario_player/runner.py | ScenarioRunner.select_chain | def select_chain(self, chain_urls: Dict[str, List[str]]) -> Tuple[str, List[str]]:
"""Select a chain and return its name and RPC URL.
If the currently loaded scenario's designated chain is set to 'any',
we randomly select a chain from the given `chain_urls`.
Otherwise, we will return `S... | python | def select_chain(self, chain_urls: Dict[str, List[str]]) -> Tuple[str, List[str]]:
"""Select a chain and return its name and RPC URL.
If the currently loaded scenario's designated chain is set to 'any',
we randomly select a chain from the given `chain_urls`.
Otherwise, we will return `S... | [
"def",
"select_chain",
"(",
"self",
",",
"chain_urls",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
")",
"->",
"Tuple",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
":",
"chain_name",
"=",
"self",
".",
"scenario",
".",
"chain_name"... | Select a chain and return its name and RPC URL.
If the currently loaded scenario's designated chain is set to 'any',
we randomly select a chain from the given `chain_urls`.
Otherwise, we will return `ScenarioRunner.scenario.chain_name` and whatever value
may be associated with this key ... | [
"Select",
"a",
"chain",
"and",
"return",
"its",
"name",
"and",
"RPC",
"URL",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/runner.py#L139-L161 | train |
raiden-network/raiden | raiden/transfer/balance_proof.py | pack_balance_proof | def pack_balance_proof(
nonce: Nonce,
balance_hash: BalanceHash,
additional_hash: AdditionalHash,
canonical_identifier: CanonicalIdentifier,
msg_type: MessageTypeId = MessageTypeId.BALANCE_PROOF,
) -> bytes:
"""Packs balance proof data to be signed
Packs the given argume... | python | def pack_balance_proof(
nonce: Nonce,
balance_hash: BalanceHash,
additional_hash: AdditionalHash,
canonical_identifier: CanonicalIdentifier,
msg_type: MessageTypeId = MessageTypeId.BALANCE_PROOF,
) -> bytes:
"""Packs balance proof data to be signed
Packs the given argume... | [
"def",
"pack_balance_proof",
"(",
"nonce",
":",
"Nonce",
",",
"balance_hash",
":",
"BalanceHash",
",",
"additional_hash",
":",
"AdditionalHash",
",",
"canonical_identifier",
":",
"CanonicalIdentifier",
",",
"msg_type",
":",
"MessageTypeId",
"=",
"MessageTypeId",
".",
... | Packs balance proof data to be signed
Packs the given arguments in a byte array in the same configuration the
contracts expect the signed data to have. | [
"Packs",
"balance",
"proof",
"data",
"to",
"be",
"signed"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/balance_proof.py#L7-L35 | train |
raiden-network/raiden | raiden/transfer/balance_proof.py | pack_balance_proof_update | def pack_balance_proof_update(
nonce: Nonce,
balance_hash: BalanceHash,
additional_hash: AdditionalHash,
canonical_identifier: CanonicalIdentifier,
partner_signature: Signature,
) -> bytes:
"""Packs balance proof data to be signed for updateNonClosingBalanceProof
Packs t... | python | def pack_balance_proof_update(
nonce: Nonce,
balance_hash: BalanceHash,
additional_hash: AdditionalHash,
canonical_identifier: CanonicalIdentifier,
partner_signature: Signature,
) -> bytes:
"""Packs balance proof data to be signed for updateNonClosingBalanceProof
Packs t... | [
"def",
"pack_balance_proof_update",
"(",
"nonce",
":",
"Nonce",
",",
"balance_hash",
":",
"BalanceHash",
",",
"additional_hash",
":",
"AdditionalHash",
",",
"canonical_identifier",
":",
"CanonicalIdentifier",
",",
"partner_signature",
":",
"Signature",
",",
")",
"->",... | Packs balance proof data to be signed for updateNonClosingBalanceProof
Packs the given arguments in a byte array in the same configuration the
contracts expect the signed data for updateNonClosingBalanceProof to have. | [
"Packs",
"balance",
"proof",
"data",
"to",
"be",
"signed",
"for",
"updateNonClosingBalanceProof"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/balance_proof.py#L38-L56 | train |
raiden-network/raiden | raiden/network/transport/udp/healthcheck.py | healthcheck | def healthcheck(
transport: 'UDPTransport',
recipient: Address,
stop_event: Event,
event_healthy: Event,
event_unhealthy: Event,
nat_keepalive_retries: int,
nat_keepalive_timeout: int,
nat_invitation_timeout: int,
ping_nonce: Dict[str, Nonce],
):
... | python | def healthcheck(
transport: 'UDPTransport',
recipient: Address,
stop_event: Event,
event_healthy: Event,
event_unhealthy: Event,
nat_keepalive_retries: int,
nat_keepalive_timeout: int,
nat_invitation_timeout: int,
ping_nonce: Dict[str, Nonce],
):
... | [
"def",
"healthcheck",
"(",
"transport",
":",
"'UDPTransport'",
",",
"recipient",
":",
"Address",
",",
"stop_event",
":",
"Event",
",",
"event_healthy",
":",
"Event",
",",
"event_unhealthy",
":",
"Event",
",",
"nat_keepalive_retries",
":",
"int",
",",
"nat_keepal... | Sends a periodical Ping to `recipient` to check its health. | [
"Sends",
"a",
"periodical",
"Ping",
"to",
"recipient",
"to",
"check",
"its",
"health",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/healthcheck.py#L32-L171 | train |
raiden-network/raiden | raiden/network/proxies/token_network_registry.py | TokenNetworkRegistry.get_token_network | def get_token_network(
self,
token_address: TokenAddress,
block_identifier: BlockSpecification = 'latest',
) -> Optional[Address]:
""" Return the token network address for the given token or None if
there is no correspoding address.
"""
if not isin... | python | def get_token_network(
self,
token_address: TokenAddress,
block_identifier: BlockSpecification = 'latest',
) -> Optional[Address]:
""" Return the token network address for the given token or None if
there is no correspoding address.
"""
if not isin... | [
"def",
"get_token_network",
"(",
"self",
",",
"token_address",
":",
"TokenAddress",
",",
"block_identifier",
":",
"BlockSpecification",
"=",
"'latest'",
",",
")",
"->",
"Optional",
"[",
"Address",
"]",
":",
"if",
"not",
"isinstance",
"(",
"token_address",
",",
... | Return the token network address for the given token or None if
there is no correspoding address. | [
"Return",
"the",
"token",
"network",
"address",
"for",
"the",
"given",
"token",
"or",
"None",
"if",
"there",
"is",
"no",
"correspoding",
"address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network_registry.py#L79-L98 | train |
raiden-network/raiden | raiden/network/proxies/token_network_registry.py | TokenNetworkRegistry.add_token_with_limits | def add_token_with_limits(
self,
token_address: TokenAddress,
channel_participant_deposit_limit: TokenAmount,
token_network_deposit_limit: TokenAmount,
) -> Address:
"""
Register token of `token_address` with the token network.
The limits apply... | python | def add_token_with_limits(
self,
token_address: TokenAddress,
channel_participant_deposit_limit: TokenAmount,
token_network_deposit_limit: TokenAmount,
) -> Address:
"""
Register token of `token_address` with the token network.
The limits apply... | [
"def",
"add_token_with_limits",
"(",
"self",
",",
"token_address",
":",
"TokenAddress",
",",
"channel_participant_deposit_limit",
":",
"TokenAmount",
",",
"token_network_deposit_limit",
":",
"TokenAmount",
",",
")",
"->",
"Address",
":",
"return",
"self",
".",
"_add_t... | Register token of `token_address` with the token network.
The limits apply for version 0.13.0 and above of raiden-contracts,
since instantiation also takes the limits as constructor arguments. | [
"Register",
"token",
"of",
"token_address",
"with",
"the",
"token",
"network",
".",
"The",
"limits",
"apply",
"for",
"version",
"0",
".",
"13",
".",
"0",
"and",
"above",
"of",
"raiden",
"-",
"contracts",
"since",
"instantiation",
"also",
"takes",
"the",
"l... | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network_registry.py#L100-L117 | train |
raiden-network/raiden | raiden/network/proxies/token_network_registry.py | TokenNetworkRegistry.add_token_without_limits | def add_token_without_limits(
self,
token_address: TokenAddress,
) -> Address:
"""
Register token of `token_address` with the token network.
This applies for versions prior to 0.13.0 of raiden-contracts,
since limits were hardcoded into the TokenNetwork contra... | python | def add_token_without_limits(
self,
token_address: TokenAddress,
) -> Address:
"""
Register token of `token_address` with the token network.
This applies for versions prior to 0.13.0 of raiden-contracts,
since limits were hardcoded into the TokenNetwork contra... | [
"def",
"add_token_without_limits",
"(",
"self",
",",
"token_address",
":",
"TokenAddress",
",",
")",
"->",
"Address",
":",
"return",
"self",
".",
"_add_token",
"(",
"token_address",
"=",
"token_address",
",",
"additional_arguments",
"=",
"dict",
"(",
")",
",",
... | Register token of `token_address` with the token network.
This applies for versions prior to 0.13.0 of raiden-contracts,
since limits were hardcoded into the TokenNetwork contract. | [
"Register",
"token",
"of",
"token_address",
"with",
"the",
"token",
"network",
".",
"This",
"applies",
"for",
"versions",
"prior",
"to",
"0",
".",
"13",
".",
"0",
"of",
"raiden",
"-",
"contracts",
"since",
"limits",
"were",
"hardcoded",
"into",
"the",
"Tok... | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network_registry.py#L119-L131 | train |
raiden-network/raiden | raiden/network/utils.py | get_free_port | def get_free_port(
initial_port: int = 0,
socket_kind: SocketKind = SocketKind.SOCK_STREAM,
reliable: bool = True,
):
"""
Find an unused TCP port.
Unless the `reliable` parameter is set to `True` (the default) this is prone to race
conditions - some other process may grab the po... | python | def get_free_port(
initial_port: int = 0,
socket_kind: SocketKind = SocketKind.SOCK_STREAM,
reliable: bool = True,
):
"""
Find an unused TCP port.
Unless the `reliable` parameter is set to `True` (the default) this is prone to race
conditions - some other process may grab the po... | [
"def",
"get_free_port",
"(",
"initial_port",
":",
"int",
"=",
"0",
",",
"socket_kind",
":",
"SocketKind",
"=",
"SocketKind",
".",
"SOCK_STREAM",
",",
"reliable",
":",
"bool",
"=",
"True",
",",
")",
":",
"def",
"_port_generator",
"(",
")",
":",
"if",
"ini... | Find an unused TCP port.
Unless the `reliable` parameter is set to `True` (the default) this is prone to race
conditions - some other process may grab the port before the caller of this function has
a chance to use it.
When using `reliable` the port is forced into TIME_WAIT mode, ensuring that it will ... | [
"Find",
"an",
"unused",
"TCP",
"port",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/utils.py#L13-L64 | train |
raiden-network/raiden | raiden/network/utils.py | get_http_rtt | def get_http_rtt(
url: str,
samples: int = 3,
method: str = 'head',
timeout: int = 1,
) -> Optional[float]:
"""
Determine the average HTTP RTT to `url` over the number of `samples`.
Returns `None` if the server is unreachable.
"""
durations = []
for _ in range(sam... | python | def get_http_rtt(
url: str,
samples: int = 3,
method: str = 'head',
timeout: int = 1,
) -> Optional[float]:
"""
Determine the average HTTP RTT to `url` over the number of `samples`.
Returns `None` if the server is unreachable.
"""
durations = []
for _ in range(sam... | [
"def",
"get_http_rtt",
"(",
"url",
":",
"str",
",",
"samples",
":",
"int",
"=",
"3",
",",
"method",
":",
"str",
"=",
"'head'",
",",
"timeout",
":",
"int",
"=",
"1",
",",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"durations",
"=",
"[",
"]",
... | Determine the average HTTP RTT to `url` over the number of `samples`.
Returns `None` if the server is unreachable. | [
"Determine",
"the",
"average",
"HTTP",
"RTT",
"to",
"url",
"over",
"the",
"number",
"of",
"samples",
".",
"Returns",
"None",
"if",
"the",
"server",
"is",
"unreachable",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/utils.py#L67-L90 | train |
raiden-network/raiden | raiden/storage/migrations/v18_to_v19.py | _add_blockhash_to_state_changes | def _add_blockhash_to_state_changes(storage: SQLiteStorage, cache: BlockHashCache) -> None:
"""Adds blockhash to ContractReceiveXXX and ActionInitChain state changes"""
batch_size = 50
batch_query = storage.batch_query_state_changes(
batch_size=batch_size,
filters=[
('_type', 'r... | python | def _add_blockhash_to_state_changes(storage: SQLiteStorage, cache: BlockHashCache) -> None:
"""Adds blockhash to ContractReceiveXXX and ActionInitChain state changes"""
batch_size = 50
batch_query = storage.batch_query_state_changes(
batch_size=batch_size,
filters=[
('_type', 'r... | [
"def",
"_add_blockhash_to_state_changes",
"(",
"storage",
":",
"SQLiteStorage",
",",
"cache",
":",
"BlockHashCache",
")",
"->",
"None",
":",
"batch_size",
"=",
"50",
"batch_query",
"=",
"storage",
".",
"batch_query_state_changes",
"(",
"batch_size",
"=",
"batch_size... | Adds blockhash to ContractReceiveXXX and ActionInitChain state changes | [
"Adds",
"blockhash",
"to",
"ContractReceiveXXX",
"and",
"ActionInitChain",
"state",
"changes"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L53-L90 | train |
raiden-network/raiden | raiden/storage/migrations/v18_to_v19.py | _add_blockhash_to_events | def _add_blockhash_to_events(storage: SQLiteStorage, cache: BlockHashCache) -> None:
"""Adds blockhash to all ContractSendXXX events"""
batch_query = storage.batch_query_event_records(
batch_size=500,
filters=[('_type', 'raiden.transfer.events.ContractSend%')],
)
for events_batch in batc... | python | def _add_blockhash_to_events(storage: SQLiteStorage, cache: BlockHashCache) -> None:
"""Adds blockhash to all ContractSendXXX events"""
batch_query = storage.batch_query_event_records(
batch_size=500,
filters=[('_type', 'raiden.transfer.events.ContractSend%')],
)
for events_batch in batc... | [
"def",
"_add_blockhash_to_events",
"(",
"storage",
":",
"SQLiteStorage",
",",
"cache",
":",
"BlockHashCache",
")",
"->",
"None",
":",
"batch_query",
"=",
"storage",
".",
"batch_query_event_records",
"(",
"batch_size",
"=",
"500",
",",
"filters",
"=",
"[",
"(",
... | Adds blockhash to all ContractSendXXX events | [
"Adds",
"blockhash",
"to",
"all",
"ContractSendXXX",
"events"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L93-L125 | train |
raiden-network/raiden | raiden/storage/migrations/v18_to_v19.py | _transform_snapshot | def _transform_snapshot(
raw_snapshot: str,
storage: SQLiteStorage,
cache: BlockHashCache,
) -> str:
"""Upgrades a single snapshot by adding the blockhash to it and to any pending transactions"""
snapshot = json.loads(raw_snapshot)
block_number = int(snapshot['block_number'])
sna... | python | def _transform_snapshot(
raw_snapshot: str,
storage: SQLiteStorage,
cache: BlockHashCache,
) -> str:
"""Upgrades a single snapshot by adding the blockhash to it and to any pending transactions"""
snapshot = json.loads(raw_snapshot)
block_number = int(snapshot['block_number'])
sna... | [
"def",
"_transform_snapshot",
"(",
"raw_snapshot",
":",
"str",
",",
"storage",
":",
"SQLiteStorage",
",",
"cache",
":",
"BlockHashCache",
",",
")",
"->",
"str",
":",
"snapshot",
"=",
"json",
".",
"loads",
"(",
"raw_snapshot",
")",
"block_number",
"=",
"int",... | Upgrades a single snapshot by adding the blockhash to it and to any pending transactions | [
"Upgrades",
"a",
"single",
"snapshot",
"by",
"adding",
"the",
"blockhash",
"to",
"it",
"and",
"to",
"any",
"pending",
"transactions"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L128-L162 | train |
raiden-network/raiden | raiden/storage/migrations/v18_to_v19.py | _transform_snapshots_for_blockhash | def _transform_snapshots_for_blockhash(storage: SQLiteStorage, cache: BlockHashCache) -> None:
"""Upgrades the snapshots by adding the blockhash to it and to any pending transactions"""
snapshots = storage.get_snapshots()
snapshot_records = [
TransformSnapshotRecord(
data=snapshot.data,... | python | def _transform_snapshots_for_blockhash(storage: SQLiteStorage, cache: BlockHashCache) -> None:
"""Upgrades the snapshots by adding the blockhash to it and to any pending transactions"""
snapshots = storage.get_snapshots()
snapshot_records = [
TransformSnapshotRecord(
data=snapshot.data,... | [
"def",
"_transform_snapshots_for_blockhash",
"(",
"storage",
":",
"SQLiteStorage",
",",
"cache",
":",
"BlockHashCache",
")",
"->",
"None",
":",
"snapshots",
"=",
"storage",
".",
"get_snapshots",
"(",
")",
"snapshot_records",
"=",
"[",
"TransformSnapshotRecord",
"(",... | Upgrades the snapshots by adding the blockhash to it and to any pending transactions | [
"Upgrades",
"the",
"snapshots",
"by",
"adding",
"the",
"blockhash",
"to",
"it",
"and",
"to",
"any",
"pending",
"transactions"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L181-L201 | train |
raiden-network/raiden | raiden/storage/migrations/v18_to_v19.py | BlockHashCache.get | def get(self, block_number: BlockNumber) -> str:
"""Given a block number returns the hex representation of the blockhash"""
if block_number in self.mapping:
return self.mapping[block_number]
block_hash = self.web3.eth.getBlock(block_number)['hash']
block_hash = block_hash.he... | python | def get(self, block_number: BlockNumber) -> str:
"""Given a block number returns the hex representation of the blockhash"""
if block_number in self.mapping:
return self.mapping[block_number]
block_hash = self.web3.eth.getBlock(block_number)['hash']
block_hash = block_hash.he... | [
"def",
"get",
"(",
"self",
",",
"block_number",
":",
"BlockNumber",
")",
"->",
"str",
":",
"if",
"block_number",
"in",
"self",
".",
"mapping",
":",
"return",
"self",
".",
"mapping",
"[",
"block_number",
"]",
"block_hash",
"=",
"self",
".",
"web3",
".",
... | Given a block number returns the hex representation of the blockhash | [
"Given",
"a",
"block",
"number",
"returns",
"the",
"hex",
"representation",
"of",
"the",
"blockhash"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L27-L35 | train |
raiden-network/raiden | raiden/utils/gas_reserve.py | has_enough_gas_reserve | def has_enough_gas_reserve(
raiden,
channels_to_open: int = 0,
) -> Tuple[bool, int]:
""" Checks if the account has enough balance to handle the lifecycles of all
open channels as well as the to be created channels.
Note: This is just an estimation.
Args:
raiden: A raiden servi... | python | def has_enough_gas_reserve(
raiden,
channels_to_open: int = 0,
) -> Tuple[bool, int]:
""" Checks if the account has enough balance to handle the lifecycles of all
open channels as well as the to be created channels.
Note: This is just an estimation.
Args:
raiden: A raiden servi... | [
"def",
"has_enough_gas_reserve",
"(",
"raiden",
",",
"channels_to_open",
":",
"int",
"=",
"0",
",",
")",
"->",
"Tuple",
"[",
"bool",
",",
"int",
"]",
":",
"secure_reserve_estimate",
"=",
"get_reserve_estimate",
"(",
"raiden",
",",
"channels_to_open",
")",
"cur... | Checks if the account has enough balance to handle the lifecycles of all
open channels as well as the to be created channels.
Note: This is just an estimation.
Args:
raiden: A raiden service instance
channels_to_open: The number of new channels that should be opened
Returns:
T... | [
"Checks",
"if",
"the",
"account",
"has",
"enough",
"balance",
"to",
"handle",
"the",
"lifecycles",
"of",
"all",
"open",
"channels",
"as",
"well",
"as",
"the",
"to",
"be",
"created",
"channels",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/gas_reserve.py#L126-L147 | train |
raiden-network/raiden | raiden/transfer/merkle_tree.py | hash_pair | def hash_pair(first: Keccak256, second: Optional[Keccak256]) -> Keccak256:
""" Computes the keccak hash of the elements ordered topologically.
Since a merkle proof will not include all the elements, but only the path
starting from the leaves up to the root, the order of the elements is not
known by the... | python | def hash_pair(first: Keccak256, second: Optional[Keccak256]) -> Keccak256:
""" Computes the keccak hash of the elements ordered topologically.
Since a merkle proof will not include all the elements, but only the path
starting from the leaves up to the root, the order of the elements is not
known by the... | [
"def",
"hash_pair",
"(",
"first",
":",
"Keccak256",
",",
"second",
":",
"Optional",
"[",
"Keccak256",
"]",
")",
"->",
"Keccak256",
":",
"assert",
"first",
"is",
"not",
"None",
"if",
"second",
"is",
"None",
":",
"return",
"first",
"if",
"first",
">",
"s... | Computes the keccak hash of the elements ordered topologically.
Since a merkle proof will not include all the elements, but only the path
starting from the leaves up to the root, the order of the elements is not
known by the proof checker. The topological order is used as a
deterministic way of orderin... | [
"Computes",
"the",
"keccak",
"hash",
"of",
"the",
"elements",
"ordered",
"topologically",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L16-L33 | train |
raiden-network/raiden | raiden/transfer/merkle_tree.py | compute_layers | def compute_layers(elements: List[Keccak256]) -> List[List[Keccak256]]:
""" Computes the layers of the merkletree.
First layer is the list of elements and the last layer is a list with a
single entry, the merkleroot.
"""
elements = list(elements) # consume generators
assert elements, 'Use mak... | python | def compute_layers(elements: List[Keccak256]) -> List[List[Keccak256]]:
""" Computes the layers of the merkletree.
First layer is the list of elements and the last layer is a list with a
single entry, the merkleroot.
"""
elements = list(elements) # consume generators
assert elements, 'Use mak... | [
"def",
"compute_layers",
"(",
"elements",
":",
"List",
"[",
"Keccak256",
"]",
")",
"->",
"List",
"[",
"List",
"[",
"Keccak256",
"]",
"]",
":",
"elements",
"=",
"list",
"(",
"elements",
")",
"# consume generators",
"assert",
"elements",
",",
"'Use make_empty_... | Computes the layers of the merkletree.
First layer is the list of elements and the last layer is a list with a
single entry, the merkleroot. | [
"Computes",
"the",
"layers",
"of",
"the",
"merkletree",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L36-L64 | train |
raiden-network/raiden | raiden/transfer/merkle_tree.py | compute_merkleproof_for | def compute_merkleproof_for(merkletree: 'MerkleTreeState', element: Keccak256) -> List[Keccak256]:
""" Containment proof for element.
The proof contains only the entries that are sufficient to recompute the
merkleroot, from the leaf `element` up to `root`.
Raises:
IndexError: If the element is... | python | def compute_merkleproof_for(merkletree: 'MerkleTreeState', element: Keccak256) -> List[Keccak256]:
""" Containment proof for element.
The proof contains only the entries that are sufficient to recompute the
merkleroot, from the leaf `element` up to `root`.
Raises:
IndexError: If the element is... | [
"def",
"compute_merkleproof_for",
"(",
"merkletree",
":",
"'MerkleTreeState'",
",",
"element",
":",
"Keccak256",
")",
"->",
"List",
"[",
"Keccak256",
"]",
":",
"idx",
"=",
"merkletree",
".",
"layers",
"[",
"LEAVES",
"]",
".",
"index",
"(",
"element",
")",
... | Containment proof for element.
The proof contains only the entries that are sufficient to recompute the
merkleroot, from the leaf `element` up to `root`.
Raises:
IndexError: If the element is not part of the merkletree. | [
"Containment",
"proof",
"for",
"element",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L67-L92 | train |
raiden-network/raiden | raiden/transfer/merkle_tree.py | validate_proof | def validate_proof(proof: List[Keccak256], root: Keccak256, leaf_element: Keccak256) -> bool:
""" Checks that `leaf_element` was contained in the tree represented by
`merkleroot`.
"""
hash_ = leaf_element
for pair in proof:
hash_ = hash_pair(hash_, pair)
return hash_ == root | python | def validate_proof(proof: List[Keccak256], root: Keccak256, leaf_element: Keccak256) -> bool:
""" Checks that `leaf_element` was contained in the tree represented by
`merkleroot`.
"""
hash_ = leaf_element
for pair in proof:
hash_ = hash_pair(hash_, pair)
return hash_ == root | [
"def",
"validate_proof",
"(",
"proof",
":",
"List",
"[",
"Keccak256",
"]",
",",
"root",
":",
"Keccak256",
",",
"leaf_element",
":",
"Keccak256",
")",
"->",
"bool",
":",
"hash_",
"=",
"leaf_element",
"for",
"pair",
"in",
"proof",
":",
"hash_",
"=",
"hash_... | Checks that `leaf_element` was contained in the tree represented by
`merkleroot`. | [
"Checks",
"that",
"leaf_element",
"was",
"contained",
"in",
"the",
"tree",
"represented",
"by",
"merkleroot",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L95-L104 | train |
raiden-network/raiden | raiden/transfer/merkle_tree.py | merkleroot | def merkleroot(merkletree: 'MerkleTreeState') -> Locksroot:
""" Return the root element of the merkle tree. """
assert merkletree.layers, 'the merkle tree layers are empty'
assert merkletree.layers[MERKLEROOT], 'the root layer is empty'
return Locksroot(merkletree.layers[MERKLEROOT][0]) | python | def merkleroot(merkletree: 'MerkleTreeState') -> Locksroot:
""" Return the root element of the merkle tree. """
assert merkletree.layers, 'the merkle tree layers are empty'
assert merkletree.layers[MERKLEROOT], 'the root layer is empty'
return Locksroot(merkletree.layers[MERKLEROOT][0]) | [
"def",
"merkleroot",
"(",
"merkletree",
":",
"'MerkleTreeState'",
")",
"->",
"Locksroot",
":",
"assert",
"merkletree",
".",
"layers",
",",
"'the merkle tree layers are empty'",
"assert",
"merkletree",
".",
"layers",
"[",
"MERKLEROOT",
"]",
",",
"'the root layer is emp... | Return the root element of the merkle tree. | [
"Return",
"the",
"root",
"element",
"of",
"the",
"merkle",
"tree",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L107-L112 | train |
raiden-network/raiden | raiden/storage/migrations/v19_to_v20.py | _add_onchain_locksroot_to_channel_settled_state_changes | def _add_onchain_locksroot_to_channel_settled_state_changes(
raiden: RaidenService,
storage: SQLiteStorage,
) -> None:
""" Adds `our_onchain_locksroot` and `partner_onchain_locksroot` to
ContractReceiveChannelSettled. """
batch_size = 50
batch_query = storage.batch_query_state_changes(
... | python | def _add_onchain_locksroot_to_channel_settled_state_changes(
raiden: RaidenService,
storage: SQLiteStorage,
) -> None:
""" Adds `our_onchain_locksroot` and `partner_onchain_locksroot` to
ContractReceiveChannelSettled. """
batch_size = 50
batch_query = storage.batch_query_state_changes(
... | [
"def",
"_add_onchain_locksroot_to_channel_settled_state_changes",
"(",
"raiden",
":",
"RaidenService",
",",
"storage",
":",
"SQLiteStorage",
",",
")",
"->",
"None",
":",
"batch_size",
"=",
"50",
"batch_query",
"=",
"storage",
".",
"batch_query_state_changes",
"(",
"ba... | Adds `our_onchain_locksroot` and `partner_onchain_locksroot` to
ContractReceiveChannelSettled. | [
"Adds",
"our_onchain_locksroot",
"and",
"partner_onchain_locksroot",
"to",
"ContractReceiveChannelSettled",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v19_to_v20.py#L103-L168 | train |
raiden-network/raiden | raiden/storage/migrations/v19_to_v20.py | _add_onchain_locksroot_to_snapshot | def _add_onchain_locksroot_to_snapshot(
raiden: RaidenService,
storage: SQLiteStorage,
snapshot_record: StateChangeRecord,
) -> str:
"""
Add `onchain_locksroot` to each NettingChannelEndState
"""
snapshot = json.loads(snapshot_record.data)
for payment_network in snapshot.get... | python | def _add_onchain_locksroot_to_snapshot(
raiden: RaidenService,
storage: SQLiteStorage,
snapshot_record: StateChangeRecord,
) -> str:
"""
Add `onchain_locksroot` to each NettingChannelEndState
"""
snapshot = json.loads(snapshot_record.data)
for payment_network in snapshot.get... | [
"def",
"_add_onchain_locksroot_to_snapshot",
"(",
"raiden",
":",
"RaidenService",
",",
"storage",
":",
"SQLiteStorage",
",",
"snapshot_record",
":",
"StateChangeRecord",
",",
")",
"->",
"str",
":",
"snapshot",
"=",
"json",
".",
"loads",
"(",
"snapshot_record",
"."... | Add `onchain_locksroot` to each NettingChannelEndState | [
"Add",
"onchain_locksroot",
"to",
"each",
"NettingChannelEndState"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v19_to_v20.py#L171-L197 | train |
raiden-network/raiden | raiden/log_config.py | add_greenlet_name | def add_greenlet_name(
_logger: str,
_method_name: str,
event_dict: Dict[str, Any],
) -> Dict[str, Any]:
"""Add greenlet_name to the event dict for greenlets that have a non-default name."""
current_greenlet = gevent.getcurrent()
greenlet_name = getattr(current_greenlet, 'name', None... | python | def add_greenlet_name(
_logger: str,
_method_name: str,
event_dict: Dict[str, Any],
) -> Dict[str, Any]:
"""Add greenlet_name to the event dict for greenlets that have a non-default name."""
current_greenlet = gevent.getcurrent()
greenlet_name = getattr(current_greenlet, 'name', None... | [
"def",
"add_greenlet_name",
"(",
"_logger",
":",
"str",
",",
"_method_name",
":",
"str",
",",
"event_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"current_greenlet",
"=",
"gevent",
".",
"g... | Add greenlet_name to the event dict for greenlets that have a non-default name. | [
"Add",
"greenlet_name",
"to",
"the",
"event",
"dict",
"for",
"greenlets",
"that",
"have",
"a",
"non",
"-",
"default",
"name",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L107-L117 | train |
raiden-network/raiden | raiden/log_config.py | redactor | def redactor(blacklist: Dict[Pattern, str]) -> Callable[[str], str]:
"""Returns a function which transforms a str, replacing all matches for its replacement"""
def processor_wrapper(msg: str) -> str:
for regex, repl in blacklist.items():
if repl is None:
repl = '<redacted>'
... | python | def redactor(blacklist: Dict[Pattern, str]) -> Callable[[str], str]:
"""Returns a function which transforms a str, replacing all matches for its replacement"""
def processor_wrapper(msg: str) -> str:
for regex, repl in blacklist.items():
if repl is None:
repl = '<redacted>'
... | [
"def",
"redactor",
"(",
"blacklist",
":",
"Dict",
"[",
"Pattern",
",",
"str",
"]",
")",
"->",
"Callable",
"[",
"[",
"str",
"]",
",",
"str",
"]",
":",
"def",
"processor_wrapper",
"(",
"msg",
":",
"str",
")",
"->",
"str",
":",
"for",
"regex",
",",
... | Returns a function which transforms a str, replacing all matches for its replacement | [
"Returns",
"a",
"function",
"which",
"transforms",
"a",
"str",
"replacing",
"all",
"matches",
"for",
"its",
"replacement"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L120-L128 | train |
raiden-network/raiden | raiden/log_config.py | _wrap_tracebackexception_format | def _wrap_tracebackexception_format(redact: Callable[[str], str]):
"""Monkey-patch TracebackException.format to redact printed lines.
Only the last call will be effective. Consecutive calls will overwrite the
previous monkey patches.
"""
original_format = getattr(TracebackException, '_original', No... | python | def _wrap_tracebackexception_format(redact: Callable[[str], str]):
"""Monkey-patch TracebackException.format to redact printed lines.
Only the last call will be effective. Consecutive calls will overwrite the
previous monkey patches.
"""
original_format = getattr(TracebackException, '_original', No... | [
"def",
"_wrap_tracebackexception_format",
"(",
"redact",
":",
"Callable",
"[",
"[",
"str",
"]",
",",
"str",
"]",
")",
":",
"original_format",
"=",
"getattr",
"(",
"TracebackException",
",",
"'_original'",
",",
"None",
")",
"if",
"original_format",
"is",
"None"... | Monkey-patch TracebackException.format to redact printed lines.
Only the last call will be effective. Consecutive calls will overwrite the
previous monkey patches. | [
"Monkey",
"-",
"patch",
"TracebackException",
".",
"format",
"to",
"redact",
"printed",
"lines",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L131-L147 | train |
raiden-network/raiden | raiden/log_config.py | LogFilter.should_log | def should_log(self, logger_name: str, level: str) -> bool:
""" Returns if a message for the logger should be logged. """
if (logger_name, level) not in self._should_log:
log_level_per_rule = self._get_log_level(logger_name)
log_level_per_rule_numeric = getattr(logging, log_level... | python | def should_log(self, logger_name: str, level: str) -> bool:
""" Returns if a message for the logger should be logged. """
if (logger_name, level) not in self._should_log:
log_level_per_rule = self._get_log_level(logger_name)
log_level_per_rule_numeric = getattr(logging, log_level... | [
"def",
"should_log",
"(",
"self",
",",
"logger_name",
":",
"str",
",",
"level",
":",
"str",
")",
"->",
"bool",
":",
"if",
"(",
"logger_name",
",",
"level",
")",
"not",
"in",
"self",
".",
"_should_log",
":",
"log_level_per_rule",
"=",
"self",
".",
"_get... | Returns if a message for the logger should be logged. | [
"Returns",
"if",
"a",
"message",
"for",
"the",
"logger",
"should",
"be",
"logged",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L86-L95 | train |
raiden-network/raiden | raiden/storage/migrations/v20_to_v21.py | _update_statechanges | def _update_statechanges(storage: SQLiteStorage):
"""
Update each ContractReceiveChannelNew's channel_state member
by setting the `mediation_fee` that was added to the NettingChannelState
"""
batch_size = 50
batch_query = storage.batch_query_state_changes(
batch_size=batch_size,
... | python | def _update_statechanges(storage: SQLiteStorage):
"""
Update each ContractReceiveChannelNew's channel_state member
by setting the `mediation_fee` that was added to the NettingChannelState
"""
batch_size = 50
batch_query = storage.batch_query_state_changes(
batch_size=batch_size,
... | [
"def",
"_update_statechanges",
"(",
"storage",
":",
"SQLiteStorage",
")",
":",
"batch_size",
"=",
"50",
"batch_query",
"=",
"storage",
".",
"batch_query_state_changes",
"(",
"batch_size",
"=",
"batch_size",
",",
"filters",
"=",
"[",
"(",
"'_type'",
",",
"'raiden... | Update each ContractReceiveChannelNew's channel_state member
by setting the `mediation_fee` that was added to the NettingChannelState | [
"Update",
"each",
"ContractReceiveChannelNew",
"s",
"channel_state",
"member",
"by",
"setting",
"the",
"mediation_fee",
"that",
"was",
"added",
"to",
"the",
"NettingChannelState"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v20_to_v21.py#L52-L100 | train |
raiden-network/raiden | raiden/blockchain/events.py | get_contract_events | def get_contract_events(
chain: BlockChainService,
abi: Dict,
contract_address: Address,
topics: Optional[List[str]],
from_block: BlockSpecification,
to_block: BlockSpecification,
) -> List[Dict]:
""" Query the blockchain for all events of the smart contract at
`c... | python | def get_contract_events(
chain: BlockChainService,
abi: Dict,
contract_address: Address,
topics: Optional[List[str]],
from_block: BlockSpecification,
to_block: BlockSpecification,
) -> List[Dict]:
""" Query the blockchain for all events of the smart contract at
`c... | [
"def",
"get_contract_events",
"(",
"chain",
":",
"BlockChainService",
",",
"abi",
":",
"Dict",
",",
"contract_address",
":",
"Address",
",",
"topics",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"from_block",
":",
"BlockSpecification",
",",
"to_... | Query the blockchain for all events of the smart contract at
`contract_address` that match the filters `topics`, `from_block`, and
`to_block`. | [
"Query",
"the",
"blockchain",
"for",
"all",
"events",
"of",
"the",
"smart",
"contract",
"at",
"contract_address",
"that",
"match",
"the",
"filters",
"topics",
"from_block",
"and",
"to_block",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L50-L78 | train |
raiden-network/raiden | raiden/blockchain/events.py | get_token_network_registry_events | def get_token_network_registry_events(
chain: BlockChainService,
token_network_registry_address: PaymentNetworkID,
contract_manager: ContractManager,
events: Optional[List[str]] = ALL_EVENTS,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecificat... | python | def get_token_network_registry_events(
chain: BlockChainService,
token_network_registry_address: PaymentNetworkID,
contract_manager: ContractManager,
events: Optional[List[str]] = ALL_EVENTS,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecificat... | [
"def",
"get_token_network_registry_events",
"(",
"chain",
":",
"BlockChainService",
",",
"token_network_registry_address",
":",
"PaymentNetworkID",
",",
"contract_manager",
":",
"ContractManager",
",",
"events",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",... | Helper to get all events of the Registry contract at `registry_address`. | [
"Helper",
"to",
"get",
"all",
"events",
"of",
"the",
"Registry",
"contract",
"at",
"registry_address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L81-L97 | train |
raiden-network/raiden | raiden/blockchain/events.py | get_token_network_events | def get_token_network_events(
chain: BlockChainService,
token_network_address: Address,
contract_manager: ContractManager,
events: Optional[List[str]] = ALL_EVENTS,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
) -> List[D... | python | def get_token_network_events(
chain: BlockChainService,
token_network_address: Address,
contract_manager: ContractManager,
events: Optional[List[str]] = ALL_EVENTS,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
) -> List[D... | [
"def",
"get_token_network_events",
"(",
"chain",
":",
"BlockChainService",
",",
"token_network_address",
":",
"Address",
",",
"contract_manager",
":",
"ContractManager",
",",
"events",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"ALL_EVENTS",
",",
"... | Helper to get all events of the ChannelManagerContract at `token_address`. | [
"Helper",
"to",
"get",
"all",
"events",
"of",
"the",
"ChannelManagerContract",
"at",
"token_address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L100-L117 | train |
raiden-network/raiden | raiden/blockchain/events.py | get_all_netting_channel_events | def get_all_netting_channel_events(
chain: BlockChainService,
token_network_address: TokenNetworkAddress,
netting_channel_identifier: ChannelID,
contract_manager: ContractManager,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'lates... | python | def get_all_netting_channel_events(
chain: BlockChainService,
token_network_address: TokenNetworkAddress,
netting_channel_identifier: ChannelID,
contract_manager: ContractManager,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'lates... | [
"def",
"get_all_netting_channel_events",
"(",
"chain",
":",
"BlockChainService",
",",
"token_network_address",
":",
"TokenNetworkAddress",
",",
"netting_channel_identifier",
":",
"ChannelID",
",",
"contract_manager",
":",
"ContractManager",
",",
"from_block",
":",
"BlockSpe... | Helper to get all events of a NettingChannelContract. | [
"Helper",
"to",
"get",
"all",
"events",
"of",
"a",
"NettingChannelContract",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L120-L145 | train |
raiden-network/raiden | raiden/blockchain/events.py | decode_event_to_internal | def decode_event_to_internal(abi, log_event):
""" Enforce the binary for internal usage. """
# Note: All addresses inside the event_data must be decoded.
decoded_event = decode_event(abi, log_event)
if not decoded_event:
raise UnknownEventType()
# copy the attribute dict because that data... | python | def decode_event_to_internal(abi, log_event):
""" Enforce the binary for internal usage. """
# Note: All addresses inside the event_data must be decoded.
decoded_event = decode_event(abi, log_event)
if not decoded_event:
raise UnknownEventType()
# copy the attribute dict because that data... | [
"def",
"decode_event_to_internal",
"(",
"abi",
",",
"log_event",
")",
":",
"# Note: All addresses inside the event_data must be decoded.",
"decoded_event",
"=",
"decode_event",
"(",
"abi",
",",
"log_event",
")",
"if",
"not",
"decoded_event",
":",
"raise",
"UnknownEventTyp... | Enforce the binary for internal usage. | [
"Enforce",
"the",
"binary",
"for",
"internal",
"usage",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L148-L195 | train |
raiden-network/raiden | raiden/blockchain/events.py | BlockchainEvents.poll_blockchain_events | def poll_blockchain_events(self, block_number: typing.BlockNumber):
""" Poll for new blockchain events up to `block_number`. """
for event_listener in self.event_listeners:
assert isinstance(event_listener.filter, StatelessFilter)
for log_event in event_listener.filter.get_new_... | python | def poll_blockchain_events(self, block_number: typing.BlockNumber):
""" Poll for new blockchain events up to `block_number`. """
for event_listener in self.event_listeners:
assert isinstance(event_listener.filter, StatelessFilter)
for log_event in event_listener.filter.get_new_... | [
"def",
"poll_blockchain_events",
"(",
"self",
",",
"block_number",
":",
"typing",
".",
"BlockNumber",
")",
":",
"for",
"event_listener",
"in",
"self",
".",
"event_listeners",
":",
"assert",
"isinstance",
"(",
"event_listener",
".",
"filter",
",",
"StatelessFilter"... | Poll for new blockchain events up to `block_number`. | [
"Poll",
"for",
"new",
"blockchain",
"events",
"up",
"to",
"block_number",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L216-L223 | train |
raiden-network/raiden | tools/genesis_builder.py | generate_accounts | def generate_accounts(seeds):
"""Create private keys and addresses for all seeds.
"""
return {
seed: {
'privatekey': encode_hex(sha3(seed)),
'address': encode_hex(privatekey_to_address(sha3(seed))),
}
for seed in seeds
} | python | def generate_accounts(seeds):
"""Create private keys and addresses for all seeds.
"""
return {
seed: {
'privatekey': encode_hex(sha3(seed)),
'address': encode_hex(privatekey_to_address(sha3(seed))),
}
for seed in seeds
} | [
"def",
"generate_accounts",
"(",
"seeds",
")",
":",
"return",
"{",
"seed",
":",
"{",
"'privatekey'",
":",
"encode_hex",
"(",
"sha3",
"(",
"seed",
")",
")",
",",
"'address'",
":",
"encode_hex",
"(",
"privatekey_to_address",
"(",
"sha3",
"(",
"seed",
")",
... | Create private keys and addresses for all seeds. | [
"Create",
"private",
"keys",
"and",
"addresses",
"for",
"all",
"seeds",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/genesis_builder.py#L9-L18 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.