# Copyright (C) 2010 One Laptop Per Child # # Author: Sayamindu Dasgupta # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. from gettext import gettext import locale import os import struct import sys import dateutil.parser import time _MO_BIG_ENDIAN = 0xde120495 _MO_LITTLE_ENDIAN = 0x950412de def _read_bin(handle, format_string, byte_count): read_bytes = handle.read(byte_count) return_value = struct.unpack(format_string, read_bytes) if len(return_value) == 1: return return_value[0] else: return return_value def _extract_header(file_path): header = '' handle = open(file_path, 'rb') magic_number = _read_bin(handle, '