Clean and made a lot of pylint improvements. Still working on this though.
svn: r17737
This commit is contained in:
parent
65c7aa80f1
commit
cfc37a6760
@ -25,7 +25,7 @@
|
|||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
# Python Modules
|
# Python Modules
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
import os, sys
|
import os
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
import calendar, time
|
import calendar, time
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ from xml.sax.saxutils import escape as _html_escape
|
|||||||
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
from decimal import *
|
from decimal import Decimal, getcontext
|
||||||
getcontext().prec = 4
|
getcontext().prec = 4
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
|
|
||||||
@ -46,21 +46,26 @@ import subprocess
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# GRAMPS modules
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# GRAMPS modules
|
# GRAMPS modules
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
from QuestionDialog import WarningDialog, QuestionDialog
|
|
||||||
|
|
||||||
from gen.ggettext import gettext as _
|
|
||||||
|
|
||||||
from gen.plug import Gramplet
|
from gen.plug import Gramplet
|
||||||
from DateHandler import displayer as _dd
|
from DateHandler import displayer as _dd
|
||||||
|
|
||||||
import gen.lib
|
import gen.lib
|
||||||
|
import gen.mime
|
||||||
import Utils
|
import Utils
|
||||||
from PlaceUtils import conv_lat_lon
|
from PlaceUtils import conv_lat_lon
|
||||||
|
|
||||||
|
from QuestionDialog import WarningDialog, QuestionDialog
|
||||||
|
|
||||||
|
from gen.ggettext import gettext as _
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# Check for pyexiv2 library...
|
# Check for pyexiv2 library...
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@ -148,31 +153,31 @@ _TOOLTIPS = {
|
|||||||
"the company who is responsible for the creation of this image."),
|
"the company who is responsible for the creation of this image."),
|
||||||
|
|
||||||
# Copyright
|
# Copyright
|
||||||
"Copyright" : _("Enter the copyright information for this image. \n"
|
"Copyright" : _("Enter the copyright information for this image. \n"
|
||||||
"Example: (C) 2010 Smith and Wesson"),
|
"Example: (C) 2010 Smith and Wesson"),
|
||||||
|
|
||||||
# Calendar date select...
|
# Calendar date select...
|
||||||
"Date:Select" : _("Allows you to select a date from a pop-up window calendar. \n"
|
"Date:Select" : _("Allows you to select a date from a pop-up window calendar. \n"
|
||||||
"Warning: You will still need to edit the time..."),
|
"Warning: You will still need to edit the time..."),
|
||||||
|
|
||||||
# Original Date/ Time...
|
# Original Date/ Time...
|
||||||
"DateTime" : _("Original Date/ Time of this image.\n"
|
"DateTime" : _("Original Date/ Time of this image.\n"
|
||||||
"Example: 1826-Apr-12 14:30:00, 1826-April-12, 1998-01-31 13:30:00"),
|
"Example: 1826-Apr-12 14:30:00, 1826-April-12, 1998-01-31 13:30:00"),
|
||||||
|
|
||||||
# Convert to decimal button...
|
# Convert to decimal button...
|
||||||
"GPSFormat:Decimal" : _("Converts Degree, Minutes, Seconds GPS Coordinates to a "
|
"GPSFormat:Decimal" : _("Converts Degree, Minutes, Seconds GPS coordinates to a "
|
||||||
"Decimal representation."),
|
"Decimal representation."),
|
||||||
|
|
||||||
# convert to degrees, minutes, seconds button...
|
# convert to degrees, minutes, seconds button...
|
||||||
"GPSFormat:DMS" : _("Converts Decimal GPS Coordinates "
|
"GPSFormat:DMS" : _("Converts Decimal GPS coordinates "
|
||||||
"to a Degrees, Minutes, Seconds representation."),
|
"to a Degrees, Minutes, Seconds representation."),
|
||||||
|
|
||||||
# GPS Latitude...
|
# GPS Latitude...
|
||||||
"Latitude" : _(u"Enter the GPS Latitude Coordinates for your image,\n"
|
"Latitude" : _(u"Enter the GPS Latitude coordinates for your image,\n"
|
||||||
u"Example: 43.722965, 43 43 22 N, 38° 38′ 03″ N, 38 38 3"),
|
u"Example: 43.722965, 43 43 22 N, 38° 38′ 03″ N, 38 38 3"),
|
||||||
|
|
||||||
# GPS Longitude...
|
# GPS Longitude...
|
||||||
"Longitude" : _(u"Enter the GPS Longitude Coordinates for your image,\n"
|
"Longitude" : _(u"Enter the GPS Longitude coordinates for your image,\n"
|
||||||
u"Example: 10.396378, 10 23 46 E, 105° 6′ 6″ W, -105 6 6") }.items()
|
u"Example: 10.396378, 10 23 46 E, 105° 6′ 6″ W, -105 6 6") }.items()
|
||||||
|
|
||||||
# set up Exif keys for Image.exif_keys
|
# set up Exif keys for Image.exif_keys
|
||||||
@ -265,7 +270,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
self.plugin_image = False
|
self.plugin_image = False
|
||||||
|
|
||||||
self.connect_signal("Media", self.update)
|
self.connect_signal("Media", self.update)
|
||||||
vbox = self.build_gui()
|
vbox = self.__build_gui()
|
||||||
|
|
||||||
self.gui.get_container_widget().remove(self.gui.textview)
|
self.gui.get_container_widget().remove(self.gui.textview)
|
||||||
self.gui.get_container_widget().add_with_viewport(vbox)
|
self.gui.get_container_widget().add_with_viewport(vbox)
|
||||||
@ -274,7 +279,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
# provide tooltips for all fields and buttons...
|
# provide tooltips for all fields and buttons...
|
||||||
_setup_widget_tooltips(self.exif_widgets)
|
_setup_widget_tooltips(self.exif_widgets)
|
||||||
|
|
||||||
def build_gui(self):
|
def __build_gui(self):
|
||||||
|
|
||||||
vbox = gtk.VBox()
|
vbox = gtk.VBox()
|
||||||
|
|
||||||
@ -345,7 +350,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
# Original Date/ Time Entry, 1826-April-12 14:06:00
|
# Original Date/ Time Entry, 1826-April-12 14:06:00
|
||||||
("DateTime", _("Date/ Time"), None, False, [], True, 0),
|
("DateTime", _("Date/ Time"), None, False, [], True, 0),
|
||||||
|
|
||||||
# Convert GPS Coordinates
|
# Convert GPS coordinates
|
||||||
("GPSFormat", _("Convert GPS"), None, True,
|
("GPSFormat", _("Convert GPS"), None, True,
|
||||||
[("Decimal", _("Decimal"), "button", self.convert2decimal),
|
[("Decimal", _("Decimal"), "button", self.convert2decimal),
|
||||||
("DMS", _("Deg. Min. Sec."), "button", self.convert2dms)],
|
("DMS", _("Deg. Min. Sec."), "button", self.convert2dms)],
|
||||||
@ -370,7 +375,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
# Save button...
|
# Save button...
|
||||||
hsd_box.add( self.__create_button(
|
hsd_box.add( self.__create_button(
|
||||||
"Save", False, [self.__save_dialog, self.update, self.CopyTo, self.display_exif_tags],
|
"Save", False, [self.save_metadata, self.update, self.CopyTo, self.display_exif_tags],
|
||||||
gtk.STOCK_SAVE, False) )
|
gtk.STOCK_SAVE, False) )
|
||||||
|
|
||||||
if _MAGICK_FOUND:
|
if _MAGICK_FOUND:
|
||||||
@ -505,7 +510,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
self.activate_buttons(["Convert"])
|
self.activate_buttons(["Convert"])
|
||||||
|
|
||||||
# displays the imge Exif metadata
|
# displays the imge Exif metadata
|
||||||
self.display_exif_tags(self.orig_image)
|
self.display_exif_tags()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.exif_widgets["Message:Area"].set_text(_("Choose a different image..."))
|
self.exif_widgets["Message:Area"].set_text(_("Choose a different image..."))
|
||||||
@ -536,7 +541,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
return column
|
return column
|
||||||
|
|
||||||
def __create_button(self, pos, text, callback =[], icon =False, sensitive = True):
|
def __create_button(self, pos, text, callback =False , icon =False, sensitive = True):
|
||||||
"""
|
"""
|
||||||
creates and returns a button for display
|
creates and returns a button for display
|
||||||
"""
|
"""
|
||||||
@ -566,19 +571,6 @@ class EditExifMetadata(Gramplet):
|
|||||||
QuestionDialog(_("Edit Image Exif Metadata"), _("Convert this image to a .jpeg image?"),
|
QuestionDialog(_("Edit Image Exif Metadata"), _("Convert this image to a .jpeg image?"),
|
||||||
_("Convert"), self.convert2Jpeg)
|
_("Convert"), self.convert2Jpeg)
|
||||||
|
|
||||||
def __save_dialog(self, obj):
|
|
||||||
"""
|
|
||||||
Handles the Save question Dialog...
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.SavedEntries = [self.exif_widgets[widget].get_text() for widget in [
|
|
||||||
"Description", "Artist", "Copyright", "DateTime", "Latitude", "Longitude"] ]
|
|
||||||
self.SavedEntries = [entry for entry in self.SavedEntries if entry]
|
|
||||||
if self.SavedEntries:
|
|
||||||
|
|
||||||
QuestionDialog(_("Edit Image Exif Metadata"), _("Save Exif metadata to this image?"),
|
|
||||||
_("Save"), self.save_metadata)
|
|
||||||
|
|
||||||
def __delete_dialog(self, obj):
|
def __delete_dialog(self, obj):
|
||||||
"""
|
"""
|
||||||
Handles the Delete Dialog...
|
Handles the Delete Dialog...
|
||||||
@ -618,7 +610,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
self.set_has_data(False)
|
self.set_has_data(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
def make_row(self, pos, text, choices=None, readonly=False, callback_list=[],
|
def make_row(self, pos, text, choices=None, readonly=False, callback_list =[],
|
||||||
mark_dirty=False, default=0):
|
mark_dirty=False, default=0):
|
||||||
|
|
||||||
# Edit Image Exif Metadata
|
# Edit Image Exif Metadata
|
||||||
@ -686,41 +678,41 @@ class EditExifMetadata(Gramplet):
|
|||||||
def _mark_dirty(self, obj):
|
def _mark_dirty(self, obj):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _get_value(self, KeyTag):
|
def _get_value(self, keytag):
|
||||||
"""
|
"""
|
||||||
gets the value from the Exif Key, and returns it...
|
gets the value from the Exif Key, and returns it...
|
||||||
|
|
||||||
@param: KeyTag -- image metadata key
|
@param: keytag -- image metadata key
|
||||||
"""
|
"""
|
||||||
|
|
||||||
KeyValue = ""
|
KeyValue = ""
|
||||||
if LesserVersion:
|
if LesserVersion:
|
||||||
KeyValue = self.plugin_image[KeyTag]
|
KeyValue = self.plugin_image[keytag]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
KeyValue = self.plugin_image[KeyTag].value
|
KeyValue = self.plugin_image[keytag].value
|
||||||
|
|
||||||
except (KeyError, ValueError, AttributeError):
|
except (KeyError, ValueError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return KeyValue
|
return KeyValue
|
||||||
|
|
||||||
def display_exif_tags(self, object):
|
def display_exif_tags(self, mediadatatags_ =None):
|
||||||
"""
|
"""
|
||||||
once the pyexiv2.Image has been created, we display
|
once the pyexiv2.Image has been created, we display
|
||||||
all of the image Exif metadata...
|
all of the image Exif metadata...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MediaDataTags = _get_exif_keypairs(self.plugin_image)
|
mediadatatags_ = _get_exif_keypairs(self.plugin_image)
|
||||||
|
|
||||||
# set has data flag...
|
# set has data flag...
|
||||||
self.set_has_data(len(MediaDataTags) > 0)
|
self.set_has_data(len(mediadatatags_) > 0)
|
||||||
|
|
||||||
# Activate Clear and Save buttons...
|
# Activate Clear and Save buttons...
|
||||||
self.activate_buttons(["Clear", "Save"])
|
self.activate_buttons(["Clear", "Save"])
|
||||||
|
|
||||||
# check to see if we got metadata from the media object?
|
# check to see if we got metadata from the media object?
|
||||||
if MediaDataTags:
|
if mediadatatags_:
|
||||||
|
|
||||||
# activate CopyTo button...
|
# activate CopyTo button...
|
||||||
self.activate_buttons(["CopyTo"])
|
self.activate_buttons(["CopyTo"])
|
||||||
@ -728,45 +720,45 @@ class EditExifMetadata(Gramplet):
|
|||||||
# set Message Area to Display...
|
# set Message Area to Display...
|
||||||
self.exif_widgets["Message:Area"].set_text(_("Displaying image Exif metadata..."))
|
self.exif_widgets["Message:Area"].set_text(_("Displaying image Exif metadata..."))
|
||||||
|
|
||||||
for KeyTag in MediaDataTags:
|
for keytag in mediadatatags_:
|
||||||
|
|
||||||
if LesserVersion:
|
if LesserVersion:
|
||||||
label = self.plugin_image.tagDetails(KeyTag)[0]
|
label = self.plugin_image.tagDetails(keytag)[0]
|
||||||
human_value = self.plugin_image.interpretedExifValue(KeyTag)
|
human_value = self.plugin_image.interpretedExifValue(keytag)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
tag = self.plugin_image[KeyTag]
|
tag = self.plugin_image[keytag]
|
||||||
label = tag.label
|
label = tag.label
|
||||||
human_value = tag.human_value
|
human_value = tag.human_value
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
human_value = False
|
human_value = False
|
||||||
|
|
||||||
if KeyTag in ("Exif.Image.DateTime",
|
if keytag in ("Exif.Image.DateTime",
|
||||||
"Exif.Photo.DateTimeOriginal",
|
"Exif.Photo.DateTimeOriginal",
|
||||||
"Exif.Photo.DateTimeDigitized"):
|
"Exif.Photo.DateTimeDigitized"):
|
||||||
human_value = _process_datetime(self._get_value(KeyTag))
|
human_value = _process_datetime(self._get_value(keytag))
|
||||||
|
|
||||||
if human_value is not False:
|
if human_value is not False:
|
||||||
self.model.append((self.plugin_image, label, human_value))
|
self.model.append((self.plugin_image, label, human_value))
|
||||||
|
|
||||||
def CopyTo(self, object):
|
def CopyTo(self, imagekeytags =None):
|
||||||
"""
|
"""
|
||||||
reads the image metadata after the pyexiv2.Image has been created
|
reads the image metadata after the pyexiv2.Image has been created
|
||||||
"""
|
"""
|
||||||
|
|
||||||
imageKeyTags = _get_exif_keypairs(self.plugin_image)
|
imagekeytags = _get_exif_keypairs(self.plugin_image)
|
||||||
if imageKeyTags:
|
if imagekeytags:
|
||||||
imageKeyTags = [KeyTag for KeyTag in imageKeyTags if KeyTag in _DATAMAP]
|
imagekeytags = [keytag for keytag in imagekeytags if keytag in _DATAMAP]
|
||||||
|
|
||||||
self.exif_widgets["Message:Area"].set_text(_("Copying Exif metadata to the Edit Area..."))
|
self.exif_widgets["Message:Area"].set_text(_("Copying Exif metadata to the Edit Area..."))
|
||||||
|
|
||||||
for KeyTag in imageKeyTags:
|
for keytag in imagekeytags:
|
||||||
|
|
||||||
# name for matching to exif_widgets
|
# name for matching to exif_widgets
|
||||||
widgetsName = _DATAMAP[KeyTag]
|
widgetsName = _DATAMAP[keytag]
|
||||||
|
|
||||||
tagValue = self._get_value(KeyTag)
|
tagValue = self._get_value(keytag)
|
||||||
if tagValue:
|
if tagValue:
|
||||||
|
|
||||||
if widgetsName in ["Description", "Artist", "Copyright"]:
|
if widgetsName in ["Description", "Artist", "Copyright"]:
|
||||||
@ -774,15 +766,15 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
# Original Date of the image...
|
# Original Date of the image...
|
||||||
elif widgetsName == "DateTime":
|
elif widgetsName == "DateTime":
|
||||||
use_date = self._get_value(KeyTag)
|
use_date = self._get_value(keytag)
|
||||||
use_date = _process_datetime(use_date) if use_date else False
|
use_date = _process_datetime(use_date) if use_date else False
|
||||||
if use_date is not False:
|
if use_date is not False:
|
||||||
self.exif_widgets[widgetsName].set_text(use_date)
|
self.exif_widgets[widgetsName].set_text(use_date)
|
||||||
|
|
||||||
# LatitudeRef, Latitude, LongitudeRef, Longitude...
|
# latituderef, Latitude, longituderef, Longitude...
|
||||||
elif widgetsName == "Latitude":
|
elif widgetsName == "Latitude":
|
||||||
|
|
||||||
latitude = self._get_value(KeyTag)
|
latitude = self._get_value(keytag)
|
||||||
longitude = self._get_value(_DATAMAP["Longitude"] )
|
longitude = self._get_value(_DATAMAP["Longitude"] )
|
||||||
|
|
||||||
# if latitude and longitude exist, display them?
|
# if latitude and longitude exist, display them?
|
||||||
@ -794,24 +786,24 @@ class EditExifMetadata(Gramplet):
|
|||||||
# split longitude metadata into degrees, minutes, and seconds
|
# split longitude metadata into degrees, minutes, and seconds
|
||||||
longdeg, longmin, longsec = rational_to_dms(longitude)
|
longdeg, longmin, longsec = rational_to_dms(longitude)
|
||||||
|
|
||||||
# check to see if we have valid GPS Coordinates?
|
# check to see if we have valid GPS coordinates?
|
||||||
latfail = any(coords == False for coords in [latdeg, latmin, latsec])
|
latfail = any(coords == False for coords in [latdeg, latmin, latsec])
|
||||||
longfail = any(coords == False for coords in [longdeg, longmin, longsec])
|
longfail = any(coords == False for coords in [longdeg, longmin, longsec])
|
||||||
if (not latfail and not longfail):
|
if (not latfail and not longfail):
|
||||||
|
|
||||||
# Latitude Direction Reference
|
# Latitude Direction Reference
|
||||||
LatitudeRef = self._get_value(_DATAMAP["LatitudeRef"] )
|
latituderef = self._get_value(_DATAMAP["LatitudeRef"] )
|
||||||
|
|
||||||
# Longitude Direction Reference
|
# Longitude Direction Reference
|
||||||
LongitudeRef = self._get_value(_DATAMAP["LongitudeRef"] )
|
longituderef = self._get_value(_DATAMAP["LongitudeRef"] )
|
||||||
|
|
||||||
# set display for Latitude GPS Coordinates
|
# set display for Latitude GPS coordinates
|
||||||
self.exif_widgets["Latitude"].set_text(
|
self.exif_widgets["Latitude"].set_text(
|
||||||
"""%s° %s′ %s″ %s""" % (latdeg, latmin, latsec, LatitudeRef) )
|
"""%s° %s′ %s″ %s""" % (latdeg, latmin, latsec, latituderef) )
|
||||||
|
|
||||||
# set display for Longitude GPS Coordinates
|
# set display for Longitude GPS coordinates
|
||||||
self.exif_widgets["Longitude"].set_text(
|
self.exif_widgets["Longitude"].set_text(
|
||||||
"""%s° %s′ %s″ %s""" % (longdeg, longmin, longsec, LongitudeRef) )
|
"""%s° %s′ %s″ %s""" % (longdeg, longmin, longsec, longituderef) )
|
||||||
|
|
||||||
# enable Save button after metadata has been "Copied to Edit Area"...
|
# enable Save button after metadata has been "Copied to Edit Area"...
|
||||||
self.activate_buttons(["Save"])
|
self.activate_buttons(["Save"])
|
||||||
@ -866,22 +858,22 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
self.deactivate_buttons(["Convert"])
|
self.deactivate_buttons(["Convert"])
|
||||||
|
|
||||||
def _set_exif_KeyTag(self, KeyTag, KeyValue):
|
def _set_exif_keytag(self, keytag, KeyValue):
|
||||||
"""
|
"""
|
||||||
sets the value for the metadata KeyTags
|
sets the value for the metadata keytags
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if LesserVersion:
|
if LesserVersion:
|
||||||
self.plugin_image[KeyTag] = KeyValue
|
self.plugin_image[keytag] = KeyValue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try: # tag is being modified...
|
try: # tag is being modified...
|
||||||
self.plugin_image[KeyTag] = KeyValue
|
self.plugin_image[keytag] = KeyValue
|
||||||
|
|
||||||
except KeyError: # tag has not been set...
|
except KeyError: # tag has not been set...
|
||||||
self.plugin_image[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue)
|
self.plugin_image[keytag] = pyexiv2.ExifTag(keytag, KeyValue)
|
||||||
|
|
||||||
except (ValueError, AttributeError): # there is an issue with either KeyTag or KeyValue
|
except (ValueError, AttributeError): # there is an issue with either keytag or KeyValue
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def write_metadata(self, imageinstance):
|
def write_metadata(self, imageinstance):
|
||||||
@ -898,17 +890,17 @@ class EditExifMetadata(Gramplet):
|
|||||||
imageinstance.write()
|
imageinstance.write()
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# GPS Coordinates functions
|
# GPS coordinates functions
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
def addsymbols2gps(self, latitude =False, longitude =False):
|
def addsymbols2gps(self, latitude =False, longitude =False):
|
||||||
"""
|
"""
|
||||||
converts a degrees, minutes, seconds representation of Latitude/ Longitude
|
converts a degrees, minutes, seconds representation of Latitude/ Longitude
|
||||||
without their symbols to having them...
|
without their symbols to having them...
|
||||||
|
|
||||||
@param: latitude -- Latitude GPS Coordinates
|
@param: latitude -- Latitude GPS coordinates
|
||||||
@param: longitude -- Longitude GPS Coordinates
|
@param: longitude -- Longitude GPS coordinates
|
||||||
"""
|
"""
|
||||||
LatitudeRef, LongitudeRef = "N", "E"
|
latituderef, longituderef = "N", "E"
|
||||||
|
|
||||||
# check to see if Latitude/ Longitude exits?
|
# check to see if Latitude/ Longitude exits?
|
||||||
if (latitude and longitude):
|
if (latitude and longitude):
|
||||||
@ -929,35 +921,35 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
# is there a direction element here?
|
# is there a direction element here?
|
||||||
if (latitude.count("N") == 1 or latitude.count("S") == 1):
|
if (latitude.count("N") == 1 or latitude.count("S") == 1):
|
||||||
latdeg, latmin, latsec, LatitudeRef = latitude.split(" ", 3)
|
latdeg, latmin, latsec, latituderef = latitude.split(" ", 3)
|
||||||
else:
|
else:
|
||||||
atitudeRef = "N"
|
atitudeRef = "N"
|
||||||
latdeg, latmin, latsec = latitude.split(" ", 2)
|
latdeg, latmin, latsec = latitude.split(" ", 2)
|
||||||
if latdeg[0] == "-":
|
if latdeg[0] == "-":
|
||||||
latdeg = latdeg.replace("-", "")
|
latdeg = latdeg.replace("-", "")
|
||||||
LatitudeRef = "S"
|
latituderef = "S"
|
||||||
|
|
||||||
# is there a direction element here?
|
# is there a direction element here?
|
||||||
if (longitude.count("E") == 1 or longitude.count("W") == 1):
|
if (longitude.count("E") == 1 or longitude.count("W") == 1):
|
||||||
longdeg, longmin, longsec, LongitudeRef = longitude.split(" ", 3)
|
longdeg, longmin, longsec, longituderef = longitude.split(" ", 3)
|
||||||
else:
|
else:
|
||||||
ongitudeRef = "E"
|
ongitudeRef = "E"
|
||||||
longdeg, longmin, longsec = longitude.split(" ", 2)
|
longdeg, longmin, longsec = longitude.split(" ", 2)
|
||||||
if longdeg[0] == "-":
|
if longdeg[0] == "-":
|
||||||
longdeg = longdeg.replace("-", "")
|
longdeg = longdeg.replace("-", "")
|
||||||
LongitudeRef = "W"
|
longituderef = "W"
|
||||||
|
|
||||||
latitude = """%s° %s′ %s″ %s""" % (latdeg, latmin, latsec, LatitudeRef)
|
latitude = """%s° %s′ %s″ %s""" % (latdeg, latmin, latsec, latituderef)
|
||||||
longitude = """%s° %s′ %s″ %s""" % (longdeg, longmin, longsec, LongitudeRef)
|
longitude = """%s° %s′ %s″ %s""" % (longdeg, longmin, longsec, longituderef)
|
||||||
|
|
||||||
return latitude, longitude
|
return latitude, longitude
|
||||||
|
|
||||||
def convert2decimal(self, obj):
|
def convert2decimal(self, obj):
|
||||||
"""
|
"""
|
||||||
will convert a decimal GPS Coordinates into decimal format.
|
will convert a decimal GPS coordinates into decimal format.
|
||||||
|
|
||||||
@param: latitude -- GPS Latitude Coordinates from data field...
|
@param: latitude -- GPS Latitude coordinates from data field...
|
||||||
@param: longitude -- GPS Longitude Coordinates from data field...
|
@param: longitude -- GPS Longitude coordinates from data field...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# get Latitude/ Longitude from the data fields
|
# get Latitude/ Longitude from the data fields
|
||||||
@ -987,7 +979,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
def convert2dms(self, obj):
|
def convert2dms(self, obj):
|
||||||
"""
|
"""
|
||||||
will convert a decimal GPS Coordinates into degrees, minutes, seconds
|
will convert a decimal GPS coordinates into degrees, minutes, seconds
|
||||||
for display only
|
for display only
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -1005,32 +997,32 @@ class EditExifMetadata(Gramplet):
|
|||||||
latitude, longitude = conv_lat_lon(latitude, longitude, "DEG-:")
|
latitude, longitude = conv_lat_lon(latitude, longitude, "DEG-:")
|
||||||
|
|
||||||
# remove negative symbol if there is one?
|
# remove negative symbol if there is one?
|
||||||
LatitudeRef = "N"
|
latituderef = "N"
|
||||||
if latitude[0] == "-":
|
if latitude[0] == "-":
|
||||||
latitude = latitude.replace("-", "")
|
latitude = latitude.replace("-", "")
|
||||||
LatitudeRef = "S"
|
latituderef = "S"
|
||||||
latdeg, latmin, latsec = latitude.split(":", 2)
|
latdeg, latmin, latsec = latitude.split(":", 2)
|
||||||
|
|
||||||
# remove negative symbol if there is one?
|
# remove negative symbol if there is one?
|
||||||
LongitudeRef = "E"
|
longituderef = "E"
|
||||||
if longitude[0] == "-":
|
if longitude[0] == "-":
|
||||||
longitude = longitude.replace("-", "")
|
longitude = longitude.replace("-", "")
|
||||||
LongitudeRef = "W"
|
longituderef = "W"
|
||||||
longdeg, longmin, longsec = longitude.split(":", 2)
|
longdeg, longmin, longsec = longitude.split(":", 2)
|
||||||
|
|
||||||
self.exif_widgets["Latitude"].set_text(
|
self.exif_widgets["Latitude"].set_text(
|
||||||
"""%s° %s′ %s″ %s""" % (latdeg, latmin, latsec, LatitudeRef) )
|
"""%s° %s′ %s″ %s""" % (latdeg, latmin, latsec, latituderef) )
|
||||||
|
|
||||||
self.exif_widgets["Longitude"].set_text(
|
self.exif_widgets["Longitude"].set_text(
|
||||||
"""%s° %s′ %s″ %s""" % (longdeg, longmin, longsec, LongitudeRef) )
|
"""%s° %s′ %s″ %s""" % (longdeg, longmin, longsec, longituderef) )
|
||||||
|
|
||||||
#------------------------------------------------
|
#------------------------------------------------
|
||||||
# Writes/ saves Exif metadata to image
|
# Writes/ saves Exif metadata to image
|
||||||
#------------------------------------------------
|
#------------------------------------------------
|
||||||
def save_metadata(self):
|
def save_metadata(self, datatags =None):
|
||||||
"""
|
"""
|
||||||
gets the information from the plugin data fields
|
gets the information from the plugin data fields
|
||||||
and sets the KeyTag = keyvalue image metadata
|
and sets the keytag = keyvalue image metadata
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# determine if there has been something entered in the data fields?
|
# determine if there has been something entered in the data fields?
|
||||||
@ -1042,26 +1034,26 @@ class EditExifMetadata(Gramplet):
|
|||||||
len(self.exif_widgets["Longitude"].get_text() ) )
|
len(self.exif_widgets["Longitude"].get_text() ) )
|
||||||
|
|
||||||
# Description data field
|
# Description data field
|
||||||
self._set_exif_KeyTag(_DATAMAP["Description"], self.exif_widgets["Description"].get_text() )
|
self._set_exif_keytag(_DATAMAP["Description"], self.exif_widgets["Description"].get_text() )
|
||||||
|
|
||||||
# Modify Date/ Time... not a data field, but saved anyway...
|
# Modify Date/ Time... not a data field, but saved anyway...
|
||||||
self._set_exif_KeyTag(_DATAMAP["Modified"], datetime.now() )
|
self._set_exif_keytag(_DATAMAP["Modified"], datetime.now() )
|
||||||
|
|
||||||
# display modified Date/ Time
|
# display modified Date/ Time
|
||||||
self.exif_widgets["Modified"].set_text(_format_datetime(datetime.now() ) )
|
self.exif_widgets["Modified"].set_text(_format_datetime(datetime.now() ) )
|
||||||
|
|
||||||
# Artist/ Author data field
|
# Artist/ Author data field
|
||||||
self._set_exif_KeyTag(_DATAMAP["Artist"], self.exif_widgets["Artist"].get_text() )
|
self._set_exif_keytag(_DATAMAP["Artist"], self.exif_widgets["Artist"].get_text() )
|
||||||
|
|
||||||
# Copyright data field
|
# Copyright data field
|
||||||
self._set_exif_KeyTag(_DATAMAP["Copyright"], self.exif_widgets["Copyright"].get_text() )
|
self._set_exif_keytag(_DATAMAP["Copyright"], self.exif_widgets["Copyright"].get_text() )
|
||||||
|
|
||||||
# Original Date/ Time data field
|
# Original Date/ Time data field
|
||||||
DateTime = self.exif_widgets["DateTime"].get_text()
|
datetime_ = self.exif_widgets["DateTime"].get_text()
|
||||||
if DateTime:
|
if datetime_:
|
||||||
DateTime = _process_datetime(DateTime, False)
|
datetime_ = _process_datetime(datetime_, False)
|
||||||
if DateTime is not False:
|
if datetime_ is not False:
|
||||||
self._set_exif_KeyTag(_DATAMAP["DateTime"], DateTime)
|
self._set_exif_keytag(_DATAMAP["DateTime"], datetime_)
|
||||||
|
|
||||||
# Latitude/ Longitude data fields
|
# Latitude/ Longitude data fields
|
||||||
latitude = self.exif_widgets["Latitude"].get_text()
|
latitude = self.exif_widgets["Latitude"].get_text()
|
||||||
@ -1099,28 +1091,28 @@ class EditExifMetadata(Gramplet):
|
|||||||
self.exif_widgets["Latitude"].set_text(latitude)
|
self.exif_widgets["Latitude"].set_text(latitude)
|
||||||
self.exif_widgets["Longitude"].set_text(longitude)
|
self.exif_widgets["Longitude"].set_text(longitude)
|
||||||
|
|
||||||
LatitudeRef = " N"
|
latituderef = " N"
|
||||||
if "S" in latitude:
|
if "S" in latitude:
|
||||||
LatitudeRef = " S"
|
latituderef = " S"
|
||||||
latitude = latitude.replace(LatitudeRef, "")
|
latitude = latitude.replace(latituderef, "")
|
||||||
LatitudeRef = LatitudeRef.replace(" ", "")
|
latituderef = latituderef.replace(" ", "")
|
||||||
|
|
||||||
LongitudeRef = " E"
|
longituderef = " E"
|
||||||
if "W" in longitude:
|
if "W" in longitude:
|
||||||
LongitudeRef = " W"
|
longituderef = " W"
|
||||||
longitude = longitude.replace(LongitudeRef, "")
|
longitude = longitude.replace(longituderef, "")
|
||||||
LongitudeRef = LongitudeRef.replace(" ", "")
|
longituderef = longituderef.replace(" ", "")
|
||||||
|
|
||||||
# remove symbols for saving Latitude/ Longitude GPS Coordinates
|
# remove symbols for saving Latitude/ Longitude GPS coordinates
|
||||||
latitude, longitude = _removesymbols4saving(latitude, longitude)
|
latitude, longitude = _removesymbols4saving(latitude, longitude)
|
||||||
|
|
||||||
# convert (degrees, minutes, seconds) to Rational for saving
|
# convert (degrees, minutes, seconds) to Rational for saving
|
||||||
self._set_exif_KeyTag(_DATAMAP["LatitudeRef"], LatitudeRef)
|
self._set_exif_keytag(_DATAMAP["LatitudeRef"], latituderef)
|
||||||
self._set_exif_KeyTag(_DATAMAP["Latitude"], coords_to_rational(latitude))
|
self._set_exif_keytag(_DATAMAP["Latitude"], coords_to_rational(latitude))
|
||||||
|
|
||||||
# convert (degrees, minutes, seconds) to Rational for saving
|
# convert (degrees, minutes, seconds) to Rational for saving
|
||||||
self._set_exif_KeyTag(_DATAMAP["LongitudeRef"], LongitudeRef)
|
self._set_exif_keytag(_DATAMAP["LongitudeRef"], longituderef)
|
||||||
self._set_exif_KeyTag(_DATAMAP["Longitude"], coords_to_rational(longitude))
|
self._set_exif_keytag(_DATAMAP["Longitude"], coords_to_rational(longitude))
|
||||||
|
|
||||||
if datatags:
|
if datatags:
|
||||||
# set Message Area to Saved...
|
# set Message Area to Saved...
|
||||||
@ -1137,7 +1129,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
if _MAGICK_FOUND:
|
if _MAGICK_FOUND:
|
||||||
self.activate_buttons(["Delete"])
|
self.activate_buttons(["Delete"])
|
||||||
|
|
||||||
def strip_metadata(self):
|
def strip_metadata(self, erase_results =None):
|
||||||
"""
|
"""
|
||||||
Will completely and irrevocably erase all Exif metadata from this image.
|
Will completely and irrevocably erase all Exif metadata from this image.
|
||||||
"""
|
"""
|
||||||
@ -1147,10 +1139,10 @@ class EditExifMetadata(Gramplet):
|
|||||||
erase_results = str(erase)
|
erase_results = str(erase)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
MediaDataTags = _get_exif_keypairs(self.plugin_image)
|
mediadatatags_ = _get_exif_keypairs(self.plugin_image)
|
||||||
if MediaDataTags:
|
if mediadatatags_:
|
||||||
for KeyTag in MediaDataTags:
|
for keytag in mediadatatags_:
|
||||||
del self.plugin_image[KeyTag]
|
del self.plugin_image[keytag]
|
||||||
erase_results = True
|
erase_results = True
|
||||||
|
|
||||||
# write wiped metadata to image...
|
# write wiped metadata to image...
|
||||||
@ -1168,12 +1160,15 @@ class EditExifMetadata(Gramplet):
|
|||||||
# Notify the User...
|
# Notify the User...
|
||||||
self.exif_widgets["Message:Area"].set_text(_("All Exif metadata has been "
|
self.exif_widgets["Message:Area"].set_text(_("All Exif metadata has been "
|
||||||
"deleted from this image..."))
|
"deleted from this image..."))
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
# re- initialize the image...
|
# re- initialize the image...
|
||||||
if _JHEAD_FOUND:
|
if _JHEAD_FOUND:
|
||||||
reinit = subprocess.check_call( ["jhead", "-purejpg", self.image_path] )
|
reinit = subprocess.check_call( ["jhead", "-purejpg", self.image_path] )
|
||||||
|
reinitialize = str(reinit)
|
||||||
|
if reinitialize:
|
||||||
|
self.exif_widgets["Message:Area"].set_text(_("Image has be re- initialized "
|
||||||
|
"for Exif metadata..."))
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
# Date Calendar functions
|
# Date Calendar functions
|
||||||
@ -1230,27 +1225,27 @@ def _get_exif_keypairs(plugin_image):
|
|||||||
if not plugin_image:
|
if not plugin_image:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
MediaDataTags = False
|
mediadatatags_ = False
|
||||||
if LesserVersion: # prior to pyexiv2-0.2.0
|
if LesserVersion: # prior to pyexiv2-0.2.0
|
||||||
|
|
||||||
# get all KeyTags for this image for diplay only...
|
# get all keytags for this image for diplay only...
|
||||||
MediaDataTags = [KeyTag for KeyTag in plugin_image.exifKeys() ]
|
mediadatatags_ = [keytag for keytag in plugin_image.exifKeys() ]
|
||||||
|
|
||||||
else: # pyexiv2-0.2.0 and above
|
else: # pyexiv2-0.2.0 and above
|
||||||
|
|
||||||
# get all KeyTags for this image for diplay only...
|
# get all keytags for this image for diplay only...
|
||||||
MediaDataTags = [KeyTag for KeyTag in chain(
|
mediadatatags_ = [keytag for keytag in chain(
|
||||||
plugin_image.exif_keys, plugin_image.xmp_keys,
|
plugin_image.exif_keys, plugin_image.xmp_keys,
|
||||||
plugin_image.iptc_keys) ]
|
plugin_image.iptc_keys) ]
|
||||||
|
|
||||||
return MediaDataTags
|
return mediadatatags_
|
||||||
|
|
||||||
def coords_to_rational(Coordinates):
|
def coords_to_rational(coordinates):
|
||||||
"""
|
"""
|
||||||
returns the GPS coordinates to Latitude/ Longitude
|
returns the GPS coordinates to Latitude/ Longitude
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return [string_to_rational(coordinate) for coordinate in Coordinates.split(" ")]
|
return [string_to_rational(coordinate) for coordinate in coordinates.split(" ")]
|
||||||
|
|
||||||
def convert_value(value):
|
def convert_value(value):
|
||||||
"""
|
"""
|
||||||
@ -1265,8 +1260,8 @@ def _removesymbols4saving(latitude, longitude):
|
|||||||
"""
|
"""
|
||||||
will recieve a DMS with symbols and return it without them
|
will recieve a DMS with symbols and return it without them
|
||||||
|
|
||||||
@param: latitude -- Latitude GPS Coordinates
|
@param: latitude -- Latitude GPS coordinates
|
||||||
@param: longitude -- GPS Longitude Coordinates
|
@param: longitude -- GPS Longitude coordinates
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# check to see if latitude/ longitude exist?
|
# check to see if latitude/ longitude exist?
|
||||||
@ -1293,7 +1288,7 @@ def rational_to_dms(coords):
|
|||||||
[Fraction(40, 1), Fraction(0, 1), Fraction(1079, 20)]
|
[Fraction(40, 1), Fraction(0, 1), Fraction(1079, 20)]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
deg, min, sec = False, False, False
|
degrees, minutes, seconds = [False]*3
|
||||||
# coordinates look like:
|
# coordinates look like:
|
||||||
# [Rational(38, 1), Rational(38, 1), Rational(150, 50)]
|
# [Rational(38, 1), Rational(38, 1), Rational(150, 50)]
|
||||||
# or [Fraction(38, 1), Fraction(38, 1), Fraction(318, 100)]
|
# or [Fraction(38, 1), Fraction(38, 1), Fraction(318, 100)]
|
||||||
@ -1302,7 +1297,7 @@ def rational_to_dms(coords):
|
|||||||
if len(coords) == 3:
|
if len(coords) == 3:
|
||||||
return [convert_value(coordinate) for coordinate in coords]
|
return [convert_value(coordinate) for coordinate in coords]
|
||||||
|
|
||||||
return deg, min, sec
|
return degrees, minutes, seconds
|
||||||
|
|
||||||
def _format_datetime(exif_dt):
|
def _format_datetime(exif_dt):
|
||||||
"""
|
"""
|
||||||
@ -1335,7 +1330,7 @@ def _get_date_format(datestr):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# attempt to determine the dateformat of the variable passed to it...
|
# attempt to determine the dateformat of the variable passed to it...
|
||||||
tmpDate = False
|
tmpdate = False
|
||||||
for dateformat in ["%Y-%m-%d %H:%M:%S", "%Y %m %d %H:%M:%S",
|
for dateformat in ["%Y-%m-%d %H:%M:%S", "%Y %m %d %H:%M:%S",
|
||||||
"%Y-%b-%d %H:%M:%S", "%Y %b %d %H:%M:%S",
|
"%Y-%b-%d %H:%M:%S", "%Y %b %d %H:%M:%S",
|
||||||
"%Y-%B-%d %H:%M:%S", "%Y %B %d %H:%M:%S",
|
"%Y-%B-%d %H:%M:%S", "%Y %B %d %H:%M:%S",
|
||||||
@ -1348,22 +1343,23 @@ def _get_date_format(datestr):
|
|||||||
|
|
||||||
# find date string format
|
# find date string format
|
||||||
try:
|
try:
|
||||||
tmpDate = time.strptime(datestr, dateformat)
|
tmpdate = time.strptime(datestr, dateformat)
|
||||||
break
|
break
|
||||||
|
|
||||||
# datestring format not found...
|
# datestring format not found...
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return tmpDate
|
return tmpdate
|
||||||
|
|
||||||
def _create_datetime(pyear, pmonth, day, hour, minutes, seconds):
|
def _create_datetime(date_elements):
|
||||||
"""
|
"""
|
||||||
will create and retrun a str or datetime from (
|
will create and retrun a str or datetime from (
|
||||||
year, month, day, hour, minutes, and seconds) ...
|
year, month, day, hour, minutes, and seconds) ...
|
||||||
|
|
||||||
if the year is less than 1900, then it will return a string representation...
|
if the year is less than 1900, then it will return a string representation...
|
||||||
"""
|
"""
|
||||||
|
pyear, pmonth, day, hour, minutes, seconds = date_elements
|
||||||
|
|
||||||
# do some error trapping...
|
# do some error trapping...
|
||||||
if pmonth > 12:
|
if pmonth > 12:
|
||||||
@ -1395,58 +1391,58 @@ def _create_datetime(pyear, pmonth, day, hour, minutes, seconds):
|
|||||||
|
|
||||||
if pyear < 1900:
|
if pyear < 1900:
|
||||||
try:
|
try:
|
||||||
tmpDate = "%04d-%s-%02d %02d:%02d:%02d" % (pyear, _dd.long_months[pmonth], day,
|
tmpdate = "%04d-%s-%02d %02d:%02d:%02d" % (pyear, _dd.long_months[pmonth], day,
|
||||||
hour, minutes, seconds)
|
hour, minutes, seconds)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
tmpDate = False
|
tmpdate = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
tmpDate = datetime(pyear, pmonth, day, hour, minutes, seconds)
|
tmpdate = datetime(pyear, pmonth, day, hour, minutes, seconds)
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
tmpDate = False
|
tmpdate = False
|
||||||
|
|
||||||
if tmpDate is False:
|
if tmpdate is False:
|
||||||
tmpDate = ""
|
tmpdate = ""
|
||||||
|
|
||||||
return tmpDate
|
return tmpdate
|
||||||
|
|
||||||
def _process_datetime(tmpDate, exif_type =True):
|
def _process_datetime(tmpdate, exif_type =True):
|
||||||
"""
|
"""
|
||||||
will attempt to parse the date/ time Exif metadata entry into its pieces...
|
will attempt to parse the date/ time Exif metadata entry into its pieces...
|
||||||
(year, month, day, hour, minutes, seconds)
|
(year, month, day, hour, minutes, seconds)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not tmpDate:
|
if not tmpdate:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
datetype = type(tmpDate)
|
datetype = type(tmpdate)
|
||||||
|
|
||||||
# if variable is already in datetime.datetime() format, return it?
|
# if variable is already in datetime.datetime() format, return it?
|
||||||
if datetype == datetime:
|
if datetype == datetime:
|
||||||
pyear, pmonth, day = tmpDate.year, tmpDate.month, tmpDate.day
|
pyear, pmonth, day = tmpdate.year, tmpdate.month, tmpdate.day
|
||||||
hour, minutes, seconds = tmpDate.hour, tmpDate.minute, tmpDate.second
|
hour, minutes, seconds = tmpdate.hour, tmpdate.minute, tmpdate.second
|
||||||
|
|
||||||
elif any(datetype == value for value in [date, gen.lib.date.Date, list] ):
|
elif any(datetype == value for value in [date, gen.lib.date.Date, list] ):
|
||||||
hour, minutes, seconds = time.localtime()[3:6]
|
hour, minutes, seconds = time.localtime()[3:6]
|
||||||
|
|
||||||
# datetime.date format
|
# datetime.date format
|
||||||
if isinstance(tmpDate, date):
|
if isinstance(tmpdate, date):
|
||||||
pyear, pmonth, day = tmpDate.year, tmpDate.month, tmpDate.day
|
pyear, pmonth, day = tmpdate.year, tmpdate.month, tmpdate.day
|
||||||
|
|
||||||
# gen.lib.date.Date format
|
# gen.lib.date.Date format
|
||||||
elif isinstance(tmpDate, gen.lib.date.Date):
|
elif isinstance(tmpdate, gen.lib.date.Date):
|
||||||
pyear, pmonth, day = tmpDate.get_year(), tmpDate.get_month(), tmpDate.get_day()
|
pyear, pmonth, day = tmpdate.get_year(), tmpdate.get_month(), tmpdate.get_day()
|
||||||
|
|
||||||
# list format
|
# list format
|
||||||
else:
|
else:
|
||||||
pyear, pmonth, day = tmpDate[0].year, tmpDate[0].month, tmpDate[0].day
|
pyear, pmonth, day = tmpdate[0].year, tmpdate[0].month, tmpdate[0].day
|
||||||
|
|
||||||
# string format...
|
# string format...
|
||||||
elif datetype == str:
|
elif datetype == str:
|
||||||
|
|
||||||
datestr = _get_date_format(tmpDate)
|
datestr = _get_date_format(tmpdate)
|
||||||
if datestr is not False:
|
if datestr is not False:
|
||||||
pyear, pmonth, day, hour, minutes, seconds = datestr[0:6]
|
pyear, pmonth, day, hour, minutes, seconds = datestr[0:6]
|
||||||
|
|
||||||
@ -1454,33 +1450,33 @@ def _process_datetime(tmpDate, exif_type =True):
|
|||||||
pyear, pmonth, day, hour, minutes, seconds = [False]*6
|
pyear, pmonth, day, hour, minutes, seconds = [False]*6
|
||||||
|
|
||||||
if (not pyear and not pmonth):
|
if (not pyear and not pmonth):
|
||||||
tmpDate = False
|
tmpdate = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# create datetime...
|
# create datetime...
|
||||||
tmpDate = _create_datetime(pyear, pmonth, day, hour, minutes, seconds)
|
tmpdate = _create_datetime([pyear, pmonth, day, hour, minutes, seconds])
|
||||||
|
|
||||||
if tmpDate is not False:
|
if tmpdate is not False:
|
||||||
|
|
||||||
if isinstance(tmpDate, datetime):
|
if isinstance(tmpdate, datetime):
|
||||||
|
|
||||||
# for display only...
|
# for display only...
|
||||||
# make datetime displayed as user has set in preferences...
|
# make datetime displayed as user has set in preferences...
|
||||||
if exif_type:
|
if exif_type:
|
||||||
tmpDate = _format_datetime(tmpDate)
|
tmpdate = _format_datetime(tmpdate)
|
||||||
|
|
||||||
return tmpDate
|
return tmpdate
|
||||||
|
|
||||||
def _setup_widget_tooltips(Exif_widgets):
|
def _setup_widget_tooltips(exif_widgets):
|
||||||
"""
|
"""
|
||||||
setup tooltips for each entry field and button.
|
setup tooltips for each entry field and button.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# add tooltips for the data entry fields...
|
# add tooltips for the data entry fields...
|
||||||
for widget, tooltip in _TOOLTIPS:
|
for widget, tooltip in _TOOLTIPS:
|
||||||
Exif_widgets[widget].set_tooltip_text(tooltip)
|
exif_widgets[widget].set_tooltip_text(tooltip)
|
||||||
|
|
||||||
# add tooltips for the buttons...
|
# add tooltips for the buttons...
|
||||||
for widget, tooltip in _BUTTONTIPS.items():
|
for widget, tooltip in _BUTTONTIPS.items():
|
||||||
Exif_widgets[widget].set_tooltip_text(tooltip)
|
exif_widgets[widget].set_tooltip_text(tooltip)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user