id
int32
0
252k
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
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
244,000
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: all_indices = range(len(descendants)) if seal_check_random_sample_rate == 1: indices_to_check_seal = set(all_indi...
[ "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
244,001
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': genesis_vm_class = cls.get_vm_class_for_block_number(BlockNumber(0)) pre_genesis_header = BlockHeader(di...
[ "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
244,002
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': 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.chaindb)
[ "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
244,003
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: return self.get_vm_class_for_block_number( block_number=parent_header.block_number + 1, ).create_header_from_pare...
[ "def", "create_header_from_parent", "(", "self", ",", "parent_header", ":", "BlockHeader", ",", "*", "*", "header_params", ":", "HeaderParams", ")", "->", "BlockHeader", ":", "return", "self", ".", "get_vm_class_for_block_number", "(", "block_number", "=", "parent_h...
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
244,004
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: if header is None: head = self.get_canonical_head() return self.create_header_from_parent(head) else: return header
[ "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
244,005
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, ...]: ancestor_count = min(header.block_number, limit) # We construct a temporary block object vm_class = self.get_vm_class_for_block_number(header.block_number) block_class = vm_class.get_block_class() ...
[ "def", "get_ancestors", "(", "self", ",", "limit", ":", "int", ",", "header", ":", "BlockHeader", ")", "->", "Tuple", "[", "BaseBlock", ",", "...", "]", ":", "ancestor_count", "=", "min", "(", "header", ".", "block_number", ",", "limit", ")", "# We const...
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
244,006
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: validate_word(block_hash, title="Block Hash") block_header = self.get_block_header_by_hash(block_hash) return self.get_block_by_header(block_header)
[ "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
244,007
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: 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
244,008
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: validate_uint256(block_number, title="Block Number") return self.get_block_by_hash(self.chaindb.get_canonical_block_hash(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
244,009
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: (block_num, index) = self.chaindb.get_transaction_index(transaction_hash) VM_class = self.get_vm_class_for_block_number(block_num) transaction = self.chaindb.get_transaction_by_index( block_num, ...
[ "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
244,010
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: if at_header is None: at_header = self.get_canonical_head() with self.get_vm(at_header).state_in_temp_block() as state: return self.gas_estimator(...
[ "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
244,011
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, ...]]: try: parent_header = self.get_block_header_by_hash(block.header.parent_hash) except Heade...
[ "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
244,012
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: if block.is_genesis: raise ValidationError("Cannot validate genesis block this way") VM_class = self.get_vm_class_for_block_number(BlockNumber(block.number)) parent_block = self.get_block_by_hash(block.header.parent_hash) VM...
[ "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
244,013
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: 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: raise ValidationError( "The gas limit on block ...
[ "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
244,014
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: 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: # optimization to avoid loading ancestors from DB, since the block has no uncles ...
[ "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
244,015
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]: vm = self.get_vm(self.header) base_block = vm.block receipt, computation = vm.apply_transaction(base_block.header, transaction) h...
[ "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
244,016
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): host = 'localhost:%i' % port start_time = time.time() while True: if (time.time() - start_time) > timeout: if queue: queue.put_nowait((port, False)) ...
[ "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
244,017
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): host = 'localhost:%i' % port try: mc = MongoConnection(host) try: if username and password and authdb: if authdb != "admin": raise RuntimeError("given username/password is not for ...
[ "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
244,018
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): 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 nodes via init if all nodes are dow...
[ "def", "start", "(", "self", ")", ":", "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", "# ver...
Sub-command start.
[ "Sub", "-", "command", "start", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L861-L923
244,019
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): try: con = self.client('localhost:%s' % port) con.admin.command('ping') return True except (AutoReconnect, ConnectionFailure, OperationFailure): # Catch OperationFailure to work around SERVER-31916. return False
[ "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
244,020
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): # if tags is a simple string, make it a list (note: tuples like # ('mongos', 2) must be in a surrounding list) if not hasattr(tags, '__iter__') and type(tags) == str: tags = [tags] nodes = set(self.cluster_tags['all']) for tag in tags: ...
[ "def", "get_tagged", "(", "self", ",", "tags", ")", ":", "# if tags is a simple string, make it a list (note: tuples like", "# ('mongos', 2) must be in a surrounding list)", "if", "not", "hasattr", "(", "tags", ",", "'__iter__'", ")", "and", "type", "(", "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.g. 'primary'.
[ "Tag", "format", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1300-L1337
244,021
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): 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
244,022
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): threads = [] queue = Queue.Queue() for port in ports: threads.append(threading.Thread(target=wait_for_host, args=( port, interval, timeout, to_start, queue, self.ssl_pymongo_options))...
[ "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
244,023
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): datapath = self.dir startup_file = os.path.join(datapath, '.mlaunch_startup') if not os.path.exists(startup_file): return False in_dict = json.load(open(startup_file, 'rb')) # handle legacy version without versioned protocol if '...
[ "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
244,024
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): 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(dbpath) if self.args['verbose']: ...
[ "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
244,025
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): # get the help list of the binary if self.args and self.args['binarypath']: binary = os.path.join(self.args['binarypath'], binary) ret = (subprocess.Popen(['%s' % binary, '--h...
[ "def", "_filter_valid_arguments", "(", "self", ",", "arguments", ",", "binary", "=", "\"mongod\"", ",", "config", "=", "False", ")", ":", "# get the help list of the binary", "if", "self", ".", "args", "and", "self", ".", "args", "[", "'binarypath'", "]", ":",...
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
244,026
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): if not self.args['replicaset'] and name != 'configRepl': if self.args['verbose']: print('Skipping replica set initialization for %s' % name) return con = self.client('localhost:%i' % port) try: ...
[ "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
244,027
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): 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 or replica sets nextport = self.args['port'] + num_mongos ...
[ "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
244,028
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=''): self.config_docs[name] = {'_id': name, 'members': []} # Construct individual replica set nodes for i in num_nodes: datapath = self._create_paths(basedir, '%s/rs%i' % (nam...
[ "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
244,029
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): if isreplset: return self._construct_replset(basedir=basedir, portstart=port, name=name, num_nodes=list(range( ...
[ "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
244,030
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=''): datapath = self._create_paths(basedir, name) self._construct_mongod(os.path.join(datapath, 'db'), os.path.join(datapath, 'mongod.log'), port, replset=None, extra=extra) ...
[ "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
244,031
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=''): rs_param = '' if replset: rs_param = '--replSet %s' % replset auth_param = '' if self.args['auth']: key_path = os.path.abspath(os.path.join(self.dir, 'keyfile')) auth_param = ...
[ "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
244,032
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): extra = '' auth_param = '' if self.args['auth']: key_path = os.path.abspath(os.path.join(self.dir, 'keyfile')) auth_param = '--keyFile %s' % key_path if self.unknown_args: extra = self._filter_val...
[ "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
244,033
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): self.versions.add(version) self.matches[version].append((filename, lineno, loglevel, trigger))
[ "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
244,034
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): if ("is now in state" in logevent.line_str and logevent.split_tokens[-1] in self.states): return True if ("replSet" in logevent.line_str and logevent.thread == "rsMgr" and logevent.split_tokens[-1] in self.stat...
[ "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
244,035
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) try: state_idx = cls.states.index(group) except ValueError: # on any unexpected state, return black state_idx = 5 return cls.colors[state_idx], cls.markers[0]
[ "def", "color_map", "(", "cls", ",", "group", ")", ":", "print", "(", "\"Group %s\"", "%", "group", ")", "try", ":", "state_idx", "=", "cls", ".", "states", ".", "index", "(", "group", ")", "except", "ValueError", ":", "# on any unexpected state, return blac...
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
244,036
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): 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
244,037
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): 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
244,038
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): 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:%M:%S")))
[ "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
244,039
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): 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, '__call__'): key = group_by(item) # if the item ...
[ "def", "add", "(", "self", ",", "item", ",", "group_by", "=", "None", ")", ":", "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"...
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
244,040
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): 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
244,041
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): 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 (from_group, list())) if from_group in se...
[ "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
244,042
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 groups by number of elements self.groups = OrderedDict(sorted(six.iteritems(self.groups), key=lambda x: len(x[1]), ...
[ "def", "sort_by_size", "(", "self", ",", "group_limit", "=", "None", ",", "discard_others", "=", "False", ",", "others_label", "=", "'others'", ")", ":", "# sort groups by number of elements", "self", ".", "groups", "=", "OrderedDict", "(", "sorted", "(", "six",...
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
244,043
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(): 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 = cPickle.load(open(os.path.join(data_path, 'log2code.pickle'), ...
[ "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
244,044
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): 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
244,045
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): try: begin = sub_line.index(']') except ValueError: return sub_line else: # create a "" in place character for the beginnings.. # needed when interleaving the lists sub = sub_line[begin + 1:] ...
[ "def", "_strip_datetime", "(", "self", ",", "sub_line", ")", ":", "try", ":", "begin", "=", "sub_line", ".", "index", "(", "']'", ")", "except", "ValueError", ":", "return", "sub_line", "else", ":", "# create a \"\" in place character for the beginnings..", "# nee...
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
244,046
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): var_subs = [] # find the beginning of the pattern first_index = logline.index(pattern[0]) beg_str = logline[:first_index] # strip the beginning substring var_subs.append(self._strip_datetime(beg_str)) for patt, patt_nex...
[ "def", "_find_variable", "(", "self", ",", "pattern", ",", "logline", ")", ":", "var_subs", "=", "[", "]", "# find the beginning of the pattern", "first_index", "=", "logline", ".", "index", "(", "pattern", "[", "0", "]", ")", "beg_str", "=", "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]
[ "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
244,047
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): var_subs = [] # codeline has pattern and then has the outputs in different versions if codeline: var_subs = self._find_variable(codeline.pattern, line) else: # make variable part of the line string without all the other s...
[ "def", "_variable_parts", "(", "self", ",", "line", ",", "codeline", ")", ":", "var_subs", "=", "[", "]", "# codeline has pattern and then has the outputs in different versions", "if", "codeline", ":", "var_subs", "=", "self", ".", "_find_variable", "(", "codeline", ...
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
244,048
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): 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
244,049
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): # redirect PIPE signal to quiet kill script, if not on Windows if os.name != 'nt': signal.signal(signal.SIGPIPE, signal.SIG_DFL) if get_unknowns: if arguments: self.args, self.unknown_args = (self.argparse...
[ "def", "run", "(", "self", ",", "arguments", "=", "None", ",", "get_unknowns", "=", "False", ")", ":", "# redirect PIPE signal to quiet kill script, if not on Windows", "if", "os", ".", "name", "!=", "'nt'", ":", "signal", ".", "signal", "(", "signal", ".", "S...
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
244,050
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=''): total_length = 40 if progress == 1.: sys.stderr.write('\r' + ' ' * (total_length + len(prefix) + 50)) sys.stderr.write('\n') sys.stderr.flush() else: bar_length = int(round(total_length * progress)) ...
[ "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
244,051
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): 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
244,052
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): group = event.artist._mt_group indices = event.ind # double click only supported on 1.2 or later major, minor, _ = mpl_version.split('.') if (int(major), int(minor)) < (1, 2) or not event.mouseevent.dblclick: for i in indices: ...
[ "def", "clicked", "(", "self", ",", "event", ")", ":", "group", "=", "event", ".", "artist", ".", "_mt_group", "indices", "=", "event", ".", "ind", "# double click only supported on 1.2 or later", "major", ",", "minor", ",", "_", "=", "mpl_version", ".", "sp...
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
244,053
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): LogFileTool.run(self, arguments) for i, self.logfile in enumerate(self.args['logfile']): if i > 0: print("\n ------------------------------------------\n") if self.logfile.datetime_format == 'ctime-pre2.4': # no mil...
[ "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
244,054
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): 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
244,055
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): 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
244,056
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): 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
244,057
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): # 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 == '': raise StopIteration line = line.rstrip('\n') ...
[ "def", "next", "(", "self", ")", ":", "# use readline here because next() iterator uses internal readahead", "# buffer so seek position is wrong", "line", "=", "self", ".", "filehandle", ".", "readline", "(", ")", "line", "=", "line", ".", "decode", "(", "'utf-8'", ",...
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
244,058
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): 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 line within max_start_lines max_start_lines = ...
[ "def", "_calculate_bounds", "(", "self", ")", ":", "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 l...
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
244,059
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): curr_pos = self.filehandle.tell() # jump back 15k characters (at most) and find last newline char jump_back = min(self.filehandle.tell(), 15000) self.filehandle.seek(-jump_back, 1) buff = self.filehandle.read(jump_back) self.filehan...
[ "def", "_find_curr_line", "(", "self", ",", "prev", "=", "False", ")", ":", "curr_pos", "=", "self", ".", "filehandle", ".", "tell", "(", ")", "# jump back 15k characters (at most) and find last newline char", "jump_back", "=", "min", "(", "self", ".", "filehandle...
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
244,060
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): if self.from_stdin: # skip lines until start_dt is reached return else: # fast bisection path max_mark = self.filesize step_size = max_mark # check if start_dt is already smaller than first dateti...
[ "def", "fast_forward", "(", "self", ",", "start_dt", ")", ":", "if", "self", ".", "from_stdin", ":", "# skip lines until start_dt is reached", "return", "else", ":", "# fast bisection path", "max_mark", "=", "self", ".", "filesize", "step_size", "=", "max_mark", "...
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
244,061
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): 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 = datetime(MAXYEAR, 12, 31, tzinfo=tzutc()) else: logf...
[ "def", "setup", "(", "self", ")", ":", "if", "self", ".", "mlogfilter", ".", "is_stdin", ":", "# assume this year (we have no other info)", "now", "=", "datetime", ".", "now", "(", ")", "self", ".", "startDateTime", "=", "datetime", "(", "now", ".", "year", ...
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
244,062
rueckstiess/mtools
mtools/util/profile_collection.py
ProfileCollection.num_events
def num_events(self): """Lazy evaluation of the number of events.""" if not self._num_events: self._num_events = self.coll_handle.count() return self._num_events
python
def num_events(self): if not self._num_events: self._num_events = self.coll_handle.count() return self._num_events
[ "def", "num_events", "(", "self", ")", ":", "if", "not", "self", ".", "_num_events", ":", "self", ".", "_num_events", "=", "self", ".", "coll_handle", ".", "count", "(", ")", "return", "self", ".", "_num_events" ]
Lazy evaluation of the number of events.
[ "Lazy", "evaluation", "of", "the", "number", "of", "events", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/profile_collection.py#L88-L92
244,063
rueckstiess/mtools
mtools/util/profile_collection.py
ProfileCollection.next
def next(self): """Make iterators.""" if not self.cursor: self.cursor = self.coll_handle.find().sort([("ts", ASCENDING)]) doc = self.cursor.next() doc['thread'] = self.name le = LogEvent(doc) return le
python
def next(self): if not self.cursor: self.cursor = self.coll_handle.find().sort([("ts", ASCENDING)]) doc = self.cursor.next() doc['thread'] = self.name le = LogEvent(doc) return le
[ "def", "next", "(", "self", ")", ":", "if", "not", "self", ".", "cursor", ":", "self", ".", "cursor", "=", "self", ".", "coll_handle", ".", "find", "(", ")", ".", "sort", "(", "[", "(", "\"ts\"", ",", "ASCENDING", ")", "]", ")", "doc", "=", "se...
Make iterators.
[ "Make", "iterators", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/profile_collection.py#L94-L102
244,064
rueckstiess/mtools
mtools/util/profile_collection.py
ProfileCollection._calculate_bounds
def _calculate_bounds(self): """Calculate beginning and end of log events.""" # get start datetime first = self.coll_handle.find_one(None, sort=[("ts", ASCENDING)]) last = self.coll_handle.find_one(None, sort=[("ts", DESCENDING)]) self._start = first['ts'] if self._start...
python
def _calculate_bounds(self): # get start datetime first = self.coll_handle.find_one(None, sort=[("ts", ASCENDING)]) last = self.coll_handle.find_one(None, sort=[("ts", DESCENDING)]) self._start = first['ts'] if self._start.tzinfo is None: self._start = self._start.re...
[ "def", "_calculate_bounds", "(", "self", ")", ":", "# get start datetime", "first", "=", "self", ".", "coll_handle", ".", "find_one", "(", "None", ",", "sort", "=", "[", "(", "\"ts\"", ",", "ASCENDING", ")", "]", ")", "last", "=", "self", ".", "coll_hand...
Calculate beginning and end of log events.
[ "Calculate", "beginning", "and", "end", "of", "log", "events", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/profile_collection.py#L117-L131
244,065
rueckstiess/mtools
mtools/mloginfo/sections/distinct_section.py
DistinctSection.run
def run(self): """Run each line through log2code and group by matched pattern.""" if ProfileCollection and isinstance(self.mloginfo.logfile, ProfileCollection): print("\n not available for system.profile collections\n") return ...
python
def run(self): if ProfileCollection and isinstance(self.mloginfo.logfile, ProfileCollection): print("\n not available for system.profile collections\n") return codelines = defaultdict(lambda: 0) non_matches = 0 # ge...
[ "def", "run", "(", "self", ")", ":", "if", "ProfileCollection", "and", "isinstance", "(", "self", ".", "mloginfo", ".", "logfile", ",", "ProfileCollection", ")", ":", "print", "(", "\"\\n not available for system.profile collections\\n\"", ")", "return", "codelin...
Run each line through log2code and group by matched pattern.
[ "Run", "each", "line", "through", "log2code", "and", "group", "by", "matched", "pattern", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mloginfo/sections/distinct_section.py#L39-L108
244,066
rueckstiess/mtools
mtools/util/pattern.py
shell2json
def shell2json(s): """Convert shell syntax to json.""" replace = { r'BinData\(.+?\)': '1', r'(new )?Date\(.+?\)': '1', r'Timestamp\(.+?\)': '1', r'ObjectId\(.+?\)': '1', r'DBRef\(.+?\)': '1', r'undefined': '1', r'MinKey': '1', r'MaxKey': '1', ...
python
def shell2json(s): replace = { r'BinData\(.+?\)': '1', r'(new )?Date\(.+?\)': '1', r'Timestamp\(.+?\)': '1', r'ObjectId\(.+?\)': '1', r'DBRef\(.+?\)': '1', r'undefined': '1', r'MinKey': '1', r'MaxKey': '1', r'NumberLong\(.+?\)': '1', r'...
[ "def", "shell2json", "(", "s", ")", ":", "replace", "=", "{", "r'BinData\\(.+?\\)'", ":", "'1'", ",", "r'(new )?Date\\(.+?\\)'", ":", "'1'", ",", "r'Timestamp\\(.+?\\)'", ":", "'1'", ",", "r'ObjectId\\(.+?\\)'", ":", "'1'", ",", "r'DBRef\\(.+?\\)'", ":", "'1'", ...
Convert shell syntax to json.
[ "Convert", "shell", "syntax", "to", "json", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/pattern.py#L52-L70
244,067
rueckstiess/mtools
mtools/util/pattern.py
json2pattern
def json2pattern(s): """ Convert JSON format to a query pattern. Includes even mongo shell notation without quoted key names. """ # make valid JSON by wrapping field names in quotes s, _ = re.subn(r'([{,])\s*([^,{\s\'"]+)\s*:', ' \\1 "\\2" : ', s) # handle shell values that are not valid JS...
python
def json2pattern(s): # make valid JSON by wrapping field names in quotes s, _ = re.subn(r'([{,])\s*([^,{\s\'"]+)\s*:', ' \\1 "\\2" : ', s) # handle shell values that are not valid JSON s = shell2json(s) # convert to 1 where possible, to get rid of things like new Date(...) s, n = re.subn(r'([:,\...
[ "def", "json2pattern", "(", "s", ")", ":", "# make valid JSON by wrapping field names in quotes", "s", ",", "_", "=", "re", ".", "subn", "(", "r'([{,])\\s*([^,{\\s\\'\"]+)\\s*:'", ",", "' \\\\1 \"\\\\2\" : '", ",", "s", ")", "# handle shell values that are not valid JSON", ...
Convert JSON format to a query pattern. Includes even mongo shell notation without quoted key names.
[ "Convert", "JSON", "format", "to", "a", "query", "pattern", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/pattern.py#L73-L90
244,068
rueckstiess/mtools
mtools/util/print_table.py
print_table
def print_table(rows, override_headers=None, uppercase_headers=True): """All rows need to be a list of dictionaries, all with the same keys.""" if len(rows) == 0: return keys = list(rows[0].keys()) headers = override_headers or keys if uppercase_headers: rows = [dict(zip(keys, ...
python
def print_table(rows, override_headers=None, uppercase_headers=True): if len(rows) == 0: return keys = list(rows[0].keys()) headers = override_headers or keys if uppercase_headers: rows = [dict(zip(keys, map(lambda x: x.upper(), headers))), None] + rows else:...
[ "def", "print_table", "(", "rows", ",", "override_headers", "=", "None", ",", "uppercase_headers", "=", "True", ")", ":", "if", "len", "(", "rows", ")", "==", "0", ":", "return", "keys", "=", "list", "(", "rows", "[", "0", "]", ".", "keys", "(", ")...
All rows need to be a list of dictionaries, all with the same keys.
[ "All", "rows", "need", "to", "be", "a", "list", "of", "dictionaries", "all", "with", "the", "same", "keys", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/print_table.py#L3-L30
244,069
rueckstiess/mtools
mtools/util/logevent.py
LogEvent.set_line_str
def set_line_str(self, line_str): """ Set line_str. Line_str is only writeable if LogEvent was created from a string, not from a system.profile documents. """ if not self.from_string: raise ValueError("can't set line_str for LogEvent created from " ...
python
def set_line_str(self, line_str): if not self.from_string: raise ValueError("can't set line_str for LogEvent created from " "system.profile documents.") if line_str != self._line_str: self._line_str = line_str.rstrip() self._reset()
[ "def", "set_line_str", "(", "self", ",", "line_str", ")", ":", "if", "not", "self", ".", "from_string", ":", "raise", "ValueError", "(", "\"can't set line_str for LogEvent created from \"", "\"system.profile documents.\"", ")", "if", "line_str", "!=", "self", ".", "...
Set line_str. Line_str is only writeable if LogEvent was created from a string, not from a system.profile documents.
[ "Set", "line_str", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L141-L154
244,070
rueckstiess/mtools
mtools/util/logevent.py
LogEvent.get_line_str
def get_line_str(self): """Return line_str depending on source, logfile or system.profile.""" if self.from_string: return ' '.join([s for s in [self.merge_marker_str, self._datetime_str, self._line_str] if s]) ...
python
def get_line_str(self): if self.from_string: return ' '.join([s for s in [self.merge_marker_str, self._datetime_str, self._line_str] if s]) else: return ' '.join([s for s in [self._datetime_str, ...
[ "def", "get_line_str", "(", "self", ")", ":", "if", "self", ".", "from_string", ":", "return", "' '", ".", "join", "(", "[", "s", "for", "s", "in", "[", "self", ".", "merge_marker_str", ",", "self", ".", "_datetime_str", ",", "self", ".", "_line_str", ...
Return line_str depending on source, logfile or system.profile.
[ "Return", "line_str", "depending", "on", "source", "logfile", "or", "system", ".", "profile", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L156-L164
244,071
rueckstiess/mtools
mtools/util/logevent.py
LogEvent._match_datetime_pattern
def _match_datetime_pattern(self, tokens): """ Match the datetime pattern at the beginning of the token list. There are several formats that this method needs to understand and distinguish between (see MongoDB's SERVER-7965): ctime-pre2.4 Wed Dec 31 19:00:00 ctime ...
python
def _match_datetime_pattern(self, tokens): # first check: less than 4 tokens can't be ctime assume_iso8601_format = len(tokens) < 4 # check for ctime-pre-2.4 or ctime format if not assume_iso8601_format: weekday, month, day, time = tokens[:4] if (len(tokens) < 4 ...
[ "def", "_match_datetime_pattern", "(", "self", ",", "tokens", ")", ":", "# first check: less than 4 tokens can't be ctime", "assume_iso8601_format", "=", "len", "(", "tokens", ")", "<", "4", "# check for ctime-pre-2.4 or ctime format", "if", "not", "assume_iso8601_format", ...
Match the datetime pattern at the beginning of the token list. There are several formats that this method needs to understand and distinguish between (see MongoDB's SERVER-7965): ctime-pre2.4 Wed Dec 31 19:00:00 ctime Wed Dec 31 19:00:00.000 iso8601-utc 1970-01...
[ "Match", "the", "datetime", "pattern", "at", "the", "beginning", "of", "the", "token", "list", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L282-L333
244,072
rueckstiess/mtools
mtools/util/logevent.py
LogEvent._extract_operation_and_namespace
def _extract_operation_and_namespace(self): """ Helper method to extract both operation and namespace from a logevent. It doesn't make sense to only extract one as they appear back to back in the token list. """ split_tokens = self.split_tokens if not self._date...
python
def _extract_operation_and_namespace(self): split_tokens = self.split_tokens if not self._datetime_nextpos: # force evaluation of thread to get access to datetime_offset and # to protect from changes due to line truncation. _ = self.thread if not self._datet...
[ "def", "_extract_operation_and_namespace", "(", "self", ")", ":", "split_tokens", "=", "self", ".", "split_tokens", "if", "not", "self", ".", "_datetime_nextpos", ":", "# force evaluation of thread to get access to datetime_offset and", "# to protect from changes due to line trun...
Helper method to extract both operation and namespace from a logevent. It doesn't make sense to only extract one as they appear back to back in the token list.
[ "Helper", "method", "to", "extract", "both", "operation", "and", "namespace", "from", "a", "logevent", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L395-L427
244,073
rueckstiess/mtools
mtools/util/logevent.py
LogEvent._extract_counters
def _extract_counters(self): """Extract counters like nscanned and nreturned from the logevent.""" # extract counters (if present) counters = ['nscanned', 'nscannedObjects', 'ntoreturn', 'nreturned', 'ninserted', 'nupdated', 'ndeleted', 'r', 'w', 'numYields', ...
python
def _extract_counters(self): # extract counters (if present) counters = ['nscanned', 'nscannedObjects', 'ntoreturn', 'nreturned', 'ninserted', 'nupdated', 'ndeleted', 'r', 'w', 'numYields', 'planSummary', 'writeConflicts', 'keyUpdates'] # TODO: refactor m...
[ "def", "_extract_counters", "(", "self", ")", ":", "# extract counters (if present)", "counters", "=", "[", "'nscanned'", ",", "'nscannedObjects'", ",", "'ntoreturn'", ",", "'nreturned'", ",", "'ninserted'", ",", "'nupdated'", ",", "'ndeleted'", ",", "'r'", ",", "...
Extract counters like nscanned and nreturned from the logevent.
[ "Extract", "counters", "like", "nscanned", "and", "nreturned", "from", "the", "logevent", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L626-L685
244,074
rueckstiess/mtools
mtools/util/logevent.py
LogEvent.parse_all
def parse_all(self): """ Trigger extraction of all information. These values are usually evaluated lazily. """ tokens = self.split_tokens duration = self.duration datetime = self.datetime thread = self.thread operation = self.operation nam...
python
def parse_all(self): tokens = self.split_tokens duration = self.duration datetime = self.datetime thread = self.thread operation = self.operation namespace = self.namespace pattern = self.pattern nscanned = self.nscanned nscannedObjects = self.nsca...
[ "def", "parse_all", "(", "self", ")", ":", "tokens", "=", "self", ".", "split_tokens", "duration", "=", "self", ".", "duration", "datetime", "=", "self", ".", "datetime", "thread", "=", "self", ".", "thread", "operation", "=", "self", ".", "operation", "...
Trigger extraction of all information. These values are usually evaluated lazily.
[ "Trigger", "extraction", "of", "all", "information", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L721-L743
244,075
rueckstiess/mtools
mtools/util/logevent.py
LogEvent.to_dict
def to_dict(self, labels=None): """Convert LogEvent object to a dictionary.""" output = {} if labels is None: labels = ['line_str', 'split_tokens', 'datetime', 'operation', 'thread', 'namespace', 'nscanned', 'ntoreturn', 'nreturned', 'ninse...
python
def to_dict(self, labels=None): output = {} if labels is None: labels = ['line_str', 'split_tokens', 'datetime', 'operation', 'thread', 'namespace', 'nscanned', 'ntoreturn', 'nreturned', 'ninserted', 'nupdated', 'ndeleted', 'd...
[ "def", "to_dict", "(", "self", ",", "labels", "=", "None", ")", ":", "output", "=", "{", "}", "if", "labels", "is", "None", ":", "labels", "=", "[", "'line_str'", ",", "'split_tokens'", ",", "'datetime'", ",", "'operation'", ",", "'thread'", ",", "'nam...
Convert LogEvent object to a dictionary.
[ "Convert", "LogEvent", "object", "to", "a", "dictionary", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L823-L837
244,076
rueckstiess/mtools
mtools/util/logevent.py
LogEvent.to_json
def to_json(self, labels=None): """Convert LogEvent object to valid JSON.""" output = self.to_dict(labels) return json.dumps(output, cls=DateTimeEncoder, ensure_ascii=False)
python
def to_json(self, labels=None): output = self.to_dict(labels) return json.dumps(output, cls=DateTimeEncoder, ensure_ascii=False)
[ "def", "to_json", "(", "self", ",", "labels", "=", "None", ")", ":", "output", "=", "self", ".", "to_dict", "(", "labels", ")", "return", "json", ".", "dumps", "(", "output", ",", "cls", "=", "DateTimeEncoder", ",", "ensure_ascii", "=", "False", ")" ]
Convert LogEvent object to valid JSON.
[ "Convert", "LogEvent", "object", "to", "valid", "JSON", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L839-L842
244,077
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool.addFilter
def addFilter(self, filterclass): """Add a filter class to the parser.""" if filterclass not in self.filters: self.filters.append(filterclass)
python
def addFilter(self, filterclass): if filterclass not in self.filters: self.filters.append(filterclass)
[ "def", "addFilter", "(", "self", ",", "filterclass", ")", ":", "if", "filterclass", "not", "in", "self", ".", "filters", ":", "self", ".", "filters", ".", "append", "(", "filterclass", ")" ]
Add a filter class to the parser.
[ "Add", "a", "filter", "class", "to", "the", "parser", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L71-L74
244,078
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool._outputLine
def _outputLine(self, logevent, length=None, human=False): """ Print the final line. Provides various options (length, human, datetime changes, ...). """ # adapt timezone output if necessary if self.args['timestamp_format'] != 'none': logevent._reformat_times...
python
def _outputLine(self, logevent, length=None, human=False): # adapt timezone output if necessary if self.args['timestamp_format'] != 'none': logevent._reformat_timestamp(self.args['timestamp_format'], force=True) if any(self.args['timezone']): ...
[ "def", "_outputLine", "(", "self", ",", "logevent", ",", "length", "=", "None", ",", "human", "=", "False", ")", ":", "# adapt timezone output if necessary", "if", "self", ".", "args", "[", "'timestamp_format'", "]", "!=", "'none'", ":", "logevent", ".", "_r...
Print the final line. Provides various options (length, human, datetime changes, ...).
[ "Print", "the", "final", "line", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L83-L112
244,079
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool._msToString
def _msToString(self, ms): """Change milliseconds to hours min sec ms format.""" hr, ms = divmod(ms, 3600000) mins, ms = divmod(ms, 60000) secs, mill = divmod(ms, 1000) return "%ihr %imin %isecs %ims" % (hr, mins, secs, mill)
python
def _msToString(self, ms): hr, ms = divmod(ms, 3600000) mins, ms = divmod(ms, 60000) secs, mill = divmod(ms, 1000) return "%ihr %imin %isecs %ims" % (hr, mins, secs, mill)
[ "def", "_msToString", "(", "self", ",", "ms", ")", ":", "hr", ",", "ms", "=", "divmod", "(", "ms", ",", "3600000", ")", "mins", ",", "ms", "=", "divmod", "(", "ms", ",", "60000", ")", "secs", ",", "mill", "=", "divmod", "(", "ms", ",", "1000", ...
Change milliseconds to hours min sec ms format.
[ "Change", "milliseconds", "to", "hours", "min", "sec", "ms", "format", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L114-L119
244,080
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool._changeMs
def _changeMs(self, line): """Change the ms part in the string if needed.""" # use the position of the last space instead try: last_space_pos = line.rindex(' ') except ValueError: return line else: end_str = line[last_space_pos:] ne...
python
def _changeMs(self, line): # use the position of the last space instead try: last_space_pos = line.rindex(' ') except ValueError: return line else: end_str = line[last_space_pos:] new_string = line if end_str[-2:] == 'ms' and in...
[ "def", "_changeMs", "(", "self", ",", "line", ")", ":", "# use the position of the last space instead", "try", ":", "last_space_pos", "=", "line", ".", "rindex", "(", "' '", ")", "except", "ValueError", ":", "return", "line", "else", ":", "end_str", "=", "line...
Change the ms part in the string if needed.
[ "Change", "the", "ms", "part", "in", "the", "string", "if", "needed", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L121-L139
244,081
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool._formatNumbers
def _formatNumbers(self, line): """ Format the numbers so that there are commas inserted. For example: 1200300 becomes 1,200,300. """ # below thousands separator syntax only works for # python 2.7, skip for 2.6 if sys.version_info < (2, 7): return lin...
python
def _formatNumbers(self, line): # below thousands separator syntax only works for # python 2.7, skip for 2.6 if sys.version_info < (2, 7): return line last_index = 0 try: # find the index of the last } character last_index = (line.rindex('}') ...
[ "def", "_formatNumbers", "(", "self", ",", "line", ")", ":", "# below thousands separator syntax only works for", "# python 2.7, skip for 2.6", "if", "sys", ".", "version_info", "<", "(", "2", ",", "7", ")", ":", "return", "line", "last_index", "=", "0", "try", ...
Format the numbers so that there are commas inserted. For example: 1200300 becomes 1,200,300.
[ "Format", "the", "numbers", "so", "that", "there", "are", "commas", "inserted", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L141-L172
244,082
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool._datetime_key_for_merge
def _datetime_key_for_merge(self, logevent): """Helper method for ordering log lines correctly during merge.""" if not logevent: # if logfile end is reached, return max datetime to never # pick this line return datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, tzutc()) ...
python
def _datetime_key_for_merge(self, logevent): if not logevent: # if logfile end is reached, return max datetime to never # pick this line return datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, tzutc()) # if no datetime present (line doesn't have one) return mindate ...
[ "def", "_datetime_key_for_merge", "(", "self", ",", "logevent", ")", ":", "if", "not", "logevent", ":", "# if logfile end is reached, return max datetime to never", "# pick this line", "return", "datetime", "(", "MAXYEAR", ",", "12", ",", "31", ",", "23", ",", "59",...
Helper method for ordering log lines correctly during merge.
[ "Helper", "method", "for", "ordering", "log", "lines", "correctly", "during", "merge", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L174-L184
244,083
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool._merge_logfiles
def _merge_logfiles(self): """Helper method to merge several files together by datetime.""" # open files, read first lines, extract first dates lines = [next(iter(logfile), None) for logfile in self.args['logfile']] # adjust lines by timezone for i in range(len(lines)): ...
python
def _merge_logfiles(self): # open files, read first lines, extract first dates lines = [next(iter(logfile), None) for logfile in self.args['logfile']] # adjust lines by timezone for i in range(len(lines)): if lines[i] and lines[i].datetime: lines[i]._datetime...
[ "def", "_merge_logfiles", "(", "self", ")", ":", "# open files, read first lines, extract first dates", "lines", "=", "[", "next", "(", "iter", "(", "logfile", ")", ",", "None", ")", "for", "logfile", "in", "self", ".", "args", "[", "'logfile'", "]", "]", "#...
Helper method to merge several files together by datetime.
[ "Helper", "method", "to", "merge", "several", "files", "together", "by", "datetime", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L186-L212
244,084
rueckstiess/mtools
mtools/mlogfilter/mlogfilter.py
MLogFilterTool.logfile_generator
def logfile_generator(self): """Yield each line of the file, or the next line if several files.""" if not self.args['exclude']: # ask all filters for a start_limit and fast-forward to the maximum start_limits = [f.start_limit for f in self.filters if h...
python
def logfile_generator(self): if not self.args['exclude']: # ask all filters for a start_limit and fast-forward to the maximum start_limits = [f.start_limit for f in self.filters if hasattr(f, 'start_limit')] if start_limits: for lo...
[ "def", "logfile_generator", "(", "self", ")", ":", "if", "not", "self", ".", "args", "[", "'exclude'", "]", ":", "# ask all filters for a start_limit and fast-forward to the maximum", "start_limits", "=", "[", "f", ".", "start_limit", "for", "f", "in", "self", "."...
Yield each line of the file, or the next line if several files.
[ "Yield", "each", "line", "of", "the", "file", "or", "the", "next", "line", "if", "several", "files", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/mlogfilter.py#L214-L236
244,085
rueckstiess/mtools
mtools/mlogfilter/filters/mask_filter.py
MaskFilter.setup
def setup(self): """ Create mask list. Consists of all tuples between which this filter accepts lines. """ # get start and end of the mask and set a start_limit if not self.mask_source.start: raise SystemExit("Can't parse format of %s. Is this a log file or "...
python
def setup(self): # get start and end of the mask and set a start_limit if not self.mask_source.start: raise SystemExit("Can't parse format of %s. Is this a log file or " "system.profile collection?" % self.mlogfilter.args['mask']) ...
[ "def", "setup", "(", "self", ")", ":", "# get start and end of the mask and set a start_limit", "if", "not", "self", ".", "mask_source", ".", "start", ":", "raise", "SystemExit", "(", "\"Can't parse format of %s. Is this a log file or \"", "\"system.profile collection?\"", "%...
Create mask list. Consists of all tuples between which this filter accepts lines.
[ "Create", "mask", "list", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlogfilter/filters/mask_filter.py#L60-L135
244,086
rueckstiess/mtools
mtools/util/parse_sourcecode.py
source_files
def source_files(mongodb_path): """Find source files.""" for root, dirs, files in os.walk(mongodb_path): for filename in files: # skip files in dbtests folder if 'dbtests' in root: continue if filename.endswith(('.cpp', '.c', '.h')): yi...
python
def source_files(mongodb_path): for root, dirs, files in os.walk(mongodb_path): for filename in files: # skip files in dbtests folder if 'dbtests' in root: continue if filename.endswith(('.cpp', '.c', '.h')): yield os.path.join(root, filena...
[ "def", "source_files", "(", "mongodb_path", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "mongodb_path", ")", ":", "for", "filename", "in", "files", ":", "# skip files in dbtests folder", "if", "'dbtests'", "in", "root", ...
Find source files.
[ "Find", "source", "files", "." ]
a6a22910c3569c0c8a3908660ca218a4557e4249
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/parse_sourcecode.py#L23-L31
244,087
ansible-community/ara
ara/views/result.py
index
def index(): """ This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with result.show_result directly and are instead dynamically generated through javas...
python
def index(): if current_app.config['ARA_PLAYBOOK_OVERRIDE'] is not None: override = current_app.config['ARA_PLAYBOOK_OVERRIDE'] results = (models.TaskResult.query .join(models.Task) .filter(models.Task.playbook_id.in_(override))) else: results = mode...
[ "def", "index", "(", ")", ":", "if", "current_app", ".", "config", "[", "'ARA_PLAYBOOK_OVERRIDE'", "]", "is", "not", "None", ":", "override", "=", "current_app", ".", "config", "[", "'ARA_PLAYBOOK_OVERRIDE'", "]", "results", "=", "(", "models", ".", "TaskRes...
This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with result.show_result directly and are instead dynamically generated through javascript for performance pur...
[ "This", "is", "not", "served", "anywhere", "in", "the", "web", "application", ".", "It", "is", "used", "explicitly", "in", "the", "context", "of", "generating", "static", "files", "since", "flask", "-", "frozen", "requires", "url_for", "s", "to", "crawl", ...
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/views/result.py#L28-L44
244,088
ansible-community/ara
ara/models.py
content_sha1
def content_sha1(context): """ Used by the FileContent model to automatically compute the sha1 hash of content before storing it to the database. """ try: content = context.current_parameters['content'] except AttributeError: content = context return hashlib.sha1(encodeutils....
python
def content_sha1(context): try: content = context.current_parameters['content'] except AttributeError: content = context return hashlib.sha1(encodeutils.to_utf8(content)).hexdigest()
[ "def", "content_sha1", "(", "context", ")", ":", "try", ":", "content", "=", "context", ".", "current_parameters", "[", "'content'", "]", "except", "AttributeError", ":", "content", "=", "context", "return", "hashlib", ".", "sha1", "(", "encodeutils", ".", "...
Used by the FileContent model to automatically compute the sha1 hash of content before storing it to the database.
[ "Used", "by", "the", "FileContent", "model", "to", "automatically", "compute", "the", "sha1", "hash", "of", "content", "before", "storing", "it", "to", "the", "database", "." ]
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/models.py#L53-L62
244,089
ansible-community/ara
ara/views/about.py
main
def main(): """ Returns the about page """ files = models.File.query hosts = models.Host.query facts = models.HostFacts.query playbooks = models.Playbook.query records = models.Data.query tasks = models.Task.query results = models.TaskResult.query if current_app.config['ARA_PLAYBOOK...
python
def main(): files = models.File.query hosts = models.Host.query facts = models.HostFacts.query playbooks = models.Playbook.query records = models.Data.query tasks = models.Task.query results = models.TaskResult.query if current_app.config['ARA_PLAYBOOK_OVERRIDE'] is not None: ov...
[ "def", "main", "(", ")", ":", "files", "=", "models", ".", "File", ".", "query", "hosts", "=", "models", ".", "Host", ".", "query", "facts", "=", "models", ".", "HostFacts", ".", "query", "playbooks", "=", "models", ".", "Playbook", ".", "query", "re...
Returns the about page
[ "Returns", "the", "about", "page" ]
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/views/about.py#L29-L63
244,090
ansible-community/ara
ara/views/host.py
index
def index(): """ This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with host.show_host directly and are instead dynamically generated through javascrip...
python
def index(): if current_app.config['ARA_PLAYBOOK_OVERRIDE'] is not None: override = current_app.config['ARA_PLAYBOOK_OVERRIDE'] hosts = (models.Host.query .filter(models.Host.playbook_id.in_(override))) else: hosts = models.Host.query.all() return render_template('h...
[ "def", "index", "(", ")", ":", "if", "current_app", ".", "config", "[", "'ARA_PLAYBOOK_OVERRIDE'", "]", "is", "not", "None", ":", "override", "=", "current_app", ".", "config", "[", "'ARA_PLAYBOOK_OVERRIDE'", "]", "hosts", "=", "(", "models", ".", "Host", ...
This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with host.show_host directly and are instead dynamically generated through javascript for performance purpose...
[ "This", "is", "not", "served", "anywhere", "in", "the", "web", "application", ".", "It", "is", "used", "explicitly", "in", "the", "context", "of", "generating", "static", "files", "since", "flask", "-", "frozen", "requires", "url_for", "s", "to", "crawl", ...
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/views/host.py#L31-L46
244,091
ansible-community/ara
ara/config/webapp.py
WebAppConfig.config
def config(self): """ Returns a dictionary for the loaded configuration """ return { key: self.__dict__[key] for key in dir(self) if key.isupper() }
python
def config(self): return { key: self.__dict__[key] for key in dir(self) if key.isupper() }
[ "def", "config", "(", "self", ")", ":", "return", "{", "key", ":", "self", ".", "__dict__", "[", "key", "]", "for", "key", "in", "dir", "(", "self", ")", "if", "key", ".", "isupper", "(", ")", "}" ]
Returns a dictionary for the loaded configuration
[ "Returns", "a", "dictionary", "for", "the", "loaded", "configuration" ]
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/config/webapp.py#L58-L64
244,092
ansible-community/ara
ara/views/file.py
index
def index(): """ This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with file.show_file directly and are instead dynamically generated through javascrip...
python
def index(): if current_app.config['ARA_PLAYBOOK_OVERRIDE'] is not None: override = current_app.config['ARA_PLAYBOOK_OVERRIDE'] files = (models.File.query .filter(models.File.playbook_id.in_(override))) else: files = models.File.query.all() return render_template('f...
[ "def", "index", "(", ")", ":", "if", "current_app", ".", "config", "[", "'ARA_PLAYBOOK_OVERRIDE'", "]", "is", "not", "None", ":", "override", "=", "current_app", ".", "config", "[", "'ARA_PLAYBOOK_OVERRIDE'", "]", "files", "=", "(", "models", ".", "File", ...
This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with file.show_file directly and are instead dynamically generated through javascript for performance purpose...
[ "This", "is", "not", "served", "anywhere", "in", "the", "web", "application", ".", "It", "is", "used", "explicitly", "in", "the", "context", "of", "generating", "static", "files", "since", "flask", "-", "frozen", "requires", "url_for", "s", "to", "crawl", ...
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/views/file.py#L28-L43
244,093
ansible-community/ara
ara/views/file.py
show_file
def show_file(file_): """ Returns details of a file """ file_ = (models.File.query.get(file_)) if file_ is None: abort(404) return render_template('file.html', file_=file_)
python
def show_file(file_): file_ = (models.File.query.get(file_)) if file_ is None: abort(404) return render_template('file.html', file_=file_)
[ "def", "show_file", "(", "file_", ")", ":", "file_", "=", "(", "models", ".", "File", ".", "query", ".", "get", "(", "file_", ")", ")", "if", "file_", "is", "None", ":", "abort", "(", "404", ")", "return", "render_template", "(", "'file.html'", ",", ...
Returns details of a file
[ "Returns", "details", "of", "a", "file" ]
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/views/file.py#L47-L55
244,094
ansible-community/ara
ara/webapp.py
configure_db
def configure_db(app): """ 0.10 is the first version of ARA that ships with a stable database schema. We can identify a database that originates from before this by checking if there is an alembic revision available. If there is no alembic revision available, assume we are running the first revi...
python
def configure_db(app): models.db.init_app(app) log = logging.getLogger('ara.webapp.configure_db') log.debug('Setting up database...') if app.config.get('ARA_AUTOCREATE_DATABASE'): with app.app_context(): migrations = app.config['DB_MIGRATIONS'] flask_migrate.Migrate(app,...
[ "def", "configure_db", "(", "app", ")", ":", "models", ".", "db", ".", "init_app", "(", "app", ")", "log", "=", "logging", ".", "getLogger", "(", "'ara.webapp.configure_db'", ")", "log", ".", "debug", "(", "'Setting up database...'", ")", "if", "app", ".",...
0.10 is the first version of ARA that ships with a stable database schema. We can identify a database that originates from before this by checking if there is an alembic revision available. If there is no alembic revision available, assume we are running the first revision which contains the latest stat...
[ "0", ".", "10", "is", "the", "first", "version", "of", "ARA", "that", "ships", "with", "a", "stable", "database", "schema", ".", "We", "can", "identify", "a", "database", "that", "originates", "from", "before", "this", "by", "checking", "if", "there", "i...
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/webapp.py#L248-L288
244,095
ansible-community/ara
ara/webapp.py
configure_cache
def configure_cache(app): """ Sets up an attribute to cache data in the app context """ log = logging.getLogger('ara.webapp.configure_cache') log.debug('Configuring cache') if not getattr(app, '_cache', None): app._cache = {}
python
def configure_cache(app): log = logging.getLogger('ara.webapp.configure_cache') log.debug('Configuring cache') if not getattr(app, '_cache', None): app._cache = {}
[ "def", "configure_cache", "(", "app", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "'ara.webapp.configure_cache'", ")", "log", ".", "debug", "(", "'Configuring cache'", ")", "if", "not", "getattr", "(", "app", ",", "'_cache'", ",", "None", ")", ...
Sets up an attribute to cache data in the app context
[ "Sets", "up", "an", "attribute", "to", "cache", "data", "in", "the", "app", "context" ]
15e2d0133c23b6d07438a553bb8149fadff21547
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/webapp.py#L318-L324
244,096
orbingol/NURBS-Python
geomdl/convert.py
bspline_to_nurbs
def bspline_to_nurbs(obj): """ Converts non-rational parametric shapes to rational ones. :param obj: B-Spline shape :type obj: BSpline.Curve, BSpline.Surface or BSpline.Volume :return: NURBS shape :rtype: NURBS.Curve, NURBS.Surface or NURBS.Volume :raises: TypeError """ # B-Spline -> NU...
python
def bspline_to_nurbs(obj): # B-Spline -> NURBS if isinstance(obj, BSpline.Curve): return _convert.convert_curve(obj, NURBS) elif isinstance(obj, BSpline.Surface): return _convert.convert_surface(obj, NURBS) elif isinstance(obj, BSpline.Volume): return _convert.convert_volume(obj,...
[ "def", "bspline_to_nurbs", "(", "obj", ")", ":", "# B-Spline -> NURBS", "if", "isinstance", "(", "obj", ",", "BSpline", ".", "Curve", ")", ":", "return", "_convert", ".", "convert_curve", "(", "obj", ",", "NURBS", ")", "elif", "isinstance", "(", "obj", ","...
Converts non-rational parametric shapes to rational ones. :param obj: B-Spline shape :type obj: BSpline.Curve, BSpline.Surface or BSpline.Volume :return: NURBS shape :rtype: NURBS.Curve, NURBS.Surface or NURBS.Volume :raises: TypeError
[ "Converts", "non", "-", "rational", "parametric", "shapes", "to", "rational", "ones", "." ]
b1c6a8b51cf143ff58761438e93ba6baef470627
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/convert.py#L14-L31
244,097
orbingol/NURBS-Python
geomdl/convert.py
nurbs_to_bspline
def nurbs_to_bspline(obj, **kwargs): """ Extracts the non-rational components from rational parametric shapes, if possible. The possibility of converting a rational shape to a non-rational one depends on the weights vector. :param obj: NURBS shape :type obj: NURBS.Curve, NURBS.Surface or NURBS.Volume ...
python
def nurbs_to_bspline(obj, **kwargs): if not obj.rational: raise TypeError("The input must be a rational shape") # Get keyword arguments tol = kwargs.get('tol', 10e-8) # Test for non-rational component extraction for w in obj.weights: if abs(w - 1.0) > tol: print("Cannot...
[ "def", "nurbs_to_bspline", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "if", "not", "obj", ".", "rational", ":", "raise", "TypeError", "(", "\"The input must be a rational shape\"", ")", "# Get keyword arguments", "tol", "=", "kwargs", ".", "get", "(", "'to...
Extracts the non-rational components from rational parametric shapes, if possible. The possibility of converting a rational shape to a non-rational one depends on the weights vector. :param obj: NURBS shape :type obj: NURBS.Curve, NURBS.Surface or NURBS.Volume :return: B-Spline shape :rtype: BSpli...
[ "Extracts", "the", "non", "-", "rational", "components", "from", "rational", "parametric", "shapes", "if", "possible", "." ]
b1c6a8b51cf143ff58761438e93ba6baef470627
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/convert.py#L34-L65
244,098
orbingol/NURBS-Python
geomdl/_linalg.py
doolittle
def doolittle(matrix_a): """ Doolittle's Method for LU-factorization. :param matrix_a: Input matrix (must be a square matrix) :type matrix_a: list, tuple :return: a tuple containing matrices (L,U) :rtype: tuple """ # Initialize L and U matrices matrix_u = [[0.0 for _ in range(len(matrix...
python
def doolittle(matrix_a): # Initialize L and U matrices matrix_u = [[0.0 for _ in range(len(matrix_a))] for _ in range(len(matrix_a))] matrix_l = [[0.0 for _ in range(len(matrix_a))] for _ in range(len(matrix_a))] # Doolittle Method for i in range(0, len(matrix_a)): for k in range(i, len(mat...
[ "def", "doolittle", "(", "matrix_a", ")", ":", "# Initialize L and U matrices", "matrix_u", "=", "[", "[", "0.0", "for", "_", "in", "range", "(", "len", "(", "matrix_a", ")", ")", "]", "for", "_", "in", "range", "(", "len", "(", "matrix_a", ")", ")", ...
Doolittle's Method for LU-factorization. :param matrix_a: Input matrix (must be a square matrix) :type matrix_a: list, tuple :return: a tuple containing matrices (L,U) :rtype: tuple
[ "Doolittle", "s", "Method", "for", "LU", "-", "factorization", "." ]
b1c6a8b51cf143ff58761438e93ba6baef470627
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_linalg.py#L14-L42
244,099
orbingol/NURBS-Python
setup.py
read_files
def read_files(project, ext): """ Reads files inside the input project directory. """ project_path = os.path.join(os.path.dirname(__file__), project) file_list = os.listdir(project_path) flist = [] flist_path = [] for f in file_list: f_path = os.path.join(project_path, f) if os.p...
python
def read_files(project, ext): project_path = os.path.join(os.path.dirname(__file__), project) file_list = os.listdir(project_path) flist = [] flist_path = [] for f in file_list: f_path = os.path.join(project_path, f) if os.path.isfile(f_path) and f.endswith(ext) and f != "__init__.py...
[ "def", "read_files", "(", "project", ",", "ext", ")", ":", "project_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "project", ")", "file_list", "=", "os", ".", "listdir", "(", "project_p...
Reads files inside the input project directory.
[ "Reads", "files", "inside", "the", "input", "project", "directory", "." ]
b1c6a8b51cf143ff58761438e93ba6baef470627
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/setup.py#L141-L152