############################################################################
#    Copyright (C) 2005 by Manuel Amador (Rudd-O)                          #
#    rudd-o@amautacorp.com                                                 #
#                                                                          #
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################

# FIXME implement an interface that allows the indexer to compare in-store file objects' interface versions with its corresponding plugin"s interface version, to provide for automatic schema migration.  Bump the interface number on your plugin, and pof all files are automatically reindexed when they are modified (or perhaps upon startup/reload)
# FIXME implement an observer pattern so that the index database detects when the plugins are reloaded, suspend database access to client classes, run __prepare_indexes and refresh objects whose interfaces have changed (ay que pensar bien el orden de mierda de estas operaciones para que no se vaya todo a la verga"), 

import sys
import os
import glob
import imp
import urllib

from gnome import vfs

# FIXME PRETTY PLEASE
# this may involve the creation of two other data types: naivedate (yy/mm/dd) and naivetime(hh:mm:ss) which operate in local time, and then client methods can interpret them and cast them to DateTime on their own, with this knowledge.
# or perhaps even better create an object daydelta = num of seconds after 0h00 and then we can sum that to the DateTime
# this should be moved to KDE's own module
def get_mimetype(filename):
		""" Returns a file's MIME type. """
		if os.path.isdir(filename): return "inode/directory"
		fn = urllib.pathname2url(filename)
		try: mt = vfs.get_mime_type(fn)
		except RuntimeError: raise IOError,(2,"No such file or directory: %s"%repr(filename))
		if len(mt) > 0: return mt

