Add extension to files that come into the clipboard without one.

This commit is contained in:
Tomeu Vizoso
2007-06-21 13:07:11 +02:00
parent 3ebb8f1291
commit 427e9a00d7
3 changed files with 29 additions and 5 deletions
+18
View File
@@ -9,3 +9,21 @@ def get_for_file(file_name):
def get_from_file_name(file_name):
return _sugarext.get_mime_type_from_file_name(file_name)
_extensions_cache = {}
def get_primary_extension(mime_type):
if _extensions_cache.has_key(mime_type):
return _extensions_cache[mime_type]
f = open('/etc/mime.types')
while True:
line = f.readline()
cols = line.replace('\t', ' ').split(' ')
if mime_type == cols[0]:
for col in cols[1:]:
if col:
_extensions_cache[mime_type] = col
return col
_extensions_cache[mime_type] = None
return None