From 2145de103988086a6a0e72890b1104cd9c4a843e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 24 May 2007 12:08:05 +0200 Subject: [PATCH] Hook up get_from_file_name --- sugar/objects/__init__.py | 3 +-- sugar/objects/mime.py | 12 ++++++++---- tests/test-mime.py | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sugar/objects/__init__.py b/sugar/objects/__init__.py index 139597f9..8f3e5528 100644 --- a/sugar/objects/__init__.py +++ b/sugar/objects/__init__.py @@ -1,2 +1 @@ - - +from sugar.objects import mime diff --git a/sugar/objects/mime.py b/sugar/objects/mime.py index 9e405611..1ab12510 100644 --- a/sugar/objects/mime.py +++ b/sugar/objects/mime.py @@ -1,4 +1,8 @@ -from sugar import _sugarext - -def get_from_filename(filename): - return _sugarext.get_mime_type_from_filename(filename) +try: + from sugar import _sugarext +except ImportError: + from sugar import ltihooks + from sugar import _sugarext + +def get_from_file_name(file_name): + return _sugarext.get_mime_type_from_file_name(file_name) diff --git a/tests/test-mime.py b/tests/test-mime.py index 8ecd6132..f9b3ac2d 100755 --- a/tests/test-mime.py +++ b/tests/test-mime.py @@ -16,6 +16,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from sugar import objects +from sugar.objects import mime -print objects.mime.get_from_filename('test.pdf') +print mime.get_from_file_name('test.pdf')