示例#1
0
    def __date_time(self, op, path, operation):
        dateTimePanel = operation.dateTimePanel
        dateTime = dateTimePanel.dateTime
        dateTime[1] = dateTimePanel.dateTestDisplay.GetLabel()
        dateTime[2] = dateTimePanel.timeTestDisplay.GetLabel()

        # user specified date/time
        if not dateTime[0]:
            return dateTime[op + 1]

        # get date/time from item
        else:
            itemTimeType = dateTimePanel.itemTimeType.GetSelection()
            if itemTimeType == 0:
                try: itemDateTime = time.localtime(os.path.getctime(path))
                except WindowsError: return ''
            elif itemTimeType == 1:
                try: itemDateTime = time.localtime(os.path.getmtime(path))
                except WindowsError: return ''
            elif itemTimeType == 2:
                try: itemDateTime = time.localtime(os.path.getatime(path))
                except WindowsError: return ''
            elif itemTimeType == 3:
                itemDateTime = self.__get_exif_date(path, 'EXIF DateTimeOriginal')
            elif itemTimeType == 4:
                itemDateTime = self.__get_exif_date(path, 'Image DateTime')

            if itemDateTime:
                return utils.udate(main, dateTime[op + 1], itemDateTime)
            else:
                return ''
示例#2
0
    def __create_file(self):
        """Create an XML configuration file."""
        datetime = utils.udate(main, '%Y-%m-%d %H:%M:%S', time.localtime())
        cfgFile = u'<?xml version="1.0" encoding="UTF-8"?>\n'
        cfgFile += u'<configuration application="Métamorphose-2" ' + \
            'version="%s" datetime="%s">\n'\
            % (app.version, datetime)
        # get info for 'normal' notebook tabs
        pages = utils.get_notebook_page_names(main)
        for i in (0, 2, 3):
            # section header is page name
            cfgFile += u'\t<page id="%s" name="%s">\n' % (i, pages[i].GetName())
            for child in pages[i].GetChildren():
                try:
                    id, type, value = self.__get_child_values(child)
                except TypeError:
                    pass
                else:
                    cfgFile += u'\t\t<value id="%s" type="%s">%s</value>\n'\
                        % (id, type, value)
            cfgFile += u'\t</page>\n'

        # get renaming operations
        cfgFile += u'\t<page id="1" name="%s">\n' % pages[1].GetName()
        cfgFile += self._renaming_ops_to_xml()
        cfgFile += "\t</page>\n</configuration>\n"
        
        return cfgFile
示例#3
0
    def __create_file(self):
        """Create an XML configuration file."""
        datetime = utils.udate(main, '%Y-%m-%d %H:%M:%S', time.localtime())
        cfgFile = u'<?xml version="1.0" encoding="UTF-8"?>\n'
        cfgFile += u'<configuration application="Métamorphose-2" ' + \
            'version="%s" datetime="%s">\n'\
            % (app.version, datetime)
        # get info for 'normal' notebook tabs
        pages = utils.get_notebook_page_names(main)
        for i in (0, 2, 3):
            # section header is page name
            cfgFile += u'\t<page id="%s" name="%s">\n' % (i,
                                                          pages[i].GetName())
            for child in pages[i].GetChildren():
                try:
                    id, type, value = self.__get_child_values(child)
                except TypeError:
                    pass
                else:
                    cfgFile += u'\t\t<value id="%s" type="%s">%s</value>\n'\
                        % (id, type, value)
            cfgFile += u'\t</page>\n'

        # get renaming operations
        cfgFile += u'\t<page id="1" name="%s">\n' % pages[1].GetName()
        cfgFile += self._renaming_ops_to_xml()
        cfgFile += "\t</page>\n</configuration>\n"

        return cfgFile
示例#4
0
    def __date_time(self, op, path, operation):
        dateTimePanel = operation.dateTimePanel
        dateTime = dateTimePanel.dateTime
        dateTime[1] = dateTimePanel.dateTestDisplay.GetLabel()
        dateTime[2] = dateTimePanel.timeTestDisplay.GetLabel()

        # user specified date/time
        if not dateTime[0]:
            return dateTime[op + 1]

        # get date/time from item
        else:
            itemTimeType = dateTimePanel.itemTimeType.GetSelection()
            if itemTimeType == 0:
                try:
                    itemDateTime = time.localtime(os.path.getctime(path))
                except WindowsError:
                    return ''
            elif itemTimeType == 1:
                try:
                    itemDateTime = time.localtime(os.path.getmtime(path))
                except WindowsError:
                    return ''
            elif itemTimeType == 2:
                try:
                    itemDateTime = time.localtime(os.path.getatime(path))
                except WindowsError:
                    return ''
            elif itemTimeType == 3:
                itemDateTime = self.__get_exif_date(path,
                                                    'EXIF DateTimeOriginal')
            elif itemTimeType == 4:
                itemDateTime = self.__get_exif_date(path, 'Image DateTime')

            if itemDateTime:
                return utils.udate(main, dateTime[op + 1], itemDateTime)
            else:
                return ''