doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
suffix_map
Dictionary mapping suffixes to suffixes. This is used to allow recognition of encoded files for which the encoding and the type are indicated by the same extension. For example, the .tgz extension is mapped to .tar.gz to allow the encoding and type to be recognized separately. This is initially a copy of the global suffix_map defined in the module. | python.library.mimetypes#mimetypes.MimeTypes.suffix_map |
types_map
Tuple containing two dictionaries, mapping filename extensions to MIME types: the first dictionary is for the non-standards types and the second one is for the standard types. They are initialized by common_types and types_map. | python.library.mimetypes#mimetypes.MimeTypes.types_map |
types_map_inv
Tuple containing two dictionaries, mapping MIME types to a list of filename extensions: the first dictionary is for the non-standards types and the second one is for the standard types. They are initialized by common_types and types_map. | python.library.mimetypes#mimetypes.MimeTypes.types_map_inv |
mimetypes.read_mime_types(filename)
Load the type map given in the file filename, if it exists. The type map is returned as a dictionary mapping filename extensions, including the leading dot ('.'), to strings of the form 'type/subtype'. If the file filename does not exist or cannot be read, None is returned. | python.library.mimetypes#mimetypes.read_mime_types |
mimetypes.suffix_map
Dictionary mapping suffixes to suffixes. This is used to allow recognition of encoded files for which the encoding and the type are indicated by the same extension. For example, the .tgz extension is mapped to .tar.gz to allow the encoding and type to be recognized separately. | python.library.mimetypes#mimetypes.suffix_map |
mimetypes.types_map
Dictionary mapping filename extensions to MIME types. | python.library.mimetypes#mimetypes.types_map |
min(iterable, *[, key, default])
min(arg1, arg2, *args[, key])
Return the smallest item in an iterable or the smallest of two or more arguments. If one positional argument is provided, it should be an iterable. The smallest item in the iterable is returned. If two or more positional arguments are provided, the smallest of the positional arguments is returned. There are two optional keyword-only arguments. The key argument specifies a one-argument ordering function like that used for list.sort(). The default argument specifies an object to return if the provided iterable is empty. If the iterable is empty and default is not provided, a ValueError is raised. If multiple items are minimal, the function returns the first one encountered. This is consistent with other sort-stability preserving tools such as sorted(iterable, key=keyfunc)[0] and heapq.nsmallest(1,
iterable, key=keyfunc). New in version 3.4: The default keyword-only argument. Changed in version 3.8: The key can be None. | python.library.functions#min |
mmap — Memory-mapped file support Memory-mapped file objects behave like both bytearray and like file objects. You can use mmap objects in most places where bytearray are expected; for example, you can use the re module to search through a memory-mapped file. You can also change a single byte by doing obj[index] = 97, or change a subsequence by assigning to a slice: obj[i1:i2] = b'...'. You can also read and write data starting at the current file position, and seek() through the file to different positions. A memory-mapped file is created by the mmap constructor, which is different on Unix and on Windows. In either case you must provide a file descriptor for a file opened for update. If you wish to map an existing Python file object, use its fileno() method to obtain the correct value for the fileno parameter. Otherwise, you can open the file using the os.open() function, which returns a file descriptor directly (the file still needs to be closed when done). Note If you want to create a memory-mapping for a writable, buffered file, you should flush() the file first. This is necessary to ensure that local modifications to the buffers are actually available to the mapping. For both the Unix and Windows versions of the constructor, access may be specified as an optional keyword parameter. access accepts one of four values: ACCESS_READ, ACCESS_WRITE, or ACCESS_COPY to specify read-only, write-through or copy-on-write memory respectively, or ACCESS_DEFAULT to defer to prot. access can be used on both Unix and Windows. If access is not specified, Windows mmap returns a write-through mapping. The initial memory values for all three access types are taken from the specified file. Assignment to an ACCESS_READ memory map raises a TypeError exception. Assignment to an ACCESS_WRITE memory map affects both memory and the underlying file. Assignment to an ACCESS_COPY memory map affects memory but does not update the underlying file. Changed in version 3.7: Added ACCESS_DEFAULT constant. To map anonymous memory, -1 should be passed as the fileno along with the length.
class mmap.mmap(fileno, length, tagname=None, access=ACCESS_DEFAULT[, offset])
(Windows version) Maps length bytes from the file specified by the file handle fileno, and creates a mmap object. If length is larger than the current size of the file, the file is extended to contain length bytes. If length is 0, the maximum length of the map is the current size of the file, except that if the file is empty Windows raises an exception (you cannot create an empty mapping on Windows). tagname, if specified and not None, is a string giving a tag name for the mapping. Windows allows you to have many different mappings against the same file. If you specify the name of an existing tag, that tag is opened, otherwise a new tag of this name is created. If this parameter is omitted or None, the mapping is created without a name. Avoiding the use of the tag parameter will assist in keeping your code portable between Unix and Windows. offset may be specified as a non-negative integer offset. mmap references will be relative to the offset from the beginning of the file. offset defaults to 0. offset must be a multiple of the ALLOCATIONGRANULARITY. Raises an auditing event mmap.__new__ with arguments fileno, length, access, offset.
class mmap.mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, access=ACCESS_DEFAULT[, offset])
(Unix version) Maps length bytes from the file specified by the file descriptor fileno, and returns a mmap object. If length is 0, the maximum length of the map will be the current size of the file when mmap is called. flags specifies the nature of the mapping. MAP_PRIVATE creates a private copy-on-write mapping, so changes to the contents of the mmap object will be private to this process, and MAP_SHARED creates a mapping that’s shared with all other processes mapping the same areas of the file. The default value is MAP_SHARED. prot, if specified, gives the desired memory protection; the two most useful values are PROT_READ and PROT_WRITE, to specify that the pages may be read or written. prot defaults to PROT_READ | PROT_WRITE. access may be specified in lieu of flags and prot as an optional keyword parameter. It is an error to specify both flags, prot and access. See the description of access above for information on how to use this parameter. offset may be specified as a non-negative integer offset. mmap references will be relative to the offset from the beginning of the file. offset defaults to 0. offset must be a multiple of ALLOCATIONGRANULARITY which is equal to PAGESIZE on Unix systems. To ensure validity of the created memory mapping the file specified by the descriptor fileno is internally automatically synchronized with physical backing store on Mac OS X and OpenVMS. This example shows a simple way of using mmap: import mmap
# write a simple example file
with open("hello.txt", "wb") as f:
f.write(b"Hello Python!\n")
with open("hello.txt", "r+b") as f:
# memory-map the file, size 0 means whole file
mm = mmap.mmap(f.fileno(), 0)
# read content via standard file methods
print(mm.readline()) # prints b"Hello Python!\n"
# read content via slice notation
print(mm[:5]) # prints b"Hello"
# update content using slice notation;
# note that new content must have same size
mm[6:] = b" world!\n"
# ... and read again using standard file methods
mm.seek(0)
print(mm.readline()) # prints b"Hello world!\n"
# close the map
mm.close()
mmap can also be used as a context manager in a with statement: import mmap
with mmap.mmap(-1, 13) as mm:
mm.write(b"Hello world!")
New in version 3.2: Context manager support. The next example demonstrates how to create an anonymous map and exchange data between the parent and child processes: import mmap
import os
mm = mmap.mmap(-1, 13)
mm.write(b"Hello world!")
pid = os.fork()
if pid == 0: # In a child process
mm.seek(0)
print(mm.readline())
mm.close()
Raises an auditing event mmap.__new__ with arguments fileno, length, access, offset. Memory-mapped file objects support the following methods:
close()
Closes the mmap. Subsequent calls to other methods of the object will result in a ValueError exception being raised. This will not close the open file.
closed
True if the file is closed. New in version 3.2.
find(sub[, start[, end]])
Returns the lowest index in the object where the subsequence sub is found, such that sub is contained in the range [start, end]. Optional arguments start and end are interpreted as in slice notation. Returns -1 on failure. Changed in version 3.5: Writable bytes-like object is now accepted.
flush([offset[, size]])
Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are written back before the object is destroyed. If offset and size are specified, only changes to the given range of bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. offset must be a multiple of the PAGESIZE or ALLOCATIONGRANULARITY. None is returned to indicate success. An exception is raised when the call failed. Changed in version 3.8: Previously, a nonzero value was returned on success; zero was returned on error under Windows. A zero value was returned on success; an exception was raised on error under Unix.
madvise(option[, start[, length]])
Send advice option to the kernel about the memory region beginning at start and extending length bytes. option must be one of the MADV_* constants available on the system. If start and length are omitted, the entire mapping is spanned. On some systems (including Linux), start must be a multiple of the PAGESIZE. Availability: Systems with the madvise() system call. New in version 3.8.
move(dest, src, count)
Copy the count bytes starting at offset src to the destination index dest. If the mmap was created with ACCESS_READ, then calls to move will raise a TypeError exception.
read([n])
Return a bytes containing up to n bytes starting from the current file position. If the argument is omitted, None or negative, return all bytes from the current file position to the end of the mapping. The file position is updated to point after the bytes that were returned. Changed in version 3.3: Argument can be omitted or None.
read_byte()
Returns a byte at the current file position as an integer, and advances the file position by 1.
readline()
Returns a single line, starting at the current file position and up to the next newline. The file position is updated to point after the bytes that were returned.
resize(newsize)
Resizes the map and the underlying file, if any. If the mmap was created with ACCESS_READ or ACCESS_COPY, resizing the map will raise a TypeError exception.
rfind(sub[, start[, end]])
Returns the highest index in the object where the subsequence sub is found, such that sub is contained in the range [start, end]. Optional arguments start and end are interpreted as in slice notation. Returns -1 on failure. Changed in version 3.5: Writable bytes-like object is now accepted.
seek(pos[, whence])
Set the file’s current position. whence argument is optional and defaults to os.SEEK_SET or 0 (absolute file positioning); other values are os.SEEK_CUR or 1 (seek relative to the current position) and os.SEEK_END or 2 (seek relative to the file’s end).
size()
Return the length of the file, which can be larger than the size of the memory-mapped area.
tell()
Returns the current position of the file pointer.
write(bytes)
Write the bytes in bytes into memory at the current position of the file pointer and return the number of bytes written (never less than len(bytes), since if the write fails, a ValueError will be raised). The file position is updated to point after the bytes that were written. If the mmap was created with ACCESS_READ, then writing to it will raise a TypeError exception. Changed in version 3.5: Writable bytes-like object is now accepted. Changed in version 3.6: The number of bytes written is now returned.
write_byte(byte)
Write the integer byte into memory at the current position of the file pointer; the file position is advanced by 1. If the mmap was created with ACCESS_READ, then writing to it will raise a TypeError exception.
MADV_* Constants
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_AUTOSYNC |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_CORE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_DODUMP |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_DOFORK |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_DONTDUMP |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_DONTFORK |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_DONTNEED |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_FREE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_HUGEPAGE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_HWPOISON |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_MERGEABLE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_NOCORE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_NOHUGEPAGE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_NORMAL |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_NOSYNC |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_PROTECT |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_RANDOM |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_REMOVE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_SEQUENTIAL |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_SOFT_OFFLINE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_UNMERGEABLE |
mmap.MADV_NORMAL
mmap.MADV_RANDOM
mmap.MADV_SEQUENTIAL
mmap.MADV_WILLNEED
mmap.MADV_DONTNEED
mmap.MADV_REMOVE
mmap.MADV_DONTFORK
mmap.MADV_DOFORK
mmap.MADV_HWPOISON
mmap.MADV_MERGEABLE
mmap.MADV_UNMERGEABLE
mmap.MADV_SOFT_OFFLINE
mmap.MADV_HUGEPAGE
mmap.MADV_NOHUGEPAGE
mmap.MADV_DONTDUMP
mmap.MADV_DODUMP
mmap.MADV_FREE
mmap.MADV_NOSYNC
mmap.MADV_AUTOSYNC
mmap.MADV_NOCORE
mmap.MADV_CORE
mmap.MADV_PROTECT
These options can be passed to mmap.madvise(). Not every option will be present on every system. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.MADV_WILLNEED |
class mmap.mmap(fileno, length, tagname=None, access=ACCESS_DEFAULT[, offset])
(Windows version) Maps length bytes from the file specified by the file handle fileno, and creates a mmap object. If length is larger than the current size of the file, the file is extended to contain length bytes. If length is 0, the maximum length of the map is the current size of the file, except that if the file is empty Windows raises an exception (you cannot create an empty mapping on Windows). tagname, if specified and not None, is a string giving a tag name for the mapping. Windows allows you to have many different mappings against the same file. If you specify the name of an existing tag, that tag is opened, otherwise a new tag of this name is created. If this parameter is omitted or None, the mapping is created without a name. Avoiding the use of the tag parameter will assist in keeping your code portable between Unix and Windows. offset may be specified as a non-negative integer offset. mmap references will be relative to the offset from the beginning of the file. offset defaults to 0. offset must be a multiple of the ALLOCATIONGRANULARITY. Raises an auditing event mmap.__new__ with arguments fileno, length, access, offset. | python.library.mmap#mmap.mmap |
close()
Closes the mmap. Subsequent calls to other methods of the object will result in a ValueError exception being raised. This will not close the open file. | python.library.mmap#mmap.mmap.close |
closed
True if the file is closed. New in version 3.2. | python.library.mmap#mmap.mmap.closed |
find(sub[, start[, end]])
Returns the lowest index in the object where the subsequence sub is found, such that sub is contained in the range [start, end]. Optional arguments start and end are interpreted as in slice notation. Returns -1 on failure. Changed in version 3.5: Writable bytes-like object is now accepted. | python.library.mmap#mmap.mmap.find |
flush([offset[, size]])
Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are written back before the object is destroyed. If offset and size are specified, only changes to the given range of bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. offset must be a multiple of the PAGESIZE or ALLOCATIONGRANULARITY. None is returned to indicate success. An exception is raised when the call failed. Changed in version 3.8: Previously, a nonzero value was returned on success; zero was returned on error under Windows. A zero value was returned on success; an exception was raised on error under Unix. | python.library.mmap#mmap.mmap.flush |
madvise(option[, start[, length]])
Send advice option to the kernel about the memory region beginning at start and extending length bytes. option must be one of the MADV_* constants available on the system. If start and length are omitted, the entire mapping is spanned. On some systems (including Linux), start must be a multiple of the PAGESIZE. Availability: Systems with the madvise() system call. New in version 3.8. | python.library.mmap#mmap.mmap.madvise |
move(dest, src, count)
Copy the count bytes starting at offset src to the destination index dest. If the mmap was created with ACCESS_READ, then calls to move will raise a TypeError exception. | python.library.mmap#mmap.mmap.move |
read([n])
Return a bytes containing up to n bytes starting from the current file position. If the argument is omitted, None or negative, return all bytes from the current file position to the end of the mapping. The file position is updated to point after the bytes that were returned. Changed in version 3.3: Argument can be omitted or None. | python.library.mmap#mmap.mmap.read |
readline()
Returns a single line, starting at the current file position and up to the next newline. The file position is updated to point after the bytes that were returned. | python.library.mmap#mmap.mmap.readline |
read_byte()
Returns a byte at the current file position as an integer, and advances the file position by 1. | python.library.mmap#mmap.mmap.read_byte |
resize(newsize)
Resizes the map and the underlying file, if any. If the mmap was created with ACCESS_READ or ACCESS_COPY, resizing the map will raise a TypeError exception. | python.library.mmap#mmap.mmap.resize |
rfind(sub[, start[, end]])
Returns the highest index in the object where the subsequence sub is found, such that sub is contained in the range [start, end]. Optional arguments start and end are interpreted as in slice notation. Returns -1 on failure. Changed in version 3.5: Writable bytes-like object is now accepted. | python.library.mmap#mmap.mmap.rfind |
seek(pos[, whence])
Set the file’s current position. whence argument is optional and defaults to os.SEEK_SET or 0 (absolute file positioning); other values are os.SEEK_CUR or 1 (seek relative to the current position) and os.SEEK_END or 2 (seek relative to the file’s end). | python.library.mmap#mmap.mmap.seek |
size()
Return the length of the file, which can be larger than the size of the memory-mapped area. | python.library.mmap#mmap.mmap.size |
tell()
Returns the current position of the file pointer. | python.library.mmap#mmap.mmap.tell |
write(bytes)
Write the bytes in bytes into memory at the current position of the file pointer and return the number of bytes written (never less than len(bytes), since if the write fails, a ValueError will be raised). The file position is updated to point after the bytes that were written. If the mmap was created with ACCESS_READ, then writing to it will raise a TypeError exception. Changed in version 3.5: Writable bytes-like object is now accepted. Changed in version 3.6: The number of bytes written is now returned. | python.library.mmap#mmap.mmap.write |
write_byte(byte)
Write the integer byte into memory at the current position of the file pointer; the file position is advanced by 1. If the mmap was created with ACCESS_READ, then writing to it will raise a TypeError exception. | python.library.mmap#mmap.mmap.write_byte |
modulefinder — Find modules used by a script Source code: Lib/modulefinder.py This module provides a ModuleFinder class that can be used to determine the set of modules imported by a script. modulefinder.py can also be run as a script, giving the filename of a Python script as its argument, after which a report of the imported modules will be printed.
modulefinder.AddPackagePath(pkg_name, path)
Record that the package named pkg_name can be found in the specified path.
modulefinder.ReplacePackage(oldname, newname)
Allows specifying that the module named oldname is in fact the package named newname.
class modulefinder.ModuleFinder(path=None, debug=0, excludes=[], replace_paths=[])
This class provides run_script() and report() methods to determine the set of modules imported by a script. path can be a list of directories to search for modules; if not specified, sys.path is used. debug sets the debugging level; higher values make the class print debugging messages about what it’s doing. excludes is a list of module names to exclude from the analysis. replace_paths is a list of (oldpath, newpath) tuples that will be replaced in module paths.
report()
Print a report to standard output that lists the modules imported by the script and their paths, as well as modules that are missing or seem to be missing.
run_script(pathname)
Analyze the contents of the pathname file, which must contain Python code.
modules
A dictionary mapping module names to modules. See Example usage of ModuleFinder.
Example usage of ModuleFinder The script that is going to get analyzed later on (bacon.py): import re, itertools
try:
import baconhameggs
except ImportError:
pass
try:
import guido.python.ham
except ImportError:
pass
The script that will output the report of bacon.py: from modulefinder import ModuleFinder
finder = ModuleFinder()
finder.run_script('bacon.py')
print('Loaded modules:')
for name, mod in finder.modules.items():
print('%s: ' % name, end='')
print(','.join(list(mod.globalnames.keys())[:3]))
print('-'*50)
print('Modules not imported:')
print('\n'.join(finder.badmodules.keys()))
Sample output (may vary depending on the architecture): Loaded modules:
_types:
copyreg: _inverted_registry,_slotnames,__all__
sre_compile: isstring,_sre,_optimize_unicode
_sre:
sre_constants: REPEAT_ONE,makedict,AT_END_LINE
sys:
re: __module__,finditer,_expand
itertools:
__main__: re,itertools,baconhameggs
sre_parse: _PATTERNENDERS,SRE_FLAG_UNICODE
array:
types: __module__,IntType,TypeType
---------------------------------------------------
Modules not imported:
guido.python.ham
baconhameggs | python.library.modulefinder |
modulefinder.AddPackagePath(pkg_name, path)
Record that the package named pkg_name can be found in the specified path. | python.library.modulefinder#modulefinder.AddPackagePath |
class modulefinder.ModuleFinder(path=None, debug=0, excludes=[], replace_paths=[])
This class provides run_script() and report() methods to determine the set of modules imported by a script. path can be a list of directories to search for modules; if not specified, sys.path is used. debug sets the debugging level; higher values make the class print debugging messages about what it’s doing. excludes is a list of module names to exclude from the analysis. replace_paths is a list of (oldpath, newpath) tuples that will be replaced in module paths.
report()
Print a report to standard output that lists the modules imported by the script and their paths, as well as modules that are missing or seem to be missing.
run_script(pathname)
Analyze the contents of the pathname file, which must contain Python code.
modules
A dictionary mapping module names to modules. See Example usage of ModuleFinder. | python.library.modulefinder#modulefinder.ModuleFinder |
modules
A dictionary mapping module names to modules. See Example usage of ModuleFinder. | python.library.modulefinder#modulefinder.ModuleFinder.modules |
report()
Print a report to standard output that lists the modules imported by the script and their paths, as well as modules that are missing or seem to be missing. | python.library.modulefinder#modulefinder.ModuleFinder.report |
run_script(pathname)
Analyze the contents of the pathname file, which must contain Python code. | python.library.modulefinder#modulefinder.ModuleFinder.run_script |
modulefinder.ReplacePackage(oldname, newname)
Allows specifying that the module named oldname is in fact the package named newname. | python.library.modulefinder#modulefinder.ReplacePackage |
exception ModuleNotFoundError
A subclass of ImportError which is raised by import when a module could not be located. It is also raised when None is found in sys.modules. New in version 3.6. | python.library.exceptions#ModuleNotFoundError |
msilib — Read and write Microsoft Installer files Source code: Lib/msilib/__init__.py The msilib supports the creation of Microsoft Installer (.msi) files. Because these files often contain an embedded “cabinet” file (.cab), it also exposes an API to create CAB files. Support for reading .cab files is currently not implemented; read support for the .msi database is possible. This package aims to provide complete access to all tables in an .msi file, therefore, it is a fairly low-level API. Two primary applications of this package are the distutils command bdist_msi, and the creation of Python installer package itself (although that currently uses a different version of msilib). The package contents can be roughly split into four parts: low-level CAB routines, low-level MSI routines, higher-level MSI routines, and standard table structures.
msilib.FCICreate(cabname, files)
Create a new CAB file named cabname. files must be a list of tuples, each containing the name of the file on disk, and the name of the file inside the CAB file. The files are added to the CAB file in the order they appear in the list. All files are added into a single CAB file, using the MSZIP compression algorithm. Callbacks to Python for the various steps of MSI creation are currently not exposed.
msilib.UuidCreate()
Return the string representation of a new unique identifier. This wraps the Windows API functions UuidCreate() and UuidToString().
msilib.OpenDatabase(path, persist)
Return a new database object by calling MsiOpenDatabase. path is the file name of the MSI file; persist can be one of the constants MSIDBOPEN_CREATEDIRECT, MSIDBOPEN_CREATE, MSIDBOPEN_DIRECT, MSIDBOPEN_READONLY, or MSIDBOPEN_TRANSACT, and may include the flag MSIDBOPEN_PATCHFILE. See the Microsoft documentation for the meaning of these flags; depending on the flags, an existing database is opened, or a new one created.
msilib.CreateRecord(count)
Return a new record object by calling MSICreateRecord(). count is the number of fields of the record.
msilib.init_database(name, schema, ProductName, ProductCode, ProductVersion, Manufacturer)
Create and return a new database name, initialize it with schema, and set the properties ProductName, ProductCode, ProductVersion, and Manufacturer. schema must be a module object containing tables and _Validation_records attributes; typically, msilib.schema should be used. The database will contain just the schema and the validation records when this function returns.
msilib.add_data(database, table, records)
Add all records to the table named table in database. The table argument must be one of the predefined tables in the MSI schema, e.g. 'Feature', 'File', 'Component', 'Dialog', 'Control', etc. records should be a list of tuples, each one containing all fields of a record according to the schema of the table. For optional fields, None can be passed. Field values can be ints, strings, or instances of the Binary class.
class msilib.Binary(filename)
Represents entries in the Binary table; inserting such an object using add_data() reads the file named filename into the table.
msilib.add_tables(database, module)
Add all table content from module to database. module must contain an attribute tables listing all tables for which content should be added, and one attribute per table that has the actual content. This is typically used to install the sequence tables.
msilib.add_stream(database, name, path)
Add the file path into the _Stream table of database, with the stream name name.
msilib.gen_uuid()
Return a new UUID, in the format that MSI typically requires (i.e. in curly braces, and with all hexdigits in upper-case).
See also FCICreate UuidCreate UuidToString Database Objects
Database.OpenView(sql)
Return a view object, by calling MSIDatabaseOpenView(). sql is the SQL statement to execute.
Database.Commit()
Commit the changes pending in the current transaction, by calling MSIDatabaseCommit().
Database.GetSummaryInformation(count)
Return a new summary information object, by calling MsiGetSummaryInformation(). count is the maximum number of updated values.
Database.Close()
Close the database object, through MsiCloseHandle(). New in version 3.7.
See also MSIDatabaseOpenView MSIDatabaseCommit MSIGetSummaryInformation MsiCloseHandle View Objects
View.Execute(params)
Execute the SQL query of the view, through MSIViewExecute(). If params is not None, it is a record describing actual values of the parameter tokens in the query.
View.GetColumnInfo(kind)
Return a record describing the columns of the view, through calling MsiViewGetColumnInfo(). kind can be either MSICOLINFO_NAMES or MSICOLINFO_TYPES.
View.Fetch()
Return a result record of the query, through calling MsiViewFetch().
View.Modify(kind, data)
Modify the view, by calling MsiViewModify(). kind can be one of MSIMODIFY_SEEK, MSIMODIFY_REFRESH, MSIMODIFY_INSERT, MSIMODIFY_UPDATE, MSIMODIFY_ASSIGN, MSIMODIFY_REPLACE, MSIMODIFY_MERGE, MSIMODIFY_DELETE, MSIMODIFY_INSERT_TEMPORARY, MSIMODIFY_VALIDATE, MSIMODIFY_VALIDATE_NEW, MSIMODIFY_VALIDATE_FIELD, or MSIMODIFY_VALIDATE_DELETE. data must be a record describing the new data.
View.Close()
Close the view, through MsiViewClose().
See also MsiViewExecute MSIViewGetColumnInfo MsiViewFetch MsiViewModify MsiViewClose Summary Information Objects
SummaryInformation.GetProperty(field)
Return a property of the summary, through MsiSummaryInfoGetProperty(). field is the name of the property, and can be one of the constants PID_CODEPAGE, PID_TITLE, PID_SUBJECT, PID_AUTHOR, PID_KEYWORDS, PID_COMMENTS, PID_TEMPLATE, PID_LASTAUTHOR, PID_REVNUMBER, PID_LASTPRINTED, PID_CREATE_DTM, PID_LASTSAVE_DTM, PID_PAGECOUNT, PID_WORDCOUNT, PID_CHARCOUNT, PID_APPNAME, or PID_SECURITY.
SummaryInformation.GetPropertyCount()
Return the number of summary properties, through MsiSummaryInfoGetPropertyCount().
SummaryInformation.SetProperty(field, value)
Set a property through MsiSummaryInfoSetProperty(). field can have the same values as in GetProperty(), value is the new value of the property. Possible value types are integer and string.
SummaryInformation.Persist()
Write the modified properties to the summary information stream, using MsiSummaryInfoPersist().
See also MsiSummaryInfoGetProperty MsiSummaryInfoGetPropertyCount MsiSummaryInfoSetProperty MsiSummaryInfoPersist Record Objects
Record.GetFieldCount()
Return the number of fields of the record, through MsiRecordGetFieldCount().
Record.GetInteger(field)
Return the value of field as an integer where possible. field must be an integer.
Record.GetString(field)
Return the value of field as a string where possible. field must be an integer.
Record.SetString(field, value)
Set field to value through MsiRecordSetString(). field must be an integer; value a string.
Record.SetStream(field, value)
Set field to the contents of the file named value, through MsiRecordSetStream(). field must be an integer; value a string.
Record.SetInteger(field, value)
Set field to value through MsiRecordSetInteger(). Both field and value must be an integer.
Record.ClearData()
Set all fields of the record to 0, through MsiRecordClearData().
See also MsiRecordGetFieldCount MsiRecordSetString MsiRecordSetStream MsiRecordSetInteger MsiRecordClearData Errors All wrappers around MSI functions raise MSIError; the string inside the exception will contain more detail. CAB Objects
class msilib.CAB(name)
The class CAB represents a CAB file. During MSI construction, files will be added simultaneously to the Files table, and to a CAB file. Then, when all files have been added, the CAB file can be written, then added to the MSI file. name is the name of the CAB file in the MSI file.
append(full, file, logical)
Add the file with the pathname full to the CAB file, under the name logical. If there is already a file named logical, a new file name is created. Return the index of the file in the CAB file, and the new name of the file inside the CAB file.
commit(database)
Generate a CAB file, add it as a stream to the MSI file, put it into the Media table, and remove the generated file from the disk.
Directory Objects
class msilib.Directory(database, cab, basedir, physical, logical, default[, componentflags])
Create a new directory in the Directory table. There is a current component at each point in time for the directory, which is either explicitly created through start_component(), or implicitly when files are added for the first time. Files are added into the current component, and into the cab file. To create a directory, a base directory object needs to be specified (can be None), the path to the physical directory, and a logical directory name. default specifies the DefaultDir slot in the directory table. componentflags specifies the default flags that new components get.
start_component(component=None, feature=None, flags=None, keyfile=None, uuid=None)
Add an entry to the Component table, and make this component the current component for this directory. If no component name is given, the directory name is used. If no feature is given, the current feature is used. If no flags are given, the directory’s default flags are used. If no keyfile is given, the KeyPath is left null in the Component table.
add_file(file, src=None, version=None, language=None)
Add a file to the current component of the directory, starting a new one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the current directory. Optionally, a version and a language can be specified for the entry in the File table.
glob(pattern, exclude=None)
Add a list of files to the current component as specified in the glob pattern. Individual files can be excluded in the exclude list.
remove_pyc()
Remove .pyc files on uninstall.
See also Directory Table File Table Component Table FeatureComponents Table Features
class msilib.Feature(db, id, title, desc, display, level=1, parent=None, directory=None, attributes=0)
Add a new record to the Feature table, using the values id, parent.id, title, desc, display, level, directory, and attributes. The resulting feature object can be passed to the start_component() method of Directory.
set_current()
Make this feature the current feature of msilib. New components are automatically added to the default feature, unless a feature is explicitly specified.
See also Feature Table GUI classes msilib provides several classes that wrap the GUI tables in an MSI database. However, no standard user interface is provided; use bdist_msi to create MSI files with a user-interface for installing Python packages.
class msilib.Control(dlg, name)
Base class of the dialog controls. dlg is the dialog object the control belongs to, and name is the control’s name.
event(event, argument, condition=1, ordering=None)
Make an entry into the ControlEvent table for this control.
mapping(event, attribute)
Make an entry into the EventMapping table for this control.
condition(action, condition)
Make an entry into the ControlCondition table for this control.
class msilib.RadioButtonGroup(dlg, name, property)
Create a radio button control named name. property is the installer property that gets set when a radio button is selected.
add(name, x, y, width, height, text, value=None)
Add a radio button named name to the group, at the coordinates x, y, width, height, and with the label text. If value is None, it defaults to name.
class msilib.Dialog(db, name, x, y, w, h, attr, title, first, default, cancel)
Return a new Dialog object. An entry in the Dialog table is made, with the specified coordinates, dialog attributes, title, name of the first, default, and cancel controls.
control(name, type, x, y, width, height, attributes, property, text, control_next, help)
Return a new Control object. An entry in the Control table is made with the specified parameters. This is a generic method; for specific types, specialized methods are provided.
text(name, x, y, width, height, attributes, text)
Add and return a Text control.
bitmap(name, x, y, width, height, text)
Add and return a Bitmap control.
line(name, x, y, width, height)
Add and return a Line control.
pushbutton(name, x, y, width, height, attributes, text, next_control)
Add and return a PushButton control.
radiogroup(name, x, y, width, height, attributes, property, text, next_control)
Add and return a RadioButtonGroup control.
checkbox(name, x, y, width, height, attributes, property, text, next_control)
Add and return a CheckBox control.
See also Dialog Table Control Table Control Types ControlCondition Table ControlEvent Table EventMapping Table RadioButton Table Precomputed tables msilib provides a few subpackages that contain only schema and table definitions. Currently, these definitions are based on MSI version 2.0.
msilib.schema
This is the standard MSI schema for MSI 2.0, with the tables variable providing a list of table definitions, and _Validation_records providing the data for MSI validation.
msilib.sequence
This module contains table contents for the standard sequence tables: AdminExecuteSequence, AdminUISequence, AdvtExecuteSequence, InstallExecuteSequence, and InstallUISequence.
msilib.text
This module contains definitions for the UIText and ActionText tables, for the standard installer actions. | python.library.msilib |
msilib.add_data(database, table, records)
Add all records to the table named table in database. The table argument must be one of the predefined tables in the MSI schema, e.g. 'Feature', 'File', 'Component', 'Dialog', 'Control', etc. records should be a list of tuples, each one containing all fields of a record according to the schema of the table. For optional fields, None can be passed. Field values can be ints, strings, or instances of the Binary class. | python.library.msilib#msilib.add_data |
msilib.add_stream(database, name, path)
Add the file path into the _Stream table of database, with the stream name name. | python.library.msilib#msilib.add_stream |
msilib.add_tables(database, module)
Add all table content from module to database. module must contain an attribute tables listing all tables for which content should be added, and one attribute per table that has the actual content. This is typically used to install the sequence tables. | python.library.msilib#msilib.add_tables |
class msilib.Binary(filename)
Represents entries in the Binary table; inserting such an object using add_data() reads the file named filename into the table. | python.library.msilib#msilib.Binary |
class msilib.CAB(name)
The class CAB represents a CAB file. During MSI construction, files will be added simultaneously to the Files table, and to a CAB file. Then, when all files have been added, the CAB file can be written, then added to the MSI file. name is the name of the CAB file in the MSI file.
append(full, file, logical)
Add the file with the pathname full to the CAB file, under the name logical. If there is already a file named logical, a new file name is created. Return the index of the file in the CAB file, and the new name of the file inside the CAB file.
commit(database)
Generate a CAB file, add it as a stream to the MSI file, put it into the Media table, and remove the generated file from the disk. | python.library.msilib#msilib.CAB |
append(full, file, logical)
Add the file with the pathname full to the CAB file, under the name logical. If there is already a file named logical, a new file name is created. Return the index of the file in the CAB file, and the new name of the file inside the CAB file. | python.library.msilib#msilib.CAB.append |
commit(database)
Generate a CAB file, add it as a stream to the MSI file, put it into the Media table, and remove the generated file from the disk. | python.library.msilib#msilib.CAB.commit |
class msilib.Control(dlg, name)
Base class of the dialog controls. dlg is the dialog object the control belongs to, and name is the control’s name.
event(event, argument, condition=1, ordering=None)
Make an entry into the ControlEvent table for this control.
mapping(event, attribute)
Make an entry into the EventMapping table for this control.
condition(action, condition)
Make an entry into the ControlCondition table for this control. | python.library.msilib#msilib.Control |
condition(action, condition)
Make an entry into the ControlCondition table for this control. | python.library.msilib#msilib.Control.condition |
event(event, argument, condition=1, ordering=None)
Make an entry into the ControlEvent table for this control. | python.library.msilib#msilib.Control.event |
mapping(event, attribute)
Make an entry into the EventMapping table for this control. | python.library.msilib#msilib.Control.mapping |
msilib.CreateRecord(count)
Return a new record object by calling MSICreateRecord(). count is the number of fields of the record. | python.library.msilib#msilib.CreateRecord |
Database.Close()
Close the database object, through MsiCloseHandle(). New in version 3.7. | python.library.msilib#msilib.Database.Close |
Database.Commit()
Commit the changes pending in the current transaction, by calling MSIDatabaseCommit(). | python.library.msilib#msilib.Database.Commit |
Database.GetSummaryInformation(count)
Return a new summary information object, by calling MsiGetSummaryInformation(). count is the maximum number of updated values. | python.library.msilib#msilib.Database.GetSummaryInformation |
Database.OpenView(sql)
Return a view object, by calling MSIDatabaseOpenView(). sql is the SQL statement to execute. | python.library.msilib#msilib.Database.OpenView |
class msilib.Dialog(db, name, x, y, w, h, attr, title, first, default, cancel)
Return a new Dialog object. An entry in the Dialog table is made, with the specified coordinates, dialog attributes, title, name of the first, default, and cancel controls.
control(name, type, x, y, width, height, attributes, property, text, control_next, help)
Return a new Control object. An entry in the Control table is made with the specified parameters. This is a generic method; for specific types, specialized methods are provided.
text(name, x, y, width, height, attributes, text)
Add and return a Text control.
bitmap(name, x, y, width, height, text)
Add and return a Bitmap control.
line(name, x, y, width, height)
Add and return a Line control.
pushbutton(name, x, y, width, height, attributes, text, next_control)
Add and return a PushButton control.
radiogroup(name, x, y, width, height, attributes, property, text, next_control)
Add and return a RadioButtonGroup control.
checkbox(name, x, y, width, height, attributes, property, text, next_control)
Add and return a CheckBox control. | python.library.msilib#msilib.Dialog |
bitmap(name, x, y, width, height, text)
Add and return a Bitmap control. | python.library.msilib#msilib.Dialog.bitmap |
checkbox(name, x, y, width, height, attributes, property, text, next_control)
Add and return a CheckBox control. | python.library.msilib#msilib.Dialog.checkbox |
control(name, type, x, y, width, height, attributes, property, text, control_next, help)
Return a new Control object. An entry in the Control table is made with the specified parameters. This is a generic method; for specific types, specialized methods are provided. | python.library.msilib#msilib.Dialog.control |
line(name, x, y, width, height)
Add and return a Line control. | python.library.msilib#msilib.Dialog.line |
pushbutton(name, x, y, width, height, attributes, text, next_control)
Add and return a PushButton control. | python.library.msilib#msilib.Dialog.pushbutton |
radiogroup(name, x, y, width, height, attributes, property, text, next_control)
Add and return a RadioButtonGroup control. | python.library.msilib#msilib.Dialog.radiogroup |
text(name, x, y, width, height, attributes, text)
Add and return a Text control. | python.library.msilib#msilib.Dialog.text |
class msilib.Directory(database, cab, basedir, physical, logical, default[, componentflags])
Create a new directory in the Directory table. There is a current component at each point in time for the directory, which is either explicitly created through start_component(), or implicitly when files are added for the first time. Files are added into the current component, and into the cab file. To create a directory, a base directory object needs to be specified (can be None), the path to the physical directory, and a logical directory name. default specifies the DefaultDir slot in the directory table. componentflags specifies the default flags that new components get.
start_component(component=None, feature=None, flags=None, keyfile=None, uuid=None)
Add an entry to the Component table, and make this component the current component for this directory. If no component name is given, the directory name is used. If no feature is given, the current feature is used. If no flags are given, the directory’s default flags are used. If no keyfile is given, the KeyPath is left null in the Component table.
add_file(file, src=None, version=None, language=None)
Add a file to the current component of the directory, starting a new one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the current directory. Optionally, a version and a language can be specified for the entry in the File table.
glob(pattern, exclude=None)
Add a list of files to the current component as specified in the glob pattern. Individual files can be excluded in the exclude list.
remove_pyc()
Remove .pyc files on uninstall. | python.library.msilib#msilib.Directory |
add_file(file, src=None, version=None, language=None)
Add a file to the current component of the directory, starting a new one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the current directory. Optionally, a version and a language can be specified for the entry in the File table. | python.library.msilib#msilib.Directory.add_file |
glob(pattern, exclude=None)
Add a list of files to the current component as specified in the glob pattern. Individual files can be excluded in the exclude list. | python.library.msilib#msilib.Directory.glob |
remove_pyc()
Remove .pyc files on uninstall. | python.library.msilib#msilib.Directory.remove_pyc |
start_component(component=None, feature=None, flags=None, keyfile=None, uuid=None)
Add an entry to the Component table, and make this component the current component for this directory. If no component name is given, the directory name is used. If no feature is given, the current feature is used. If no flags are given, the directory’s default flags are used. If no keyfile is given, the KeyPath is left null in the Component table. | python.library.msilib#msilib.Directory.start_component |
msilib.FCICreate(cabname, files)
Create a new CAB file named cabname. files must be a list of tuples, each containing the name of the file on disk, and the name of the file inside the CAB file. The files are added to the CAB file in the order they appear in the list. All files are added into a single CAB file, using the MSZIP compression algorithm. Callbacks to Python for the various steps of MSI creation are currently not exposed. | python.library.msilib#msilib.FCICreate |
class msilib.Feature(db, id, title, desc, display, level=1, parent=None, directory=None, attributes=0)
Add a new record to the Feature table, using the values id, parent.id, title, desc, display, level, directory, and attributes. The resulting feature object can be passed to the start_component() method of Directory.
set_current()
Make this feature the current feature of msilib. New components are automatically added to the default feature, unless a feature is explicitly specified. | python.library.msilib#msilib.Feature |
set_current()
Make this feature the current feature of msilib. New components are automatically added to the default feature, unless a feature is explicitly specified. | python.library.msilib#msilib.Feature.set_current |
msilib.gen_uuid()
Return a new UUID, in the format that MSI typically requires (i.e. in curly braces, and with all hexdigits in upper-case). | python.library.msilib#msilib.gen_uuid |
msilib.init_database(name, schema, ProductName, ProductCode, ProductVersion, Manufacturer)
Create and return a new database name, initialize it with schema, and set the properties ProductName, ProductCode, ProductVersion, and Manufacturer. schema must be a module object containing tables and _Validation_records attributes; typically, msilib.schema should be used. The database will contain just the schema and the validation records when this function returns. | python.library.msilib#msilib.init_database |
msilib.OpenDatabase(path, persist)
Return a new database object by calling MsiOpenDatabase. path is the file name of the MSI file; persist can be one of the constants MSIDBOPEN_CREATEDIRECT, MSIDBOPEN_CREATE, MSIDBOPEN_DIRECT, MSIDBOPEN_READONLY, or MSIDBOPEN_TRANSACT, and may include the flag MSIDBOPEN_PATCHFILE. See the Microsoft documentation for the meaning of these flags; depending on the flags, an existing database is opened, or a new one created. | python.library.msilib#msilib.OpenDatabase |
class msilib.RadioButtonGroup(dlg, name, property)
Create a radio button control named name. property is the installer property that gets set when a radio button is selected.
add(name, x, y, width, height, text, value=None)
Add a radio button named name to the group, at the coordinates x, y, width, height, and with the label text. If value is None, it defaults to name. | python.library.msilib#msilib.RadioButtonGroup |
add(name, x, y, width, height, text, value=None)
Add a radio button named name to the group, at the coordinates x, y, width, height, and with the label text. If value is None, it defaults to name. | python.library.msilib#msilib.RadioButtonGroup.add |
Record.ClearData()
Set all fields of the record to 0, through MsiRecordClearData(). | python.library.msilib#msilib.Record.ClearData |
Record.GetFieldCount()
Return the number of fields of the record, through MsiRecordGetFieldCount(). | python.library.msilib#msilib.Record.GetFieldCount |
Record.GetInteger(field)
Return the value of field as an integer where possible. field must be an integer. | python.library.msilib#msilib.Record.GetInteger |
Record.GetString(field)
Return the value of field as a string where possible. field must be an integer. | python.library.msilib#msilib.Record.GetString |
Record.SetInteger(field, value)
Set field to value through MsiRecordSetInteger(). Both field and value must be an integer. | python.library.msilib#msilib.Record.SetInteger |
Record.SetStream(field, value)
Set field to the contents of the file named value, through MsiRecordSetStream(). field must be an integer; value a string. | python.library.msilib#msilib.Record.SetStream |
Record.SetString(field, value)
Set field to value through MsiRecordSetString(). field must be an integer; value a string. | python.library.msilib#msilib.Record.SetString |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.