Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Mimeo.py 2012-06-02 15:26:00.000000000 +0100
- +++ Mimeo_patched.py 2012-06-05 17:21:15.000000000 +0100
- @@ -722,11 +722,23 @@ class Mimeo():
- if os.path.isdir(rpath):
- return DIRECTORY_MIMETYPE
- elif os.path.isfile(rpath):
- - mimetype = mimetypes.guess_type(rpath)[0]
- - if not mimetype:
- - proc = subprocess.Popen(['file', '--mime-type', rpath], stdout=subprocess.PIPE)
- + method = os.getenv("MIMEO")
- + if not method:
- + method = "python"
- + if 'file' in method:
- + proc = subprocess.Popen(['file', '--mime-type', rpath], stdout=subprocess.PIPE)
- + output = proc.communicate()[0]
- + mimetype = output[len(rpath)+2:].rstrip()
- + elif 'mimetype' in method:
- + proc = subprocess.Popen(['mimetype', '-i', rpath], stdout=subprocess.PIPE)
- output = proc.communicate()[0]
- mimetype = output[len(rpath)+2:].rstrip()
- + elif 'rox' in method:
- + proc = subprocess.Popen(['rox', '-m', rpath], stdout=subprocess.PIPE)
- + output = proc.communicate()[0]
- + mimetype = output[0:].rstrip()
- + else:
- + mimetype = mimetypes.guess_type(rpath)[0]
- if not mimetype:
- self.error_msg("error: failed to detect MIME-type of %s" % arg)
- return mimetype
- @@ -2026,7 +2038,7 @@ def main():
- - conf_group = parser.add_argument_group('Configuration', 'Various configuration options.')
- + conf_group = parser.add_argument_group('Configuration', 'Various configuration options. Optionally, set the environment variable \'MIMEO\' to contain one of the following command names which will be used to determine MIME-types (assuming the relevant packages are installed): file, mimetype, rox. If none is specified, Python\'s \'mimetypes\' module is used instead.')
- conf_group.add_argument('-a', '--assoc', dest='assoc', metavar='<filepath>', action='append',
- help='Specify a file that associates regular expressions with custom commands. This can be used for opening URLs, for example. See "--assoc-help" for details.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement