Changes to imports - part 5

svn: r20489
This commit is contained in:
Nick Hall 2012-10-02 20:04:29 +00:00
parent 186b27bf34
commit d696b6be75
12 changed files with 34 additions and 34 deletions

View File

@ -54,7 +54,7 @@ from gen.const import ICON, THUMBSCALE, USER_HOME
from gen.config import config
from gen.utils.file import (media_path_full, media_path, relative_path,
find_file, get_unicode_path_from_file_chooser)
import gen.mime
from gramps.gen.mime import get_type
from gui.thumbnails import find_mime_type_pixbuf
from gui.display import display_help
from gui.managedwindow import ManagedWindow
@ -163,7 +163,7 @@ class AddMediaObject(ManagedWindow):
filename = relative_path(filename, pname)
mtype = gen.mime.get_type(full_file)
mtype = get_type(full_file)
description = description or os.path.basename(filename)
self.obj.set_description(description)
@ -198,7 +198,7 @@ class AddMediaObject(ManagedWindow):
filename = find_file( filename)
if filename:
mtype = gen.mime.get_type(filename)
mtype = get_type(filename)
if mtype and mtype.startswith("image"):
image = scale_image(filename, THUMBSCALE)
else:

View File

@ -58,7 +58,7 @@ from gen.utils.file import (media_path_full, media_path, relative_path,
fix_encoding)
from gui.thumbnails import get_thumbnail_image
from gen.errors import WindowActiveError
import gen.mime
from gramps.gen.mime import get_type, is_valid_type
from gui.ddtargets import DdTargets
from buttontab import ButtonTab
from gen.constfunc import win
@ -512,8 +512,8 @@ class GalleryTab(ButtonTab, DbGUIElement):
name = fix_encoding(mfile)
name = unicode(urllib.url2pathname(
name.encode(sys.getfilesystemencoding())))
mime = gen.mime.get_type(name)
if not gen.mime.is_valid_type(mime):
mime = get_type(name)
if not is_valid_type(mime):
return
photo = MediaObject()
base_dir = unicode(media_path(self.dbstate.db))

View File

@ -46,7 +46,7 @@ from gi.repository import Gdk
from gui.utils import open_file_with_default_application
from gramps.gen.lib import MediaObject, NoteType
from gen.db import DbTxn
import gen.mime
from gramps.gen.mime import get_description, get_type
from gui.thumbnails import get_thumbnail_image, find_mime_type_pixbuf
from gen.utils.file import (media_path_full, find_file,
get_unicode_path_from_file_chooser)
@ -153,7 +153,7 @@ class EditMedia(EditPrimary):
self.draw_preview()
def determine_mime(self):
descr = gen.mime.get_description(self.obj.get_mime_type())
descr = get_description(self.obj.get_mime_type())
if descr:
self.mimetext.set_text(descr)
@ -161,9 +161,9 @@ class EditMedia(EditPrimary):
path_full = media_path_full(self.db, path)
if path != self.obj.get_path() and path_full != self.obj.get_path():
#redetermine mime
mime = gen.mime.get_type(find_file(path_full))
mime = get_type(find_file(path_full))
self.obj.set_mime_type(mime)
descr = gen.mime.get_description(mime)
descr = get_description(mime)
if descr:
self.mimetext.set_text(descr)
else:

View File

@ -46,7 +46,7 @@ from gi.repository import Gdk
#-------------------------------------------------------------------------
from gui.utils import open_file_with_default_application
from gen.const import THUMBSCALE
import gen.mime
from gramps.gen.mime import get_description, get_type
from gui.thumbnails import get_thumbnail_image, find_mime_type_pixbuf
from gen.utils.file import (media_path_full, find_file,
get_unicode_path_from_file_chooser)
@ -115,7 +115,7 @@ class EditMediaRef(EditReference):
self.select.connect('clicked', self.select_file)
def determine_mime(self):
descr = gen.mime.get_description(self.source.get_mime_type())
descr = get_description(self.source.get_mime_type())
if descr:
self.mimetext.set_text(descr)
@ -123,9 +123,9 @@ class EditMediaRef(EditReference):
path_full = media_path_full(self.db, path)
if path != self.source.get_path() and path_full != self.source.get_path():
#redetermine mime
mime = gen.mime.get_type(find_file(path_full))
mime = get_type(find_file(path_full))
self.source.set_mime_type(mime)
descr = gen.mime.get_description(mime)
descr = get_description(mime)
if descr:
self.mimetext.set_text(descr)
else:

View File

@ -63,7 +63,7 @@ from gui.dialog import QuestionDialog, OptionDialog
from gen.lib import Date
import gen.mime
from gramps.gen.mime import get_description
from gen.utils.file import search_for, media_path_full
from gen.utils.place import conv_lat_lon
@ -425,7 +425,7 @@ class EditExifMetadata(Gramplet):
# Mime type information
mime_type = self.orig_image.get_mime_type()
self.exif_widgets["MimeType"].set_text(gen.mime.get_description(mime_type))
self.exif_widgets["MimeType"].set_text(get_description(mime_type))
# check image write privileges
_writable = os.access(self.image_path, os.W_OK)

View File

@ -43,7 +43,7 @@ LOG = logging.getLogger(".ImportXML")
# Gramps Modules
#
#-------------------------------------------------------------------------
import gen.mime
from gramps.gen.mime import get_type
from gramps.gen.lib import Address, Attribute, AttributeType, ChildRef, ChildRefType, Citation, Date, Event, EventRef, EventRoleType, EventType, Family, LdsOrd, Location, MediaObject, MediaRef, Name, NameOriginType, NameType, Note, NoteType, Person, PersonRef, Place, RepoRef, Repository, Researcher, Source, StyledText, StyledTextTag, StyledTextTagType, Surname, Tag, Url
from gen.db import DbTxn
from gen.db.write import CLASS_TO_KEY_MAP
@ -2144,7 +2144,7 @@ class GrampsParser(UpdateCallback):
attr.set_type(key)
attr.set_value(attrs[key])
self.photo.add_attribute(attr)
self.photo.set_mime_type(gen.mime.get_type(self.photo.get_path()))
self.photo.set_mime_type(get_type(self.photo.get_path()))
self.db.add_object(self.photo, self.trans)
#set correct change time
self.db.commit_media_object(self.photo, self.trans, self.change)

View File

@ -117,7 +117,7 @@ from gen.const import DATA_DIR
from gramps.gen.lib import Address, Attribute, AttributeType, ChildRef, ChildRefType, Citation, Date, Event, EventRef, EventRoleType, EventType, Family, FamilyRelType, LdsOrd, Location, MediaObject, MediaRef, Name, NameType, Note, NoteType, Person, PersonRef, Place, RepoRef, Repository, RepositoryType, Researcher, Source, SourceMediaType, Surname, Url, UrlType
from gen.db import DbTxn
from gen.updatecallback import UpdateCallback
import gen.mime
from gramps.gen.mime import get_type
from gen.utils.id import create_id
from gen.utils.lds import TEMPLES
from gen.utils.unknown import make_unknown, create_explanation_note
@ -6117,7 +6117,7 @@ class GedcomParser(UpdateCallback):
path = line.data
state.media.set_path(path)
state.media.set_mime_type(gen.mime.get_type(path))
state.media.set_mime_type(get_type(path))
if not state.media.get_description():
state.media.set_description(path)
@ -7115,7 +7115,7 @@ class GedcomParser(UpdateCallback):
photo.set_description(title)
full_path = os.path.abspath(path)
if os.path.isfile(full_path):
photo.set_mime_type(gen.mime.get_type(full_path))
photo.set_mime_type(get_type(full_path))
else:
photo.set_mime_type(MIME_MAP.get(form.lower(), 'unknown'))
self.dbase.add_object(photo, self.trans)

View File

@ -58,7 +58,7 @@ from gen.updatecallback import UpdateCallback
from gui.plug import tool
from gen.utils.file import media_path_full, relative_path, media_path
from gen.ggettext import sgettext as _
import gen.mime
from gramps.gen.mime import get_type, is_image_type
#-------------------------------------------------------------------------
#
@ -674,8 +674,8 @@ class ImagesNotIncluded(BatchOp):
media_full_path = os.path.join(dirpath, filename)
if media_full_path not in self.path_list:
self.path_list.append(media_full_path)
mime_type = gen.mime.get_type(media_full_path)
if gen.mime.is_image_type(mime_type):
mime_type = get_type(media_full_path)
if is_image_type(mime_type):
obj = MediaObject()
obj.set_path(media_full_path)
obj.set_mime_type(mime_type)

View File

@ -50,7 +50,7 @@ from gi.repository import Gtk
from gramps.gen.lib import Address, Attribute, AttributeType, ChildRef, ChildRefType, Citation, Date, Event, EventRef, EventRoleType, EventType, Family, FamilyRelType, GrampsType, LdsOrd, Location, MediaObject, MediaRef, Name, NameOriginType, NameType, Note, NoteType, Person, PersonRef, Place, RepoRef, Repository, RepositoryType, Source, SourceMediaType, Surname, Tag, Url, UrlType
from gen.lib import StyledText, StyledTextTag, StyledTextTagType
from gen.db import DbTxn
import gen.mime
from gramps.gen.mime import get_type
from gui.plug import tool
from gen.utils.string import confidence
from gui.utils import ProgressMeter
@ -898,7 +898,7 @@ class TestcaseGenerator(tool.BatchTool):
m = MediaObject()
m.set_description(message)
m.set_path(unicode(ICON))
m.set_mime_type(gen.mime.get_type(m.get_path()))
m.set_mime_type(get_type(m.get_path()))
m.add_citation(choice(c_h_list))
# MediaObject : Attribute
a = Attribute()
@ -1580,7 +1580,7 @@ class TestcaseGenerator(tool.BatchTool):
o.set_description(unicode(self.rand_text(self.LONG)))
path = choice((ICON, LOGO, SPLASH))
o.set_path(unicode(path))
mime = gen.mime.get_type(path)
mime = get_type(path)
o.set_mime_type(mime)
else:
o.set_description(unicode(self.rand_text(self.SHORT)))

View File

@ -58,7 +58,7 @@ from gen.utils.file import (media_path, relative_path, media_path_full,
fix_encoding)
from gen.utils.db import get_media_referents
from gui.views.bookmarks import MediaBookmarks
import gen.mime
from gramps.gen.mime import get_type, is_valid_type
from gramps.gen.lib import MediaObject
from gen.db import DbTxn
from gui.editors import EditMedia, DeleteMediaQuery
@ -186,8 +186,8 @@ class MediaView(ListView):
if protocol == "file":
name = unicode(urllib.url2pathname(
mfile.encode(sys.getfilesystemencoding())))
mime = gen.mime.get_type(name)
if not gen.mime.is_valid_type(mime):
mime = get_type(name)
if not is_valid_type(mime):
return
photo = MediaObject()
base_dir = unicode(media_path(self.dbstate.db))

View File

@ -95,7 +95,7 @@ from gen.utils.db import get_source_and_citation_referents
from gen.constfunc import win
from gui.thumbnails import get_thumbnail_path, run_thumbnailer
from gen.utils.image import image_size, resize_to_jpeg_buffer
import gen.mime
from gramps.gen.mime import get_description
from gen.display.name import displayer as _nd
from gen.datehandler import displayer as _dd
from gen.proxy import PrivateProxyDb, LivingProxyDb
@ -3887,7 +3887,7 @@ class MediaPage(BasePage):
# get media type to be used primarily with "img" tags
mime_type = media.get_mime_type()
mtype = gen.mime.get_description(mime_type)
mtype = get_description(mime_type)
if mime_type:
note_only = False

View File

@ -31,7 +31,7 @@ from django.forms.widgets import TextInput, HiddenInput
# Gramps Modules:
from webapp.grampsdb.models import *
import gen.mime
from gramps.gen.mime import get_type
# Python Modules:
import datetime
@ -195,7 +195,7 @@ class MediaForm(forms.ModelForm):
from webapp.libdjango import DjangoInterface
dji = DjangoInterface()
model = super(MediaForm, self).save(commit=False)
model.mime = gen.mime.get_type(model.path)
model.mime = get_type(model.path)
dobj = dp(self.cleaned_data['text'])
dji.add_date(model, dobj.serialize())
if commit: