Python: module rox.mime

rox.mime | index

`This module provides access to the shared MIME database.
types is a dictionary of all known MIME types, indexed by the type name, e.g.
types['application/x-python']
Applications can install information about MIME types by storing an
XML file as <MIME>/packages/<application>.xml and running the
update-mime-database command, which is provided by the freedesktop.org
shared mime database package.
See http://www.freedesktop.org/standards/shared-mime-info-spec/ for
information about the format of these files.`

Classes
`` |  | MIMEtype MagicDB MagicRule MagicType
class MIMEtype
`` | `Type holding data about a MIME type`
| Methods defined here: __init__(self, media, subtype) `Don't use this constructor directly; use mime.lookup() instead.` get_comment(self) `Returns comment for current language, loading it if needed.` get_icon(self, size=None) `Return a GdkPixbuf with the icon for this type. If size is None then the image is returned at its natural size, otherwise the image is scaled to that width with the height at the correct aspect ratio. The constants ICON_SIZE_{HUGE,LARGE,SMALL} match the sizes used by the filer.`
class MagicDB
`` |
| Methods defined here: __init__(self) match(self, path, max_pri=100, min_pri=0) mergeFile(self, fname)
class MagicRule
`` |
| Methods defined here: __init__(self, f) appendRule(self, rule) getLength(self) match(self, buffer) match0(self, buffer)
class MagicType
`` |
| Methods defined here: __init__(self, mtype) getLine(self, f) match(self, buffer)

Functions
`` |  | get_type(path, follow=1, name_pri=100) `Returns type of file indicated by path. path - pathname to check (need not exist) follow - when reading file, follow symbolic links name_pri - Priority to do name matches. 100=override magic` get_type_by_contents(path, max_pri=100, min_pri=0) `Returns type of file by its contents, or None if not known` get_type_by_name(path) `Returns type of file by its name, or None if not known` get_type_handler(mime_type, handler_type='MIME-types') `Lookup the ROX-defined run action for a given mime type. mime_type is an object returned by lookup(). handler_type is a config directory leaf (e.g.'MIME-types').` image_for_type(type, size=48, flags=0) `Search XDG_CONFIG or icon theme for a suitable icon. Returns a pixbuf, or None.` install_mime_info(application, package_file=None) `Copy 'package_file' as ~/.local/share/mime/packages/<application>.xml. If package_file is None, install <app_dir>/<application>.xml. If already installed, does nothing. May overwrite an existing file with the same name (if the contents are different)` lookup(media, subtype=None) `Get the MIMEtype object for this type, creating a new one if needed.`