output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
Determines whether or not the resource is filtered based on the tags and paths specified in the command line options. | Here you have a function in Python 3, explain what it does
def filtered(self):
if not is_tagged(self.tags, self.opt.tags):
LOG.info("Skipping %s as it does not have requested tags",
self.path)
return False
if not specific_path_check(self.path, self.opt):
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Read from Vault while handling non surprising errors. | Can you generate the documentation for the following Python 3 function
def read(self, client):
val = None
if self.no_resource:
return val
LOG.debug("Reading from %s", self)
try:
val = client.read(self.path)
except hvac.exceptions.InvalidRequest as vault_e... | As a Python code composer, you craft elegant and concise scripts. |
def write(self, client):
"""Write to Vault while handling non-surprising errors."""
val = None
if not self.no_resource:
val = client.write(self.path, **self.obj())
return val | Write a Python 3 function that can
write to Vault while handling non - surprising errors. | As a python code expert, you are capable of creating scripts from specifications. |
Searches up from a directory looking for a file | Can you generate a brief explanation for the following Python 3 code
def find_file(name, directory):
path_bits = directory.split(os.sep)
for i in range(0, len(path_bits) - 1):
check_path = path_bits[0:len(path_bits) - i]
check_file = "%s%s%s" % (os.sep.join(check_path), os.sep, name)
if ... | You are a Python code generator, capable of creating scripts from specifications. |
def in_file(string, search_file):
"""Looks in a file for a string."""
handle = open(search_file, 'r')
for line in handle.readlines():
if string in line:
return True
return False | How would you code a function in Python 3 to
look in a file for a string. | As a python code expert, you are capable of creating scripts from specifications. |
Will check directories upwards from the Secretfile in order
to ensure the gitignore file is set properly | Given the following Python 3 function, write the documentation
def gitignore(opt):
directory = os.path.dirname(abspath(opt.secretfile))
gitignore_file = find_file('.gitignore', directory)
if gitignore_file:
secrets_path = subdir_path(abspath(opt.secrets), gitignore_file)
if secrets_path:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Will make checks against include and exclude to determine if we care about the path in question. | Explain what the following Python 3 code does
def specific_path_check(path, opt):
if opt.exclude:
if path in opt.exclude:
return False
if opt.include:
if path not in opt.include:
return False
return True | As a Python code analyst, you investigate and solve complex coding mysteries |
def check_obj(keys, name, obj):
"""Do basic validation on an object"""
msg = validate_obj(keys, obj)
if msg:
raise aomi.exceptions.AomiData("object check : %s in %s" % (msg, name)) | Create a Python 3 function to
do basic validation on an object | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns a quote - unquote sanitized mount path | Given the following Python 3 function, write the documentation
def sanitize_mount(mount):
sanitized_mount = mount
if sanitized_mount.startswith('/'):
sanitized_mount = sanitized_mount[1:]
if sanitized_mount.endswith('/'):
sanitized_mount = sanitized_mount[:-1]
sanitized_mount = sanitiz... | You are a Python code generator, capable of creating scripts from specifications. |
Validates a GPG key fingerprint | Can you tell what is the following Python 3 function doing
def gpg_fingerprint(key):
if (len(key) == 8 and re.match(r'^[0-9A-F]{8}$', key)) or \
(len(key) == 40 and re.match(r'^[0-9A-F]{40}$', key)):
return
raise aomi.exceptions.Validation('Invalid GPG Fingerprint') | As a Python code composer, you craft elegant and concise scripts. |
def is_unicode_string(string):
"""Validates that we are some kinda unicode string"""
try:
if sys.version_info >= (3, 0):
# isn't a python 3 str actually unicode
if not isinstance(string, str):
string.decode('utf-8')
else:
string.decode('utf-8'... | Can you write a function in Python 3 where it
validates that we are some kinda unicode string | You are a Python code architect, reviewing and designing scalable and efficient code |
Validates that the object itself is some kinda string | How would you explain what the following Python 3 function does
def is_unicode(string):
str_type = str(type(string))
if str_type.find('str') > 0 or str_type.find('unicode') > 0:
return True
return False | As a Python code analyst, you investigate and solve complex coding mysteries |
def safe_modulo(s, meta, checked='', print_warning=True, stacklevel=2):
"""Safe version of the modulo operation (%) of strings
Parameters
----------
s: str
string to apply the modulo operation with
meta: dict or tuple
meta informations to insert (usually via ``s % meta``)
checke... | Write a Python 3 script to
safe version of the modulo operation (%) of strings Parameters ---------- s: str string to apply the modulo operation with meta: dict or tuple meta informations to insert (usually via ``s % meta``) checked: {'KEY', 'VALUE'}, optional Security parameter for the recursive structure of this func... | You are a Python code architect, reviewing and designing scalable and efficient code |
Method that extracts the specified sections out of the given string s. | Make a summary of the following Python 3 code
def get_sections(self, s, base,
sections=['Parameters', 'Other Parameters']):
"""
Method that extracts the specified sections out of the given string if
(and only if) the docstring follows the numpy documentation guidelines
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Dedent the docstring of a function and substitute with params | Here you have a function in Python 3, explain what it does
def dedent(self, func):
doc = func.__doc__ and self.dedents(func.__doc__, stacklevel=4)
return self._set_object_doc(func, doc) | You are a Python code generator, capable of creating scripts from specifications. |
Dedent a string and substitute with the params attribute and return the string. | Here you have a function in Python 3, explain what it does
def dedents(self, s, stacklevel=3):
s = dedents(s)
return safe_modulo(s, self.params, stacklevel=stacklevel) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def with_indent(self, indent=0):
"""
Substitute in the docstring of a function with indented :attr:`params`
Parameters
----------
indent: int
The number of spaces that the substitution should be indented
Returns
-------
function
W... | Write a Python 3 script for
returning a function that replaces the docstring of a function with indented versions of the object s parameters with the indented version of the object s parameters. | As a python code expert, you are capable of creating scripts from specifications. |
def with_indents(self, s, indent=0, stacklevel=3):
"""
Substitute a string with the indented :attr:`params`
Parameters
----------
s: str
The string in which to substitute
indent: int
The number of spaces that the substitution should be indented
... | How would you code a function in Python 3 to
substitute a string with the indented string with the indented params. | As a Python code composer, you craft elegant and concise scripts. |
def delete_params_s(s, params):
"""
Delete the given parameters from a string
Same as :meth:`delete_params` but does not use the :attr:`params`
dictionary
Parameters
----------
s: str
The string of the parameters section
params: list of str
... | Implement a Python 3 function for
deleting the given parameters from a string s without the descriptions of the parameters. | As a python code expert, you are capable of creating scripts from specifications. |
Delete the kwargs part of the parameters section of the parameters section of the current object. | Can you generate a brief explanation for the following Python 3 code
def delete_kwargs(self, base_key, args=None, kwargs=None):
if not args and not kwargs:
warn("Neither args nor kwargs are given. I do nothing for %s" % (
base_key))
return
ext = '.no' + ('_args' i... | As a python code expert, you are capable of creating scripts from specifications. |
def delete_kwargs_s(cls, s, args=None, kwargs=None):
"""
Deletes the ``*args`` or ``**kwargs`` part from the parameters section
Either `args` or `kwargs` must not be None.
Parameters
----------
s: str
The string to delete the args and kwargs from
arg... | Write a Python 3 function for
deleting the args or kwargs part from the parameters section s | As a Python code analyst, you investigate and solve complex coding mysteries |
def delete_types_s(s, types):
"""
Delete the given types from a string
Same as :meth:`delete_types` but does not use the :attr:`params`
dictionary
Parameters
----------
s: str
The string of the returns like section
types: list of str
... | Create a Python 3 function to
delete the given types from a string s. | As a Python code composer, you craft elegant and concise scripts. |
def keep_params_s(s, params):
"""
Keep the given parameters from a string
Same as :meth:`keep_params` but does not use the :attr:`params`
dictionary
Parameters
----------
s: str
The string of the parameters like section
params: list of str
... | How would you implement a function in Python 3 that
keeps the given parameters from a string s with only the descriptions of params. | As a Python code composer, you craft elegant and concise scripts. |
Method to keep only specific parameters from a parameter documentation. | How would you explain what the following Python 3 function does
def keep_types(self, base_key, out_key, *types):
self.params['%s.%s' % (base_key, out_key)] = self.keep_types_s(
self.params[base_key], types) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def keep_types_s(s, types):
"""
Keep the given types from a string
Same as :meth:`keep_types` but does not use the :attr:`params`
dictionary
Parameters
----------
s: str
The string of the returns like section
types: list of str
Th... | Can you create a Python 3 function that
keeps the given types from a string s | As a Python code translator, you convert algorithms and pseudocode into Python. |
def save_docstring(self, key):
"""
Descriptor method to save a docstring from a function
Like the :meth:`get_sectionsf` method this method serves as a
descriptor for functions but saves the entire docstring"""
def func(f):
self.params[key] = f.__doc__ or ''
... | Implement a Python 3 function for
saving a docstring from a function that returns a dict of the key and the value of the docstring. | As a Python code composer, you craft elegant and concise scripts. |
This method extracts the summary of the given docstring s which is the key under which the summary is stored in the given base. | Given the following Python 3 function, write the documentation
def get_summary(self, s, base=None):
summary = summary_patt.search(s).group()
if base is not None:
self.params[base + '.summary'] = summary
return summary | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_summaryf(self, *args, **kwargs):
"""
Extract the summary from a function docstring
Parameters
----------
``*args`` and ``**kwargs``
See the :meth:`get_summary` method. Note, that the first argument
will be the docstring of the specified function
... | How would you implement a function in Python 3 that
returns a function that returns the summary of the specified function. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_extended_summary(self, s, base=None):
"""Get the extended summary from a docstring
This here is the extended summary
Parameters
----------
s: str
The docstring to use
base: str or None
A key under which the summary shall be stored in the ... | Can you write a function in Python 3 where it
gets the extended summary from a docstring | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns a function that extracts the extended summary of a function docstring | Given the following Python 3 function, write the documentation
def get_extended_summaryf(self, *args, **kwargs):
def func(f):
doc = f.__doc__
self.get_extended_summary(doc or '', *args, **kwargs)
return f
return func | As a Python code composer, you craft elegant and concise scripts. |
Get the full description from a docstring | Make a summary of the following Python 3 code
def get_full_description(self, s, base=None):
summary = self.get_summary(s)
extended_summary = self.get_extended_summary(s)
ret = (summary + '\n\n' + extended_summary).strip()
if base is not None:
self.params[base + '.full_desc'] ... | You are a Python code architect, reviewing and designing scalable and efficient code |
def get_full_descriptionf(self, *args, **kwargs):
"""Extract the full description from a function docstring
This function can be used as a decorator to extract the full
descriptions of a function docstring (similar to
:meth:`get_sectionsf`).
Parameters
----------
... | Can you implement a function in Python 3 that
returns a function that extracts the full description of a function docstring | You are a Python code analyst, evaluating scripts for potential improvements. |
Makes an object mergable if possible. Returns the virgin object if the object is mergable. | Given the following Python 3 function, write the documentation
def make_mergable_if_possible(cls, data, context):
if isinstance(data, dict):
return MergableDict(data=data, context=context)
elif isiterable(data):
return MergableList(
data=[cls.make_mergable_if_poss... | As a python code expert, you are capable of creating scripts from specifications. |
def merge(self, *args):
"""
Merges this instance with new instances, in-place.
:param \\*args: Configuration values to merge with current instance.
:type \\*args: iterable
"""
for data in args:
if isinstance(data, str):
to_merge = load_string... | Can you write a function in Python 3 where it
merges this instance with new instances in - place. | You are a Python code generator, capable of creating scripts from specifications. |
load file which contains yaml configuration entries and merge it by
current instance | Make a summary of the following Python 3 code
def load_file(self, filename):
if not path.exists(filename):
raise FileNotFoundError(filename)
loaded_yaml = load_yaml(filename, self.context)
if loaded_yaml:
self.merge(loaded_yaml) | You are a Python code analyst, evaluating scripts for potential improvements. |
def initialize(self, init_value, context=None, force=False):
"""
Initialize the configuration manager
:param force: force initialization even if it's already initialized
:return:
"""
if not force and self._instance is not None:
raise ConfigurationAlreadyInit... | Can you implement a function in Python 3 that
initializes the configuration manager. | You are a Python code generator, capable of creating scripts from specifications. |
def grok_filter_name(element):
"""Extracts the name, which may be embedded, for a Jinja2
filter node"""
e_name = None
if element.name == 'default':
if isinstance(element.node, jinja2.nodes.Getattr):
e_name = element.node.node.name
else:
e_name = element.node.name
... | Can you implement a function in Python 3 that
extracts the name which may be embedded for a Jinja2 filter node | As a Python code analyst, you investigate and solve complex coding mysteries |
Properly parses a If element | Can you generate the documentation for the following Python 3 function
def grok_if_node(element, default_vars):
if isinstance(element.test, jinja2.nodes.Filter) and \
element.test.name == 'default':
default_vars.append(element.test.node.name)
return default_vars + grok_vars(element) | As a Python code analyst, you investigate and solve complex coding mysteries |
Returns a list of vars for which the value is being appropriately set
| Can you tell what is the following Python 3 function doing
def grok_vars(elements):
default_vars = []
iterbody = None
if hasattr(elements, 'body'):
iterbody = elements.body
elif hasattr(elements, 'nodes'):
iterbody = elements.nodes
for element in iterbody:
if isinstance(elem... | You are a Python code architect, reviewing and designing scalable and efficient code |
Sets up our Jinja environment loading the few filters we have | Make a summary of the following Python 3 code
def jinja_env(template_path):
fs_loader = FileSystemLoader(os.path.dirname(template_path))
env = Environment(loader=fs_loader,
autoescape=True,
trim_blocks=True,
lstrip_blocks=True)
env.filters['b... | You are a Python code generator, capable of creating scripts from specifications. |
def missing_vars(template_vars, parsed_content, obj):
"""If we find missing variables when rendering a template
we want to give the user a friendly error"""
missing = []
default_vars = grok_vars(parsed_content)
for var in template_vars:
if var not in default_vars and var not in obj:
... | Create a Python 3 function to
check if the user has required variables in a template. | You are a Python code analyst, evaluating scripts for potential improvements. |
Render a template with the given object. | Can you generate a brief explanation for the following Python 3 code
def render(filename, obj):
template_path = abspath(filename)
env = jinja_env(template_path)
template_base = os.path.basename(template_path)
try:
parsed_content = env.parse(env
.loader
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def load_vars(opt):
"""Loads variable from cli and var files, passing in cli options
as a seed (although they can be overwritten!).
Note, turn this into an object so it's a nicer "cache"."""
if not hasattr(opt, '_vars_cache'):
cli_opts = cli_hash(opt.extra_vars)
setattr(opt, '_vars_cache... | How would you code a function in Python 3 to
load variable from cli and var files passing in cli options as a seed. | You are a Python code architect, reviewing and designing scalable and efficient code |
Load variable files merge and return contents | Explain what the following Python 3 code does
def load_var_files(opt, p_obj=None):
obj = {}
if p_obj:
obj = p_obj
for var_file in opt.extra_vars_file:
LOG.debug("loading vars from %s", var_file)
obj = merge_dicts(obj.copy(), load_var_file(var_file, obj))
return obj | As a Python code translator, you convert algorithms and pseudocode into Python. |
def load_var_file(filename, obj):
"""Loads a varible file, processing it as a template"""
rendered = render(filename, obj)
ext = os.path.splitext(filename)[1][1:]
v_obj = dict()
if ext == 'json':
v_obj = json.loads(rendered)
elif ext == 'yaml' or ext == 'yml':
v_obj = yaml.safe_l... | Can you write a function in Python 3 where it
loads a varible file processing it as a template | You are a Python code architect, reviewing and designing scalable and efficient code |
Loads the help for a given template | Can you tell what is the following Python 3 function doing
def load_template_help(builtin):
help_file = "templates/%s-help.yml" % builtin
help_file = resource_filename(__name__, help_file)
help_obj = {}
if os.path.exists(help_file):
help_data = yaml.safe_load(open(help_file))
if 'name' ... | As a python code expert, you are capable of creating scripts from specifications. |
def builtin_list():
"""Show a listing of all our builtin templates"""
for template in resource_listdir(__name__, "templates"):
builtin, ext = os.path.splitext(os.path.basename(abspath(template)))
if ext == '.yml':
continue
help_obj = load_template_help(builtin)
if 'n... | Can you write a function in Python 3 where it
shows a listing of all our builtin templates | As a Python code composer, you craft elegant and concise scripts. |
Show information on a particular builtin template | Make a summary of the following Python 3 code
def builtin_info(builtin):
help_obj = load_template_help(builtin)
if help_obj.get('name') and help_obj.get('help'):
print("The %s template" % (help_obj['name']))
print(help_obj['help'])
else:
print("No help for %s" % builtin)
if help... | As a python code expert, you are capable of creating scripts from specifications. |
def render_secretfile(opt):
"""Renders and returns the Secretfile construct"""
LOG.debug("Using Secretfile %s", opt.secretfile)
secretfile_path = abspath(opt.secretfile)
obj = load_vars(opt)
return render(secretfile_path, obj) | How would you code a function in Python 3 to
render and returns the Secretfile construct | As a Python code composer, you craft elegant and concise scripts. |
Will update the password for a userpass user | Can you tell what is the following Python 3 function doing
def update_user_password(client, userpass):
vault_path = ''
user = ''
user_path_bits = userpass.split('/')
if len(user_path_bits) == 1:
user = user_path_bits[0]
vault_path = "auth/userpass/users/%s/password" % user
LOG.de... | You are a Python code generator, capable of creating scripts from specifications. |
Will update a single key in a generic secret backend as
thought it was a password | Explain what the following Python 3 code does
def update_generic_password(client, path):
vault_path, key = path_pieces(path)
mount = mount_for_path(vault_path, client)
if not mount:
client.revoke_self_token()
raise aomi.exceptions.VaultConstraint('invalid path')
if backend_type(mount, c... | You are a Python code generator, capable of creating scripts from specifications. |
Will attempt to update a password in Vault | Here you have a function in Python 3, explain what it does
def password(client, path):
if path.startswith('user:'):
update_user_password(client, path[5:])
else:
update_generic_password(client, path) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns the path to a misc Vault file | Make a summary of the following Python 3 code
def vault_file(env, default):
home = os.environ['HOME'] if 'HOME' in os.environ else \
os.environ['USERPROFILE']
filename = os.environ.get(env, os.path.join(home, default))
filename = abspath(filename)
if os.path.exists(filename):
return file... | You are a Python code architect, reviewing and designing scalable and efficient code |
def vault_time_to_s(time_string):
"""Will convert a time string, as recognized by other Vault
tooling, into an integer representation of seconds"""
if not time_string or len(time_string) < 2:
raise aomi.exceptions \
.AomiData("Invalid timestring %s" % time_string)
last_char = ... | Write a Python 3 function that can
convert a time string into an integer representation of seconds | As a Python code composer, you craft elegant and concise scripts. |
def run(*args, **kwargs):
"""Execute a command.
Command can be passed as several arguments, each being a string
or a list of strings; lists are flattened.
If opts.verbose is True, output of the command is shown.
If the command exits with non-zero, print an error message and exit.
If keyward arg... | Implement a function in Python 3 to
execute a command and return the output of the command. | As a Python code composer, you craft elegant and concise scripts. |
Sets the current thread s is_executing flag. | Can you generate a brief explanation for the following Python 3 code
def set_executing(on: bool):
my_thread = threading.current_thread()
if isinstance(my_thread, threads.CauldronThread):
my_thread.is_executing = on | You are a Python code architect, reviewing and designing scalable and efficient code |
Loads the contents of the source file into a string for execution using multiple
loading methods. | Explain what the following Python 3 code does
def get_file_contents(source_path: str) -> str:
open_funcs = [
functools.partial(codecs.open, source_path, encoding='utf-8'),
functools.partial(open, source_path, 'r')
]
for open_func in open_funcs:
try:
with open_func() as ... | You are a Python code analyst, evaluating scripts for potential improvements. |
def load_step_file(source_path: str) -> str:
"""
Loads the source for a step file at the given path location and then
renders it in a template to add additional footer data.
The footer is used to force the display to flush the print buffer and
breathe the step to open things up for resolution. This... | Write a Python 3 script for
loading the source for a step file at the given path and renders it in a template. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def create_module(
project: 'projects.Project',
step: 'projects.ProjectStep'
):
"""
Creates an artificial module that will encompass the code execution for
the specified step. The target module is populated with the standard dunder
attributes like __file__ to simulate the normal way that... | Implement a Python 3 function for
creating a artificial module that encompasses code execution for the specified project. | You are a Python code architect, reviewing and designing scalable and efficient code |
Runs the python source file of the current project and returns the result of the execution. | Can you tell what is the following Python 3 function doing
def run(
project: 'projects.Project',
step: 'projects.ProjectStep',
) -> dict:
"""
Carries out the execution of the step python source file by loading it into
an artificially created module and then executing that module and returnin... | You are a Python code generator, capable of creating scripts from specifications. |
Renders a SyntaxError to html and text for both text and html output. | Explain what the following Python 3 code does
def render_syntax_error(
project: 'projects.Project',
error: SyntaxError
) -> dict:
"""
Renders a SyntaxError, which has a shallow, custom stack trace derived
from the data included in the error, instead of the standard stack trace
pulled fro... | You are a Python code analyst, evaluating scripts for potential improvements. |
def render_error(
project: 'projects.Project',
error: Exception,
stack: typing.List[dict] = None
) -> dict:
"""
Renders an Exception to an error response that includes rendered text and
html error messages for display.
:param project:
Currently open project.
:param e... | Write a Python 3 script for
rendering an exception to an error response that includes rendered text and html error messages for display. | As a Python code composer, you craft elegant and concise scripts. |
Executes a command and returns the result of the command. | Can you generate a brief explanation for the following Python 3 code
def execute(asynchronous: bool = False):
r = Response()
r.update(server=server_runner.get_server_data())
cmd, args = parse_command_args(r)
if r.failed:
return flask.jsonify(r.serialize())
try:
commander.execute(cm... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def abort():
"""..."""
uid_list = list(server_runner.active_execution_responses.keys())
while len(uid_list) > 0:
uid = uid_list.pop()
response = server_runner.active_execution_responses.get(uid)
if not response:
continue
try:
del server_runner.activ... | Create a Python 3 function for
aborting the current server execution process. | You are a Python code analyst, evaluating scripts for potential improvements. |
def remove_key(key: str, persists: bool = True):
"""
Removes the specified key from the cauldron configs if the key exists
:param key:
The key in the cauldron configs object to remove
:param persists:
"""
environ.configs.remove(key, include_persists=persists)
environ.configs.save()... | Write a Python 3 script to
remove the specified key from the cauldron configs object if the key exists. | You are a Python code architect, reviewing and designing scalable and efficient code |
Sets the specified key to the specified value. | Make a summary of the following Python 3 code
def set_key(key: str, value: typing.List[str], persists: bool = True):
if key.endswith('_path') or key.endswith('_paths'):
for index in range(len(value)):
value[index] = environ.paths.clean(value[index])
if len(value) == 1:
value = valu... | You are a Python code analyst, evaluating scripts for potential improvements. |
Saves the current configuration settings object to the current user s home
directory. | Can you tell what is the following Python 3 function doing
def save(self) -> 'Configuration':
data = self.load().persistent
if data is None:
return self
directory = os.path.dirname(self._source_path)
if not os.path.exists(directory):
os.makedirs(directory)
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Get a dictionary that pulls together information about the poster
safely for both authenticated and non - authenticated comments. | Here you have a function in Python 3, explain what it does
def _get_userinfo(self):
if not hasattr(self, "_userinfo"):
userinfo = {
"name": self.user_name,
"email": self.user_email,
"url": self.user_url
}
if self.user_id:
... | You are a Python code generator, capable of creating scripts from specifications. |
Return this comment as plain text. Useful for emails. | Can you generate the documentation for the following Python 3 function
def get_as_text(self):
d = {
'user': self.user or self.name,
'date': self.submit_date,
'comment': self.comment,
'domain': self.site.domain,
'url': self.get_absolute_url()
}
... | You are a Python code generator, capable of creating scripts from specifications. |
Converts the given dictionary into a file write or file copy entry depending on the keys in the dictionary. | Here you have a function in Python 3, explain what it does
def entry_from_dict(
data: dict
) -> typing.Union[FILE_WRITE_ENTRY, FILE_COPY_ENTRY]:
"""
Converts the given data dictionary into either a file write or file copy
entry depending on the keys in the dictionary. The dictionary should
conta... | As a Python code composer, you craft elegant and concise scripts. |
def deploy(files_list: typing.List[tuple]):
"""
Iterates through the specified files_list and copies or writes each entry
depending on whether its a file copy entry or a file write entry.
:param files_list:
A list of file write entries and file copy entries
"""
def deploy_entry(entry):
... | How would you code a function in Python 3 to
return a list of files that are deployed to the virtual machine. | You are a Python code analyst, evaluating scripts for potential improvements. |
def make_output_directory(output_path: str) -> str:
"""
Creates the parent directory or directories for the specified output path
if they do not already exist to prevent incomplete directory path errors
during copying/writing operations.
:param output_path:
The path of the destination file ... | Implement a function in Python 3 to
create the output directory for the specified output path. | As a Python code composer, you craft elegant and concise scripts. |
def copy(copy_entry: FILE_COPY_ENTRY):
"""
Copies the specified file from its source location to its destination
location.
"""
source_path = environ.paths.clean(copy_entry.source)
output_path = environ.paths.clean(copy_entry.destination)
copier = shutil.copy2 if os.path.isfile(source_path) e... | Create a Python 3 function for
copying the specified file to its destination location. | You are a Python code analyst, evaluating scripts for potential improvements. |
def write(write_entry: FILE_WRITE_ENTRY):
"""
Writes the contents of the specified file entry to its destination path.
"""
output_path = environ.paths.clean(write_entry.path)
make_output_directory(output_path)
writer.write_file(output_path, write_entry.contents) | How would you implement a function in Python 3 that
writes the contents of the specified file entry to its destination path. | As a python code expert, you are capable of creating scripts from specifications. |
Enable print equivalent function that also writes the output to the current project page. | Can you generate the documentation for the following Python 3 function
def enable(step: 'projects.ProjectStep'):
# Prevent anything unusual from causing buffer issues
restore_default_configuration()
stdout_interceptor = RedirectBuffer(sys.stdout)
sys.stdout = stdout_interceptor
step.report.stdout_... | As a Python code analyst, you investigate and solve complex coding mysteries |
Restores sys. stdout and sys. stderr streams to their default
AttributeNames values without regard to what step has currently overridden their values. | How would you explain what the following Python 3 function does
def restore_default_configuration():
def restore(target, default_value):
if target == default_value:
return default_value
if not isinstance(target, RedirectBuffer):
return target
try:
targe... | You are a Python code architect, reviewing and designing scalable and efficient code |
def create(
project: 'projects.Project',
destination_directory,
destination_filename: str = None
) -> file_io.FILE_WRITE_ENTRY:
"""
Creates a FILE_WRITE_ENTRY for the rendered HTML file for the given
project that will be saved in the destination directory with the given
filename.... | Write a Python 3 function that can
create a FILE_WRITE_ENTRY for the rendered HTML file for the given project. | As a Python code analyst, you investigate and solve complex coding mysteries |
Runs an interactive container | Given the following Python 3 function, write the documentation
def run_container():
os.chdir(my_directory)
cmd = [
'docker', 'run',
'-it', '--rm',
'-v', '{}:/cauldron'.format(my_directory),
'-p', '5010:5010',
'cauldron_app',
'/bin/bash'
]
return os.syst... | As a Python code analyst, you investigate and solve complex coding mysteries |
def run():
"""Execute the Cauldron container command"""
command = sys.argv[1].strip().lower()
print('[COMMAND]:', command)
if command == 'test':
return run_test()
elif command == 'build':
return run_build()
elif command == 'up':
return run_container()
elif command =... | Create a Python 3 function to
execute the Cauldron container command | As a Python code analyst, you investigate and solve complex coding mysteries |
def inspect(source: dict):
"""
Inspects the data and structure of the source dictionary object and
adds the results to the display for viewing.
:param source:
A dictionary object to be inspected.
:return:
"""
r = _get_report()
r.append_body(render.inspect(source)) | Write a Python 3 function that can
inspect the data and structure of the source dictionary object and adds the results to the display. | You are a Python code generator, capable of creating scripts from specifications. |
Adds a text header to the display with the specified level. | Here you have a function in Python 3, explain what it does
def header(header_text: str, level: int = 1, expand_full: bool = False):
r = _get_report()
r.append_body(render.header(
header_text,
level=level,
expand_full=expand_full
)) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def text(value: str, preformatted: bool = False):
"""
Adds text to the display. If the text is not preformatted, it will be
displayed in paragraph format. Preformatted text will be displayed
inside a pre tag with a monospace font.
:param value:
The text to display.
:param preformatted:
... | How would you implement a function in Python 3 that
adds text to the available language. | You are a Python code architect, reviewing and designing scalable and efficient code |
def markdown(
source: str = None,
source_path: str = None,
preserve_lines: bool = False,
font_size: float = None,
**kwargs
):
"""
Renders the specified source string or source file using markdown and
adds the resulting HTML to the notebook display.
:param source... | Implement a function in Python 3 to
render the specified source string or source file using markdown and adds the resulting HTML to the notebook display. | As a Python code analyst, you investigate and solve complex coding mysteries |
def json(**kwargs):
"""
Adds the specified data to the the output display window with the
specified key. This allows the user to make available arbitrary
JSON-compatible data to the display for runtime use.
:param kwargs:
Each keyword argument is added to the CD.data object with the
... | Create a Python 3 function for
adding the specified data to the output display window with the specified key and value. | As a Python code composer, you craft elegant and concise scripts. |
Creates a Plotly trace in the notebook with the specified data and layout. | Make a summary of the following Python 3 code
def plotly(
data: typing.Union[dict, list] = None,
layout: dict = None,
scale: float = 0.5,
figure: dict = None,
static: bool = False
):
"""
Creates a Plotly plot in the display with the specified data and
layout.
:pa... | As a python code expert, you are capable of creating scripts from specifications. |
Adds the specified data frame to the notebook display in a nicely formatted table. | Can you generate a brief explanation for the following Python 3 code
def table(
data_frame,
scale: float = 0.7,
include_index: bool = False,
max_rows: int = 500
):
"""
Adds the specified data frame to the display in a nicely formatted
scrolling table.
:param data_frame:
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adds the SVG string to the display. | Can you tell what is the following Python 3 function doing
def svg(svg_dom: str, filename: str = None):
r = _get_report()
r.append_body(render.svg(svg_dom))
r.stdout_interceptor.write_source('[ADDED] SVG\n')
if not filename:
return
if not filename.endswith('.svg'):
filename += '.sv... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def jinja(path: str, **kwargs):
"""
Renders the specified Jinja2 template to HTML and adds the output to the
display.
:param path:
The fully-qualified path to the template to be rendered.
:param kwargs:
Any keyword arguments that will be use as variable replacements within
t... | Can you implement a function in Python 3 that
renders the specified Jinja2 template to HTML and adds the output to the display. | You are a Python code analyst, evaluating scripts for potential improvements. |
def whitespace(lines: float = 1.0):
"""
Adds the specified number of lines of whitespace.
:param lines:
The number of lines of whitespace to show.
"""
r = _get_report()
r.append_body(render.whitespace(lines))
r.stdout_interceptor.write_source('\n') | Can you implement a function in Python 3 that
adds the specified number of lines of whitespace to the current page. | As a python code expert, you are capable of creating scripts from specifications. |
def image(
filename: str,
width: int = None,
height: int = None,
justify: str = 'left'
):
"""
Adds an image to the display. The image must be located within the
assets directory of the Cauldron notebook's folder.
:param filename:
Name of the file within the asset... | Write a Python 3 script for
adding an image to the notebook display. | You are a Python code architect, reviewing and designing scalable and efficient code |
Adds a valid HTML snippet to the display. | Can you generate the documentation for the following Python 3 function
def html(dom: str):
r = _get_report()
r.append_body(render.html(dom))
r.stdout_interceptor.write_source('[ADDED] HTML\n') | As a Python code composer, you craft elegant and concise scripts. |
def workspace(show_values: bool = True, show_types: bool = True):
"""
Adds a list of the shared variables currently stored in the project
workspace.
:param show_values:
When true the values for each variable will be shown in addition to
their name.
:param show_types:
When tr... | Can you write a function in Python 3 where it
adds a list of the shared variables currently stored in the project workspace. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Creates a matplotlib plot in the display for the specified figure. | Can you generate the documentation for the following Python 3 function
def pyplot(
figure=None,
scale: float = 0.8,
clear: bool = True,
aspect_ratio: typing.Union[list, tuple] = None
):
"""
Creates a matplotlib plot in the display for the specified figure. The size
of the plo... | You are a Python code generator, capable of creating scripts from specifications. |
def bokeh(model, scale: float = 0.7, responsive: bool = True):
"""
Adds a Bokeh plot object to the notebook display.
:param model:
The plot object to be added to the notebook display.
:param scale:
How tall the plot should be in the notebook as a fraction of screen
height. A num... | Can you create a Python 3 function that
adds a Bokeh plot object to the notebook display. | You are a Python code generator, capable of creating scripts from specifications. |
Displays a list of the specified source iterable. | Explain what the following Python 3 code does
def listing(
source: list,
ordered: bool = False,
expand_full: bool = False
):
"""
An unordered or ordered list of the specified *source* iterable where
each element is converted to a string representation for display.
:param source:... | You are a Python code generator, capable of creating scripts from specifications. |
def list_grid(
source: list,
expand_full: bool = False,
column_count: int = 2,
row_spacing: float = 1.0
):
"""
An multi-column list of the specified *source* iterable where
each element is converted to a string representation for display.
:param source:
The itera... | Can you write a function in Python 3 where it
displays a multi - column list of the specified source iterable. | You are a Python code generator, capable of creating scripts from specifications. |
Adds a mathematical equation in latex math - mode to the display. | Can you generate a brief explanation for the following Python 3 code
def latex(source: str):
r = _get_report()
if 'katex' not in r.library_includes:
r.library_includes.append('katex')
r.append_body(render_texts.latex(source.replace('@', '\\')))
r.stdout_interceptor.write_source('[ADDED] Latex e... | As a Python code analyst, you investigate and solve complex coding mysteries |
Displays a specified number of elements in a source object of many
different possible types. | Can you generate the documentation for the following Python 3 function
def head(source, count: int = 5):
r = _get_report()
r.append_body(render_texts.head(source, count=count))
r.stdout_interceptor.write_source('[ADDED] Head\n') | As a python code expert, you are capable of creating scripts from specifications. |
def status(
message: str = None,
progress: float = None,
section_message: str = None,
section_progress: float = None,
):
"""
Updates the status display, which is only visible while a step is running.
This is useful for providing feedback and information during long-running
... | How would you code a function in Python 3 to
display the status of the current task in the current project. | You are a Python code analyst, evaluating scripts for potential improvements. |
Adds a code block to the display from either the code file specified by the path argument or the language identifier that is used by the Pygments highlighter. | Can you tell what is the following Python 3 function doing
def code_block(
code: str = None,
path: str = None,
language_id: str = None,
title: str = None,
caption: str = None
):
"""
Adds a block of syntax highlighted code to the display from either
the supplied code a... | As a python code expert, you are capable of creating scripts from specifications. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.