Package Gnumed :: Package pycommon :: Module gmMimeLib
[frames] | no frames]

Module gmMimeLib

source code

This module encapsulates mime operations.

http://www.dwheeler.com/essays/open-files-urls.html


Author: Karsten Hilbert <Karsten.Hilbert@gmx.net>

License: GPL

Functions
 
guess_mimetype(filename=None)
Guess mime type of arbitrary file.
source code
 
get_viewer_cmd(aMimeType=None, aFileName=None, aToken=None)
Return command for viewer for this mime type complete with this file
source code
 
get_editor_cmd(mimetype=None, filename=None) source code
 
guess_ext_by_mimetype(mimetype='')
Return file extension based on what the OS thinks a file of this mimetype should end in.
source code
 
guess_ext_for_file(aFile=None) source code
 
adjust_extension_by_mimetype(filename) source code
 
convert_file(filename=None, target_mime=None, target_filename=None, target_extension=None, verbose=False)
Convert file from one format into another.
source code
 
describe_file(filename, callback=None) source code
 
call_viewer_on_file(aFile=None, block=None)
Try to find an appropriate viewer with all tricks and call it.
source code
 
call_editor_on_file(filename=None, block=True)
Try to find an appropriate editor with all tricks and call it.
source code
Variables
  open_cmds = {'cmd.exe': 'cmd.exe /c "%s"', 'exo-open': 'exo-op...
  __package__ = 'Gnumed.pycommon'

Imports: sys, os, mailcap, mimetypes, subprocess, shutil, logging, io, gmShellAPI, gmTools, gmCfg2, gmWorkerThread


Function Details

guess_mimetype(filename=None)

source code 

Guess mime type of arbitrary file.

filenames are supposed to be in Unicode

convert_file(filename=None, target_mime=None, target_filename=None, target_extension=None, verbose=False)

source code 

Convert file from one format into another.

target_mime: a mime type

call_viewer_on_file(aFile=None, block=None)

source code 

Try to find an appropriate viewer with all tricks and call it.

block: try to detach from viewer or not, None means to use mailcap default

call_editor_on_file(filename=None, block=True)

source code 

Try to find an appropriate editor with all tricks and call it.

block: try to detach from editor or not, None means to use mailcap default.


Variables Details

open_cmds

Value:
{'cmd.exe': 'cmd.exe /c "%s"',
 'exo-open': 'exo-open "%s"',
 'gnome-open': 'gnome-open "%s"',
 'kfmclient': 'kfmclient exec "%s"',
 'op': 'op "%s"',
 'open': 'open "%s"',
 'xdg-open': 'xdg-open "%s"'}