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 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
230,200 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | wait_for_host | def wait_for_host(port, interval=1, timeout=30, to_start=True, queue=None,
ssl_pymongo_options=None):
"""
Ping server and wait for response.
Ping a mongod or mongos every `interval` seconds until it responds, or
`timeout` seconds have passed. If `to_start` is set to False, will wait f... | python | def wait_for_host(port, interval=1, timeout=30, to_start=True, queue=None,
ssl_pymongo_options=None):
"""
Ping server and wait for response.
Ping a mongod or mongos every `interval` seconds until it responds, or
`timeout` seconds have passed. If `to_start` is set to False, will wait f... | [
"def",
"wait_for_host",
"(",
"port",
",",
"interval",
"=",
"1",
",",
"timeout",
"=",
"30",
",",
"to_start",
"=",
"True",
",",
"queue",
"=",
"None",
",",
"ssl_pymongo_options",
"=",
"None",
")",
":",
"host",
"=",
"'localhost:%i'",
"%",
"port",
"start_time... | Ping server and wait for response.
Ping a mongod or mongos every `interval` seconds until it responds, or
`timeout` seconds have passed. If `to_start` is set to False, will wait for
the node to shut down instead. This function can be called as a separate
thread.
If queue is provided, it will place... | [
"Ping",
"server",
"and",
"wait",
"for",
"response",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L73-L110 |
230,201 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | shutdown_host | def shutdown_host(port, username=None, password=None, authdb=None):
"""
Send the shutdown command to a mongod or mongos on given port.
This function can be called as a separate thread.
"""
host = 'localhost:%i' % port
try:
mc = MongoConnection(host)
try:
if username ... | python | def shutdown_host(port, username=None, password=None, authdb=None):
"""
Send the shutdown command to a mongod or mongos on given port.
This function can be called as a separate thread.
"""
host = 'localhost:%i' % port
try:
mc = MongoConnection(host)
try:
if username ... | [
"def",
"shutdown_host",
"(",
"port",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"host",
"=",
"'localhost:%i'",
"%",
"port",
"try",
":",
"mc",
"=",
"MongoConnection",
"(",
"host",
")",
"try",
":",
... | Send the shutdown command to a mongod or mongos on given port.
This function can be called as a separate thread. | [
"Send",
"the",
"shutdown",
"command",
"to",
"a",
"mongod",
"or",
"mongos",
"on",
"given",
"port",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L113-L144 |
230,202 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool.start | def start(self):
"""Sub-command start."""
self.discover()
# startup_info only gets loaded from protocol version 2 on,
# check if it's loaded
if not self.startup_info:
# hack to make environment startable with older protocol
# versions < 2: try to start no... | python | def start(self):
"""Sub-command start."""
self.discover()
# startup_info only gets loaded from protocol version 2 on,
# check if it's loaded
if not self.startup_info:
# hack to make environment startable with older protocol
# versions < 2: try to start no... | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"discover",
"(",
")",
"# 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 |
230,203 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool.is_running | def is_running(self, port):
"""Return True if a host on a specific port is running."""
try:
con = self.client('localhost:%s' % port)
con.admin.command('ping')
return True
except (AutoReconnect, ConnectionFailure, OperationFailure):
# Catch Operatio... | python | def is_running(self, port):
"""Return True if a host on a specific port is running."""
try:
con = self.client('localhost:%s' % port)
con.admin.command('ping')
return True
except (AutoReconnect, ConnectionFailure, OperationFailure):
# Catch Operatio... | [
"def",
"is_running",
"(",
"self",
",",
"port",
")",
":",
"try",
":",
"con",
"=",
"self",
".",
"client",
"(",
"'localhost:%s'",
"%",
"port",
")",
"con",
".",
"admin",
".",
"command",
"(",
"'ping'",
")",
"return",
"True",
"except",
"(",
"AutoReconnect",
... | Return True if a host on a specific port is running. | [
"Return",
"True",
"if",
"a",
"host",
"on",
"a",
"specific",
"port",
"is",
"running",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1290-L1298 |
230,204 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool.get_tagged | def get_tagged(self, tags):
"""
Tag format.
The format for the tags list is tuples for tags: mongos, config, shard,
secondary tags of the form (tag, number), e.g. ('mongos', 2) which
references the second mongos in the list. For all other tags, it is
simply the string, e... | python | def get_tagged(self, tags):
"""
Tag format.
The format for the tags list is tuples for tags: mongos, config, shard,
secondary tags of the form (tag, number), e.g. ('mongos', 2) which
references the second mongos in the list. For all other tags, it is
simply the string, e... | [
"def",
"get_tagged",
"(",
"self",
",",
"tags",
")",
":",
"# if 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 |
230,205 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool.get_tags_of_port | def get_tags_of_port(self, port):
"""
Get all tags related to a given port.
This is the inverse of what is stored in self.cluster_tags).
"""
return(sorted([tag for tag in self.cluster_tags
if port in self.cluster_tags[tag]])) | python | def get_tags_of_port(self, port):
"""
Get all tags related to a given port.
This is the inverse of what is stored in self.cluster_tags).
"""
return(sorted([tag for tag in self.cluster_tags
if port in self.cluster_tags[tag]])) | [
"def",
"get_tags_of_port",
"(",
"self",
",",
"port",
")",
":",
"return",
"(",
"sorted",
"(",
"[",
"tag",
"for",
"tag",
"in",
"self",
".",
"cluster_tags",
"if",
"port",
"in",
"self",
".",
"cluster_tags",
"[",
"tag",
"]",
"]",
")",
")"
] | Get all tags related to a given port.
This is the inverse of what is stored in self.cluster_tags). | [
"Get",
"all",
"tags",
"related",
"to",
"a",
"given",
"port",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1339-L1346 |
230,206 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool.wait_for | def wait_for(self, ports, interval=1.0, timeout=30, to_start=True):
"""
Spawn threads to ping host using a list of ports.
Returns when all hosts are running (if to_start=True) / shut down (if
to_start=False).
"""
threads = []
queue = Queue.Queue()
for po... | python | def wait_for(self, ports, interval=1.0, timeout=30, to_start=True):
"""
Spawn threads to ping host using a list of ports.
Returns when all hosts are running (if to_start=True) / shut down (if
to_start=False).
"""
threads = []
queue = Queue.Queue()
for po... | [
"def",
"wait_for",
"(",
"self",
",",
"ports",
",",
"interval",
"=",
"1.0",
",",
"timeout",
"=",
"30",
",",
"to_start",
"=",
"True",
")",
":",
"threads",
"=",
"[",
"]",
"queue",
"=",
"Queue",
".",
"Queue",
"(",
")",
"for",
"port",
"in",
"ports",
"... | Spawn threads to ping host using a list of ports.
Returns when all hosts are running (if to_start=True) / shut down (if
to_start=False). | [
"Spawn",
"threads",
"to",
"ping",
"host",
"using",
"a",
"list",
"of",
"ports",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1348-L1374 |
230,207 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._load_parameters | def _load_parameters(self):
"""
Load the .mlaunch_startup file that exists in each datadir.
Handles different protocol versions.
"""
datapath = self.dir
startup_file = os.path.join(datapath, '.mlaunch_startup')
if not os.path.exists(startup_file):
re... | python | def _load_parameters(self):
"""
Load the .mlaunch_startup file that exists in each datadir.
Handles different protocol versions.
"""
datapath = self.dir
startup_file = os.path.join(datapath, '.mlaunch_startup')
if not os.path.exists(startup_file):
re... | [
"def",
"_load_parameters",
"(",
"self",
")",
":",
"datapath",
"=",
"self",
".",
"dir",
"startup_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"datapath",
",",
"'.mlaunch_startup'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"startup_file... | Load the .mlaunch_startup file that exists in each datadir.
Handles different protocol versions. | [
"Load",
"the",
".",
"mlaunch_startup",
"file",
"that",
"exists",
"in",
"each",
"datadir",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1378-L1410 |
230,208 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._create_paths | def _create_paths(self, basedir, name=None):
"""Create datadir and subdir paths."""
if name:
datapath = os.path.join(basedir, name)
else:
datapath = basedir
dbpath = os.path.join(datapath, 'db')
if not os.path.exists(dbpath):
os.makedirs(dbpat... | python | def _create_paths(self, basedir, name=None):
"""Create datadir and subdir paths."""
if name:
datapath = os.path.join(basedir, name)
else:
datapath = basedir
dbpath = os.path.join(datapath, 'db')
if not os.path.exists(dbpath):
os.makedirs(dbpat... | [
"def",
"_create_paths",
"(",
"self",
",",
"basedir",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
":",
"datapath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"basedir",
",",
"name",
")",
"else",
":",
"datapath",
"=",
"basedir",
"dbpath",
"=",
"... | Create datadir and subdir paths. | [
"Create",
"datadir",
"and",
"subdir",
"paths",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1433-L1446 |
230,209 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._filter_valid_arguments | def _filter_valid_arguments(self, arguments, binary="mongod",
config=False):
"""
Return a list of accepted arguments.
Check which arguments in list are accepted by the specified binary
(mongod, mongos). If an argument does not start with '-' but its
... | python | def _filter_valid_arguments(self, arguments, binary="mongod",
config=False):
"""
Return a list of accepted arguments.
Check which arguments in list are accepted by the specified binary
(mongod, mongos). If an argument does not start with '-' but its
... | [
"def",
"_filter_valid_arguments",
"(",
"self",
",",
"arguments",
",",
"binary",
"=",
"\"mongod\"",
",",
"config",
"=",
"False",
")",
":",
"# 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 |
230,210 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._initiate_replset | def _initiate_replset(self, port, name, maxwait=30):
"""Initiate replica set."""
if not self.args['replicaset'] and name != 'configRepl':
if self.args['verbose']:
print('Skipping replica set initialization for %s' % name)
return
con = self.client('localho... | python | def _initiate_replset(self, port, name, maxwait=30):
"""Initiate replica set."""
if not self.args['replicaset'] and name != 'configRepl':
if self.args['verbose']:
print('Skipping replica set initialization for %s' % name)
return
con = self.client('localho... | [
"def",
"_initiate_replset",
"(",
"self",
",",
"port",
",",
"name",
",",
"maxwait",
"=",
"30",
")",
":",
"if",
"not",
"self",
".",
"args",
"[",
"'replicaset'",
"]",
"and",
"name",
"!=",
"'configRepl'",
":",
"if",
"self",
".",
"args",
"[",
"'verbose'",
... | Initiate replica set. | [
"Initiate",
"replica",
"set",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1667-L1692 |
230,211 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._construct_sharded | def _construct_sharded(self):
"""Construct command line strings for a sharded cluster."""
current_version = self.getMongoDVersion()
num_mongos = self.args['mongos'] if self.args['mongos'] > 0 else 1
shard_names = self._get_shard_names(self.args)
# create shards as stand-alones... | python | def _construct_sharded(self):
"""Construct command line strings for a sharded cluster."""
current_version = self.getMongoDVersion()
num_mongos = self.args['mongos'] if self.args['mongos'] > 0 else 1
shard_names = self._get_shard_names(self.args)
# create shards as stand-alones... | [
"def",
"_construct_sharded",
"(",
"self",
")",
":",
"current_version",
"=",
"self",
".",
"getMongoDVersion",
"(",
")",
"num_mongos",
"=",
"self",
".",
"args",
"[",
"'mongos'",
"]",
"if",
"self",
".",
"args",
"[",
"'mongos'",
"]",
">",
"0",
"else",
"1",
... | Construct command line strings for a sharded cluster. | [
"Construct",
"command",
"line",
"strings",
"for",
"a",
"sharded",
"cluster",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1820-L1892 |
230,212 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._construct_replset | def _construct_replset(self, basedir, portstart, name, num_nodes,
arbiter, extra=''):
"""
Construct command line strings for a replicaset.
Handles single set or sharded cluster.
"""
self.config_docs[name] = {'_id': name, 'members': []}
# Const... | python | def _construct_replset(self, basedir, portstart, name, num_nodes,
arbiter, extra=''):
"""
Construct command line strings for a replicaset.
Handles single set or sharded cluster.
"""
self.config_docs[name] = {'_id': name, 'members': []}
# Const... | [
"def",
"_construct_replset",
"(",
"self",
",",
"basedir",
",",
"portstart",
",",
"name",
",",
"num_nodes",
",",
"arbiter",
",",
"extra",
"=",
"''",
")",
":",
"self",
".",
"config_docs",
"[",
"name",
"]",
"=",
"{",
"'_id'",
":",
"name",
",",
"'members'"... | Construct command line strings for a replicaset.
Handles single set or sharded cluster. | [
"Construct",
"command",
"line",
"strings",
"for",
"a",
"replicaset",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1894-L1943 |
230,213 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._construct_config | def _construct_config(self, basedir, port, name=None, isreplset=False):
"""Construct command line strings for a config server."""
if isreplset:
return self._construct_replset(basedir=basedir, portstart=port,
name=name,
... | python | def _construct_config(self, basedir, port, name=None, isreplset=False):
"""Construct command line strings for a config server."""
if isreplset:
return self._construct_replset(basedir=basedir, portstart=port,
name=name,
... | [
"def",
"_construct_config",
"(",
"self",
",",
"basedir",
",",
"port",
",",
"name",
"=",
"None",
",",
"isreplset",
"=",
"False",
")",
":",
"if",
"isreplset",
":",
"return",
"self",
".",
"_construct_replset",
"(",
"basedir",
"=",
"basedir",
",",
"portstart",... | Construct command line strings for a config server. | [
"Construct",
"command",
"line",
"strings",
"for",
"a",
"config",
"server",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1945-L1957 |
230,214 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._construct_single | def _construct_single(self, basedir, port, name=None, extra=''):
"""
Construct command line strings for a single node.
Handles shards and stand-alones.
"""
datapath = self._create_paths(basedir, name)
self._construct_mongod(os.path.join(datapath, 'db'),
... | python | def _construct_single(self, basedir, port, name=None, extra=''):
"""
Construct command line strings for a single node.
Handles shards and stand-alones.
"""
datapath = self._create_paths(basedir, name)
self._construct_mongod(os.path.join(datapath, 'db'),
... | [
"def",
"_construct_single",
"(",
"self",
",",
"basedir",
",",
"port",
",",
"name",
"=",
"None",
",",
"extra",
"=",
"''",
")",
":",
"datapath",
"=",
"self",
".",
"_create_paths",
"(",
"basedir",
",",
"name",
")",
"self",
".",
"_construct_mongod",
"(",
"... | Construct command line strings for a single node.
Handles shards and stand-alones. | [
"Construct",
"command",
"line",
"strings",
"for",
"a",
"single",
"node",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1959-L1972 |
230,215 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._construct_mongod | def _construct_mongod(self, dbpath, logpath, port, replset=None, extra=''):
"""Construct command line strings for mongod process."""
rs_param = ''
if replset:
rs_param = '--replSet %s' % replset
auth_param = ''
if self.args['auth']:
key_path = os.path.abs... | python | def _construct_mongod(self, dbpath, logpath, port, replset=None, extra=''):
"""Construct command line strings for mongod process."""
rs_param = ''
if replset:
rs_param = '--replSet %s' % replset
auth_param = ''
if self.args['auth']:
key_path = os.path.abs... | [
"def",
"_construct_mongod",
"(",
"self",
",",
"dbpath",
",",
"logpath",
",",
"port",
",",
"replset",
"=",
"None",
",",
"extra",
"=",
"''",
")",
":",
"rs_param",
"=",
"''",
"if",
"replset",
":",
"rs_param",
"=",
"'--replSet %s'",
"%",
"replset",
"auth_par... | Construct command line strings for mongod process. | [
"Construct",
"command",
"line",
"strings",
"for",
"mongod",
"process",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L1974-L2029 |
230,216 | rueckstiess/mtools | mtools/mlaunch/mlaunch.py | MLaunchTool._construct_mongos | def _construct_mongos(self, logpath, port, configdb):
"""Construct command line strings for a mongos process."""
extra = ''
auth_param = ''
if self.args['auth']:
key_path = os.path.abspath(os.path.join(self.dir, 'keyfile'))
auth_param = '--keyFile %s' % key_path
... | python | def _construct_mongos(self, logpath, port, configdb):
"""Construct command line strings for a mongos process."""
extra = ''
auth_param = ''
if self.args['auth']:
key_path = os.path.abspath(os.path.join(self.dir, 'keyfile'))
auth_param = '--keyFile %s' % key_path
... | [
"def",
"_construct_mongos",
"(",
"self",
",",
"logpath",
",",
"port",
",",
"configdb",
")",
":",
"extra",
"=",
"''",
"auth_param",
"=",
"''",
"if",
"self",
".",
"args",
"[",
"'auth'",
"]",
":",
"key_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",... | Construct command line strings for a mongos process. | [
"Construct",
"command",
"line",
"strings",
"for",
"a",
"mongos",
"process",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mlaunch/mlaunch.py#L2031-L2059 |
230,217 | rueckstiess/mtools | mtools/util/logcodeline.py | LogCodeLine.addMatch | def addMatch(self, version, filename, lineno, loglevel, trigger):
"""
Add a match to the LogCodeLine.
Include the version, filename of the source file, the line number, and
the loglevel.
"""
self.versions.add(version)
self.matches[version].append((filename, linen... | python | def addMatch(self, version, filename, lineno, loglevel, trigger):
"""
Add a match to the LogCodeLine.
Include the version, filename of the source file, the line number, and
the loglevel.
"""
self.versions.add(version)
self.matches[version].append((filename, linen... | [
"def",
"addMatch",
"(",
"self",
",",
"version",
",",
"filename",
",",
"lineno",
",",
"loglevel",
",",
"trigger",
")",
":",
"self",
".",
"versions",
".",
"add",
"(",
"version",
")",
"self",
".",
"matches",
"[",
"version",
"]",
".",
"append",
"(",
"(",... | Add a match to the LogCodeLine.
Include the version, filename of the source file, the line number, and
the loglevel. | [
"Add",
"a",
"match",
"to",
"the",
"LogCodeLine",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logcodeline.py#L29-L37 |
230,218 | rueckstiess/mtools | mtools/mplotqueries/plottypes/event_type.py | RSStatePlotType.accept_line | def accept_line(self, logevent):
"""
Return True on match.
Only match log lines containing 'is now in state' (reflects other
node's state changes) or of type "[rsMgr] replSet PRIMARY" (reflects
own state changes).
"""
if ("is now in state" in logevent.line_str an... | python | def accept_line(self, logevent):
"""
Return True on match.
Only match log lines containing 'is now in state' (reflects other
node's state changes) or of type "[rsMgr] replSet PRIMARY" (reflects
own state changes).
"""
if ("is now in state" in logevent.line_str an... | [
"def",
"accept_line",
"(",
"self",
",",
"logevent",
")",
":",
"if",
"(",
"\"is now in state\"",
"in",
"logevent",
".",
"line_str",
"and",
"logevent",
".",
"split_tokens",
"[",
"-",
"1",
"]",
"in",
"self",
".",
"states",
")",
":",
"return",
"True",
"if",
... | Return True on match.
Only match log lines containing 'is now in state' (reflects other
node's state changes) or of type "[rsMgr] replSet PRIMARY" (reflects
own state changes). | [
"Return",
"True",
"on",
"match",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/event_type.py#L73-L90 |
230,219 | rueckstiess/mtools | mtools/mplotqueries/plottypes/event_type.py | RSStatePlotType.color_map | def color_map(cls, group):
print("Group %s" % group)
"""
Change default color behavior.
Map certain states always to the same colors (similar to MMS).
"""
try:
state_idx = cls.states.index(group)
except ValueError:
# on any unexpected stat... | python | def color_map(cls, group):
print("Group %s" % group)
"""
Change default color behavior.
Map certain states always to the same colors (similar to MMS).
"""
try:
state_idx = cls.states.index(group)
except ValueError:
# on any unexpected stat... | [
"def",
"color_map",
"(",
"cls",
",",
"group",
")",
":",
"print",
"(",
"\"Group %s\"",
"%",
"group",
")",
"try",
":",
"state_idx",
"=",
"cls",
".",
"states",
".",
"index",
"(",
"group",
")",
"except",
"ValueError",
":",
"# 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 |
230,220 | rueckstiess/mtools | mtools/mplotqueries/plottypes/base_type.py | BasePlotType.add_line | def add_line(self, logevent):
"""Append log line to this plot type."""
key = None
self.empty = False
self.groups.setdefault(key, list()).append(logevent) | python | def add_line(self, logevent):
"""Append log line to this plot type."""
key = None
self.empty = False
self.groups.setdefault(key, list()).append(logevent) | [
"def",
"add_line",
"(",
"self",
",",
"logevent",
")",
":",
"key",
"=",
"None",
"self",
".",
"empty",
"=",
"False",
"self",
".",
"groups",
".",
"setdefault",
"(",
"key",
",",
"list",
"(",
")",
")",
".",
"append",
"(",
"logevent",
")"
] | Append log line to this plot type. | [
"Append",
"log",
"line",
"to",
"this",
"plot",
"type",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/base_type.py#L53-L57 |
230,221 | rueckstiess/mtools | mtools/mplotqueries/plottypes/base_type.py | BasePlotType.logevents | def logevents(self):
"""Iterator yielding all logevents from groups dictionary."""
for key in self.groups:
for logevent in self.groups[key]:
yield logevent | python | def logevents(self):
"""Iterator yielding all logevents from groups dictionary."""
for key in self.groups:
for logevent in self.groups[key]:
yield logevent | [
"def",
"logevents",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"groups",
":",
"for",
"logevent",
"in",
"self",
".",
"groups",
"[",
"key",
"]",
":",
"yield",
"logevent"
] | Iterator yielding all logevents from groups dictionary. | [
"Iterator",
"yielding",
"all",
"logevents",
"from",
"groups",
"dictionary",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/base_type.py#L60-L64 |
230,222 | rueckstiess/mtools | mtools/mplotqueries/plottypes/histogram_type.py | HistogramPlotType.clicked | def clicked(self, event):
"""Print group name and number of items in bin."""
group = event.artist._mt_group
n = event.artist._mt_n
dt = num2date(event.artist._mt_bin)
print("%4i %s events in %s sec beginning at %s"
% (n, group, self.bucketsize, dt.strftime("%b %d %H... | python | def clicked(self, event):
"""Print group name and number of items in bin."""
group = event.artist._mt_group
n = event.artist._mt_n
dt = num2date(event.artist._mt_bin)
print("%4i %s events in %s sec beginning at %s"
% (n, group, self.bucketsize, dt.strftime("%b %d %H... | [
"def",
"clicked",
"(",
"self",
",",
"event",
")",
":",
"group",
"=",
"event",
".",
"artist",
".",
"_mt_group",
"n",
"=",
"event",
".",
"artist",
".",
"_mt_n",
"dt",
"=",
"num2date",
"(",
"event",
".",
"artist",
".",
"_mt_bin",
")",
"print",
"(",
"\... | Print group name and number of items in bin. | [
"Print",
"group",
"name",
"and",
"number",
"of",
"items",
"in",
"bin",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/histogram_type.py#L153-L159 |
230,223 | rueckstiess/mtools | mtools/util/grouping.py | Grouping.add | def add(self, item, group_by=None):
"""General purpose class to group items by certain criteria."""
key = None
if not group_by:
group_by = self.group_by
if group_by:
# if group_by is a function, use it with item as argument
if hasattr(group_by, '__ca... | python | def add(self, item, group_by=None):
"""General purpose class to group items by certain criteria."""
key = None
if not group_by:
group_by = self.group_by
if group_by:
# if group_by is a function, use it with item as argument
if hasattr(group_by, '__ca... | [
"def",
"add",
"(",
"self",
",",
"item",
",",
"group_by",
"=",
"None",
")",
":",
"key",
"=",
"None",
"if",
"not",
"group_by",
":",
"group_by",
"=",
"self",
".",
"group_by",
"if",
"group_by",
":",
"# if 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 |
230,224 | rueckstiess/mtools | mtools/util/grouping.py | Grouping.regroup | def regroup(self, group_by=None):
"""Regroup items."""
if not group_by:
group_by = self.group_by
groups = self.groups
self.groups = {}
for g in groups:
for item in groups[g]:
self.add(item, group_by) | python | def regroup(self, group_by=None):
"""Regroup items."""
if not group_by:
group_by = self.group_by
groups = self.groups
self.groups = {}
for g in groups:
for item in groups[g]:
self.add(item, group_by) | [
"def",
"regroup",
"(",
"self",
",",
"group_by",
"=",
"None",
")",
":",
"if",
"not",
"group_by",
":",
"group_by",
"=",
"self",
".",
"group_by",
"groups",
"=",
"self",
".",
"groups",
"self",
".",
"groups",
"=",
"{",
"}",
"for",
"g",
"in",
"groups",
"... | Regroup items. | [
"Regroup",
"items",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/grouping.py#L78-L88 |
230,225 | rueckstiess/mtools | mtools/util/grouping.py | Grouping.move_items | def move_items(self, from_group, to_group):
"""Take all elements from the from_group and add it to the to_group."""
if from_group not in self.keys() or len(self.groups[from_group]) == 0:
return
self.groups.setdefault(to_group, list()).extend(self.groups.get
... | python | def move_items(self, from_group, to_group):
"""Take all elements from the from_group and add it to the to_group."""
if from_group not in self.keys() or len(self.groups[from_group]) == 0:
return
self.groups.setdefault(to_group, list()).extend(self.groups.get
... | [
"def",
"move_items",
"(",
"self",
",",
"from_group",
",",
"to_group",
")",
":",
"if",
"from_group",
"not",
"in",
"self",
".",
"keys",
"(",
")",
"or",
"len",
"(",
"self",
".",
"groups",
"[",
"from_group",
"]",
")",
"==",
"0",
":",
"return",
"self",
... | Take all elements from the from_group and add it to the to_group. | [
"Take",
"all",
"elements",
"from",
"the",
"from_group",
"and",
"add",
"it",
"to",
"the",
"to_group",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/grouping.py#L90-L98 |
230,226 | rueckstiess/mtools | mtools/util/grouping.py | Grouping.sort_by_size | def sort_by_size(self, group_limit=None, discard_others=False,
others_label='others'):
"""
Sort the groups by the number of elements they contain, descending.
Also has option to limit the number of groups. If this option is
chosen, the remaining elements are placed ... | python | def sort_by_size(self, group_limit=None, discard_others=False,
others_label='others'):
"""
Sort the groups by the number of elements they contain, descending.
Also has option to limit the number of groups. If this option is
chosen, the remaining elements are placed ... | [
"def",
"sort_by_size",
"(",
"self",
",",
"group_limit",
"=",
"None",
",",
"discard_others",
"=",
"False",
",",
"others_label",
"=",
"'others'",
")",
":",
"# 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 |
230,227 | rueckstiess/mtools | mtools/util/log2code.py | import_l2c_db | def import_l2c_db():
"""
Static import helper function.
Checks if the log2code.pickle exists first, otherwise raises ImportError.
"""
data_path = os.path.join(os.path.dirname(mtools.__file__), 'data')
if os.path.exists(os.path.join(data_path, 'log2code.pickle')):
av, lv, lbw, lcl = cPic... | python | def import_l2c_db():
"""
Static import helper function.
Checks if the log2code.pickle exists first, otherwise raises ImportError.
"""
data_path = os.path.join(os.path.dirname(mtools.__file__), 'data')
if os.path.exists(os.path.join(data_path, 'log2code.pickle')):
av, lv, lbw, lcl = cPic... | [
"def",
"import_l2c_db",
"(",
")",
":",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"mtools",
".",
"__file__",
")",
",",
"'data'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"pat... | Static import helper function.
Checks if the log2code.pickle exists first, otherwise raises ImportError. | [
"Static",
"import",
"helper",
"function",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L15-L29 |
230,228 | rueckstiess/mtools | mtools/util/log2code.py | Log2CodeConverter._strip_counters | def _strip_counters(self, sub_line):
"""Find the codeline end by taking out the counters and durations."""
try:
end = sub_line.rindex('}')
except ValueError:
return sub_line
else:
return sub_line[:(end + 1)] | python | def _strip_counters(self, sub_line):
"""Find the codeline end by taking out the counters and durations."""
try:
end = sub_line.rindex('}')
except ValueError:
return sub_line
else:
return sub_line[:(end + 1)] | [
"def",
"_strip_counters",
"(",
"self",
",",
"sub_line",
")",
":",
"try",
":",
"end",
"=",
"sub_line",
".",
"rindex",
"(",
"'}'",
")",
"except",
"ValueError",
":",
"return",
"sub_line",
"else",
":",
"return",
"sub_line",
"[",
":",
"(",
"end",
"+",
"1",
... | Find the codeline end by taking out the counters and durations. | [
"Find",
"the",
"codeline",
"end",
"by",
"taking",
"out",
"the",
"counters",
"and",
"durations",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L78-L85 |
230,229 | rueckstiess/mtools | mtools/util/log2code.py | Log2CodeConverter._strip_datetime | def _strip_datetime(self, sub_line):
"""Strip datetime and other parts so that there is no redundancy."""
try:
begin = sub_line.index(']')
except ValueError:
return sub_line
else:
# create a "" in place character for the beginnings..
# need... | python | def _strip_datetime(self, sub_line):
"""Strip datetime and other parts so that there is no redundancy."""
try:
begin = sub_line.index(']')
except ValueError:
return sub_line
else:
# create a "" in place character for the beginnings..
# need... | [
"def",
"_strip_datetime",
"(",
"self",
",",
"sub_line",
")",
":",
"try",
":",
"begin",
"=",
"sub_line",
".",
"index",
"(",
"']'",
")",
"except",
"ValueError",
":",
"return",
"sub_line",
"else",
":",
"# 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 |
230,230 | rueckstiess/mtools | mtools/util/log2code.py | Log2CodeConverter._find_variable | def _find_variable(self, pattern, logline):
"""
Return the variable parts of the code given a tuple of strings pattern.
Example: (this, is, a, pattern) -> 'this is a good pattern' -> [good]
"""
var_subs = []
# find the beginning of the pattern
first_index = logli... | python | def _find_variable(self, pattern, logline):
"""
Return the variable parts of the code given a tuple of strings pattern.
Example: (this, is, a, pattern) -> 'this is a good pattern' -> [good]
"""
var_subs = []
# find the beginning of the pattern
first_index = logli... | [
"def",
"_find_variable",
"(",
"self",
",",
"pattern",
",",
"logline",
")",
":",
"var_subs",
"=",
"[",
"]",
"# 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 |
230,231 | rueckstiess/mtools | mtools/util/log2code.py | Log2CodeConverter._variable_parts | def _variable_parts(self, line, codeline):
"""Return variable parts of the codeline, given the static parts."""
var_subs = []
# codeline has pattern and then has the outputs in different versions
if codeline:
var_subs = self._find_variable(codeline.pattern, line)
else... | python | def _variable_parts(self, line, codeline):
"""Return variable parts of the codeline, given the static parts."""
var_subs = []
# codeline has pattern and then has the outputs in different versions
if codeline:
var_subs = self._find_variable(codeline.pattern, line)
else... | [
"def",
"_variable_parts",
"(",
"self",
",",
"line",
",",
"codeline",
")",
":",
"var_subs",
"=",
"[",
"]",
"# 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 |
230,232 | rueckstiess/mtools | mtools/util/log2code.py | Log2CodeConverter.combine | def combine(self, pattern, variable):
"""Combine a pattern and variable parts to be a line string again."""
inter_zip = izip_longest(variable, pattern, fillvalue='')
interleaved = [elt for pair in inter_zip for elt in pair]
return ''.join(interleaved) | python | def combine(self, pattern, variable):
"""Combine a pattern and variable parts to be a line string again."""
inter_zip = izip_longest(variable, pattern, fillvalue='')
interleaved = [elt for pair in inter_zip for elt in pair]
return ''.join(interleaved) | [
"def",
"combine",
"(",
"self",
",",
"pattern",
",",
"variable",
")",
":",
"inter_zip",
"=",
"izip_longest",
"(",
"variable",
",",
"pattern",
",",
"fillvalue",
"=",
"''",
")",
"interleaved",
"=",
"[",
"elt",
"for",
"pair",
"in",
"inter_zip",
"for",
"elt",... | Combine a pattern and variable parts to be a line string again. | [
"Combine",
"a",
"pattern",
"and",
"variable",
"parts",
"to",
"be",
"a",
"line",
"string",
"again",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/log2code.py#L154-L158 |
230,233 | rueckstiess/mtools | mtools/util/cmdlinetool.py | BaseCmdLineTool.run | def run(self, arguments=None, get_unknowns=False):
"""
Init point to execute the script.
If `arguments` string is given, will evaluate the arguments, else
evaluates sys.argv. Any inheriting class should extend the run method
(but first calling BaseCmdLineTool.run(self)).
... | python | def run(self, arguments=None, get_unknowns=False):
"""
Init point to execute the script.
If `arguments` string is given, will evaluate the arguments, else
evaluates sys.argv. Any inheriting class should extend the run method
(but first calling BaseCmdLineTool.run(self)).
... | [
"def",
"run",
"(",
"self",
",",
"arguments",
"=",
"None",
",",
"get_unknowns",
"=",
"False",
")",
":",
"# 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 |
230,234 | rueckstiess/mtools | mtools/util/cmdlinetool.py | BaseCmdLineTool.update_progress | def update_progress(self, progress, prefix=''):
"""
Print a progress bar for longer-running scripts.
The progress value is a value between 0.0 and 1.0. If a prefix is
present, it will be printed before the progress bar.
"""
total_length = 40
if progress == 1.:
... | python | def update_progress(self, progress, prefix=''):
"""
Print a progress bar for longer-running scripts.
The progress value is a value between 0.0 and 1.0. If a prefix is
present, it will be printed before the progress bar.
"""
total_length = 40
if progress == 1.:
... | [
"def",
"update_progress",
"(",
"self",
",",
"progress",
",",
"prefix",
"=",
"''",
")",
":",
"total_length",
"=",
"40",
"if",
"progress",
"==",
"1.",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'\\r'",
"+",
"' '",
"*",
"(",
"total_length",
"+",
"le... | Print a progress bar for longer-running scripts.
The progress value is a value between 0.0 and 1.0. If a prefix is
present, it will be printed before the progress bar. | [
"Print",
"a",
"progress",
"bar",
"for",
"longer",
"-",
"running",
"scripts",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/cmdlinetool.py#L153-L172 |
230,235 | rueckstiess/mtools | mtools/mplotqueries/plottypes/scatter_type.py | ScatterPlotType.accept_line | def accept_line(self, logevent):
"""Return True if the log line has the nominated yaxis field."""
if self.regex_mode:
return bool(re.search(self.field, logevent.line_str))
else:
return getattr(logevent, self.field) is not None | python | def accept_line(self, logevent):
"""Return True if the log line has the nominated yaxis field."""
if self.regex_mode:
return bool(re.search(self.field, logevent.line_str))
else:
return getattr(logevent, self.field) is not None | [
"def",
"accept_line",
"(",
"self",
",",
"logevent",
")",
":",
"if",
"self",
".",
"regex_mode",
":",
"return",
"bool",
"(",
"re",
".",
"search",
"(",
"self",
".",
"field",
",",
"logevent",
".",
"line_str",
")",
")",
"else",
":",
"return",
"getattr",
"... | Return True if the log line has the nominated yaxis field. | [
"Return",
"True",
"if",
"the",
"log",
"line",
"has",
"the",
"nominated",
"yaxis",
"field",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/scatter_type.py#L54-L59 |
230,236 | rueckstiess/mtools | mtools/mplotqueries/plottypes/scatter_type.py | ScatterPlotType.clicked | def clicked(self, event):
"""
Call if an element of this plottype is clicked.
Implement in sub class.
"""
group = event.artist._mt_group
indices = event.ind
# double click only supported on 1.2 or later
major, minor, _ = mpl_version.split('.')
if... | python | def clicked(self, event):
"""
Call if an element of this plottype is clicked.
Implement in sub class.
"""
group = event.artist._mt_group
indices = event.ind
# double click only supported on 1.2 or later
major, minor, _ = mpl_version.split('.')
if... | [
"def",
"clicked",
"(",
"self",
",",
"event",
")",
":",
"group",
"=",
"event",
".",
"artist",
".",
"_mt_group",
"indices",
"=",
"event",
".",
"ind",
"# 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 |
230,237 | rueckstiess/mtools | mtools/mloginfo/mloginfo.py | MLogInfoTool.run | def run(self, arguments=None):
"""Print useful information about the log file."""
LogFileTool.run(self, arguments)
for i, self.logfile in enumerate(self.args['logfile']):
if i > 0:
print("\n ------------------------------------------\n")
if self.logfile.... | python | def run(self, arguments=None):
"""Print useful information about the log file."""
LogFileTool.run(self, arguments)
for i, self.logfile in enumerate(self.args['logfile']):
if i > 0:
print("\n ------------------------------------------\n")
if self.logfile.... | [
"def",
"run",
"(",
"self",
",",
"arguments",
"=",
"None",
")",
":",
"LogFileTool",
".",
"run",
"(",
"self",
",",
"arguments",
")",
"for",
"i",
",",
"self",
".",
"logfile",
"in",
"enumerate",
"(",
"self",
".",
"args",
"[",
"'logfile'",
"]",
")",
":"... | Print useful information about the log file. | [
"Print",
"useful",
"information",
"about",
"the",
"log",
"file",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mloginfo/mloginfo.py#L32-L90 |
230,238 | rueckstiess/mtools | mtools/util/logfile.py | LogFile.filesize | def filesize(self):
"""
Lazy evaluation of start and end of logfile.
Returns None for stdin input currently.
"""
if self.from_stdin:
return None
if not self._filesize:
self._calculate_bounds()
return self._filesize | python | def filesize(self):
"""
Lazy evaluation of start and end of logfile.
Returns None for stdin input currently.
"""
if self.from_stdin:
return None
if not self._filesize:
self._calculate_bounds()
return self._filesize | [
"def",
"filesize",
"(",
"self",
")",
":",
"if",
"self",
".",
"from_stdin",
":",
"return",
"None",
"if",
"not",
"self",
".",
"_filesize",
":",
"self",
".",
"_calculate_bounds",
"(",
")",
"return",
"self",
".",
"_filesize"
] | Lazy evaluation of start and end of logfile.
Returns None for stdin input currently. | [
"Lazy",
"evaluation",
"of",
"start",
"and",
"end",
"of",
"logfile",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L84-L94 |
230,239 | rueckstiess/mtools | mtools/util/logfile.py | LogFile.num_lines | def num_lines(self):
"""
Lazy evaluation of the number of lines.
Returns None for stdin input currently.
"""
if self.from_stdin:
return None
if not self._num_lines:
self._iterate_lines()
return self._num_lines | python | def num_lines(self):
"""
Lazy evaluation of the number of lines.
Returns None for stdin input currently.
"""
if self.from_stdin:
return None
if not self._num_lines:
self._iterate_lines()
return self._num_lines | [
"def",
"num_lines",
"(",
"self",
")",
":",
"if",
"self",
".",
"from_stdin",
":",
"return",
"None",
"if",
"not",
"self",
".",
"_num_lines",
":",
"self",
".",
"_iterate_lines",
"(",
")",
"return",
"self",
".",
"_num_lines"
] | Lazy evaluation of the number of lines.
Returns None for stdin input currently. | [
"Lazy",
"evaluation",
"of",
"the",
"number",
"of",
"lines",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L118-L128 |
230,240 | rueckstiess/mtools | mtools/util/logfile.py | LogFile.versions | def versions(self):
"""Return all version changes."""
versions = []
for v, _ in self.restarts:
if len(versions) == 0 or v != versions[-1]:
versions.append(v)
return versions | python | def versions(self):
"""Return all version changes."""
versions = []
for v, _ in self.restarts:
if len(versions) == 0 or v != versions[-1]:
versions.append(v)
return versions | [
"def",
"versions",
"(",
"self",
")",
":",
"versions",
"=",
"[",
"]",
"for",
"v",
",",
"_",
"in",
"self",
".",
"restarts",
":",
"if",
"len",
"(",
"versions",
")",
"==",
"0",
"or",
"v",
"!=",
"versions",
"[",
"-",
"1",
"]",
":",
"versions",
".",
... | Return all version changes. | [
"Return",
"all",
"version",
"changes",
"."
] | a6a22910c3569c0c8a3908660ca218a4557e4249 | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L166-L172 |
230,241 | rueckstiess/mtools | mtools/util/logfile.py | LogFile.next | def next(self):
"""Get next line, adjust for year rollover and hint datetime format."""
# use readline here because next() iterator uses internal readahead
# buffer so seek position is wrong
line = self.filehandle.readline()
line = line.decode('utf-8', 'replace')
if line ... | python | def next(self):
"""Get next line, adjust for year rollover and hint datetime format."""
# use readline here because next() iterator uses internal readahead
# buffer so seek position is wrong
line = self.filehandle.readline()
line = line.decode('utf-8', 'replace')
if line ... | [
"def",
"next",
"(",
"self",
")",
":",
"# 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 |
230,242 | rueckstiess/mtools | mtools/util/logfile.py | LogFile._calculate_bounds | def _calculate_bounds(self):
"""Calculate beginning and end of logfile."""
if self._bounds_calculated:
# Assume no need to recalc bounds for lifetime of a Logfile object
return
if self.from_stdin:
return False
# we should be able to find a valid log ... | python | def _calculate_bounds(self):
"""Calculate beginning and end of logfile."""
if self._bounds_calculated:
# Assume no need to recalc bounds for lifetime of a Logfile object
return
if self.from_stdin:
return False
# we should be able to find a valid log ... | [
"def",
"_calculate_bounds",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bounds_calculated",
":",
"# 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 |
230,243 | rueckstiess/mtools | mtools/util/logfile.py | LogFile._find_curr_line | def _find_curr_line(self, prev=False):
"""
Internal helper function.
Find the current (or previous if prev=True) line in a log file based on
the current seek position.
"""
curr_pos = self.filehandle.tell()
# jump back 15k characters (at most) and find last newli... | python | def _find_curr_line(self, prev=False):
"""
Internal helper function.
Find the current (or previous if prev=True) line in a log file based on
the current seek position.
"""
curr_pos = self.filehandle.tell()
# jump back 15k characters (at most) and find last newli... | [
"def",
"_find_curr_line",
"(",
"self",
",",
"prev",
"=",
"False",
")",
":",
"curr_pos",
"=",
"self",
".",
"filehandle",
".",
"tell",
"(",
")",
"# jump back 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 |
230,244 | rueckstiess/mtools | mtools/util/logfile.py | LogFile.fast_forward | def fast_forward(self, start_dt):
"""
Fast-forward file to given start_dt datetime obj using binary search.
Only fast for files. Streams need to be forwarded manually, and it will
miss the first line that would otherwise match (as it consumes the log
line).
"""
i... | python | def fast_forward(self, start_dt):
"""
Fast-forward file to given start_dt datetime obj using binary search.
Only fast for files. Streams need to be forwarded manually, and it will
miss the first line that would otherwise match (as it consumes the log
line).
"""
i... | [
"def",
"fast_forward",
"(",
"self",
",",
"start_dt",
")",
":",
"if",
"self",
".",
"from_stdin",
":",
"# 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 |
230,245 | rueckstiess/mtools | mtools/mlogfilter/filters/datetime_filter.py | DateTimeFilter.setup | def setup(self):
"""Get start end end date of logfile before starting to parse."""
if self.mlogfilter.is_stdin:
# assume this year (we have no other info)
now = datetime.now()
self.startDateTime = datetime(now.year, 1, 1, tzinfo=tzutc())
self.endDateTime =... | python | def setup(self):
"""Get start end end date of logfile before starting to parse."""
if self.mlogfilter.is_stdin:
# assume this year (we have no other info)
now = datetime.now()
self.startDateTime = datetime(now.year, 1, 1, tzinfo=tzutc())
self.endDateTime =... | [
"def",
"setup",
"(",
"self",
")",
":",
"if",
"self",
".",
"mlogfilter",
".",
"is_stdin",
":",
"# 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 |
230,246 | 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):
"""Lazy evaluation of the number of events."""
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 |
230,247 | 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):
"""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 | [
"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 |
230,248 | 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):
"""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... | [
"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 |
230,249 | 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):
"""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
... | [
"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 |
230,250 | 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):
"""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',
... | [
"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 |
230,251 | 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):
"""
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... | [
"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 |
230,252 | 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):
"""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,
... | [
"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 |
230,253 | 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):
"""
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 "
... | [
"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 |
230,254 | 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):
"""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])
... | [
"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 |
230,255 | 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):
"""
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 ... | [
"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 |
230,256 | 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):
"""
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... | [
"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 |
230,257 | 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 like nscanned and nreturned from the logevent."""
# extract counters (if present)
counters = ['nscanned', 'nscannedObjects', 'ntoreturn', 'nreturned',
'ninserted', 'nupdated', 'ndeleted', 'r', 'w', 'numYields',
... | [
"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 |
230,258 | 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):
"""
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... | [
"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 |
230,259 | 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):
"""Convert LogEvent object to a dictionary."""
output = {}
if labels is None:
labels = ['line_str', 'split_tokens', 'datetime', 'operation',
'thread', 'namespace', 'nscanned', 'ntoreturn',
'nreturned', 'ninse... | [
"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 |
230,260 | 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):
"""Convert LogEvent object to valid JSON."""
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 |
230,261 | 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):
"""Add a filter class to the parser."""
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 |
230,262 | 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):
"""
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... | [
"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 |
230,263 | 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):
"""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) | [
"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 |
230,264 | 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):
"""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... | [
"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 |
230,265 | 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):
"""
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... | [
"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 |
230,266 | 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):
"""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())
... | [
"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 |
230,267 | 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):
"""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)):
... | [
"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 |
230,268 | 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):
"""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... | [
"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 |
230,269 | 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):
"""
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 "... | [
"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 |
230,270 | 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):
"""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... | [
"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 |
230,271 | 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():
"""
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... | [
"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 |
230,272 | 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):
"""
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.... | [
"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 |
230,273 | 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():
""" 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... | [
"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 |
230,274 | 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():
"""
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... | [
"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 |
230,275 | 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):
""" Returns a dictionary for the loaded configuration """
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 |
230,276 | 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():
"""
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... | [
"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 |
230,277 | 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_):
"""
Returns details of a 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 |
230,278 | 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):
"""
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... | [
"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 |
230,279 | 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):
""" 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 = {} | [
"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 |
230,280 | 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):
""" 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... | [
"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 |
230,281 | 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):
""" 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
... | [
"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 |
230,282 | 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):
""" 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... | [
"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 |
230,283 | 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):
""" 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... | [
"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 |
230,284 | orbingol/NURBS-Python | setup.py | copy_files | def copy_files(src, ext, dst):
""" Copies files with extensions "ext" from "src" to "dst" directory. """
src_path = os.path.join(os.path.dirname(__file__), src)
dst_path = os.path.join(os.path.dirname(__file__), dst)
file_list = os.listdir(src_path)
for f in file_list:
if f == '__init__.py'... | python | def copy_files(src, ext, dst):
""" Copies files with extensions "ext" from "src" to "dst" directory. """
src_path = os.path.join(os.path.dirname(__file__), src)
dst_path = os.path.join(os.path.dirname(__file__), dst)
file_list = os.listdir(src_path)
for f in file_list:
if f == '__init__.py'... | [
"def",
"copy_files",
"(",
"src",
",",
"ext",
",",
"dst",
")",
":",
"src_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"src",
")",
"dst_path",
"=",
"os",
".",
"path",
".",
"join",
... | Copies files with extensions "ext" from "src" to "dst" directory. | [
"Copies",
"files",
"with",
"extensions",
"ext",
"from",
"src",
"to",
"dst",
"directory",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/setup.py#L155-L165 |
230,285 | orbingol/NURBS-Python | setup.py | make_dir | def make_dir(project):
""" Creates the project directory for compiled modules. """
project_path = os.path.join(os.path.dirname(__file__), project)
# Delete the directory and the files inside it
if os.path.exists(project_path):
shutil.rmtree(project_path)
# Create the directory
os.mkdir(p... | python | def make_dir(project):
""" Creates the project directory for compiled modules. """
project_path = os.path.join(os.path.dirname(__file__), project)
# Delete the directory and the files inside it
if os.path.exists(project_path):
shutil.rmtree(project_path)
# Create the directory
os.mkdir(p... | [
"def",
"make_dir",
"(",
"project",
")",
":",
"project_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"project",
")",
"# Delete the directory and the files inside it",
"if",
"os",
".",
"path",
... | Creates the project directory for compiled modules. | [
"Creates",
"the",
"project",
"directory",
"for",
"compiled",
"modules",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/setup.py#L168-L180 |
230,286 | orbingol/NURBS-Python | setup.py | in_argv | def in_argv(arg_list):
""" Checks if any of the elements of the input list is in sys.argv array. """
for arg in sys.argv:
for parg in arg_list:
if parg == arg or arg.startswith(parg):
return True
return False | python | def in_argv(arg_list):
""" Checks if any of the elements of the input list is in sys.argv array. """
for arg in sys.argv:
for parg in arg_list:
if parg == arg or arg.startswith(parg):
return True
return False | [
"def",
"in_argv",
"(",
"arg_list",
")",
":",
"for",
"arg",
"in",
"sys",
".",
"argv",
":",
"for",
"parg",
"in",
"arg_list",
":",
"if",
"parg",
"==",
"arg",
"or",
"arg",
".",
"startswith",
"(",
"parg",
")",
":",
"return",
"True",
"return",
"False"
] | Checks if any of the elements of the input list is in sys.argv array. | [
"Checks",
"if",
"any",
"of",
"the",
"elements",
"of",
"the",
"input",
"list",
"is",
"in",
"sys",
".",
"argv",
"array",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/setup.py#L183-L189 |
230,287 | orbingol/NURBS-Python | geomdl/knotvector.py | generate | def generate(degree, num_ctrlpts, **kwargs):
""" Generates an equally spaced knot vector.
It uses the following equality to generate knot vector: :math:`m = n + p + 1`
where;
* :math:`p`, degree
* :math:`n + 1`, number of control points
* :math:`m + 1`, number of knots
Keyword Arguments:... | python | def generate(degree, num_ctrlpts, **kwargs):
""" Generates an equally spaced knot vector.
It uses the following equality to generate knot vector: :math:`m = n + p + 1`
where;
* :math:`p`, degree
* :math:`n + 1`, number of control points
* :math:`m + 1`, number of knots
Keyword Arguments:... | [
"def",
"generate",
"(",
"degree",
",",
"num_ctrlpts",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"degree",
"==",
"0",
"or",
"num_ctrlpts",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Input values should be different than zero.\"",
")",
"# Get keyword arguments",
... | Generates an equally spaced knot vector.
It uses the following equality to generate knot vector: :math:`m = n + p + 1`
where;
* :math:`p`, degree
* :math:`n + 1`, number of control points
* :math:`m + 1`, number of knots
Keyword Arguments:
* ``clamped``: Flag to choose from clamped ... | [
"Generates",
"an",
"equally",
"spaced",
"knot",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/knotvector.py#L15-L65 |
230,288 | orbingol/NURBS-Python | geomdl/knotvector.py | check | def check(degree, knot_vector, num_ctrlpts):
""" Checks the validity of the input knot vector.
Please refer to The NURBS Book (2nd Edition), p.50 for details.
:param degree: degree of the curve or the surface
:type degree: int
:param knot_vector: knot vector to be checked
:type knot_vector: li... | python | def check(degree, knot_vector, num_ctrlpts):
""" Checks the validity of the input knot vector.
Please refer to The NURBS Book (2nd Edition), p.50 for details.
:param degree: degree of the curve or the surface
:type degree: int
:param knot_vector: knot vector to be checked
:type knot_vector: li... | [
"def",
"check",
"(",
"degree",
",",
"knot_vector",
",",
"num_ctrlpts",
")",
":",
"try",
":",
"if",
"knot_vector",
"is",
"None",
"or",
"len",
"(",
"knot_vector",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Input knot vector cannot be empty\"",
")",
"e... | Checks the validity of the input knot vector.
Please refer to The NURBS Book (2nd Edition), p.50 for details.
:param degree: degree of the curve or the surface
:type degree: int
:param knot_vector: knot vector to be checked
:type knot_vector: list, tuple
:param num_ctrlpts: number of control p... | [
"Checks",
"the",
"validity",
"of",
"the",
"input",
"knot",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/knotvector.py#L99-L133 |
230,289 | orbingol/NURBS-Python | geomdl/fitting.py | interpolate_curve | def interpolate_curve(points, degree, **kwargs):
""" Curve interpolation through the data points.
Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369-370 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization method. *Default: False*
:param... | python | def interpolate_curve(points, degree, **kwargs):
""" Curve interpolation through the data points.
Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369-370 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization method. *Default: False*
:param... | [
"def",
"interpolate_curve",
"(",
"points",
",",
"degree",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"use_centripetal",
"=",
"kwargs",
".",
"get",
"(",
"'centripetal'",
",",
"False",
")",
"# Number of control points",
"num_points",
"=",
"len",
"("... | Curve interpolation through the data points.
Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369-370 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization method. *Default: False*
:param points: data points
:type points: list, tuple
:p... | [
"Curve",
"interpolation",
"through",
"the",
"data",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L16-L53 |
230,290 | orbingol/NURBS-Python | geomdl/fitting.py | interpolate_surface | def interpolate_surface(points, size_u, size_v, degree_u, degree_v, **kwargs):
""" Surface interpolation through the data points.
Please refer to the Algorithm A9.4 on The NURBS Book (2nd Edition), pp.380 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization meth... | python | def interpolate_surface(points, size_u, size_v, degree_u, degree_v, **kwargs):
""" Surface interpolation through the data points.
Please refer to the Algorithm A9.4 on The NURBS Book (2nd Edition), pp.380 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization meth... | [
"def",
"interpolate_surface",
"(",
"points",
",",
"size_u",
",",
"size_v",
",",
"degree_u",
",",
"degree_v",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"use_centripetal",
"=",
"kwargs",
".",
"get",
"(",
"'centripetal'",
",",
"False",
")",
"# G... | Surface interpolation through the data points.
Please refer to the Algorithm A9.4 on The NURBS Book (2nd Edition), pp.380 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization method. *Default: False*
:param points: data points
:type points: list, tuple
... | [
"Surface",
"interpolation",
"through",
"the",
"data",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L57-L112 |
230,291 | orbingol/NURBS-Python | geomdl/fitting.py | compute_knot_vector | def compute_knot_vector(degree, num_points, params):
""" Computes a knot vector from the parameter list using averaging method.
Please refer to the Equation 9.8 on The NURBS Book (2nd Edition), pp.365 for details.
:param degree: degree
:type degree: int
:param num_points: number of data points
... | python | def compute_knot_vector(degree, num_points, params):
""" Computes a knot vector from the parameter list using averaging method.
Please refer to the Equation 9.8 on The NURBS Book (2nd Edition), pp.365 for details.
:param degree: degree
:type degree: int
:param num_points: number of data points
... | [
"def",
"compute_knot_vector",
"(",
"degree",
",",
"num_points",
",",
"params",
")",
":",
"# Start knot vector",
"kv",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"degree",
"+",
"1",
")",
"]",
"# Use averaging method (Eqn 9.8) to compute internal knots in the kn... | Computes a knot vector from the parameter list using averaging method.
Please refer to the Equation 9.8 on The NURBS Book (2nd Edition), pp.365 for details.
:param degree: degree
:type degree: int
:param num_points: number of data points
:type num_points: int
:param params: list of parameters,... | [
"Computes",
"a",
"knot",
"vector",
"from",
"the",
"parameter",
"list",
"using",
"averaging",
"method",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L358-L383 |
230,292 | orbingol/NURBS-Python | geomdl/fitting.py | ginterp | def ginterp(coeff_matrix, points):
""" Applies global interpolation to the set of data points to find control points.
:param coeff_matrix: coefficient matrix
:type coeff_matrix: list, tuple
:param points: data points
:type points: list, tuple
:return: control points
:rtype: list
"""
... | python | def ginterp(coeff_matrix, points):
""" Applies global interpolation to the set of data points to find control points.
:param coeff_matrix: coefficient matrix
:type coeff_matrix: list, tuple
:param points: data points
:type points: list, tuple
:return: control points
:rtype: list
"""
... | [
"def",
"ginterp",
"(",
"coeff_matrix",
",",
"points",
")",
":",
"# Dimension",
"dim",
"=",
"len",
"(",
"points",
"[",
"0",
"]",
")",
"# Number of data points",
"num_points",
"=",
"len",
"(",
"points",
")",
"# Solve system of linear equations",
"matrix_l",
",",
... | Applies global interpolation to the set of data points to find control points.
:param coeff_matrix: coefficient matrix
:type coeff_matrix: list, tuple
:param points: data points
:type points: list, tuple
:return: control points
:rtype: list | [
"Applies",
"global",
"interpolation",
"to",
"the",
"set",
"of",
"data",
"points",
"to",
"find",
"control",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L509-L536 |
230,293 | orbingol/NURBS-Python | geomdl/fitting.py | _build_coeff_matrix | def _build_coeff_matrix(degree, knotvector, params, points):
""" Builds the coefficient matrix for global interpolation.
This function only uses data points to build the coefficient matrix. Please refer to The NURBS Book (2nd Edition),
pp364-370 for details.
:param degree: degree
:type degree: int... | python | def _build_coeff_matrix(degree, knotvector, params, points):
""" Builds the coefficient matrix for global interpolation.
This function only uses data points to build the coefficient matrix. Please refer to The NURBS Book (2nd Edition),
pp364-370 for details.
:param degree: degree
:type degree: int... | [
"def",
"_build_coeff_matrix",
"(",
"degree",
",",
"knotvector",
",",
"params",
",",
"points",
")",
":",
"# Number of data points",
"num_points",
"=",
"len",
"(",
"points",
")",
"# Set up coefficient matrix",
"matrix_a",
"=",
"[",
"[",
"0.0",
"for",
"_",
"in",
... | Builds the coefficient matrix for global interpolation.
This function only uses data points to build the coefficient matrix. Please refer to The NURBS Book (2nd Edition),
pp364-370 for details.
:param degree: degree
:type degree: int
:param knotvector: knot vector
:type knotvector: list, tuple... | [
"Builds",
"the",
"coefficient",
"matrix",
"for",
"global",
"interpolation",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L539-L566 |
230,294 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_render_window | def create_render_window(actors, callbacks, **kwargs):
""" Creates VTK render window with an interactor.
:param actors: list of VTK actors
:type actors: list, tuple
:param callbacks: callback functions for registering custom events
:type callbacks: dict
"""
# Get keyword arguments
figur... | python | def create_render_window(actors, callbacks, **kwargs):
""" Creates VTK render window with an interactor.
:param actors: list of VTK actors
:type actors: list, tuple
:param callbacks: callback functions for registering custom events
:type callbacks: dict
"""
# Get keyword arguments
figur... | [
"def",
"create_render_window",
"(",
"actors",
",",
"callbacks",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get keyword arguments",
"figure_size",
"=",
"kwargs",
".",
"get",
"(",
"'figure_size'",
",",
"(",
"800",
",",
"600",
")",
")",
"camera_position",
"=",
"kwar... | Creates VTK render window with an interactor.
:param actors: list of VTK actors
:type actors: list, tuple
:param callbacks: callback functions for registering custom events
:type callbacks: dict | [
"Creates",
"VTK",
"render",
"window",
"with",
"an",
"interactor",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L14-L73 |
230,295 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_color | def create_color(color):
""" Creates VTK-compatible RGB color from a color string.
:param color: color
:type color: str
:return: RGB color values
:rtype: list
"""
if color[0] == "#":
# Convert hex string to RGB
return [int(color[i:i + 2], 16) / 255 for i in range(1, 7, 2)]
... | python | def create_color(color):
""" Creates VTK-compatible RGB color from a color string.
:param color: color
:type color: str
:return: RGB color values
:rtype: list
"""
if color[0] == "#":
# Convert hex string to RGB
return [int(color[i:i + 2], 16) / 255 for i in range(1, 7, 2)]
... | [
"def",
"create_color",
"(",
"color",
")",
":",
"if",
"color",
"[",
"0",
"]",
"==",
"\"#\"",
":",
"# Convert hex string to RGB",
"return",
"[",
"int",
"(",
"color",
"[",
"i",
":",
"i",
"+",
"2",
"]",
",",
"16",
")",
"/",
"255",
"for",
"i",
"in",
"... | Creates VTK-compatible RGB color from a color string.
:param color: color
:type color: str
:return: RGB color values
:rtype: list | [
"Creates",
"VTK",
"-",
"compatible",
"RGB",
"color",
"from",
"a",
"color",
"string",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L76-L90 |
230,296 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_pts | def create_actor_pts(pts, color, **kwargs):
""" Creates a VTK actor for rendering scatter plots.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name = kwargs.get('name', ... | python | def create_actor_pts(pts, color, **kwargs):
""" Creates a VTK actor for rendering scatter plots.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name = kwargs.get('name', ... | [
"def",
"create_actor_pts",
"(",
"pts",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'",
",",
"0",
... | Creates a VTK actor for rendering scatter plots.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"scatter",
"plots",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L93-L135 |
230,297 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_polygon | def create_actor_polygon(pts, color, **kwargs):
""" Creates a VTK actor for rendering polygons.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name = kwargs.get('name', "... | python | def create_actor_polygon(pts, color, **kwargs):
""" Creates a VTK actor for rendering polygons.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name = kwargs.get('name', "... | [
"def",
"create_actor_polygon",
"(",
"pts",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'",
",",
"0... | Creates a VTK actor for rendering polygons.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"polygons",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L138-L186 |
230,298 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_mesh | def create_actor_mesh(pts, lines, color, **kwargs):
""" Creates a VTK actor for rendering quadrilateral plots.
:param pts: points
:type pts: vtkFloatArray
:param lines: point connectivity information
:type lines: vtkIntArray
:param color: actor color
:type color: list
:return: a VTK act... | python | def create_actor_mesh(pts, lines, color, **kwargs):
""" Creates a VTK actor for rendering quadrilateral plots.
:param pts: points
:type pts: vtkFloatArray
:param lines: point connectivity information
:type lines: vtkIntArray
:param color: actor color
:type color: list
:return: a VTK act... | [
"def",
"create_actor_mesh",
"(",
"pts",
",",
"lines",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index... | Creates a VTK actor for rendering quadrilateral plots.
:param pts: points
:type pts: vtkFloatArray
:param lines: point connectivity information
:type lines: vtkIntArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"quadrilateral",
"plots",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L189-L238 |
230,299 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_tri | def create_actor_tri(pts, tris, color, **kwargs):
""" Creates a VTK actor for rendering triangulated surface plots.
:param pts: points
:type pts: vtkFloatArray
:param tris: list of triangle indices
:type tris: ndarray
:param color: actor color
:type color: list
:return: a VTK actor
... | python | def create_actor_tri(pts, tris, color, **kwargs):
""" Creates a VTK actor for rendering triangulated surface plots.
:param pts: points
:type pts: vtkFloatArray
:param tris: list of triangle indices
:type tris: ndarray
:param color: actor color
:type color: list
:return: a VTK actor
... | [
"def",
"create_actor_tri",
"(",
"pts",
",",
"tris",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'"... | Creates a VTK actor for rendering triangulated surface plots.
:param pts: points
:type pts: vtkFloatArray
:param tris: list of triangle indices
:type tris: ndarray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"triangulated",
"surface",
"plots",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L241-L286 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.