neulab/docprompting-conala huggingface dataset:
tempfile.mkstemp(suffix=None, prefix=None, dir=None, text=False)  
Creates a temporary file in the most secure manner possible. There are no race conditions in the file’s creation, assuming that the platform properly implements the os.O_EXCL flag for os.open(). The file is readable and writable only by the creating user ID. If the platform uses permission bits to indicate whether a file is executable, the file is executable by no one. The file descriptor is not inherited by child processes. Unlike TemporaryFile(), the user of mkstemp() is responsible for deleting the temporary file when done with it. If suffix is not None, the file name will end with that suffix, otherwise there will be no suffix. mkstemp() does not put a dot between the file name and the suffix; if you need one, put it at the beginning of suffix. If prefix is not None, the file name will begin with that prefix; otherwise, a default prefix is used. The default is the return value of gettempprefix() or gettempprefixb(), as appropriate. If dir is not None, the file will be created in that directory; otherwise, a default directory is used. The default directory is chosen from a platform-dependent list, but the user of the application can control the directory location by setting the TMPDIR, TEMP or TMP environment variables. There is thus no guarantee that the generated filename will have any nice properties, such as not requiring quoting when passed to external commands via os.popen(). If any of suffix, prefix, and dir are not None, they must be the same type. If they are bytes, the returned name will be bytes instead of str. If you want to force a bytes return value with otherwise default behavior, pass suffix=b''. If text is specified and true, the file is opened in text mode. Otherwise, (the default) the file is opened in binary mode. mkstemp() returns a tuple containing an OS-level handle to an open file (as would be returned by os.open()) and the absolute pathname of that file, in that order. Raises an auditing event tempfile.mkstemp with argument fullpath.  Changed in version 3.5: suffix, prefix, and dir may now be supplied in bytes in order to obtain a bytes return value. Prior to this, only str was allowed. suffix and prefix now accept and default to None to cause an appropriate default value to be used.   Changed in version 3.6: The dir parameter now accepts a path-like object.
tempfile.mktemp(suffix='', prefix='tmp', dir=None)  
 Deprecated since version 2.3: Use mkstemp() instead.  Return an absolute pathname of a file that did not exist at the time the call is made. The prefix, suffix, and dir arguments are similar to those of mkstemp(), except that bytes file names, suffix=None and prefix=None are not supported.  Warning Use of this function may introduce a security hole in your program. By the time you get around to doing anything with the file name it returns, someone else may have beaten you to the punch. mktemp() usage can be replaced easily with NamedTemporaryFile(), passing it the delete=False parameter: >>> f = NamedTemporaryFile(delete=False)
>>> f.name
'/tmp/tmptjujjt'
>>> f.write(b"Hello World!\n")
13
>>> f.close()
>>> os.unlink(f.name)
>>> os.path.exists(f.name)
False
tempfile.NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, delete=True, *, errors=None)  
This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved from the name attribute of the returned file-like object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed. The returned object is always a file-like object whose file attribute is the underlying true file object. This file-like object can be used in a with statement, just like a normal file. Raises an auditing event tempfile.mkstemp with argument fullpath.  Changed in version 3.8: Added errors parameter.
tempfile.SpooledTemporaryFile(max_size=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)  
This function operates exactly as TemporaryFile() does, except that data is spooled in memory until the file size exceeds max_size, or until the file’s fileno() method is called, at which point the contents are written to disk and operation proceeds as with TemporaryFile(). The resulting file has one additional method, rollover(), which causes the file to roll over to an on-disk file regardless of its size. The returned object is a file-like object whose _file attribute is either an io.BytesIO or io.TextIOWrapper object (depending on whether binary or text mode was specified) or a true file object, depending on whether rollover() has been called. This file-like object can be used in a with statement, just like a normal file.  Changed in version 3.3: the truncate method now accepts a size argument.   Changed in version 3.8: Added errors parameter.
tempfile.tempdir  
When set to a value other than None, this variable defines the default value for the dir argument to the functions defined in this module. If tempdir is None (the default) at any call to any of the above functions except gettempprefix() it is initialized following the algorithm described in gettempdir().
tempfile.TemporaryDirectory(suffix=None, prefix=None, dir=None)  
This function securely creates a temporary directory using the same rules as mkdtemp(). The resulting object can be used as a context manager (see Examples). On completion of the context or destruction of the temporary directory object the newly created temporary directory and all its contents are removed from the filesystem. The directory name can be retrieved from the name attribute of the returned object. When the returned object is used as a context manager, the name will be assigned to the target of the as clause in the with statement, if there is one. The directory can be explicitly cleaned up by calling the cleanup() method. Raises an auditing event tempfile.mkdtemp with argument fullpath.  New in version 3.2.
tempfile.TemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)  
Return a file-like object that can be used as a temporary storage area. The file is created securely, using the same rules as mkstemp(). It will be destroyed as soon as it is closed (including an implicit close when the object is garbage collected). Under Unix, the directory entry for the file is either not created at all or is removed immediately after the file is created. Other platforms do not support this; your code should not rely on a temporary file created using this function having or not having a visible name in the file system. The resulting object can be used as a context manager (see Examples). On completion of the context or destruction of the file object the temporary file will be removed from the filesystem. The mode parameter defaults to 'w+b' so that the file created can be read and written without being closed. Binary mode is used so that it behaves consistently on all platforms without regard for the data that is stored. buffering, encoding, errors and newline are interpreted as for open(). The dir, prefix and suffix parameters have the same meaning and defaults as with mkstemp(). The returned object is a true file object on POSIX platforms. On other platforms, it is a file-like object whose file attribute is the underlying true file object. The os.O_TMPFILE flag is used if it is available and works (Linux-specific, requires Linux kernel 3.11 or later). Raises an auditing event tempfile.mkstemp with argument fullpath.  Changed in version 3.5: The os.O_TMPFILE flag is now used if available.   Changed in version 3.8: Added errors parameter.
termios — POSIX style tty control This module provides an interface to the POSIX calls for tty I/O control. For a complete description of these calls, see termios(3) Unix manual page. It is only available for those Unix versions that support POSIX termios style tty I/O control configured during installation. All functions in this module take a file descriptor fd as their first argument. This can be an integer file descriptor, such as returned by sys.stdin.fileno(), or a file object, such as sys.stdin itself. This module also defines all the constants needed to work with the functions provided here; these have the same name as their counterparts in C. Please refer to your system documentation for more information on using these terminal control interfaces. The module defines the following functions:  
termios.tcgetattr(fd)  
Return a list containing the tty attributes for file descriptor fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list of the tty special characters (each a string of length 1, except the items with indices VMIN and VTIME, which are integers when these fields are defined). The interpretation of the flags and the speeds as well as the indexing in the cc array must be done using the symbolic constants defined in the termios module. 
  
termios.tcsetattr(fd, when, attributes)  
Set the tty attributes for file descriptor fd from the attributes, which is a list like the one returned by tcgetattr(). The when argument determines when the attributes are changed: TCSANOW to change immediately, TCSADRAIN to change after transmitting all queued output, or TCSAFLUSH to change after transmitting all queued output and discarding all queued input. 
  
termios.tcsendbreak(fd, duration)  
Send a break on file descriptor fd. A zero duration sends a break for 0.25–0.5 seconds; a nonzero duration has a system dependent meaning. 
  
termios.tcdrain(fd)  
Wait until all output written to file descriptor fd has been transmitted. 
  
termios.tcflush(fd, queue)  
Discard queued data on file descriptor fd. The queue selector specifies which queue: TCIFLUSH for the input queue, TCOFLUSH for the output queue, or TCIOFLUSH for both queues. 
  
termios.tcflow(fd, action)  
Suspend or resume input or output on file descriptor fd. The action argument can be TCOOFF to suspend output, TCOON to restart output, TCIOFF to suspend input, or TCION to restart input. 
  See also  
Module tty


Convenience functions for common terminal control operations.    Example Here’s a function that prompts for a password with echoing turned off. Note the technique using a separate tcgetattr() call and a try … finally statement to ensure that the old tty attributes are restored exactly no matter what happens: def getpass(prompt="Password: "):
    import termios, sys
    fd = sys.stdin.fileno()
    old = termios.tcgetattr(fd)
    new = termios.tcgetattr(fd)
    new[3] = new[3] & ~termios.ECHO          # lflags
    try:
        termios.tcsetattr(fd, termios.TCSADRAIN, new)
        passwd = input(prompt)
    finally:
        termios.tcsetattr(fd, termios.TCSADRAIN, old)
    return passwd
termios.tcdrain(fd)  
Wait until all output written to file descriptor fd has been transmitted.
termios.tcflow(fd, action)  
Suspend or resume input or output on file descriptor fd. The action argument can be TCOOFF to suspend output, TCOON to restart output, TCIOFF to suspend input, or TCION to restart input.
termios.tcflush(fd, queue)  
Discard queued data on file descriptor fd. The queue selector specifies which queue: TCIFLUSH for the input queue, TCOFLUSH for the output queue, or TCIOFLUSH for both queues.
termios.tcgetattr(fd)  
Return a list containing the tty attributes for file descriptor fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list of the tty special characters (each a string of length 1, except the items with indices VMIN and VTIME, which are integers when these fields are defined). The interpretation of the flags and the speeds as well as the indexing in the cc array must be done using the symbolic constants defined in the termios module.
termios.tcsendbreak(fd, duration)  
Send a break on file descriptor fd. A zero duration sends a break for 0.25–0.5 seconds; a nonzero duration has a system dependent meaning.
termios.tcsetattr(fd, when, attributes)  
Set the tty attributes for file descriptor fd from the attributes, which is a list like the one returned by tcgetattr(). The when argument determines when the attributes are changed: TCSANOW to change immediately, TCSADRAIN to change after transmitting all queued output, or TCSAFLUSH to change after transmitting all queued output and discarding all queued input.
test.support.ALWAYS_EQ  
Object that is equal to anything. Used to test mixed type comparison.
@test.support.anticipate_failure(condition)  
A decorator to conditionally mark tests with unittest.expectedFailure(). Any use of this decorator should have an associated comment identifying the relevant tracker issue.
test.support.args_from_interpreter_flags()  
Return a list of command line arguments reproducing the current settings in sys.flags and sys.warnoptions.
class test.support.BasicTestRunner  
 
run(test)  
Run test and return the result.
@test.support.bigaddrspacetest(f)  
Decorator for tests that fill the address space. f is the function to wrap.
@test.support.bigmemtest(size, memuse, dry_run=True)  
Decorator for bigmem tests. size is a requested size for the test (in arbitrary, test-interpreted units.) memuse is the number of bytes per unit for the test, or a good estimate of it. For example, a test that needs two byte buffers, of 4 GiB each, could be decorated with @bigmemtest(size=_4G, memuse=2). The size argument is normally passed to the decorated test method as an extra argument. If dry_run is True, the value passed to the test method may be less than the requested value. If dry_run is False, it means the test doesn’t support dummy runs when -M is not specified.
class test.support.bytecode_helper.BytecodeTestCase(unittest.TestCase)  
This class has custom assertion methods for inspecting bytecode.
BytecodeTestCase.assertInBytecode(x, opname, argval=_UNSPECIFIED)  
Return instr if opname is found, otherwise throws AssertionError.
BytecodeTestCase.assertNotInBytecode(x, opname, argval=_UNSPECIFIED)  
Throws AssertionError if opname is found.
BytecodeTestCase.get_disassembly_as_string(co)  
Return the disassembly of co as string.
test.support.calcobjsize(fmt)  
Return struct.calcsize() for nP{fmt}0n or, if gettotalrefcount exists, 2PnP{fmt}0P.
test.support.calcvobjsize(fmt)  
Return struct.calcsize() for nPn{fmt}0n or, if gettotalrefcount exists, 2PnPn{fmt}0P.
test.support.can_symlink()  
Return True if the OS supports symbolic links, False otherwise.
test.support.can_xattr()  
Return True if the OS supports xattr, False otherwise.
test.support.captured_stdin()  
test.support.captured_stdout()  
test.support.captured_stderr()  
A context managers that temporarily replaces the named stream with io.StringIO object. Example use with output streams: with captured_stdout() as stdout, captured_stderr() as stderr:
    print("hello")
    print("error", file=sys.stderr)
assert stdout.getvalue() == "hello\n"
assert stderr.getvalue() == "error\n"
 Example use with input stream: with captured_stdin() as stdin:
    stdin.write('hello\n')
    stdin.seek(0)
    # call test code that consumes from sys.stdin
    captured = input()
self.assertEqual(captured, "hello")
test.support.catch_threading_exception()  
Context manager catching threading.Thread exception using threading.excepthook(). Attributes set when an exception is catched:  exc_type exc_value exc_traceback thread  See threading.excepthook() documentation. These attributes are deleted at the context manager exit. Usage: with support.catch_threading_exception() as cm:
    # code spawning a thread which raises an exception
    ...

    # check the thread exception, use cm attributes:
    # exc_type, exc_value, exc_traceback, thread
    ...

# exc_type, exc_value, exc_traceback, thread attributes of cm no longer
# exists at this point
# (to avoid reference cycles)
  New in version 3.8.
test.support.catch_unraisable_exception()  
Context manager catching unraisable exception using sys.unraisablehook(). Storing the exception value (cm.unraisable.exc_value) creates a reference cycle. The reference cycle is broken explicitly when the context manager exits. Storing the object (cm.unraisable.object) can resurrect it if it is set to an object which is being finalized. Exiting the context manager clears the stored object. Usage: with support.catch_unraisable_exception() as cm:
    # code creating an "unraisable exception"
    ...

    # check the unraisable exception: use cm.unraisable
    ...

# cm.unraisable attribute no longer exists at this point
# (to break a reference cycle)
  New in version 3.8.
test.support.change_cwd(path, quiet=False)  
A context manager that temporarily changes the current working directory to path and yields the directory. If quiet is False, the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same.
test.support.checksizeof(test, o, size)  
For testcase test, assert that the sys.getsizeof for o plus the GC header size equals size.
test.support.check_free_after_iterating(test, iter, cls, args=())  
Assert that iter is deallocated after iterating.
test.support.check_impl_detail(**guards)  
Use this check to guard CPython’s implementation-specific tests or to run them only on the implementations guarded by the arguments: check_impl_detail()               # Only on CPython (default).
check_impl_detail(jython=True)    # Only on Jython.
check_impl_detail(cpython=False)  # Everywhere except CPython.
test.support.check_no_resource_warning(testcase)  
Context manager to check that no ResourceWarning was raised. You must remove the object which may emit ResourceWarning before the end of the context manager.
test.support.check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None)  
Test for syntax errors in statement by attempting to compile statement. testcase is the unittest instance for the test. errtext is the regular expression which should match the string representation of the raised SyntaxError. If lineno is not None, compares to the line of the exception. If offset is not None, compares to the offset of the exception.
test.support.check_syntax_warning(testcase, statement, errtext='', *, lineno=1, offset=None)  
Test for syntax warning in statement by attempting to compile statement. Test also that the SyntaxWarning is emitted only once, and that it will be converted to a SyntaxError when turned into error. testcase is the unittest instance for the test. errtext is the regular expression which should match the string representation of the emitted SyntaxWarning and raised SyntaxError. If lineno is not None, compares to the line of the warning and exception. If offset is not None, compares to the offset of the exception.  New in version 3.8.
test.support.check_warnings(*filters, quiet=True)  
A convenience wrapper for warnings.catch_warnings() that makes it easier to test that a warning was correctly raised. It is approximately equivalent to calling warnings.catch_warnings(record=True) with warnings.simplefilter() set to always and with the option to automatically validate the results that are recorded. check_warnings accepts 2-tuples of the form ("message regexp",
WarningCategory) as positional arguments. If one or more filters are provided, or if the optional keyword argument quiet is False, it checks to make sure the warnings are as expected: each specified filter must match at least one of the warnings raised by the enclosed code or the test fails, and if any warnings are raised that do not match any of the specified filters the test fails. To disable the first of these checks, set quiet to True. If no arguments are specified, it defaults to: check_warnings(("", Warning), quiet=True)
 In this case all warnings are caught and no errors are raised. On entry to the context manager, a WarningRecorder instance is returned. The underlying warnings list from catch_warnings() is available via the recorder object’s warnings attribute. As a convenience, the attributes of the object representing the most recent warning can also be accessed directly through the recorder object (see example below). If no warning has been raised, then any of the attributes that would otherwise be expected on an object representing a warning will return None. The recorder object also has a reset() method, which clears the warnings list. The context manager is designed to be used like this: with check_warnings(("assertion is always true", SyntaxWarning),
                    ("", UserWarning)):
    exec('assert(False, "Hey!")')
    warnings.warn(UserWarning("Hide me!"))
 In this case if either warning was not raised, or some other warning was raised, check_warnings() would raise an error. When a test needs to look more deeply into the warnings, rather than just checking whether or not they occurred, code like this can be used: with check_warnings(quiet=True) as w:
    warnings.warn("foo")
    assert str(w.args[0]) == "foo"
    warnings.warn("bar")
    assert str(w.args[0]) == "bar"
    assert str(w.warnings[0].args[0]) == "foo"
    assert str(w.warnings[1].args[0]) == "bar"
    w.reset()
    assert len(w.warnings) == 0
 Here all warnings will be caught, and the test code tests the captured warnings directly.  Changed in version 3.2: New optional arguments filters and quiet.
test.support.check__all__(test_case, module, name_of_module=None, extra=(), blacklist=())  
Assert that the __all__ variable of module contains all public names. The module’s public names (its API) are detected automatically based on whether they match the public name convention and were defined in module. The name_of_module argument can specify (as a string or tuple thereof) what module(s) an API could be defined in order to be detected as a public API. One case for this is when module imports part of its public API from other modules, possibly a C backend (like csv and its _csv). The extra argument can be a set of names that wouldn’t otherwise be automatically detected as “public”, like objects without a proper __module__ attribute. If provided, it will be added to the automatically detected ones. The blacklist argument can be a set of names that must not be treated as part of the public API even though their names indicate otherwise. Example use: import bar
import foo
import unittest
from test import support

class MiscTestCase(unittest.TestCase):
    def test__all__(self):
        support.check__all__(self, foo)

class OtherTestCase(unittest.TestCase):
    def test__all__(self):
        extra = {'BAR_CONST', 'FOO_CONST'}
        blacklist = {'baz'}  # Undocumented name.
        # bar imports part of its API from _bar.
        support.check__all__(self, bar, ('bar', '_bar'),
                             extra=extra, blacklist=blacklist)
  New in version 3.6.
class test.support.CleanImport(*module_names)  
A context manager to force import to return a new module reference. This is useful for testing module-level behaviors, such as the emission of a DeprecationWarning on import. Example usage: with CleanImport('foo'):
    importlib.import_module('foo')  # New reference.
@test.support.cpython_only(test)  
Decorator for tests only applicable to CPython.
test.support.create_empty_file(filename)  
Create an empty file with filename. If it already exists, truncate it.
test.support.detect_api_mismatch(ref_api, other_api, *, ignore=())  
Returns the set of attributes, functions or methods of ref_api not found on other_api, except for a defined list of items to be ignored in this check specified in ignore. By default this skips private attributes beginning with ‘_’ but includes all magic methods, i.e. those starting and ending in ‘__’.  New in version 3.5.