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
ethereum/py-evm
eth/db/storage.py
AccountStorageDB._validate_flushed
def _validate_flushed(self) -> None: """ Will raise an exception if there are some changes made since the last persist. """ journal_diff = self._journal_storage.diff() if len(journal_diff) > 0: raise ValidationError( "StorageDB had a dirty journal when...
python
def _validate_flushed(self) -> None: """ Will raise an exception if there are some changes made since the last persist. """ journal_diff = self._journal_storage.diff() if len(journal_diff) > 0: raise ValidationError( "StorageDB had a dirty journal when...
[ "def", "_validate_flushed", "(", "self", ")", "->", "None", ":", "journal_diff", "=", "self", ".", "_journal_storage", ".", "diff", "(", ")", "if", "len", "(", "journal_diff", ")", ">", "0", ":", "raise", "ValidationError", "(", "\"StorageDB had a dirty journa...
Will raise an exception if there are some changes made since the last persist.
[ "Will", "raise", "an", "exception", "if", "there", "are", "some", "changes", "made", "since", "the", "last", "persist", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/db/storage.py#L243-L251
train
ethereum/py-evm
eth/vm/memory.py
Memory.write
def write(self, start_position: int, size: int, value: bytes) -> None: """ Write `value` into memory. """ if size: validate_uint256(start_position) validate_uint256(size) validate_is_bytes(value) validate_length(value, length=size) ...
python
def write(self, start_position: int, size: int, value: bytes) -> None: """ Write `value` into memory. """ if size: validate_uint256(start_position) validate_uint256(size) validate_is_bytes(value) validate_length(value, length=size) ...
[ "def", "write", "(", "self", ",", "start_position", ":", "int", ",", "size", ":", "int", ",", "value", ":", "bytes", ")", "->", "None", ":", "if", "size", ":", "validate_uint256", "(", "start_position", ")", "validate_uint256", "(", "size", ")", "validat...
Write `value` into memory.
[ "Write", "value", "into", "memory", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/memory.py#L49-L61
train
ethereum/py-evm
eth/vm/memory.py
Memory.read
def read(self, start_position: int, size: int) -> memoryview: """ Return a view into the memory """ return memoryview(self._bytes)[start_position:start_position + size]
python
def read(self, start_position: int, size: int) -> memoryview: """ Return a view into the memory """ return memoryview(self._bytes)[start_position:start_position + size]
[ "def", "read", "(", "self", ",", "start_position", ":", "int", ",", "size", ":", "int", ")", "->", "memoryview", ":", "return", "memoryview", "(", "self", ".", "_bytes", ")", "[", "start_position", ":", "start_position", "+", "size", "]" ]
Return a view into the memory
[ "Return", "a", "view", "into", "the", "memory" ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/memory.py#L63-L67
train
ethereum/py-evm
eth/vm/memory.py
Memory.read_bytes
def read_bytes(self, start_position: int, size: int) -> bytes: """ Read a value from memory and return a fresh bytes instance """ return bytes(self._bytes[start_position:start_position + size])
python
def read_bytes(self, start_position: int, size: int) -> bytes: """ Read a value from memory and return a fresh bytes instance """ return bytes(self._bytes[start_position:start_position + size])
[ "def", "read_bytes", "(", "self", ",", "start_position", ":", "int", ",", "size", ":", "int", ")", "->", "bytes", ":", "return", "bytes", "(", "self", ".", "_bytes", "[", "start_position", ":", "start_position", "+", "size", "]", ")" ]
Read a value from memory and return a fresh bytes instance
[ "Read", "a", "value", "from", "memory", "and", "return", "a", "fresh", "bytes", "instance" ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/memory.py#L69-L73
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.extend_memory
def extend_memory(self, start_position: int, size: int) -> None: """ Extend the size of the memory to be at minimum ``start_position + size`` bytes in length. Raise `eth.exceptions.OutOfGas` if there is not enough gas to pay for extending the memory. """ validate_uint256...
python
def extend_memory(self, start_position: int, size: int) -> None: """ Extend the size of the memory to be at minimum ``start_position + size`` bytes in length. Raise `eth.exceptions.OutOfGas` if there is not enough gas to pay for extending the memory. """ validate_uint256...
[ "def", "extend_memory", "(", "self", ",", "start_position", ":", "int", ",", "size", ":", "int", ")", "->", "None", ":", "validate_uint256", "(", "start_position", ",", "title", "=", "\"Memory start position\"", ")", "validate_uint256", "(", "size", ",", "titl...
Extend the size of the memory to be at minimum ``start_position + size`` bytes in length. Raise `eth.exceptions.OutOfGas` if there is not enough gas to pay for extending the memory.
[ "Extend", "the", "size", "of", "the", "memory", "to", "be", "at", "minimum", "start_position", "+", "size", "bytes", "in", "length", ".", "Raise", "eth", ".", "exceptions", ".", "OutOfGas", "if", "there", "is", "not", "enough", "gas", "to", "pay", "for",...
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L205-L242
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.memory_read
def memory_read(self, start_position: int, size: int) -> memoryview: """ Read and return a view of ``size`` bytes from memory starting at ``start_position``. """ return self._memory.read(start_position, size)
python
def memory_read(self, start_position: int, size: int) -> memoryview: """ Read and return a view of ``size`` bytes from memory starting at ``start_position``. """ return self._memory.read(start_position, size)
[ "def", "memory_read", "(", "self", ",", "start_position", ":", "int", ",", "size", ":", "int", ")", "->", "memoryview", ":", "return", "self", ".", "_memory", ".", "read", "(", "start_position", ",", "size", ")" ]
Read and return a view of ``size`` bytes from memory starting at ``start_position``.
[ "Read", "and", "return", "a", "view", "of", "size", "bytes", "from", "memory", "starting", "at", "start_position", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L250-L254
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.memory_read_bytes
def memory_read_bytes(self, start_position: int, size: int) -> bytes: """ Read and return ``size`` bytes from memory starting at ``start_position``. """ return self._memory.read_bytes(start_position, size)
python
def memory_read_bytes(self, start_position: int, size: int) -> bytes: """ Read and return ``size`` bytes from memory starting at ``start_position``. """ return self._memory.read_bytes(start_position, size)
[ "def", "memory_read_bytes", "(", "self", ",", "start_position", ":", "int", ",", "size", ":", "int", ")", "->", "bytes", ":", "return", "self", ".", "_memory", ".", "read_bytes", "(", "start_position", ",", "size", ")" ]
Read and return ``size`` bytes from memory starting at ``start_position``.
[ "Read", "and", "return", "size", "bytes", "from", "memory", "starting", "at", "start_position", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L256-L260
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.consume_gas
def consume_gas(self, amount: int, reason: str) -> None: """ Consume ``amount`` of gas from the remaining gas. Raise `eth.exceptions.OutOfGas` if there is not enough gas remaining. """ return self._gas_meter.consume_gas(amount, reason)
python
def consume_gas(self, amount: int, reason: str) -> None: """ Consume ``amount`` of gas from the remaining gas. Raise `eth.exceptions.OutOfGas` if there is not enough gas remaining. """ return self._gas_meter.consume_gas(amount, reason)
[ "def", "consume_gas", "(", "self", ",", "amount", ":", "int", ",", "reason", ":", "str", ")", "->", "None", ":", "return", "self", ".", "_gas_meter", ".", "consume_gas", "(", "amount", ",", "reason", ")" ]
Consume ``amount`` of gas from the remaining gas. Raise `eth.exceptions.OutOfGas` if there is not enough gas remaining.
[ "Consume", "amount", "of", "gas", "from", "the", "remaining", "gas", ".", "Raise", "eth", ".", "exceptions", ".", "OutOfGas", "if", "there", "is", "not", "enough", "gas", "remaining", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L268-L273
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.stack_pop
def stack_pop(self, num_items: int=1, type_hint: str=None) -> Any: # TODO: Needs to be replaced with # `Union[int, bytes, Tuple[Union[int, bytes], ...]]` if done properly """ Pop and return a number of items equal to ``num_items`` from the stack. ``type_hint`` can be either ``'ui...
python
def stack_pop(self, num_items: int=1, type_hint: str=None) -> Any: # TODO: Needs to be replaced with # `Union[int, bytes, Tuple[Union[int, bytes], ...]]` if done properly """ Pop and return a number of items equal to ``num_items`` from the stack. ``type_hint`` can be either ``'ui...
[ "def", "stack_pop", "(", "self", ",", "num_items", ":", "int", "=", "1", ",", "type_hint", ":", "str", "=", "None", ")", "->", "Any", ":", "return", "self", ".", "_stack", ".", "pop", "(", "num_items", ",", "type_hint", ")" ]
Pop and return a number of items equal to ``num_items`` from the stack. ``type_hint`` can be either ``'uint256'`` or ``'bytes'``. The return value will be an ``int`` or ``bytes`` type depending on the value provided for the ``type_hint``. Raise `eth.exceptions.InsufficientStack` if the...
[ "Pop", "and", "return", "a", "number", "of", "items", "equal", "to", "num_items", "from", "the", "stack", ".", "type_hint", "can", "be", "either", "uint256", "or", "bytes", ".", "The", "return", "value", "will", "be", "an", "int", "or", "bytes", "type", ...
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L311-L323
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.stack_push
def stack_push(self, value: Union[int, bytes]) -> None: """ Push ``value`` onto the stack. Raise `eth.exceptions.StackDepthLimit` if the stack is full. """ return self._stack.push(value)
python
def stack_push(self, value: Union[int, bytes]) -> None: """ Push ``value`` onto the stack. Raise `eth.exceptions.StackDepthLimit` if the stack is full. """ return self._stack.push(value)
[ "def", "stack_push", "(", "self", ",", "value", ":", "Union", "[", "int", ",", "bytes", "]", ")", "->", "None", ":", "return", "self", ".", "_stack", ".", "push", "(", "value", ")" ]
Push ``value`` onto the stack. Raise `eth.exceptions.StackDepthLimit` if the stack is full.
[ "Push", "value", "onto", "the", "stack", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L325-L331
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.prepare_child_message
def prepare_child_message(self, gas: int, to: Address, value: int, data: BytesOrView, code: bytes, **kwargs: Any) -> Message: """ ...
python
def prepare_child_message(self, gas: int, to: Address, value: int, data: BytesOrView, code: bytes, **kwargs: Any) -> Message: """ ...
[ "def", "prepare_child_message", "(", "self", ",", "gas", ":", "int", ",", "to", ":", "Address", ",", "value", ":", "int", ",", "data", ":", "BytesOrView", ",", "code", ":", "bytes", ",", "**", "kwargs", ":", "Any", ")", "->", "Message", ":", "kwargs"...
Helper method for creating a child computation.
[ "Helper", "method", "for", "creating", "a", "child", "computation", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L369-L390
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.apply_child_computation
def apply_child_computation(self, child_msg: Message) -> 'BaseComputation': """ Apply the vm message ``child_msg`` as a child computation. """ child_computation = self.generate_child_computation(child_msg) self.add_child_computation(child_computation) return child_computa...
python
def apply_child_computation(self, child_msg: Message) -> 'BaseComputation': """ Apply the vm message ``child_msg`` as a child computation. """ child_computation = self.generate_child_computation(child_msg) self.add_child_computation(child_computation) return child_computa...
[ "def", "apply_child_computation", "(", "self", ",", "child_msg", ":", "Message", ")", "->", "'BaseComputation'", ":", "child_computation", "=", "self", ".", "generate_child_computation", "(", "child_msg", ")", "self", ".", "add_child_computation", "(", "child_computat...
Apply the vm message ``child_msg`` as a child computation.
[ "Apply", "the", "vm", "message", "child_msg", "as", "a", "child", "computation", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L392-L398
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation._get_log_entries
def _get_log_entries(self) -> List[Tuple[int, bytes, List[int], bytes]]: """ Return the log entries for this computation and its children. They are sorted in the same order they were emitted during the transaction processing, and include the sequential counter as the first element of th...
python
def _get_log_entries(self) -> List[Tuple[int, bytes, List[int], bytes]]: """ Return the log entries for this computation and its children. They are sorted in the same order they were emitted during the transaction processing, and include the sequential counter as the first element of th...
[ "def", "_get_log_entries", "(", "self", ")", "->", "List", "[", "Tuple", "[", "int", ",", "bytes", ",", "List", "[", "int", "]", ",", "bytes", "]", "]", ":", "if", "self", ".", "is_error", ":", "return", "[", "]", "else", ":", "return", "sorted", ...
Return the log entries for this computation and its children. They are sorted in the same order they were emitted during the transaction processing, and include the sequential counter as the first element of the tuple representing every entry.
[ "Return", "the", "log", "entries", "for", "this", "computation", "and", "its", "children", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L463-L476
train
ethereum/py-evm
eth/vm/computation.py
BaseComputation.apply_computation
def apply_computation(cls, state: BaseState, message: Message, transaction_context: BaseTransactionContext) -> 'BaseComputation': """ Perform the computation that would be triggered by the VM message. """ with ...
python
def apply_computation(cls, state: BaseState, message: Message, transaction_context: BaseTransactionContext) -> 'BaseComputation': """ Perform the computation that would be triggered by the VM message. """ with ...
[ "def", "apply_computation", "(", "cls", ",", "state", ":", "BaseState", ",", "message", ":", "Message", ",", "transaction_context", ":", "BaseTransactionContext", ")", "->", "'BaseComputation'", ":", "with", "cls", "(", "state", ",", "message", ",", "transaction...
Perform the computation that would be triggered by the VM message.
[ "Perform", "the", "computation", "that", "would", "be", "triggered", "by", "the", "VM", "message", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/computation.py#L562-L592
train
ethereum/py-evm
eth/vm/forks/homestead/headers.py
compute_homestead_difficulty
def compute_homestead_difficulty(parent_header: BlockHeader, timestamp: int) -> int: """ Computes the difficulty for a homestead block based on the parent block. """ parent_tstamp = parent_header.timestamp validate_gt(timestamp, parent_tstamp, title="Header.timestamp") offset = parent_header.dif...
python
def compute_homestead_difficulty(parent_header: BlockHeader, timestamp: int) -> int: """ Computes the difficulty for a homestead block based on the parent block. """ parent_tstamp = parent_header.timestamp validate_gt(timestamp, parent_tstamp, title="Header.timestamp") offset = parent_header.dif...
[ "def", "compute_homestead_difficulty", "(", "parent_header", ":", "BlockHeader", ",", "timestamp", ":", "int", ")", "->", "int", ":", "parent_tstamp", "=", "parent_header", ".", "timestamp", "validate_gt", "(", "timestamp", ",", "parent_tstamp", ",", "title", "=",...
Computes the difficulty for a homestead block based on the parent block.
[ "Computes", "the", "difficulty", "for", "a", "homestead", "block", "based", "on", "the", "parent", "block", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/forks/homestead/headers.py#L39-L58
train
ethereum/py-evm
eth/vm/state.py
BaseState.snapshot
def snapshot(self) -> Tuple[Hash32, UUID]: """ Perform a full snapshot of the current state. Snapshots are a combination of the :attr:`~state_root` at the time of the snapshot and the id of the changeset from the journaled DB. """ return self.state_root, self._account_db...
python
def snapshot(self) -> Tuple[Hash32, UUID]: """ Perform a full snapshot of the current state. Snapshots are a combination of the :attr:`~state_root` at the time of the snapshot and the id of the changeset from the journaled DB. """ return self.state_root, self._account_db...
[ "def", "snapshot", "(", "self", ")", "->", "Tuple", "[", "Hash32", ",", "UUID", "]", ":", "return", "self", ".", "state_root", ",", "self", ".", "_account_db", ".", "record", "(", ")" ]
Perform a full snapshot of the current state. Snapshots are a combination of the :attr:`~state_root` at the time of the snapshot and the id of the changeset from the journaled DB.
[ "Perform", "a", "full", "snapshot", "of", "the", "current", "state", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/state.py#L225-L232
train
ethereum/py-evm
eth/vm/state.py
BaseState.revert
def revert(self, snapshot: Tuple[Hash32, UUID]) -> None: """ Revert the VM to the state at the snapshot """ state_root, account_snapshot = snapshot # first revert the database state root. self._account_db.state_root = state_root # now roll the underlying database...
python
def revert(self, snapshot: Tuple[Hash32, UUID]) -> None: """ Revert the VM to the state at the snapshot """ state_root, account_snapshot = snapshot # first revert the database state root. self._account_db.state_root = state_root # now roll the underlying database...
[ "def", "revert", "(", "self", ",", "snapshot", ":", "Tuple", "[", "Hash32", ",", "UUID", "]", ")", "->", "None", ":", "state_root", ",", "account_snapshot", "=", "snapshot", "self", ".", "_account_db", ".", "state_root", "=", "state_root", "self", ".", "...
Revert the VM to the state at the snapshot
[ "Revert", "the", "VM", "to", "the", "state", "at", "the", "snapshot" ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/state.py#L234-L243
train
ethereum/py-evm
eth/vm/state.py
BaseState.get_computation
def get_computation(self, message: Message, transaction_context: 'BaseTransactionContext') -> 'BaseComputation': """ Return a computation instance for the given `message` and `transaction_context` """ if self.computation_class is None: ...
python
def get_computation(self, message: Message, transaction_context: 'BaseTransactionContext') -> 'BaseComputation': """ Return a computation instance for the given `message` and `transaction_context` """ if self.computation_class is None: ...
[ "def", "get_computation", "(", "self", ",", "message", ":", "Message", ",", "transaction_context", ":", "'BaseTransactionContext'", ")", "->", "'BaseComputation'", ":", "if", "self", ".", "computation_class", "is", "None", ":", "raise", "AttributeError", "(", "\"N...
Return a computation instance for the given `message` and `transaction_context`
[ "Return", "a", "computation", "instance", "for", "the", "given", "message", "and", "transaction_context" ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/state.py#L283-L293
train
ethereum/py-evm
eth/vm/state.py
BaseState.apply_transaction
def apply_transaction( self, transaction: BaseOrSpoofTransaction) -> 'BaseComputation': """ Apply transaction to the vm state :param transaction: the transaction to apply :return: the computation """ if self.state_root != BLANK_ROOT_HASH and not s...
python
def apply_transaction( self, transaction: BaseOrSpoofTransaction) -> 'BaseComputation': """ Apply transaction to the vm state :param transaction: the transaction to apply :return: the computation """ if self.state_root != BLANK_ROOT_HASH and not s...
[ "def", "apply_transaction", "(", "self", ",", "transaction", ":", "BaseOrSpoofTransaction", ")", "->", "'BaseComputation'", ":", "if", "self", ".", "state_root", "!=", "BLANK_ROOT_HASH", "and", "not", "self", ".", "_account_db", ".", "has_root", "(", "self", "."...
Apply transaction to the vm state :param transaction: the transaction to apply :return: the computation
[ "Apply", "transaction", "to", "the", "vm", "state" ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/state.py#L311-L323
train
ethereum/py-evm
eth/_utils/env.py
get_env_value
def get_env_value(name: str, required: bool=False, default: Any=empty) -> str: """ Core function for extracting the environment variable. Enforces mutual exclusivity between `required` and `default` keywords. The `empty` sentinal value is used as the default `default` value to allow other function...
python
def get_env_value(name: str, required: bool=False, default: Any=empty) -> str: """ Core function for extracting the environment variable. Enforces mutual exclusivity between `required` and `default` keywords. The `empty` sentinal value is used as the default `default` value to allow other function...
[ "def", "get_env_value", "(", "name", ":", "str", ",", "required", ":", "bool", "=", "False", ",", "default", ":", "Any", "=", "empty", ")", "->", "str", ":", "if", "required", "and", "default", "is", "not", "empty", ":", "raise", "ValueError", "(", "...
Core function for extracting the environment variable. Enforces mutual exclusivity between `required` and `default` keywords. The `empty` sentinal value is used as the default `default` value to allow other function to handle default/empty logic in the appropriate way.
[ "Core", "function", "for", "extracting", "the", "environment", "variable", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/_utils/env.py#L36-L56
train
ethereum/py-evm
eth/vm/base.py
BaseVM.make_receipt
def make_receipt(self, base_header: BlockHeader, transaction: BaseTransaction, computation: BaseComputation, state: BaseState) -> Receipt: """ Generate the receipt resulting from applying the transaction. :param...
python
def make_receipt(self, base_header: BlockHeader, transaction: BaseTransaction, computation: BaseComputation, state: BaseState) -> Receipt: """ Generate the receipt resulting from applying the transaction. :param...
[ "def", "make_receipt", "(", "self", ",", "base_header", ":", "BlockHeader", ",", "transaction", ":", "BaseTransaction", ",", "computation", ":", "BaseComputation", ",", "state", ":", "BaseState", ")", "->", "Receipt", ":", "raise", "NotImplementedError", "(", "\...
Generate the receipt resulting from applying the transaction. :param base_header: the header of the block before the transaction was applied. :param transaction: the transaction used to generate the receipt :param computation: the result of running the transaction computation :param sta...
[ "Generate", "the", "receipt", "resulting", "from", "applying", "the", "transaction", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L155-L170
train
ethereum/py-evm
eth/vm/base.py
VM.execute_bytecode
def execute_bytecode(self, origin: Address, gas_price: int, gas: int, to: Address, sender: Address, value: int, data: bytes, ...
python
def execute_bytecode(self, origin: Address, gas_price: int, gas: int, to: Address, sender: Address, value: int, data: bytes, ...
[ "def", "execute_bytecode", "(", "self", ",", "origin", ":", "Address", ",", "gas_price", ":", "int", ",", "gas", ":", "int", ",", "to", ":", "Address", ",", "sender", ":", "Address", ",", "value", ":", "int", ",", "data", ":", "bytes", ",", "code", ...
Execute raw bytecode in the context of the current state of the virtual machine.
[ "Execute", "raw", "bytecode", "in", "the", "context", "of", "the", "current", "state", "of", "the", "virtual", "machine", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L470-L510
train
ethereum/py-evm
eth/vm/base.py
VM.import_block
def import_block(self, block: BaseBlock) -> BaseBlock: """ Import the given block to the chain. """ if self.block.number != block.number: raise ValidationError( "This VM can only import blocks at number #{}, the attempted block was #{}".format( ...
python
def import_block(self, block: BaseBlock) -> BaseBlock: """ Import the given block to the chain. """ if self.block.number != block.number: raise ValidationError( "This VM can only import blocks at number #{}, the attempted block was #{}".format( ...
[ "def", "import_block", "(", "self", ",", "block", ":", "BaseBlock", ")", "->", "BaseBlock", ":", "if", "self", ".", "block", ".", "number", "!=", "block", ".", "number", ":", "raise", "ValidationError", "(", "\"This VM can only import blocks at number #{}, the att...
Import the given block to the chain.
[ "Import", "the", "given", "block", "to", "the", "chain", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L557-L594
train
ethereum/py-evm
eth/vm/base.py
VM.mine_block
def mine_block(self, *args: Any, **kwargs: Any) -> BaseBlock: """ Mine the current block. Proxies to self.pack_block method. """ packed_block = self.pack_block(self.block, *args, **kwargs) final_block = self.finalize_block(packed_block) # Perform validation self...
python
def mine_block(self, *args: Any, **kwargs: Any) -> BaseBlock: """ Mine the current block. Proxies to self.pack_block method. """ packed_block = self.pack_block(self.block, *args, **kwargs) final_block = self.finalize_block(packed_block) # Perform validation self...
[ "def", "mine_block", "(", "self", ",", "*", "args", ":", "Any", ",", "**", "kwargs", ":", "Any", ")", "->", "BaseBlock", ":", "packed_block", "=", "self", ".", "pack_block", "(", "self", ".", "block", ",", "*", "args", ",", "**", "kwargs", ")", "fi...
Mine the current block. Proxies to self.pack_block method.
[ "Mine", "the", "current", "block", ".", "Proxies", "to", "self", ".", "pack_block", "method", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L596-L607
train
ethereum/py-evm
eth/vm/base.py
VM.finalize_block
def finalize_block(self, block: BaseBlock) -> BaseBlock: """ Perform any finalization steps like awarding the block mining reward, and persisting the final state root. """ if block.number > 0: self._assign_block_rewards(block) # We need to call `persist` here...
python
def finalize_block(self, block: BaseBlock) -> BaseBlock: """ Perform any finalization steps like awarding the block mining reward, and persisting the final state root. """ if block.number > 0: self._assign_block_rewards(block) # We need to call `persist` here...
[ "def", "finalize_block", "(", "self", ",", "block", ":", "BaseBlock", ")", "->", "BaseBlock", ":", "if", "block", ".", "number", ">", "0", ":", "self", ".", "_assign_block_rewards", "(", "block", ")", "self", ".", "state", ".", "persist", "(", ")", "re...
Perform any finalization steps like awarding the block mining reward, and persisting the final state root.
[ "Perform", "any", "finalization", "steps", "like", "awarding", "the", "block", "mining", "reward", "and", "persisting", "the", "final", "state", "root", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L653-L665
train
ethereum/py-evm
eth/vm/base.py
VM.pack_block
def pack_block(self, block: BaseBlock, *args: Any, **kwargs: Any) -> BaseBlock: """ Pack block for mining. :param bytes coinbase: 20-byte public address to receive block reward :param bytes uncles_hash: 32 bytes :param bytes state_root: 32 bytes :param bytes transaction_...
python
def pack_block(self, block: BaseBlock, *args: Any, **kwargs: Any) -> BaseBlock: """ Pack block for mining. :param bytes coinbase: 20-byte public address to receive block reward :param bytes uncles_hash: 32 bytes :param bytes state_root: 32 bytes :param bytes transaction_...
[ "def", "pack_block", "(", "self", ",", "block", ":", "BaseBlock", ",", "*", "args", ":", "Any", ",", "**", "kwargs", ":", "Any", ")", "->", "BaseBlock", ":", "if", "'uncles'", "in", "kwargs", ":", "uncles", "=", "kwargs", ".", "pop", "(", "'uncles'",...
Pack block for mining. :param bytes coinbase: 20-byte public address to receive block reward :param bytes uncles_hash: 32 bytes :param bytes state_root: 32 bytes :param bytes transaction_root: 32 bytes :param bytes receipt_root: 32 bytes :param int bloom: :param ...
[ "Pack", "block", "for", "mining", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L667-L704
train
ethereum/py-evm
eth/vm/base.py
VM.generate_block_from_parent_header_and_coinbase
def generate_block_from_parent_header_and_coinbase(cls, parent_header: BlockHeader, coinbase: Address) -> BaseBlock: """ Generate block from parent header and coinbase. """ block...
python
def generate_block_from_parent_header_and_coinbase(cls, parent_header: BlockHeader, coinbase: Address) -> BaseBlock: """ Generate block from parent header and coinbase. """ block...
[ "def", "generate_block_from_parent_header_and_coinbase", "(", "cls", ",", "parent_header", ":", "BlockHeader", ",", "coinbase", ":", "Address", ")", "->", "BaseBlock", ":", "block_header", "=", "generate_header_from_parent_header", "(", "cls", ".", "compute_difficulty", ...
Generate block from parent header and coinbase.
[ "Generate", "block", "from", "parent", "header", "and", "coinbase", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L710-L727
train
ethereum/py-evm
eth/vm/base.py
VM.previous_hashes
def previous_hashes(self) -> Optional[Iterable[Hash32]]: """ Convenience API for accessing the previous 255 block hashes. """ return self.get_prev_hashes(self.header.parent_hash, self.chaindb)
python
def previous_hashes(self) -> Optional[Iterable[Hash32]]: """ Convenience API for accessing the previous 255 block hashes. """ return self.get_prev_hashes(self.header.parent_hash, self.chaindb)
[ "def", "previous_hashes", "(", "self", ")", "->", "Optional", "[", "Iterable", "[", "Hash32", "]", "]", ":", "return", "self", ".", "get_prev_hashes", "(", "self", ".", "header", ".", "parent_hash", ",", "self", ".", "chaindb", ")" ]
Convenience API for accessing the previous 255 block hashes.
[ "Convenience", "API", "for", "accessing", "the", "previous", "255", "block", "hashes", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L756-L760
train
ethereum/py-evm
eth/vm/base.py
VM.create_transaction
def create_transaction(self, *args: Any, **kwargs: Any) -> BaseTransaction: """ Proxy for instantiating a signed transaction for this VM. """ return self.get_transaction_class()(*args, **kwargs)
python
def create_transaction(self, *args: Any, **kwargs: Any) -> BaseTransaction: """ Proxy for instantiating a signed transaction for this VM. """ return self.get_transaction_class()(*args, **kwargs)
[ "def", "create_transaction", "(", "self", ",", "*", "args", ":", "Any", ",", "**", "kwargs", ":", "Any", ")", "->", "BaseTransaction", ":", "return", "self", ".", "get_transaction_class", "(", ")", "(", "*", "args", ",", "**", "kwargs", ")" ]
Proxy for instantiating a signed transaction for this VM.
[ "Proxy", "for", "instantiating", "a", "signed", "transaction", "for", "this", "VM", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L765-L769
train
ethereum/py-evm
eth/vm/base.py
VM.create_unsigned_transaction
def create_unsigned_transaction(cls, *, nonce: int, gas_price: int, gas: int, to: Address, value: int, ...
python
def create_unsigned_transaction(cls, *, nonce: int, gas_price: int, gas: int, to: Address, value: int, ...
[ "def", "create_unsigned_transaction", "(", "cls", ",", "*", ",", "nonce", ":", "int", ",", "gas_price", ":", "int", ",", "gas", ":", "int", ",", "to", ":", "Address", ",", "value", ":", "int", ",", "data", ":", "bytes", ")", "->", "'BaseUnsignedTransac...
Proxy for instantiating an unsigned transaction for this VM.
[ "Proxy", "for", "instantiating", "an", "unsigned", "transaction", "for", "this", "VM", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L772-L790
train
ethereum/py-evm
eth/vm/base.py
VM.validate_block
def validate_block(self, block: BaseBlock) -> None: """ Validate the the given block. """ if not isinstance(block, self.get_block_class()): raise ValidationError( "This vm ({0!r}) is not equipped to validate a block of type {1!r}".format( s...
python
def validate_block(self, block: BaseBlock) -> None: """ Validate the the given block. """ if not isinstance(block, self.get_block_class()): raise ValidationError( "This vm ({0!r}) is not equipped to validate a block of type {1!r}".format( s...
[ "def", "validate_block", "(", "self", ",", "block", ":", "BaseBlock", ")", "->", "None", ":", "if", "not", "isinstance", "(", "block", ",", "self", ".", "get_block_class", "(", ")", ")", ":", "raise", "ValidationError", "(", "\"This vm ({0!r}) is not equipped ...
Validate the the given block.
[ "Validate", "the", "the", "given", "block", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L828-L876
train
ethereum/py-evm
eth/vm/base.py
VM.validate_uncle
def validate_uncle(cls, block: BaseBlock, uncle: BaseBlock, uncle_parent: BaseBlock) -> None: """ Validate the given uncle in the context of the given block. """ if uncle.block_number >= block.number: raise ValidationError( "Uncle number ({0}) is higher than b...
python
def validate_uncle(cls, block: BaseBlock, uncle: BaseBlock, uncle_parent: BaseBlock) -> None: """ Validate the given uncle in the context of the given block. """ if uncle.block_number >= block.number: raise ValidationError( "Uncle number ({0}) is higher than b...
[ "def", "validate_uncle", "(", "cls", ",", "block", ":", "BaseBlock", ",", "uncle", ":", "BaseBlock", ",", "uncle_parent", ":", "BaseBlock", ")", "->", "None", ":", "if", "uncle", ".", "block_number", ">=", "block", ".", "number", ":", "raise", "ValidationE...
Validate the given uncle in the context of the given block.
[ "Validate", "the", "given", "uncle", "in", "the", "context", "of", "the", "given", "block", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L927-L947
train
ethereum/py-evm
eth/tools/_utils/mappings.py
is_cleanly_mergable
def is_cleanly_mergable(*dicts: Dict[Any, Any]) -> bool: """Check that nothing will be overwritten when dictionaries are merged using `deep_merge`. Examples: >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"c": 3}) True >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"a": 0, c": 3}) ...
python
def is_cleanly_mergable(*dicts: Dict[Any, Any]) -> bool: """Check that nothing will be overwritten when dictionaries are merged using `deep_merge`. Examples: >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"c": 3}) True >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"a": 0, c": 3}) ...
[ "def", "is_cleanly_mergable", "(", "*", "dicts", ":", "Dict", "[", "Any", ",", "Any", "]", ")", "->", "bool", ":", "if", "len", "(", "dicts", ")", "<=", "1", ":", "return", "True", "elif", "len", "(", "dicts", ")", "==", "2", ":", "if", "not", ...
Check that nothing will be overwritten when dictionaries are merged using `deep_merge`. Examples: >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"c": 3}) True >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"a": 0, c": 3}) False >>> is_cleanly_mergable({"a": 1, "b": {"ba": 2}}, ...
[ "Check", "that", "nothing", "will", "be", "overwritten", "when", "dictionaries", "are", "merged", "using", "deep_merge", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/tools/_utils/mappings.py#L24-L49
train
ethereum/py-evm
eth/db/diff.py
DBDiff.deleted_keys
def deleted_keys(self) -> Iterable[bytes]: """ List all the keys that have been deleted. """ for key, value in self._changes.items(): if value is DELETED: yield key
python
def deleted_keys(self) -> Iterable[bytes]: """ List all the keys that have been deleted. """ for key, value in self._changes.items(): if value is DELETED: yield key
[ "def", "deleted_keys", "(", "self", ")", "->", "Iterable", "[", "bytes", "]", ":", "for", "key", ",", "value", "in", "self", ".", "_changes", ".", "items", "(", ")", ":", "if", "value", "is", "DELETED", ":", "yield", "key" ]
List all the keys that have been deleted.
[ "List", "all", "the", "keys", "that", "have", "been", "deleted", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/db/diff.py#L160-L166
train
ethereum/py-evm
eth/db/diff.py
DBDiff.apply_to
def apply_to(self, db: Union[BaseDB, ABC_Mutable_Mapping], apply_deletes: bool = True) -> None: """ Apply the changes in this diff to the given database. You may choose to opt out of deleting any underlying keys. :param apply_deletes: whether the pendin...
python
def apply_to(self, db: Union[BaseDB, ABC_Mutable_Mapping], apply_deletes: bool = True) -> None: """ Apply the changes in this diff to the given database. You may choose to opt out of deleting any underlying keys. :param apply_deletes: whether the pendin...
[ "def", "apply_to", "(", "self", ",", "db", ":", "Union", "[", "BaseDB", ",", "ABC_Mutable_Mapping", "]", ",", "apply_deletes", ":", "bool", "=", "True", ")", "->", "None", ":", "for", "key", ",", "value", "in", "self", ".", "_changes", ".", "items", ...
Apply the changes in this diff to the given database. You may choose to opt out of deleting any underlying keys. :param apply_deletes: whether the pending deletes should be applied to the database
[ "Apply", "the", "changes", "in", "this", "diff", "to", "the", "given", "database", ".", "You", "may", "choose", "to", "opt", "out", "of", "deleting", "any", "underlying", "keys", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/db/diff.py#L188-L208
train
ethereum/py-evm
eth/db/diff.py
DBDiff.join
def join(cls, diffs: Iterable['DBDiff']) -> 'DBDiff': """ Join several DBDiff objects into a single DBDiff object. In case of a conflict, changes in diffs that come later in ``diffs`` will overwrite changes from earlier changes. """ tracker = DBDiffTracker() for ...
python
def join(cls, diffs: Iterable['DBDiff']) -> 'DBDiff': """ Join several DBDiff objects into a single DBDiff object. In case of a conflict, changes in diffs that come later in ``diffs`` will overwrite changes from earlier changes. """ tracker = DBDiffTracker() for ...
[ "def", "join", "(", "cls", ",", "diffs", ":", "Iterable", "[", "'DBDiff'", "]", ")", "->", "'DBDiff'", ":", "tracker", "=", "DBDiffTracker", "(", ")", "for", "diff", "in", "diffs", ":", "diff", ".", "apply_to", "(", "tracker", ")", "return", "tracker",...
Join several DBDiff objects into a single DBDiff object. In case of a conflict, changes in diffs that come later in ``diffs`` will overwrite changes from earlier changes.
[ "Join", "several", "DBDiff", "objects", "into", "a", "single", "DBDiff", "object", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/db/diff.py#L211-L221
train
ethereum/py-evm
eth/tools/_utils/hashing.py
hash_log_entries
def hash_log_entries(log_entries: Iterable[Tuple[bytes, List[int], bytes]]) -> Hash32: """ Helper function for computing the RLP hash of the logs from transaction execution. """ logs = [Log(*entry) for entry in log_entries] encoded_logs = rlp.encode(logs) logs_hash = keccak(encoded_logs) ...
python
def hash_log_entries(log_entries: Iterable[Tuple[bytes, List[int], bytes]]) -> Hash32: """ Helper function for computing the RLP hash of the logs from transaction execution. """ logs = [Log(*entry) for entry in log_entries] encoded_logs = rlp.encode(logs) logs_hash = keccak(encoded_logs) ...
[ "def", "hash_log_entries", "(", "log_entries", ":", "Iterable", "[", "Tuple", "[", "bytes", ",", "List", "[", "int", "]", ",", "bytes", "]", "]", ")", "->", "Hash32", ":", "logs", "=", "[", "Log", "(", "*", "entry", ")", "for", "entry", "in", "log_...
Helper function for computing the RLP hash of the logs from transaction execution.
[ "Helper", "function", "for", "computing", "the", "RLP", "hash", "of", "the", "logs", "from", "transaction", "execution", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/tools/_utils/hashing.py#L18-L26
train
ethereum/py-evm
eth/chains/base.py
BaseChain.get_vm_class_for_block_number
def get_vm_class_for_block_number(cls, block_number: BlockNumber) -> Type['BaseVM']: """ Returns the VM class for the given block number. """ if cls.vm_configuration is None: raise AttributeError("Chain classes must define the VMs in vm_configuration") validate_block...
python
def get_vm_class_for_block_number(cls, block_number: BlockNumber) -> Type['BaseVM']: """ Returns the VM class for the given block number. """ if cls.vm_configuration is None: raise AttributeError("Chain classes must define the VMs in vm_configuration") validate_block...
[ "def", "get_vm_class_for_block_number", "(", "cls", ",", "block_number", ":", "BlockNumber", ")", "->", "Type", "[", "'BaseVM'", "]", ":", "if", "cls", ".", "vm_configuration", "is", "None", ":", "raise", "AttributeError", "(", "\"Chain classes must define the VMs i...
Returns the VM class for the given block number.
[ "Returns", "the", "VM", "class", "for", "the", "given", "block", "number", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L182-L194
train
ethereum/py-evm
eth/chains/base.py
BaseChain.validate_chain
def validate_chain( cls, root: BlockHeader, descendants: Tuple[BlockHeader, ...], seal_check_random_sample_rate: int = 1) -> None: """ Validate that all of the descendents are valid, given that the root header is valid. By default, check the seal ...
python
def validate_chain( cls, root: BlockHeader, descendants: Tuple[BlockHeader, ...], seal_check_random_sample_rate: int = 1) -> None: """ Validate that all of the descendents are valid, given that the root header is valid. By default, check the seal ...
[ "def", "validate_chain", "(", "cls", ",", "root", ":", "BlockHeader", ",", "descendants", ":", "Tuple", "[", "BlockHeader", ",", "...", "]", ",", "seal_check_random_sample_rate", ":", "int", "=", "1", ")", "->", "None", ":", "all_indices", "=", "range", "(...
Validate that all of the descendents are valid, given that the root header is valid. By default, check the seal validity (Proof-of-Work on Ethereum 1.x mainnet) of all headers. This can be expensive. Instead, check a random sample of seals using seal_check_random_sample_rate.
[ "Validate", "that", "all", "of", "the", "descendents", "are", "valid", "given", "that", "the", "root", "header", "is", "valid", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L326-L364
train
ethereum/py-evm
eth/chains/base.py
Chain.from_genesis
def from_genesis(cls, base_db: BaseAtomicDB, genesis_params: Dict[str, HeaderParams], genesis_state: AccountState=None) -> 'BaseChain': """ Initializes the Chain from a genesis state. """ genesis_vm_class = cls.get_vm_class_f...
python
def from_genesis(cls, base_db: BaseAtomicDB, genesis_params: Dict[str, HeaderParams], genesis_state: AccountState=None) -> 'BaseChain': """ Initializes the Chain from a genesis state. """ genesis_vm_class = cls.get_vm_class_f...
[ "def", "from_genesis", "(", "cls", ",", "base_db", ":", "BaseAtomicDB", ",", "genesis_params", ":", "Dict", "[", "str", ",", "HeaderParams", "]", ",", "genesis_state", ":", "AccountState", "=", "None", ")", "->", "'BaseChain'", ":", "genesis_vm_class", "=", ...
Initializes the Chain from a genesis state.
[ "Initializes", "the", "Chain", "from", "a", "genesis", "state", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L405-L440
train
ethereum/py-evm
eth/chains/base.py
Chain.get_vm
def get_vm(self, at_header: BlockHeader=None) -> 'BaseVM': """ Returns the VM instance for the given block number. """ header = self.ensure_header(at_header) vm_class = self.get_vm_class_for_block_number(header.block_number) return vm_class(header=header, chaindb=self.cha...
python
def get_vm(self, at_header: BlockHeader=None) -> 'BaseVM': """ Returns the VM instance for the given block number. """ header = self.ensure_header(at_header) vm_class = self.get_vm_class_for_block_number(header.block_number) return vm_class(header=header, chaindb=self.cha...
[ "def", "get_vm", "(", "self", ",", "at_header", ":", "BlockHeader", "=", "None", ")", "->", "'BaseVM'", ":", "header", "=", "self", ".", "ensure_header", "(", "at_header", ")", "vm_class", "=", "self", ".", "get_vm_class_for_block_number", "(", "header", "."...
Returns the VM instance for the given block number.
[ "Returns", "the", "VM", "instance", "for", "the", "given", "block", "number", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L456-L462
train
ethereum/py-evm
eth/chains/base.py
Chain.create_header_from_parent
def create_header_from_parent(self, parent_header: BlockHeader, **header_params: HeaderParams) -> BlockHeader: """ Passthrough helper to the VM class of the block descending from the given header. """ return self...
python
def create_header_from_parent(self, parent_header: BlockHeader, **header_params: HeaderParams) -> BlockHeader: """ Passthrough helper to the VM class of the block descending from the given header. """ return self...
[ "def", "create_header_from_parent", "(", "self", ",", "parent_header", ":", "BlockHeader", ",", "**", "header_params", ":", "HeaderParams", ")", "->", "BlockHeader", ":", "return", "self", ".", "get_vm_class_for_block_number", "(", "block_number", "=", "parent_header"...
Passthrough helper to the VM class of the block descending from the given header.
[ "Passthrough", "helper", "to", "the", "VM", "class", "of", "the", "block", "descending", "from", "the", "given", "header", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L467-L476
train
ethereum/py-evm
eth/chains/base.py
Chain.ensure_header
def ensure_header(self, header: BlockHeader=None) -> BlockHeader: """ Return ``header`` if it is not ``None``, otherwise return the header of the canonical head. """ if header is None: head = self.get_canonical_head() return self.create_header_from_parent(...
python
def ensure_header(self, header: BlockHeader=None) -> BlockHeader: """ Return ``header`` if it is not ``None``, otherwise return the header of the canonical head. """ if header is None: head = self.get_canonical_head() return self.create_header_from_parent(...
[ "def", "ensure_header", "(", "self", ",", "header", ":", "BlockHeader", "=", "None", ")", "->", "BlockHeader", ":", "if", "header", "is", "None", ":", "head", "=", "self", ".", "get_canonical_head", "(", ")", "return", "self", ".", "create_header_from_parent...
Return ``header`` if it is not ``None``, otherwise return the header of the canonical head.
[ "Return", "header", "if", "it", "is", "not", "None", "otherwise", "return", "the", "header", "of", "the", "canonical", "head", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L503-L512
train
ethereum/py-evm
eth/chains/base.py
Chain.get_ancestors
def get_ancestors(self, limit: int, header: BlockHeader) -> Tuple[BaseBlock, ...]: """ Return `limit` number of ancestor blocks from the current canonical head. """ ancestor_count = min(header.block_number, limit) # We construct a temporary block object vm_class = self.g...
python
def get_ancestors(self, limit: int, header: BlockHeader) -> Tuple[BaseBlock, ...]: """ Return `limit` number of ancestor blocks from the current canonical head. """ ancestor_count = min(header.block_number, limit) # We construct a temporary block object vm_class = self.g...
[ "def", "get_ancestors", "(", "self", ",", "limit", ":", "int", ",", "header", ":", "BlockHeader", ")", "->", "Tuple", "[", "BaseBlock", ",", "...", "]", ":", "ancestor_count", "=", "min", "(", "header", ".", "block_number", ",", "limit", ")", "vm_class",...
Return `limit` number of ancestor blocks from the current canonical head.
[ "Return", "limit", "number", "of", "ancestor", "blocks", "from", "the", "current", "canonical", "head", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L517-L537
train
ethereum/py-evm
eth/chains/base.py
Chain.get_block_by_hash
def get_block_by_hash(self, block_hash: Hash32) -> BaseBlock: """ Returns the requested block as specified by block hash. """ validate_word(block_hash, title="Block Hash") block_header = self.get_block_header_by_hash(block_hash) return self.get_block_by_header(block_heade...
python
def get_block_by_hash(self, block_hash: Hash32) -> BaseBlock: """ Returns the requested block as specified by block hash. """ validate_word(block_hash, title="Block Hash") block_header = self.get_block_header_by_hash(block_hash) return self.get_block_by_header(block_heade...
[ "def", "get_block_by_hash", "(", "self", ",", "block_hash", ":", "Hash32", ")", "->", "BaseBlock", ":", "validate_word", "(", "block_hash", ",", "title", "=", "\"Block Hash\"", ")", "block_header", "=", "self", ".", "get_block_header_by_hash", "(", "block_hash", ...
Returns the requested block as specified by block hash.
[ "Returns", "the", "requested", "block", "as", "specified", "by", "block", "hash", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L545-L551
train
ethereum/py-evm
eth/chains/base.py
Chain.get_block_by_header
def get_block_by_header(self, block_header: BlockHeader) -> BaseBlock: """ Returns the requested block as specified by the block header. """ vm = self.get_vm(block_header) return vm.block
python
def get_block_by_header(self, block_header: BlockHeader) -> BaseBlock: """ Returns the requested block as specified by the block header. """ vm = self.get_vm(block_header) return vm.block
[ "def", "get_block_by_header", "(", "self", ",", "block_header", ":", "BlockHeader", ")", "->", "BaseBlock", ":", "vm", "=", "self", ".", "get_vm", "(", "block_header", ")", "return", "vm", ".", "block" ]
Returns the requested block as specified by the block header.
[ "Returns", "the", "requested", "block", "as", "specified", "by", "the", "block", "header", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L553-L558
train
ethereum/py-evm
eth/chains/base.py
Chain.get_canonical_block_by_number
def get_canonical_block_by_number(self, block_number: BlockNumber) -> BaseBlock: """ Returns the block with the given number in the canonical chain. Raises BlockNotFound if there's no block with the given number in the canonical chain. """ validate_uint256(block_number, ...
python
def get_canonical_block_by_number(self, block_number: BlockNumber) -> BaseBlock: """ Returns the block with the given number in the canonical chain. Raises BlockNotFound if there's no block with the given number in the canonical chain. """ validate_uint256(block_number, ...
[ "def", "get_canonical_block_by_number", "(", "self", ",", "block_number", ":", "BlockNumber", ")", "->", "BaseBlock", ":", "validate_uint256", "(", "block_number", ",", "title", "=", "\"Block Number\"", ")", "return", "self", ".", "get_block_by_hash", "(", "self", ...
Returns the block with the given number in the canonical chain. Raises BlockNotFound if there's no block with the given number in the canonical chain.
[ "Returns", "the", "block", "with", "the", "given", "number", "in", "the", "canonical", "chain", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L560-L568
train
ethereum/py-evm
eth/chains/base.py
Chain.get_canonical_transaction
def get_canonical_transaction(self, transaction_hash: Hash32) -> BaseTransaction: """ Returns the requested transaction as specified by the transaction hash from the canonical chain. Raises TransactionNotFound if no transaction with the specified hash is found in the main chain....
python
def get_canonical_transaction(self, transaction_hash: Hash32) -> BaseTransaction: """ Returns the requested transaction as specified by the transaction hash from the canonical chain. Raises TransactionNotFound if no transaction with the specified hash is found in the main chain....
[ "def", "get_canonical_transaction", "(", "self", ",", "transaction_hash", ":", "Hash32", ")", "->", "BaseTransaction", ":", "(", "block_num", ",", "index", ")", "=", "self", ".", "chaindb", ".", "get_transaction_index", "(", "transaction_hash", ")", "VM_class", ...
Returns the requested transaction as specified by the transaction hash from the canonical chain. Raises TransactionNotFound if no transaction with the specified hash is found in the main chain.
[ "Returns", "the", "requested", "transaction", "as", "specified", "by", "the", "transaction", "hash", "from", "the", "canonical", "chain", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L604-L629
train
ethereum/py-evm
eth/chains/base.py
Chain.estimate_gas
def estimate_gas( self, transaction: BaseOrSpoofTransaction, at_header: BlockHeader=None) -> int: """ Returns an estimation of the amount of gas the given transaction will use if executed on top of the block specified by the given header. """ i...
python
def estimate_gas( self, transaction: BaseOrSpoofTransaction, at_header: BlockHeader=None) -> int: """ Returns an estimation of the amount of gas the given transaction will use if executed on top of the block specified by the given header. """ i...
[ "def", "estimate_gas", "(", "self", ",", "transaction", ":", "BaseOrSpoofTransaction", ",", "at_header", ":", "BlockHeader", "=", "None", ")", "->", "int", ":", "if", "at_header", "is", "None", ":", "at_header", "=", "self", ".", "get_canonical_head", "(", "...
Returns an estimation of the amount of gas the given transaction will use if executed on top of the block specified by the given header.
[ "Returns", "an", "estimation", "of", "the", "amount", "of", "gas", "the", "given", "transaction", "will", "use", "if", "executed", "on", "top", "of", "the", "block", "specified", "by", "the", "given", "header", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L685-L696
train
ethereum/py-evm
eth/chains/base.py
Chain.import_block
def import_block(self, block: BaseBlock, perform_validation: bool=True ) -> Tuple[BaseBlock, Tuple[BaseBlock, ...], Tuple[BaseBlock, ...]]: """ Imports a complete block and returns a 3-tuple - the imported block - a tuple of...
python
def import_block(self, block: BaseBlock, perform_validation: bool=True ) -> Tuple[BaseBlock, Tuple[BaseBlock, ...], Tuple[BaseBlock, ...]]: """ Imports a complete block and returns a 3-tuple - the imported block - a tuple of...
[ "def", "import_block", "(", "self", ",", "block", ":", "BaseBlock", ",", "perform_validation", ":", "bool", "=", "True", ")", "->", "Tuple", "[", "BaseBlock", ",", "Tuple", "[", "BaseBlock", ",", "...", "]", ",", "Tuple", "[", "BaseBlock", ",", "...", ...
Imports a complete block and returns a 3-tuple - the imported block - a tuple of blocks which are now part of the canonical chain. - a tuple of blocks which were canonical and now are no longer canonical.
[ "Imports", "a", "complete", "block", "and", "returns", "a", "3", "-", "tuple" ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L698-L752
train
ethereum/py-evm
eth/chains/base.py
Chain.validate_block
def validate_block(self, block: BaseBlock) -> None: """ Performs validation on a block that is either being mined or imported. Since block validation (specifically the uncle validation) must have access to the ancestor blocks, this validation must occur at the Chain level. ...
python
def validate_block(self, block: BaseBlock) -> None: """ Performs validation on a block that is either being mined or imported. Since block validation (specifically the uncle validation) must have access to the ancestor blocks, this validation must occur at the Chain level. ...
[ "def", "validate_block", "(", "self", ",", "block", ":", "BaseBlock", ")", "->", "None", ":", "if", "block", ".", "is_genesis", ":", "raise", "ValidationError", "(", "\"Cannot validate genesis block this way\"", ")", "VM_class", "=", "self", ".", "get_vm_class_for...
Performs validation on a block that is either being mined or imported. Since block validation (specifically the uncle validation) must have access to the ancestor blocks, this validation must occur at the Chain level. Cannot be used to validate genesis block.
[ "Performs", "validation", "on", "a", "block", "that", "is", "either", "being", "mined", "or", "imported", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L761-L777
train
ethereum/py-evm
eth/chains/base.py
Chain.validate_gaslimit
def validate_gaslimit(self, header: BlockHeader) -> None: """ Validate the gas limit on the given header. """ parent_header = self.get_block_header_by_hash(header.parent_hash) low_bound, high_bound = compute_gas_limit_bounds(parent_header) if header.gas_limit < low_bound:...
python
def validate_gaslimit(self, header: BlockHeader) -> None: """ Validate the gas limit on the given header. """ parent_header = self.get_block_header_by_hash(header.parent_hash) low_bound, high_bound = compute_gas_limit_bounds(parent_header) if header.gas_limit < low_bound:...
[ "def", "validate_gaslimit", "(", "self", ",", "header", ":", "BlockHeader", ")", "->", "None", ":", "parent_header", "=", "self", ".", "get_block_header_by_hash", "(", "header", ".", "parent_hash", ")", "low_bound", ",", "high_bound", "=", "compute_gas_limit_bound...
Validate the gas limit on the given header.
[ "Validate", "the", "gas", "limit", "on", "the", "given", "header", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L786-L799
train
ethereum/py-evm
eth/chains/base.py
Chain.validate_uncles
def validate_uncles(self, block: BaseBlock) -> None: """ Validate the uncles for the given block. """ has_uncles = len(block.uncles) > 0 should_have_uncles = block.header.uncles_hash != EMPTY_UNCLE_HASH if not has_uncles and not should_have_uncles: # optimiza...
python
def validate_uncles(self, block: BaseBlock) -> None: """ Validate the uncles for the given block. """ has_uncles = len(block.uncles) > 0 should_have_uncles = block.header.uncles_hash != EMPTY_UNCLE_HASH if not has_uncles and not should_have_uncles: # optimiza...
[ "def", "validate_uncles", "(", "self", ",", "block", ":", "BaseBlock", ")", "->", "None", ":", "has_uncles", "=", "len", "(", "block", ".", "uncles", ")", ">", "0", "should_have_uncles", "=", "block", ".", "header", ".", "uncles_hash", "!=", "EMPTY_UNCLE_H...
Validate the uncles for the given block.
[ "Validate", "the", "uncles", "for", "the", "given", "block", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L801-L870
train
ethereum/py-evm
eth/chains/base.py
MiningChain.apply_transaction
def apply_transaction(self, transaction: BaseTransaction ) -> Tuple[BaseBlock, Receipt, BaseComputation]: """ Applies the transaction to the current tip block. WARNING: Receipt and Transaction trie generation is computationally heavy a...
python
def apply_transaction(self, transaction: BaseTransaction ) -> Tuple[BaseBlock, Receipt, BaseComputation]: """ Applies the transaction to the current tip block. WARNING: Receipt and Transaction trie generation is computationally heavy a...
[ "def", "apply_transaction", "(", "self", ",", "transaction", ":", "BaseTransaction", ")", "->", "Tuple", "[", "BaseBlock", ",", "Receipt", ",", "BaseComputation", "]", ":", "vm", "=", "self", ".", "get_vm", "(", "self", ".", "header", ")", "base_block", "=...
Applies the transaction to the current tip block. WARNING: Receipt and Transaction trie generation is computationally heavy and incurs significant performance overhead.
[ "Applies", "the", "transaction", "to", "the", "current", "tip", "block", "." ]
58346848f076116381d3274bbcea96b9e2cfcbdf
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L887-L913
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
wait_for_host
def wait_for_host(port, interval=1, timeout=30, to_start=True, queue=None, ssl_pymongo_options=None): """ Ping server and wait for response. Ping a mongod or mongos every `interval` seconds until it responds, or `timeout` seconds have passed. If `to_start` is set to False, will wait f...
python
def wait_for_host(port, interval=1, timeout=30, to_start=True, queue=None, ssl_pymongo_options=None): """ Ping server and wait for response. Ping a mongod or mongos every `interval` seconds until it responds, or `timeout` seconds have passed. If `to_start` is set to False, will wait f...
[ "def", "wait_for_host", "(", "port", ",", "interval", "=", "1", ",", "timeout", "=", "30", ",", "to_start", "=", "True", ",", "queue", "=", "None", ",", "ssl_pymongo_options", "=", "None", ")", ":", "host", "=", "'localhost:%i'", "%", "port", "start_time...
Ping server and wait for response. Ping a mongod or mongos every `interval` seconds until it responds, or `timeout` seconds have passed. If `to_start` is set to False, will wait for the node to shut down instead. This function can be called as a separate thread. If queue is provided, it will place...
[ "Ping", "server", "and", "wait", "for", "response", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L73-L110
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
shutdown_host
def shutdown_host(port, username=None, password=None, authdb=None): """ Send the shutdown command to a mongod or mongos on given port. This function can be called as a separate thread. """ host = 'localhost:%i' % port try: mc = MongoConnection(host) try: if username ...
python
def shutdown_host(port, username=None, password=None, authdb=None): """ Send the shutdown command to a mongod or mongos on given port. This function can be called as a separate thread. """ host = 'localhost:%i' % port try: mc = MongoConnection(host) try: if username ...
[ "def", "shutdown_host", "(", "port", ",", "username", "=", "None", ",", "password", "=", "None", ",", "authdb", "=", "None", ")", ":", "host", "=", "'localhost:%i'", "%", "port", "try", ":", "mc", "=", "MongoConnection", "(", "host", ")", "try", ":", ...
Send the shutdown command to a mongod or mongos on given port. This function can be called as a separate thread.
[ "Send", "the", "shutdown", "command", "to", "a", "mongod", "or", "mongos", "on", "given", "port", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L113-L144
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool.start
def start(self): """Sub-command start.""" self.discover() # startup_info only gets loaded from protocol version 2 on, # check if it's loaded if not self.startup_info: # hack to make environment startable with older protocol # versions < 2: try to start no...
python
def start(self): """Sub-command start.""" self.discover() # startup_info only gets loaded from protocol version 2 on, # check if it's loaded if not self.startup_info: # hack to make environment startable with older protocol # versions < 2: try to start no...
[ "def", "start", "(", "self", ")", ":", "self", ".", "discover", "(", ")", "if", "not", "self", ".", "startup_info", ":", "if", "len", "(", "self", ".", "get_tagged", "(", "[", "'down'", "]", ")", ")", "==", "len", "(", "self", ".", "get_tagged", ...
Sub-command start.
[ "Sub", "-", "command", "start", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L861-L923
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool.is_running
def is_running(self, port): """Return True if a host on a specific port is running.""" try: con = self.client('localhost:%s' % port) con.admin.command('ping') return True except (AutoReconnect, ConnectionFailure, OperationFailure): # Catch Operatio...
python
def is_running(self, port): """Return True if a host on a specific port is running.""" try: con = self.client('localhost:%s' % port) con.admin.command('ping') return True except (AutoReconnect, ConnectionFailure, OperationFailure): # Catch Operatio...
[ "def", "is_running", "(", "self", ",", "port", ")", ":", "try", ":", "con", "=", "self", ".", "client", "(", "'localhost:%s'", "%", "port", ")", "con", ".", "admin", ".", "command", "(", "'ping'", ")", "return", "True", "except", "(", "AutoReconnect", ...
Return True if a host on a specific port is running.
[ "Return", "True", "if", "a", "host", "on", "a", "specific", "port", "is", "running", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1290-L1298
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool.get_tagged
def get_tagged(self, tags): """ Tag format. The format for the tags list is tuples for tags: mongos, config, shard, secondary tags of the form (tag, number), e.g. ('mongos', 2) which references the second mongos in the list. For all other tags, it is simply the string, e...
python
def get_tagged(self, tags): """ Tag format. The format for the tags list is tuples for tags: mongos, config, shard, secondary tags of the form (tag, number), e.g. ('mongos', 2) which references the second mongos in the list. For all other tags, it is simply the string, e...
[ "def", "get_tagged", "(", "self", ",", "tags", ")", ":", "if", "not", "hasattr", "(", "tags", ",", "'__iter__'", ")", "and", "type", "(", "tags", ")", "==", "str", ":", "tags", "=", "[", "tags", "]", "nodes", "=", "set", "(", "self", ".", "cluste...
Tag format. The format for the tags list is tuples for tags: mongos, config, shard, secondary tags of the form (tag, number), e.g. ('mongos', 2) which references the second mongos in the list. For all other tags, it is simply the string, e.g. 'primary'.
[ "Tag", "format", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1300-L1337
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool.get_tags_of_port
def get_tags_of_port(self, port): """ Get all tags related to a given port. This is the inverse of what is stored in self.cluster_tags). """ return(sorted([tag for tag in self.cluster_tags if port in self.cluster_tags[tag]]))
python
def get_tags_of_port(self, port): """ Get all tags related to a given port. This is the inverse of what is stored in self.cluster_tags). """ return(sorted([tag for tag in self.cluster_tags if port in self.cluster_tags[tag]]))
[ "def", "get_tags_of_port", "(", "self", ",", "port", ")", ":", "return", "(", "sorted", "(", "[", "tag", "for", "tag", "in", "self", ".", "cluster_tags", "if", "port", "in", "self", ".", "cluster_tags", "[", "tag", "]", "]", ")", ")" ]
Get all tags related to a given port. This is the inverse of what is stored in self.cluster_tags).
[ "Get", "all", "tags", "related", "to", "a", "given", "port", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1339-L1346
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool.wait_for
def wait_for(self, ports, interval=1.0, timeout=30, to_start=True): """ Spawn threads to ping host using a list of ports. Returns when all hosts are running (if to_start=True) / shut down (if to_start=False). """ threads = [] queue = Queue.Queue() for po...
python
def wait_for(self, ports, interval=1.0, timeout=30, to_start=True): """ Spawn threads to ping host using a list of ports. Returns when all hosts are running (if to_start=True) / shut down (if to_start=False). """ threads = [] queue = Queue.Queue() for po...
[ "def", "wait_for", "(", "self", ",", "ports", ",", "interval", "=", "1.0", ",", "timeout", "=", "30", ",", "to_start", "=", "True", ")", ":", "threads", "=", "[", "]", "queue", "=", "Queue", ".", "Queue", "(", ")", "for", "port", "in", "ports", "...
Spawn threads to ping host using a list of ports. Returns when all hosts are running (if to_start=True) / shut down (if to_start=False).
[ "Spawn", "threads", "to", "ping", "host", "using", "a", "list", "of", "ports", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1348-L1374
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._load_parameters
def _load_parameters(self): """ Load the .mlaunch_startup file that exists in each datadir. Handles different protocol versions. """ datapath = self.dir startup_file = os.path.join(datapath, '.mlaunch_startup') if not os.path.exists(startup_file): re...
python
def _load_parameters(self): """ Load the .mlaunch_startup file that exists in each datadir. Handles different protocol versions. """ datapath = self.dir startup_file = os.path.join(datapath, '.mlaunch_startup') if not os.path.exists(startup_file): re...
[ "def", "_load_parameters", "(", "self", ")", ":", "datapath", "=", "self", ".", "dir", "startup_file", "=", "os", ".", "path", ".", "join", "(", "datapath", ",", "'.mlaunch_startup'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "startup_file...
Load the .mlaunch_startup file that exists in each datadir. Handles different protocol versions.
[ "Load", "the", ".", "mlaunch_startup", "file", "that", "exists", "in", "each", "datadir", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1378-L1410
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._create_paths
def _create_paths(self, basedir, name=None): """Create datadir and subdir paths.""" if name: datapath = os.path.join(basedir, name) else: datapath = basedir dbpath = os.path.join(datapath, 'db') if not os.path.exists(dbpath): os.makedirs(dbpat...
python
def _create_paths(self, basedir, name=None): """Create datadir and subdir paths.""" if name: datapath = os.path.join(basedir, name) else: datapath = basedir dbpath = os.path.join(datapath, 'db') if not os.path.exists(dbpath): os.makedirs(dbpat...
[ "def", "_create_paths", "(", "self", ",", "basedir", ",", "name", "=", "None", ")", ":", "if", "name", ":", "datapath", "=", "os", ".", "path", ".", "join", "(", "basedir", ",", "name", ")", "else", ":", "datapath", "=", "basedir", "dbpath", "=", "...
Create datadir and subdir paths.
[ "Create", "datadir", "and", "subdir", "paths", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1433-L1446
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._filter_valid_arguments
def _filter_valid_arguments(self, arguments, binary="mongod", config=False): """ Return a list of accepted arguments. Check which arguments in list are accepted by the specified binary (mongod, mongos). If an argument does not start with '-' but its ...
python
def _filter_valid_arguments(self, arguments, binary="mongod", config=False): """ Return a list of accepted arguments. Check which arguments in list are accepted by the specified binary (mongod, mongos). If an argument does not start with '-' but its ...
[ "def", "_filter_valid_arguments", "(", "self", ",", "arguments", ",", "binary", "=", "\"mongod\"", ",", "config", "=", "False", ")", ":", "if", "self", ".", "args", "and", "self", ".", "args", "[", "'binarypath'", "]", ":", "binary", "=", "os", ".", "p...
Return a list of accepted arguments. Check which arguments in list are accepted by the specified binary (mongod, mongos). If an argument does not start with '-' but its preceding argument was accepted, then it is accepted as well. Example ['--slowms', '1000'] both arguments would be acc...
[ "Return", "a", "list", "of", "accepted", "arguments", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1479-L1538
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._initiate_replset
def _initiate_replset(self, port, name, maxwait=30): """Initiate replica set.""" if not self.args['replicaset'] and name != 'configRepl': if self.args['verbose']: print('Skipping replica set initialization for %s' % name) return con = self.client('localho...
python
def _initiate_replset(self, port, name, maxwait=30): """Initiate replica set.""" if not self.args['replicaset'] and name != 'configRepl': if self.args['verbose']: print('Skipping replica set initialization for %s' % name) return con = self.client('localho...
[ "def", "_initiate_replset", "(", "self", ",", "port", ",", "name", ",", "maxwait", "=", "30", ")", ":", "if", "not", "self", ".", "args", "[", "'replicaset'", "]", "and", "name", "!=", "'configRepl'", ":", "if", "self", ".", "args", "[", "'verbose'", ...
Initiate replica set.
[ "Initiate", "replica", "set", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1667-L1692
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._construct_sharded
def _construct_sharded(self): """Construct command line strings for a sharded cluster.""" current_version = self.getMongoDVersion() num_mongos = self.args['mongos'] if self.args['mongos'] > 0 else 1 shard_names = self._get_shard_names(self.args) # create shards as stand-alones...
python
def _construct_sharded(self): """Construct command line strings for a sharded cluster.""" current_version = self.getMongoDVersion() num_mongos = self.args['mongos'] if self.args['mongos'] > 0 else 1 shard_names = self._get_shard_names(self.args) # create shards as stand-alones...
[ "def", "_construct_sharded", "(", "self", ")", ":", "current_version", "=", "self", ".", "getMongoDVersion", "(", ")", "num_mongos", "=", "self", ".", "args", "[", "'mongos'", "]", "if", "self", ".", "args", "[", "'mongos'", "]", ">", "0", "else", "1", ...
Construct command line strings for a sharded cluster.
[ "Construct", "command", "line", "strings", "for", "a", "sharded", "cluster", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1820-L1892
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._construct_replset
def _construct_replset(self, basedir, portstart, name, num_nodes, arbiter, extra=''): """ Construct command line strings for a replicaset. Handles single set or sharded cluster. """ self.config_docs[name] = {'_id': name, 'members': []} # Const...
python
def _construct_replset(self, basedir, portstart, name, num_nodes, arbiter, extra=''): """ Construct command line strings for a replicaset. Handles single set or sharded cluster. """ self.config_docs[name] = {'_id': name, 'members': []} # Const...
[ "def", "_construct_replset", "(", "self", ",", "basedir", ",", "portstart", ",", "name", ",", "num_nodes", ",", "arbiter", ",", "extra", "=", "''", ")", ":", "self", ".", "config_docs", "[", "name", "]", "=", "{", "'_id'", ":", "name", ",", "'members'"...
Construct command line strings for a replicaset. Handles single set or sharded cluster.
[ "Construct", "command", "line", "strings", "for", "a", "replicaset", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1894-L1943
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._construct_config
def _construct_config(self, basedir, port, name=None, isreplset=False): """Construct command line strings for a config server.""" if isreplset: return self._construct_replset(basedir=basedir, portstart=port, name=name, ...
python
def _construct_config(self, basedir, port, name=None, isreplset=False): """Construct command line strings for a config server.""" if isreplset: return self._construct_replset(basedir=basedir, portstart=port, name=name, ...
[ "def", "_construct_config", "(", "self", ",", "basedir", ",", "port", ",", "name", "=", "None", ",", "isreplset", "=", "False", ")", ":", "if", "isreplset", ":", "return", "self", ".", "_construct_replset", "(", "basedir", "=", "basedir", ",", "portstart",...
Construct command line strings for a config server.
[ "Construct", "command", "line", "strings", "for", "a", "config", "server", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1945-L1957
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._construct_single
def _construct_single(self, basedir, port, name=None, extra=''): """ Construct command line strings for a single node. Handles shards and stand-alones. """ datapath = self._create_paths(basedir, name) self._construct_mongod(os.path.join(datapath, 'db'), ...
python
def _construct_single(self, basedir, port, name=None, extra=''): """ Construct command line strings for a single node. Handles shards and stand-alones. """ datapath = self._create_paths(basedir, name) self._construct_mongod(os.path.join(datapath, 'db'), ...
[ "def", "_construct_single", "(", "self", ",", "basedir", ",", "port", ",", "name", "=", "None", ",", "extra", "=", "''", ")", ":", "datapath", "=", "self", ".", "_create_paths", "(", "basedir", ",", "name", ")", "self", ".", "_construct_mongod", "(", "...
Construct command line strings for a single node. Handles shards and stand-alones.
[ "Construct", "command", "line", "strings", "for", "a", "single", "node", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1959-L1972
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._construct_mongod
def _construct_mongod(self, dbpath, logpath, port, replset=None, extra=''): """Construct command line strings for mongod process.""" rs_param = '' if replset: rs_param = '--replSet %s' % replset auth_param = '' if self.args['auth']: key_path = os.path.abs...
python
def _construct_mongod(self, dbpath, logpath, port, replset=None, extra=''): """Construct command line strings for mongod process.""" rs_param = '' if replset: rs_param = '--replSet %s' % replset auth_param = '' if self.args['auth']: key_path = os.path.abs...
[ "def", "_construct_mongod", "(", "self", ",", "dbpath", ",", "logpath", ",", "port", ",", "replset", "=", "None", ",", "extra", "=", "''", ")", ":", "rs_param", "=", "''", "if", "replset", ":", "rs_param", "=", "'--replSet %s'", "%", "replset", "auth_par...
Construct command line strings for mongod process.
[ "Construct", "command", "line", "strings", "for", "mongod", "process", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1974-L2029
train
rueckstiess/mtools
mtools/mlaunch/mlaunch.py
MLaunchTool._construct_mongos
def _construct_mongos(self, logpath, port, configdb): """Construct command line strings for a mongos process.""" extra = '' auth_param = '' if self.args['auth']: key_path = os.path.abspath(os.path.join(self.dir, 'keyfile')) auth_param = '--keyFile %s' % key_path ...
python
def _construct_mongos(self, logpath, port, configdb): """Construct command line strings for a mongos process.""" extra = '' auth_param = '' if self.args['auth']: key_path = os.path.abspath(os.path.join(self.dir, 'keyfile')) auth_param = '--keyFile %s' % key_path ...
[ "def", "_construct_mongos", "(", "self", ",", "logpath", ",", "port", ",", "configdb", ")", ":", "extra", "=", "''", "auth_param", "=", "''", "if", "self", ".", "args", "[", "'auth'", "]", ":", "key_path", "=", "os", ".", "path", ".", "abspath", "(",...
Construct command line strings for a mongos process.
[ "Construct", "command", "line", "strings", "for", "a", "mongos", "process", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L2031-L2059
train
rueckstiess/mtools
mtools/util/logcodeline.py
LogCodeLine.addMatch
def addMatch(self, version, filename, lineno, loglevel, trigger): """ Add a match to the LogCodeLine. Include the version, filename of the source file, the line number, and the loglevel. """ self.versions.add(version) self.matches[version].append((filename, linen...
python
def addMatch(self, version, filename, lineno, loglevel, trigger): """ Add a match to the LogCodeLine. Include the version, filename of the source file, the line number, and the loglevel. """ self.versions.add(version) self.matches[version].append((filename, linen...
[ "def", "addMatch", "(", "self", ",", "version", ",", "filename", ",", "lineno", ",", "loglevel", ",", "trigger", ")", ":", "self", ".", "versions", ".", "add", "(", "version", ")", "self", ".", "matches", "[", "version", "]", ".", "append", "(", "(",...
Add a match to the LogCodeLine. Include the version, filename of the source file, the line number, and the loglevel.
[ "Add", "a", "match", "to", "the", "LogCodeLine", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logcodeline.py#L29-L37
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/event_type.py
RSStatePlotType.accept_line
def accept_line(self, logevent): """ Return True on match. Only match log lines containing 'is now in state' (reflects other node's state changes) or of type "[rsMgr] replSet PRIMARY" (reflects own state changes). """ if ("is now in state" in logevent.line_str an...
python
def accept_line(self, logevent): """ Return True on match. Only match log lines containing 'is now in state' (reflects other node's state changes) or of type "[rsMgr] replSet PRIMARY" (reflects own state changes). """ if ("is now in state" in logevent.line_str an...
[ "def", "accept_line", "(", "self", ",", "logevent", ")", ":", "if", "(", "\"is now in state\"", "in", "logevent", ".", "line_str", "and", "logevent", ".", "split_tokens", "[", "-", "1", "]", "in", "self", ".", "states", ")", ":", "return", "True", "if", ...
Return True on match. Only match log lines containing 'is now in state' (reflects other node's state changes) or of type "[rsMgr] replSet PRIMARY" (reflects own state changes).
[ "Return", "True", "on", "match", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/event_type.py#L73-L90
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/event_type.py
RSStatePlotType.color_map
def color_map(cls, group): print("Group %s" % group) """ Change default color behavior. Map certain states always to the same colors (similar to MMS). """ try: state_idx = cls.states.index(group) except ValueError: # on any unexpected stat...
python
def color_map(cls, group): print("Group %s" % group) """ Change default color behavior. Map certain states always to the same colors (similar to MMS). """ try: state_idx = cls.states.index(group) except ValueError: # on any unexpected stat...
[ "def", "color_map", "(", "cls", ",", "group", ")", ":", "print", "(", "\"Group %s\"", "%", "group", ")", "try", ":", "state_idx", "=", "cls", ".", "states", ".", "index", "(", "group", ")", "except", "ValueError", ":", "state_idx", "=", "5", "return", ...
Change default color behavior. Map certain states always to the same colors (similar to MMS).
[ "Change", "default", "color", "behavior", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/event_type.py#L97-L109
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/base_type.py
BasePlotType.add_line
def add_line(self, logevent): """Append log line to this plot type.""" key = None self.empty = False self.groups.setdefault(key, list()).append(logevent)
python
def add_line(self, logevent): """Append log line to this plot type.""" key = None self.empty = False self.groups.setdefault(key, list()).append(logevent)
[ "def", "add_line", "(", "self", ",", "logevent", ")", ":", "key", "=", "None", "self", ".", "empty", "=", "False", "self", ".", "groups", ".", "setdefault", "(", "key", ",", "list", "(", ")", ")", ".", "append", "(", "logevent", ")" ]
Append log line to this plot type.
[ "Append", "log", "line", "to", "this", "plot", "type", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/base_type.py#L53-L57
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/base_type.py
BasePlotType.logevents
def logevents(self): """Iterator yielding all logevents from groups dictionary.""" for key in self.groups: for logevent in self.groups[key]: yield logevent
python
def logevents(self): """Iterator yielding all logevents from groups dictionary.""" for key in self.groups: for logevent in self.groups[key]: yield logevent
[ "def", "logevents", "(", "self", ")", ":", "for", "key", "in", "self", ".", "groups", ":", "for", "logevent", "in", "self", ".", "groups", "[", "key", "]", ":", "yield", "logevent" ]
Iterator yielding all logevents from groups dictionary.
[ "Iterator", "yielding", "all", "logevents", "from", "groups", "dictionary", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/base_type.py#L60-L64
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/histogram_type.py
HistogramPlotType.clicked
def clicked(self, event): """Print group name and number of items in bin.""" group = event.artist._mt_group n = event.artist._mt_n dt = num2date(event.artist._mt_bin) print("%4i %s events in %s sec beginning at %s" % (n, group, self.bucketsize, dt.strftime("%b %d %H...
python
def clicked(self, event): """Print group name and number of items in bin.""" group = event.artist._mt_group n = event.artist._mt_n dt = num2date(event.artist._mt_bin) print("%4i %s events in %s sec beginning at %s" % (n, group, self.bucketsize, dt.strftime("%b %d %H...
[ "def", "clicked", "(", "self", ",", "event", ")", ":", "group", "=", "event", ".", "artist", ".", "_mt_group", "n", "=", "event", ".", "artist", ".", "_mt_n", "dt", "=", "num2date", "(", "event", ".", "artist", ".", "_mt_bin", ")", "print", "(", "\...
Print group name and number of items in bin.
[ "Print", "group", "name", "and", "number", "of", "items", "in", "bin", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/histogram_type.py#L153-L159
train
rueckstiess/mtools
mtools/util/grouping.py
Grouping.add
def add(self, item, group_by=None): """General purpose class to group items by certain criteria.""" key = None if not group_by: group_by = self.group_by if group_by: # if group_by is a function, use it with item as argument if hasattr(group_by, '__ca...
python
def add(self, item, group_by=None): """General purpose class to group items by certain criteria.""" key = None if not group_by: group_by = self.group_by if group_by: # if group_by is a function, use it with item as argument if hasattr(group_by, '__ca...
[ "def", "add", "(", "self", ",", "item", ",", "group_by", "=", "None", ")", ":", "key", "=", "None", "if", "not", "group_by", ":", "group_by", "=", "self", ".", "group_by", "if", "group_by", ":", "if", "hasattr", "(", "group_by", ",", "'__call__'", ")...
General purpose class to group items by certain criteria.
[ "General", "purpose", "class", "to", "group", "items", "by", "certain", "criteria", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/grouping.py#L23-L50
train
rueckstiess/mtools
mtools/util/grouping.py
Grouping.regroup
def regroup(self, group_by=None): """Regroup items.""" if not group_by: group_by = self.group_by groups = self.groups self.groups = {} for g in groups: for item in groups[g]: self.add(item, group_by)
python
def regroup(self, group_by=None): """Regroup items.""" if not group_by: group_by = self.group_by groups = self.groups self.groups = {} for g in groups: for item in groups[g]: self.add(item, group_by)
[ "def", "regroup", "(", "self", ",", "group_by", "=", "None", ")", ":", "if", "not", "group_by", ":", "group_by", "=", "self", ".", "group_by", "groups", "=", "self", ".", "groups", "self", ".", "groups", "=", "{", "}", "for", "g", "in", "groups", "...
Regroup items.
[ "Regroup", "items", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/grouping.py#L78-L88
train
rueckstiess/mtools
mtools/util/grouping.py
Grouping.move_items
def move_items(self, from_group, to_group): """Take all elements from the from_group and add it to the to_group.""" if from_group not in self.keys() or len(self.groups[from_group]) == 0: return self.groups.setdefault(to_group, list()).extend(self.groups.get ...
python
def move_items(self, from_group, to_group): """Take all elements from the from_group and add it to the to_group.""" if from_group not in self.keys() or len(self.groups[from_group]) == 0: return self.groups.setdefault(to_group, list()).extend(self.groups.get ...
[ "def", "move_items", "(", "self", ",", "from_group", ",", "to_group", ")", ":", "if", "from_group", "not", "in", "self", ".", "keys", "(", ")", "or", "len", "(", "self", ".", "groups", "[", "from_group", "]", ")", "==", "0", ":", "return", "self", ...
Take all elements from the from_group and add it to the to_group.
[ "Take", "all", "elements", "from", "the", "from_group", "and", "add", "it", "to", "the", "to_group", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/grouping.py#L90-L98
train
rueckstiess/mtools
mtools/util/grouping.py
Grouping.sort_by_size
def sort_by_size(self, group_limit=None, discard_others=False, others_label='others'): """ Sort the groups by the number of elements they contain, descending. Also has option to limit the number of groups. If this option is chosen, the remaining elements are placed ...
python
def sort_by_size(self, group_limit=None, discard_others=False, others_label='others'): """ Sort the groups by the number of elements they contain, descending. Also has option to limit the number of groups. If this option is chosen, the remaining elements are placed ...
[ "def", "sort_by_size", "(", "self", ",", "group_limit", "=", "None", ",", "discard_others", "=", "False", ",", "others_label", "=", "'others'", ")", ":", "self", ".", "groups", "=", "OrderedDict", "(", "sorted", "(", "six", ".", "iteritems", "(", "self", ...
Sort the groups by the number of elements they contain, descending. Also has option to limit the number of groups. If this option is chosen, the remaining elements are placed into another group with the name specified with others_label. if discard_others is True, the others group is rem...
[ "Sort", "the", "groups", "by", "the", "number", "of", "elements", "they", "contain", "descending", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/grouping.py#L100-L138
train
rueckstiess/mtools
mtools/util/log2code.py
import_l2c_db
def import_l2c_db(): """ Static import helper function. Checks if the log2code.pickle exists first, otherwise raises ImportError. """ data_path = os.path.join(os.path.dirname(mtools.__file__), 'data') if os.path.exists(os.path.join(data_path, 'log2code.pickle')): av, lv, lbw, lcl = cPic...
python
def import_l2c_db(): """ Static import helper function. Checks if the log2code.pickle exists first, otherwise raises ImportError. """ data_path = os.path.join(os.path.dirname(mtools.__file__), 'data') if os.path.exists(os.path.join(data_path, 'log2code.pickle')): av, lv, lbw, lcl = cPic...
[ "def", "import_l2c_db", "(", ")", ":", "data_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "mtools", ".", "__file__", ")", ",", "'data'", ")", "if", "os", ".", "path", ".", "exists", "(", "os", ".", "pat...
Static import helper function. Checks if the log2code.pickle exists first, otherwise raises ImportError.
[ "Static", "import", "helper", "function", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L15-L29
train
rueckstiess/mtools
mtools/util/log2code.py
Log2CodeConverter._strip_counters
def _strip_counters(self, sub_line): """Find the codeline end by taking out the counters and durations.""" try: end = sub_line.rindex('}') except ValueError: return sub_line else: return sub_line[:(end + 1)]
python
def _strip_counters(self, sub_line): """Find the codeline end by taking out the counters and durations.""" try: end = sub_line.rindex('}') except ValueError: return sub_line else: return sub_line[:(end + 1)]
[ "def", "_strip_counters", "(", "self", ",", "sub_line", ")", ":", "try", ":", "end", "=", "sub_line", ".", "rindex", "(", "'}'", ")", "except", "ValueError", ":", "return", "sub_line", "else", ":", "return", "sub_line", "[", ":", "(", "end", "+", "1", ...
Find the codeline end by taking out the counters and durations.
[ "Find", "the", "codeline", "end", "by", "taking", "out", "the", "counters", "and", "durations", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L78-L85
train
rueckstiess/mtools
mtools/util/log2code.py
Log2CodeConverter._strip_datetime
def _strip_datetime(self, sub_line): """Strip datetime and other parts so that there is no redundancy.""" try: begin = sub_line.index(']') except ValueError: return sub_line else: # create a "" in place character for the beginnings.. # need...
python
def _strip_datetime(self, sub_line): """Strip datetime and other parts so that there is no redundancy.""" try: begin = sub_line.index(']') except ValueError: return sub_line else: # create a "" in place character for the beginnings.. # need...
[ "def", "_strip_datetime", "(", "self", ",", "sub_line", ")", ":", "try", ":", "begin", "=", "sub_line", ".", "index", "(", "']'", ")", "except", "ValueError", ":", "return", "sub_line", "else", ":", "sub", "=", "sub_line", "[", "begin", "+", "1", ":", ...
Strip datetime and other parts so that there is no redundancy.
[ "Strip", "datetime", "and", "other", "parts", "so", "that", "there", "is", "no", "redundancy", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L87-L97
train
rueckstiess/mtools
mtools/util/log2code.py
Log2CodeConverter._find_variable
def _find_variable(self, pattern, logline): """ Return the variable parts of the code given a tuple of strings pattern. Example: (this, is, a, pattern) -> 'this is a good pattern' -> [good] """ var_subs = [] # find the beginning of the pattern first_index = logli...
python
def _find_variable(self, pattern, logline): """ Return the variable parts of the code given a tuple of strings pattern. Example: (this, is, a, pattern) -> 'this is a good pattern' -> [good] """ var_subs = [] # find the beginning of the pattern first_index = logli...
[ "def", "_find_variable", "(", "self", ",", "pattern", ",", "logline", ")", ":", "var_subs", "=", "[", "]", "first_index", "=", "logline", ".", "index", "(", "pattern", "[", "0", "]", ")", "beg_str", "=", "logline", "[", ":", "first_index", "]", "var_su...
Return the variable parts of the code given a tuple of strings pattern. Example: (this, is, a, pattern) -> 'this is a good pattern' -> [good]
[ "Return", "the", "variable", "parts", "of", "the", "code", "given", "a", "tuple", "of", "strings", "pattern", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L99-L132
train
rueckstiess/mtools
mtools/util/log2code.py
Log2CodeConverter._variable_parts
def _variable_parts(self, line, codeline): """Return variable parts of the codeline, given the static parts.""" var_subs = [] # codeline has pattern and then has the outputs in different versions if codeline: var_subs = self._find_variable(codeline.pattern, line) else...
python
def _variable_parts(self, line, codeline): """Return variable parts of the codeline, given the static parts.""" var_subs = [] # codeline has pattern and then has the outputs in different versions if codeline: var_subs = self._find_variable(codeline.pattern, line) else...
[ "def", "_variable_parts", "(", "self", ",", "line", ",", "codeline", ")", ":", "var_subs", "=", "[", "]", "if", "codeline", ":", "var_subs", "=", "self", ".", "_find_variable", "(", "codeline", ".", "pattern", ",", "line", ")", "else", ":", "line_str", ...
Return variable parts of the codeline, given the static parts.
[ "Return", "variable", "parts", "of", "the", "codeline", "given", "the", "static", "parts", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L134-L144
train
rueckstiess/mtools
mtools/util/log2code.py
Log2CodeConverter.combine
def combine(self, pattern, variable): """Combine a pattern and variable parts to be a line string again.""" inter_zip = izip_longest(variable, pattern, fillvalue='') interleaved = [elt for pair in inter_zip for elt in pair] return ''.join(interleaved)
python
def combine(self, pattern, variable): """Combine a pattern and variable parts to be a line string again.""" inter_zip = izip_longest(variable, pattern, fillvalue='') interleaved = [elt for pair in inter_zip for elt in pair] return ''.join(interleaved)
[ "def", "combine", "(", "self", ",", "pattern", ",", "variable", ")", ":", "inter_zip", "=", "izip_longest", "(", "variable", ",", "pattern", ",", "fillvalue", "=", "''", ")", "interleaved", "=", "[", "elt", "for", "pair", "in", "inter_zip", "for", "elt",...
Combine a pattern and variable parts to be a line string again.
[ "Combine", "a", "pattern", "and", "variable", "parts", "to", "be", "a", "line", "string", "again", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L154-L158
train
rueckstiess/mtools
mtools/util/cmdlinetool.py
BaseCmdLineTool.run
def run(self, arguments=None, get_unknowns=False): """ Init point to execute the script. If `arguments` string is given, will evaluate the arguments, else evaluates sys.argv. Any inheriting class should extend the run method (but first calling BaseCmdLineTool.run(self)). ...
python
def run(self, arguments=None, get_unknowns=False): """ Init point to execute the script. If `arguments` string is given, will evaluate the arguments, else evaluates sys.argv. Any inheriting class should extend the run method (but first calling BaseCmdLineTool.run(self)). ...
[ "def", "run", "(", "self", ",", "arguments", "=", "None", ",", "get_unknowns", "=", "False", ")", ":", "if", "os", ".", "name", "!=", "'nt'", ":", "signal", ".", "signal", "(", "signal", ".", "SIGPIPE", ",", "signal", ".", "SIG_DFL", ")", "if", "ge...
Init point to execute the script. If `arguments` string is given, will evaluate the arguments, else evaluates sys.argv. Any inheriting class should extend the run method (but first calling BaseCmdLineTool.run(self)).
[ "Init", "point", "to", "execute", "the", "script", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/cmdlinetool.py#L110-L139
train
rueckstiess/mtools
mtools/util/cmdlinetool.py
BaseCmdLineTool.update_progress
def update_progress(self, progress, prefix=''): """ Print a progress bar for longer-running scripts. The progress value is a value between 0.0 and 1.0. If a prefix is present, it will be printed before the progress bar. """ total_length = 40 if progress == 1.: ...
python
def update_progress(self, progress, prefix=''): """ Print a progress bar for longer-running scripts. The progress value is a value between 0.0 and 1.0. If a prefix is present, it will be printed before the progress bar. """ total_length = 40 if progress == 1.: ...
[ "def", "update_progress", "(", "self", ",", "progress", ",", "prefix", "=", "''", ")", ":", "total_length", "=", "40", "if", "progress", "==", "1.", ":", "sys", ".", "stderr", ".", "write", "(", "'\\r'", "+", "' '", "*", "(", "total_length", "+", "le...
Print a progress bar for longer-running scripts. The progress value is a value between 0.0 and 1.0. If a prefix is present, it will be printed before the progress bar.
[ "Print", "a", "progress", "bar", "for", "longer", "-", "running", "scripts", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/cmdlinetool.py#L153-L172
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/scatter_type.py
ScatterPlotType.accept_line
def accept_line(self, logevent): """Return True if the log line has the nominated yaxis field.""" if self.regex_mode: return bool(re.search(self.field, logevent.line_str)) else: return getattr(logevent, self.field) is not None
python
def accept_line(self, logevent): """Return True if the log line has the nominated yaxis field.""" if self.regex_mode: return bool(re.search(self.field, logevent.line_str)) else: return getattr(logevent, self.field) is not None
[ "def", "accept_line", "(", "self", ",", "logevent", ")", ":", "if", "self", ".", "regex_mode", ":", "return", "bool", "(", "re", ".", "search", "(", "self", ".", "field", ",", "logevent", ".", "line_str", ")", ")", "else", ":", "return", "getattr", "...
Return True if the log line has the nominated yaxis field.
[ "Return", "True", "if", "the", "log", "line", "has", "the", "nominated", "yaxis", "field", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/scatter_type.py#L54-L59
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/scatter_type.py
ScatterPlotType.clicked
def clicked(self, event): """ Call if an element of this plottype is clicked. Implement in sub class. """ group = event.artist._mt_group indices = event.ind # double click only supported on 1.2 or later major, minor, _ = mpl_version.split('.') if...
python
def clicked(self, event): """ Call if an element of this plottype is clicked. Implement in sub class. """ group = event.artist._mt_group indices = event.ind # double click only supported on 1.2 or later major, minor, _ = mpl_version.split('.') if...
[ "def", "clicked", "(", "self", ",", "event", ")", ":", "group", "=", "event", ".", "artist", ".", "_mt_group", "indices", "=", "event", ".", "ind", "major", ",", "minor", ",", "_", "=", "mpl_version", ".", "split", "(", "'.'", ")", "if", "(", "int"...
Call if an element of this plottype is clicked. Implement in sub class.
[ "Call", "if", "an", "element", "of", "this", "plottype", "is", "clicked", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/scatter_type.py#L88-L140
train
rueckstiess/mtools
mtools/mloginfo/mloginfo.py
MLogInfoTool.run
def run(self, arguments=None): """Print useful information about the log file.""" LogFileTool.run(self, arguments) for i, self.logfile in enumerate(self.args['logfile']): if i > 0: print("\n ------------------------------------------\n") if self.logfile....
python
def run(self, arguments=None): """Print useful information about the log file.""" LogFileTool.run(self, arguments) for i, self.logfile in enumerate(self.args['logfile']): if i > 0: print("\n ------------------------------------------\n") if self.logfile....
[ "def", "run", "(", "self", ",", "arguments", "=", "None", ")", ":", "LogFileTool", ".", "run", "(", "self", ",", "arguments", ")", "for", "i", ",", "self", ".", "logfile", "in", "enumerate", "(", "self", ".", "args", "[", "'logfile'", "]", ")", ":"...
Print useful information about the log file.
[ "Print", "useful", "information", "about", "the", "log", "file", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mloginfo/mloginfo.py#L32-L90
train
rueckstiess/mtools
mtools/util/logfile.py
LogFile.filesize
def filesize(self): """ Lazy evaluation of start and end of logfile. Returns None for stdin input currently. """ if self.from_stdin: return None if not self._filesize: self._calculate_bounds() return self._filesize
python
def filesize(self): """ Lazy evaluation of start and end of logfile. Returns None for stdin input currently. """ if self.from_stdin: return None if not self._filesize: self._calculate_bounds() return self._filesize
[ "def", "filesize", "(", "self", ")", ":", "if", "self", ".", "from_stdin", ":", "return", "None", "if", "not", "self", ".", "_filesize", ":", "self", ".", "_calculate_bounds", "(", ")", "return", "self", ".", "_filesize" ]
Lazy evaluation of start and end of logfile. Returns None for stdin input currently.
[ "Lazy", "evaluation", "of", "start", "and", "end", "of", "logfile", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L84-L94
train
rueckstiess/mtools
mtools/util/logfile.py
LogFile.num_lines
def num_lines(self): """ Lazy evaluation of the number of lines. Returns None for stdin input currently. """ if self.from_stdin: return None if not self._num_lines: self._iterate_lines() return self._num_lines
python
def num_lines(self): """ Lazy evaluation of the number of lines. Returns None for stdin input currently. """ if self.from_stdin: return None if not self._num_lines: self._iterate_lines() return self._num_lines
[ "def", "num_lines", "(", "self", ")", ":", "if", "self", ".", "from_stdin", ":", "return", "None", "if", "not", "self", ".", "_num_lines", ":", "self", ".", "_iterate_lines", "(", ")", "return", "self", ".", "_num_lines" ]
Lazy evaluation of the number of lines. Returns None for stdin input currently.
[ "Lazy", "evaluation", "of", "the", "number", "of", "lines", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L118-L128
train
rueckstiess/mtools
mtools/util/logfile.py
LogFile.versions
def versions(self): """Return all version changes.""" versions = [] for v, _ in self.restarts: if len(versions) == 0 or v != versions[-1]: versions.append(v) return versions
python
def versions(self): """Return all version changes.""" versions = [] for v, _ in self.restarts: if len(versions) == 0 or v != versions[-1]: versions.append(v) return versions
[ "def", "versions", "(", "self", ")", ":", "versions", "=", "[", "]", "for", "v", ",", "_", "in", "self", ".", "restarts", ":", "if", "len", "(", "versions", ")", "==", "0", "or", "v", "!=", "versions", "[", "-", "1", "]", ":", "versions", ".", ...
Return all version changes.
[ "Return", "all", "version", "changes", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L166-L172
train
rueckstiess/mtools
mtools/util/logfile.py
LogFile.next
def next(self): """Get next line, adjust for year rollover and hint datetime format.""" # use readline here because next() iterator uses internal readahead # buffer so seek position is wrong line = self.filehandle.readline() line = line.decode('utf-8', 'replace') if line ...
python
def next(self): """Get next line, adjust for year rollover and hint datetime format.""" # use readline here because next() iterator uses internal readahead # buffer so seek position is wrong line = self.filehandle.readline() line = line.decode('utf-8', 'replace') if line ...
[ "def", "next", "(", "self", ")", ":", "line", "=", "self", ".", "filehandle", ".", "readline", "(", ")", "line", "=", "line", ".", "decode", "(", "'utf-8'", ",", "'replace'", ")", "if", "line", "==", "''", ":", "raise", "StopIteration", "line", "=", ...
Get next line, adjust for year rollover and hint datetime format.
[ "Get", "next", "line", "adjust", "for", "year", "rollover", "and", "hint", "datetime", "format", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L210-L236
train
rueckstiess/mtools
mtools/util/logfile.py
LogFile._calculate_bounds
def _calculate_bounds(self): """Calculate beginning and end of logfile.""" if self._bounds_calculated: # Assume no need to recalc bounds for lifetime of a Logfile object return if self.from_stdin: return False # we should be able to find a valid log ...
python
def _calculate_bounds(self): """Calculate beginning and end of logfile.""" if self._bounds_calculated: # Assume no need to recalc bounds for lifetime of a Logfile object return if self.from_stdin: return False # we should be able to find a valid log ...
[ "def", "_calculate_bounds", "(", "self", ")", ":", "if", "self", ".", "_bounds_calculated", ":", "return", "if", "self", ".", "from_stdin", ":", "return", "False", "max_start_lines", "=", "10", "lines_checked", "=", "0", "for", "line", "in", "self", ".", "...
Calculate beginning and end of logfile.
[ "Calculate", "beginning", "and", "end", "of", "logfile", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L407-L461
train
rueckstiess/mtools
mtools/util/logfile.py
LogFile._find_curr_line
def _find_curr_line(self, prev=False): """ Internal helper function. Find the current (or previous if prev=True) line in a log file based on the current seek position. """ curr_pos = self.filehandle.tell() # jump back 15k characters (at most) and find last newli...
python
def _find_curr_line(self, prev=False): """ Internal helper function. Find the current (or previous if prev=True) line in a log file based on the current seek position. """ curr_pos = self.filehandle.tell() # jump back 15k characters (at most) and find last newli...
[ "def", "_find_curr_line", "(", "self", ",", "prev", "=", "False", ")", ":", "curr_pos", "=", "self", ".", "filehandle", ".", "tell", "(", ")", "jump_back", "=", "min", "(", "self", ".", "filehandle", ".", "tell", "(", ")", ",", "15000", ")", "self", ...
Internal helper function. Find the current (or previous if prev=True) line in a log file based on the current seek position.
[ "Internal", "helper", "function", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L463-L515
train
rueckstiess/mtools
mtools/util/logfile.py
LogFile.fast_forward
def fast_forward(self, start_dt): """ Fast-forward file to given start_dt datetime obj using binary search. Only fast for files. Streams need to be forwarded manually, and it will miss the first line that would otherwise match (as it consumes the log line). """ i...
python
def fast_forward(self, start_dt): """ Fast-forward file to given start_dt datetime obj using binary search. Only fast for files. Streams need to be forwarded manually, and it will miss the first line that would otherwise match (as it consumes the log line). """ i...
[ "def", "fast_forward", "(", "self", ",", "start_dt", ")", ":", "if", "self", ".", "from_stdin", ":", "return", "else", ":", "max_mark", "=", "self", ".", "filesize", "step_size", "=", "max_mark", "self", ".", "filehandle", ".", "seek", "(", "0", ")", "...
Fast-forward file to given start_dt datetime obj using binary search. Only fast for files. Streams need to be forwarded manually, and it will miss the first line that would otherwise match (as it consumes the log line).
[ "Fast", "-", "forward", "file", "to", "given", "start_dt", "datetime", "obj", "using", "binary", "search", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L517-L566
train
rueckstiess/mtools
mtools/mlogfilter/filters/datetime_filter.py
DateTimeFilter.setup
def setup(self): """Get start end end date of logfile before starting to parse.""" if self.mlogfilter.is_stdin: # assume this year (we have no other info) now = datetime.now() self.startDateTime = datetime(now.year, 1, 1, tzinfo=tzutc()) self.endDateTime =...
python
def setup(self): """Get start end end date of logfile before starting to parse.""" if self.mlogfilter.is_stdin: # assume this year (we have no other info) now = datetime.now() self.startDateTime = datetime(now.year, 1, 1, tzinfo=tzutc()) self.endDateTime =...
[ "def", "setup", "(", "self", ")", ":", "if", "self", ".", "mlogfilter", ".", "is_stdin", ":", "now", "=", "datetime", ".", "now", "(", ")", "self", ".", "startDateTime", "=", "datetime", "(", "now", ".", "year", ",", "1", ",", "1", ",", "tzinfo", ...
Get start end end date of logfile before starting to parse.
[ "Get", "start", "end", "end", "date", "of", "logfile", "before", "starting", "to", "parse", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/filters/datetime_filter.py#L108-L151
train