code stringlengths 1 1.72M | language stringclasses 1 value |
|---|---|
from sys import stdin
print len(stdin.readline().strip())
| Python |
from itertools import product
from math import *
def issqrt(n):
s = int(floor(sqrt(n)))
return s*s == n
aabb = [a*1100+b*11 for a,b in product(range(1,10),range(10))]
print ' '.join(map(str, filter(issqrt, aabb)))
| Python |
from sys import stdin
a = map(int, stdin.readline().strip().split())
print "%d %d %.3lf" % (min(a), max(a), float(sum(a)) / len(a))
| Python |
from sys import stdin
def cycle(n):
if n == 1: return 0
elif n % 2 == 1: return cycle(n*3+1) + 1
else: return cycle(n/2) + 1
n = int(stdin.readline().strip())
print cycle(n)
| Python |
from sys import stdin
n = int(stdin.readline().strip())
count = n*2-1
for i in range(n):
print ' '*i + '#'*count
count -= 2
| Python |
for abc in range(123, 329):
big = str(abc) + str(abc*2) + str(abc*3)
if(''.join(sorted(big)) == '123456789'): print abc, abc*2, abc*3
| Python |
from sys import stdin
n, m = map(int, stdin.readline().strip().split())
print "%.5lf" % sum([1.0/i/i for i in range(n,m+1)])
| Python |
from sys import stdin
data = map(int, stdin.readline().strip().split())
n, m = data[0], data[-1]
data = data[1:-1]
print len(filter(lambda x: x < m, data))
| Python |
from sys import stdin
def solve(a, b, c):
for i in range(10, 101):
if i % 3 == a and i % 5 == b and i % 7 == c:
print i
return
print 'No answer'
a, b, c = map(int, stdin.readline().strip().split())
solve(a, b, c)
| Python |
from itertools import product
sol = [a*100+b*10+c for a,b,c in product(range(1,10), range(10), range(10)) if a**3+b**3+c**3 == a*100+b*10+c]
print '\n'.join(map(str, sol))
| Python |
from sys import stdin
from math import *
n = int(stdin.readline().strip())
print sum(map(factorial, range(1,n+1))) % (10**6)
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import serial
import time
import sys
import os
if len(sys.argv) == 3:
avrdude_parameter1 = "-c stk500v2 -p m8 -v -v -P "+sys.argv[1]
avrdude_parameter2 = " -e -U "+sys.argv[2]
avrdude_command = "avrdude "+avrdude_parameter1+avrdude_parameter2
os.system('cls')
print
print"***************************************************"
print"* *"
print"* *"
print"* Martinez V3 Flasher *"
print"* *"
print"* IM Coref und Martinez *"
print"* *"
print"* *"
print"***************************************************"
print
print
for x in range(2, 6):
#os.system('cls')
print"Setting ArduinoUSBLinker to Pin PD%d" % (x)
ser = serial.Serial(sys.argv[1],19200) #öffnet die serielle Schnittstelle mit 19200Baud
pinChange = 16+x
#print pinChange # nur zum Testen an der Shell
ser.write('$M<P')+pinChange #setzt den Arduino OutputPin e.g. $M<P18 wäre PD2
ser.write('$M<W') # schreibt den aktuellen Wert des o.g. Pins ins EEPROM
ser.close() # schliesst die serielle Schnittstelle
time.sleep(2) # warte 2 sec
print "Flashing MCU%d" % (x-1)
print avrdude_command # nur zum Testen an der Shell
#os.system (avrdude_command) #auskommentieren, wenn im Regelbetrieb. Gibt den avrdude-Befehl an die Shell
print
time.sleep(5) # warte 5sec
os.system('cls')
print" MartinezV3 ist jetzt betriebsbereit!"
#print sys.argv[1],sys.argv[2]
else:
print
print "Usage : "
print " Please specify a port and file "
print " e.g.:"
print
print " %s /dev/ttyUSB0 martinez.hex" % sys.argv[0]
| Python |
#!/usr/bin/python
import os
def main():
lists = [
"ISODrivers/Galaxy/galaxy.prx",
"ISODrivers/March33/march33.prx",
"ISODrivers/March33/march33_620.prx",
"ISODrivers/Inferno/inferno.prx",
"Popcorn/popcorn.prx",
"Satelite/satelite.prx",
"Stargate/stargate.prx",
"SystemControl/systemctrl.prx",
"contrib/usbdevice.prx",
"Vshctrl/vshctrl.prx",
"Recovery/recovery.prx",
]
for fn in lists:
path = "../" + fn
name=os.path.split(fn)[-1]
name=os.path.splitext(name)[0]
ret = os.system("bin2c %s %s.h %s"%(path, name, name))
assert(ret == 0)
if __name__ == "__main__":
main()
| Python |
#!/usr/bin/python
class FakeTime:
def time(self):
return 1225856967.109
import os, gzip, StringIO
gzip.time = FakeTime()
def create_gzip(input, output):
f_in=open(input, 'rb')
temp=StringIO.StringIO()
f=gzip.GzipFile(fileobj=temp, mode='wb')
f.writelines(f_in)
f.close()
f_in.close()
fout=open(output, 'wb')
temp.seek(0)
fout.writelines(temp)
fout.close()
temp.close()
def cleanup():
del_list = [
"installer.prx.gz",
"Rebootex.prx.gz",
]
for file in del_list:
try:
os.remove(file)
except OSError:
pass
def main():
create_gzip("../../Installer/installer.prx", "installer.prx.gz")
create_gzip("../../Rebootex/Rebootex.prx", "Rebootex.prx.gz")
os.system("bin2c installer.prx.gz installer.h installer")
os.system("bin2c Rebootex.prx.gz Rebootex_prx.h Rebootex_prx")
cleanup()
if __name__ == "__main__":
main()
| Python |
#!/usr/bin/python
from hashlib import *
import sys, struct
def sha512(psid):
if len(psid) != 16:
return "".encode()
for i in range(512):
psid = sha1(psid).digest()
return psid
def get_psid(str):
if len(str) != 32:
return "".encode()
b = "".encode()
for i in range(0, len(str), 2):
b += struct.pack('B', int(str[i] + str[i+1], 16))
return b
def main():
if len(sys.argv) < 2:
print ("Usage: sha512.py psid")
exit(0)
psid = get_psid(sys.argv[1])
xhash = sha512(psid)
if len(xhash) == 0:
print ("wrong PSID")
exit(0)
print ("{\n\t"),
for i in range(len(xhash)):
if i != 0 and i % 8 == 0:
print ("\n\t"),
print ("0x%02X, "%(struct.unpack('B', xhash[i])[0])),
print ("\n},")
if __name__ == "__main__":
main()
| Python |
#!/usr/bin/python
import sys, hashlib
def toNID(name):
hashstr = hashlib.sha1(name.encode()).hexdigest().upper()
return "0x" + hashstr[6:8] + hashstr[4:6] + hashstr[2:4] + hashstr[0:2]
if __name__ == "__main__":
assert(toNID("sceKernelCpuSuspendIntr") == "0x092968F4")
for name in sys.argv[1:]:
print ("%s: %s"%(name, toNID(name)))
| Python |
#!/usr/bin/python
"""
pspbtcnf_editor: An script that add modules from pspbtcnf
"""
import sys, os, re
from getopt import *
from struct import *
BTCNF_MAGIC=0x0F803001
verbose = False
def print_usage():
print ("%s: pspbtcnf.bin [-o output.bin] [-a add_module_name:before_module_name:flag]" %(os.path.split(sys.argv[0]))[-1])
def replace_binary(data, offset, newdata):
newdata = data[0:offset] + newdata + data[offset+len(newdata):]
assert(len(data) == len(newdata))
return newdata
def dump_binary(data, offset, size):
newdata = data[offset:offset+size]
assert(len(newdata) == size)
return newdata
def dump_binary_str(data, offset):
ch = data[offset]
tmp = b''
while ch != 0:
tmp += pack('b', ch)
offset += 1
ch = data[offset]
return tmp.decode()
def add_prx_to_bootconf(srcfn, before_modname, modname, modflag):
"Return new bootconf data"
fn=open(srcfn, "rb")
bootconf = fn.read()
fn.close()
if len(bootconf) < 64:
raise Exception("Bad bootconf")
signature, devkit, modestart, nmodes, modulestart, nmodules, modnamestart, modnameend = unpack('LL8xLL8xLL8xLL8x', bootconf[:64])
if verbose:
print ("Devkit: 0x%08X"%(devkit))
print ("modestart: 0x%08X"%(modestart))
print ("nmodes: %d"%(nmodes))
print ("modulestart: 0x%08X"%(modulestart))
print ("nmodules: 0x%08X"%(nmodules))
print ("modnamestart: 0x%08X"%(modnamestart))
print ("modnameend: 0x%08X"%(modnameend))
if signature != BTCNF_MAGIC or nmodules <= 0 or nmodes <= 0:
raise Exception("Bad bootconf")
bootconf = bootconf + modname.encode() + b'\0'
modnameend += len(modname) + 1
i=0
while i < nmodules:
module_path, module_flags = unpack('L4xL4x16x', bootconf[modulestart+i*32:modulestart+(i+1)*32])
module_name = dump_binary_str(bootconf, modnamestart+module_path)
if verbose:
print ("[%02d]: Module path: %s flag: 0x%08X"%(i, module_name, module_flags))
if before_modname == module_name:
break
i+=1
if i >= nmodules:
raise Exception("module %s not found"%(before_modname))
module_path = modnameend - len(modname) - 1 - modnamestart
module_flag = 0x80010000 | (modflag & 0xFFFF)
newmod = dump_binary(bootconf, modulestart+i*32, 32)
newmod = replace_binary(newmod, 0, pack('L', module_path))
newmod = replace_binary(newmod, 8, pack('L', module_flag))
bootconf = bootconf[0:modulestart+i*32] + newmod + bootconf[modulestart+i*32:]
nmodules+=1
bootconf = replace_binary(bootconf, 0x24, pack('L', nmodules))
modnamestart += 32
bootconf = replace_binary(bootconf, 0x30, pack('L', modnamestart))
modnameend += 32
bootconf = replace_binary(bootconf, 0x34, pack('L', modnameend))
i = 0
while i < nmodes:
num = unpack('H', bootconf[modestart+i*32:modestart+i*32+2])[0]
num += 1
bootconf = replace_binary(bootconf, modestart + i * 32, pack('H', num))
i += 1
return bootconf
def write_file(output_fn, data):
fn = open(output_fn, "wb")
fn.write(data)
fn.close()
def main():
global verbose
try:
optlist, args = gnu_getopt(sys.argv, "a:o:vh")
except GetoptError as err:
print(err)
print_usage()
sys.exit(1)
# default configure
verbose = False
dst_filename = "-"
add_module = ""
for o, a in optlist:
if o == "-v":
verbose = True
elif o == "-h":
print_usage()
sys.exit()
elif o == "-o":
dst_filename = a
elif o == "-a":
add_module = a
else:
assert False, "unhandled option"
if verbose:
print (optlist, args)
if len(args) < 2:
print ("Missing input pspbtcnf.bin")
sys.exit(1)
src_filename = args[1]
if verbose:
print ("src_filename: " + src_filename)
print ("dst_filename: " + dst_filename)
# check add_module
if add_module != "":
t = (re.split(":", add_module, re.I))
if len(t) != 3:
print ("Bad add_module input")
sys.exit(1)
add_module, before_module, add_module_flag = (re.split(":", add_module, re.I))
if verbose:
print ("add_module: " + add_module)
print ("before_module: " + before_module)
print ("add_module_flag: " + add_module_flag)
if add_module != "":
result = add_prx_to_bootconf(src_filename, before_module, add_module, int(add_module_flag, 16))
if dst_filename == "-":
# print("Bootconf result:")
# print(result)
pass
else:
write_file(dst_filename, result)
if __name__ == "__main__":
main()
| Python |
#!/usr/bin/python
class FakeTime:
def time(self):
return 1225856967.109
import sys, os, struct, gzip, hashlib, StringIO
gzip.time = FakeTime()
def binary_replace(data, newdata, offset):
return data[0:offset] + newdata + data[offset+len(newdata):]
def prx_compress(output, hdr, input, mod_name="", mod_attr=0xFFFFFFFF):
a=open(hdr, "rb")
fileheader = a.read();
a.close()
a=open(input, "rb")
elf = a.read(4);
a.close()
if (elf != '\x7fELF'.encode()):
print ("not a ELF/PRX file!")
return -1
uncompsize = os.stat(input).st_size
f_in=open(input, 'rb')
temp=StringIO.StringIO()
f=gzip.GzipFile(fileobj=temp, mode='wb')
f.writelines(f_in)
f.close()
f_in.close()
prx=temp.getvalue()
temp.close()
digest=hashlib.md5(prx).digest()
filesize = len(fileheader) + len(prx)
if mod_name != "":
if len(mod_name) < 28:
mod_name += "\x00" * (28-len(mod_name))
else:
mod_name = mod_name[0:28]
fileheader = binary_replace(fileheader, mod_name.encode(), 0xA)
if mod_attr != 0xFFFFFFFF:
fileheader = binary_replace(fileheader, struct.pack('H', mod_attr), 0x4)
fileheader = binary_replace(fileheader, struct.pack('L', uncompsize), 0x28)
fileheader = binary_replace(fileheader, struct.pack('L', filesize), 0x2c)
fileheader = binary_replace(fileheader, struct.pack('L', len(prx)), 0xb0)
fileheader = binary_replace(fileheader, digest, 0x140)
a=open(output, "wb")
assert(len(fileheader) == 0x150)
a.write(fileheader)
a.write(prx)
a.close()
try:
os.remove("tmp.gz")
except OSError:
pass
return 0
def main():
if len(sys.argv) < 4:
print ("Usage: %s outfile prxhdr infile [modname] [modattr]\n"%(sys.argv[0]))
exit(-1)
if len(sys.argv) < 5:
prx_compress(sys.argv[1], sys.argv[2], sys.argv[3])
elif len(sys.argv) < 6:
prx_compress(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
else:
prx_compress(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], int(sys.argv[5], 16))
if __name__ == "__main__":
main()
| Python |
#coding:utf8
'''
google appengine album
author: smallfish <smallfish.xy@gmail.com>
create: 2009-08-04
'''
import os
import wsgiref.handlers
import logging
import web
from mako.template import Template
from mako.lookup import TemplateLookup
import google.appengine.ext import db
import google.appengine.api import users
BASE_DIR = os.path.dirname(__file__)
TEMP_DIR = BASE_DIR + '/templates'
MAKO_LOOKUP = TemplateLookup(directories = [TEMP_DIR])
def render(template_name, **kargs):
template = MAKO_LOOKUP.get_template(template_name)
return template.render(**kargs)
class AlbumType(db.Model):
name = db.StringProperty()
size = db.IntegerProperty()
date = db.DateTimeProperty(auto_now_add=True)
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _checkconn.py: Check connect to a specified server.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
from PyQt4 import QtCore
import sys
sys.path.append("..")
from util import CommonUtil
class QSubChkConnection(QtCore.QThread):
"""
QSubChkConnection is a subclass of :class:`PyQt4.QtCore.QThread`. This
class contains methods to check the network connection with a specified
server.
.. inheritance-diagram:: gui._checkconn.QSubChkConnection
:parts: 1
.. note:: The instance of this class should be created in an individual
thread. And an instance of class should be set as :attr:`parent`
here.
:ivar PyQt4.QtCore.pyqtSignal trigger: An instance of
:class:`PyQt4.QtCore.pyqtSignal` to emit signal to the main dialog
which indicates current status.
.. note:: The signal :attr:`trigger` should be a integer flag:
====== ========
signal Status
====== ========
-1 Checking
0 Failed
1 OK
====== ========
"""
trigger = QtCore.pyqtSignal(int)
def __init__(self, parent):
"""
Initialize a new instance of this class. Retrieve mirror settings from
the main dialog to check the connection.
:param parent: An instance of :class:`~gui.qdialog_d.QDialogDaemon`
class to fetch settings from.
:type parent: :class:`~gui.qdialog_d.QDialogDaemon`
.. warning:: :attr:`parent` MUST NOT be set as `None`.
"""
super(QSubChkConnection, self).__init__(parent)
self.link = parent.mirrors[parent.mirror_id]["test_url"]
def run(self):
"""
Start operations to check the network connection with a specified
server.
"""
self.trigger.emit(-1)
status = CommonUtil.check_connection(self.link)
self.trigger.emit(status) | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _update.py: Fetch the latest data file.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
import socket
import urllib
from PyQt4 import QtCore
from util_ui import _translate
import sys
sys.path.append("..")
from util import CommonUtil
class QSubFetchUpdate(QtCore.QThread):
"""
QSubFetchUpdate is a subclass of :class:`PyQt4.QtCore.QThread`. This
class contains methods to retrieve the latest hosts data file from a
server.
.. inheritance-diagram:: gui._update.QSubFetchUpdate
:parts: 1
.. note:: The instance of this class should be created in an individual
thread. And an instance of class should be set as :attr:`parent`
here.
:ivar PyQt4.QtCore.pyqtSignal prog_trigger: An instance of
:class:`PyQt4.QtCore.pyqtSignal` to emit signal to the main dialog
which indicates current downloading progress.
.. note:: The signal :attr:`prog_trigger` should be a tuple of
(`progress`, message`):
* progress(`int`): An number between `0` and `100` which indicates
current download progress.
* message(`str`): Message to be displayed to users on the progress
bar.
:ivar PyQt4.QtCore.pyqtSignal finish_trigger: An instance of
:class:`PyQt4.QtCore.pyqtSignal` to emit signal to the main dialog
which notifies if current operation is finished.
.. note:: The signal :attr:`finish_trigger` should be a tuple of
(`refresh_flag`, error_flag`):
* refresh_flag(`int`): An flag indicating whether to refresh
function list in the main dialog or not.
============ ==============
refresh_flag Operation
============ ==============
1 Refresh
0 Do not refresh
============ ==============
* error_flag(`int`): An flag indicating whether the downloading
progress is successfully finished or not.
========== =======
error_flag Status
========== =======
1 Error
0 Success
========== =======
.. seealso:: Method :meth:`~gui.qdialog_d.QDialogDaemon.finish_fetch`
in :class:`~gui.qdialog_d.QDialogDaemon` class.
"""
prog_trigger = QtCore.pyqtSignal(int, str)
finish_trigger = QtCore.pyqtSignal(int, int)
def __init__(self, parent):
"""
Initialize a new instance of this class. Fetch download settings from
the main dialog to retrieve new hosts data file.
:param parent: An instance of :class:`~gui.qdialog_d.QDialogDaemon`
class to fetch settings from.
:type parent: :class:`~gui.qdialog_d.QDialogDaemon`
.. warning:: :attr:`parent` MUST NOT be set as `None`.
"""
super(QSubFetchUpdate, self).__init__(parent)
self.url = parent.mirrors[parent.mirror_id]["update"] + \
parent.filename
self.path = "./" + parent.filename
self.tmp_path = self.path + ".download"
self.filesize = parent._update["size"]
def run(self):
"""
Start operations to retrieve the new hosts data file.
"""
self.prog_trigger.emit(0, unicode(_translate(
"Util", "Connecting...", None)))
self.fetch_file()
def fetch_file(self):
"""
Retrieve the latest data file to a specified local path with a url.
"""
socket.setdefaulttimeout(10)
try:
urllib.urlretrieve(self.url, self.tmp_path, self.set_progress)
self.replace_old()
self.finish_trigger.emit(1, 0)
except:
self.finish_trigger.emit(1, 1)
def set_progress(self, done, block, total):
"""
Send message to the main dialog to set the progress bar.
:param done: Block count of packaged retrieved.
:type done: int
:param block: Block size of the data pack retrieved.
:type block: int
:param total: Total size of the hosts data file.
:type total: int
"""
done = done * block
if total <= 0:
total = self.filesize
prog = 100 * done / total
done = CommonUtil.convert_size(done)
total = CommonUtil.convert_size(total)
text = unicode(_translate(
"Util", "Downloading: %s / %s", None)) % (done, total)
self.prog_trigger.emit(prog, text)
def replace_old(self):
"""
Replace the old hosts data file with the new one.
"""
if os.path.isfile(self.path):
os.remove(self.path)
os.rename(self.tmp_path, self.path) | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# language.py : Language utilities used in GUI module.
#
# Copyleft (C) 2013 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import locale
class LangUtil(object):
"""
LangUtil contains a set of language tools for Hosts Setup Utility to
use.
.. note:: All methods from this class are declared as `classmethod`.
:ivar dict language: Supported localized language name for a specified
locale tag.
The default declaration of :attr:`language` is::
language = {"de_DE": u"Deutsch",
"en_US": u"English",
"ja_JP": u"日本語",
"ko_KR": u"한글",
"ru_RU": u"Русский",
"zh_CN": u"简体中文",
"zh_TW": u"正體中文", }
.. note:: The keys of :attr:`language` are typically in the format of \
IETF language tag. For example: en_US, en_GB, etc.
.. note:: The Hosts Setup Utility would check whether the language
files exist in `gui/lang/` folder automatically while loading GUI.
If not, the language related wouldn't be available in language
selection combobox.
"""
language = {"de_DE": u"Deutsch",
"en_US": u"English",
"ja_JP": u"日本語",
"ko_KR": u"한글",
"ru_RU": u"Русский",
"zh_CN": u"简体中文",
"zh_TW": u"正體中文", }
@classmethod
def get_locale(cls):
"""
Retrieve the default locale tag of current operating system.
.. note:: This is a `classmethod`.
:return: Default locale tag of current operating system. If the locale
is not found in cls.dictionary dictionary, the return value
"en_US" as default.
:rtype: str
"""
lc = locale.getdefaultlocale()[0]
if lc is None:
lc = "en_US"
return lc
@classmethod
def get_language_by_locale(cls, l_locale):
"""
Return the name of a specified language by :attr:`l_locale`.
.. note:: This is a `classmethod`.
:param l_locale: Locale tag of a specified language.
:type l_locale: str
:return: Localized name of a specified language.
:type: str
"""
try:
return cls.language[l_locale]
except KeyError:
return cls.language["en_US"]
@classmethod
def get_locale_by_language(cls, l_lang):
"""
Get the locale string connecting with a language specified by
:attr:`l_lang`.
.. note:: This is a `classmethod`.
:param l_lang: Localized name of a specified language.
:type l_lang: unicode
:return: Locale tag of a specified language.
:rtype: str
"""
for locl, lang in cls.language.items():
if l_lang == lang:
return locl
return "en_US"
| Python |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '../pyqt\util_ui.ui'
#
# Created: Wed Jan 22 13:03:09 2014
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Util(object):
def setupUi(self, Util):
Util.setObjectName(_fromUtf8("Util"))
Util.setEnabled(True)
Util.resize(640, 420)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Util.sizePolicy().hasHeightForWidth())
Util.setSizePolicy(sizePolicy)
Util.setMinimumSize(QtCore.QSize(640, 420))
Util.setMaximumSize(QtCore.QSize(640, 420))
Util.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/icon/res/img/icons/utl_icon@256x256.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Util.setWindowIcon(icon)
Util.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
Util.setSizeGripEnabled(False)
Util.setModal(False)
self.mainFrame = QtGui.QFrame(Util)
self.mainFrame.setGeometry(QtCore.QRect(0, 40, 640, 351))
self.mainFrame.setFrameShape(QtGui.QFrame.StyledPanel)
self.mainFrame.setFrameShadow(QtGui.QFrame.Raised)
self.mainFrame.setObjectName(_fromUtf8("mainFrame"))
self.ConfigBox = QtGui.QGroupBox(self.mainFrame)
self.ConfigBox.setGeometry(QtCore.QRect(10, 20, 240, 90))
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.ConfigBox.sizePolicy().hasHeightForWidth())
self.ConfigBox.setSizePolicy(sizePolicy)
self.ConfigBox.setObjectName(_fromUtf8("ConfigBox"))
self.layoutWidget = QtGui.QWidget(self.ConfigBox)
self.layoutWidget.setGeometry(QtCore.QRect(10, 25, 221, 50))
self.layoutWidget.setObjectName(_fromUtf8("layoutWidget"))
self.configLayout = QtGui.QGridLayout(self.layoutWidget)
self.configLayout.setMargin(0)
self.configLayout.setObjectName(_fromUtf8("configLayout"))
self.labelIP = QtGui.QLabel(self.layoutWidget)
self.labelIP.setObjectName(_fromUtf8("labelIP"))
self.configLayout.addWidget(self.labelIP, 0, 0, 1, 1)
self.SelectMirror = QtGui.QComboBox(self.layoutWidget)
self.SelectMirror.setObjectName(_fromUtf8("SelectMirror"))
self.configLayout.addWidget(self.SelectMirror, 0, 1, 1, 1)
self.labelMirror = QtGui.QLabel(self.layoutWidget)
self.labelMirror.setObjectName(_fromUtf8("labelMirror"))
self.configLayout.addWidget(self.labelMirror, 1, 0, 1, 1)
self.SelectIP = QtGui.QComboBox(self.layoutWidget)
self.SelectIP.setObjectName(_fromUtf8("SelectIP"))
self.SelectIP.addItem(_fromUtf8(""))
self.SelectIP.setItemText(0, _fromUtf8("IPv4"))
self.SelectIP.addItem(_fromUtf8(""))
self.SelectIP.setItemText(1, _fromUtf8("IPv6"))
self.configLayout.addWidget(self.SelectIP, 1, 1, 1, 1)
self.StatusBox = QtGui.QGroupBox(self.mainFrame)
self.StatusBox.setGeometry(QtCore.QRect(10, 120, 240, 90))
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.StatusBox.sizePolicy().hasHeightForWidth())
self.StatusBox.setSizePolicy(sizePolicy)
self.StatusBox.setObjectName(_fromUtf8("StatusBox"))
self.layoutWidget1 = QtGui.QWidget(self.StatusBox)
self.layoutWidget1.setGeometry(QtCore.QRect(10, 30, 221, 40))
self.layoutWidget1.setObjectName(_fromUtf8("layoutWidget1"))
self.StatusLayout = QtGui.QGridLayout(self.layoutWidget1)
self.StatusLayout.setMargin(0)
self.StatusLayout.setObjectName(_fromUtf8("StatusLayout"))
self.labelConn = QtGui.QLabel(self.layoutWidget1)
self.labelConn.setObjectName(_fromUtf8("labelConn"))
self.StatusLayout.addWidget(self.labelConn, 0, 0, 1, 1)
self.labelConnStat = QtGui.QLabel(self.layoutWidget1)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.labelConnStat.setFont(font)
self.labelConnStat.setObjectName(_fromUtf8("labelConnStat"))
self.StatusLayout.addWidget(self.labelConnStat, 0, 1, 1, 1)
self.labelOS = QtGui.QLabel(self.layoutWidget1)
self.labelOS.setObjectName(_fromUtf8("labelOS"))
self.StatusLayout.addWidget(self.labelOS, 1, 0, 1, 1)
self.labelOSStat = QtGui.QLabel(self.layoutWidget1)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.labelOSStat.setFont(font)
self.labelOSStat.setObjectName(_fromUtf8("labelOSStat"))
self.StatusLayout.addWidget(self.labelOSStat, 1, 1, 1, 1)
self.InfoBox = QtGui.QGroupBox(self.mainFrame)
self.InfoBox.setGeometry(QtCore.QRect(10, 220, 240, 90))
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.InfoBox.sizePolicy().hasHeightForWidth())
self.InfoBox.setSizePolicy(sizePolicy)
self.InfoBox.setObjectName(_fromUtf8("InfoBox"))
self.layoutWidget2 = QtGui.QWidget(self.InfoBox)
self.layoutWidget2.setGeometry(QtCore.QRect(10, 20, 221, 59))
self.layoutWidget2.setObjectName(_fromUtf8("layoutWidget2"))
self.InfoLayout = QtGui.QGridLayout(self.layoutWidget2)
self.InfoLayout.setMargin(0)
self.InfoLayout.setObjectName(_fromUtf8("InfoLayout"))
self.labelVersion = QtGui.QLabel(self.layoutWidget2)
self.labelVersion.setObjectName(_fromUtf8("labelVersion"))
self.InfoLayout.addWidget(self.labelVersion, 0, 0, 1, 1)
self.labelVersionData = QtGui.QLabel(self.layoutWidget2)
self.labelVersionData.setObjectName(_fromUtf8("labelVersionData"))
self.InfoLayout.addWidget(self.labelVersionData, 0, 1, 1, 1)
self.labelRelease = QtGui.QLabel(self.layoutWidget2)
self.labelRelease.setObjectName(_fromUtf8("labelRelease"))
self.InfoLayout.addWidget(self.labelRelease, 1, 0, 1, 1)
self.labelReleaseData = QtGui.QLabel(self.layoutWidget2)
self.labelReleaseData.setObjectName(_fromUtf8("labelReleaseData"))
self.InfoLayout.addWidget(self.labelReleaseData, 1, 1, 1, 1)
self.labelLatest = QtGui.QLabel(self.layoutWidget2)
self.labelLatest.setObjectName(_fromUtf8("labelLatest"))
self.InfoLayout.addWidget(self.labelLatest, 2, 0, 1, 1)
self.labelLatestData = QtGui.QLabel(self.layoutWidget2)
self.labelLatestData.setObjectName(_fromUtf8("labelLatestData"))
self.InfoLayout.addWidget(self.labelLatestData, 2, 1, 1, 1)
self.FunctionsBox = QtGui.QGroupBox(self.mainFrame)
self.FunctionsBox.setGeometry(QtCore.QRect(260, 20, 250, 290))
self.FunctionsBox.setObjectName(_fromUtf8("FunctionsBox"))
self.Functionlist = QtGui.QListWidget(self.FunctionsBox)
self.Functionlist.setGeometry(QtCore.QRect(10, 20, 230, 260))
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.Functionlist.sizePolicy().hasHeightForWidth())
self.Functionlist.setSizePolicy(sizePolicy)
self.Functionlist.setObjectName(_fromUtf8("Functionlist"))
self.frame = QtGui.QFrame(self.mainFrame)
self.frame.setGeometry(QtCore.QRect(520, 30, 110, 280))
self.frame.setFrameShape(QtGui.QFrame.NoFrame)
self.frame.setFrameShadow(QtGui.QFrame.Raised)
self.frame.setLineWidth(0)
self.frame.setObjectName(_fromUtf8("frame"))
self.ButtonBackup = QtGui.QPushButton(self.frame)
self.ButtonBackup.setGeometry(QtCore.QRect(0, 10, 48, 48))
self.ButtonBackup.setText(_fromUtf8(""))
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_backup.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_backup_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonBackup.setIcon(icon1)
self.ButtonBackup.setIconSize(QtCore.QSize(32, 32))
self.ButtonBackup.setObjectName(_fromUtf8("ButtonBackup"))
self.ButtonUpdate = QtGui.QPushButton(self.frame)
self.ButtonUpdate.setGeometry(QtCore.QRect(60, 70, 48, 48))
self.ButtonUpdate.setText(_fromUtf8(""))
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_download.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_download_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonUpdate.setIcon(icon2)
self.ButtonUpdate.setIconSize(QtCore.QSize(32, 32))
self.ButtonUpdate.setObjectName(_fromUtf8("ButtonUpdate"))
self.ButtonRestore = QtGui.QPushButton(self.frame)
self.ButtonRestore.setGeometry(QtCore.QRect(60, 10, 48, 48))
self.ButtonRestore.setText(_fromUtf8(""))
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_restore.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_restore_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonRestore.setIcon(icon3)
self.ButtonRestore.setIconSize(QtCore.QSize(32, 32))
self.ButtonRestore.setObjectName(_fromUtf8("ButtonRestore"))
self.ButtonApply = QtGui.QPushButton(self.frame)
self.ButtonApply.setGeometry(QtCore.QRect(0, 220, 48, 48))
self.ButtonApply.setText(_fromUtf8(""))
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_apply.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_apply_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonApply.setIcon(icon4)
self.ButtonApply.setIconSize(QtCore.QSize(32, 32))
self.ButtonApply.setObjectName(_fromUtf8("ButtonApply"))
self.ButtonExit = QtGui.QPushButton(self.frame)
self.ButtonExit.setGeometry(QtCore.QRect(60, 220, 48, 48))
self.ButtonExit.setText(_fromUtf8(""))
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_exit.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon5.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_exit_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonExit.setIcon(icon5)
self.ButtonExit.setIconSize(QtCore.QSize(32, 32))
self.ButtonExit.setObjectName(_fromUtf8("ButtonExit"))
self.ButtonCheck = QtGui.QPushButton(self.frame)
self.ButtonCheck.setGeometry(QtCore.QRect(0, 70, 48, 48))
self.ButtonCheck.setText(_fromUtf8(""))
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_update.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_update_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonCheck.setIcon(icon6)
self.ButtonCheck.setIconSize(QtCore.QSize(32, 32))
self.ButtonCheck.setObjectName(_fromUtf8("ButtonCheck"))
self.ButtonANSI = QtGui.QPushButton(self.frame)
self.ButtonANSI.setGeometry(QtCore.QRect(0, 160, 48, 48))
self.ButtonANSI.setText(_fromUtf8(""))
icon7 = QtGui.QIcon()
icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_ansi.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_ansi_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonANSI.setIcon(icon7)
self.ButtonANSI.setIconSize(QtCore.QSize(32, 32))
self.ButtonANSI.setObjectName(_fromUtf8("ButtonANSI"))
self.ButtonUTF = QtGui.QPushButton(self.frame)
self.ButtonUTF.setGeometry(QtCore.QRect(60, 160, 48, 48))
self.ButtonUTF.setText(_fromUtf8(""))
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_utf8.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/buttons/res/img/buttons/button_utf8_disabled.png")), QtGui.QIcon.Disabled, QtGui.QIcon.Off)
self.ButtonUTF.setIcon(icon8)
self.ButtonUTF.setIconSize(QtCore.QSize(32, 32))
self.ButtonUTF.setObjectName(_fromUtf8("ButtonUTF"))
self.SelectLang = QtGui.QComboBox(self.mainFrame)
self.SelectLang.setGeometry(QtCore.QRect(520, 320, 108, 25))
self.SelectLang.setObjectName(_fromUtf8("SelectLang"))
self.Prog = QtGui.QProgressBar(self.mainFrame)
self.Prog.setGeometry(QtCore.QRect(10, 320, 500, 25))
self.Prog.setAlignment(QtCore.Qt.AlignCenter)
self.Prog.setTextVisible(True)
self.Prog.setInvertedAppearance(False)
self.Prog.setObjectName(_fromUtf8("Prog"))
self.TitleLabel = QtGui.QLabel(Util)
self.TitleLabel.setGeometry(QtCore.QRect(20, 20, 250, 25))
self.TitleLabel.setObjectName(_fromUtf8("TitleLabel"))
self.Copyright = QtGui.QLabel(Util)
self.Copyright.setGeometry(QtCore.QRect(330, 390, 300, 16))
self.Copyright.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.Copyright.setObjectName(_fromUtf8("Copyright"))
self.label = QtGui.QLabel(Util)
self.label.setGeometry(QtCore.QRect(10, 390, 150, 16))
self.label.setObjectName(_fromUtf8("label"))
self.VersionLabel = QtGui.QLabel(Util)
self.VersionLabel.setGeometry(QtCore.QRect(380, 20, 250, 25))
self.VersionLabel.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.VersionLabel.setObjectName(_fromUtf8("VersionLabel"))
self.labelIP.setBuddy(self.SelectMirror)
self.labelMirror.setBuddy(self.SelectIP)
self.retranslateUi(Util)
QtCore.QObject.connect(self.ButtonExit, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.close)
QtCore.QObject.connect(self.SelectIP, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), Util.on_IPVersion_changed)
QtCore.QObject.connect(self.SelectMirror, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), Util.on_Mirror_changed)
QtCore.QObject.connect(self.Functionlist, QtCore.SIGNAL(_fromUtf8("itemChanged(QListWidgetItem*)")), Util.on_Selection_changed)
QtCore.QObject.connect(self.ButtonApply, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.on_MakeHosts_clicked)
QtCore.QObject.connect(self.ButtonBackup, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.on_Backup_clicked)
QtCore.QObject.connect(self.ButtonRestore, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.on_Restore_clicked)
QtCore.QObject.connect(self.ButtonCheck, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.on_CheckUpdate_clicked)
QtCore.QObject.connect(self.ButtonUpdate, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.on_FetchUpdate_clicked)
QtCore.QObject.connect(self.SelectLang, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(QString)")), Util.on_Lang_changed)
QtCore.QObject.connect(self.ButtonANSI, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.on_MakeANSI_clicked)
QtCore.QObject.connect(self.ButtonUTF, QtCore.SIGNAL(_fromUtf8("clicked()")), Util.on_MakeUTF8_clicked)
QtCore.QObject.connect(self.Copyright, QtCore.SIGNAL(_fromUtf8("linkActivated(QString)")), Util.on_LinkActivated)
QtCore.QMetaObject.connectSlotsByName(Util)
Util.setTabOrder(self.SelectMirror, self.SelectIP)
Util.setTabOrder(self.SelectIP, self.Functionlist)
Util.setTabOrder(self.Functionlist, self.ButtonApply)
Util.setTabOrder(self.ButtonApply, self.ButtonExit)
Util.setTabOrder(self.ButtonExit, self.ButtonCheck)
Util.setTabOrder(self.ButtonCheck, self.ButtonUpdate)
Util.setTabOrder(self.ButtonUpdate, self.ButtonBackup)
Util.setTabOrder(self.ButtonBackup, self.ButtonRestore)
Util.setTabOrder(self.ButtonRestore, self.ButtonANSI)
Util.setTabOrder(self.ButtonANSI, self.ButtonUTF)
Util.setTabOrder(self.ButtonUTF, self.SelectLang)
def retranslateUi(self, Util):
Util.setWindowTitle(_translate("Util", "Hosts Setup Utility", None))
self.ConfigBox.setTitle(_translate("Util", "Config", None))
self.labelIP.setText(_translate("Util", "Server", None))
self.labelMirror.setText(_translate("Util", "IP Version", None))
self.StatusBox.setTitle(_translate("Util", "Status", None))
self.labelConn.setText(_translate("Util", "Connection", None))
self.labelConnStat.setText(_translate("Util", "N/A", None))
self.labelOS.setText(_translate("Util", "OS", None))
self.labelOSStat.setText(_translate("Util", "N/A", None))
self.InfoBox.setTitle(_translate("Util", "Hosts Info", None))
self.labelVersion.setText(_translate("Util", "Version", None))
self.labelVersionData.setText(_translate("Util", "N/A", None))
self.labelRelease.setText(_translate("Util", "Release", None))
self.labelReleaseData.setText(_translate("Util", "N/A", None))
self.labelLatest.setText(_translate("Util", "Latest", None))
self.labelLatestData.setText(_translate("Util", "N/A", None))
self.FunctionsBox.setTitle(_translate("Util", "Functions", None))
self.ButtonBackup.setToolTip(_translate("Util", "Backup hosts", None))
self.ButtonBackup.setWhatsThis(_translate("Util", "Backup the hosts file of current system.", None))
self.ButtonUpdate.setToolTip(_translate("Util", "Download data file", None))
self.ButtonUpdate.setWhatsThis(_translate("Util", "Download the latest data file.", None))
self.ButtonRestore.setToolTip(_translate("Util", "Restore backup", None))
self.ButtonRestore.setWhatsThis(_translate("Util", "Restore a previous backup of hosts file.", None))
self.ButtonApply.setToolTip(_translate("Util", "Apply hosts", None))
self.ButtonApply.setWhatsThis(_translate("Util", "Apply changes to the hosts file.", None))
self.ButtonExit.setToolTip(_translate("Util", "Exit", None))
self.ButtonExit.setWhatsThis(_translate("Util", "Close this tool.", None))
self.ButtonCheck.setToolTip(_translate("Util", "Check update / Refresh", None))
self.ButtonCheck.setWhatsThis(_translate("Util", "Check the latest version of hosts data file.", None))
self.ButtonANSI.setToolTip(_translate("Util", "Save with ANSI", None))
self.ButtonANSI.setWhatsThis(_translate("Util", "Export to hosts file encoding by ANSI.", None))
self.ButtonUTF.setToolTip(_translate("Util", "Save with UTF-8", None))
self.ButtonUTF.setWhatsThis(_translate("Util", "Export to hosts file encoding by UTF-8.", None))
self.TitleLabel.setText(_translate("Util", "Hosts Setup Utility", None))
self.Copyright.setText(_translate("Util", "Copyleft (C) 2011-2014 <a href=\"https://hosts.huhamhire.com/\"><span style=\"text-decoration: none;color: #b1b1b1;\">huhamhire-hosts</span></a>", None))
self.label.setText(_translate("Util", "Powered by PyQT", None))
import util_rc
import style_rc
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Util = QtGui.QDialog()
ui = Ui_Util()
ui.setupUi(Util)
Util.show()
sys.exit(app.exec_())
| Python |
# -*- coding: utf-8 -*-
# Resource object code
#
# Created: 周三 1月 22 13:03:07 2014
# by: The Resource Compiler for PyQt (Qt v4.8.5)
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore
qt_resource_data = "\
\x00\x00\x04\xf8\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x38\x34\x39\
\x36\x35\x45\x39\x33\x35\x39\x38\x35\x31\x31\x45\x33\x42\x38\x30\
\x33\x45\x39\x42\x31\x37\x42\x32\x36\x32\x41\x35\x41\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x38\x34\x39\x36\x35\x45\x39\
\x32\x35\x39\x38\x35\x31\x31\x45\x33\x42\x38\x30\x33\x45\x39\x42\
\x31\x37\x42\x32\x36\x32\x41\x35\x41\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xcf\x3d\
\xf2\xba\x00\x00\x01\x1d\x49\x44\x41\x54\x78\xda\x62\xcc\xcb\xcb\
\x3b\xc7\xc0\xc0\x60\xc8\x80\x1d\xfc\x05\xe2\xb0\x49\x93\x26\xad\
\x03\x71\x80\x6a\x13\x80\xd4\x3c\x20\x66\x64\xa0\x0e\x38\xcf\x84\
\xc7\x72\x10\x60\x06\x62\x3d\x24\xbe\x03\x15\x2d\x07\x01\x43\x26\
\x86\x01\x06\xa3\x0e\x18\x75\x00\xc8\x01\x9f\x08\xa8\xf9\x88\xc4\
\x7e\x4e\x65\xfb\x3f\xb1\x00\x09\x63\x20\xd6\xc1\xa1\xe0\x07\x10\
\xef\x41\xe2\x37\x00\xf1\x61\x20\x66\xa3\x92\x03\xae\x30\x8c\x78\
\xc0\x08\x2d\x5e\x1d\x70\xc8\x7f\x01\xe2\x0e\x60\x51\xfc\x04\x5a\
\x14\xab\x01\xa9\x62\x20\x66\xa7\x92\xfd\x07\x58\x88\x28\xdb\x5f\
\x01\x71\x13\x94\x5d\x08\xc4\x69\x54\x0c\x80\x38\x26\x22\xca\x76\
\xe4\xac\xca\x49\xed\x18\x18\x2d\x88\x46\x1d\x00\x72\xc0\x7f\x02\
\x6a\xfe\x21\xb1\xbf\x53\xd9\xfe\xff\xa0\x6c\x98\x44\xa0\x1c\x98\
\x87\xc4\xef\x87\x3a\x9a\x6a\xe5\xc0\x68\x51\x0c\x2a\x8a\x55\xf0\
\xd4\x86\xa0\x38\xdf\x0b\x2c\x8a\xff\x40\x8b\x62\x50\xd0\x3b\x53\
\xb3\x36\x04\xa5\x81\xb3\x40\xcc\x87\x47\x51\x11\x34\xee\x61\xd5\
\x71\x05\x35\xdb\x03\x4c\x04\x2c\x07\x01\x7e\x24\xb6\x24\x95\x63\
\x80\x6f\xb4\x20\x1a\x75\xc0\xa0\x70\xc0\x39\x3c\xf2\xa0\xfc\x7f\
\x09\xad\xe8\xfc\x4f\x45\xfb\xcf\x31\xfe\xff\xff\x7f\x40\x43\x00\
\x20\xc0\x00\xcb\x8e\x3a\x29\x41\x01\xac\xc1\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x05\xa0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x31\x35\x41\
\x39\x46\x35\x46\x42\x35\x39\x38\x35\x31\x31\x45\x33\x38\x30\x36\
\x39\x39\x35\x43\x31\x38\x46\x35\x39\x35\x39\x46\x42\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x31\x35\x41\x39\x46\x35\x46\
\x41\x35\x39\x38\x35\x31\x31\x45\x33\x38\x30\x36\x39\x39\x35\x43\
\x31\x38\x46\x35\x39\x35\x39\x46\x42\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xec\xd9\
\x4e\x52\x00\x00\x01\xc5\x49\x44\x41\x54\x78\xda\x62\xfc\xff\xff\
\x3f\x03\x23\x23\x23\x03\x3e\xb0\x77\x5a\xd2\x04\x20\x95\xcf\x40\
\x1a\x98\xe8\x9c\x35\xaf\x00\x9f\x02\x90\xdd\x4c\x0c\x03\x0c\x58\
\x88\x54\x77\x0a\x88\x17\x92\x68\xf6\x29\x6a\x3a\x60\x07\x10\x1f\
\x23\xd1\x01\x9f\xa8\xe9\x80\x3a\x72\xd2\x00\x10\x17\x10\x52\x34\
\xe0\x69\x60\xc8\x24\xc2\x26\x20\x9e\x30\x90\x69\x20\x10\x88\x7d\
\x49\x74\xc0\x66\x20\x9e\x4b\x2d\x07\xe8\x02\xb1\x3f\x89\x0e\x78\
\x30\x24\xd2\xc0\xa8\x03\x58\xa0\x95\x4d\x22\x90\x92\xc7\xa3\xce\
\x82\x0c\xb3\x2d\x80\xe6\x36\xe0\x91\x7f\x08\xc4\xf3\x61\x89\x70\
\x1b\x10\xaf\x07\x62\x4b\x2a\x7a\xce\x1c\x8a\xb1\x81\xe3\xd0\x9c\
\x05\x89\x02\x60\xb5\xf9\x12\x48\x39\x92\x51\xe1\x90\x03\x40\x76\
\x38\x42\xed\x64\x60\x44\x6f\x0f\x00\x83\xad\x0c\x48\xb5\xd3\x20\
\x7d\xfc\x03\xe2\x4a\xa0\xc5\x5d\xc8\xed\x01\x46\x6c\x0d\x12\xa0\
\x23\xbc\x81\xd4\x72\x20\xe6\xa5\x92\xe5\x9f\x81\x38\x12\x68\xf9\
\x56\xf4\x06\x09\x23\xae\x16\x11\xd0\x11\xda\x40\x6a\x13\x10\x2b\
\x51\x68\xf9\x3d\x20\xf6\x03\x5a\x7e\x95\xa4\x16\x11\x54\x83\x19\
\x10\x1f\xa4\xc0\x72\x90\x5e\x33\x6c\x96\x13\x55\x0e\x00\x35\xbe\
\x05\x52\xae\x40\x3c\x93\x0c\xcb\x41\x7a\x5c\xa1\x66\xe0\x04\x8c\
\xc4\x34\x4a\xa1\x51\x92\x0b\xa4\xfa\x81\x98\x99\x80\xd2\xbf\x40\
\x5c\x08\xb4\x78\x32\x21\x33\xf1\xa6\x01\x1c\x8e\x70\x01\x52\xab\
\x81\x58\x00\x87\x92\x0f\x40\x1c\x0a\xb4\x7c\x0f\x31\xe6\x91\xec\
\x00\xa8\x23\xd4\xa0\x89\x53\x1d\x4d\xea\x26\x34\xb1\xdd\x22\xd6\
\x2c\xb2\x9a\xe5\x50\x0b\x40\x45\xf3\x2e\x24\xe1\xdd\x20\x31\x52\
\x2c\x27\x39\x0d\x60\x09\x09\x50\x5a\xe8\x85\x72\x8b\x81\x96\xff\
\x25\xd5\x0c\x78\x14\xec\x9b\x9e\x0c\x0a\x09\x4d\x20\x66\xa5\x53\
\x25\xf8\x1b\x88\x6f\x38\x65\xce\xfd\x0b\xab\x8c\xd6\x91\xd1\xe2\
\xa1\x14\x6c\x07\x62\x2f\x58\x1a\xf0\x1b\x80\xa6\x80\x27\x72\x41\
\xc4\xc8\x30\x40\x00\xe6\x80\x3f\x03\x60\xf7\x3f\x64\x07\x4c\x81\
\x09\xd0\xd1\xf2\xa9\x20\x06\x40\x80\x01\x00\x51\x94\x9c\xf8\x84\
\x67\x5d\xdc\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x07\x88\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x43\x42\x44\
\x44\x46\x43\x41\x38\x35\x39\x38\x44\x31\x31\x45\x33\x38\x45\x43\
\x31\x45\x30\x35\x34\x36\x33\x33\x31\x39\x46\x38\x34\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x43\x42\x44\x44\x46\x43\x41\
\x37\x35\x39\x38\x44\x31\x31\x45\x33\x38\x45\x43\x31\x45\x30\x35\
\x34\x36\x33\x33\x31\x39\x46\x38\x34\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x37\x31\x65\x61\x35\x61\x61\x61\
\x2d\x63\x33\x30\x31\x2d\x30\x61\x34\x35\x2d\x62\x36\x30\x35\x2d\
\x38\x64\x36\x65\x63\x37\x33\x34\x65\x37\x62\x66\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xf7\xcb\
\xb3\xc5\x00\x00\x03\xad\x49\x44\x41\x54\x78\xda\xbc\x97\x69\x48\
\x55\x41\x14\xc7\xef\xd3\xd7\x26\x2d\x96\x18\x25\xb6\x88\x49\x54\
\x52\x7e\x50\xd3\xca\x28\x69\xa7\x3d\xa9\x84\xac\x8c\xa2\x5d\x92\
\x16\x22\x41\xcb\x16\xcb\x82\x20\x89\x8a\x84\x6c\x21\x22\xac\x88\
\x56\xbf\xd8\xf2\x21\xa5\x04\x97\x28\x08\x6c\xd1\x24\x22\x42\x4d\
\xc5\x35\xad\xff\x81\xff\xc4\x74\xbb\xbd\xad\x67\x07\x7e\xcc\xdc\
\x99\x37\x67\xce\xcc\x9c\x39\x73\x9e\x6d\xf7\xe5\x22\x9b\x61\x18\
\x29\x60\x23\x08\x32\x3c\x93\x47\x20\xe1\x78\x52\x6c\xa7\xbb\x03\
\x6d\x30\x60\x2f\xca\x2c\xd0\x0a\xf2\x40\x39\xeb\xae\x88\x1f\x38\
\xcd\xfa\x25\xb0\x16\x46\xfc\x70\xc7\x00\x3b\xd8\x09\x9a\xc0\x54\
\x0c\x2e\x75\x67\x30\x8c\xf7\xa7\x01\x55\x60\x35\xa8\x05\xa9\xee\
\xee\x80\x58\x7c\x0c\x1c\x01\x83\x40\x3d\x77\x60\x88\xe9\xb7\x9f\
\x41\x6f\xe0\xcf\xef\x56\x52\x07\x56\x80\x24\x30\x1f\xa4\x63\x21\
\x07\x5d\x35\xc0\x87\x65\x09\x58\x07\xde\x83\x1d\x20\x86\x75\x9d\
\x18\xf6\xa9\xef\x6b\x9a\x9e\x76\x1a\x21\xbe\x90\x89\x45\x6d\x75\
\xd7\x80\xef\xa0\x18\x1c\x00\x1f\xb8\x4a\xa9\x6f\x07\x33\x59\xf7\
\x67\xdf\x02\xb0\x81\xfe\xf2\x4b\xb0\xea\x66\x14\x8b\xc1\x73\x70\
\x0a\x46\x24\xba\x63\x80\xc1\x15\x66\x80\x0b\xe0\x16\xeb\x33\xb8\
\x3b\x19\x6c\x93\xbe\x1a\x10\x2e\x0e\x67\xf2\x25\x31\xa2\x01\xc5\
\x1c\xf0\x1a\x5c\x84\x11\xf3\xdc\x31\xe0\x09\x1d\x28\x95\xc7\x11\
\x02\xee\x73\xe5\x21\x1a\xa2\x3c\x13\xac\x04\xea\xda\x45\x68\x3b\
\x21\x3e\x11\x0f\xaa\x41\x3e\x8c\x98\xec\x8a\x13\x2e\x01\x23\xc1\
\x49\xb6\x97\x43\x51\x04\xfb\x92\x51\xcf\x73\x70\x13\xc4\xf3\x7d\
\xc1\x24\xfc\xee\x95\xd6\x1e\x8c\xa2\x08\xf4\x07\x71\xe8\xab\x70\
\x66\xc0\x03\xd0\xc7\xe2\x37\xcd\x18\xdc\xee\xc0\x80\x74\xfa\x48\
\x23\xc8\x05\x2f\x81\x8a\x05\xa3\x40\x1a\xf8\x02\x22\xa1\xe7\xa3\
\x55\x1c\x50\x22\xce\xb5\xcd\x62\x8e\xa3\x98\xa4\xaf\xd6\x57\x09\
\x45\xeb\xb5\xfe\x43\xa0\x03\x6c\xe2\x2d\xb1\x59\xe8\x18\x0c\x42\
\x81\x43\x03\x1a\xe8\xe5\x66\xe9\xe2\x04\xaa\xef\x93\xc9\xfb\xbb\
\x18\x49\xb3\x1c\x04\xab\x3a\x57\x9c\x30\x90\xce\x24\xec\xa3\x13\
\x49\x3d\x9b\x5b\x1c\x8a\xc9\xc4\xf3\x23\xa1\xb4\x0c\xe4\x1a\x5e\
\x10\x7d\x07\xe4\x7a\x15\x72\x27\x02\xf8\xfd\x58\xeb\x6f\x61\x59\
\xcc\x88\x59\xe9\x6d\x03\xc6\xca\xbd\xc7\x2a\xc7\x63\x75\x12\xdb\
\x07\xb0\x7d\x0b\xda\xae\x6a\x5b\x9e\x69\x78\x51\x74\x03\x64\x65\
\x6d\xca\xf1\x40\x2f\xd6\xcb\x8c\x6e\x14\xbb\xb6\x32\x79\x09\x4b\
\x59\x3f\x63\xfc\x27\xb1\xbb\xf0\xe4\x46\x32\x59\x09\xf4\x70\x8e\
\x1e\xea\xba\x42\xd7\x57\xd6\xa5\xcc\xc5\x42\x8b\xed\x4e\x26\x9f\
\x8d\xe2\x8e\xa6\xe4\x5f\xc4\x1c\x92\x93\xa1\x7f\xa9\x8f\x93\x41\
\xd9\x5e\x9a\xfc\x6f\x21\xe0\x84\x33\x03\xc6\xb1\xbc\x02\xce\xea\
\xd6\x83\x7b\x60\x3a\x58\xc8\x50\x2e\x0f\x50\x01\x5f\x50\xf9\x96\
\xdd\x7b\xab\x8d\xb9\xc1\xf6\x04\xf0\x46\x85\x6a\x67\x06\xf8\xb2\
\xac\x60\x60\x52\x72\x1b\x84\x31\x01\x09\xe0\x64\x85\xcc\x90\x3a\
\xf9\x74\x17\x30\xfc\x2a\x49\xe1\x42\xe6\x82\xf3\x2e\x3b\x21\xa5\
\x91\xaf\xa5\x92\x26\x2d\x4e\x7c\xd3\x1e\xb1\x76\x06\x28\x79\xd2\
\x83\x99\x6f\x2a\x59\xce\x1c\xa2\x8a\x8f\xd6\x1f\xa1\xd8\x99\x01\
\x3d\x59\xaf\x85\xf7\x76\x68\xb9\x61\x8b\x66\x4c\x33\x03\x9a\x3c\
\x4a\xab\x24\x29\xe1\xa4\x37\xc1\x43\x39\x73\xb0\xc8\x93\x1d\x88\
\xe6\xa0\x7e\x92\xb8\xc0\x7b\xe3\xb5\x40\xd5\xa0\xbd\x80\x52\x1f\
\x0a\x46\xf0\x7b\x0d\xa9\x66\xb2\xfb\x82\x69\x7f\xb4\xab\x06\xc8\
\x2b\x36\x90\xe7\x17\xcb\x6c\x28\x91\x79\xa2\x92\xc3\x4c\xd1\x44\
\x66\x81\x29\x16\x7a\x86\x83\xa7\x4c\x50\x24\xcf\x8c\x63\x7b\x9b\
\x33\x03\xae\x33\x08\x89\x44\x11\xb3\x4c\xd3\xea\xa3\x1d\xe8\x0a\
\x23\xbf\xe9\xf7\x31\x79\xbb\x59\x76\xf1\xfc\xba\x43\xee\xca\x6e\
\xa8\x1d\x08\xe7\x3d\x35\x4c\xc9\x86\x78\xfb\x32\x9c\x79\x10\xb3\
\x1a\x4f\x44\x8e\x24\x87\xa9\x7c\x89\x0a\xc5\xd0\x5d\xa3\x72\xc2\
\x7a\xde\xdd\x28\x34\xbe\xf3\xe6\x12\xa1\xdb\x8f\xf1\x61\x22\x98\
\x60\x95\x98\xca\x0e\x9c\x03\x7b\xe4\x0f\x05\x06\xe4\x30\xa9\xec\
\xf2\xc2\xfc\xc3\xc0\x66\x30\x06\x3c\xa3\x5e\xcb\xd7\x30\x8d\x59\
\xac\x24\x95\xfb\xbd\x7c\xce\x12\x2f\xf2\x99\xd4\x58\xfe\x6b\xfe\
\x29\xc0\x00\x12\x09\x26\xe1\x36\xa9\x6f\xb1\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\xbf\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x42\x43\x39\
\x35\x36\x46\x31\x41\x35\x39\x38\x34\x31\x31\x45\x33\x38\x45\x35\
\x31\x43\x44\x35\x41\x43\x39\x34\x42\x36\x39\x45\x41\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x42\x43\x39\x35\x36\x46\x31\
\x39\x35\x39\x38\x34\x31\x31\x45\x33\x38\x45\x35\x31\x43\x44\x35\
\x41\x43\x39\x34\x42\x36\x39\x45\x41\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x5a\x6c\
\x96\x67\x00\x00\x02\xe4\x49\x44\x41\x54\x78\xda\xc4\x57\xbd\x6b\
\x14\x41\x14\xdf\xdd\x9c\x88\xa0\xb1\xb1\x12\xab\xa0\x9c\x26\xa8\
\x8d\x70\x82\xf8\x41\x8a\xa0\x8d\x45\xf0\x0f\x30\x9c\x28\x24\x70\
\x20\x39\xa3\x85\xa4\x38\xd3\xa8\x88\x72\x45\x2a\xb5\x4e\x95\x42\
\x2d\xd6\x14\x21\x0a\x16\x57\x08\x7e\x25\xb9\xcb\xa9\x58\x04\x0b\
\x89\x85\xa7\x9d\x90\xf3\xf7\xe0\xb7\x30\x8c\xfb\x76\x76\x97\x9c\
\x3e\xf8\x31\xc3\xbc\x79\x1f\xf3\xe6\xcd\x9b\x19\xdf\xcb\x41\x95\
\x4a\xa5\x8a\x66\x1a\xd8\xc5\xa1\x0e\x50\xab\xd7\xeb\xf7\xb2\xea\
\xf2\x73\x18\xdf\x8b\x66\x3d\x46\xb6\x0b\xec\x83\x13\x5f\xb3\xe8\
\x0b\x72\x04\xe0\x80\xe2\xb8\x4f\x5e\x26\x2a\x28\xab\x1c\x43\x33\
\x0e\x6c\x00\x55\xac\x6a\x39\x65\xd4\x7c\x4b\xcf\x29\xd9\x1a\xda\
\x99\x81\x9e\xd0\x19\x01\x08\xdd\x40\xf3\x18\x38\x06\x9c\x05\x96\
\x30\x76\x98\x3c\x31\x30\x90\xe0\xc0\x00\xe7\xc8\xdc\x61\x34\x62\
\xf0\x34\x70\x02\x78\x82\xb1\xf3\x2e\x8f\xc7\x68\xdc\x26\x89\xc4\
\x5d\xe0\x52\x8a\x30\x7f\x04\xe6\x80\x49\x60\x87\xc5\xfb\x2d\x8b\
\x42\x24\x16\xb5\x08\x8c\x2b\x4a\xf7\x00\xb7\x53\xee\xf1\x7e\xe0\
\x66\x8c\x71\xa1\x6d\xc0\x95\xa4\x2d\xd8\xf0\x7a\x4f\xdf\x93\x1c\
\xa8\xf6\xd8\x89\x4f\xc0\xad\xc4\x3a\xc0\x84\x5b\x64\xd8\x93\xa8\
\x05\xac\xb2\x7f\x08\x28\xa6\x30\x7e\x06\xfb\xbf\xee\x2c\x44\x70\
\x62\x8a\x7b\x1e\x47\xcf\x81\x29\x28\x7a\x67\xc9\x1c\x61\xa2\x8e\
\x28\x72\x13\x90\x99\x75\x56\x42\x1e\xa3\x96\x92\x70\xf7\x25\xbb\
\xa1\xa8\xab\x38\x2e\xb2\x52\x8e\xaf\xc6\xb0\xd7\x80\x83\xb6\xac\
\x6f\x94\xd7\xa8\xc2\xc9\x39\x7f\xa4\xac\xfc\x5c\xa4\x00\x32\x92\
\x3f\x83\xe4\xad\x60\x7c\xd3\x70\x22\x54\x22\x51\x06\x3e\xb3\x6c\
\xb7\xa5\x6c\xfb\x10\x98\x64\xe8\x5c\xf7\xc2\xd1\x28\xec\x90\x91\
\x3d\x9f\x97\x15\x91\xd7\x04\x46\xc1\x5f\x35\xb6\xe3\xad\x43\x9f\
\x38\x71\x2d\xe0\xad\xe6\x32\xde\x32\x8c\x07\x96\x71\x8f\xfd\x79\
\xf2\x3c\xce\x6d\xa5\xb8\x08\xa7\x45\xa0\x3f\xc5\xf1\x69\x1a\xfd\
\x21\xcb\xb8\xe9\xc4\xa0\x22\xa3\x51\x7f\xe0\xfd\x67\x0a\xf8\x98\
\x70\x91\xb9\xe2\x65\x65\x75\x32\xb6\xa2\xc8\x68\xd4\x09\x78\x5d\
\x76\x1d\x13\x8b\x4c\x2c\x8f\xd9\x3e\x6a\x39\x11\x25\xe1\xa6\x91\
\x84\xc5\x14\x49\x58\xcb\x72\x0c\x17\x78\x93\x99\xc7\x70\x28\x8a\
\x4a\xee\x63\xa8\x14\x93\x35\xde\x6a\x5b\x59\x88\xda\x12\x15\x5b\
\xf6\xaf\x24\xe4\x84\x39\x25\x6c\xa2\x38\x8c\xb6\x23\xa6\x14\x87\
\x8a\x71\xa1\x87\x71\x8e\xc7\x45\x40\x5e\x32\xcf\x94\xfb\xdc\xbe\
\x8c\x9a\x46\xc2\xb9\xf6\x5c\x6e\xd9\x61\x38\xf1\xde\xf5\x86\x0b\
\x53\x18\xcf\x4b\xe2\xc4\x49\x38\xd1\xd4\xb6\xa0\xd6\x43\xe3\xd1\
\xcb\xea\x7a\x52\x0e\x14\xfe\x41\xed\x29\x24\x39\x30\xc3\x87\x63\
\xdc\x63\x62\x82\xa7\xc3\x45\x6d\xae\x32\xee\x65\xd5\xe1\x29\x89\
\x77\x80\xef\xf6\x0b\x96\x13\xd1\x4b\x66\x96\xc9\x56\x4e\x30\x5e\
\xe6\x51\xbb\x23\x09\x67\x39\x21\xc6\x47\xc0\x7b\x63\x0a\xf4\xd9\
\x1a\x1a\x8d\x46\xab\x54\x2a\xbd\x62\x2e\xbc\x04\x2e\x46\xdf\x2d\
\xf0\x3c\xf0\x76\xcb\x98\xe2\xc0\x03\xcc\xfd\xc2\xb9\xdf\x30\xf7\
\x29\xba\x3b\x81\x0f\xc0\x65\xf0\x5e\x6f\xc5\xdf\x50\x3e\x1a\x4b\
\x0a\x5b\x22\xf5\xa2\xd7\x7f\xc3\xb6\x72\x77\x74\xc9\xcb\x44\x7d\
\x59\x05\x10\xda\x9f\x08\xed\x2f\x74\x8f\x03\xdb\x39\xfc\x43\x3e\
\x23\x58\xfd\x42\x56\x7d\x7f\x04\x18\x00\xe5\xb8\x12\x0b\xa0\x46\
\x15\xe4\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x05\xa0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x31\x45\x45\
\x31\x42\x33\x30\x45\x35\x39\x38\x35\x31\x31\x45\x33\x38\x46\x34\
\x31\x43\x38\x46\x38\x31\x43\x33\x30\x33\x39\x39\x45\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x31\x45\x45\x31\x42\x33\x30\
\x44\x35\x39\x38\x35\x31\x31\x45\x33\x38\x46\x34\x31\x43\x38\x46\
\x38\x31\x43\x33\x30\x33\x39\x39\x45\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x68\x12\
\x49\xb3\x00\x00\x01\xc5\x49\x44\x41\x54\x78\xda\x62\xfc\xff\xff\
\x3f\x03\x23\x23\x23\x03\x3e\x90\x97\x97\x37\x01\x48\xe5\x33\x90\
\x06\x26\x4e\x9a\x34\xa9\x00\x9f\x02\x90\xdd\x4c\x0c\x03\x0c\x58\
\x88\x54\x77\x0a\x88\x17\x92\x68\xf6\x29\x6a\x3a\x60\x07\x10\x1f\
\x23\xd1\x01\x9f\xa8\xe9\x80\x3a\x72\xd2\x00\x10\x17\x10\x52\x34\
\xe0\x69\x60\xc8\x24\xc2\x26\x20\x9e\x30\x90\x69\x20\x10\x88\x7d\
\x49\x74\xc0\x66\x20\x9e\x4b\x2d\x07\xe8\x02\xb1\x3f\x89\x0e\x78\
\x30\x24\xd2\xc0\xa8\x03\x58\xa0\x95\x4d\x22\x90\x92\xc7\xa3\xce\
\x82\x0c\xb3\x2d\x80\xe6\x36\xe0\x91\x7f\x08\xc4\xf3\x61\x89\x70\
\x1b\x10\xaf\x07\x62\x4b\x2a\x7a\xce\x1c\x8a\xb1\x81\xe3\xd0\x9c\
\x05\x89\x02\x60\xb5\xf9\x12\x48\x39\x92\x51\xe1\x90\x03\x40\x76\
\x38\x42\xed\x64\x60\x44\x6f\x0f\x00\x83\xad\x0c\x48\xb5\xd3\x20\
\x7d\xfc\x03\xe2\x4a\xa0\xc5\x5d\xc8\xed\x01\x46\x6c\x0d\x12\xa0\
\x23\xbc\x81\xd4\x72\x20\xe6\xa5\x92\xe5\x9f\x81\x38\x12\x68\xf9\
\x56\xf4\x06\x09\x23\xae\x16\x11\xd0\x11\xda\x40\x6a\x13\x10\x2b\
\x51\x68\xf9\x3d\x20\xf6\x03\x5a\x7e\x95\xa4\x16\x11\x54\x83\x19\
\x10\x1f\xa4\xc0\x72\x90\x5e\x33\x6c\x96\x13\x55\x0e\x00\x35\xbe\
\x05\x52\xae\x40\x3c\x93\x0c\xcb\x41\x7a\x5c\xa1\x66\xe0\x04\x8c\
\xc4\x34\x4a\xa1\x51\x92\x0b\xa4\xfa\x81\x98\x99\x80\xd2\xbf\x40\
\x5c\x08\xb4\x78\x32\x21\x33\xf1\xa6\x01\x1c\x8e\x70\x01\x52\xab\
\x81\x58\x00\x87\x92\x0f\x40\x1c\x0a\xb4\x7c\x0f\x31\xe6\x91\xec\
\x00\xa8\x23\xd4\xa0\x89\x53\x1d\x4d\xea\x26\x34\xb1\xdd\x22\xd6\
\x2c\xb2\x9a\xe5\x50\x0b\x40\x45\xf3\x2e\x24\xe1\xdd\x20\x31\x52\
\x2c\x27\x39\x0d\x60\x09\x09\x50\x5a\xe8\x85\x72\x8b\x81\x96\xff\
\x25\xd5\x0c\x78\x14\xe4\xe7\xe7\x83\x42\x42\x13\x88\x59\xe9\x54\
\x09\xfe\x06\xe2\x1b\x13\x27\x4e\xfc\x0b\xab\x8c\xd6\x91\xd1\xe2\
\xa1\x14\x6c\x07\x62\x2f\x58\x1a\xf0\x1b\x80\xa6\x80\x27\x72\x41\
\xc4\xc8\x30\x40\x00\xe6\x80\x3f\x03\x60\xf7\x3f\x64\x07\x4c\x81\
\x09\xd0\xd1\xf2\xa9\x20\x06\x40\x80\x01\x00\xc6\x51\x9f\x7a\x83\
\x78\x67\xeb\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\xbd\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x41\x41\x42\
\x31\x33\x44\x37\x30\x35\x39\x38\x34\x31\x31\x45\x33\x41\x44\x39\
\x31\x44\x46\x46\x41\x36\x32\x34\x34\x38\x41\x34\x46\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x41\x41\x42\x31\x33\x44\x36\
\x46\x35\x39\x38\x34\x31\x31\x45\x33\x41\x44\x39\x31\x44\x46\x46\
\x41\x36\x32\x34\x34\x38\x41\x34\x46\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x74\x3f\
\x67\x43\x00\x00\x02\xe2\x49\x44\x41\x54\x78\xda\xbc\x97\x5d\x88\
\xcc\x51\x14\xc0\x67\xd6\x60\xdb\x98\x15\xa5\x79\xf0\x15\x4b\x48\
\xbe\x8a\x44\xc8\xee\x4a\x11\xf2\x64\x1f\x58\x91\x42\x69\xac\xf2\
\x91\xb2\xa5\x15\x25\xe5\x61\x3c\xd9\x97\x8d\x37\x1e\xb0\x51\xe4\
\xa3\x59\xad\x94\x07\xab\xb4\xb2\x59\xb2\x25\xd2\x96\xb0\xd8\xf5\
\xd1\x18\xbf\x53\x67\x74\xfb\x37\xf7\xce\xfd\x9b\x7f\x7b\xea\xd7\
\xbd\x73\x3f\xfe\xf7\x9c\x73\xcf\x3d\xf7\x4e\x3c\x16\xa1\xa4\xd3\
\xe9\x75\x14\x19\x98\x05\xcf\x61\x5f\x26\x93\xe9\xb4\x8d\xcf\xe7\
\xf3\xb1\x78\x84\x8b\x4f\xa3\xe8\x81\xd1\x46\xf3\x57\xa8\x41\x89\
\x7e\x9b\x02\x15\x11\x3a\x60\x7d\x60\x71\x91\xb1\x50\xe7\x9a\x14\
\xa5\x02\xdf\x2d\xed\x83\xae\x49\x89\x08\x5c\x5f\x25\x6e\x86\x6b\
\x70\x12\x26\x1b\xdd\xb2\x25\xb7\x23\x55\x80\x05\x47\x50\x2c\x55\
\xd7\xd6\xc3\x72\x18\x09\xbd\xd0\x0e\x93\x60\x1c\x3c\x83\x53\xec\
\xff\xcf\xb2\x15\x60\x51\x09\xd6\x46\xd8\x02\x6b\x20\x59\x64\xd8\
\x4c\xe5\x0f\xdc\x82\x07\xf0\xb1\xd4\xb7\x7d\x3d\xb0\x1b\x5a\x3d\
\xc7\x4a\x5c\x6d\x50\x36\xc1\x8d\xb2\x82\x10\xeb\x47\x51\x34\x07\
\x9a\xdf\xc0\x7b\x0f\x65\xea\xa3\xf0\xc0\x4e\x23\xb0\xde\xc2\x2a\
\xf8\x0c\x7d\x1e\x73\xd7\x16\x09\xd8\xd5\x30\x1b\xae\x8b\x21\x89\
\x12\xd6\x4b\xff\x61\xa3\xe9\x34\x41\xd5\x47\xbb\x78\xa4\xda\x96\
\xe0\x20\xa7\xc6\xcd\x61\xac\x6c\xc3\x02\x0d\xda\x42\xc0\x8a\x34\
\xc1\xd4\x52\x1e\xd8\x06\x33\xb4\xfe\x01\xda\xf8\xe0\x18\xca\x03\
\x8e\x39\x57\xf4\x24\xac\xd0\xdf\xed\x96\x71\x55\xce\x18\x50\xeb\
\x8f\x1b\x4d\x67\xf4\x48\xed\x87\x09\x0e\xeb\x5b\xe0\x9e\x43\xc1\
\x77\x70\x51\x33\xa7\xfd\x2e\x40\x81\x46\x1d\x58\xb0\x7e\xba\xd6\
\x65\xef\x27\x5a\xa6\x5d\x46\xc9\x06\xe6\xca\x71\xec\x02\xf1\xd6\
\x00\x64\x55\xa9\xfb\xf4\xbf\x30\xef\x02\xd7\x16\xec\x30\xea\xe7\
\x98\x38\xc4\x87\x9b\x1c\x8b\x17\xac\x8f\x31\xb6\x97\xb1\x53\xa8\
\xa6\xe0\x25\xbf\x73\xb6\x45\x5c\x1e\x38\x4b\x71\x08\x5e\xc3\x42\
\xf8\xad\xd6\xa7\x2c\x53\x9e\xc2\x32\x16\xfb\xe5\x9b\x55\x4b\xdd\
\x86\x47\x60\x2e\xcc\xe7\xa3\xdf\xf4\x38\xa6\x1c\xe3\x17\x41\xb7\
\x46\xbd\xb7\xc4\x3d\x53\xb1\x24\xa3\x57\x81\x8b\xc6\x25\xb2\xdf\
\x07\x51\xbc\xbb\x1c\x0f\x98\xb2\x3d\xc4\xe2\x85\x0c\xd8\x85\xe2\
\x4b\x7c\xf2\x76\xcc\x23\x19\x1d\x2b\xd2\xb5\x07\x2e\x68\xd2\x29\
\x26\x92\x70\x76\x95\xad\x40\x20\x19\x15\xe4\x31\xee\x6d\x85\xbd\
\xd4\xe7\xc1\x4d\xcb\xdc\xea\xb2\x14\xc0\xfa\x0a\x0d\xc6\xa0\x9c\
\x28\x54\x50\xa2\x07\x36\xea\x35\xfd\xa4\x58\xb6\x0b\x15\x84\x2c\
\x3a\x9e\xa2\xd6\x78\x70\xd4\x04\x86\x3c\x64\xc1\x95\x16\x85\xe5\
\x21\xf2\xc9\x68\xca\x32\xb6\xd6\x15\x84\x09\xb5\xb2\x4e\x6f\xae\
\x3a\x3d\x4e\xae\xd3\xd1\xec\xe8\x0b\xbe\xff\x2a\x7d\xb6\xe0\x12\
\xdc\xd1\x5b\x6f\x71\x89\xc5\xcf\x63\x51\x87\xad\x53\x93\x50\x3e\
\xcc\x16\x48\x84\x37\x38\xfa\xe5\x83\x8f\xf4\x5c\x5f\x35\xf3\xb8\
\x43\x06\x8c\xe0\x4b\xfa\x28\x90\x0d\xbc\x5c\xe4\x31\x79\x57\xe9\
\x64\xd1\xc1\x90\xef\xd6\x21\x43\x81\x4a\x1f\x05\x36\xc3\x56\x7d\
\xd7\x77\xd8\xfe\xc5\x84\x90\x1f\xa1\xb6\x40\x2d\x6c\x8b\xf0\x0f\
\xca\x17\xa3\x9e\x8c\x22\x11\xc5\xfe\x63\x0b\xfe\x1d\x73\xbd\x47\
\x86\x55\x81\xfe\xc0\x76\xe4\x86\x5b\x81\x16\x7d\x37\x88\x27\x8e\
\xba\x1e\x23\x22\x7f\x05\x18\x00\x68\x1f\xde\x97\xa8\x2b\x9f\x11\
\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\xbd\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x39\x46\x38\
\x32\x32\x30\x43\x30\x35\x39\x38\x34\x31\x31\x45\x33\x42\x35\x45\
\x42\x44\x32\x39\x33\x41\x33\x42\x36\x34\x41\x32\x38\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x39\x46\x38\x32\x32\x30\x42\
\x46\x35\x39\x38\x34\x31\x31\x45\x33\x42\x35\x45\x42\x44\x32\x39\
\x33\x41\x33\x42\x36\x34\x41\x32\x38\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x7d\x29\
\xa2\x1a\x00\x00\x02\xe2\x49\x44\x41\x54\x78\xda\xbc\x97\x5d\x88\
\xcc\x51\x14\xc0\x67\xd6\x60\xdb\x98\x15\xa5\x79\xf0\xb1\xb1\x84\
\xe4\xab\x48\x84\xec\xac\x14\x21\x4f\xf6\x81\x15\x6d\xa1\x94\x55\
\x8b\x94\x2d\xad\x28\x91\x07\x9e\x6c\x6a\xe3\x8d\x07\x6c\x14\xf9\
\x68\x6c\x2b\xe5\xc1\x2a\xad\x6c\x96\x6c\x89\xb4\x25\x2c\x76\x7d\
\x34\xc6\xef\xd4\xf9\xeb\xf6\x6f\xee\x9d\x3b\xe6\xdf\x9e\xfa\x75\
\xef\xdc\x8f\xff\x3d\xe7\xdc\x73\xcf\xbd\x13\x8f\x45\x28\x7d\x4d\
\x0d\x6b\x29\xce\xc2\x4c\x78\x0e\x7b\xaa\x4e\x5f\xe8\xb4\x8d\xcf\
\xe5\x72\xb1\x78\x84\x8b\x57\x51\xf4\xc0\x68\xa3\xf9\x2b\x54\xa3\
\x44\xbf\x4d\x81\xb2\x08\x1d\xb0\x2e\xb4\xb8\xc8\x58\x48\xbb\x26\
\x45\xa9\xc0\x77\x4b\xfb\xa0\x6b\x52\x22\x02\xd7\x57\x88\x9b\xe1\
\x1a\x1c\x83\xc9\x46\xb7\x6c\xc9\xed\x48\x15\x60\xc1\x11\x14\x4b\
\xd4\xb5\xb5\xb0\x0c\x46\x42\x2f\xb4\xc3\x24\x18\x07\xcf\xe0\x38\
\xfb\xff\xb3\x64\x05\x58\x54\x82\xb5\x1e\x36\xc3\x6a\x48\xe6\x19\
\x36\x43\xf9\x03\xb7\xa0\x03\x3e\x16\xfa\xb6\xaf\x07\x1a\xa0\xd5\
\x73\xac\xc4\xd5\x7a\x65\x23\xdc\x28\x29\x08\xb1\x7e\x14\x45\x73\
\xa8\xf9\x0d\xbc\xf7\x50\xa6\x36\x0a\x0f\xec\x30\x02\xeb\x2d\xac\
\x84\xcf\xa2\x9b\xc7\xdc\x35\x79\x02\x76\x15\xcc\x82\xeb\x62\x48\
\xa2\x80\xf5\xd2\x7f\xc0\x68\x3a\x41\x50\xf5\xd1\x2e\x1e\xa9\xb4\
\x25\x38\xc8\xaa\x71\xb3\x19\x2b\xdb\x30\x5f\x83\x36\x08\x58\x91\
\x46\x98\x5a\xc8\x03\x5b\x61\xba\xd6\x3f\x40\x1b\x1f\x1c\x43\xb9\
\xcf\x31\xe7\x8a\x9e\x84\xe5\xfa\xbb\xdd\x32\xae\xc2\x19\x03\x6a\
\xfd\x11\xa3\xe9\xa4\x1e\xa9\xbd\x30\xc1\x61\x7d\x0b\xdc\x73\x28\
\xf8\x0e\x2e\x6a\xe6\xb4\xdf\x05\x28\x50\xaf\x03\x03\xeb\xa7\x05\
\x5d\x30\xd1\x32\xed\x32\x4a\xd6\x31\x57\x8e\x63\x17\x88\xb7\x06\
\x20\xa3\x4a\xdd\xa7\xff\x85\x79\x17\xb8\xb6\x60\xbb\x51\x3f\xc3\
\xc4\x21\x3e\xdc\xe8\x58\x3c\xb0\x3e\xc6\xd8\x5e\xc6\x4e\xa1\x9a\
\x82\x97\xfc\xce\xda\x16\x71\x79\xe0\x14\x45\x13\xbc\x86\x05\xf0\
\x5b\xad\x4f\x59\xa6\x3c\x85\xa5\x2c\xf6\xcb\x37\xab\x16\xba\x0d\
\x0f\xc2\x1c\x98\xc7\x47\xbf\xe9\x71\x4c\x39\xc6\x2f\x84\x6e\x8d\
\x7a\x6f\x89\x7b\xa6\x62\x49\x46\xaf\x42\x17\x8d\x4b\x64\xbf\xf7\
\xa3\x78\x77\x29\x1e\x30\x65\x5b\x11\x8b\x07\x19\xb0\x0b\xc5\x17\
\xfb\xe4\xed\x98\x47\x32\x3a\x9c\xa7\x6b\x17\x9c\xd7\xa4\x93\x4f\
\x24\xe1\xec\x2c\x59\x81\x50\x32\x0a\xe4\x31\xee\x6d\x85\xdd\xd4\
\xe7\xc2\x4d\xcb\xdc\xca\x92\x14\xc0\xfa\x32\x0d\xc6\xb0\x1c\x0d\
\x2a\x28\xd1\x03\x1b\xf4\x9a\x7e\x92\x2f\xdb\x15\x15\x84\x2c\x3a\
\x9e\xa2\xc6\x78\x70\x54\x87\x86\x3c\x64\xc1\x15\x16\x85\xe5\x21\
\xf2\xc9\x68\xca\x30\xb6\xc6\x15\x84\x09\xb5\x32\xad\x37\x57\x5a\
\x8f\x93\xeb\x74\x34\x3b\xfa\xc2\xef\xbf\x72\x9f\x2d\xb8\x04\x77\
\xf4\xd6\x5b\x54\x60\xf1\x73\x58\xf4\xc0\xd6\xa9\x49\x28\x57\xcc\
\x16\x48\x84\xd7\x39\xfa\xe5\x83\x8f\xf4\x5c\x5f\x35\xf3\xb8\x43\
\x06\x8c\xe0\x4b\xfa\x28\x90\x09\xbd\x5c\xe4\x31\x79\x57\xe9\x64\
\xd1\xc1\x22\xdf\xad\x43\x86\x02\xe5\x3e\x0a\x6c\x82\x2d\x20\xe9\
\xb6\xc3\xf6\x2f\xa6\x08\xf9\x51\xd4\x16\xa8\x85\x6d\x11\xfe\x41\
\xf9\x62\xd4\x93\x51\x24\xa2\xd8\x7f\x6c\xc1\xbf\x63\xae\xf7\xc8\
\xb0\x2a\xd0\x1f\xda\x8e\xec\x70\x2b\xd0\xa2\xef\x06\xf1\xc4\x21\
\xd7\x63\x44\xe4\xaf\x00\x03\x00\x67\x30\xde\x97\xf5\x5f\xa5\xbd\
\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x07\x85\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x45\x45\x35\
\x37\x44\x41\x37\x43\x35\x39\x38\x34\x31\x31\x45\x33\x39\x44\x32\
\x38\x41\x32\x46\x31\x34\x37\x35\x33\x41\x36\x39\x46\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x45\x45\x35\x37\x44\x41\x37\
\x42\x35\x39\x38\x34\x31\x31\x45\x33\x39\x44\x32\x38\x41\x32\x46\
\x31\x34\x37\x35\x33\x41\x36\x39\x46\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x33\xcd\
\x50\xb2\x00\x00\x03\xaa\x49\x44\x41\x54\x78\xda\xbc\x97\x79\x48\
\x55\x41\x14\xc6\xef\xb3\x97\x95\x59\xbd\x0a\x23\xa4\xc0\x25\xa2\
\x3d\x21\x25\x69\x83\xc8\x32\x5b\xa0\x7d\xfb\xa3\x32\x5a\x6c\x7b\
\x24\x45\x44\x86\x96\x45\x96\x08\x91\x11\x51\x08\x69\x54\x58\x58\
\xfd\x51\x54\x44\xb6\x40\x94\x94\xa4\x66\x46\x84\x6d\x26\x11\x91\
\xf9\xd0\x32\xb5\xb4\xbe\x13\xdf\x95\xe1\x72\xdf\x72\x5f\xcf\x0e\
\xfc\x98\xb9\x33\xf7\xce\x7c\x33\xef\xcc\x99\xf3\x6c\x4e\xa7\xd3\
\xa6\x69\x9a\x13\x6c\x00\xe1\x9a\x7f\x76\x17\x2c\xca\xcd\xcd\x6d\
\xb3\xfa\xa1\x0d\x02\x76\xa1\xcc\x02\xcd\x20\x1f\x54\xb0\xee\x8b\
\x85\x80\xe3\xac\x17\x80\x64\x88\xf8\x6d\x45\x80\x1d\x6c\x07\xdf\
\xc0\x14\x7c\x5c\x66\xe5\x63\x88\x77\x50\xc0\x7b\xb0\x0a\xd4\x83\
\x54\xab\x3b\x20\x8a\x0f\x83\x83\xa0\x1f\x70\x71\x07\x06\x1a\xde\
\xfd\x04\xba\x03\x07\x9f\x9b\x89\x4c\xba\x14\xac\x04\xb3\x41\x3a\
\x16\xb2\xdf\x57\x01\x41\x2c\x4b\xc1\x1a\xf0\x16\x6c\x03\xf1\xac\
\xab\xc4\xb3\x4f\x7f\x2e\x54\xc6\x69\x05\x4b\xe8\x0b\x99\x58\xd4\
\x66\xab\x02\x7e\x81\x12\xb0\x0f\xbc\xe3\x2a\xa5\xbe\x15\x4c\x67\
\xdd\xc1\xbe\xb9\x60\x1d\xfd\xa5\xc3\xb0\xea\x26\x14\xf3\xc0\x63\
\x79\x84\x88\xe5\x56\x04\x68\x5c\x61\x06\x38\x0d\xae\xb0\x9e\xc0\
\xdd\xc9\x60\x9b\xf4\xd5\x82\x51\x60\xb5\xc1\x97\x44\x44\x03\x8a\
\x99\xe0\x85\x38\x25\x44\xcc\xb2\x22\xe0\x3e\x1d\x28\x95\x3f\x47\
\x24\xb8\xce\x95\x47\x2a\xc8\xe0\x99\x60\x19\xd0\x8f\x5d\x8c\xb2\
\x13\xe2\x13\xd3\x40\x0d\x28\x82\x88\x89\xbe\x38\xe1\x7c\x10\x01\
\x8e\xb0\xbd\x02\x03\xc5\xb0\x4f\x8e\x56\xbe\x87\x93\x50\xc7\x1d\
\x98\x80\xf7\xaa\x94\xf6\x41\x28\x1e\x81\xde\x60\x32\xfa\x9e\x79\
\x13\x70\x03\xf4\x30\x79\xa7\x09\x1f\xb7\x7a\x10\x90\x4e\x1f\x69\
\x04\x79\xa0\x12\xe8\xb1\x60\x08\x48\x03\x9f\x41\x2c\xc6\xf9\x60\
\x16\x07\x74\x13\xe7\xda\x62\x32\xc7\x21\x4c\x12\xaa\xf4\x55\x63\
\xa0\xb5\x4a\xff\x01\xf0\x13\xa4\xf0\x94\xd8\x4c\xc6\x18\x00\xa2\
\x81\x47\x01\x0d\xf4\x72\xa3\xb5\x73\x02\xbd\xef\xa3\xc1\xfb\xdb\
\x19\x49\xb3\x3c\x04\xab\x7a\x5f\x9c\x30\x8c\xce\x24\xec\xa6\x13\
\x49\x3d\x9b\x5b\x1c\x8d\xc9\xc4\xf3\x63\x31\x68\x39\xc8\xd3\x02\
\x60\xea\x0e\xc8\xf1\xba\xc3\x9d\xe8\xcf\xe7\x7b\x4a\xff\x0f\x96\
\x25\x8c\x98\xd5\x81\x16\x30\x42\xce\x3d\x56\x39\x06\xab\x93\xd8\
\xde\x87\xed\x9b\xd0\x76\x5e\xd9\xf2\x4c\x2d\x80\xa6\x0a\x90\x95\
\xb5\xe8\x8e\x07\xba\xb1\x5e\xae\x75\xa2\xd9\x95\x95\xc9\x4d\x58\
\xc6\xfa\x09\xed\x3f\x99\xdd\x87\x2b\x37\x96\xc9\x4a\x98\x9f\x73\
\x74\xd5\x8f\x2b\xc6\xfa\xc2\xba\x94\x79\x58\x68\x89\xdd\xcb\xe4\
\x89\x28\xae\x2a\x83\xfc\x8b\x19\x43\x72\x32\xc6\x5f\x10\xe4\xe5\
\xa3\xec\x00\x4d\xee\x2e\x04\xe4\x78\x13\x30\xd2\xa4\x4d\x76\x24\
\x09\x3c\xe7\xf3\x6b\x20\xb7\x5e\x31\x9f\x9f\x32\x3a\x36\x32\x4b\
\x4a\x60\x88\xae\x30\xdc\xa0\x7f\x43\xb5\x37\x01\x5d\x0c\xcf\x12\
\xe3\x25\xf6\x8f\x05\x67\xd9\xf6\x15\x54\x31\x14\xb7\x30\xdc\xbe\
\x02\x37\xc1\x4b\x70\x9b\x42\x5c\xbc\x9c\xdc\x46\x42\x5f\xac\x90\
\xce\x28\xd7\xed\x39\x0a\x92\x44\x24\x0e\x4c\x65\x38\x6e\xe2\x0d\
\x38\x07\x04\x83\xbd\xfc\x19\xbf\x33\x89\xf5\x5b\x40\x1b\x13\x93\
\x71\xe0\x21\x6f\xce\x62\x46\xce\x5e\xf4\x97\x02\xfe\x34\xa1\xec\
\xbf\xc5\xf8\x92\x43\x61\x3d\x2d\x1f\x43\xc5\x4e\x81\x61\xca\xa5\
\x23\x93\x9e\x01\x89\x5c\xa9\x83\x22\x56\x80\x3d\x4c\x66\x5c\xec\
\xab\x63\xf8\x0e\xb6\x2a\xc0\xa5\x64\xc1\xa3\x99\xf5\x76\x1c\x23\
\xf0\x04\x0c\xa5\x4f\x88\x2d\xe6\xea\xa3\x18\x49\x1f\x80\xf5\x4c\
\xd3\x6a\x98\xca\xa9\xd6\xe2\x4d\xc0\x05\x06\x21\xb1\x49\x86\xbe\
\xbe\x60\x86\xc9\x37\x49\x4a\x3d\x42\xa9\x47\x11\xd5\x2e\x06\xb9\
\xf1\x76\xdd\x76\x80\xcb\x9d\x14\x07\xae\x49\xd6\xad\xef\x80\x6c\
\xcd\x25\xe3\x1b\x08\x95\xf2\x8f\x69\x21\x22\x56\x38\xb3\x1a\x7f\
\x4c\x76\xee\x18\x53\xf9\x52\x3d\x14\x63\xec\x5a\x3d\x27\x74\xd1\
\xc3\xe3\xd0\xf8\x26\x90\x4b\xc4\xd8\x21\xcc\x31\xc6\x8b\x9f\x98\
\x25\xa6\xb2\x03\x27\xc1\x4e\x51\x87\x0f\x8e\x32\xa9\x6c\x0f\xc0\
\xfc\x83\xc1\x46\x30\x9c\xc7\xb6\xd2\xdd\x6d\x98\xc6\x80\x92\xc2\
\xa0\x11\x48\x93\x5c\xb2\x88\x49\x8d\xe9\xbf\xe6\x3f\x02\x0c\x00\
\x19\xca\x22\x70\x0c\xa6\x9f\x87\x00\x00\x00\x00\x49\x45\x4e\x44\
\xae\x42\x60\x82\
\x00\x00\x06\xbb\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x37\x34\x35\
\x38\x33\x43\x33\x39\x35\x39\x38\x35\x31\x31\x45\x33\x41\x31\x43\
\x32\x46\x42\x37\x41\x42\x30\x37\x44\x42\x42\x38\x37\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x37\x34\x35\x38\x33\x43\x33\
\x38\x35\x39\x38\x35\x31\x31\x45\x33\x41\x31\x43\x32\x46\x42\x37\
\x41\x42\x30\x37\x44\x42\x42\x38\x37\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x83\x53\
\x5b\xa8\x00\x00\x02\xe0\x49\x44\x41\x54\x78\xda\xc4\x97\x5d\x88\
\x4d\x51\x14\x80\xcf\x3d\xf7\xc6\x0c\xe6\x87\x51\x1a\x43\x8d\x14\
\xae\x19\x3f\xe3\xa7\x1b\xde\x66\x42\x89\x32\xf2\xa0\x79\x98\x97\
\x21\x0f\xc6\x95\xbc\x88\x46\x24\xc9\x4f\xe8\x26\x2f\x46\x29\x49\
\x1e\x64\x3c\x90\x78\xf0\xf3\xc2\x2d\xa1\xe6\x0e\x93\x22\xf2\x73\
\xf3\x30\x4d\x83\x49\x46\x5c\xdf\xd2\xbe\x75\xbb\x73\xf6\xbe\xfb\
\xdc\xb9\x87\x55\x5f\xeb\xfc\xec\xb3\xd6\x3a\x6b\xaf\xb3\xf7\x3a\
\x21\xc7\x52\xe2\xf1\x78\x15\xaa\x15\x56\x42\x0c\xa6\xc3\x14\x70\
\xe1\x3b\xbc\x85\x3e\x78\x00\xd7\x13\x89\xc4\x47\x1b\xbb\x21\x0b\
\xc7\xf3\x50\x5d\xb0\x09\xca\x2c\xe3\xcd\xc0\x6d\x38\x4e\x20\xf7\
\x8b\x0a\x00\xc7\x95\xa8\x13\xd0\x01\x61\xa7\x78\xe9\x81\x4e\x5d\
\x46\x42\x1a\xe7\x8b\x25\x8d\x50\xef\x94\x46\x06\xa0\x8d\x20\xee\
\xe4\xdf\x08\x7b\x38\x6f\x56\xe9\x9b\xe6\x94\x4e\x26\xc0\x96\x58\
\x2c\xf6\x26\x99\x4c\xf6\x6a\x33\x80\xf3\x26\x55\x44\x15\x4e\x30\
\xf2\x1b\x36\x90\x89\x5b\xa3\x02\xc0\x79\x35\xea\x99\x45\xda\x87\
\xe1\x26\x3c\x86\x34\xfc\x84\x19\xb0\x5c\x8c\x43\x65\x81\xe7\x87\
\x60\x29\x41\xbc\x96\x93\x48\xce\x8d\xa3\x05\x9c\x7f\x85\xc3\x70\
\x8e\x87\x87\x35\xb5\x53\x8e\xda\x0e\x07\xa1\x4a\x63\x47\xae\x9f\
\x67\x6c\x0b\x76\x32\x21\xf5\x60\x23\xea\xb9\xa1\xda\x53\xb0\x31\
\x1b\xb5\xc5\xa7\x3b\x53\x55\xff\x12\xc3\xb0\x56\xec\xf5\xb8\xea\
\xe4\x15\x6c\x53\x8e\xf2\xa5\x1f\x9a\x6d\x9d\x8b\x30\xf6\xbd\x3c\
\xa3\x5e\x4a\x27\xfb\xbd\x8a\x50\xce\x57\xc3\x1e\x58\x03\x23\xd0\
\x84\xc1\x17\xc5\x54\x1c\xf6\x66\xa3\xa4\xea\xcb\x35\x43\x16\x9a\
\x16\xa2\x05\xa8\xf9\x38\xbf\x3a\x96\xb2\xc7\xce\x21\xd4\x01\xcd\
\xed\xae\x90\x13\xb0\x10\x40\x2d\xea\x83\xda\x33\xf2\xe5\xae\x1b\
\x74\x00\x64\x30\x6d\xa8\x85\x68\x84\x08\xeb\x38\x58\x25\x55\xcb\
\xe0\x91\x80\xe2\x48\x69\xbe\x88\x5a\xc9\xc0\x1c\x90\x79\xfe\x44\
\x30\xa7\xa0\x21\x80\x00\x06\x35\xd7\xc3\xb2\x10\x4d\x56\x27\x35\
\xb0\x5b\x20\x88\x47\xe8\x0b\x12\x18\x59\xf9\x56\x82\x00\x6a\x34\
\xd7\x7f\x49\x06\xaa\x3d\x6e\xac\x80\x6e\x59\x6a\x09\xa6\x1b\x62\
\x63\x0c\xa0\x51\x73\x3d\x9d\x9b\x01\x2f\x99\xa4\xfa\x81\x0e\x82\
\x48\xa9\xac\x5c\x22\x2b\x03\x3e\xbe\x02\xd9\x27\x16\x69\x6e\xbf\
\x74\x0b\x04\x90\xff\x16\xa7\xe1\x22\x46\xcb\x7c\xbc\xfd\x4e\x43\
\xe3\xf3\x30\xe2\x23\x80\xcf\x52\x1f\xbc\xfd\x15\x1f\x6f\x1f\x45\
\xed\x32\x0c\xb9\x11\xd1\xd4\x40\xbe\x5c\x86\x1d\x38\x1f\xf2\xe1\
\x7c\x2a\xea\x1a\x8c\xd7\x0c\x79\x82\xbd\x5e\xdb\x29\x58\x26\xdf\
\xac\xcf\x3d\x40\x1a\x9b\xa8\x61\xd8\x91\x6c\x3f\x60\x13\xc0\x5c\
\x78\x8a\x61\x69\x52\xcf\x10\xf9\xa0\xa1\x91\xed\x84\x7d\x30\xd1\
\x60\xef\x9e\xa4\xff\xef\x6e\xc8\x43\xfd\xca\x81\xad\xfc\x90\x35\
\x1c\x92\x6a\x8d\x17\xa9\x53\x1d\xd1\x5a\x8b\xd6\x7d\x54\x47\x94\
\xcd\xc0\x3b\x38\xa9\x52\x63\x6a\xab\x64\x4e\xd7\x2b\x8a\xe9\x09\
\xdb\x72\x7b\x0b\x57\xa5\xea\x98\xda\x7a\xcf\xaa\xbe\xee\x4b\x00\
\xcb\xb1\xf4\x8e\xed\xb9\x0d\x69\x76\x0a\x1a\xb8\xd8\xe7\xd1\x0b\
\xc8\x1c\xcd\x0a\xfa\xbf\xc0\xd4\x90\x54\xa8\x29\xd9\xaa\xd9\xcb\
\x83\xfb\x33\xf2\xc8\xc6\x5e\xd8\x0c\xe3\xfe\xd9\xbf\xa1\x66\x61\
\x59\x07\x2d\x6a\x6d\xaf\xcf\x69\xbd\x8b\xff\x3b\xce\x64\x32\xce\
\xff\x94\x3f\x02\x0c\x00\xbe\x84\xeb\xde\xd4\xad\xd3\x24\x00\x00\
\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x07\x88\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x30\x31\x43\
\x33\x45\x33\x41\x37\x35\x39\x38\x35\x31\x31\x45\x33\x42\x46\x41\
\x33\x46\x46\x39\x46\x44\x38\x42\x31\x45\x45\x45\x30\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x30\x31\x43\x33\x45\x33\x41\
\x36\x35\x39\x38\x35\x31\x31\x45\x33\x42\x46\x41\x33\x46\x46\x39\
\x46\x44\x38\x42\x31\x45\x45\x45\x30\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x90\x2e\
\xe6\x71\x00\x00\x03\xad\x49\x44\x41\x54\x78\xda\xbc\x97\x69\x48\
\x55\x41\x14\xc7\xef\xd3\xd7\x26\x2d\x56\x28\x25\xb6\x88\x49\x54\
\x52\x7e\x50\xb3\xc5\x28\x69\x5f\xa0\x45\x2a\xa1\x32\xa3\x68\x7f\
\x24\x45\x44\x82\x96\x85\x96\x08\x81\x12\x51\xbd\xc8\x16\x22\xc2\
\xea\x43\x1b\xf5\x21\xeb\x4b\x4a\x09\x6a\x52\x10\xd8\x2e\x11\x11\
\xee\xb8\x96\xf5\x3f\xf0\xbf\x32\x5d\x6e\xef\xde\x6b\xcf\x0e\xfc\
\x98\xb9\x33\x6f\xce\x9c\x99\x39\x73\xe6\x3c\x97\xc7\xe3\x71\x69\
\x9a\xe6\x01\xdb\x41\x98\xd6\x3b\x29\x01\xc9\x05\x05\x05\x3f\x9d\
\x0e\x74\xc1\x80\x43\x28\x73\x41\x3b\x28\x02\x55\xac\xdb\x91\x20\
\x70\x9a\xf5\xcb\x60\x33\x8c\xf8\xe5\xc4\x00\x37\xd8\x0f\x5a\xc0\
\x1c\x0c\xae\x70\x32\x18\xc6\x07\xd3\x80\x8f\x60\x13\xa8\x03\xe9\
\x4e\x77\x40\x2c\x3e\x09\x72\xc0\x08\xd0\xc0\x1d\x18\x65\xf8\xed\
\x57\x30\x10\x04\xf3\xbb\x9d\xd4\x83\x75\x60\x23\x58\x0e\x32\xb1\
\x90\x63\x76\x0d\x08\x60\x59\x0e\xb6\x80\xf7\x60\x1f\x48\x60\x5d\
\x25\x81\x7d\xfa\xf7\x75\x45\x4f\x27\x8d\x10\x5f\xc8\xc6\xa2\x76\
\x3b\x35\xe0\x07\x28\x03\x47\xc1\x07\xae\x52\xea\x7b\xc1\x02\xd6\
\x83\xd9\xb7\x02\x6c\xa3\xbf\xf4\x08\x56\xdd\x8a\x62\x25\x78\x2e\
\x9f\x30\x22\xc5\x89\x01\x1a\x57\x98\x05\x2e\x82\xdb\xac\xcf\xe7\
\xee\x64\xb1\x4d\xfa\x6a\x41\xb4\x38\x9c\xc1\x97\xc4\x88\x26\x14\
\x8b\xc1\x6b\x70\x09\x46\x2c\x75\x62\xc0\x53\x3a\x50\x3a\x8f\x23\
\x02\xdc\xe7\xca\x23\x14\x44\x79\x36\x58\x0f\xf4\x6b\x17\xa3\xec\
\x84\xf8\x44\x12\xf8\x04\x8a\x61\xc4\x2c\x3b\x4e\xb8\x0a\x8c\x07\
\xa7\xd8\x5e\x05\x45\x31\xec\x4b\x43\xbd\xc8\xc7\x4d\x10\xcf\x0f\
\x04\x33\xf1\xbb\x57\x4a\x7b\x38\x8a\x52\x30\x14\x24\xa2\xef\xa5\
\x95\x01\x0f\xc0\x20\x93\xdf\xb4\x62\x70\xa7\x0f\x03\x32\xe9\x23\
\xcd\xc0\x0b\xaa\x81\x1e\x0b\x26\x80\x0c\xf0\x0d\xc4\x42\xcf\x67\
\xb3\x38\xa0\x8b\x38\xd7\x1e\x93\x39\x4e\x60\x92\xc1\x4a\x5f\x0d\
\x14\x6d\x55\xfa\x8f\x83\x2e\xb0\x83\xb7\xc4\x65\xa2\x23\x14\x44\
\x02\x9f\x06\x34\xd1\xcb\x8d\xd2\xcd\x09\xf4\xbe\x2f\x06\xef\xef\
\x66\x24\xcd\xf5\x11\xac\xea\xed\x38\x61\x08\x9d\x49\x38\x4c\x27\
\x92\x7a\x1e\xb7\x38\x12\x93\x89\xe7\xc7\x42\x69\x25\xf0\x6a\x7e\
\x10\x75\x07\xe4\x7a\x3d\xe6\x4e\x8c\xe4\xf7\x13\xa5\xbf\x8d\x65\
\x19\x23\x66\x8d\xbf\x0d\x98\x2c\xf7\x1e\xab\x9c\x8a\xd5\x49\x6c\
\x1f\xc6\xf6\x5d\x68\xbb\xa6\x6c\x79\xb6\xe6\x47\x51\x0d\x90\x95\
\x75\xe8\x8e\x07\x06\xb0\x5e\xa9\xf5\xa1\xb8\x95\x95\xc9\x4b\x58\
\xc1\xfa\x19\xed\x3f\x89\xdb\xc6\x93\x1b\xcb\x64\x25\xa4\x97\x73\
\xf4\xd3\xaf\x2b\x74\x7d\x67\x5d\x4a\x2f\x16\x5a\xe6\xb6\x98\x7c\
\x11\x8a\x3b\x8a\x92\x7f\x11\x63\x48\x4e\x83\xfe\xd5\x01\x16\x83\
\xf2\xfc\x34\xf9\xdf\x42\x40\xbe\x95\x01\x53\x58\x5e\x01\xaa\x5f\
\xa4\x82\x7b\x60\x1e\x58\xc6\x67\x58\xea\x0f\x59\x4a\x68\x5f\x08\
\xde\x2a\x63\x6e\xb2\x3d\x19\xbc\xd1\x43\xb5\x95\x01\x81\x2c\xab\
\x0d\x61\x54\x8e\x25\x8a\x09\x48\x28\x9f\xe0\x12\x25\x97\x94\xa7\
\xfb\x11\xc3\x6f\xcf\x89\x82\xab\x60\x09\xdf\x0c\x7b\x4e\x48\x69\
\xe6\x6b\xa9\x4b\x8b\x12\x27\x1a\x95\x47\xac\x93\x01\x4a\x9e\xf4\
\x70\xe6\x9b\xba\xac\x65\x0e\x21\x21\xfd\x82\x59\x28\xb6\x32\xa0\
\x3f\xeb\x75\xf0\xde\x2e\x25\x37\x6c\x53\xea\xad\x0c\x68\xf2\x28\
\x6d\x90\xa4\x84\x93\xde\xe2\xf1\xe4\xf3\xb8\xce\x3b\xdd\x81\x78\
\x70\x0e\x0c\x91\xc4\x05\xde\x9b\xa4\x04\xaa\x46\xc3\x83\x36\x1a\
\x8c\x53\x7c\x25\x95\xef\x8a\x24\xbb\x2f\x98\xf6\xc7\xdb\x35\x40\
\x5e\xb1\xe1\x3c\xbf\x19\xcc\x86\x52\x98\x27\xea\x92\xc3\x14\x4d\
\xa3\xe3\xcd\x36\xd1\x33\x96\x19\x57\x29\xf3\xcc\x44\xb6\x77\x58\
\x19\x70\x83\x41\x48\x24\x8e\x18\x65\xae\x52\x9f\xe8\x43\x57\x14\
\xf9\x43\x7f\x80\xc1\xdb\x8d\x72\x80\xe7\xd7\x17\x72\x57\x76\x43\
\xdf\x81\x68\xde\x53\xcd\x90\x6c\x88\xb7\xaf\xc1\x99\x87\xf1\xba\
\xf5\x46\xe4\x48\x0a\x99\xca\x97\xeb\xa1\x18\xba\x6b\xf5\x9c\xb0\
\x81\xd9\x6d\x1c\x1a\xdf\xf9\x73\x89\xd0\x1d\xc4\x1c\x63\x3a\x98\
\x66\x96\x98\xca\x0e\x9c\x05\x07\xe5\x0f\x05\x06\x14\x32\xe8\x74\
\xfb\x61\xfe\x31\x60\x27\x98\x04\x9e\x51\xaf\xe9\x6b\x98\xc1\x2c\
\x56\x92\xca\x23\x7e\x3e\x67\x89\x17\xc5\x4c\x6a\x4c\xff\x35\xff\
\x16\x60\x00\x9d\x8f\x25\xe2\xca\x2c\x04\xd4\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\xed\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x36\x31\x41\
\x31\x30\x32\x43\x34\x35\x39\x38\x35\x31\x31\x45\x33\x42\x46\x35\
\x45\x43\x42\x45\x34\x45\x41\x32\x36\x32\x30\x45\x41\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x36\x31\x41\x31\x30\x32\x43\
\x33\x35\x39\x38\x35\x31\x31\x45\x33\x42\x46\x35\x45\x43\x42\x45\
\x34\x45\x41\x32\x36\x32\x30\x45\x41\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xf0\xfb\
\xe3\xbf\x00\x00\x03\x12\x49\x44\x41\x54\x78\xda\xc4\x97\x59\x68\
\x14\x41\x10\x86\x67\x36\x6b\x3c\x58\x3c\x50\x30\xa8\xa8\xa0\x46\
\xe3\x85\x20\xc6\x20\x51\x04\x2f\x54\x44\xd4\x27\xf3\x10\x04\x11\
\x3c\xe2\x2a\xe2\x8b\x04\x3c\x02\x1e\xa0\x08\xae\x27\x88\x22\x06\
\x7c\x92\x48\x10\x73\x78\x60\x50\x09\x1e\x08\x12\x95\xa8\x41\xf0\
\x26\x3e\x88\x9a\x88\x17\xd9\xe8\x57\x50\x23\xcd\xb2\x99\xe9\xdd\
\x6c\xd6\x82\x2f\x95\xdd\xe9\xa9\xfa\xa7\xa7\xbb\xba\xd6\x75\x2c\
\x2c\x1a\x8d\xe6\xe0\xe6\xc0\x12\x98\x09\xf9\x30\x54\x2f\xff\x82\
\x37\xf0\x08\x6e\x40\x75\x2c\x16\x6b\x75\x2c\xcd\x0d\x48\x1c\xc1\
\x95\xc1\x26\x18\x61\x19\xb3\x03\xae\xc0\x01\x84\xdc\x4d\x5b\x00\
\xc9\x57\xe2\x8e\xc2\x30\x27\x7d\xbb\x04\xdb\x10\xf2\xca\x88\x3b\
\x1c\x57\xc1\x77\x6b\x93\x0a\x60\x40\x2f\x5c\x0c\xd6\x3b\x99\xb1\
\x76\x99\x41\x12\x56\x12\x7b\x22\xff\xd7\xc1\x10\x88\xf0\x5d\xa7\
\x9b\x90\x3c\x17\x77\x11\x96\x39\x99\xb7\xf3\x1a\x77\x90\x7e\xce\
\x47\x40\x4b\xc8\x48\x2e\x62\x2e\xf4\x50\x72\xb1\x52\x23\xb9\xd8\
\x64\xf9\x13\x36\xbe\xd8\x01\xab\x2c\x02\xb5\x41\x03\x3c\x87\x2f\
\x30\x18\x8a\xa1\x30\x45\x41\x53\x64\x8d\x84\xf5\xe9\x45\x4d\x45\
\xc0\x0d\xb2\x90\xf6\xc8\x2c\x31\x75\xbf\x93\xac\x9d\x31\xb8\xcd\
\xb0\x01\x72\x2d\x05\xfc\x9b\x81\x43\x90\x13\xf0\xfe\x64\x21\x7d\
\xeb\x6a\x00\xd7\x5e\xe2\xb6\x22\x44\x16\xf0\x39\x98\x6d\x23\x20\
\xc4\x0d\xd3\xf1\x8b\x7c\x06\x9e\x80\x35\x7e\xc9\x13\xec\x35\xb4\
\x58\x8c\x1b\x4b\xee\x3e\x32\x03\xeb\x7c\x06\xdd\x86\x2d\x24\xff\
\x63\x59\x31\xfb\xe9\x2e\x5a\x6c\x31\x5c\x66\xbc\x20\xac\xe5\x35\
\x99\x49\xd2\x32\x92\x77\x58\x26\xef\x8b\xbb\x06\xb3\x52\x59\x88\
\xb2\x0d\x27\xc0\x02\xd8\x0b\x8d\x10\xd7\x8b\x57\x49\xde\x64\x1b\
\x89\xb1\x3f\xf4\x61\x96\x6b\x05\x6d\xb6\x11\xe0\x76\x51\xff\x65\
\x5b\x7d\x22\xe8\x83\xee\x6c\x7c\x2d\xbb\xf3\x0d\xf2\x12\x86\xd4\
\xbb\x4e\x16\x0d\x41\x93\x0c\x31\x73\xe1\x6b\x56\x05\x24\x88\x91\
\xf5\x57\x24\xff\x14\xeb\x87\xff\x62\x2e\xc9\xdf\xe1\x07\x68\x79\
\xbd\x2e\xf0\xee\x9f\x66\x53\x40\x5d\x92\x42\xd4\xea\x89\x51\x41\
\xef\xbb\x39\xdd\x33\xf4\xcc\xb8\x93\x58\xd0\x44\xc0\x41\xfc\xf6\
\x80\x18\xcd\x86\xa0\x06\x82\xb4\xa5\x28\xc0\x7b\x48\xd9\xe2\xf7\
\xe0\xa6\xce\x78\xa3\xd4\x81\xc7\x16\x31\x0a\xf4\xa0\xa9\x86\x5a\
\x2d\x3a\xb6\xc9\xa7\xe2\x16\x1a\xd5\x4f\x0a\x55\xb9\x16\xad\x67\
\xb6\x02\x3c\xab\x95\xa2\xa5\x45\xc7\x76\xa5\x1f\xf3\x69\xfd\x6a\
\x42\x3a\xbd\x9d\x16\xf1\xce\x4a\xb3\x42\xf2\xef\x96\xc9\x25\xe9\
\x91\x80\x53\xf1\x74\x88\x80\x3f\x2d\x4f\xaf\x71\x30\xca\x32\x79\
\x44\x8f\xe4\x8d\x3e\xc3\xea\xc9\xfd\xd0\xdb\xff\xf2\x1a\xc6\x07\
\xc4\x95\x27\x69\x26\xf8\x49\xa9\xf5\x7a\xfe\x3b\x49\x7a\xca\x12\
\xd8\x05\xa3\x7d\x62\xc5\xbd\x85\xef\xea\x8d\x72\xc3\xee\x14\x77\
\xd7\x7d\xd9\x56\x72\x66\xc0\x40\x7d\x00\x29\xaf\xfd\x2d\xee\x2d\
\xe7\x01\xf6\x99\x1d\x51\x53\x1a\xdb\xbb\x30\x8d\x3e\x50\xac\x0a\
\xf6\x7b\x1f\xbc\xae\xf8\x89\x31\xe0\x33\x54\xf6\x50\xe1\xbb\x0c\
\xab\xcd\x06\xc7\x13\x20\xef\x53\xb6\xd6\x5b\x39\x8a\x19\x50\xaa\
\x6d\x74\x7b\x06\x93\x9f\x92\xae\x3b\xb1\xa1\x75\x8d\x05\x74\x06\
\xb7\xd3\x2c\xbb\x7c\x27\x0b\xe9\x30\xac\xe8\x46\xe2\x0f\x52\xc4\
\x88\x5b\x95\xf2\x8f\x53\x43\x48\x91\xfe\x6e\x58\x1a\xd0\x3d\x9b\
\x26\x87\xdc\x71\x29\x44\x7e\x0d\x6d\x4a\xfd\x00\x42\xf2\xb4\xe5\
\x9a\x07\xd3\x60\x24\xf4\xd6\xcb\x1f\xe1\x85\xd6\xfa\x1a\xb8\x45\
\xe2\x78\x50\xcc\xbf\x02\x0c\x00\xb3\x4a\xfb\x1f\xcd\xe1\x9d\xc3\
\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x07\x89\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x44\x39\x41\
\x43\x30\x30\x39\x35\x35\x39\x38\x44\x31\x31\x45\x33\x41\x41\x46\
\x43\x43\x39\x35\x30\x31\x33\x33\x31\x41\x30\x30\x39\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x44\x39\x41\x43\x30\x30\x39\
\x34\x35\x39\x38\x44\x31\x31\x45\x33\x41\x41\x46\x43\x43\x39\x35\
\x30\x31\x33\x33\x31\x41\x30\x30\x39\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x36\x63\x33\x30\x35\x65\x36\x65\
\x2d\x66\x31\x33\x66\x2d\x35\x65\x34\x38\x2d\x62\x37\x32\x65\x2d\
\x33\x31\x38\x39\x62\x37\x63\x66\x34\x66\x34\x38\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x3e\x1d\
\x49\x08\x00\x00\x03\xae\x49\x44\x41\x54\x78\xda\xbc\x97\x69\x48\
\x54\x51\x14\xc7\xdf\x8c\x93\x95\x59\x4d\x8b\x11\x52\xe0\x46\xb4\
\x59\x7e\x50\xb2\x15\x22\xcb\x16\x82\xf6\x0d\x5a\x8c\x16\x93\x8a\
\xa4\x85\xc8\xd0\xb2\xc8\x32\xa1\x0f\x12\x51\x08\x69\x1b\x11\x56\
\x1f\x8c\x82\xc8\x16\xa8\x94\x92\xd4\xac\x88\xb0\xcd\x24\x22\x4a\
\xc5\x6c\x52\x4b\xeb\x7f\xe0\xff\xe4\xf6\x78\xce\xcc\x9b\xc6\x0e\
\xfc\xb8\xf7\xdd\xfb\xde\xbd\xff\x7b\xe7\xdc\x73\xcf\xd8\x76\x9e\
\x2d\xb1\x69\x9a\xb6\x15\x6c\x04\xa1\x9a\x6f\x76\x07\x2c\x3a\xba\
\x72\x7c\x9b\xd5\x0f\x6d\x10\xb0\x1b\x65\x16\x68\x06\xf9\xa0\x92\
\x75\x6f\x2c\x08\x1c\x67\xbd\x00\x24\x41\xc4\x6f\x2b\x02\x1c\x60\
\x3b\x68\x02\x53\xf0\x71\xb9\x95\x8f\x21\xde\x49\x01\xef\xc1\x6a\
\x50\x0f\x52\xad\xee\x80\x28\x3e\x02\x0e\x81\xfe\xa0\x81\x3b\x30\
\xd8\xf0\xee\x27\xd0\x03\x38\xf9\xdc\x4c\x64\xd2\xa5\x60\x15\x98\
\x03\xd2\xb1\x90\x03\xde\x0a\xb0\xb3\x2c\x03\x6b\xc1\x5b\xb0\x0d\
\xc4\xb3\xae\x12\xcf\x3e\xfd\xf9\xa2\x32\x4e\x2b\x58\x42\x5f\xc8\
\xc4\xa2\x52\xac\x0a\xf8\x05\x4a\xc1\x7e\xf0\x8e\xab\x94\xfa\x16\
\x30\x9d\x75\x27\xfb\xe6\x82\xf5\xf4\x97\x0e\xc3\xaa\x5d\x28\xe6\
\x81\x47\x20\x17\x22\x96\x5b\x11\xa0\x71\x85\x19\xe0\x34\xb8\xca\
\x7a\x02\x77\x27\x83\x6d\xd2\x57\x0b\x46\x83\x35\x06\x5f\x12\x11\
\x8d\x28\x66\x82\x17\xe2\x94\x10\x31\xdb\x8a\x80\x7b\x74\xa0\x54\
\xfe\x1c\xe1\xe0\x3a\x57\x1e\xae\x20\x83\x67\x82\x65\x40\x3f\x76\
\x31\xca\x4e\x88\x4f\x4c\x03\x35\xa0\x10\x22\x26\x7a\xe3\x84\xf3\
\x41\x18\x38\xc6\xf6\x4a\x0c\x14\xc3\x3e\x39\x5a\xf9\x6e\x4e\x42\
\x1d\x8a\x00\x30\x01\xef\x3d\x57\xda\x87\xa0\x28\x01\x7d\xc0\x64\
\xf4\x3d\xf5\x24\xe0\x06\xe8\x69\xf2\x8e\x0b\x1f\xb7\xba\x11\x90\
\x4e\x1f\xf9\x06\xf2\x40\x15\xd0\x63\x41\x14\x48\x03\x9f\x41\x2c\
\xc6\xf9\x60\x16\x07\x74\x13\xe7\xda\x6c\x32\xc7\x61\x4c\x12\xac\
\xf4\x55\x63\xa0\x75\x4a\xff\x41\xf0\x13\x24\xf3\x94\xd8\x4c\xc6\
\x18\x04\x22\x81\x5b\x01\x8d\xf4\x72\xa3\xb5\x73\x02\xbd\xef\xa3\
\xc1\xfb\xdb\x19\x49\xb3\xdc\x04\xab\x7a\x6f\x9c\x30\x84\xce\x24\
\xec\xa1\x13\x49\x3d\x9b\x5b\x1c\x89\xc9\xc4\xf3\x63\x31\x68\x05\
\xc8\xd3\xfc\x60\xea\x0e\xc8\xf1\xba\xcd\x9d\x18\xc0\xe7\xbb\x4a\
\xff\x0f\x96\xa5\x8c\x98\xd5\xfe\x16\x30\x52\xce\x3d\x56\x39\x06\
\xab\x93\xd8\xde\x97\xed\x29\x68\xbb\xa0\x6c\x79\xa6\xe6\x47\x53\
\x05\xc8\xca\x5a\x74\xc7\x03\xdd\x59\xaf\xd0\xba\xd0\x1c\xca\xca\
\xe4\x26\x2c\x67\xfd\x84\xf6\x9f\xcc\xe1\xc5\x95\x1b\xcb\x64\x25\
\xc4\xc7\x39\xba\xe9\xc7\x15\x63\x7d\x61\x5d\xca\x3c\x2c\xb4\xd4\
\xe1\x61\xf2\x44\x14\x45\xca\x20\xff\x62\xc6\x90\x9c\x84\xf1\x17\
\xd8\x3d\x7c\x94\xed\xa7\xc9\x3b\x0b\x01\x39\x9e\x04\x8c\x32\x69\
\x2b\x62\xe2\xf1\x8c\xcf\xaf\xf9\x5c\xcc\xe7\x27\x8c\x8e\x4d\xcc\
\x92\x12\x18\xa2\x2b\x79\xc9\xa9\x16\xe5\x49\x40\x80\xe1\x59\x62\
\xbc\xc4\xfe\x68\x70\x8e\x6d\x75\x14\x93\xcc\x53\x24\xe1\xf6\x15\
\xef\x96\x97\xe0\x16\x85\x48\xa6\xf5\xc0\x5d\x24\xf4\xc6\x24\x0b\
\x1a\xc8\xeb\xf6\x3c\x05\x49\x22\x12\x07\xa6\x32\x1c\xbb\x78\x03\
\xca\xdd\x12\x08\xf6\xf1\x67\x74\x31\x89\xf5\x59\x40\x1b\x13\x13\
\x39\x15\x0f\x79\x73\x16\x33\x72\xf6\xa6\xbf\x14\x70\x37\x82\x99\
\x3f\xde\x64\x7c\xc9\x01\xdf\x41\x2f\xcb\xc7\x50\xb1\x53\x60\xb8\
\x72\xe9\xc8\xa4\x67\x40\x22\x57\xea\xa4\x88\x15\x60\x2f\x93\x99\
\x06\xf6\x7d\x65\xf8\x0e\xb4\x2a\x40\x6e\xb1\x7e\xac\x47\xd3\xd9\
\x3a\x8e\x11\x78\x0c\x86\x81\xb1\x6c\x5b\xcc\xd5\x47\x30\x92\xde\
\x07\x1b\x98\xa6\xd5\x30\x95\x53\xad\xc5\x93\x80\x4b\x0c\x42\x62\
\x93\x0c\x7d\x22\x6c\x86\xc9\x37\xb3\x94\x7a\x98\x52\x8f\x20\x7f\
\x8d\x6f\xef\xc4\xdb\x75\xdb\x01\xae\x74\x51\x1c\xb8\x26\x59\xb7\
\xbe\x03\xb2\x35\x97\x8d\x6f\x20\x54\xca\x59\x5e\x88\x88\x15\xca\
\xac\xc6\x17\x93\x9d\xcb\x65\x2a\x5f\xa6\x87\x62\x8c\x5d\xab\xe7\
\x84\x0d\xf4\xf0\x38\x34\xbe\xf1\xe7\x12\x31\x76\x10\x73\x8c\x71\
\xe2\x27\x66\x89\xa9\xec\xc0\x49\xb0\x4b\xfe\x50\xe0\x83\x5c\x26\
\x95\xed\x7e\x98\x7f\x28\xd8\x04\x46\xf0\xd8\x56\x75\x76\x1b\xa6\
\x31\xa0\x24\x33\x68\xf8\xd3\x24\x97\x2c\x64\x52\x63\xfa\xaf\xf9\
\x8f\x00\x03\x00\xa7\xa0\x22\x71\x6e\x63\x94\xd3\x00\x00\x00\x00\
\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\xed\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x35\x34\x30\
\x45\x44\x39\x43\x31\x35\x39\x38\x35\x31\x31\x45\x33\x39\x39\x43\
\x37\x38\x31\x46\x35\x33\x32\x45\x32\x43\x37\x44\x43\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x35\x34\x30\x45\x44\x39\x43\
\x30\x35\x39\x38\x35\x31\x31\x45\x33\x39\x39\x43\x37\x38\x31\x46\
\x35\x33\x32\x45\x32\x43\x37\x44\x43\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xce\x34\
\xc5\x6a\x00\x00\x03\x12\x49\x44\x41\x54\x78\xda\xc4\x97\x7b\x68\
\x8d\x71\x18\xc7\xdf\xf7\xec\x98\x4b\x27\x97\x28\x0b\xa1\x30\xe6\
\x96\x92\x59\x1a\xa9\xb9\x84\x24\xfc\x65\x7f\x2c\x91\x62\x26\x92\
\x7f\xb4\x72\x59\xb9\x14\x29\xb7\x51\xb2\x64\xe5\x2f\x4d\x4b\x76\
\x71\xc9\x42\xcb\x25\xa5\xa1\x83\xa5\xdc\x9b\x3f\x84\x4d\x6e\xed\
\x8c\xcf\x53\xcf\xab\x5f\xa7\xb3\xf7\xfd\x9d\xcb\xe6\xa9\xcf\x9e\
\x9d\xf3\xfe\xde\xe7\xf9\xbe\xbf\xf7\xf7\x7b\x7e\xcf\x71\x1d\x0b\
\xbb\x51\xb9\x2e\x0b\x37\x0f\x96\xc2\x6c\xc8\x85\xe1\x7a\xf9\x17\
\xbc\x81\x47\x32\x14\x6a\x8b\x4a\xab\xda\x1c\x4b\x73\x03\x12\x47\
\x70\x65\xb0\x19\x46\x59\xc6\xec\x84\x2b\x70\x10\x21\x77\x53\x16\
\x40\xf2\x55\xb8\xe3\x30\xc2\x49\xdd\x2e\xc1\x76\x84\xbc\x32\xe2\
\x8e\xc4\x55\xf0\xdd\xfa\x84\x02\x18\xd0\x07\x77\x0c\x36\x3a\x99\
\xb1\x0e\x99\x41\x12\x56\x13\x7b\x32\xff\x37\xc0\x30\x88\xf0\x5d\
\x97\x1b\x97\x3c\x1b\x77\x11\x96\x3b\x99\xb7\xf3\x1a\x77\x88\x7e\
\xce\x45\x40\x6b\xc8\x48\x2e\x62\x2e\xf4\x50\x72\xb1\x12\x23\xb9\
\xd8\x54\xf9\x13\x36\xbe\xd8\x09\xab\x2d\x02\xb5\x43\x13\x3c\x87\
\x2f\x30\x14\x0a\x21\x3f\x49\x41\xd3\x64\x8d\x84\xf5\xe9\x45\x4d\
\x45\xc0\x0d\xb2\x90\xf6\xca\x2c\x31\x75\xbf\x13\xac\x9d\x71\xb8\
\x2d\xb0\x09\xb2\x2d\x05\xfc\x9b\x81\xc3\x90\x15\xf0\xfe\x64\x21\
\x7d\xeb\x6e\x00\xd7\x5e\xe2\xb6\x21\x44\x16\xf0\x39\x98\x6b\x23\
\x20\xc4\x0d\x33\xf1\x8b\x7d\x06\x56\xc2\x5a\xbf\xe4\x71\xf6\x1a\
\x5a\x2d\xc6\x8d\x27\x77\x3f\x99\x81\x0d\x3e\x83\x6e\xc3\x56\x92\
\xff\xb1\xac\x98\x03\x74\x17\x2d\xb1\x18\x2e\x33\x9e\x17\xd6\xf2\
\x9a\xc8\x24\x69\x19\xc9\x3b\x2d\x93\xf7\xc7\x5d\x83\x39\xc9\x2c\
\x44\xd9\x86\x93\x60\x21\xec\x83\x66\x88\xe9\xc5\xab\x24\x6f\xb1\
\x8d\xc4\xd8\x1f\xfa\x30\x2b\xb4\x82\x46\x6d\x04\xb8\xdd\xd4\x7f\
\xd9\x56\x9f\x08\xfa\x20\x9d\x8d\xaf\x65\x77\x81\x41\x4e\xdc\x90\
\x46\xd7\xe9\x45\x43\xd0\x14\x43\xcc\x7c\xf8\xda\xab\x02\xe2\xc4\
\xc8\xfa\x2b\x90\x7f\x0a\xf5\xc3\x7f\x31\x97\xe4\xef\xf0\x83\xb4\
\xbc\x5e\x17\x78\xf7\x4f\x7b\x53\x40\x43\x82\x42\xd4\xe6\x89\x51\
\x41\xef\xd3\x9c\xee\x59\x7a\x66\xdc\x89\x2f\x68\x22\xe0\x10\x7e\
\x47\x40\x8c\xa8\x21\xa8\x89\x20\xed\x49\x0a\xf0\x1e\x52\xb6\xf8\
\x3d\xb8\xa9\x33\xde\x2c\x75\xe0\xb1\x45\x8c\x3c\x3d\x68\x6a\xa1\
\x5e\x8b\x8e\x6d\xf2\xe9\xb8\x45\x46\xf5\x93\x42\x55\xae\x45\xeb\
\x99\xad\x00\xcf\xea\xa5\x68\x69\xd1\xb1\x5d\xe9\x27\x7c\x5a\xbf\
\xba\x90\x4e\x6f\x97\x45\xbc\x2a\x69\x56\x48\xfe\xdd\x32\xb9\x24\
\x3d\x1a\x70\x2a\x9e\x09\x11\xf0\xa7\xe5\xe9\x35\x01\xc6\x58\x26\
\x8f\xe8\x91\x5c\xea\x33\xac\x91\xdc\x0f\xbd\xfd\x2f\xaf\x61\x62\
\x40\x5c\x79\x92\x28\xc1\x4f\x49\xad\xd7\xf3\xdf\x49\xd0\x53\x16\
\xc3\x6e\x18\xeb\x13\x2b\xe6\x2d\x7c\x57\x6f\x94\x1b\xf6\x24\xb9\
\xbb\xee\xcb\xb6\x92\x33\x03\x06\xeb\x03\x48\x79\x1d\x68\x71\x6f\
\x39\x0f\xb0\xdf\xec\x88\x5a\x52\xd8\xde\xf9\x29\xf4\x81\x62\x35\
\x70\xc0\xfb\xe0\x75\xc5\x4f\x8c\x01\x9f\xa1\xba\x87\x0a\xdf\x65\
\x58\x63\x36\x38\x9e\x00\x79\x9f\xb2\xb5\xde\xca\x51\xcc\x80\x12\
\x6d\xa3\x3b\x32\x98\xfc\xb4\x74\xdd\xf1\x0d\xad\x6b\x2c\xa0\xb3\
\xb8\x5d\x66\xd9\xe5\x3b\x59\x48\x47\x60\x65\x1a\x89\x3f\x48\x11\
\x23\x6e\x4d\xd2\x3f\x4e\x0d\x21\x05\xfa\xbb\x61\x59\x40\xf7\x6c\
\x9a\x1c\x72\x27\xa5\x10\xf9\x35\xb4\x49\xf5\x03\x08\xc9\xd1\x96\
\xab\x08\x66\xc0\x68\xe8\xab\x97\x3f\xc2\x0b\xad\xf5\x75\x70\x8b\
\xc4\xb1\xa0\x98\x7f\x05\x18\x00\x90\xb5\xfd\x36\x34\xeb\xb9\xe4\
\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\xa4\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x42\x33\x41\
\x34\x45\x35\x42\x34\x35\x39\x38\x34\x31\x31\x45\x33\x42\x33\x31\
\x41\x45\x43\x34\x30\x43\x43\x32\x45\x39\x37\x31\x33\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x42\x33\x41\x34\x45\x35\x42\
\x33\x35\x39\x38\x34\x31\x31\x45\x33\x42\x33\x31\x41\x45\x43\x34\
\x30\x43\x43\x32\x45\x39\x37\x31\x33\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x63\x31\x65\x61\x38\x31\x32\x35\
\x2d\x65\x62\x64\x64\x2d\x63\x38\x34\x62\x2d\x39\x66\x37\x61\x2d\
\x30\x36\x39\x39\x32\x39\x38\x64\x62\x39\x33\x63\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x47\x2d\
\xcb\x84\x00\x00\x02\xc9\x49\x44\x41\x54\x78\xda\xc4\x57\x3f\x68\
\x93\x41\x14\xff\xbe\x10\x07\x07\x3b\x39\x89\x53\x51\x52\x1b\xd4\
\x45\x70\x90\xaa\x74\x28\xba\x28\x14\x07\xd7\x12\x41\x68\x27\x69\
\x52\x1d\xc4\x21\x76\x51\x11\xb7\xba\xa8\x38\x38\x04\x07\xc1\xe2\
\x10\x1d\x4a\x1d\xbb\xf9\x87\xb4\x69\xa3\x99\x82\x53\x1d\xcc\x2a\
\x34\xfe\x1e\xfc\x0e\x8e\xf3\xde\xdd\x97\xd0\x4f\x1f\xfc\xf8\xc2\
\x5d\xde\x7b\xbf\x7b\xef\xdd\xbb\xbb\x34\x19\x41\xce\xbe\xbd\x5e\
\xc5\xe7\x1e\x70\x88\x43\x7d\xa0\xbe\x71\xb5\xf1\x78\x58\x5b\xe9\
\x08\xce\x8f\xe0\xd3\xf3\xe8\x0e\x80\xa3\x20\xf1\x63\x18\x7b\x85\
\x11\x02\x70\x5c\x21\x9e\x72\x6e\x28\x29\x2a\xab\x9c\xc3\x67\x1e\
\xd8\x05\xaa\x58\x55\x2b\x63\xd4\x52\xc7\xce\x79\x49\x0d\xfd\x2c\
\xc3\x4e\x33\x1a\x01\x28\xdd\xc1\xe7\x05\x70\x06\xb8\x04\xac\x63\
\xec\x24\xe7\xc4\xc1\x78\x80\xc0\x38\xff\x23\xff\x9d\xc6\x47\x1c\
\x5e\x00\xce\x01\xab\x18\xbb\x12\x63\x3c\x47\xe7\xae\x48\x24\x1e\
\x01\x37\x32\x84\xf9\x1b\xd0\x00\x16\x81\x83\xce\xdc\x6f\x59\x14\
\x22\xb1\xa6\x45\x60\x5e\x31\x7a\x18\x78\x90\x31\xc7\xc7\x80\xbb\
\x1e\xe7\x22\x07\x80\x9b\xa1\x14\xec\x26\xf9\xcb\xcf\x10\x81\x6a\
\xce\x24\xbe\x03\xf7\x83\x7d\x80\x05\xb7\xc6\xb0\x87\x64\x1b\xd8\
\xe2\xef\x13\x40\x29\x83\xf3\x8b\xc8\x7f\x2f\xda\x88\x40\x62\x89\
\x39\xf7\xc9\x7b\x60\x09\x86\xbe\x38\x3a\xa7\x58\xa8\x33\x8a\xde\
\x02\x74\x56\xa2\x9d\x90\xdb\x68\x5b\x29\xb8\x27\x52\xdd\x30\x34\
\x50\x88\x8b\xae\xb4\xe3\x5b\x9e\xe9\x1d\x60\xc2\xd5\x4d\xad\xf6\
\x6a\x3a\x9c\xec\xf3\xe7\xca\xca\x2f\x1b\x03\xd0\x91\xfa\x99\xe4\
\xdc\x26\xc6\xf7\x2c\x12\x4d\x25\x12\x15\xa0\xcb\xb6\xdd\x91\xb6\
\x9d\x42\x61\x91\xa1\x8b\x9d\x0b\xa7\x4d\xd8\xa1\x23\x39\x7f\x23\
\x2b\xe2\x5c\x1b\x98\xc5\xfc\x96\x95\x8e\xcf\x11\x7b\x42\xa2\x26\
\x04\x7e\xe1\xc7\x58\xac\xe0\x60\x7c\xc2\x5a\x79\xcb\x72\x9e\x58\
\x24\xca\x56\x24\xda\x19\x0a\xb3\x5f\xc8\xe0\xdc\x18\x37\x52\xf6\
\x38\x4f\x38\x36\xa9\xe8\x68\x32\x56\x48\xfe\xb3\x14\x78\x99\x88\
\x89\xbd\xe2\x96\xb2\x3a\x19\xdb\x54\x74\x82\x29\xa8\xb3\x20\x42\
\x52\x62\x61\x25\xcc\xf1\xac\x43\xc2\x14\xe1\x9e\x55\x84\xa5\x0c\
\x45\x58\x1f\x66\x1b\x7e\xe0\x49\x66\x6f\xc3\xb2\x89\xca\xc8\xdb\
\x50\x69\x26\x3b\x3c\xd5\xf6\xb3\x11\x75\x24\x2a\xae\xee\x5f\x45\
\xc8\x3f\x34\x94\xb0\x89\xe1\xa6\x49\x87\xa7\x15\x37\x15\xe7\x22\
\xcf\x7c\xc4\x7d\x11\x90\x9b\xcc\x3b\xe5\x3c\x77\x0f\xa3\xb6\x55\
\x70\xb1\x9c\xcb\x29\x3b\x0d\x12\x5f\x63\x77\xb8\x66\x06\xe7\xa3\
\x8a\x90\x98\x02\x89\xb6\x96\x82\x7a\x8e\xce\xcd\xcd\xea\x76\xa8\
\x06\x8a\xff\xa0\xf7\x14\x43\x04\x96\x79\x71\xf4\x5d\x26\x16\xb8\
\x3b\x62\xd2\xe1\x2a\x7d\x37\xab\x3e\x77\x89\x9f\x00\xef\xed\xd7\
\x1c\x12\xe6\x26\xb3\xc2\x62\xab\x04\x9c\x57\xb8\xd5\x1e\x4a\xc1\
\x39\x24\xc4\xf9\x0c\xe6\x3e\xc5\xb6\xe1\x2a\xdf\x03\xaf\x81\xa7\
\x2c\x9a\x9e\xb5\x45\xbb\x01\x02\x5d\xb3\xd5\x58\xed\x53\xc0\x4b\
\xe0\x95\xbc\x0f\x30\xb6\xb1\x1f\x6f\x43\x79\x68\xac\x2b\xd3\x12\
\xa9\x8f\x79\xbf\x0d\x3b\xca\xd9\x31\xe0\x5c\x92\x2b\x01\xbe\x7e\
\x6b\xce\x29\x2a\x97\x9a\xda\xb0\x2f\x63\x91\x3f\x02\x0c\x00\x21\
\x27\x10\xbf\xa7\x82\xc6\x68\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
\x42\x60\x82\
\x00\x00\x04\xf8\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x41\x45\x36\
\x37\x43\x43\x34\x36\x35\x39\x38\x44\x31\x31\x45\x33\x39\x32\x37\
\x33\x46\x43\x46\x32\x35\x44\x37\x31\x38\x43\x35\x39\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x41\x45\x36\x37\x43\x43\x34\
\x35\x35\x39\x38\x44\x31\x31\x45\x33\x39\x32\x37\x33\x46\x43\x46\
\x32\x35\x44\x37\x31\x38\x43\x35\x39\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x37\x31\x65\x61\x35\x61\x61\x61\
\x2d\x63\x33\x30\x31\x2d\x30\x61\x34\x35\x2d\x62\x36\x30\x35\x2d\
\x38\x64\x36\x65\x63\x37\x33\x34\x65\x37\x62\x66\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xe1\x20\
\xe3\x43\x00\x00\x01\x1d\x49\x44\x41\x54\x78\xda\x62\x6c\x4f\x5c\
\x74\x8e\x81\x81\xc1\x90\x01\x3b\xf8\x0b\xc4\x61\x95\xf3\xe3\xd6\
\x81\x38\x40\xb5\x09\x40\x6a\x1e\x10\x33\x32\x50\x07\x9c\x67\xc2\
\x63\x39\x08\x30\x03\xb1\x1e\x12\xdf\x81\x8a\x96\x83\x80\x21\x13\
\xc3\x00\x83\x51\x07\x8c\x3a\x00\xe4\x80\x4f\x04\xd4\x7c\x44\x62\
\x3f\xa7\xb2\xfd\x9f\x58\x80\x84\x31\x10\xeb\xe0\x50\xf0\x03\x88\
\xf7\x20\xf1\x1b\x80\xf8\x30\x10\xb3\x51\xc9\x01\x57\x18\x46\x3c\
\x60\x84\x16\xaf\x0e\x38\xe4\xbf\x00\x71\x07\xb0\x28\x7e\x02\x2d\
\x8a\xd5\x80\x54\x31\x10\xb3\x53\xc9\xfe\x03\x2c\x44\x94\xed\xaf\
\x80\xb8\x09\xca\x2e\x04\xe2\x34\x2a\x06\x40\x1c\x13\x11\x65\x3b\
\x72\x56\xe5\xa4\x76\x0c\x8c\x16\x44\xa3\x0e\x00\x39\xe0\x3f\x01\
\x35\xff\x90\xd8\xdf\xa9\x6c\xff\x7f\x50\x36\x4c\x22\x50\x0e\xcc\
\x43\xe2\xf7\x43\x1d\x4d\xb5\x72\x60\xb4\x28\x06\x15\xc5\x2a\x78\
\x6a\x43\x50\x9c\xef\x05\x16\xc5\x7f\xa0\x45\x31\x28\xe8\x9d\xa9\
\x59\x1b\x82\xd2\xc0\x59\x20\xe6\xc3\xa3\xa8\x08\x1a\xf7\xb0\xea\
\xb8\x82\x9a\xed\x01\x26\x02\x96\x83\x00\x3f\x12\x5b\x92\xca\x31\
\xc0\x37\x5a\x10\x8d\x3a\x60\x50\x38\xe0\x1c\x1e\x79\x50\xfe\xbf\
\x84\x56\x74\xfe\xa7\xa2\xfd\xe7\x18\xff\xff\xff\x3f\xa0\x21\x00\
\x10\x60\x00\xb3\xf5\x3a\xe9\xf9\xc0\x6c\x8c\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\xb1\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x71\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\
\x39\x66\x62\x31\x39\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\
\x39\x39\x31\x31\x2d\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\
\x31\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x42\x45\x42\
\x44\x37\x42\x46\x37\x35\x39\x38\x44\x31\x31\x45\x33\x39\x39\x41\
\x31\x41\x44\x34\x30\x37\x44\x35\x45\x43\x33\x39\x32\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x42\x45\x42\x44\x37\x42\x46\
\x36\x35\x39\x38\x44\x31\x31\x45\x33\x39\x39\x41\x31\x41\x44\x34\
\x30\x37\x44\x35\x45\x43\x33\x39\x32\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\
\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\
\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\
\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x37\x31\x65\x61\x35\x61\x61\x61\
\x2d\x63\x33\x30\x31\x2d\x30\x61\x34\x35\x2d\x62\x36\x30\x35\x2d\
\x38\x64\x36\x65\x63\x37\x33\x34\x65\x37\x62\x66\x22\x20\x73\x74\
\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x34\x37\x39\x66\x62\x31\x39\
\x2d\x34\x33\x34\x34\x2d\x62\x65\x34\x33\x2d\x39\x39\x31\x31\x2d\
\x33\x64\x35\x32\x63\x31\x30\x33\x35\x37\x65\x31\x22\x2f\x3e\x20\
\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\
\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\
\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\
\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x59\x34\
\x5e\xf3\x00\x00\x02\xd6\x49\x44\x41\x54\x78\xda\xc4\x97\x5d\x88\
\x4d\x51\x14\x80\xcf\x3d\x73\x63\x26\xe6\x0f\x2f\x63\xa8\x91\xc2\
\x35\xe3\x67\xfc\x34\xe1\x6d\x26\x94\x28\x23\x4f\xa3\xa6\x34\xe4\
\x61\x46\x92\x17\x3f\x8d\x48\x92\x9f\xf0\x20\x2f\x46\x44\x92\x07\
\x19\x85\xc4\x83\x9f\x17\x94\x50\x73\x87\x49\x29\xf2\x73\xf3\x30\
\x4d\x83\x49\x46\x5c\xdf\xd2\x3e\x75\xba\x73\xf6\xbe\xfb\x9c\xb9\
\x87\x55\x5f\xeb\xde\x73\xf6\x59\x6b\xed\xb5\xd7\xd9\x7b\x9d\x84\
\x63\x29\x87\x36\x5e\x28\x47\x35\xc3\x52\x68\x80\xc9\x30\x01\x5c\
\xf8\x0e\x6f\xa1\x17\x1e\xc0\xb5\x5d\xe7\x5a\x3f\xda\xd8\x4d\x58\
\x38\x9e\x85\xea\x84\x75\x50\x6c\x19\x6f\x16\x6e\xc3\x11\x02\xb9\
\x1f\x29\x00\x1c\x97\xa1\x8e\x42\x1b\x14\x39\xd1\xa5\x1b\x3a\x74\
\x19\x49\x68\x9c\xcf\x97\x34\x42\x8d\x53\x18\xe9\x87\x16\x82\xb8\
\x93\x7b\xc3\x0d\x70\xde\xa8\xd6\xb1\x50\xce\x45\x26\xc2\x0d\x6c\
\x6f\x30\x66\x80\x01\xf5\xca\x79\xa9\x13\x8f\xfc\x86\x35\x64\xe2\
\xd6\x88\x00\x70\x5e\x81\x7a\x6e\x31\xf3\x21\xb8\x09\x8f\x21\x03\
\x3f\x61\x0a\x2c\x16\xe3\x50\x96\xe7\xf9\x41\x58\x48\x10\x6f\xe4\
\x4f\xd2\x9f\x80\x3c\xce\xbf\xc2\x01\x38\xcd\xc3\x43\x9a\xda\x29\
\x41\x6d\x81\x7d\x50\xae\xb1\x23\xd7\xcf\x30\xb6\x09\x3b\xd9\x84\
\x7a\xb0\x0e\xf5\xc2\x50\xed\x69\x58\xeb\x45\x6d\xf1\xea\x4e\x55\
\xd5\xbf\xc0\x30\xac\x19\x7b\xdd\x5e\x11\xbe\x86\xcd\xca\x51\xae\
\xf4\x41\xa3\xad\x73\x11\xc6\xbe\x97\x67\xd4\xa4\x74\xb2\x27\xa8\
\x08\xe5\xff\x72\xd8\x01\x2b\x60\x18\xea\x31\xf8\x32\x4a\xc5\x61\
\x6f\x3a\xaa\x07\x4a\x34\x43\xe6\x9a\x36\xa2\x39\xa8\xd9\x38\xbf\
\x32\x9a\xb2\xc7\xce\x7e\xd4\x5e\xcd\xed\xce\x84\x13\xb3\x10\x40\
\x15\xea\x43\xd0\x9e\x83\xdc\x75\xe3\x0e\x80\x0c\x66\x0c\xb5\x90\
\x4a\x12\x61\x35\x3f\x96\x49\xd5\x32\x78\x38\xa6\x38\xd2\x9a\x37\
\xa2\x4a\x32\x30\x03\x64\x9d\x3f\x11\xcc\x71\xa8\x8d\x21\x80\x01\
\xcd\xf5\x22\xd9\x88\x2a\x7d\xfb\xf5\x76\x81\x20\x1e\xa1\xcf\x4a\
\x60\x64\xe5\x5b\x81\xce\x82\x20\xf9\x25\x19\xa8\x08\xb8\xb1\x04\
\xba\x64\xab\x25\x98\x2e\x68\x18\x65\x00\x75\x9a\xeb\x19\x7f\x06\
\x82\x64\xbc\xea\x07\xda\x08\x22\xad\xb2\x72\x91\xac\xf4\x87\x78\
\x0b\xe4\x9c\x98\xa7\xb9\xfd\xca\xcd\x13\x40\xee\x2c\x4e\xc0\x79\
\x8c\x16\x87\x98\xfd\x56\x43\xe3\xf3\x30\x19\x22\x80\xcf\x52\x1f\
\xcc\xfe\x72\x88\xd9\xa7\x50\xdb\x0c\x43\xae\x27\x35\x35\x90\x2b\
\x97\xa0\x1d\xe7\x83\x21\x9c\x4f\x42\x5d\x85\xb1\x9a\x21\x4f\xb1\
\xd7\x63\xbb\x04\x8b\xe4\x9d\x0d\x79\x06\x48\x63\x93\x32\x0c\x3b\
\xe8\xf5\x03\x36\x01\xcc\x84\x67\x18\x96\x26\xf5\x24\x91\x0f\x18\
\x1a\xd9\x0e\xd8\x0d\xe3\x0c\xf6\xee\x49\xfa\xff\x9e\x86\x3c\xd4\
\xa7\x1c\xd8\xca\x0f\xd9\xc3\xe1\x89\xda\xe3\x45\xaa\x55\x47\xb4\
\xd2\xa2\x75\x1f\xd1\x11\x79\x19\x78\x07\xc7\x54\x6a\x4c\x6d\x95\
\xac\xe9\x6a\x45\x94\x9e\xb0\xc5\xdf\x5b\xb8\x2a\x55\x87\xd5\xd1\
\x7b\x4a\xf5\x75\x5f\x62\xd8\x8e\xa5\x77\x6c\xf5\x37\xa4\xde\x12\
\xd4\x72\xb1\x37\xa0\x17\x90\x35\x9a\x16\xf7\x77\x81\xa9\x21\x29\
\x55\x4b\xb2\x49\x73\x96\xc7\xf7\x65\x14\x90\x8d\x9d\xb0\x1e\xc6\
\xfc\xb3\x6f\x43\xcd\xc6\xb2\x0a\x9a\xd4\xde\x5e\xe3\x6b\xbd\xa3\
\x7f\x1d\x67\xb3\x59\xe7\x7f\xca\x1f\x01\x06\x00\x05\x3b\xea\xc8\
\xfa\x24\x85\x20\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\
\x00\x00\x69\xec\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x01\x00\x00\x00\x01\x00\x08\x06\x00\x00\x00\x5c\x72\xa8\x66\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x6b\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x35\x2d\x63\x30\x31\x34\x20\x37\x39\
\x2e\x31\x35\x31\x34\x38\x31\x2c\x20\x32\x30\x31\x33\x2f\x30\x33\
\x2f\x31\x33\x2d\x31\x32\x3a\x30\x39\x3a\x31\x35\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x30\x43\x31\
\x42\x46\x41\x46\x35\x41\x33\x39\x32\x45\x31\x31\x31\x41\x36\x37\
\x39\x38\x32\x45\x39\x30\x31\x31\x30\x33\x32\x43\x43\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x43\x41\x33\x32\x31\x42\x46\
\x41\x35\x34\x30\x38\x31\x31\x45\x33\x41\x31\x35\x45\x45\x45\x33\
\x31\x41\x34\x30\x39\x34\x30\x45\x31\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\x70\
\x2e\x69\x69\x64\x3a\x43\x41\x33\x32\x31\x42\x46\x39\x35\x34\x30\
\x38\x31\x31\x45\x33\x41\x31\x35\x45\x45\x45\x33\x31\x41\x34\x30\
\x39\x34\x30\x45\x31\x22\x20\x78\x6d\x70\x3a\x43\x72\x65\x61\x74\
\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\x65\x20\x50\x68\
\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x28\x4d\x61\x63\x69\
\x6e\x74\x6f\x73\x68\x29\x22\x3e\x20\x3c\x78\x6d\x70\x4d\x4d\x3a\
\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\x52\x65\
\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x69\x69\x64\x3a\x39\x31\x66\x35\x61\x38\x61\x34\x2d\x36\
\x31\x62\x36\x2d\x34\x66\x34\x62\x2d\x62\x38\x61\x38\x2d\x32\x31\
\x61\x66\x32\x62\x30\x37\x63\x64\x31\x38\x22\x20\x73\x74\x52\x65\
\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x64\x69\x64\x3a\x30\x43\x31\x42\x46\x41\x46\x35\x41\x33\
\x39\x32\x45\x31\x31\x31\x41\x36\x37\x39\x38\x32\x45\x39\x30\x31\
\x31\x30\x33\x32\x43\x43\x22\x2f\x3e\x20\x3c\x2f\x72\x64\x66\x3a\
\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\x72\
\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x65\
\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x64\xc0\x1f\x2c\x00\x00\x66\x17\
\x49\x44\x41\x54\x78\xda\xec\x7d\x07\x80\x1d\x75\xb5\xfe\x37\x73\
\x7b\xdd\xbb\x7d\x37\xbd\x07\x12\x52\x08\x81\xd0\xa4\x13\xaa\x48\
\x49\xa4\x17\x69\x02\x8a\xe2\x53\xf9\x8b\xa0\xf2\xb0\x20\x8a\xcf\
\xf7\xf4\xd9\x50\x9f\x0a\x22\x9d\xa0\x14\xe9\x45\x29\xd2\x09\x25\
\x05\x42\xfa\x6e\xb6\xef\xbd\x7b\x7b\x99\x99\xff\x39\x67\xe6\x6e\
\x49\x93\x96\x6c\xc9\xef\xc0\xe4\xee\xde\x3b\xf7\xee\xcc\xdc\x39\
\xdf\xf9\x4e\xf9\x9d\xa3\x59\x96\x05\x25\x4a\x06\x43\x0e\x3b\xec\
\x30\x3c\xf5\xd4\x53\xbb\xdc\x79\xf3\x39\x1f\x72\xc8\x21\x43\xe2\
\x58\xdc\xea\x36\x54\x32\x58\xd2\xdd\xdd\x8d\xda\xda\x5a\xdc\x78\
\xe3\x8d\x35\x9d\x9d\x9d\x99\x1f\xfd\xe8\x47\x99\x96\x96\x96\x01\
\xfb\x5c\x75\xd5\x55\x98\x3b\x77\x2e\x72\xb9\xdc\xb0\x3b\x3f\xbf\
\xdf\x8f\xef\x7c\xe7\x3b\x58\xb1\x62\xc5\x80\xe7\x03\x81\xc0\x90\
\x39\xc6\x21\x07\x00\xf1\x78\x1c\x6f\xbc\xf1\x86\x7c\xe1\x7b\xed\
\xb5\x17\xdf\x20\x7e\xd3\x34\xab\xe9\xa5\x1a\xda\x82\xb4\x79\x69\
\xd3\x94\xfa\x0c\x7f\xd9\x67\x9f\x7d\x90\xcd\x66\x23\xc7\x1d\x77\
\xdc\x1e\xa4\xf8\x6f\xdd\x77\xdf\x7d\x8f\x13\x28\x88\xa6\xe7\xf3\
\x79\xd9\x67\xdf\x7d\xf7\xc5\xc2\x85\x0b\x91\x4e\xa7\x87\xdd\xf9\
\x85\x42\x21\xfc\xec\x67\x3f\xdb\xe2\xf9\x17\x5e\x78\x01\xd3\xa7\
\x4f\x47\x2c\x16\x53\x00\xb0\xb9\xbc\xf6\xda\x6b\x38\xfc\xf0\xc3\
\x31\x7e\xfc\x78\xdc\x71\xc7\x1d\x7a\x65\x65\xe5\x78\x02\x83\xc5\
\x9a\xa6\x9d\xac\xeb\xfa\x74\x06\x01\xfa\x59\x69\xcf\x08\x90\xdf\
\xfc\xe6\x37\x02\xf4\x1d\x1d\x1d\x08\x87\xc3\xef\x90\xa5\xbf\x64\
\xe5\xca\x95\xaf\xa6\x52\x29\xd2\xff\xbc\xc9\xfb\xf0\xeb\xac\xfc\
\xc3\x11\x00\x58\x0c\xc3\xd8\xe2\xb9\xaf\x7c\xe5\x2b\x98\x35\x6b\
\x96\xdc\xe7\x83\x2d\xfa\x50\xbb\x60\x1c\x93\xf0\xf9\x7c\x78\xf0\
\xc1\x07\x7d\x0b\x16\x2c\x38\x90\x6e\x80\x2f\xd0\xd3\x27\x91\xd2\
\x4f\xa4\xcd\x4f\x9b\x0a\x5a\x8c\x10\xc9\x64\x32\xe8\xe9\xe9\x01\
\x31\x3c\xfe\xde\x77\x3f\xf5\xd4\x53\x7f\x70\xd8\x61\x87\x1d\x44\
\xca\xee\x25\x9a\xec\xe2\x7d\xbc\x5e\xef\x88\x3c\x77\x97\xcb\xa5\
\x5c\x80\xad\x09\x23\xfe\x0d\x37\xdc\xa0\xcf\x9c\x39\x73\x36\xdd\
\x08\x5f\x72\xbb\xdd\x9f\x76\x68\xbf\x92\x11\x26\x0c\xf6\xac\xfc\
\x72\x23\xba\xdd\xfa\x98\x31\x63\x3e\x75\xde\x79\xe7\x7d\xd3\xe3\
\xf1\x58\xf7\xdf\x7f\xff\xb3\xe4\x1e\x64\xd7\xad\x5b\x67\x1d\x75\
\xd4\x51\x02\x16\xc3\x4d\x98\xa9\x0e\x75\xb6\xaa\x0f\xc5\x83\x9a\
\x30\x61\xc2\x34\x7a\x38\x91\x28\xff\xd1\x4a\xf9\x77\x1d\x30\x60\
\x65\xd9\x7d\xf7\xdd\x0f\xba\xe4\x92\x4b\xbe\x73\xf0\xc1\x07\xef\
\x53\x53\x53\x13\xf8\xc6\x37\xbe\xa1\xdd\x79\xe7\x9d\x20\x57\x10\
\x2a\x63\xb5\x8b\x00\x40\xb1\x58\x3c\xd1\xa1\xfd\x21\xf5\x15\xed\
\x02\x37\xa1\xae\xf7\x5a\x4b\xfe\xb9\xb1\xb1\x71\xff\x2b\xaf\xbc\
\xf2\xfb\x8b\x16\x2d\x3a\x98\x18\xa1\xe7\xa2\x8b\x2e\xd2\x96\x2c\
\x59\x82\xea\xea\xea\x01\x96\x75\x38\x6c\x43\x5d\xdc\x43\xf4\x86\
\x38\x84\x1e\xa6\x2b\xd5\xd8\x35\x99\x00\xb9\x00\x20\x77\x60\xff\
\x53\x4e\x39\xe5\xca\x52\xa9\x64\xdc\x7a\xeb\xad\xff\xfc\xdc\xe7\
\x3e\xc7\xd9\x01\xeb\xe4\x93\x4f\x96\xf4\xa1\x92\x11\x0c\x00\xb0\
\xd3\x7d\xba\xfa\x7a\x76\x0d\xd9\x9a\xa5\xe4\xe7\x76\xdb\x6d\xb7\
\x43\xce\x3f\xff\x7c\xcf\xc6\x8d\x1b\xbf\xf1\xf4\xd3\x4f\xbf\x7a\
\xe1\x85\x17\x72\x6e\xd0\x24\x60\x40\x57\x57\xd7\x90\xb7\xb0\xc3\
\x81\x01\x0c\x55\x25\x53\xce\x9e\x02\x05\x71\x07\x46\x8f\x1e\x7d\
\xc0\x35\xd7\x5c\xf3\x7d\xb2\xfc\xfb\x16\x0a\x05\xf7\x05\x17\x5c\
\xa0\xdd\x7b\xef\xbd\xa8\xaa\xaa\x52\x17\x69\x04\x33\x00\x25\xbb\
\x38\x03\x28\x0b\xbb\x03\x13\x27\x4e\x3c\xe8\xec\xb3\xcf\xbe\x8a\
\x00\xe0\x7b\x0f\x3e\xf8\xe0\xcb\x65\x77\x80\x99\xc0\x50\x76\x07\
\x14\x03\x50\xa2\xe4\x13\x88\x09\xb0\x22\xcd\x9e\x3d\xfb\xc8\x2b\
\xae\xb8\xe2\x3f\xf7\xd9\x67\x9f\x39\xf4\xb4\x97\x98\x80\xce\x4c\
\x80\xb3\x03\x4a\x14\x00\x28\x19\xc6\xd6\xff\x83\x44\xd2\xd9\x1d\
\x18\x37\x6e\xdc\xc1\xdf\xff\xfe\xf7\x7f\xf0\xd9\xcf\x7e\x76\x3f\
\x62\x03\x2e\x62\x02\x3a\x67\x07\xd8\x1d\x50\x99\x00\xe5\x02\x28\
\x19\x81\x2e\x40\x7f\xf1\x7a\xbd\xda\xe4\xc9\x93\x0f\x3d\xe7\x9c\
\x73\x8a\xf4\xeb\xf5\x77\xdd\x75\xd7\x8b\xf4\x73\x8e\x58\x82\xb5\
\x68\xd1\xa2\x21\x17\x18\x54\x2e\x80\x12\x25\x3b\xc0\x1d\x98\x35\
\x6b\xd6\x42\x76\x07\x0e\x3a\xe8\xa0\x3d\x43\xa1\x90\xef\xa2\x8b\
\x2e\xd2\x09\x0c\x54\x60\x50\x01\x80\x92\x91\xea\x06\xf4\xa7\xd3\
\x1c\x18\x6c\x6c\x6c\xfc\xd4\xb5\xd7\x5e\xfb\xbd\xe3\x8e\x3b\x6e\
\x41\x36\x9b\x75\x9d\x7f\xfe\xf9\x7a\x39\x3b\xa0\xe8\xff\x08\x71\
\x01\x54\xe9\xe7\xc8\xb7\xe8\x1f\x85\x2a\x3b\x0b\xc6\xb4\xa9\x53\
\xa7\xb2\x3b\x90\x8b\xc7\xe3\xdf\x7d\xf4\xd1\x47\x5f\xa7\x9f\xb9\
\x4e\x60\xc8\xb8\x03\xca\x05\x50\xa2\x64\x07\x01\x7c\xd9\x1d\xd8\
\x73\xcf\x3d\x8f\xb9\xfa\xea\xab\xaf\xdb\x7b\xef\xbd\x67\xea\xba\
\xee\x3d\xef\xbc\xf3\xf4\xbb\xef\xbe\x5b\xb9\x03\x0a\x00\x94\x8c\
\x44\x17\x60\xf3\xcd\xed\x76\x63\xd2\xa4\x49\x47\xdc\x70\xc3\x0d\
\x3f\xf8\xcc\x67\x3e\xb3\x57\xa1\x50\xd0\x89\x09\xe8\xf7\xdc\x73\
\xcf\x90\x71\x07\x94\x0b\xa0\x44\xc9\x0e\xa2\xca\xcc\x04\xb8\x67\
\xc0\x8c\x19\x33\x16\x9e\x7b\xee\xb9\x05\xfa\xfd\x07\x8f\x3d\xf6\
\xd8\x1b\x67\x9d\x75\x96\x14\x0b\x2d\x5e\xbc\x78\xd0\xdc\x01\x15\
\x03\x50\xa2\x64\x27\x29\x0a\x7f\xc6\x3e\xfb\xec\x73\x7c\x5d\x5d\
\x5d\xa0\xad\xad\xed\xaa\x57\x5e\x79\xe5\x4d\x02\x84\x22\x3d\x6f\
\x0e\x16\x08\xa8\x18\x80\x12\x25\x3b\xd3\x9a\x91\x3b\x30\x66\xcc\
\x98\x43\xaf\xbf\xfe\xfa\xef\x9f\x71\xc6\x19\xfb\x95\xdd\x01\x95\
\x22\x54\x0c\x40\xc9\x10\xf7\xff\x3f\x09\x61\x77\xc0\xef\xf7\xeb\
\xd3\xa7\x4f\x3f\xf2\x94\x53\x4e\x29\x90\xd5\xcf\x3f\xf1\xc4\x13\
\x4b\xc9\x1d\xc8\x72\x2b\xb9\x9d\xcd\x04\x94\x0b\xa0\x44\xc9\x4e\
\x96\x72\x76\x60\xaf\xbd\xf6\x3a\xae\xba\xba\x3a\xd0\xd4\xd4\x74\
\xe5\x6b\xaf\xbd\xf6\xd6\xd9\x67\x9f\x5d\x32\x49\x4e\x3d\xf5\x54\
\xd5\x4f\x40\xb9\x00\x4a\x46\xba\x70\xb1\xd0\xb8\x71\xe3\x0e\xbd\
\xe1\x86\x1b\xbe\x7b\xf2\xc9\x27\xef\xcd\xee\xc0\xb9\xe7\x9e\x2b\
\xee\x80\x6a\x2f\xa6\x18\x80\x92\x21\xe6\x06\xec\x08\x26\xc0\xc5\
\x42\xb3\x67\xcf\x3e\xe6\x82\x0b\x2e\xb0\x7a\x7a\x7a\xfe\xf3\x9f\
\xff\xfc\xe7\x9b\x67\x9e\x79\x66\x7e\x67\xb9\x03\xaa\x29\xa8\x12\
\x25\x43\xc0\x1d\xd8\x73\xcf\x3d\x8f\xbd\xee\xba\xeb\x7e\x30\x7f\
\xfe\xfc\x59\x4c\x0e\xce\x3a\xeb\x2c\x15\x18\x54\x00\xa0\x64\x57\
\x01\x01\xc7\x1d\x38\xec\xfb\xdf\xff\xfe\xf7\x88\x01\x48\x76\xe0\
\x8c\x33\xce\xe8\x75\x07\x94\x0b\xa0\x44\xc9\x08\x73\x01\xb6\xe6\
\x0e\xec\xb6\xdb\x6e\x0b\xcf\x3e\xfb\x6c\x83\xe4\xfa\x7b\xef\xbd\
\xf7\x55\x02\x81\x2c\x9c\x62\x21\x1e\x49\x37\xdc\xce\x4b\x31\x00\
\x25\x4a\x3e\x04\x08\x70\x53\x91\x59\xb3\x66\x1d\xf5\xb5\xaf\x7d\
\xed\xba\x03\x0f\x3c\x70\xb6\xcb\xe5\xf2\x96\xdd\x01\x9e\xd3\xb7\
\x2b\x06\x06\x15\x00\x28\xd9\xa5\x84\xeb\x04\x1a\x1b\x1b\x0f\xfe\
\xf6\xb7\xbf\x7d\xed\x79\xe7\x9d\x27\x9d\x85\x88\x09\x68\xbb\xaa\
\x3b\xa0\x5c\x00\x25\x23\xde\x05\xd8\x9c\x09\x10\x08\x68\x33\x67\
\xce\x3c\x8a\xa8\xbf\xd9\xda\xda\xfa\xdd\xa7\x9e\x7a\xea\x0d\x02\
\x81\x1c\x67\x07\x78\x29\x71\x22\x91\x50\x2e\x80\x12\x25\x23\xdd\
\x1d\x98\x3b\x77\xee\x31\xc4\x04\xbe\xb7\x60\xc1\x82\x59\xf4\x9c\
\xe7\xcc\x33\xcf\x14\x77\xa0\xa2\xa2\x62\x97\x71\x07\x14\x00\x28\
\xd9\x65\x41\x80\x57\x11\x8e\x1d\x3b\xf6\xd0\xab\xaf\xbe\xfa\xda\
\x73\xce\x39\x47\xdc\x81\xd3\x4f\x3f\x5d\xfa\x09\x70\x4c\x40\xb9\
\x00\x4a\x94\xec\x04\xfa\x3f\x58\x54\xb9\x9c\x1d\x98\x33\x67\xce\
\x31\x04\x00\x56\x73\x73\xf3\x75\xaf\xbf\xfe\xfa\x5b\x04\x02\xec\
\x0e\xc8\x04\x22\x1e\x5f\xae\x5c\x00\x25\x4a\x46\xb8\x3b\xb0\xc7\
\x1e\x7b\x1c\xcd\xab\x08\xf7\xdf\x7f\xff\xd9\xa6\x69\xba\xd8\x1d\
\x60\x26\x10\x8d\x46\x47\xb4\x3b\xa0\x00\x40\xc9\x90\x61\x01\x83\
\xd9\xb1\x87\xb3\x03\xec\x0e\x5c\x71\xc5\x15\xd7\x9c\x75\xd6\x59\
\x0b\xf2\xf9\x3c\xbb\x03\x32\x86\x8c\x63\x02\x1f\xe7\x38\x15\x00\
\x28\x51\x32\x0c\x98\x00\xb9\x03\xfa\x9e\x7b\xee\x79\xdc\x79\xe7\
\x9d\xf7\xff\x0e\x3b\xec\xb0\x39\xc1\x60\xd0\xc7\x31\x01\x06\x81\
\x48\x24\xa2\x18\xc0\xce\xfc\x32\xca\x8f\x6a\x1b\xf9\xdb\x50\x63\
\x23\xb3\x67\xcf\x3e\xf6\x86\x1b\x6e\xf8\x1e\xb9\x05\x33\xb8\x6c\
\x98\x41\xe0\xcd\x37\xdf\x14\x10\x18\x69\xee\x80\x62\x00\x4a\x94\
\x6c\x26\xec\x0e\x4c\x9a\x34\x69\xe1\x75\xd7\x5d\xf7\x9d\x4f\x7f\
\xfa\xd3\xd2\x68\xf4\xca\x2b\xaf\xd4\x96\x2e\x5d\xca\x2c\x61\x44\
\x9d\xab\xca\x02\x28\x19\x12\x56\x77\x08\xba\x03\xda\x82\x05\x0b\
\x4e\xf8\xf2\x97\xbf\x6c\xb5\xb7\xb7\x5f\xfb\xe4\x93\x4f\xae\x58\
\xb4\x68\x51\x9e\x40\xc0\x62\x10\x20\x50\x18\x76\xe7\xa5\x18\x80\
\x12\x25\x1f\x02\x04\x58\x81\xe7\xcd\x9b\x77\xc2\xcf\x7e\xf6\xb3\
\x1f\x1c\x78\xe0\x81\x33\x57\xad\x5a\xe5\xda\x7b\xef\xbd\xf5\xe5\
\xcb\x97\x23\x1c\x0e\x8f\x08\x77\x40\x01\x80\x12\x25\xff\x86\x09\
\x4c\x9e\x3c\xf9\xa8\xab\xae\xba\xea\x9a\x33\xcf\x3c\x73\xc1\xb2\
\x65\xcb\xdc\x5f\xff\xfa\xd7\x35\x8e\x09\x8c\x04\x77\x40\xb9\x00\
\x4a\x06\x9d\xfe\x0f\x65\xaa\x5c\xce\x0e\xec\xb7\xdf\x7e\x27\x7a\
\xbd\x5e\x7d\xfd\xfa\xf5\xec\x0e\x2c\x27\x26\x90\x7f\xf9\xe5\x97\
\xad\xd9\xb3\x67\x23\x9d\x4e\x2b\x17\x40\x89\x92\x91\x2c\x2e\x97\
\x8b\xb3\x03\xc7\xfd\xe4\x27\x3f\xf9\xde\x21\x87\x1c\x32\x93\xcb\
\x86\x2f\xbc\xf0\x42\x9d\x03\x83\xa1\x50\x48\xb9\x00\x4a\x94\x8c\
\x74\x77\x20\x10\x08\xb8\xa6\x4e\x9d\x7a\x0c\xb9\x00\x57\x1f\x7b\
\xec\xb1\xf3\x88\x01\xb8\xbf\xf5\xad\x6f\x69\xab\x57\xaf\x96\xae\
\x43\xca\x05\x50\xa2\xe4\x23\xba\x01\xc3\x05\x04\xc8\x0d\xd0\x3e\
\xf5\xa9\x4f\x9d\x44\x8f\xee\x8d\x1b\x37\x5e\xf3\xcc\x33\xcf\xac\
\xe4\x91\x64\x0f\x3f\xfc\xb0\xc5\x4c\x80\xdd\x81\xe1\x72\x3e\x8a\
\x01\x28\x51\xf2\x11\x01\x6b\xde\xbc\x79\xc7\xdf\x74\xd3\x4d\xd7\
\x93\x5b\x30\xe3\xd9\x67\x9f\x75\x2d\x58\xb0\x40\x5f\xb2\x64\xc9\
\xb0\x73\x07\x14\x00\x28\x51\xf2\x11\x98\x00\x67\x07\x66\xcc\x98\
\x71\xec\x35\xd7\x5c\xf3\xed\x45\x8b\x16\xcd\x7f\xe7\x9d\x77\xdc\
\x5f\xfd\xea\x57\xb5\xb7\xde\x7a\x0b\xc1\x60\x50\xb9\x00\x4a\x94\
\x8c\x64\x31\x4d\x53\x66\x11\x1e\x78\xe0\x81\x27\xfa\xfd\x7e\x57\
\x57\x57\xd7\xb5\xcf\x3f\xff\xfc\xb2\x93\x4f\x3e\x39\x7f\xef\xbd\
\xf7\x5a\xb3\x66\xcd\x52\x0c\x40\x89\x92\x0f\x43\xab\x87\xdb\xc6\
\x52\xce\x0e\xdc\x78\xe3\x8d\xd7\x1f\x7d\xf4\xd1\x73\xb8\x58\x68\
\xfe\xfc\xf9\xfa\x7d\xf7\xdd\xa7\x00\x40\x89\x92\x0f\x42\xa7\xb9\
\xac\xb6\x54\x2a\x0d\xdb\xe3\x27\xca\x2f\x6b\x07\x2e\xbb\xec\xb2\
\x6f\x72\xb1\x10\x9d\x8f\x7b\xf1\xe2\xc5\xda\xc3\x0f\x3f\x3c\xe4\
\x57\x11\x2a\x17\x40\xc9\xa0\x5b\xfd\x6c\x36\x2b\x74\x9a\xcb\x6b\
\x87\xab\x3b\xc0\x55\x81\x07\x1c\x70\xc0\x09\x04\x06\xee\x35\x6b\
\xd6\x7c\x6b\xe9\xd2\xa5\xec\x0e\x14\x02\x81\x80\xa9\x18\x80\x12\
\x25\xdb\x00\x00\xee\xc6\x53\x66\x00\xc3\x29\x7d\xb6\x35\x26\xe0\
\x74\x16\x3a\xe6\xe7\x3f\xff\xf9\x0d\x07\x1d\x74\xd0\x1c\x02\x36\
\xbd\xab\xab\x4b\x57\x00\xa0\x44\xc9\x36\x00\x80\x2d\x3f\x6f\xc5\
\x62\x51\x98\xc0\x70\x77\x67\xb8\xe5\xf8\xb4\x69\xd3\x8e\xf8\xea\
\x57\xbf\x7a\x0d\xb9\x01\xfb\xd0\x39\x32\xcb\x1e\xb2\xc8\xe6\x1e\
\xaa\x17\xb2\xff\xa3\x92\x91\x2b\x6c\x35\x49\x69\x90\x4a\xa5\xd0\
\xdd\xdd\x2d\x03\x3b\xf9\xf7\xe1\x0c\x02\x5c\x15\xb8\xff\xfe\xfb\
\x1f\x4f\xee\x80\x97\x18\xc0\xb7\x5b\x5b\x5b\xdf\xde\xb0\x61\x43\
\x36\x91\x48\x0c\x39\x77\x40\x31\x00\x25\x83\x0e\x00\xac\x30\x9c\
\x3b\x67\x46\xd0\xde\xde\x0e\x52\x18\xa9\xa8\x63\xdf\x7a\xb8\x82\
\x80\x93\x1d\x58\xf8\xd3\x9f\xfe\xf4\xbf\x2e\xbf\xfc\xf2\x23\x08\
\xd8\xc2\x43\x91\x09\xa8\x20\xa0\x92\x41\x17\x56\x96\xf2\xd2\xda\
\x64\x32\x89\x7c\x3e\x2f\x3d\xfb\xf9\x39\x76\x0f\x86\xab\xf0\xf1\
\x8f\x19\x33\x66\xbf\x99\x33\x67\x5e\x1c\x0a\x85\x5a\xe9\xa9\xd7\
\x68\x2b\x32\x46\x28\x00\x18\x06\xfe\x29\x6f\x43\xb1\x6f\xdd\x48\
\x92\x72\xe3\x0d\x4d\x23\x26\x40\x4a\xcf\x69\xb3\x5c\x2e\x27\x40\
\xd0\xd1\xd1\x21\xc1\xc1\xe1\x7a\xfd\x19\xd8\x78\x23\x10\x58\x18\
\x0e\x87\x1f\xa1\xa7\x56\xd3\xc6\x73\xc7\x0a\x43\x05\x04\x14\x00\
\x6c\x83\x96\x66\x73\x59\xc4\xe3\x5d\xa8\xa9\xae\x13\x8a\x3a\x5c\
\xe9\xe8\x50\x55\x7a\xd3\x32\x85\x11\x9b\x0c\x00\xd0\x9c\x8c\x80\
\x0b\x1e\xb2\x9a\xac\x19\xa6\x69\xc1\xa0\x6b\xce\xfb\xf2\x63\xa1\
\x58\x14\xfe\xec\xf5\x78\x69\x3f\xda\x97\x14\x0b\x43\x1c\x18\xf8\
\x3e\xe2\xc5\x43\x95\x95\x95\x6e\x02\x82\xc9\xf4\xd4\x24\xda\xde\
\xa7\xad\x8b\x36\x43\x01\xc0\x50\x55\xfe\x6c\x06\xad\x6d\x9b\xc4\
\x22\xad\x5d\xbf\x1a\x0d\xf5\xa3\x10\x09\x47\xe9\xa6\x34\xd4\x05\
\xfa\x98\x8a\x5f\x32\x0c\xa6\x57\xf0\xb8\x49\x81\xc9\xea\xbb\x49\
\x87\x4b\x06\x59\x79\x52\x72\x83\x40\x81\x15\x5f\x7c\x68\x0f\xb9\
\x05\x08\xc2\x4d\xdf\x81\x2c\xc5\xa5\xf7\xb1\xba\xeb\xf4\x5e\x2f\
\x01\xb2\xcf\xef\x87\x6f\x18\x2c\xc1\x65\x60\x73\xe2\x1b\x8d\xf4\
\xeb\x78\xda\xda\x68\x8b\x2b\x00\x18\xa2\x94\x8d\x2d\x7f\xf3\xa6\
\x8d\x18\x3b\x66\x1c\x2a\x2a\x2a\xd1\xd1\xd9\x86\xb5\x6b\xdf\x47\
\x5d\xdd\x28\xd4\xd6\xd6\xcb\x8d\xaa\x5c\x82\x0f\x2f\x6c\xc5\x99\
\x45\x31\x9b\x62\x90\xe5\xeb\x58\x2a\x96\x60\x90\xf2\x97\x5f\x33\
\xd8\xea\xf3\xef\xa4\xec\x86\xc3\xb8\xf8\x3b\x61\xcb\xaf\xd1\xfb\
\x5c\xcc\x10\xbc\x9c\x36\xf4\xa0\xa5\xb3\x1b\x95\x91\x30\x2a\xa3\
\x43\xbf\x55\x37\xc7\x31\x08\x00\xb8\x24\xb0\x8a\xb6\x00\x86\x50\
\xf0\x5d\x01\x40\x3f\xcb\xcf\x69\xa8\xa6\xe6\xf5\x18\x37\x7e\x3c\
\xdc\x74\xc3\x15\x8a\x05\x71\x01\xfc\xbe\x20\x56\xbc\xfb\x0e\x52\
\xa9\x24\xc6\x8f\x9f\xd8\x1b\x1b\x50\xf2\xc1\x95\x9f\x85\xd3\x7b\
\xcc\xa2\x8a\x85\x22\x59\x7b\x52\xf2\x52\x59\xf1\x0d\x9b\xf2\x93\
\xf2\x0b\x43\x70\x8a\x6a\xca\xdf\x0b\xf1\x67\x04\x03\x41\x7a\xbf\
\x0f\x89\x54\x0a\xab\x37\x6c\x44\x4f\x3a\x23\xaf\x57\x0e\x9f\x81\
\x1d\xac\x6b\x4c\x59\x5c\x43\xea\xbe\x57\xb7\x67\x3f\x00\x20\x9f\
\xff\xe9\xa7\x9e\x96\x14\x54\x8e\x98\x00\x6f\x0c\x02\x5c\xa2\x3a\
\x67\xd6\x3c\x14\xf3\x79\xbc\xfd\xf6\x52\x29\x5a\x61\xcb\xa4\xe4\
\x83\xd1\x7e\xcd\xa1\xed\x25\x52\xf8\x62\xa9\x24\x20\x60\x5b\x7d\
\x43\x14\x9e\x2d\x3e\x07\xfb\x8a\x04\x00\x9a\x28\xbf\x4b\xde\xe3\
\x21\x4b\xcf\xd7\xbe\xb6\xa6\x06\x9a\x4b\xc7\xd2\x15\xef\xe2\x1f\
\x2f\xbd\x8a\xa6\x96\x56\x04\xbc\x3e\x54\x47\x23\xea\x02\x2b\x00\
\xf8\x64\x84\x6f\xc0\x29\x93\xa7\x62\xf7\xdd\x67\xe0\x81\xfb\x1f\
\x20\x25\x2f\x48\x34\x3a\x93\xc9\x08\x08\x30\x75\x9d\x33\x77\x2f\
\x72\x0b\x62\x78\xf5\xf5\x97\x88\x2d\x74\x0d\xeb\x14\xd5\x4e\x74\
\x82\xe5\x3a\x95\xc4\xba\x93\xe5\x37\x08\x04\x18\x00\x8a\x86\xfc\
\x6c\x98\x44\xf9\x4b\xc4\x0a\x08\x04\x24\x18\x48\x40\xcc\x41\xbe\
\x50\x20\x40\x8a\x5f\x8d\x00\xb1\x86\x37\x57\xbe\x8b\x25\x0f\x3f\
\x8e\xd7\xde\x5e\x46\x6c\x40\xc7\xd4\x09\xe3\x31\x73\xca\x24\xc4\
\xa2\x61\x58\x50\x4c\x4c\x01\xc0\x27\x08\x02\x47\x1c\xb1\x50\x82\
\x36\x4f\x3c\xf9\x04\xdd\x8c\x16\x72\xf9\x2c\xb2\x04\x02\x0c\x08\
\x2c\xbb\x4d\x9f\x81\x69\x53\x77\xc3\x1b\x4b\x5f\xc3\xba\x75\x6b\
\xca\xfe\x9d\xba\x78\xdb\x61\x56\xa2\xe0\xb4\x99\x6c\xed\xf9\xb1\
\x64\x08\xed\x2f\x99\xf6\x73\x45\x62\x03\xa4\xf3\x12\xe0\x73\xe9\
\x6e\x54\xc7\x2a\x11\xa3\xed\xbd\xf5\x1b\x70\xcb\x7d\xf7\xe3\xef\
\x4f\xfe\x03\xe9\x6c\x16\xd3\x27\x4d\xc0\xbe\x73\xe7\x60\xf2\xb8\
\xb1\xf0\x79\x3d\xe2\x36\x28\x51\x31\x80\x4f\x94\xae\xf2\x76\xd2\
\x49\xa7\xe0\x77\xbf\xbb\x09\xaf\xbe\xf6\x1a\xe6\xce\x99\x8b\x4c\
\x2e\x03\x5b\xc7\x35\x61\x02\x63\x46\x8f\x45\x24\x1c\xc1\x0b\x2f\
\x3e\x87\xae\x78\x37\x66\xed\x31\x47\xc5\x05\xb6\x61\xfd\xd9\x42\
\xb3\x95\xb7\x7a\x7d\x7d\x93\x14\x9f\x23\xfe\xf4\x0a\x53\x7f\x93\
\x5d\x04\x4b\xea\x00\xd8\x4d\xa8\xae\xaa\x42\x73\x7b\x07\x1e\x7f\
\xee\x5f\x58\xf1\xfe\x6a\xf8\x3c\x6e\xcc\x9c\x3a\x05\x7b\xcf\xda\
\x03\x63\x1a\xea\xa1\xbb\x34\x61\x0e\x4a\x14\x03\xd8\x31\x01\x2b\
\xba\x29\xc3\xa1\x30\x16\x2f\xfe\x2c\xfe\xf5\xc2\x8b\x58\xbb\x6e\
\xad\xe4\xac\x33\x4e\x4c\x80\x5f\x67\x61\x57\xe0\xb0\x43\x8f\x44\
\x9e\xdc\x84\x17\x5e\x78\x4e\x18\x82\x62\x02\x9b\x29\x3f\xe1\x21\
\x5b\x7c\xa1\xfa\xb4\x99\x42\xf9\xed\xc0\x9f\x55\xb2\xa3\xff\xbc\
\x93\x4b\x94\xdf\x0d\xaf\xcf\x87\xbf\x3d\xf5\x0c\x7e\x78\xd3\x1f\
\xf0\xec\xab\xaf\xa3\xbe\xa6\x0a\xc7\x1f\x76\xb0\x6c\xe3\xc7\x8c\
\x92\x42\x5a\xa5\xfc\x0a\x00\x76\xb8\x70\x90\x8f\xd3\x80\xc7\x1c\
\x7d\x0c\x1e\xf9\xfb\x23\x88\xc7\xe3\x44\x61\x8b\xe2\x0e\xe4\xf3\
\xb9\x5e\x4b\xcf\x45\x29\x07\x1f\x74\x28\x1a\x1b\x1a\xd1\x93\xec\
\x51\x00\xd0\xab\xfb\xe5\x0a\x4a\xd3\x49\xe9\x31\x08\x14\x9d\x9f\
\x2d\x3b\xf2\x2f\xc5\x40\xa4\xfc\x9c\x12\xa4\xf7\x04\xc9\xe7\x5f\
\xdb\xd4\x8c\xbb\x1f\x7e\x02\x01\x9f\x17\x27\x1e\x79\x28\xce\x39\
\xf1\xd3\x98\x3f\x6b\xa6\x13\x40\x2c\x29\x86\xa5\x00\x60\xe7\x09\
\xd7\xa3\xef\x35\x6f\x3e\xf6\x9c\x3b\x17\x0f\xff\xfd\xef\x62\xe1\
\x19\x18\x72\x04\x00\x85\x42\x7e\xc0\xbe\x93\x26\x4d\x42\x28\x18\
\x52\x37\x68\x2f\x02\x00\xec\x9e\x8b\xa2\x1b\xe5\x60\x1f\xa7\xf9\
\x2c\x71\x05\x4c\xd3\x2e\xf8\xd1\x9d\x0a\x40\x4d\x40\xb7\x84\xa0\
\x3f\x80\x86\xda\x6a\x9c\x7e\xdc\xd1\xf8\xf4\xc1\x9f\x42\x2c\x1a\
\x95\xe7\x55\x15\xa6\x02\x80\x41\x11\x6e\x54\xb1\x70\xe1\x31\x08\
\x91\x4b\xf0\xd8\x63\x8f\x43\xd3\x35\x61\x02\x0c\x06\xa6\xd1\x57\
\xc8\xe5\x72\xb9\x7b\x63\x08\xca\xfa\xdb\x65\xbc\x96\xe9\x58\x7e\
\xd3\xa6\xfe\x6c\xed\xc9\xe6\x4b\xea\x8f\x5f\xe7\xe8\x80\xcb\xa5\
\xf7\x32\x06\x06\xd7\x48\x28\x88\xc6\xda\x1a\x79\xe4\xfd\x0d\x43\
\x55\x5e\xee\x92\x00\x50\x0e\xc6\x0d\xf6\x26\x96\x87\x74\x7a\xf1\
\xa2\xc5\xe8\xee\xe8\x04\xb7\x7c\x0e\xd1\xcd\x69\x95\xef\x74\x47\
\xbc\x5e\x8f\xfc\x5a\xce\x14\x0c\x95\xe3\x1f\x9c\x0d\x92\xdb\x17\
\xeb\x2f\x91\x7f\xbb\xc4\xd7\x32\xcc\x5e\x40\xe0\x8b\xea\xee\x57\
\x47\xc1\x1c\x80\x9f\x0f\x07\xfc\x72\x2d\x57\xad\xdf\x38\xe2\xae\
\xa3\x02\x80\x61\x2a\x9c\xbf\xe6\x75\x00\x8b\x16\x2f\xc6\xf3\xcf\
\x3d\x87\x0d\xeb\x36\xc0\xe7\xf3\x4b\x8d\x00\xc7\x06\x78\x2b\xd1\
\x8d\x1e\xab\xa8\x14\xea\x5b\x2a\x16\x76\xe9\xeb\x25\x96\xde\xa1\
\xf8\x25\xc3\x49\xf5\x95\x4c\x94\x2c\xdb\x0d\xb0\x1c\xbf\xbf\xbf\
\xf2\xf3\xff\xd2\x52\x4b\xd3\x51\x55\x51\x81\x8e\xee\x6e\x01\x84\
\x8f\x1a\x51\x51\xb1\x98\x0f\x2e\x2a\x0d\xf8\x01\x5d\x81\xf1\xe3\
\x26\xe2\xa8\xa3\x8e\x96\x78\xc0\xb8\xf1\xcb\xc4\xd2\x75\xc7\xbb\
\xc1\x6b\x3a\x8e\x38\xe2\x08\x4c\x18\x3f\x19\x15\xd1\x18\x7a\x92\
\x09\x29\x69\x2d\xbb\x05\xbb\x1c\x00\xb0\xf5\x77\x16\xfd\xf4\xd6\
\xf8\xc3\x74\xd8\x94\x6d\xf9\xcb\x0a\x5a\x56\xfe\xb2\xef\x50\x20\
\x7f\x7f\x5c\x63\x23\x5e\x7e\xeb\x6d\x64\x09\x60\xfd\xce\x42\xa0\
\x0f\x05\xd8\xa5\x12\xf2\x85\xa2\x94\x0d\xf7\x07\x1a\x25\x0a\x00\
\x3e\x76\x50\x70\xee\x9c\x79\xa4\xe8\x13\xe5\x67\x7f\x20\x80\x9e\
\x9e\x1e\xfc\xf9\xb6\x3f\xe3\xa5\x57\x5e\x94\xe2\xa1\xba\x9a\x06\
\x44\x89\x2d\xa4\xd2\x49\xf1\x75\xb9\xa4\x75\x97\x63\x4c\x8e\xf5\
\xb7\xd3\x7f\xf6\x66\x3a\xe5\xc0\xe5\x85\x3d\x5b\x28\xbf\xf3\x8c\
\x69\x19\xa8\xaf\xae\x44\xa2\x27\x89\x54\x26\x83\x00\x29\x31\xf9\
\x0f\x1f\x28\xea\x28\x6b\x0c\xe8\x6f\x32\x33\xeb\x49\xa5\x88\x91\
\x55\x10\x73\x0b\x0d\xf9\x25\xc3\xca\x05\x18\x46\xc2\x37\x33\xe7\
\xff\xeb\xeb\x49\xd1\x23\x51\x4c\x24\x30\x38\xe5\xa4\x45\x78\xe5\
\x95\xa5\x78\xf2\xa9\x27\xd1\xda\xbe\x89\x6d\xa0\x14\x09\x71\x39\
\xeb\xae\x16\xbd\x96\xb8\x09\xf9\xfa\xec\x02\x14\x39\xed\x27\xa9\
\x3b\x88\xd5\x77\xeb\xfa\x76\x95\x9f\x6f\x44\x8e\x11\x48\x1c\xc0\
\xe3\x46\x53\x6b\xbb\xb8\x04\xff\x8e\xea\xdb\x73\x05\xf2\xc8\x66\
\x73\x28\x12\x53\x2b\x4a\x65\xa1\x25\xeb\x0a\x54\xf6\x40\x01\xc0\
\x27\x4f\x71\x9d\xd4\x16\x3f\xe6\xe9\xc6\x9b\xb1\xdb\xee\x38\xfb\
\xcc\x73\xf0\xca\xab\x6f\xe0\x89\xa7\x1e\x17\x10\x90\x80\x56\x28\
\x22\x51\x6e\xcb\xda\x35\x6e\x42\x56\xc6\x32\xe5\x2f\x95\x8a\x12\
\x17\xb1\x78\x1d\x80\x6b\xa0\xe2\x6f\x4d\xf9\x9d\x22\x4b\x49\x17\
\xf2\x22\x9f\xa3\x0f\x3a\x10\x95\xb1\x8a\x0f\xa0\xf8\x05\xe9\x24\
\xcc\x8f\xd2\x44\x84\xfe\xe5\xc5\x46\xd2\x67\xc0\xed\xb6\x1b\x8a\
\xa8\xb5\x02\x0a\x00\x76\xb4\x6b\xb0\xfb\x6e\xbb\xe1\x73\xe7\x7e\
\x0e\xaf\xbd\xfa\x16\x1e\x7d\xec\x51\xb4\xb5\x37\x8b\xf5\x0b\x06\
\x43\x12\x0b\xd8\x15\xd2\x83\xac\x94\x12\xfd\xb7\x9c\xee\x3d\xa4\
\xd0\x6e\x6d\xcb\x60\xdf\xb6\x94\xbf\x0c\x0e\xac\xcc\x53\xc7\x8c\
\x42\x7d\x65\x0c\x19\xa2\xf3\xe5\xd9\x01\xe5\xb8\x41\x7f\xc5\xe7\
\x6b\x2f\xeb\x01\x9c\xd7\xb8\x66\x80\x19\x80\xdb\xa5\x09\x8b\x30\
\x9c\x2c\x8e\x12\x05\x00\x3b\x1c\x04\xa6\x4f\x9f\x8e\xf3\xcf\x3b\
\x1f\x6f\x2c\x7d\x07\x8f\x3c\xfe\x28\x5a\xca\x20\x10\x08\xc2\xe5\
\x76\x8d\x78\x10\x90\xd6\x5d\x6c\xf5\x2d\x3b\xe7\x2f\xf4\xbd\xac\
\xec\x16\xb6\xd2\x0f\x77\xa0\xf2\xf7\x43\x12\x64\xf3\x05\xa4\x33\
\x59\x59\x89\xd9\x93\x4c\x4a\x93\x16\xd3\x61\x17\xac\xf8\x39\x51\
\x7c\xb3\xfc\x66\x79\x64\xd0\xe1\x20\x62\x89\x58\x04\x57\x68\xf6\
\xae\xcd\x50\x19\x01\x05\x00\x3b\x05\x04\x72\x79\x4c\x9b\x36\x0d\
\x17\x9e\x7f\x21\xde\x5c\xba\x0c\x8f\x0a\x08\x6c\x94\xda\x80\x80\
\x3f\x20\x94\x74\xa4\x82\x00\x2b\x1b\x5b\x62\x56\xc2\x62\xd1\x10\
\xe5\xef\xd3\x3b\xad\xb7\x77\x42\xf9\xfc\xed\x1e\x80\x5b\x2a\x3f\
\x3f\x57\x6e\xc6\xca\x31\x14\x51\x62\xfa\xdc\x7c\xae\x80\x54\x3a\
\x8d\x0c\x29\xbf\x9d\x1e\xec\x73\x25\x98\x00\xc8\xdf\x25\xb0\x2d\
\x39\x8b\x8d\x82\x7e\x1f\x4a\x45\x43\x90\x47\xa9\xbf\x02\x80\x9d\
\xca\x04\xa6\x4e\x99\x4a\x20\x70\x11\xde\x7a\x6b\x39\x1e\xfa\xfb\
\xc3\x04\x02\x4d\xb2\x0e\x9e\xd7\xb5\x7b\x3c\xee\x11\x0b\x00\x85\
\x52\xc1\x29\x84\xb2\x06\x18\x5d\x17\x47\xff\x89\x01\xb9\xe9\xdc\
\x03\x92\x9a\x73\x6d\xce\x01\x7a\x95\xbf\x4c\x13\x34\x6d\xe0\x67\
\x73\x05\xa6\x66\x23\x48\xef\x7b\x4c\x27\x66\x20\x81\x3f\x2e\x17\
\x36\x2c\xb1\xfe\xbc\x4c\xd8\xe5\xd6\x05\x0c\xf8\x6f\x29\x00\x50\
\x00\x30\x08\x20\x30\x05\x9f\xbf\xf0\x62\xac\x5c\xf1\x1e\xee\x7f\
\xe0\x01\x6c\x6a\x6d\x92\x12\x62\xbf\x6f\x84\x82\x00\x69\x59\x8e\
\xac\xb4\xbe\xb9\xcf\xcf\x15\x7e\x96\x6d\xb1\x3d\x2e\x0f\x51\xf7\
\xa2\xa4\xe8\x6c\x85\xde\xbe\xf2\xf7\xb7\xf2\xfd\x83\x88\xcc\x21\
\xf8\x33\xd9\xe2\x73\xf9\xb0\xd4\x1b\x58\xf4\xb3\x65\x08\x00\x70\
\x23\x11\x0e\xd2\x5a\xfd\x16\x1a\x29\x51\x00\xb0\xd3\x41\x60\xd2\
\xa4\xc9\xb8\xe4\xf3\x97\xe2\xfd\xf7\xd7\xe2\xbe\x25\x4b\xb0\xa9\
\x65\x83\x80\x80\xcf\xeb\x95\x9e\x02\x23\xc9\xfa\x17\x0b\xb6\x32\
\xb2\x62\xf7\xc6\x04\x34\xbb\xf6\x3f\x14\x0a\x21\x12\x0e\x4b\xc6\
\xa4\xb9\xb5\x45\x4a\xa9\x3d\xd2\x49\xc9\xda\xae\xe5\x07\xfa\x5c\
\x7c\xcd\x21\xf3\x5c\x63\x20\xd5\x85\xe5\xa6\x22\x96\x5d\x66\xcc\
\x15\x86\x5c\x03\xc0\xbd\x03\x78\xe5\x60\x81\x8e\x87\xd3\x8e\xaa\
\x10\x48\x01\xc0\xa0\x82\xc0\xf8\x71\x13\x70\xd9\x25\x97\x61\xfd\
\x86\x66\xdc\x75\xcf\x3d\x68\x12\x10\x28\xd9\x20\xe0\x1d\x19\x20\
\xc0\x2d\xbc\x32\x32\xd4\xb3\xbf\x7f\x6f\x07\xe0\x22\xa1\x30\x42\
\xc1\x00\xda\x3a\xda\xb1\x76\x43\x13\xc6\x8f\x1d\x2b\x1d\x7d\xb9\
\xa1\xa7\xee\x72\x8b\x9f\xbf\x55\xda\xdf\xdf\xec\xf3\xda\x02\xd3\
\x4e\xef\xf1\xc6\x81\x55\xae\x35\x28\x95\xab\x0c\x65\x6e\x00\xe4\
\x39\xfe\x5b\xec\x8a\xb0\xab\xc0\xd7\x58\x95\x04\x2b\x00\x18\x54\
\xe1\x02\x95\xb1\x63\xc6\xe2\x8b\x97\x7d\x11\x2d\xad\x1d\xb8\xf3\
\xce\xbb\xb0\xb1\x79\x1d\x3d\x9f\x23\x6b\xe5\x95\xf1\x57\xc3\xfa\
\xe6\x21\xe5\x2f\x4a\xf4\xbd\xdc\x0c\xa5\x4f\x71\xd9\x1d\xc8\x93\
\x6f\xbe\x7e\x63\x33\xd6\x35\x35\x63\xd2\xf8\xf1\xe2\x26\xbc\xb5\
\x6c\x85\xd4\x09\xb0\x75\xe6\x36\x5f\x76\xe0\x6f\x4b\xe5\x17\xaa\
\xcf\x81\xc5\x92\xdd\x30\xb4\x5c\x51\xc8\x0a\x5f\x5e\x57\x50\x32\
\xec\x25\xc6\xcc\x0a\x82\x01\x3f\x5c\x2e\x8d\x80\xb7\x28\x1d\x9d\
\x3d\x6e\xb7\x5a\x9d\xa9\x00\x60\x28\x80\x40\x41\x1a\x86\x7c\x89\
\x40\xa0\xb3\x33\x8e\xdb\xef\xbc\x93\x40\x60\xbd\xf4\x15\x60\xba\
\xca\x29\xab\xe1\x2c\xdc\x41\xb9\xbc\x90\x87\x8b\x7e\xf4\x7e\xb4\
\xdb\x20\x70\xc8\xe7\x0b\x98\x4c\xca\xcf\xb1\x8f\xd5\xeb\xd7\x63\
\xca\x84\x71\xb4\x8d\x17\xd6\xc0\xa9\xbe\xfe\xeb\x02\xfa\x16\x06\
\x41\xfc\x79\xc3\xa9\x2b\x30\xca\x0d\x44\x7a\x7b\x09\x38\xe5\xc6\
\xce\x92\x61\x06\x93\x50\xd0\x2f\xeb\x07\x64\x10\x87\xdf\xa7\xac\
\xff\x70\x07\x80\x91\xb4\x14\x94\x41\xa0\xb6\xb6\x8e\x98\xc0\x65\
\x48\xc4\x93\xb8\xe3\x6e\x9b\x09\x64\xf3\x59\x59\xfe\xca\x31\x81\
\xe1\x76\x4e\x9c\xda\x4b\x67\x32\xe4\xdb\x17\x6c\x6b\x4b\xff\xa5\
\xb3\x39\x02\xb6\x82\x53\xb8\x63\xdf\x5a\x95\xb1\xa8\x44\xff\x79\
\xbf\xe9\x13\x27\x60\xdc\xa8\x51\x88\x27\x7a\xb0\xb1\xa5\x45\x62\
\x03\x76\x43\x90\x3e\x67\x9f\x95\xbb\x4c\xf5\x0d\x67\x5a\x50\x7f\
\xe5\x37\x9c\x91\x61\x76\x97\x21\x3b\xd8\x17\x8b\x46\x48\xf9\xf3\
\x28\x30\x13\xf0\xf9\xe0\xa5\xe3\x31\x9d\x01\x2e\x6a\x39\xb0\x62\
\x00\x43\x42\x98\x2a\xd7\xd6\x10\x08\x5c\xfa\x05\xf4\xf4\xa4\x71\
\xdb\xed\x77\x60\x43\xd3\x5a\x69\x33\xc6\x53\x64\x87\x93\x3b\xe0\
\x76\xbb\x08\xbc\x72\x02\x00\x7c\xdc\xf1\x64\x0a\xef\xae\x5d\x8f\
\x35\x4d\x9b\xb0\x81\x14\xbb\xad\x2b\x6e\xa7\xec\x9c\x68\x7f\x81\
\x68\x79\xa1\x50\x94\x02\x9e\xf7\xd7\xaf\xc3\xb2\xf7\x56\xa1\xa6\
\xaa\x52\xea\xfe\x2d\xa9\xe4\x73\x18\x83\x94\x11\x9b\xce\x8a\x42\
\xfb\x77\xa6\xf8\xa6\x69\x39\xb3\x02\x1d\xe5\xb7\xd0\x1b\x03\xe0\
\xe5\xc3\x05\x72\x29\xb2\xf4\xd9\x3e\xb7\x17\xe1\x60\x40\x51\x7f\
\x05\x00\x43\x17\x04\x6a\x6a\x6a\x71\x39\x81\x40\xbe\x50\xc2\x9f\
\xff\x7c\x1b\xd6\x6d\x78\x9f\x7c\xe3\x8c\x80\x80\x6f\x18\x80\x00\
\x5b\x7e\xb6\xf2\xc9\x64\x9a\x2c\xad\x07\x9d\xf1\x04\xd6\x35\x6f\
\x12\x1a\x5e\x11\x0a\x4a\x1a\x8e\xb3\x1d\x09\xc7\x35\x60\xdd\x66\
\x1a\xef\x71\xeb\x52\xb0\x93\x22\xda\x3f\xa6\xa1\x81\x14\x37\xea\
\x94\xf1\xc2\xd9\xc7\x92\xe8\xbe\x58\x76\xfa\x9d\xfd\x7c\x06\x87\
\x5e\x17\xa0\xbc\xb1\xf2\x17\x4b\x72\x2c\xdc\x3e\x8c\xf7\x4f\xa6\
\xd2\xb2\xe0\x28\x16\x09\x0f\x70\x41\x94\x28\x00\x18\x92\x20\x50\
\x55\x55\x83\x2f\x5c\x72\x99\xd0\xdf\x9b\x6f\xf9\x0b\x56\xaf\x7b\
\x8f\x40\x80\x14\xca\xe7\x1d\xd2\x20\xc0\xca\x25\xca\xdf\x93\x14\
\x16\xd0\x1e\x8f\xa3\xa9\xb5\x15\xb5\x95\x95\xa4\x8c\x35\xb2\x80\
\x27\x1a\x0a\x91\x65\x0f\xd8\xc5\x41\xa4\xa8\x52\x05\x4c\x1a\xce\
\x00\x51\x15\x8b\x61\x6c\x63\x83\x44\xeb\xb9\x70\xc7\xbe\xf9\xec\
\x02\x1e\x1e\x17\x66\xf7\x0e\x70\x56\x14\x3a\x9d\x84\x0c\xa3\x2f\
\x06\xc0\xfb\x71\x00\xd1\xef\xf7\x62\x14\x29\x3f\xbb\x1c\xdd\x74\
\x2c\x9c\x4d\xa8\x22\x37\xe0\xa3\xf4\x0f\x50\x00\xa0\x64\x50\x40\
\xa0\x32\x56\x29\x29\x42\x9f\x2f\x80\x3f\xfd\xe9\xcf\x58\xb5\xfa\
\x5d\x64\xb2\x69\x69\x8d\xed\xf3\x79\x81\x21\x56\xc3\xc6\x2b\x1b\
\xf3\x74\xdc\x3d\x69\x52\x7e\x8f\x0b\x1d\x9d\xdd\xa4\xfc\x6d\x68\
\xa8\xa9\x46\x4d\x65\x0c\x01\x3e\x6e\x9e\xda\xeb\xf5\xc8\xf1\xfb\
\x69\x73\xf1\xd0\x14\xe9\xfb\x67\xb7\x08\x37\x1d\xbf\x5d\x14\x9c\
\x9e\xe0\x81\x20\x9c\x29\xc8\x16\x0a\x02\x16\xec\xc3\x97\x0a\x86\
\x3c\x72\x1c\x80\x33\x00\x85\x72\xfa\x8f\x6b\xfc\xbd\x6e\x34\x54\
\x57\xc9\x50\xd0\x76\x62\x1e\xcc\x3e\xb8\xd2\xb0\x86\xae\x65\x38\
\x18\x54\xca\xaf\x00\x60\x78\x81\x40\x45\x24\x86\x4b\x3f\x7f\x09\
\xa2\xd1\x0a\xfc\xf1\xe6\x5b\xf0\xee\xaa\x15\xe4\x57\x27\xc5\xaf\
\xf6\x49\x9d\xc0\xd0\x00\x01\xb6\xde\x39\x52\x52\x6e\x7d\xee\xd1\
\xc9\xf2\x93\x8f\xdf\xd4\xd1\x81\xc6\x3a\xb2\xfa\x15\x31\xbb\x42\
\xaf\x37\xd8\xa5\x49\x9f\x7f\x2e\xc4\xf1\x90\xf2\x33\x10\x30\x5b\
\xe8\xbf\x2c\x8f\xfd\xf7\x24\x59\xef\x78\x3a\x43\x2e\x41\x8e\x3e\
\xbb\x88\xbc\xe1\x4c\x0f\x92\xfd\x2c\xc9\x1a\x70\x40\x2f\x16\x89\
\xa0\x8e\x00\xa6\xb1\xa6\x0a\x15\xe1\x10\x3a\xba\xba\xb0\x62\xf5\
\x1a\x7a\xec\x96\x7d\x6a\x09\x10\xa2\x21\xa5\xfc\x1f\x39\x9e\xa3\
\x2e\xc1\x20\x82\x00\xd1\x59\xee\x1b\x70\xc9\x45\x9f\xc7\x6f\xff\
\xef\xf7\xb8\xf9\xe6\x5b\x71\xe6\x99\xa7\x61\xda\x94\xe9\x88\x84\
\xa2\xc2\x9d\x39\x8d\x36\x98\x6b\x5a\x7b\x95\x3f\x95\x22\xe5\x77\
\xa3\xa3\x3b\x61\x2b\x3f\x59\xfe\x4a\x02\x2e\x5b\xf1\xb6\x3c\x3e\
\xcb\x71\x19\x3c\x6e\xaf\xf8\xf2\x9c\xcb\x07\xec\x74\x1f\x7f\x26\
\x2b\x37\xbb\xeb\xb6\xde\xd2\xb3\x2e\x9b\x25\x70\x47\x1f\x66\x1b\
\xc2\x08\x8a\x05\xa4\xd3\x29\x49\x17\x76\xf5\xf4\x88\xaf\xcf\x90\
\x18\xab\x88\x12\xf8\xd4\x62\x54\x5d\x9d\xe4\xff\x2d\xd5\xf8\x43\
\x01\xc0\x70\x15\x56\x8c\x40\x30\x8c\x8b\x2e\xb8\x10\xbf\xff\xc3\
\xef\xf1\xe7\x5b\xff\x82\x33\x4e\x3b\x15\xd3\xa7\xed\x8e\x68\xd8\
\x6e\x8a\x31\x58\x20\x50\x56\xfe\x24\x2b\xbf\x8b\x68\x3f\x51\xee\
\xe6\xf6\x76\xa1\xfd\x55\xd1\xe8\x76\x15\x8f\x15\xdd\xed\x72\x8b\
\x95\xe6\x61\x2a\xe5\xe7\xec\x71\xdf\xa4\xe0\x74\x4e\x5d\xf1\x38\
\xda\xbb\xe3\xe8\xa4\x8d\x15\x9c\x0b\x85\xb8\x38\x48\xe6\x2f\xd0\
\x75\xe1\xa5\x3c\x6e\xb7\x2e\xc1\xc6\x68\x38\x8c\x7a\xf2\xfb\x59\
\xe9\x79\x44\x58\x55\xac\x42\x66\x09\xaa\xae\x3f\x0a\x00\x86\xbd\
\x70\xce\x3b\xe0\x0f\xe1\x82\xf3\x2e\xc0\x1f\x6f\xf9\x23\x6e\xb9\
\xf5\x36\x9c\x7e\xea\x62\xcc\xd8\x7d\x96\xb8\x09\x36\x08\xe4\x77\
\xb2\xcf\xef\x92\xdc\x7d\x4f\x92\x94\xdf\xcd\xca\x4f\xb4\xbf\xad\
\xa3\x4f\xf9\xad\xed\xf7\xda\x61\xda\x1f\x20\xeb\x5c\x94\x25\xc2\
\x45\xbb\x50\x88\x9e\x63\x9a\xbf\x7e\x53\x8b\x04\x0f\xbb\x08\x50\
\xf2\x64\xe5\x79\xd5\x5e\xd0\xe7\x47\x45\x28\x6c\x67\x05\x68\x5f\
\x8b\x1e\x3d\x04\x20\x95\xd1\x08\x5d\x83\x08\xb9\x1a\x11\x62\x45\
\x21\x04\xfd\x7e\x61\x46\x52\x17\xa0\x68\xbf\x02\x80\x11\x03\x02\
\x06\x81\x40\x20\x88\xcf\x9d\x73\x1e\x6e\xfe\xcb\x9f\x71\xeb\x5f\
\xee\xc0\xa9\xa7\x1a\x98\x3d\x73\x8e\x80\x00\xaf\x83\xe3\xd5\x74\
\x3b\x83\x09\x94\x95\x3f\x41\x3e\x3f\x5b\x6b\xb6\xd2\x2d\x1d\x65\
\xe5\x8f\x08\x6f\xdf\xe6\x51\xd0\x0b\xbc\xfc\x97\x2d\x36\x2b\x69\
\x92\x00\x84\xb3\x00\xcc\x04\x92\x44\xe5\x37\x34\xb7\xa0\x2b\x11\
\x97\xc6\x21\x13\xc6\x8e\x46\x6d\x55\x25\x7d\x66\x85\x2c\x97\xe6\
\xa2\x28\xbd\xdc\x3b\x50\x1b\x78\xaa\xe2\x68\x94\x95\x5e\x29\xbe\
\x02\x80\x91\x09\x02\x06\xfc\xfe\x20\xce\x3d\xf3\x1c\xdc\x7e\xe7\
\x6d\x04\x02\xb7\xa3\xb4\xa8\x80\x3d\xe7\xce\x97\x66\xa4\x7e\xd2\
\x8a\xdc\x0e\x76\x07\xf4\x5e\xcb\x9f\x84\x5b\x7c\xfe\x38\x36\x75\
\x76\xd8\x69\xbe\x70\x44\xfe\xf4\xb6\xd4\x9f\x59\x01\x57\x35\x72\
\x47\x5e\x56\x70\xee\x9a\xcc\x2d\xd1\xb8\x45\x77\x82\xdc\x88\x96\
\x8e\x4e\xa9\xdb\xaf\x23\x20\x19\x55\x5b\x8b\xea\xca\x98\xdd\x2c\
\xc4\x99\x13\x58\xbe\x06\x4a\x14\x00\xec\xd2\x20\xc0\x83\x47\xce\
\x38\xed\x0c\x49\xa3\xdd\x76\xc7\xdd\xa2\x34\x7b\xcd\xdb\x9b\x68\
\x70\x15\xfc\x9a\x8f\x7c\xe5\xfc\x0e\x01\x01\x56\xfe\x82\x43\xfb\
\xd9\xff\x6f\xef\xee\x46\x4b\x67\x27\x1a\x49\x59\x63\x64\xd1\xb7\
\x67\xf9\x59\x7f\x45\xf9\x63\x51\x69\xd3\x93\x24\x00\xe1\xb5\x0e\
\x3e\x7f\x00\xdd\x3d\x09\x74\x27\x7a\xc4\xc2\x57\xd1\xeb\x75\x95\
\x95\x52\xef\xa0\xc6\x7f\x29\x00\x50\xb2\x0d\x10\xf0\xb8\x7d\x38\
\x6d\xf1\xa9\xb2\x6c\xf8\x8e\xbb\xee\x95\x8c\xc1\x3e\xf3\x17\x90\
\xd5\xac\x15\x8b\xca\xd1\xf2\x4f\x96\xf6\xeb\xbd\x96\x9f\x7d\x72\
\x2e\xe7\x6d\x25\xe5\x1f\x55\x67\x2b\xff\xf6\x7d\x7e\x4b\x94\x9b\
\xa3\xf3\x9c\xe3\x4f\xa6\x53\x52\xd9\xc8\x0d\x50\xda\x89\xee\xf7\
\x70\xa5\x9e\x9b\xfd\xf9\x28\x62\x91\x90\xf0\x7b\x43\x05\xef\x14\
\x00\x6c\xf3\x76\x1a\x06\x8b\x28\x76\xb4\x94\x64\xba\x90\x07\xa7\
\x7c\xe6\x64\x89\xa6\xdf\xbb\xe4\x7e\xc9\x18\x2c\xd8\x7b\x5f\xd4\
\x54\xd5\x13\x08\xd8\xe3\xc9\x3e\x89\x6b\xc4\x3e\x7b\x39\xe0\xc7\
\x91\x75\xb6\xfc\x6d\x5d\xdd\x42\xd3\xff\x9d\xf2\xf3\xf3\xbc\xa2\
\xd1\x56\x7e\xbb\x2c\x97\x47\x7d\xfb\xe8\xf8\x38\x65\x98\xcd\xe4\
\x84\x19\x54\xd2\xe7\xd8\x75\xfa\xd8\x65\x5a\xa5\x6f\x7e\x3f\x2b\
\x00\x50\xf2\xa1\x99\x80\x4e\x7e\xf8\x09\xc7\x9f\x20\xe5\xae\x7f\
\xbb\xff\x21\x01\x81\xfd\x16\xec\x8f\xfa\x9a\xc6\x4f\x04\x04\xec\
\x80\x5f\x51\x82\x75\x1c\x80\xeb\x8c\xdb\x96\xbf\x4c\xfb\xb7\x17\
\x69\xe7\xbf\xcb\x96\xbf\x92\x94\x9f\x6b\xf2\x53\xac\xfc\x74\x4c\
\x7e\xa2\xfd\x9c\xd6\xe3\x05\x43\x1c\xfc\xe3\x69\xbf\x21\x7a\x5e\
\x15\xeb\x28\x00\x50\xf2\x21\x85\x23\xe9\x2e\x02\x81\xe3\x8e\x39\
\x5e\x2c\xf5\x43\x7f\x7f\x54\xca\x62\x0f\xd8\xef\x00\x34\xd4\x35\
\x4a\xf4\x3c\xfb\x11\x41\x80\x3f\x8f\x1b\x6a\xb2\xbf\xce\xd5\x7b\
\x9d\xf1\x1e\xb4\x74\x74\xa3\xa1\xba\x06\x15\x8e\xe5\xc7\xf6\x2c\
\x3f\xf9\xf1\xbc\x14\x97\x2d\x7f\x2a\x95\x12\xc5\x0f\xf0\xc8\x34\
\x02\x02\x0e\x56\xb2\xe5\x0f\x93\xbb\xc2\x65\xc2\x4a\xf9\x15\x00\
\x28\xf9\x18\x20\xe0\x26\x77\xe0\xe8\x23\x8f\x11\xff\xfc\x91\x47\
\x1e\x95\x95\x75\x87\x1c\x74\x30\x1a\xeb\x46\x4b\xbe\x9d\xfb\xe5\
\x7f\x18\x1d\x63\xcb\xcf\xab\xef\x12\x64\xa9\x99\xf6\x77\x26\x12\
\xd8\xd4\xd1\x85\xfa\xea\x2a\x54\x90\x52\x5b\xff\xc6\xf2\x7b\xca\
\x3e\x3f\x59\x7e\xae\x12\xe4\x3c\xbe\x28\x3f\xf7\x04\x20\x96\xc2\
\x01\xc0\x80\xcf\x03\x9f\xea\xcc\xa3\x00\x40\xc9\x27\x07\x02\x47\
\x1e\xbe\x50\x94\xeb\x6f\xf7\x3f\x28\x2b\xe8\x8e\x38\xfc\x70\x02\
\x81\x51\x0e\x13\xc8\x6f\x55\xd9\x98\xda\xf3\x56\x6e\xa0\xa1\xbb\
\x02\xb2\x08\xa7\x27\xd9\x05\xb7\x28\x7f\x0f\x36\xb5\x77\xc8\xf2\
\x5a\xae\xbd\xdf\x6e\xb4\x9f\xeb\xf4\xc9\xf2\xf3\x72\x5e\xfe\x3c\
\x51\x7e\xb1\xfc\x7e\xf4\x48\x5d\x7f\x5e\x32\x08\x01\x02\x08\xaf\
\x4b\x75\xe5\x55\x00\xa0\xe4\x13\x07\x81\x43\x0e\x3e\x4c\xfa\xec\
\xdf\x7b\xef\x5f\xc5\x8a\x2f\x5c\x78\x24\x46\x11\x08\x70\xf0\x8d\
\xc7\x69\xf5\x2f\xd1\x95\xf5\xfb\xf4\x5c\x47\x7b\x3b\x6a\xeb\x1b\
\xe0\xf3\x85\x01\x63\x25\xb2\x69\x1e\xdf\x35\x1a\x1d\x89\x36\xb4\
\x76\x74\xa2\xa1\xa6\x86\xe8\x3c\xa7\xf0\xcc\xed\xa6\xfa\x78\xc9\
\x72\x2c\x5a\x21\x41\xca\x54\x32\x25\xeb\xff\xfd\xc1\x00\x92\x99\
\x0c\x29\x7f\x49\x29\xbf\x02\x00\x25\x3b\x23\x26\x70\xe0\xfe\x07\
\x49\x9d\xc0\xdd\x77\xdf\x23\x6b\xe4\x8f\x3a\xea\x28\x8c\x69\x1c\
\x6b\x33\x81\x6c\x4e\x22\xed\xec\x83\xf3\xda\xfd\x3f\xdc\xf2\x27\
\xbc\xfa\xc6\x9b\xd8\x7b\xcf\xbd\x71\xe9\x67\x4b\x08\xe5\x7f\x01\
\x7f\x60\x22\x56\xe5\xbe\x8d\xe6\xf6\x20\x46\xd7\xb1\xcf\x1f\xd9\
\x6e\x6d\xbf\xad\xfc\x76\x2a\x4f\x94\x9f\x2d\x7f\x28\x28\xa9\xbe\
\x64\x3a\x2b\x2b\xfa\x94\xf2\x2b\x00\x50\xb2\x13\x41\x60\xbf\xbd\
\xf7\x93\x01\x9c\x5c\x27\xc0\x9d\x73\x8e\x3e\xea\x68\x8c\x69\x18\
\x8b\x60\xd0\xdf\x1b\xdc\xfb\xe5\x6f\x7e\x85\x17\x49\xf9\x03\xc1\
\x08\x1a\x83\x77\xc0\x6b\xa4\x01\xcd\x07\x57\x6a\x29\xea\xbd\x3f\
\x47\xa1\xe1\x3b\x64\xc5\xab\xe8\x53\x0b\xdb\x55\x7e\x8f\xd7\x2d\
\xab\xff\x98\xf6\xb3\xe5\x0f\x06\x6d\xe5\x4f\x64\xec\xe9\xbc\xba\
\x52\x7e\x05\x00\x4a\x76\x36\x08\x78\x30\x7f\xfe\x02\x59\x1c\xc3\
\x73\x07\x78\x38\xe7\xd1\x47\x2d\xc4\x94\x49\xd3\x45\x6b\x59\xf9\
\x1f\xff\xe7\x73\x88\x56\xd4\xe3\xcc\x23\xd7\xe1\x94\x63\x8b\x30\
\xbc\x7b\xc2\xcc\xb4\x03\x49\x03\xb1\xe2\x73\x70\x55\x3e\x84\xb6\
\xfc\x05\xb4\xfb\x36\xd6\x19\x38\x01\xbf\x01\xa9\x3e\xa2\xfc\x9c\
\x82\xec\x21\xe5\xe7\xfa\x01\x65\xf9\x15\x00\x28\x19\x0c\x10\x20\
\xab\xcf\xc5\x42\xf3\xf6\x9c\x4f\x20\x60\x11\x08\xdc\x2b\xad\xb8\
\xdc\x47\xbb\x71\xcb\xad\x77\xe0\xaf\x7f\x7f\x04\xbe\x60\x0d\x4e\
\x5d\xd8\x84\x53\x16\x76\xc1\x4a\x73\xcd\x7d\x0f\x11\x80\x4a\x68\
\xa5\x06\x18\xa4\xcc\xa1\xcc\x6d\x08\xf9\xe7\x21\x9d\xdf\x13\xba\
\x96\x42\xff\x26\x24\x76\x9e\xbf\x7f\x91\x4f\x4a\x06\x9d\x72\xba\
\xcf\x0e\xf8\x29\xe5\x57\x00\xa0\x64\x50\x85\xfd\x76\x8f\xc7\x87\
\x3d\x67\xef\x25\xfe\xff\x43\xa4\xf4\x57\x5d\xfd\x6d\xbc\xb9\x72\
\x15\x2c\xbd\x02\x17\x2f\xee\xc2\x39\x9f\xe9\x81\x55\xd0\xa5\xa8\
\x47\xcb\x6e\x80\x15\xdd\x0d\xf0\xd7\x13\x08\x24\x01\xfa\x3d\xe6\
\xbd\x19\x39\xd7\x74\x52\x72\x37\x01\x88\xd1\xe7\xf3\x7b\x9d\x85\
\x3d\xac\xfc\x44\xfb\x39\xcd\xc7\xee\x05\xd3\x7e\xa5\xfc\x23\x43\
\x54\x4b\xb0\x11\x02\x02\xa1\x50\x54\xa8\x7f\x57\x57\x1c\xcf\xbe\
\xf4\x3a\x7a\xd2\x6e\x7c\x7e\x51\x06\x9f\x3f\x2d\x49\x96\x1f\x28\
\xf5\x14\x61\x66\x8b\xd0\x8a\x69\x1b\x04\x3c\x11\x58\x81\x46\x98\
\xee\x0a\xf8\xd2\x4f\xa1\xc2\xfd\x20\x4c\x2d\x28\x6e\x80\x58\x7e\
\x0f\xf9\xfc\xa4\xfc\x9c\xe7\x4f\xa4\x92\x42\xfb\x79\xeb\x49\xe7\
\x24\xdd\xa8\x94\x5f\x31\x00\x25\x43\x44\x38\xda\x9f\xcb\x66\xf0\
\x3f\xff\xfb\x0b\x2c\x79\xf0\x51\x64\x4b\x7e\x7c\xf3\xec\x3c\xae\
\x38\x8f\xdc\x84\xa4\x07\x85\x44\x09\x16\xbd\x6e\x15\x73\xd0\xe8\
\x1b\x77\x57\x11\x10\xb8\x43\xb0\x7c\xc4\x02\x02\x04\x10\xc9\x95\
\x88\x14\x6e\x45\xca\xbd\x1f\x72\xc5\x06\x52\x6c\x43\x2c\x3f\x57\
\x1c\x72\x1f\x40\xee\xe2\x1b\x08\x06\xd1\x93\xca\x22\xcb\x15\x7e\
\xdc\xec\x83\x94\xdf\xad\xa6\xef\x2a\x00\xd8\x21\x16\x4d\x2d\x06\
\xfa\xc0\xc2\x79\x7e\x4e\xc9\xfd\xf8\x27\x37\xe2\x57\xbf\xff\x13\
\x32\x45\x2f\xae\xbb\x3c\x80\xff\x77\x29\x5d\xbf\x6c\x10\xc5\xbc\
\x9f\x76\xca\x12\x4a\x98\x76\xff\xfd\x5c\x06\xc5\xf6\x14\xbc\xee\
\x35\xd0\x6a\x08\x04\x42\x63\x09\x18\x7a\xe0\xca\x2c\x47\x2c\x7a\
\x07\xba\xfd\x57\x21\x16\x71\x89\xe5\x4f\x92\xe5\x0f\x05\x82\x92\
\xe7\x4f\x48\xaa\x2f\x2f\x2d\xba\x02\x1e\x47\xf9\xd5\xf7\xf3\x81\
\xef\x67\xe5\x02\x28\xd9\x61\xd6\x7f\xc9\x92\x25\xf8\x9f\x9f\xff\
\x0a\xa9\x8e\x1c\xbe\x75\x89\x1f\x57\x5f\xee\x81\x95\xd7\x50\x34\
\xa2\xd0\x7c\x21\x68\xde\x00\x3d\x12\xbd\xf7\x06\xa1\xf9\x83\xe4\
\x32\xe8\x30\xba\x53\xd0\x12\xef\x02\x9a\x8b\x40\x60\x02\xd1\xff\
\x08\x02\x99\x7b\x50\x13\x5a\x06\xc3\x0c\x90\xcf\xdf\x23\x3e\x7f\
\x80\x69\x7f\x2a\x23\x53\x7d\xb8\x3b\x10\x2b\xbf\x4b\xd7\x94\xf2\
\xab\x18\x80\x92\xa1\x20\x6c\xd5\x0b\x45\x1e\xa4\xe1\xc5\x37\x2f\
\xf7\xe1\xda\xaf\x04\x80\x3c\xf7\x19\x64\x7e\xe7\x23\x84\xf0\x43\
\xf3\x04\xfa\x36\x02\x01\xdd\xeb\x07\x67\xfd\x8c\x44\x0f\xf4\xd4\
\x6a\x58\xde\x18\xac\xf0\x44\xe8\xc5\x0e\x78\x12\x3f\x46\x26\xd7\
\x86\x60\x20\x26\x3e\xbf\x58\x7e\xa2\xfd\xfd\x95\x5f\x89\x72\x01\
\x94\x0c\x11\xe1\x99\x7b\x27\x9c\x70\x0a\xc6\x57\x3c\x8c\x63\x3e\
\x45\x16\xbd\xe8\x86\x41\xcf\xf1\x6c\x4e\x4d\x27\x60\xd0\x83\xd2\
\xa1\x47\x2b\x1b\x6c\x99\xc7\x6d\x92\xf6\x13\xcd\x2f\x1a\xd0\x7a\
\xda\xa1\xbb\x89\x15\x04\xc7\xd2\xef\x49\xe8\x89\xc7\x51\x59\xfd\
\x2b\x18\xd1\x6b\x91\x48\xf5\x48\x47\x5f\xee\x47\xa0\x94\x5f\x01\
\x80\x92\x21\x28\xa6\xe6\xc5\xa8\x8a\x7f\x62\xdc\xc1\xcb\x60\x21\
\x8a\x12\x6d\x9a\xa7\x00\x94\x12\xd0\x4b\x1d\x30\xfd\x51\x58\x3e\
\xee\xc2\xd3\x0f\x04\x60\xda\xd4\xdf\xca\xc3\xcc\xd3\xf3\xc9\x26\
\xe2\x82\x5e\x58\x15\xd3\x09\x18\x72\xf0\x75\xfd\x2f\xd2\x7a\x35\
\xb2\xb8\x0c\x2e\x97\x86\x80\xb7\xa4\x94\x5f\x01\x80\x92\x21\xe7\
\xbf\xb9\xc8\x8a\xf3\x0c\xbe\xcc\x13\x70\xa5\x5b\x48\xad\x4b\x44\
\xf1\x0d\x52\xf8\x28\xe0\xaa\x81\x56\x88\x43\xcf\x31\xc5\x1f\x0b\
\x8b\x5c\x01\xa9\xf4\x63\xeb\xaf\x31\x33\xd0\xa0\x95\x98\x0d\x30\
\x08\x98\xd0\x93\xeb\xa0\x85\x2d\x58\x95\xf3\xc8\x35\x78\x03\xc1\
\xf6\x6b\x51\x5d\x99\x46\x31\x74\x01\x5c\x1a\xaf\x10\xcc\xab\x0b\
\xae\x00\x40\xc9\x50\x11\x8e\xfe\x73\x20\x2e\x1e\x4f\x10\x3d\x3f\
\x01\x9e\xe8\x2a\x78\x92\x2f\x90\x01\x2f\x90\xa5\x27\x65\xf5\x90\
\x5f\xef\xad\x24\x26\x90\x24\x20\x58\x4b\xbf\xd7\x13\x08\xf8\xe8\
\x35\x0f\x2c\x8d\xa8\x3f\xd3\x01\xcd\x69\xb1\x6d\x16\x61\x15\x4c\
\x68\xe9\xf5\xd0\x82\x25\x02\x81\xbd\x60\xba\xa3\x08\x75\xdf\x08\
\xc3\x78\x17\xb9\xe8\x95\x04\x34\x93\x68\x5f\x5e\x2f\xa0\x9a\x78\
\x2a\x00\x50\x32\xf8\xca\x4f\x8f\x89\x9e\x24\x3c\xba\x85\x96\xae\
\x89\x78\x2f\xf3\x45\xcc\x69\x1c\x83\x70\xee\x61\x98\xb9\x0e\xc9\
\xf9\xc3\x5f\x45\x8a\x4f\xd6\xdb\x20\x40\x28\x36\x43\xd3\x09\x14\
\xdc\x21\x7a\x74\xf3\x0c\x5e\x9b\x0d\x94\x2c\xbb\xd5\xb7\x49\x00\
\x40\xba\xad\x65\x68\xbf\x52\x06\x56\x78\x02\x0c\x3f\xb1\x88\xf8\
\x53\x08\xe4\x96\xa1\x10\xbb\x14\x25\xdf\xb1\xe2\x66\xd8\x40\xa0\
\x9a\x7a\x8e\x08\x16\xa9\x2e\xc1\xf0\x54\xfe\x78\x4f\x42\xe2\x79\
\xf1\x54\x0a\xcd\x6d\xab\xe1\x76\x8f\x47\x5b\xf1\x2a\x74\x87\xae\
\x81\x15\x99\x49\x5f\x6c\xca\x56\xe6\x5c\x1b\xd1\x7d\x17\x41\x3d\
\x29\xbe\x11\x27\xa3\xdf\x49\xef\x23\x65\xf7\xb8\x68\xf3\x90\xcb\
\xe0\xa5\x47\x2f\xb8\x42\xc8\x2a\x71\x7a\x8f\xf6\x2d\xd2\x7e\xf1\
\xb7\xa0\x9b\x05\x58\xd5\xfb\x01\x3e\x1d\xbe\x8e\xab\x11\xe8\xbc\
\x14\xee\xd2\x53\x36\x73\x80\x0f\x43\x6d\x82\xb1\x12\xc5\x00\x76\
\x0d\xe5\x4f\x24\xc0\xf3\x73\x58\xf9\x37\xb4\xb4\xa2\xb6\xaa\x0a\
\x55\x15\xa4\x90\x96\x86\x44\xf1\x64\xe4\xbd\x73\x11\x75\xdf\x8c\
\x40\xe6\x01\x20\xd7\x0a\xd3\x60\x36\x50\x4b\x2e\x40\x98\xac\x7b\
\x8a\x3e\x83\x9b\x81\x84\x79\xf8\x1f\xbd\x87\x3f\xd3\x6d\xab\x32\
\xbb\x03\x86\xc9\xc1\x05\xfb\x0f\xa6\xd7\x49\xf7\x20\x8b\x98\x80\
\xe5\xde\x03\x7a\x7a\x29\xfc\x6d\x97\xc1\x88\x1c\x87\x42\xe8\x6c\
\x18\xfa\xee\xf4\x1e\xbe\x85\x8a\xea\xcb\x51\x0c\x40\xc9\x4e\xf1\
\xf9\x59\xf9\x1d\xcb\xbf\xa1\xb5\x4d\x94\xbf\x3a\x5a\x61\x0f\xe3\
\xf4\xb2\x4e\xa7\x90\xc9\x8f\xc1\xa6\xd2\xff\x43\x5b\xe0\x07\x28\
\x56\x1c\x48\xcf\x65\xa0\x67\xd6\x41\x2b\x24\x6c\x17\x80\x19\x80\
\x45\x0c\x82\x0b\x06\xdc\x6c\xfc\x5d\xfc\x07\xe8\x6e\x70\xcb\x2d\
\x61\x99\x9a\x6d\xdc\x75\x8f\xd0\x7d\x2d\xb3\x91\xde\xdb\x0e\x04\
\x1a\xc8\xf0\xc7\xe0\xea\xfa\x33\xb1\x81\xcb\xe0\x2f\xfe\x92\xf6\
\x5e\x43\x3b\x0e\x9d\x51\xe6\x4a\x14\x03\x18\x79\xca\xef\x94\xdd\
\xc6\x79\xd4\x16\xf1\xfe\x78\x92\x2d\x7f\x1b\x6a\xaa\x2a\x64\x50\
\x27\xfb\x02\xdc\x22\x8c\xa5\xc4\x2d\xbd\xac\xb4\x14\x02\x75\x17\
\x0f\x46\x97\x35\x03\x21\xeb\x6f\x68\xf4\xde\x01\x4f\x61\x3d\x19\
\xf8\x3a\xb2\xe8\x75\xd0\x8a\x49\x52\xee\x24\xbd\xd5\x47\xc4\x81\
\x18\x80\x9b\x14\xd8\x74\xd9\xae\xbd\x65\xd8\x6c\x40\x73\x6c\x84\
\x66\x8f\xef\x02\xbf\x87\x41\xc1\x5f\x4f\xec\xe0\x7d\x78\xcc\xdf\
\xc1\x55\xb1\x0c\x79\xdf\xa9\x28\xe1\x60\xd8\x01\x42\x55\x21\xa8\
\x00\x40\xc9\x27\x47\xd1\x48\xf9\x59\x27\x39\xe0\xc7\x74\xad\x9b\
\x94\x7f\x23\xd3\xfe\xca\x18\xaa\x2b\x62\x7d\x83\x32\x99\xbd\x5b\
\x26\x29\x78\x89\x36\x7e\x8e\xde\x65\xf5\xa0\xbb\xdb\xc2\xf2\x8e\
\x43\xd1\x58\x35\x15\x33\x6b\xef\x44\x94\x7c\x78\x33\x67\xc1\xf4\
\x35\x90\x3b\x10\xa7\x7d\x72\x04\x02\x1e\xb9\x15\x2c\xe1\x83\x9a\
\xf4\x14\x80\xcb\x6d\xc7\x05\x84\x22\xe8\x70\xc6\xf6\xda\x7f\x28\
\x10\xa0\xdd\x69\xcb\x76\x40\x4b\xbd\x05\x9f\x46\x68\xe3\x0d\x11\
\x08\x2c\x80\x94\x21\x2a\x51\x00\xf0\x71\x44\x2d\x06\xea\x53\x7e\
\x3b\xda\x6f\xb7\xee\xee\x4a\x24\xd1\xd4\xd6\x2e\x13\x75\xab\x2b\
\xa2\x65\xbd\x17\x10\xe0\x11\xdc\xac\xa3\x16\x29\xbf\x44\xf4\x69\
\xff\x54\x3a\x45\x2e\x43\x07\x02\x5e\x1d\xdd\xe9\xf1\x78\x36\xfd\
\x05\xcc\xa8\xab\xc5\x04\xcf\xdd\xb0\x4a\x1e\x58\x9e\x2a\xa2\xf6\
\xdd\x8e\xe5\x36\xd8\x89\xb0\x03\x7c\xbc\xc4\x57\xf3\xdb\xd6\x9e\
\x97\x0f\x4a\x4c\xc0\x61\x02\xbc\xd1\x71\xc1\x47\x4c\xc2\x2c\x42\
\xcb\x75\x42\xf3\x34\xc3\xab\xdf\x05\xc3\x5d\x07\xd3\x1a\xa7\x62\
\x02\x5b\xb9\x9f\x55\x0c\x40\xc9\x87\x56\x7e\xd6\xe8\x44\x32\xe9\
\x28\x7f\x0f\x36\x92\xf2\xd7\x55\x57\xd9\xca\x6f\x6d\x79\x63\x09\
\x6b\xb7\x6c\x5f\x9c\xc7\x7c\x75\x76\x25\xe0\x76\x7b\x64\x96\xa0\
\x46\x74\x3f\x9e\xc8\xe1\xc9\x65\x9f\xc6\xea\xfc\x69\x70\x15\xc9\
\x7a\x1b\x39\x58\xae\x20\xa3\x86\xf3\x09\x25\x27\xc2\xef\x95\xca\
\x40\xd9\x5c\x3e\xe9\x21\x08\xde\xcf\xc5\x96\x3f\x28\xc0\x61\x95\
\xd1\x87\x0f\x33\x4f\x20\x50\x78\x1f\x5e\xf3\xaf\x84\x15\x05\xe9\
\x52\x24\x2c\x42\xc9\xd0\xbf\xcf\xd4\x25\x18\xa2\x96\x9f\x14\x88\
\x6b\xf1\x75\xd2\x4d\xee\xdb\xbf\xb1\xb5\x1d\x0d\xd5\xd5\xb6\xcf\
\x6f\x6d\xdd\xd3\x66\x95\x63\xbd\x0b\xf3\x2a\x3e\x9f\x4f\xca\x78\
\x79\xe8\x27\xaf\x17\xc8\xe4\xf2\x64\x9d\x33\xa8\x8c\x78\xd1\x66\
\x7c\x01\xb9\xd0\x69\xd0\x73\x76\x09\x70\x2f\xb5\x97\x0f\x71\x91\
\x2b\xe0\xe9\x03\x00\x0e\xf0\x69\x5e\x9b\x0d\xb8\xbc\xb0\x08\x00\
\x34\x66\x0c\xdd\x2b\xc8\x7b\x48\xd3\x73\x21\x3b\x6d\x98\xeb\x82\
\xd7\x78\x11\x5a\xfa\x56\x64\x32\x19\x3a\x07\x97\x03\x62\x4a\x14\
\x00\x28\xf9\x90\x96\x9f\x2c\x38\xd1\x7e\x36\xc6\x5d\x49\x9b\xf6\
\x37\xd4\x90\xf2\x57\xfc\xbb\xa1\x1d\x4e\xf7\xde\x58\x05\x26\x8e\
\x1b\x83\x49\xe3\xc6\x12\x10\xf8\x91\xce\x64\x61\x94\x4c\xd4\x54\
\x56\x61\xe2\x98\x3a\x4c\x18\x55\x87\x42\xe4\x4b\x30\xfc\xb3\xed\
\x3a\x01\xb6\xec\x65\x36\x21\x8b\x85\x5c\x0e\xed\x77\xdb\x8a\xcf\
\xd3\x7d\x34\x72\x19\x1c\xb0\xb0\x3a\xdf\x82\x11\x6f\x86\x51\x2c\
\xd8\xe5\x40\x2e\x72\x17\x0a\x9d\xc4\x54\x3a\xf0\xaf\x87\x7e\x8c\
\x73\xcf\x39\x17\xf7\xff\xed\x7e\xf9\x28\x9e\x0a\xac\x44\xc5\x00\
\x94\x7c\x50\xe5\x67\xcb\xcf\xca\x4f\xbf\x77\xa7\x52\xd8\xd8\xde\
\x26\xe3\xba\x2a\x79\x06\x9f\xb9\x7d\x5f\xd2\x23\x6d\xbc\xa2\x32\
\x7a\x9b\xe7\x01\xd4\x54\x56\xa2\xbe\xb6\x16\xf9\x37\xde\x24\x00\
\x28\xa1\xb1\xa1\x0e\x75\x55\x55\xf0\x79\xb8\xab\x70\x23\x72\x91\
\xcb\x11\xe8\xfc\x0f\x29\x05\x16\x85\x67\x57\x40\x73\x7c\x7d\x38\
\x20\xa0\x3b\x81\x40\x97\xbd\x59\x9d\xcb\x50\x6c\x59\x49\xcf\xe9\
\xf4\x5f\x11\x7a\x21\x0f\xcb\x1f\xb6\xb3\x0a\xd9\x16\x94\xf2\x05\
\xbc\xf4\xe2\x2b\xc4\x38\xb2\x48\x26\xe3\x38\xe9\xa4\x93\x11\x8e\
\x44\xa4\x75\xb8\x12\xc5\x00\x94\x6c\x47\xf9\x35\x51\xfe\xa4\x58\
\x7e\x4e\xf5\x35\x33\xed\xe7\x3c\x7f\x24\xba\xfd\x40\x92\x05\xf1\
\xf5\x63\xb1\x98\x00\x47\x0f\xb1\x06\x1f\xf9\xfd\xdc\x2c\x24\x93\
\x2f\xa1\xa6\xaa\x1a\x63\x46\xd5\x0b\x8b\xe0\xb1\x62\xf6\xc4\xdf\
\x02\x4a\xae\x03\x50\x0c\x7f\x9a\x94\xb8\xc3\x0e\xf6\x95\x69\x04\
\x2b\x3f\xff\xae\x95\x59\x80\xad\xfc\x66\xf7\xbb\x28\x6c\x7c\x1d\
\x26\xb1\x09\x0e\x34\x5a\x66\x09\x56\x29\x6f\x03\x88\xaf\x02\x20\
\xe5\x9f\x33\x39\x8b\x39\xd3\x3c\xd8\xd8\xdc\x85\x87\x1e\xfe\x3b\
\x7e\xfc\x93\x1f\xe3\xbd\x77\xdf\x95\xee\xc2\x5c\xcb\xa0\x44\x01\
\x80\x92\xcd\x44\x14\x83\xf3\xfb\x64\xf9\xd9\x0a\x77\x93\x02\x37\
\x73\xc0\xaf\xaa\x52\x26\xf1\x98\xd8\xde\xa0\x4e\x48\x0d\x00\xd3\
\x7e\x8d\x7e\x61\xf6\xc0\xfe\x3f\x8f\x09\x93\xd6\xdd\xf9\x1c\xb1\
\x82\x08\x6a\x89\xfe\xbb\xf5\xfe\x83\x3a\x4d\xa9\xe2\x2b\x06\xce\
\x80\xe9\x69\xb4\x73\xfc\xa2\xf0\x96\x7d\x57\x30\x13\x20\xfa\x6f\
\xb9\x1d\x17\xa0\x6b\x05\x8a\xeb\x5e\x82\x25\x95\x82\x7a\xef\xdf\
\x16\x20\x28\xd9\x19\x08\x78\x2b\x51\x53\xed\xc1\x09\xfb\x16\xd0\
\xd3\x1d\x47\x4b\x6b\x07\x56\xad\x5e\x8d\xeb\x6f\xf8\x21\xee\xbe\
\xeb\x4e\x64\x33\x19\xf8\xe8\xd8\x54\x80\x50\x01\x80\x92\xb2\x0f\
\x46\xca\xc5\x0a\x9e\x48\xd8\x3e\x7f\x9c\x18\x40\x73\x7b\xbb\x50\
\x75\xa6\xfd\xdb\x1b\xf9\x6b\x3a\xca\x5f\x55\xc9\xca\x6f\xd2\x67\
\x24\x64\x5a\x8f\xdf\x99\xd2\xcb\x03\x40\x39\x83\x10\xf0\x7b\xe1\
\x96\x32\xe2\xcd\x3f\xab\x08\x43\x9b\x46\x2c\xe0\x54\x80\x27\x06\
\x99\xce\x70\x10\xa7\x0e\xc0\xe2\x5c\x3f\xd7\x07\xb5\x2f\x45\x61\
\xc3\xab\x76\xb2\x40\x77\xf7\xc5\x0a\xb8\x24\x91\x63\x12\xc2\x04\
\x8a\x74\x1e\x6e\xb8\x2b\xaa\xb0\x70\xdf\x2c\x0e\x99\x03\xbc\xb7\
\xaa\x09\xf1\xce\x2e\xa9\x4f\xb8\xfb\x9e\xbb\x71\xfd\xf5\x3f\xc0\
\x6b\xaf\xbe\x22\xc7\xa4\x62\x03\x0a\x00\x76\x79\xca\xcf\x4a\xc0\
\xbe\x71\x9c\x95\x9f\x53\x7d\x64\xbd\x9b\x3b\x3a\xc8\xe7\xaf\x46\
\x4c\x46\x74\x63\xbb\x01\x3f\x6e\xdd\x5d\x4d\x96\xdf\x12\xe0\xe8\
\x11\xab\x1f\x08\x04\x91\x64\xe5\x2f\x94\x44\x3f\x7d\xb4\x8f\x4b\
\xdb\x56\xf7\x5e\x7b\x39\x70\xd1\xfb\x69\x58\x81\x3d\x88\xc2\x93\
\x2b\x60\x95\x9c\x03\xf4\x0b\x28\x58\x2d\x2f\xc2\x68\x5d\x66\x57\
\x08\x96\xd7\x08\x70\xb1\x90\xe3\xb2\xf4\xa3\x02\xc2\x0e\x74\x5f\
\x18\xe3\xa6\x84\x70\xde\xc2\x2e\x4c\x6d\xd4\xb0\x7c\xe5\x5a\x74\
\x10\x9b\x09\x84\xc3\x58\xb3\x7e\x3d\x7e\xf4\xe3\x1f\xe3\x77\xbf\
\xbb\x09\x2d\x2d\x9b\xc4\x2d\xd0\x75\xe5\x16\x28\x00\xd8\xc5\x14\
\x9f\x87\x7a\x72\xb5\x1e\xe7\xea\x79\xbc\xb6\x5b\x94\x3f\x81\x16\
\xb2\xfc\x8d\x35\x35\x42\xfb\xb7\xe7\xf3\xcb\xac\x3e\xfa\x8c\x2a\
\x56\x7e\xd8\xeb\x03\x58\xf9\xed\x89\x3d\x59\x49\xfb\xb1\xf2\xfb\
\x49\xf9\xdd\xff\xb6\x93\x0f\x5b\xee\x46\x62\x01\xa7\x90\x07\xe0\
\x25\x10\xe8\x06\x4a\xc4\x06\x32\xeb\xa1\xb5\xbd\x02\x2b\xd9\xea\
\xd4\x03\xb8\x1d\x66\xc0\xab\x08\xdd\xb4\x2f\x3d\xc2\xd5\x0b\x02\
\x72\xbc\xb4\xf1\x7c\xd1\x70\x4d\x1d\xf6\x99\xa7\xe1\xa2\x63\x93\
\x88\xfa\x35\xac\x59\xbd\x01\xad\x9b\x5a\xe5\xbc\x83\x91\x30\x1e\
\x7f\xea\x49\x7c\xf7\xba\xeb\xf0\xe0\xfd\x7f\x45\x2e\x97\x11\x20\
\x50\x6e\xc1\x20\x31\x50\x75\x09\x76\xbc\xf0\xcd\x5d\x4e\xef\xf1\
\x38\xef\x6c\x26\x2d\x33\xf5\xd8\x00\xb3\x15\x6f\xed\xec\x46\x5b\
\x77\x37\x46\xf1\x88\xee\x48\xc4\x09\xd2\x6d\x47\xf9\x1d\x9f\xdf\
\x72\x7c\xfe\xf2\xac\x3e\x6e\xe0\x59\x28\x16\x65\xbd\x80\xef\x03\
\x29\x7f\xf9\x43\x4d\x14\x5c\x47\xc0\x1d\x7e\x02\x7a\xf7\x13\xd0\
\x72\x9b\x48\xe9\x03\xe2\xfb\xeb\xa1\x18\x50\xc8\x42\x33\x4a\x03\
\xa7\x07\x5b\xc4\x02\x5c\x9a\x64\x03\xca\xba\xeb\x92\xb5\x44\xb4\
\x8f\xdb\x8b\xea\xf1\x8d\x38\xea\xc0\x26\xb4\xc5\x73\xf8\xe5\xfd\
\x3e\x34\x6d\x6c\x92\x89\xc5\x91\x8a\x28\x62\x15\x31\xa4\xf3\x39\
\xfc\xe1\xe6\x5b\xf0\xf2\xcb\xaf\x60\xd1\xe2\xc5\x98\x31\x63\xa6\
\xb0\x14\x1e\x3e\xaa\x44\x01\xc0\xf0\x56\x78\x68\x7d\x55\x39\xb0\
\x07\x79\xe6\x72\x39\x14\xc9\x32\x17\x4b\x76\xb5\x9d\x4e\xb4\x9c\
\x3b\xed\xb6\x77\x27\xb0\xa9\xa3\x13\xa3\xea\x6a\x11\x65\xe5\x37\
\xb7\x1d\xf2\xb3\x27\xf6\x78\x50\x59\x19\x13\x65\xe2\x8c\x41\xc0\
\xef\x93\xf6\xdd\x89\xa4\xad\xfc\xba\xfe\x21\x95\xdf\x86\x25\xfa\
\xbc\x5a\x14\x82\xe7\xc2\x6f\xac\x03\x52\xef\xdb\x77\x86\x27\x42\
\xac\x9f\xac\x33\x29\xb4\xcb\x28\xc0\x34\x8a\x36\x08\xf4\x1e\x23\
\xbb\x02\x9a\x64\x0c\xdc\x6e\x0d\xe9\xee\x34\x3a\x7b\x48\xf9\x6b\
\x5c\x08\x55\x05\x51\x37\xa1\x0e\x9f\x3d\xa2\x05\xad\xf1\x4a\xdc\
\xf6\x94\x45\xfb\xb4\x49\x2a\xb3\x44\xee\x49\x94\x5c\x9c\x6a\x02\
\xbc\x15\xab\x56\xe1\x86\x1f\xdd\x80\xe3\x8f\x3d\x0e\xc7\xd0\x16\
\xe1\xf1\xe3\xa5\x92\x6a\x3b\xbe\xab\x03\xc0\x70\x5a\x0b\x20\xf4\
\x55\x13\xb5\x67\xc3\x28\xc1\x39\x1e\xa6\xc9\x93\x75\x78\xa2\x6e\
\xc9\x30\x85\xaa\xf3\xf9\xd8\xbb\xea\x12\x08\xe3\x20\x5d\x73\x7b\
\x07\x2a\xc2\x21\x84\x83\xc1\x5e\xdf\x7e\xdb\x96\x9f\x95\xbf\x42\
\xfe\x80\x28\x7f\xc0\x4b\xd4\x3f\x88\x78\x2a\x83\x02\x29\x0d\x2b\
\xbf\xdf\xe3\x22\xe5\xff\x28\xf5\xe7\x45\x14\xb4\xfd\x80\xc8\x97\
\xe1\xd3\x6e\x82\x96\x5c\x6e\xc7\x03\x3c\x15\xa4\xdf\x3e\x9b\x0d\
\xd0\xb9\x80\x03\x7e\x62\xa5\x4d\xbb\xf4\x98\xce\xc5\xe3\x75\x61\
\xcd\xaa\x34\xfe\xe7\xce\x18\x56\x6e\xaa\x25\x30\xf3\xe1\xe2\x53\
\x53\x58\x30\xdf\xc2\x98\x62\x01\x17\x1c\xdb\x85\xd6\xee\x1a\x3c\
\xf6\x5a\x86\x5c\x97\x2e\x39\x49\xbe\x3e\xc1\x50\x48\x80\x80\xad\
\xfe\x5d\xf7\xde\x8b\xe5\x2b\x96\xe3\xcc\x33\xce\xc2\x94\x69\xd3\
\x04\x28\x07\x30\x8e\x61\x2c\x43\xf9\x3e\x56\x0c\xe0\x23\x5b\x79\
\xbb\x29\x67\x59\xf9\xcb\x4a\x2a\x8a\x4f\x8a\x62\xca\xcd\xab\x49\
\x90\xcb\x43\x8f\x0c\x0c\x7c\x53\xf3\xd3\x9a\x13\x0b\x48\x67\x53\
\xf2\xc8\x43\x3d\xf5\xed\x68\x7f\x99\xf6\x57\x89\xe5\xb7\xa4\x4a\
\xd0\x2f\x96\x3f\x88\x1e\xa1\xfd\x76\xb4\x9f\x95\x9f\xe9\xff\x47\
\xbb\xdf\x38\x2d\xa8\x13\x08\x1c\x03\x33\x5c\x07\xbf\xfb\x0f\xd0\
\x7b\x9e\x85\x5e\x8a\x43\xf3\xc7\xec\x62\x20\xcb\x4d\x4a\xc9\xa9\
\x41\xd3\xa9\x48\xb4\xe8\xef\x59\x78\xff\xdd\x1e\x5c\xfd\x4b\x1f\
\x5e\x5f\x13\x41\xc8\x9b\xc1\xfa\x8d\x39\xac\x6d\x8a\xe1\x3f\xbf\
\xec\xc6\x81\xfb\x5a\x98\x4a\xee\xc3\x97\x4e\xee\x44\x47\x4f\x2d\
\xde\x58\x6d\x9f\xb3\x69\x46\x6c\x70\x2c\x15\x11\x0a\x05\x51\x53\
\x5b\x2b\x6c\xe0\xc6\x1b\x6f\xc4\xe9\xa7\x9f\x86\x03\x3f\x75\x90\
\xc4\x1b\x94\x4b\xa0\x82\x80\x43\x0f\x35\xc9\x1a\x7a\x7d\x7e\x09\
\x6a\x71\x4e\x9c\xd7\xe0\xb3\x05\x66\x0a\x5e\x2a\x99\x52\x89\xc7\
\xd6\xbf\x48\x37\x77\x2e\x57\x40\x36\x9f\x17\x17\x80\xab\xf1\x34\
\xe7\x3f\x59\x47\x43\x2e\x00\x2b\x36\x2b\x2f\x8f\xfa\xde\x5a\x91\
\x2f\x03\x06\x07\xfc\x84\xf6\xc3\xee\x06\xc4\x80\x11\x24\xa5\xb1\
\x47\x74\x17\x6d\xe5\x77\xdb\xca\xff\xf1\xc4\x94\x5e\x00\x25\x6b\
\x6f\x64\x02\xdf\x46\xb1\xfa\x02\x3a\x37\x37\xf2\xf1\x4d\xd0\x72\
\xdd\xd0\x4a\x69\xfa\x5b\x26\x74\x3a\x1e\xee\x2b\xe8\x62\xa7\x9f\
\xce\xf3\xb6\x87\xf2\xf8\xc7\x9b\x41\x54\x04\x8a\xc4\x3e\x48\xa1\
\x7d\x39\x74\xb4\xb5\xe1\xdb\xff\xed\xc3\x3f\x5f\xa8\x45\x60\x42\
\x2d\xe6\xcc\xf5\xe3\xab\x9f\xed\xc2\xc4\x7a\x1d\x9b\xda\x7a\x90\
\xcd\xa6\x91\x49\xa7\xa5\x68\x29\x91\x48\x22\x95\x4c\xc9\x3c\xc2\
\x1c\xb9\x19\x37\xfd\xf6\xb7\xb8\xf7\x9e\xbb\x50\xa2\xeb\xa9\xd2\
\x85\x0a\x00\x86\x94\x78\xb8\xa2\x4d\x72\xf7\xa6\x58\x74\x4e\xe3\
\x95\x78\x23\x2b\xcc\x8f\xf9\x52\x41\x80\xa0\x58\xe4\xc7\x82\xac\
\xcf\x67\x75\x97\x40\xa0\xe3\x26\xc8\xb2\x5d\xb2\xa0\x21\x7f\x00\
\x41\x02\x92\x32\x60\x98\x5b\x59\xdd\xe7\xf5\x92\xe5\xaf\x8a\x49\
\x17\xdf\x44\x3c\x8e\x10\x47\xfb\x43\x01\x19\xd4\xc9\x81\xc4\x32\
\xed\xff\xe4\xfa\xf6\xdb\x55\x82\xa6\x59\x0f\x33\x70\x29\xee\x78\
\xfa\x30\x1c\x7d\x5e\x0a\xdf\xfa\x51\x12\x4f\x3d\xbc\x09\x9b\x56\
\xae\x23\x40\x68\xa7\x53\x28\x49\x2a\xd0\xa2\xe3\xea\xe8\x26\x06\
\x82\xf2\xec\x00\xe1\x37\xf0\x79\x2d\x74\x92\x7b\x73\xcd\x4f\xbd\
\x78\xfa\xf9\x06\x84\x26\x36\xe2\x80\x7d\x74\x5c\xb9\xb8\x1b\x95\
\x21\x0d\x2d\x6d\x71\xb9\x76\xf9\x6c\x4e\x66\x10\x26\x89\xd5\x24\
\xe2\x09\x78\x5c\x9c\x29\x88\xe0\xae\x25\x4b\x70\xf3\x9f\xfe\x48\
\x40\x91\x55\x20\xa0\x00\x60\xf0\x7d\x38\xa6\xad\x3e\xbf\x5f\x2e\
\x19\x2b\x38\xa7\xda\x8a\x85\x92\x58\xf9\xa2\x61\x48\xe0\x8a\x1f\
\xb9\x20\xc6\x28\xf2\xf3\x36\x75\x65\xa5\xd0\x1c\xc5\xe7\x8d\x57\
\xe7\x95\x3f\x93\x2b\x00\xb9\xce\xdf\x23\x8b\x6d\x9c\x75\x38\x9a\
\xb3\x3f\xa7\xf1\xfc\xde\x5e\xda\x1f\xef\xe6\x54\x9f\x53\xe4\xc3\
\xca\x5f\x2c\x0e\xa0\xfd\x9f\xbc\x14\x09\x90\x7c\xf0\x54\x1e\x8b\
\xb5\xf1\xc9\xb8\xe9\x81\x0a\x5c\x72\x63\x14\x37\xfe\x31\x88\x57\
\xfe\xd9\x81\x8e\x35\xeb\x61\xe4\xb3\xd0\xc3\x41\x1c\xb9\x9f\x07\
\x85\x6c\x37\xb1\x11\xbb\x36\xa8\xec\x24\xf9\x09\x04\xe2\x9d\xed\
\xb8\xe6\xbf\xbd\x78\xea\xf9\x51\x88\x4e\x6e\xc0\xe1\x07\x18\xb8\
\x72\x11\x9d\x8b\x47\x43\x5b\x7b\x5c\x5c\x80\x62\xbe\x80\x14\xb1\
\x81\x24\xb1\x01\x76\x6f\xf8\x5a\x56\x56\x56\xe2\xb1\x27\x9f\xc4\
\x1f\x7e\xff\x3b\x64\x32\x69\x05\x02\x3b\x48\x5c\xd7\x5e\x7b\xed\
\x90\x3a\xa0\xf7\xde\x7b\x8f\x2d\xc3\xe7\x76\xdf\x7d\xf7\xf1\xd2\
\xe4\x62\x90\x85\xad\x32\x5b\x7c\x2e\x61\x65\x4b\x5d\x22\xab\xce\
\x37\x28\x53\x7d\xd3\xb0\xe9\xbe\x3c\x96\x6c\x0b\x2e\x3f\xf3\x7b\
\x74\xdb\xe2\x97\xe3\x05\x76\xe1\x8e\x87\x14\x38\x28\xcc\xc0\x76\
\x04\x20\xa3\xb6\xbd\xd2\x95\xd7\xae\xe7\xe7\xcc\x00\x57\xed\x31\
\xd8\x70\x56\x40\x52\x7d\x4e\x9e\x9f\x47\x74\x97\x53\x7d\x3b\x56\
\xf9\x1d\xe0\xa3\x73\x9b\x34\x61\x2c\xc2\x21\x1d\x71\xb2\xfa\xe9\
\xbc\x86\x67\xdf\x2c\x60\x6d\x4b\x18\x95\xee\x0c\x62\xbe\x6e\x3a\
\x26\x2f\xa6\xef\x51\x89\x42\x22\x8e\x47\x9f\x2f\x20\x12\x0d\xdb\
\x41\x48\xe7\xcc\xe9\x10\x91\x49\xa5\xf1\xdc\x1b\x11\x4c\x18\x1b\
\xc1\x8c\x39\x06\x46\x07\xbb\xe1\x25\xe6\xf0\xd2\x0a\x2f\x32\xd9\
\x02\x9d\x9b\x4f\xae\x50\xd1\x89\xfe\xcb\x35\x27\xc0\x0d\x47\x23\
\x78\x97\xee\x87\xce\xb6\x56\xcc\x9a\x35\x5b\xbe\x03\x73\x18\x06\
\x06\xb9\xce\xe1\xe6\x9b\x6f\x5e\xbd\x7e\xfd\xfa\x77\xe9\xd7\xb5\
\xb4\x75\x9e\x77\xde\x79\xc6\x84\x09\x13\x54\x10\x70\xa8\x5b\x7e\
\xb6\x3c\x1c\x7d\x67\x8a\x5f\x60\xeb\x4e\x56\xde\x34\x2c\x19\x9f\
\xcd\x29\x2d\x01\x00\xde\x2c\x3b\x35\xc6\xd6\xdb\xad\xf5\xe5\xc6\
\xcb\xea\xc9\x37\x34\xef\xc3\x3e\xaf\xf4\xf0\x13\x73\xef\xdc\xec\
\xa4\xf4\x2e\xdd\x5e\x2c\xc3\x75\x01\x6e\xba\x61\xbc\x6e\x2f\x4a\
\x46\x49\xa6\xf4\x72\x9e\xdf\x47\xee\x42\x77\x22\x25\x2c\x83\xd9\
\xc8\x27\xe3\xf3\x7f\x80\xf3\xa7\x73\x3f\xfd\xb4\x33\xd1\xd2\xd2\
\x86\xb7\x96\xbd\x4d\xa0\xe4\xc7\x8b\x2b\x9b\xd0\x1a\xaf\xc6\x85\
\x64\xad\x8f\xca\x6f\xc4\xe8\xdd\xea\x71\xcd\x55\xa3\x51\x32\x9b\
\xf0\xbf\x77\xb4\x61\xc2\xf8\x06\x3a\x1f\xc3\xa9\x64\xd4\xc4\x1d\
\x48\x11\x80\x5c\xfb\x3f\xb5\xc8\x5e\x32\x09\xc7\x2d\x28\x62\x71\
\xbe\x85\x5c\x18\x1d\xbf\x7c\x20\x80\xae\xae\x38\xaa\x6b\x2a\x25\
\xbb\x91\xc9\x64\xe5\xba\x32\xf8\x70\x90\x90\x17\x38\x3d\xff\xd2\
\x4b\x02\xc2\xe7\x9f\x7f\x21\xbc\x0c\xc4\x2a\x30\xa8\x00\x60\x67\
\x59\x7e\x56\x7e\xf6\xb5\xb9\x80\xc7\xe0\xcd\xb2\x2d\x3e\x2b\xb3\
\x28\xbe\x69\x47\xc3\x59\xa9\xb9\x55\xb7\xab\x9f\x53\x25\xc1\x3e\
\xfa\x1c\x9f\xcf\x2b\x16\x9d\xa3\xf5\x9a\x56\xea\x05\x16\x8e\x13\
\x58\xce\x12\x5f\x4d\xe2\x02\xa6\x54\x08\x6a\x64\x09\xd3\xec\x1f\
\xe7\xf3\x62\xf9\x7d\x3e\x3f\x9a\x5b\x3b\xe4\xc6\xe7\xba\x7e\x9f\
\x7b\xe7\x0d\xea\x94\xbf\x49\xcc\xe3\xcc\x33\xce\xc4\xf5\x37\xfc\
\x80\xac\x99\x4f\x5c\x96\x55\xef\xaf\xc7\x7f\x2d\x09\xa3\xbd\xc7\
\x23\xca\x3c\x61\x46\x11\xd7\x7e\xb3\x91\xae\xd3\x26\xfc\xe2\xae\
\x16\x4c\x99\x54\x4f\x00\x65\xc2\x3e\x3d\x8d\xde\x67\xa1\xa7\xab\
\x1d\x3f\xfc\x75\x3d\xf9\x09\xd3\x71\xdc\x9e\x45\x9c\x56\xe8\x44\
\x22\xa3\xe3\x4f\x8f\xf9\xa0\x75\xc6\x51\x55\x5d\x29\xcc\x26\x97\
\xcd\x3a\xa0\x6a\x09\x28\x44\xa3\x51\x3c\xff\xaf\x7f\x49\xbd\xc3\
\x59\x67\x9f\x23\xc1\x47\x05\x02\x0a\x00\x76\xb8\xcf\x2f\xca\x4f\
\xfe\x29\x53\x53\x43\xf2\xfa\x46\xaf\xd2\x1b\x96\xe1\xe4\xc1\x6d\
\xaa\xaf\x43\x43\x7f\x83\x5c\x2e\x06\xe2\xd7\x58\xf9\x93\x99\x0c\
\x36\x36\x35\x93\x35\xf4\x0a\xd5\x67\xe5\xe6\x00\xde\xa8\xfa\x7a\
\x09\x12\x4a\x01\x10\x37\xde\x75\x02\x88\x70\x5c\x86\x00\x59\xff\
\x75\x4d\x2d\xe4\xf7\xa7\x89\x8a\x07\xa5\xc8\xc7\xe3\xd2\x77\x6a\
\x6e\x99\x83\x75\x13\x26\x4e\xc4\xe2\x93\x17\xe1\xb7\xff\xf7\x7b\
\x34\x8e\x19\x25\xec\x65\xdd\xfa\x66\xfc\xe6\x01\x9f\xb0\x81\xcf\
\x65\xba\x88\xde\x97\xf0\xbd\xab\x6b\x09\xc4\x3a\xf0\xeb\xbb\x5b\
\x31\x65\x72\xbd\xa4\x09\xed\xe0\xa6\x0d\x02\xa9\x78\x1b\x7e\x7c\
\x53\x3d\xf4\x4b\x66\xe2\x98\xd9\x6f\xe2\xfc\x52\x37\x31\xab\x4a\
\xdc\xfa\x04\x5f\xcb\x38\x2a\xab\x79\x49\xb3\x2e\xd7\x87\x01\xb1\
\xdc\x00\x25\x10\x0e\xe1\xa9\x67\x9e\xa1\x6b\x10\xc6\x29\x8b\x16\
\x3b\xa9\x44\x35\x9d\x48\x01\xc0\x0e\x01\x00\x5e\x44\xe3\x95\xe0\
\x94\x44\xf4\x85\xf6\x1b\xbd\xfe\x3e\xca\x51\x7d\xbd\x4c\xf1\xb7\
\xae\xfc\x70\x7c\x7f\x56\x68\x0e\x0c\x56\xc7\x2a\xe1\x27\x36\x90\
\x4e\xa7\xe1\x8f\x84\x51\x53\x55\x25\x37\x39\xbb\x05\xdc\xb9\xc7\
\x74\x0a\x85\xca\x9d\x79\x43\xa1\x10\x36\xb5\x75\x60\x53\x6b\x2b\
\x42\xc1\x10\xa2\xec\x0a\x10\x28\x0c\x46\x61\x09\x03\xd3\x81\x07\
\x1d\x8c\x57\x5e\x7d\x0d\x6f\xbc\xb5\x14\xf5\xf5\x0d\x42\xef\x5b\
\x36\xb5\xe0\xce\xa7\x81\x4d\x5d\xb5\xf8\x52\xb6\x03\xf3\xe7\x97\
\x70\x3d\x81\x80\x85\x4e\xfc\xfa\x1e\x02\x81\x89\x75\x70\xbb\x34\
\xa7\x99\x89\x46\xec\xc1\x42\xa2\xbd\x15\x3f\xfa\x0d\x01\xdf\xc5\
\xb3\x70\xf4\xbc\x37\x71\x91\xd9\x45\x2e\x56\x25\x6e\x7b\x86\x63\
\xac\x71\x49\x79\x72\xbb\x91\x42\xbe\x60\x57\x56\x95\x83\x8a\x01\
\x3f\x1e\x7a\xe4\x61\x44\xe8\xda\x1d\x7d\xec\xf1\xaa\x71\xac\x02\
\x80\x1d\x40\xfd\x49\xc9\x3d\x44\x73\xd9\xff\xce\x39\xd4\x9f\x23\
\xd5\x86\x73\xb3\x49\x60\xcf\xb2\x33\xf9\xe5\xd8\xfe\x40\xe5\xc7\
\x16\x33\x32\x0a\xf9\xa2\x7c\xae\xcf\x6b\xbb\x13\x41\xa2\xd4\xa3\
\x1a\xea\x91\x24\xab\xbe\x6a\xdd\x7a\x44\xc9\xaa\x85\x02\x41\x72\
\x07\xfa\x68\x2d\xd7\xf6\xf3\xdf\x5f\xb5\x76\x83\x44\xd6\x63\x91\
\x10\xed\xe3\x1f\xb4\x1b\x9e\x8f\x9f\xfd\xef\xc5\x8b\x17\x61\xc5\
\x8a\xe5\xd0\xdd\x2e\x54\xc6\xec\xb6\xe4\x1e\x57\x07\xfe\xf1\x66\
\x06\x9d\xc9\x5a\x7c\x35\xdd\x85\x83\xf7\x6f\xc1\xf5\xdf\xa8\x25\
\xc5\x8f\xe3\x97\x77\xb5\x61\xe2\xf8\x06\x52\x7c\x73\x00\x08\xc4\
\x09\x04\x6e\xf8\x4d\x1d\xac\x8b\x66\xe3\x98\x3d\x97\xe2\x62\x83\
\x40\xc0\xac\xc2\xdd\xff\x84\x0c\x2d\x89\x55\x56\x48\x11\x55\xb1\
\x98\x47\x3a\x65\x39\x60\x6a\x49\xa3\x93\x7b\xef\xbb\x0f\xd1\x8a\
\x18\x0e\x38\xf0\x20\x09\xa8\x42\x81\xc0\x47\x16\x95\x06\xdc\x8c\
\xfa\xb3\x7f\xc9\x0a\x9d\x2b\xe4\xed\x74\x9f\xe4\xf2\x6d\xab\xef\
\xb2\x1d\x75\x09\xda\x79\x39\x2d\x65\x61\x2b\xca\xbf\xb9\x6f\x6e\
\x17\xfd\xf0\x7b\xba\x13\x09\xa4\x32\x69\xb2\xe6\x41\x24\x93\x29\
\xac\x5a\xb3\x56\x9a\x77\xf0\x92\x5e\xa3\x9f\xf2\xf3\x3a\x01\x3f\
\x3d\xbf\x66\x7d\x13\x12\xc9\x1e\xa2\xbd\x01\xd9\x67\xb0\x6f\xf4\
\x22\x01\xd2\xa4\xc9\x53\x70\xcc\xd1\x47\x23\x1e\x8f\x23\x52\x11\
\x41\x38\x1c\x46\x75\x4d\x2d\x1a\xea\xa2\x78\x67\x8d\x85\x6b\x6f\
\xae\xc6\x83\x8f\x5b\xe8\x5a\xdb\x82\xef\x7e\x25\x84\x2f\x9d\x9a\
\xc6\xba\x0d\xad\xe4\x46\xa1\x37\x2b\xc2\xd7\x48\x40\xa0\xa3\x15\
\xd7\xff\xc6\x8b\x07\x97\xce\xc5\xac\x79\x31\x5c\xf2\xe9\x6e\x9c\
\x72\x60\x91\xce\xb9\x80\xee\xee\x04\x01\x46\x49\x98\x10\xb3\x0f\
\x66\x4d\xe9\x54\x8a\xc0\x34\x4f\xe0\x6c\xe0\x2f\xb7\xfd\x05\xef\
\xbc\xfd\xa6\x44\xd8\x95\x8c\x30\x06\x30\x58\x73\x01\xc4\xc2\x93\
\xa2\xe6\x88\x7a\xe6\x73\xce\xc2\x1d\x58\x7d\x4d\x73\xb9\xe3\x2e\
\xf9\xe1\x9c\xe3\xe7\xd7\xb8\x28\x27\xcf\x69\x41\x8e\xcc\x6b\xfa\
\x56\xa6\x63\x39\x85\x3f\x5c\x48\xeb\x72\xa1\xae\xba\x5a\x02\x82\
\x5c\x1d\x98\x27\x80\xa9\x20\x2a\x1b\xe3\x8e\x3f\x8e\x2f\x6b\xf3\
\x0a\xb2\xa8\xc4\x14\xd2\x99\x1c\x56\x6f\xd8\x00\x0f\x59\xc1\x7a\
\x72\x15\x18\x40\x0c\x63\xf0\x7d\x5e\x66\x44\x47\x1e\x75\x14\x5e\
\x7e\xf5\x15\xb4\xb4\xb5\x91\x25\xae\x70\xe2\x22\x06\x5c\x6e\x1d\
\x1b\x5b\x7a\xf0\xbd\xbf\x54\x22\x91\xe9\xc1\x89\x87\x75\xe0\xda\
\x2f\x55\xc1\xe3\x49\xe1\xbf\x6f\xb7\x30\x76\x54\x1d\x01\xa7\xd6\
\x1b\x13\x60\x10\x48\x76\x11\x08\xfc\x96\xdd\x81\xb9\x38\x7a\xfe\
\xeb\xb8\xd8\xe4\xb5\x02\x55\xb8\xef\x79\x66\x1d\x71\x54\x55\x55\
\x08\x28\xf3\x42\xaa\xb4\x95\x16\xf0\x88\x10\xe8\x70\x4c\xe5\x0f\
\x7f\xfa\x03\xbe\xf4\xc5\x2f\x61\xec\xb8\xf1\x43\xba\xe7\xe0\x50\
\x76\x55\x14\x03\xd8\x2c\xf0\xc7\xca\x9c\xcb\xe5\x85\xf6\xdb\xb6\
\xdb\x12\xc3\xcb\x16\x39\x1c\x0e\xc9\xca\xbd\x27\xff\xf5\x12\x1e\
\x7c\xea\x1f\x78\x7d\xc5\x4a\x59\xd0\xc3\x5d\x78\x78\x55\xdc\xc0\
\x52\x5e\x6d\xa0\x3b\xe0\xf4\xf1\xe7\xcf\xe6\xc9\xbe\x49\xb2\x68\
\x59\x02\x01\xb1\xfc\x9a\xbd\x77\xb9\x8e\xc0\x4f\x56\x6d\x43\x73\
\xb3\x34\x0a\x89\x91\x95\x65\xa0\x18\x2a\x01\x2f\x83\x5c\xa3\x58\
\xac\x12\x27\x9f\x78\xb2\xc4\x48\xb8\x23\x11\xc7\x2a\xfc\xbc\x24\
\x99\x5d\x9b\xc6\x0a\x74\x93\x9e\xfe\xd7\x3d\x51\xdc\xf6\x90\x1f\
\xeb\x57\x74\xe0\xea\x8b\x7d\xb8\xe2\xd4\x14\xd6\x37\xb5\xa3\x68\
\x0c\x2c\x16\x62\x10\x48\x77\x93\x3b\xf0\x5b\x2f\x1e\x5b\x31\x17\
\xb3\xf7\x0e\xe3\x82\xe3\x3a\x71\xea\xc1\x36\x08\xf3\x6c\x03\xfe\
\x9b\x7c\x7d\x38\x15\x9b\x65\x26\x40\x1b\x67\x4f\x5a\x5a\xdb\x71\
\xfb\xed\xb7\x23\x45\xcc\x40\xf5\x1b\x54\x00\xf0\xf1\x00\xc0\xe6\
\xde\xc8\x92\x82\x72\x75\x9f\x3d\x5c\xcb\x92\x4c\x40\x94\x14\x30\
\x4b\x16\xe6\xd5\xb7\x97\xe1\xc5\x37\xde\x42\x36\x9b\xc3\xf8\xd1\
\x8d\xa8\x21\x1f\xb8\xa9\xb5\x15\xef\xae\x5d\x2f\x2b\xfe\x58\x71\
\xed\xd4\xdf\x40\xe5\xd7\xfa\x51\x03\x66\x13\xd5\x95\x31\x7b\xa8\
\x27\x59\x4f\x59\x4c\x64\xd9\x69\x47\x8e\x0f\x30\x88\xf0\xcf\xeb\
\x9a\x5b\x24\x17\xce\x83\x40\x74\x19\x0c\x3a\x74\xae\x15\x53\xf2\
\x79\x7b\xcd\xc7\x82\xbd\xf7\x46\xbc\x3b\x8e\x10\x01\x63\x40\xd2\
\x95\x3e\x89\x13\x34\xd4\xc7\x90\xcd\x03\x3f\xff\x5b\x18\xb7\x3c\
\x14\xc2\xea\xe5\x5d\xb8\xfa\x42\x0f\xbe\xb4\x38\x89\xb5\xeb\xdb\
\xc9\xd7\xd7\xb7\x00\x81\x04\x31\x81\x1b\x7e\xe7\xc7\x53\xab\xe6\
\x62\xee\x3e\x61\x9c\xb5\xb0\x0b\xa7\x1d\x5c\x14\xcb\xdf\xd1\x19\
\x97\x98\x0c\x5f\x3c\xae\xc0\x4c\xa7\x33\x52\x5c\xc4\x80\xfd\xe6\
\xb2\x65\xb8\xe7\xee\xbb\x04\x20\xd5\x1c\x02\x15\x04\xfc\xc8\xca\
\x2f\xd6\x9f\xe8\x2d\x53\x49\x4e\xf7\x71\x85\x1e\x2f\xb5\xe5\x45\
\x3e\x1c\x88\x5b\xdf\xb2\x49\x5e\x1b\x5d\x57\x8b\x89\x63\x47\xa3\
\xa1\xb6\x9a\x68\xbd\x5b\xaa\x02\x9b\x5a\x5a\xb1\x72\xf5\x1a\xa1\
\xa6\xe3\x1a\xeb\x09\x08\x3c\x52\x34\xa4\x59\x03\x15\xbf\x7c\xc3\
\x73\x30\x8c\x7f\x67\x70\x29\xbb\x16\x92\xfe\xa3\xcf\xe2\x85\x3e\
\x9c\xf2\x5b\xdf\xbc\x89\x00\xa6\xc2\xee\xfa\x33\xc4\xd2\x5d\x52\
\xc7\x40\xe7\x78\xe2\x49\x27\x61\xd9\x8a\xe5\x02\x5c\x11\x02\x01\
\x5e\xec\xc4\xd9\x0e\x3e\xa7\xba\xba\x4a\xb4\x93\xe2\xde\xf4\x50\
\x00\xdc\x33\xf4\x4c\xa2\xf3\xd7\x5c\x1c\x23\xe5\x4f\xe1\x7f\xef\
\xd2\x30\x69\x7c\x2d\xdc\x7a\xbf\x3a\x01\x02\x81\xee\xb6\x56\xfc\
\xe8\xb7\x75\xd0\x3f\x3f\x07\x9f\xda\x7b\x29\x81\x44\x37\x82\x9e\
\x0a\xdc\xf2\x94\x86\xf6\x8e\x04\x6a\x6a\x22\xf4\xbd\x78\x25\x0e\
\x90\x76\x00\x9b\xd9\xc7\x33\xcf\xfe\x03\xe3\xc6\x8d\xc3\xa1\x87\
\x1f\x21\xaf\x29\x51\x0c\xe0\xc3\xdd\xd0\xdc\xa4\x82\x2c\x38\x5b\
\x7f\x4e\xf7\xb1\x9f\xcf\xed\xb5\x5a\xba\xe2\x78\xfb\xdd\xf7\xd1\
\x44\x37\x66\x8c\x94\x7b\xee\xee\xd3\xb1\xcf\x9c\x3d\x30\xba\xbe\
\xd6\xa6\xa4\xb2\xba\x0f\xc4\x06\x46\x61\xde\x8c\xdd\x25\xc8\xf5\
\xfa\xb2\x95\xd8\xb0\xa9\xd5\xa9\x0b\xd0\xfa\x29\xbf\xd6\x4b\x09\
\xb4\x7e\x6e\x81\x28\xbf\xc4\x14\x0c\x29\x02\x62\x20\xea\x88\xc7\
\xe9\x58\x72\xc2\x14\x38\x6d\x68\x0e\x41\xff\x91\x57\xea\x4d\x98\
\x38\x09\x9f\x39\xe1\x04\xa4\xc8\x55\x71\x4b\xcd\x42\x50\xea\x16\
\x5c\x4e\xdb\xb3\xda\x9a\x18\x34\x97\x07\xbf\x7d\x38\x88\x5f\x2f\
\xa9\xc0\x7b\xcb\x12\xf8\xce\xc5\x2e\x7c\x71\x51\x12\xab\xd7\x6d\
\x85\x09\xb8\x4c\x74\xb4\xb4\xe1\x87\xbf\x0e\xe1\x1f\x6b\xe6\x62\
\xce\x82\x30\x16\x1d\x16\xc7\xc5\x47\x67\x10\x70\x15\xd1\xd2\x92\
\x20\x10\xce\xcb\x75\x65\x45\x67\x16\xc0\x9d\x86\x39\x36\x72\xdf\
\x5f\xff\x8a\x15\xcb\x97\xa9\xa0\xa0\x02\x80\x0f\x2f\xac\x90\xe5\
\x95\x75\x42\xf7\xc9\xb7\x7d\x6f\xc3\x46\x34\x13\xbd\xe7\xe5\xba\
\xd3\x27\x8c\x17\xe5\x1f\xd7\xd0\x20\xc1\x3c\xbe\xe1\xca\x41\x1d\
\xfe\x97\xe3\x06\xbc\xdf\xcc\x29\x93\x08\x08\x76\x43\x82\x7c\x52\
\x0e\xe2\xb9\x74\xbd\x9f\xf2\x0f\x64\x02\xe5\x5a\x01\xa6\xae\x45\
\xa2\xb7\xbc\xa4\xb8\x64\xda\x0b\x84\xda\x3b\xbb\xa5\x24\xb8\x8e\
\x2b\xe3\x86\x30\xad\x65\xc6\x74\xe8\xa1\x87\x63\xef\xbd\xe6\x21\
\x1e\xef\xb6\x5d\x81\x60\x08\x7e\x02\x50\xe9\x7d\x48\x0c\xa9\xa6\
\x3a\x06\x8f\xcf\x85\x9b\x1f\xf7\xe3\x17\xf7\x54\x60\xe5\x3b\x09\
\x7c\xfb\xf3\x3a\xbe\xe8\xb8\x03\x45\x43\xdf\x2c\x3b\xc0\x20\xd0\
\x82\xeb\x7f\x1d\xc0\x13\x2b\xe7\x62\xd6\x82\x18\x4e\x3c\xb4\x07\
\x97\x1e\x9b\x46\x5d\xd4\xc0\x26\x02\x81\x1c\x29\x3d\x5f\xf7\x3c\
\x01\x36\x67\x53\xd8\x25\xeb\xec\xee\x96\x78\x40\x77\x57\xa7\x5a\
\x38\xa4\x5c\x80\x0f\x0b\x00\x1a\x82\x7e\x2f\xd2\xa4\xf8\x9b\xc8\
\xea\x73\xa3\x4e\xee\xb1\x3f\x86\xe8\x3e\x5b\xe1\x00\x59\x61\xd6\
\x77\x63\x3b\x54\x9c\x01\xa1\xe4\xb0\x07\x06\x01\x43\xda\x80\xe5\
\x07\xa6\x09\xb5\x2d\xde\x44\xd4\xbf\x24\x0c\xc4\xb6\xf2\xf6\xda\
\x02\xae\x0f\xe0\xde\x80\xd5\xb1\xd8\xbf\x9d\x06\x34\x98\xc2\x91\
\x7f\xb6\xfa\xa7\x9e\x76\x3a\xd6\x6f\xdc\x28\x91\xf9\x48\x24\x24\
\xcf\xb3\xdb\x92\x49\xdb\x33\x02\x6b\xaa\xb8\xc4\x37\x8e\xdb\x9f\
\xf1\xd0\x6b\x31\x7c\x9e\xdc\x81\x6f\x5d\x18\x25\x30\x4d\xe2\xe7\
\x77\x59\x18\x37\xba\x96\xac\x7f\xbf\xec\x80\xc7\x42\x17\xb1\xae\
\x1f\xfc\xba\x1e\xc6\x45\x73\x70\xec\xde\xef\xd0\x73\x1d\x88\x86\
\x4c\xfc\xe9\xf1\x30\x56\x34\xa5\x50\x55\x65\x22\x1c\x26\x17\x8d\
\x98\x52\x92\xae\x1b\xd7\x05\xbc\xbf\x66\x35\x96\xdc\x77\x1f\xce\
\x39\xe7\x5c\xe9\x54\x64\x59\xaa\x52\x50\x31\x80\x0f\x7a\x21\x78\
\x01\x8f\x65\x2b\x65\x75\x34\x82\x49\x63\x46\x61\x4c\x7d\x1d\x02\
\x44\x29\xa5\xde\xff\x03\xd2\x70\xbb\xa4\xd7\x2e\x18\xd2\xf5\xad\
\xd0\xfe\x7e\xd6\x9f\x01\xc3\x70\x56\xbf\x19\x86\x6d\xfd\x39\xe2\
\xcd\xf5\x07\x15\x04\x00\xdc\xef\x6f\xa8\x57\xba\x71\xec\x62\xdc\
\xb8\xf1\x38\xf3\xf4\x33\xc4\xff\x67\xbc\xe2\xda\x80\x80\x2c\x60\
\xf2\x4b\x28\x95\x41\xa0\x8a\x40\x20\x12\xf1\xe0\xce\x7f\xfa\xf0\
\xdb\xbf\xc6\xb0\xec\xad\x1e\x7c\xe3\x73\x3a\xbe\x72\x5a\x12\x1b\
\x9b\xdb\x90\x37\xd0\xaf\x33\xb0\x1d\x18\xec\xe9\x20\x26\xf0\x1b\
\x37\x1e\x58\xba\x07\xa6\xce\xaf\xc7\xa1\xfb\xe6\xf1\xa5\xcf\x24\
\x70\xd0\xee\x45\xf4\xc4\x53\xe8\xea\xea\x21\xd6\x64\x48\xc5\x60\
\x4f\x22\x21\x6e\x1c\xc7\x03\x9e\x7d\xf6\x59\x49\xb7\x2a\x51\x0c\
\xe0\x43\x05\xb6\xc2\xa4\x70\x41\x9f\xb7\x77\x4d\xfe\xc7\xf1\xbd\
\xed\x51\x5f\xb6\x15\xda\x9a\xf2\xb3\x85\x2c\x39\xae\x84\x29\x0c\
\xc0\x44\x90\x57\x00\x4a\x67\xa1\x02\xd1\xff\x7a\x3b\xb5\x35\x0c\
\xaa\xdc\xb8\x54\x7a\x9f\x7d\xf7\x43\x6b\x4b\x2b\x6e\xbf\xfb\x4e\
\x54\x10\x6b\x0a\x85\xc2\x36\xb3\xe1\x6e\x49\xbc\xee\x81\xae\x45\
\x55\x65\x25\xd9\xea\x6e\xdc\xf3\x9c\x07\x3e\x4f\x05\xce\x30\x13\
\xf8\xfa\x39\x11\xba\x3e\x49\xfc\xf4\x36\x60\xec\xe8\xba\x2d\x98\
\x40\xaa\xbb\x0d\x37\xfc\xaa\x0e\xda\xa5\x33\x70\xdc\x82\x77\xe1\
\xf5\xb7\x13\x13\x88\x63\x54\x4d\x14\xf7\xbf\x04\xb4\xb7\x1b\x04\
\x2e\x21\xc9\x9e\x24\xe3\x09\x44\x63\x15\xb8\xef\xaf\xf7\x61\xca\
\x94\x29\x18\x3d\x7a\x34\x86\xc2\x92\x72\x05\x00\xc3\x05\x04\x80\
\x81\x7d\xee\x3f\xa6\x5b\xc1\x99\x84\x7c\xc1\x70\xd4\xbe\xdf\xfa\
\x60\x5e\xf4\x53\x32\x7b\xad\xbf\xe9\x14\x8a\x70\x4e\x3d\x5f\x28\
\xca\x20\x0f\x76\x01\x38\x86\x60\x0c\x83\x05\x2f\x0c\x66\x7c\x94\
\x47\x1f\x7b\x2c\xda\x3b\xda\xf0\xc4\xd3\x4f\x13\x08\x54\xd9\x0b\
\xa8\x1c\x46\x54\x94\x18\x8b\x2e\x53\x8c\x3a\x8d\x1e\x72\x07\x98\
\x7e\x56\xe0\x34\x10\x08\x9c\xcb\x95\x90\x29\xfc\xf4\x2f\x1a\x26\
\x8c\xab\x95\x1e\x02\xe5\xec\x00\x33\x81\x54\x77\x3b\x7e\xf4\x9b\
\x3a\x7a\xff\x54\x1c\xb3\x9f\x5b\x40\x20\x12\x4e\xa0\xb1\x32\x8c\
\xbb\x9e\x05\x36\xb6\x26\xc9\x55\x2b\x0a\xe0\x30\x68\x36\x11\x80\
\x2e\x59\x72\x2f\x2e\xbd\xf4\x32\xf9\x1e\xd4\x7a\x01\x05\x00\x83\
\xe0\x1f\x9b\x72\x33\xda\xdd\x80\x34\xf4\xd7\xff\xa2\x61\x2f\x2b\
\xd6\x2c\xa7\x91\x28\x2f\x02\xa2\xe7\xb9\xbc\x98\xfb\xe3\x71\x24\
\xdb\x6e\x92\x31\xbc\xce\xd7\xed\xf1\xe2\xd4\xd3\xce\x90\xee\x3e\
\x2f\xbe\xfc\x0a\x2a\x24\x85\x69\x83\x5b\x9a\x83\x9d\x45\x6e\x1b\
\xc6\xee\x40\x94\xe8\x7b\x02\x7f\xf9\x07\x2f\xba\x8a\xd2\x73\x3d\
\xb8\xea\xfc\x28\x5d\x97\x24\x7e\x7e\x3b\x30\x69\x3c\x2f\x20\x32\
\x07\x80\x40\x4f\x47\x2b\x7e\xfc\xeb\x7a\x68\xfa\x44\x1c\x7d\x80\
\x1b\x81\x48\x37\xa2\xd1\x04\xc6\xd4\xe5\x71\xe7\x3f\x2a\xf0\xca\
\xaa\x1c\x92\xe9\x82\x9d\x92\x8c\x86\xf1\xd8\xe3\x8f\xe1\xc0\x03\
\x0e\xc4\x9e\xf3\xe6\xa9\xc9\xc4\x0a\x00\x06\xc7\xa5\xe0\x68\x74\
\xb9\xd0\xa7\x4c\xff\xa5\xff\x9f\x69\x2f\x73\x2d\x5b\x7e\x53\xdc\
\x04\x4d\x16\x0b\x65\xf3\x39\x04\x02\x7e\xe9\x03\x30\xdc\x2c\x17\
\xc7\x2f\x42\xe4\xff\x9f\x7f\xc1\x85\x52\x13\xf0\xca\x1b\xaf\x23\
\x5a\x51\x69\x57\x48\xd2\xff\xe9\x54\x5a\x3a\x2a\xb9\xdc\x0c\x02\
\x11\x74\x74\xf6\x48\x8e\xdf\xed\xe2\xde\x0b\x09\x7c\xe7\x12\x5e\
\x5c\x94\xc4\xcf\xee\x00\x26\x4f\xa8\x93\xe7\x7b\x17\x10\x79\x4c\
\x74\x75\xb4\xe0\x47\xbf\x6c\xa0\xe7\xc6\xe0\xd8\x43\x3c\x98\x1a\
\x09\xa1\xb2\xa6\x1d\x93\x46\x77\xe0\xd1\x97\x23\x78\xe4\xb5\x00\
\xd6\xb6\xa5\xd0\xdc\x92\x14\x97\x63\x43\x53\x3b\xe6\xef\xad\xc2\
\x5c\xc3\x0e\x00\x06\x6b\x2d\xc0\x27\x2d\xb6\x1b\xe0\x16\x3f\x94\
\xd7\xb8\x9b\x92\x29\xe8\x6b\x7b\x65\xf5\x73\x01\xbc\x5c\xed\x67\
\xda\x99\x04\x5e\x63\xc0\xcb\x91\xcd\x61\x78\x0d\xf8\x5c\xc3\xe1\
\x08\x2e\xb8\xe8\x62\x68\xbf\xff\x1d\x5e\x23\x10\x08\x86\xc2\xbd\
\x95\x91\xbc\xb2\xaf\xc4\x6e\x8e\xcb\x8b\x9a\xea\x0a\xb4\xb5\x27\
\x08\x04\xfc\x08\xf9\x4b\x74\xad\xe2\xb8\xf6\x8b\xe4\x3a\x20\x85\
\x5f\xdc\x69\x61\xf2\xf8\x7a\x02\x01\x38\x20\xa0\xd3\x35\x22\x10\
\xe0\xa5\xc4\xbf\xac\x83\x59\x6a\xc0\xf1\x87\xb7\xa2\x31\x10\x44\
\x45\x4d\x07\xc6\x8d\x4f\xe0\xd0\xf9\x19\xbc\xb8\x2c\x84\x95\x1b\
\xc9\x4d\x70\x67\x31\x63\xd4\x0a\x72\xb5\x8e\x76\xc2\x28\xd6\xa0\
\xde\xcf\x0a\x00\x76\x61\x37\x40\x16\x15\x59\x90\x00\x9f\x69\x95\
\x01\xae\x2f\xbe\x27\xfd\x07\xbc\x5e\x27\x1b\x60\x4a\xf3\x4f\xdd\
\x99\xbc\x3b\x1c\x85\x41\x20\x12\xad\xc0\x05\x17\x5c\x84\xc0\xad\
\x37\xe3\x85\x97\x5f\x96\x75\x02\x65\x49\x27\xd3\xd2\x23\xc1\xed\
\xf6\xa2\xae\x36\x8a\x4d\xad\x09\xfc\xf1\xf1\x30\x42\x3e\x62\x02\
\x9e\x6e\x7c\xf7\x3f\xd8\xfa\x67\xf0\xb3\xbf\xb4\x60\xfc\xb8\x06\
\x02\x43\x07\x04\xc8\xaa\x7b\x3d\xf6\x2a\xc2\x1f\xfe\xaa\x9e\x58\
\x46\x2d\x3e\xb3\xb0\x0d\x41\x54\x13\x6b\xd2\x50\x3f\x2a\x8f\xbd\
\xe7\xe7\x60\x14\x75\xf8\x42\x01\xb8\x46\xbd\x87\x9e\x52\x07\xfd\
\xc5\x0a\xe6\x27\xea\x86\x54\x00\x30\x18\x7e\xb1\x07\x5a\xa1\xe0\
\x28\xbf\xe5\xac\x31\x70\x5e\xe7\xbc\xbf\x83\x04\x7e\xf2\xf9\x19\
\x28\xd8\x63\xe0\x49\x41\x1c\x30\x1b\xce\x0c\x88\x2b\x05\xc3\x91\
\x08\xce\x39\xef\x7c\x84\x42\x11\x3c\xf9\xf4\xd3\xd2\xd0\xc3\x4e\
\x81\x10\x08\xa4\x2d\x59\xdc\xc3\x20\xc0\x4b\x89\x9b\x9a\x13\xf8\
\xd3\x93\x61\x84\x83\x06\x3c\xde\x4e\x5c\xfb\xb5\x06\x52\xf6\x38\
\x7e\x7e\xdb\x26\xd4\x37\x34\xc0\xdf\x6f\x15\x21\x77\x16\x4a\x76\
\x3b\xfd\x04\x50\x8f\x13\x0f\x6f\x23\xd4\x89\xc0\x6d\xd1\x7b\x19\
\x2d\x3c\xf4\x77\x82\x63\x61\xb8\x0c\xb8\xf0\x1e\xa9\xfe\x02\x76\
\xbe\xd4\x0d\xb9\x15\x51\x0e\xd2\x8e\xbc\xb8\x64\xfd\xb9\x72\x90\
\x17\xfc\x31\xb5\x17\x85\xe6\xa8\xb8\x53\xf8\x23\xff\x31\x48\xd0\
\x3e\x01\x02\x0a\x6e\x00\xc2\x01\x40\xff\x08\x29\x67\x65\xd0\xe3\
\x66\xa6\xa7\x9d\x7e\x06\x4e\x38\xfe\x78\x89\x0b\x78\x7d\x5e\x02\
\x86\xb0\xb8\x09\x1e\x29\xb0\xb2\x88\xfa\xfb\xd0\x58\x1f\xc1\xaa\
\x16\x1d\xb7\x3d\x1d\xc5\x6b\xaf\x5b\x68\x59\xd9\x8e\x6f\x5e\x59\
\x8b\x6f\x7f\x3e\x87\xf6\xd6\x16\xe4\x8a\x76\x07\xa6\xf2\x6d\xeb\
\xf3\x6a\xc8\x24\xda\xf0\xa3\x9b\x3c\x78\xf2\x85\x18\xb4\xb0\x0f\
\xa6\x1e\xb2\xfb\x36\xf2\x10\x96\x5c\x12\x56\x31\x4e\x00\xd0\xe6\
\xac\xea\x54\xa2\x00\x60\x27\xfa\xfe\xac\xc8\xbc\x86\x9f\xab\xfa\
\x0a\xa5\x42\x6f\xb4\xdf\x28\x2b\xbe\xf8\xfe\x90\x6c\x40\xc0\xeb\
\x11\x57\xa1\xbc\xb4\x78\x24\xd5\xb3\xcb\x34\x24\xd2\xdc\xcf\x9c\
\x74\x32\x4e\x5d\xfc\x59\xb8\xa4\xfd\xb9\x4b\x8a\x85\x78\x21\x8f\
\xc7\xeb\xb6\x3b\xfd\xd0\x79\xd7\xd5\x84\xf1\xca\xfb\x3a\x1e\xf8\
\x57\x14\xcb\xdf\xca\xa3\x7b\x55\x07\x2e\xbd\xbc\x11\xdf\xbc\x20\
\x8b\x96\x96\x16\xba\x3e\xba\x53\x5c\x65\x07\x14\xe8\xb2\x21\x19\
\xef\xc2\xed\x7f\xf3\x20\xd9\x03\xb8\x82\x21\xba\xa3\x3d\x36\xdd\
\x37\x73\xb6\xd5\xb7\x4a\x83\xea\xff\x2b\x17\x60\x17\x53\x7c\x8e\
\xfc\x33\x7d\xb7\x87\x87\xe4\x25\xaf\xcf\xae\x80\x51\x5e\x3b\xd0\
\x2f\xf8\xc7\xd6\x9f\x53\x81\x21\xbf\x5f\x16\x02\x59\xf4\x7e\xae\
\xfe\xe3\xfa\x81\x91\x94\xbb\x2e\x57\x47\x1e\xb9\xf0\x28\x44\xc8\
\xf2\xdf\x7e\xd7\xed\x88\x27\x92\x02\x02\x7c\xcd\x78\x51\x0f\xa7\
\xea\x42\x4e\xb3\x95\x47\x97\x66\x50\x17\xab\x40\x38\x1a\xc7\xac\
\x48\x10\x5f\xb8\x62\x0c\xf2\xf9\x0d\xf8\xe1\x1f\x5b\x31\x7a\x34\
\xb9\x03\x5e\x53\x2a\x27\xb9\xd0\xca\xed\x26\xb6\xd0\x6e\x20\xd1\
\x55\x42\x64\x1c\x01\xa7\xdb\xcf\x5d\x4c\x6d\x47\x4b\x35\x0d\x55\
\x00\xb0\xd3\x2e\xa4\xdb\x2d\x56\x5c\x9a\x56\x10\x05\xe5\x9b\x5e\
\x5a\x89\x1b\x4e\x3e\xbb\x1c\xfc\x73\xd6\xfb\x8b\xff\x4f\xaf\x71\
\x96\x80\x97\x00\xe7\xc9\x45\x60\x57\x20\x48\x66\x8d\xcb\x88\x47\
\x9a\xcd\x92\xb5\x12\xc4\x06\xf6\x3b\xe0\x00\xd4\xd4\xd6\xe0\xe6\
\x3f\xdf\x82\x75\x1b\x36\x48\x93\x15\x29\xd6\x49\x26\xa5\xa4\x37\
\x1a\x0d\x09\x68\xfe\xf5\x45\xa0\xb1\x2a\x84\x58\x45\x2b\xa6\x44\
\x42\xf8\x8f\xaf\x8d\xa5\x6b\xba\x8e\x40\x00\x18\x35\xba\x9e\x40\
\x53\x93\xe1\x2c\xa9\x9c\x1b\x7b\x8c\x6d\x43\x6d\x84\x2c\x7d\x89\
\x94\xdf\xe5\x73\x7a\xac\x8b\x0f\x46\xa0\x1a\xa6\xbf\xad\x43\x53\
\xb7\xa8\x72\x01\x76\x84\xb0\xd2\xfb\x1c\xca\x9e\xce\x66\x44\xf9\
\x79\x0d\x8a\x51\x32\x7a\x03\x7f\xe5\xb5\x04\x96\x13\xf4\x93\xd2\
\x5f\xc3\x92\x32\xe1\x28\x47\xab\x39\x55\x48\x37\xb3\xdf\xe3\x91\
\x55\x80\x23\x55\xf8\x1a\x30\x33\x9a\x3a\x6d\x3a\x2e\xff\xc2\xe5\
\xd8\x6b\xee\x5c\x7b\x46\x62\x30\x28\xbd\xff\xb9\x99\x88\xae\xb9\
\x50\x5d\x19\x41\x57\x46\xc7\x5d\xcf\x45\xf0\xf6\x72\x17\xba\xd6\
\xb5\x00\x45\x17\xbe\xf6\xf5\xb1\xf8\xc6\xe7\x92\x68\xd9\xb4\x01\
\x6b\x9a\x92\x68\xea\xc8\xe1\x90\x59\xcd\xb8\xec\xb3\x49\xf8\xc2\
\x01\xbb\x65\x9a\xb4\x66\x73\x89\xf2\x9b\x7a\x94\x9c\x80\x31\x2a\
\x06\xa0\x18\xc0\x0e\x40\x4e\x5d\x17\xab\xcf\xb7\x16\x17\xef\x94\
\x9c\x59\x80\x6c\x7d\x64\x5e\x20\x37\xc7\x70\xd2\x7d\x26\xec\x62\
\x1f\x48\x21\x90\xad\xf8\xbc\x3f\x2b\x7f\x65\x24\x22\x43\x40\xb8\
\x38\x48\xa6\x02\x71\xf4\x7f\x24\x5f\x38\x06\x01\x3a\xdf\xda\xba\
\x3a\x5c\x74\xe1\xc5\xf8\xfb\xdf\x1f\xc2\xa3\x8f\x3f\x2e\x2c\xa9\
\x82\xce\x9d\x17\xf5\x68\x39\x0b\x35\x55\x61\x2c\x6f\x4a\xe3\xfe\
\x17\xab\x30\x61\x6c\x07\xa2\x75\x71\x78\x2a\x2a\xf1\xb5\xaf\x8c\
\xc1\x9c\xdd\x5a\xf1\xd4\x8b\x6d\x68\xa8\x71\xe3\xb4\x63\xbc\xa8\
\x9b\x54\x05\x23\x5f\x2e\xb8\xd2\x6c\x10\x70\x07\x61\xba\xa6\xd1\
\x77\x30\x01\x2a\x05\x38\xcc\x00\x60\x28\x17\x02\x95\xfd\x7c\x0e\
\x6c\x31\x55\x95\x06\x15\xb0\xab\xfc\x4a\x4c\x73\x79\x44\xb8\xc9\
\xa5\xbe\xe8\x5d\x4c\x24\xfe\x3e\x8f\x13\xe3\x49\x39\x9c\x0d\x20\
\x2c\x88\x92\xbf\x5b\x5f\x5d\x49\xd4\xdf\x44\x86\x7b\x07\x38\xa3\
\xbe\x76\x95\xba\x75\x06\x01\xb6\xf8\x27\x9e\x74\x32\x1a\x1b\x1b\
\x71\xef\x5f\x97\xa0\xad\xad\x1d\xb1\xca\x2a\x99\x82\xcc\x53\x87\
\xa3\xe1\x02\x9e\x79\xc7\x8d\x7d\xa6\x07\x30\x6e\x72\x17\xaa\x43\
\x51\xba\x3e\x6e\x1c\x79\xfc\x28\x1c\x79\x6c\x11\x72\x91\x0d\x2f\
\xcc\x7c\xb9\xa8\x42\xb3\x95\xdd\x45\xae\x80\xaf\x01\x39\xed\x50\
\x62\x5b\x9c\x7a\x2c\x0c\xfa\xfd\xac\x00\x60\xc4\x50\x7e\xb7\xa4\
\xf1\x32\xd9\xb4\x34\x0e\x61\xcb\xcd\x55\x7e\x96\x65\xd8\xf9\x7d\
\xd3\xb6\xf8\x56\x39\xf8\xe5\x3c\x9a\x76\x05\x90\x04\xf8\x2a\x2b\
\xa2\xb4\x85\x91\x2d\x96\x10\x4f\xa7\xc5\x65\xe5\x91\x62\xfa\x2e\
\xe6\xa8\xf2\x62\x21\x06\xd4\xfd\xf6\x3f\x40\x56\xee\xdd\x76\xc7\
\x1d\x78\xfb\x9d\xb7\x11\x8b\x55\xa0\xa7\x47\x17\x17\x6a\x63\x53\
\x02\x4f\x2c\x0d\xe3\xd0\x05\x9d\xa8\x1e\x95\x80\xe5\x8a\xc0\x4c\
\xf1\x6a\x4d\x4f\xef\xaa\xca\x7e\xaa\x46\x17\xbb\x04\x2d\x50\x8d\
\xbc\xf7\x50\x14\xcd\x59\xe0\x29\xc7\x4a\x14\x00\x7c\x3c\x04\x87\
\xdd\xdd\xdf\x1e\xdd\x55\x20\xe5\xcf\x49\x97\x60\x1e\xdd\x95\xcc\
\x64\xe9\x46\xb6\x9b\x88\x5a\x4e\x9a\xaf\x7f\x80\x45\x46\x82\x13\
\x5b\xe0\xa6\x22\xe1\x60\x80\xac\x5a\x50\xd8\x43\x3c\x95\x41\x32\
\x9b\x95\xd7\xf9\x35\x29\x05\xde\x8a\xa5\xd0\x36\xff\xc1\xea\xfb\
\xd9\xb2\xfa\x5e\xfa\x28\x36\x46\xdb\xca\x70\xd1\x8f\x62\xad\xb4\
\x6d\xfe\xb2\xf9\x13\xd6\x16\x0f\x96\xe3\x12\x70\x6b\xef\x2f\x5c\
\xf6\x05\x3c\xf2\xc8\xc3\x78\xe4\xd1\x87\x1d\x70\x00\x12\x89\x1c\
\x96\xaf\xcb\x63\x7d\xab\x17\xd3\xb3\x3d\xd0\x3c\x74\xad\x5d\x21\
\xda\x7c\xe8\xdf\x66\xcd\x0e\xbc\x64\xe9\x8e\x0e\xa0\x10\x3c\x12\
\x19\xeb\x64\x09\xfe\x01\xa5\xad\x9e\xa7\x12\x05\x00\xdb\xa4\x6b\
\xe5\x7e\x00\x72\x7b\xc9\xba\x7e\xad\x57\x61\xb8\xfd\x77\x67\xa2\
\x07\x9b\x3a\xc9\x22\x45\xa3\x32\xae\xcb\xe3\xb8\x04\xe5\xae\x3e\
\xe5\x15\x80\xd2\x16\x4b\x62\x05\x2e\xa7\x01\x88\x89\x1e\xa2\xfb\
\x99\x7c\x4e\xd8\x82\xd7\xeb\x41\x24\x10\x40\x88\x1b\x7f\xf4\x57\
\x3e\xa7\x76\xdd\x9e\xae\xdb\x57\x33\xbc\x5d\xe5\xec\x37\x8a\x7c\
\x80\x2b\xb5\x99\x1a\x32\x1b\x29\x2f\x91\x2d\xa7\xe7\x7a\xcf\x4d\
\xd3\x06\x9e\x6b\x3f\xc5\x91\xa0\xba\xa6\x95\xa1\x70\x80\x22\x7f\
\x38\xf8\xb1\x27\x29\x69\xf6\x3f\xfd\x86\xa9\x68\xa8\xae\x0e\xe0\
\xdc\x73\xcf\xc3\xdc\xb9\x73\x71\xcb\x2d\x37\xe3\xad\xb7\xde\x26\
\x90\xd5\xd0\xde\x6d\x20\x57\x30\x05\x51\xad\x42\x86\xfe\x61\x45\
\x67\x06\xe0\x11\x7f\x5f\xde\xed\xa2\xcf\x0a\xc4\x50\x8a\x1c\x8b\
\xa2\x7e\x29\xdc\x16\x8f\x5d\xcb\xd1\xbe\x9e\x3e\x37\xac\xdf\xf9\
\x96\xbf\x67\x05\x00\x4a\x06\x58\x44\x1e\xc9\x25\xdd\x7a\x45\x49\
\x30\xe0\x86\x31\x9d\x7d\xc6\x8d\x1e\x03\xa3\xa9\x19\xeb\x5a\x5b\
\x65\xb2\x4f\x2c\x1a\x91\x15\x7c\x9c\x0d\x90\xd9\x7d\xa6\x1d\x8d\
\x36\x9d\xa8\xb7\x45\x16\x8e\xdf\xcb\xb1\x01\x8e\x72\x73\xe6\x20\
\x93\x4a\xc1\xa0\x9f\x35\x4e\x65\xa5\xd2\x92\xd3\xe6\xc2\x21\x29\
\x74\x91\x7d\xec\x5e\x79\x0c\x38\xbc\xb2\xcd\xfe\x59\x2f\xab\x90\
\x7d\xd3\x6b\x5a\xef\x2c\x32\x4d\xeb\xaf\x5c\xfd\x3a\x10\xe8\x7d\
\xe3\xcb\x74\x47\xf1\x75\xe7\xdc\xca\xca\x6b\x39\xfe\xb3\xad\xf4\
\x7d\xec\x82\x7f\x36\xcb\xc0\xd3\x0b\x4a\x5a\x6f\xab\x2d\xd3\x01\
\x28\xcb\x29\x67\xee\xbf\xe6\xa6\x0f\xcc\xb8\x57\x40\x1f\x68\xc8\
\x75\x2c\x99\x42\xef\x0d\x27\x55\x6a\x96\x47\xae\xcb\x88\x75\x13\
\x75\x8d\x63\xf0\xb9\x0b\x2f\xc1\x03\x7f\x5d\x82\x67\x9f\x7b\x11\
\xd3\x8c\x6e\xcc\x9c\xbd\x1e\x18\x5b\x0b\x3d\x41\x00\x50\x48\xdb\
\x39\x7e\x3e\x56\xbf\x97\x90\x34\x82\x92\x36\x0e\x79\xd7\x89\x30\
\xdd\x27\xd2\xf3\x01\xb8\x35\x2e\x00\xf2\xf7\x82\x96\xa6\x59\x7d\
\x6c\xc9\x61\x72\x79\xd5\x41\x58\x01\xc0\xe6\xc2\xca\xcf\x0a\x6a\
\x6a\x8e\x3f\x4f\x37\x27\x5b\x6e\xa3\x3c\x0a\x9c\x1e\xdb\x3b\x3a\
\xb1\x61\xdd\x7a\xbc\xff\xfe\x6a\x99\xde\x93\xa7\x9b\x38\x5c\x11\
\x41\x5d\x6d\x8d\xf4\xa9\xe3\xd5\x7c\x1c\xe0\x72\x91\x22\x97\x41\
\x80\x17\xc8\x24\xba\xe3\x58\xb7\xbe\x09\x2d\x04\x1e\x19\xf2\xfd\
\x99\x39\xb0\x2b\xc1\x55\x70\x21\x62\x12\xa1\x50\x00\xe1\x50\x48\
\xfa\xea\x45\x22\x11\x49\x8d\x55\xd0\xc6\x9f\x1d\xa5\xdf\xb9\xed\
\x38\x1f\x9f\xe5\xe8\x35\x83\x46\x19\x04\x5c\x7c\x93\xeb\x8e\xe2\
\xdb\xda\x2e\x37\xbb\x6e\x69\xc2\x42\x4c\x47\x39\xcb\x29\x72\x89\
\x3b\xf4\x1b\xa6\xd1\x07\x76\x8e\x42\x6b\x70\xea\x15\x9c\xe7\xcd\
\x72\x40\xb3\xbf\x15\x45\xef\x8a\xc5\xde\x05\x4e\x1a\x7a\x47\x9e\
\x5b\x4e\xc6\xa3\x6c\x81\xf9\x78\x58\xe9\xba\xe2\x71\x74\x75\x76\
\xa1\xbb\xbb\x1b\xf1\x78\x52\x22\xff\x89\x9e\xa4\x34\xf8\xe4\x5e\
\x02\x9c\x4e\xe5\xe9\xdf\x7c\x3e\xde\x68\x2d\x8a\xf9\x00\xbe\x77\
\x97\x1b\x07\xb4\xb8\x31\x75\x4a\x04\xb5\x81\x12\xbc\xba\x89\x78\
\x8e\xd8\x41\x8f\x1b\xeb\xd6\x54\xa2\xbd\x6b\x06\xea\x1b\x62\x98\
\x3c\xe9\x5d\x4c\x9c\xd8\x20\xd7\x8f\x81\x93\xcf\x5d\x26\x3d\xbb\
\xec\xc7\xf2\x75\xe3\xe3\xca\xe5\x72\xbb\x3c\x0b\x50\x00\xb0\x19\
\x65\x4e\x26\x93\x4e\x47\x5b\x97\xdc\x28\xba\x33\x05\x58\xb7\xff\
\x11\xcf\xbe\xa1\xae\x1a\x41\xbf\x07\xb5\xd5\x95\x98\x30\x61\x1c\
\xda\xba\xba\xd0\x95\x48\xc2\x20\xcb\x56\xc8\x15\xe1\x61\x6a\x4a\
\x9a\xc0\xe0\xc1\xf1\x02\xbe\xe1\xe3\xdd\x49\x99\x75\xc7\x41\xc0\
\xa9\x53\x26\x21\x1c\xe4\xd6\xe3\x3e\x29\x02\xe2\x61\xa1\x41\xfa\
\xd9\x4f\xc0\xc1\xbf\x07\x82\x7e\x29\x09\xe6\x05\x42\xcc\x2a\xb8\
\x7e\x9e\x47\x8a\x73\xa1\x10\x33\x82\x5e\xf7\xa4\x9f\xc5\xd6\x9c\
\x51\xe5\xbd\x2d\xc7\xe0\x0c\x32\x75\x14\x5a\x46\x90\x5b\xf6\x7e\
\x56\xef\x38\x72\xb3\xb7\x46\x41\xce\x55\x3e\xbb\xfc\x68\x7f\x96\
\xe6\xac\x4a\x14\xb7\x81\x3f\x53\x66\x9e\xeb\xbd\x85\x4d\xae\xde\
\xa0\x84\xd9\xeb\xb2\x94\x99\x80\x0d\x0e\xae\x3e\x46\x60\x41\xba\
\x27\x7b\x3c\x5e\x54\x56\x54\x90\x02\x36\x22\x9b\xcd\x22\x9b\xc9\
\x92\xe2\x67\xec\x81\x1f\xf4\x7b\x3a\x43\x8f\x99\x3c\xd1\xfe\x9c\
\xdd\x32\x9d\x00\x38\x95\xd5\xb1\x62\x8d\x85\xae\x94\x17\x13\x46\
\x05\x10\xab\xf0\x21\x91\x02\x36\x6e\x2a\x22\x12\xaa\xc2\x5e\x13\
\xab\x30\xa6\x31\x86\x1a\xfa\x4e\x82\xe1\x90\x64\x54\x7a\xbb\x01\
\x59\xf4\x19\x85\x92\x03\x52\x36\xeb\xb0\x9c\x1e\x0c\x8a\x01\x0c\
\x61\x65\x1c\xac\xf4\x09\x07\xa0\x4a\x32\x17\x10\x03\x7d\xe2\xb2\
\xab\x40\x0a\xc0\xe3\xba\x78\x68\xc7\x6e\xd3\x26\xf7\xbe\x56\x6e\
\xee\x61\x4a\xf5\x9f\x35\xc0\xbf\xd6\x9d\x1b\x52\x77\xba\x04\x6d\
\x1e\x26\xb3\x36\x0b\xc2\xf5\x4f\x85\x4a\x6c\x81\x2d\x2f\xdf\xb8\
\x9b\x45\x06\xcb\xc1\xc9\xad\x06\xf3\x9c\x0f\xb6\x36\x8b\x21\x58\
\xdb\x89\x29\xf4\x3f\xdf\xad\x3d\x6e\x3d\x78\xe8\x50\x6c\x6b\xfb\
\xd1\x80\x32\x54\xf8\xc9\xaf\x0f\x78\x49\x89\xa3\xa1\x01\xe3\xd5\
\xad\x7e\xd7\x42\xdb\xec\x98\x74\x69\xa1\xae\x09\x33\x30\x4c\x9b\
\xca\xb8\x5c\xf6\xf3\xba\x66\xe7\x5d\xf8\xba\xf3\xa2\xab\x12\xd7\
\x65\x38\x2e\x49\x7f\xb6\x52\x3e\xba\x9d\xad\xf8\x2a\x0d\x38\x4c\
\xe3\x01\xd8\x46\x40\x8d\xef\x42\x06\x89\xcd\x5b\x4d\x7d\xe8\x1b\
\xcb\xb2\x76\x58\xd1\x4f\xaf\x22\x6d\xe7\x98\xb6\xf7\xda\x07\x01\
\x8b\x8f\x9a\x2d\xb0\xb6\x1b\xc7\xfc\xa0\xd7\xd0\x92\x89\x43\xfd\
\x5d\x98\xed\x9d\xd3\x87\xfb\x6c\xc5\x00\x94\x7c\x04\x90\xf8\x08\
\x1f\xb0\x43\x6f\x49\x6d\x28\x9d\xeb\x27\x7e\x5c\xda\x56\x14\x5c\
\xc9\x87\x15\xb5\x16\x40\x89\x12\x05\x00\x4a\x94\x28\x51\x00\xa0\
\x44\x89\x12\x15\x03\x18\x6c\x19\x29\x5d\x81\x95\x28\xe9\x7f\x3f\
\x2b\x00\xf8\x40\x07\x64\xd0\x56\x32\x7c\x2e\xa0\xe4\x52\x37\x8f\
\x92\xe1\x2f\x7c\x2f\x5b\xc5\x2c\xaf\x49\xe6\xd2\xc3\x0c\x3f\x7a\
\xb4\xa1\xd1\xad\x48\x1b\x0c\x64\xba\x79\x69\xfe\x27\xef\x76\x96\
\xe6\x79\x5d\x5b\x5e\x85\xce\xce\x4e\x5e\x5c\x33\xaf\xb6\xa6\x26\
\x26\x0d\x1e\x94\x28\x19\xe6\xc2\x65\xdd\x6f\xbc\xb1\xb4\x2b\x91\
\x48\x74\x40\xd3\xe2\xa4\x76\x99\xb9\x73\xe7\x9a\xb1\x58\x0c\x05\
\xc3\xd2\x2f\x9a\x17\xb8\x62\x7c\x4c\x5f\xba\xcb\x30\x80\x77\x3b\
\x8c\xfd\x5f\x69\x2e\xee\xcb\xad\x9e\xb7\x38\x20\x77\x95\xe4\x74\
\x9a\x5a\x4b\x2a\x44\xa1\x64\xc4\x88\x7f\xd2\xbe\x55\x21\x5d\xaf\
\x2a\xff\xbe\x2e\x9b\xc5\xea\xe6\x22\x72\x25\x0b\xa7\xed\xe1\xaf\
\xde\xa5\x5c\x00\x8f\x0b\x59\x2f\x29\xbf\xd7\xbd\xb5\xe4\xad\x21\
\x95\x22\xba\xa2\xff\x4a\x46\x90\x18\x85\xec\x80\xbe\x44\xdc\x1d\
\xd9\xc5\xb3\x0e\x20\xcb\x36\x8c\x5d\x0a\x00\x4c\xa7\x2e\xdd\x1c\
\xc1\x31\xbe\xd2\x66\xe7\x66\xf7\x05\xc0\x76\x6b\x65\xf9\x66\xd8\
\xfc\x9a\xb8\x34\x55\xbf\x36\x92\xa5\xbc\xa2\x72\x97\x02\x80\xf2\
\xe2\x32\x73\x84\x46\xf9\xb9\x2a\xad\xca\xcb\x2b\xf4\xcc\x5e\xed\
\x2f\x9a\x1a\x12\x45\x7d\x9b\x0d\x2a\xf9\xd9\x00\xb1\x9e\x90\xdb\
\x1a\xd0\xe9\xa3\x87\xde\x53\x30\x87\x17\x08\xf0\xd1\x97\xe8\x98\
\xbd\x2e\x35\x9a\xfb\xdf\xdc\x29\xbd\x1d\xa3\x77\x2d\x06\xe0\x2c\
\x1a\x19\x89\xad\x1a\xf9\xdc\x42\xba\x85\x2b\xe6\xbb\x31\x3a\xca\
\xf9\x0c\x0b\x3e\xf2\x79\x5e\x79\xbf\x13\xd7\xfd\x33\x85\xaa\xfa\
\x31\xd2\x3e\x6c\x73\xc9\x97\x80\x83\x46\x03\x9f\x9b\xed\xa1\x9f\
\xed\x3b\xc2\x47\x14\xf1\xaa\x25\xab\xf0\x3e\x46\xc9\xb8\xf0\xa1\
\xac\x4c\xe5\xb5\x07\x05\x3a\x35\x0f\x31\x9d\x09\x51\xf2\x73\x7b\
\x8c\xde\x1e\x06\x4a\xb6\x76\xcd\x9c\xe5\xd6\xd8\xd5\x00\xc0\xa1\
\xc8\xee\x11\x68\x1c\xca\xcd\x40\x2b\xfc\x1a\xaa\xc3\x6e\x14\xe9\
\x09\x0f\x37\x0a\x29\xf5\x20\xd9\xb6\x09\x95\x8d\xe3\x60\x96\x8c\
\xad\xbe\xcf\x4b\xc0\x11\x0b\xf3\x30\x51\x27\x56\x42\x9a\x94\x69\
\x5d\x83\x42\x55\xad\x34\x2a\x19\xca\x00\xc0\x16\x9f\x95\x7f\x7a\
\x25\x70\xce\x6c\x02\xab\x64\x1b\xfe\xe3\xa1\x2e\xd4\x4e\x98\x02\
\xcb\x50\x5d\x79\xb7\x77\xbf\xec\x7a\x00\xe0\xb8\x00\x23\x31\xcb\
\x27\x8d\x6a\xa5\xfd\x97\xd5\xbb\x79\xb8\x57\xa0\x69\xc9\xf9\x1a\
\xdb\x18\x58\x23\xaf\x71\xfc\x53\xde\xe3\x00\x80\x6e\xf5\xee\xcf\
\x8f\x43\x55\xff\xf9\x9c\xab\x7c\xc0\x09\x93\x75\x1c\x37\xd5\x85\
\x68\xd8\x8b\xa7\x5f\xea\x41\x3a\xde\x81\x6a\x6b\x1a\x1d\xbf\x02\
\x80\x6d\xd1\x26\xd3\x1a\xdc\xef\xd5\x3d\x68\x4a\xe2\x6c\x23\x12\
\x00\xfa\x35\xeb\xec\xef\x17\x9b\xbd\x0c\x61\x1b\xcc\x61\x1b\xfe\
\x74\xf9\x33\x87\x2a\x00\x64\x8b\xc0\x19\x73\x34\x7c\x7a\x86\x1b\
\xf9\x02\x9c\x65\xce\x9a\xb4\x02\x33\x46\x78\xb0\xf7\xe3\xba\x4d\
\x83\xad\x03\x83\xc6\x00\xd8\x22\x96\x46\xe0\x1a\xce\x32\x03\xe8\
\xdf\x2a\x0b\x4e\x1b\x2d\x3e\xef\x92\xd9\xd7\xce\x6e\x73\x06\xd0\
\xbf\xb5\x96\x28\x7f\x79\x9c\xb8\xb5\x6d\x4b\xa1\x6d\x06\x12\x65\
\xe1\x8e\x38\x6e\xfd\xc3\xdd\x5d\x72\x6c\xfd\x28\xa9\xb4\x14\xe3\
\x19\x1b\xe5\xc6\x22\xdb\x78\x1f\x3f\xef\x71\x71\xaf\x3f\x9b\xb1\
\xf4\x3f\xdf\xed\x31\x3d\xd3\xf9\x9b\x76\xe3\x0e\x38\x7d\x0b\x77\
\x9d\xcc\x07\x9f\xaf\x0c\x8a\xd9\x35\x01\x80\xb6\x11\x12\x1f\xd2\
\xb6\xe2\xde\x58\x03\x7a\xe5\x59\x03\x15\xc2\xda\x92\x1d\x94\xca\
\x96\x72\x33\x00\x60\xb0\x28\x3a\x5b\x7f\x00\xd0\x9c\xbf\x95\x33\
\xec\x9f\xeb\xfd\x16\x62\x7e\xa9\xb1\x90\xb8\x43\x3c\x6b\xa1\x25\
\x6b\xb7\xef\xe2\x82\xab\xed\x65\x1f\x72\x25\xfb\x33\x6a\xe9\x33\
\x2a\x7d\x96\x44\xef\x21\xcf\x5b\x48\xe4\x2c\xb4\xe7\xe8\xdd\xda\
\x96\x9f\xc3\x7b\xf1\xdf\x4f\x17\xe0\x04\x2e\xfb\x8e\x9d\xab\x38\
\x93\x79\x03\x3d\xf4\x9a\x46\x88\xc8\x01\x4d\x69\xc3\xd5\x2f\x5e\
\x10\xf2\x00\x0d\x01\x4b\x1e\x59\xf1\xb9\xa5\x7a\x3a\x6f\xa1\x23\
\x07\xa4\x0c\x97\xd4\x89\xb0\x1b\xd4\xff\xd0\x47\x12\x99\xd0\xac\
\xc1\x77\xed\x06\x07\x00\xd8\xfa\xd3\xe6\x1a\xca\x31\x00\xeb\x83\
\x69\xbd\xb6\x19\x08\x88\x92\x6b\xd6\x56\x3f\x44\x5e\x33\x9d\xd9\
\x80\x56\x9f\xe5\xb3\x1c\x1a\x5d\xdc\x0a\x1f\xe4\xe7\x92\x39\x13\
\xa6\xc7\xb4\xdb\x5a\x3b\xcf\xe7\x0d\xfb\xe3\x0f\x1f\xab\xe1\xf8\
\x29\x3a\xa6\x57\xeb\x88\x7a\xfb\x00\xa0\x87\x14\x77\x45\x47\x09\
\x7f\x5b\x91\xc3\x63\x4d\x3a\x34\xb7\x4f\x82\x8c\xbd\x9d\xb1\x1c\
\xff\x93\xbf\x87\x43\x46\x69\x38\x79\x37\x1d\xbb\x55\x93\xff\xee\
\xed\x0f\x00\xa4\xc4\xa4\xc0\xef\x77\x19\xb8\x6f\x79\x16\x4f\x36\
\xeb\xd0\x3d\x5e\x62\x04\x76\x83\x4f\x4e\x4f\xfe\xbf\x05\x6e\xcc\
\xa8\xd1\x30\x2a\x64\x49\x26\x43\x5c\x82\x7c\x11\x7b\x4c\x1e\x85\
\x5b\xce\xaf\x45\xa4\x42\xc3\x5b\x1b\xb2\xf8\xc9\xbf\xb2\x88\xc4\
\xaa\xe4\x33\xeb\x09\xa8\x4e\x98\x06\xec\x3f\xd6\x85\xda\x80\x0d\
\x04\xd2\x81\x98\x8e\x25\x5d\xb0\xd0\x49\x00\xf0\xd2\xc6\x02\xee\
\x5f\x65\x60\x53\xde\x87\x00\xa7\x15\xfa\x75\x4f\xb2\x3e\xe4\x77\
\x34\x94\x0d\x47\x69\x57\x64\x00\x76\x40\xcc\x0e\x90\x0d\x49\x6b\
\xae\x6d\xfe\xdc\xd6\x07\x68\x94\xad\x30\xfa\x29\x32\x9f\x92\xa7\
\xdc\x41\xb8\xdc\x8f\xcf\xb2\x27\x01\x77\xa7\x0d\x78\x32\x26\x8c\
\xa2\xd9\xdb\x3c\xd3\x79\x19\x19\x02\x80\x8c\x33\xe2\xaa\x7f\xcb\
\xee\x7c\x89\xbb\xdf\x1a\x28\x79\x0c\x87\x5a\x93\x82\xd1\x8f\xa3\
\x49\x71\xbe\x75\x80\x1b\xc7\x4c\x75\x83\xc7\x0e\x14\xcd\x3e\x37\
\xc1\x43\x96\x33\xec\xd7\x30\xbe\xca\x8d\x23\x26\x7b\x71\xd7\x1b\
\x71\x5c\xf7\x5c\x06\x9d\x7a\xc4\x5e\x98\xe2\xfc\x5d\x0e\x36\x5e\
\x31\xcf\x85\x2b\x48\x89\xf9\x3d\x45\x01\x64\x97\x93\xba\x23\x20\
\xa0\xf3\xa8\x08\x02\x13\xe9\x73\x0e\x9b\xe4\xc1\xef\x9e\xef\xc0\
\x75\x2f\x66\xe0\x0e\x45\xa1\xd3\xb1\x64\x49\xe1\xa7\x55\xba\xb0\
\x0f\x81\x50\x36\x67\xcf\x3d\xb4\xad\x3f\xb1\x91\x48\x10\x07\x55\
\x6a\xd0\xbd\x3a\x52\xcd\x6d\x68\x59\xdb\x82\xec\xf4\x05\x98\x1a\
\x36\x71\xe3\x21\x6e\xcc\xac\xd7\xe5\xef\x19\x96\xdd\xf6\xdc\x6e\
\xc3\x6e\xc2\x4f\x00\x54\x17\x05\x66\x37\xb8\x71\xf8\xb8\x0c\xbe\
\xf1\x68\x07\x96\x67\x2a\x11\xf4\xba\x7a\xd9\x87\xbe\x9d\xf6\x5e\
\xd6\xe6\x74\xc1\x1a\xba\xac\x81\xcf\xa3\x64\x0e\x6e\xcf\xc0\x41\
\x72\x01\x6c\x85\x30\x77\x72\x0c\xa0\x7f\xf3\x4d\xed\xdf\x18\x7e\
\x6b\x3b\x74\xc0\x42\xd9\xc7\xef\xa3\xfc\xe5\xc2\x26\xbe\xa9\x35\
\x97\x29\x33\xec\xfa\x53\x7f\x9f\xd7\x8d\xba\xa0\x8e\x0a\x14\x60\
\xe9\x25\x99\x7d\x57\xee\x51\x2f\xd6\x96\xb6\xb0\x4b\xef\x6b\xc3\
\xed\x3c\xb2\x52\xf1\xe4\xe0\x82\xdc\x29\xa6\x7c\x7e\xad\x0f\xf8\
\xf9\x11\x5e\xec\x37\xde\x8d\x14\x59\x4c\x66\x03\xfc\xf9\x3e\xa7\
\x83\xaf\xcd\x10\x4c\xb2\xa6\x76\xe7\xdb\x33\xf6\xa9\xc2\xd8\x50\
\x27\x2e\x78\xa0\x0d\x3d\xfe\x5a\x78\xe8\x6f\x33\xe0\x2c\x9e\xaa\
\xe3\xeb\xfb\xbb\x85\xc6\x17\xe9\xf7\xa0\xcf\x83\x54\x2a\x85\x78\
\x22\x25\x5d\x90\x6b\xab\x49\x13\x75\x0f\x7d\x8e\x21\x9d\x82\x2f\
\xf9\x54\x2d\xd6\xb7\xad\xc2\x2f\xde\x05\xa2\xd1\xb0\x1c\x97\xed\
\xb8\xf3\x6d\x64\xf4\xb6\x00\x2f\x2b\xa2\x26\xf5\xdc\x1e\xb9\xda\
\x49\xa2\x38\x51\x42\x9c\xef\xec\xaf\x8b\xf2\x27\xf3\x96\xb4\x45\
\xe7\x38\x45\x7b\x47\x97\xcc\x59\x8c\x86\x03\xa8\x88\x46\x88\x0d\
\x99\xc8\xd1\x79\x8c\xaf\x0b\xe3\x3f\x0f\xca\xe3\x8c\xbb\x37\x22\
\x11\x19\x2b\x0c\x46\xd7\xca\x2d\xd1\xed\x38\xc7\xc7\x31\xfe\xfd\
\x9b\x8f\x0e\x86\x0a\x72\x0b\x75\x63\x90\x8d\xe0\x20\x01\x80\xe9\
\x6c\x83\xc3\xd1\xfa\x1a\x66\x6e\xe5\x4b\xe9\xf5\xd3\xb7\x54\xf0\
\x5e\x3f\xbe\x1c\xb4\xc3\x40\xf4\x96\x81\x13\x9c\xcf\x77\x9b\xce\
\x5c\x40\x1b\x00\x32\xb9\x02\x66\x11\x25\x7e\xe8\xf2\x5a\xa7\x1e\
\xd8\xb3\xe5\x2d\x4a\xfb\x79\x89\xea\x66\x8b\xd6\xc0\x46\x9c\xce\
\xb5\xb2\x9c\x8d\x9b\x15\x7f\xe3\x20\x0f\x29\xbf\x8b\x68\xbe\xad\
\x70\x41\xbf\x17\xcb\xdf\x5b\x8b\x07\x9e\x5f\x89\xf6\x8c\x85\x29\
\xa3\x6b\xf0\x99\x7d\x27\xa3\x86\x14\x38\x5f\x24\x3f\x3c\xa3\xe1\
\x53\x33\xaa\x71\x65\x73\x02\x57\xbe\xd0\x09\xbd\xa2\x0a\x01\x02\
\xa9\xb3\xf7\xf0\xda\x60\x6c\x6a\x12\xb3\xff\xdf\xdb\x9f\xc0\xed\
\x2f\x36\x23\xe5\x8e\x42\xf3\xf8\x30\xb9\xda\x8f\xeb\x4e\x9e\x81\
\xe9\xe3\xab\xed\xef\xca\xe3\xc6\xe5\x07\xd7\xe1\x81\x95\xeb\xd0\
\x5a\x9a\x48\xcc\x43\xc7\x13\xcb\x3b\xb1\x76\x59\x13\xf6\x9c\x3e\
\x06\xe3\x1b\x6b\xa4\x2b\x2f\x4f\x42\x6a\x69\x8f\xe3\x99\xd7\xde\
\x93\x71\x68\x6f\xae\x6e\x85\xe1\x0a\xe1\xa0\xd1\x16\xe6\x8f\x72\
\x91\xf2\x9b\xd2\xe2\x7c\xe5\xea\x8d\xb8\xfe\xd6\x7f\x62\x65\x92\
\x8e\xc3\x1b\x92\xe9\xc8\x67\xec\xd3\x80\x4b\x17\x4e\xe7\x55\x61\
\x04\x29\x1a\x76\x9b\x52\x87\xd3\xa6\x6c\xc2\x0d\xef\x74\x92\x3b\
\x11\xe3\xe5\xab\x72\xe9\x74\x27\x40\xa9\xa3\x0c\x08\x5a\x2f\x38\
\xf4\x07\x08\xbd\x77\x50\xca\x40\x25\x2f\x7f\x6d\x83\xe9\x85\x6a\
\x56\x9f\x21\xd9\xe5\x62\x00\x32\x68\xc3\xf8\x64\x01\xc0\xda\x06\
\x8d\xdf\x3c\xe0\x66\x59\x7d\xca\x3b\xf0\x77\x27\x4f\xef\x0c\xc4\
\x28\x53\xea\xb2\xf2\x97\x53\x71\xdb\xfb\xbe\x4a\x92\x05\x30\x07\
\x06\xae\x78\x28\x28\xdd\xdc\xb5\x95\xee\xed\x46\x7c\xb6\x56\x1e\
\x5d\x1e\xe1\xc5\x1b\xbb\x03\x0b\xea\xc8\xe7\x9f\x46\x96\x3f\x6f\
\x03\x45\x30\xe0\xc5\x43\x4f\xbd\x82\x2f\xfc\xdf\x4b\x68\xab\x9c\
\x01\x6f\xac\x01\xc6\x86\x12\x6e\x5f\xf9\x3e\x7e\x73\xda\x44\x4c\
\x6c\xac\x10\xf6\x90\x22\xa5\x3b\x7d\xbf\x51\xb8\xfb\xad\x65\x78\
\x36\x13\xc2\x8c\x2a\x17\xc6\x45\x2d\xf2\xe3\x35\xb1\xee\xa9\x44\
\x0f\x6e\xfa\x47\x13\xde\x09\xef\x8d\x50\x75\x8d\x54\xf3\xad\xe4\
\xde\xfc\x8f\x24\xf0\xbb\x93\x74\x74\xf7\xa4\xf0\x5e\x53\x37\xd6\
\x37\x77\xc2\x4c\x96\x60\xfa\xc6\x90\xc2\x7a\xf1\x5f\x2f\x15\x10\
\xdf\x94\xc3\x9f\x4e\x2f\x62\xda\x18\xdb\xad\xf0\x11\x00\x2c\x27\
\xca\x7f\xfe\xff\x2d\x43\x70\xe2\x1e\xa4\x88\x15\x08\xd6\x8f\xc6\
\x9c\xca\x92\x0c\xf5\xe4\xe3\xf6\xba\x75\x3c\xbb\x74\x35\xee\x58\
\x13\x85\x7f\xb7\x7d\xe4\x77\xa6\xf8\xdf\x79\xb5\x07\x8d\x35\xed\
\xe2\x72\xac\xd8\xd8\x85\xf5\xad\x71\xbc\xfb\x5e\x3b\xcc\xcc\x04\
\x14\xc2\x15\x3c\xa9\x65\x0b\x30\xd7\x7a\x15\xbf\x4f\xe1\xf5\x32\
\x48\x94\xe7\x3a\x68\x7d\xfb\xf6\xce\x54\xe8\xf7\xfb\x56\xb9\x9e\
\xf5\xef\x19\xe3\xc7\xcd\x02\x88\xab\xb8\xcb\xad\x05\x30\x9d\xde\
\xf9\x3b\xc8\x05\xd8\xd6\xe5\x34\x7b\x95\xdc\xea\x4d\x9b\x95\x03\
\x72\xbd\x8a\xff\x31\x23\xce\xb6\xd1\x36\x37\xcb\x00\xd8\xd6\x4a\
\x28\xb1\xb5\x5d\x64\xb4\x67\xf7\xf5\x53\x7e\xab\x3c\xd3\x8e\xb6\
\x22\x59\xf3\x13\xa7\xf9\x10\xf6\x11\xa5\x2e\xd8\x93\x86\x9b\xc9\
\xbf\xfe\xc6\x9f\x5f\x46\xf7\xf8\x43\x51\x4d\x4a\x66\x39\x0a\xf2\
\x32\x71\xfc\xef\x3f\x4d\x4a\xbd\x38\x28\x43\x32\x39\xde\x12\x09\
\xf8\x71\xd2\x34\x0f\x9e\x78\x96\x14\x2a\x56\x2f\xdf\x01\x7f\x3e\
\x4f\x3e\x0a\x47\xc2\xf8\xdd\x97\x17\x62\x09\xd1\xfb\x17\x5a\x4d\
\x6c\xe8\x21\x65\xf6\xfa\xf1\x5c\xc2\x8b\x85\x37\xad\x41\xaa\x75\
\x3d\x5a\x0b\x3e\x68\xc1\x4a\x02\x88\x7a\xa2\xee\x3c\xf8\xa4\x08\
\x7f\x30\x84\x8a\x09\x33\xe0\x0e\xba\xa4\xe0\xa7\x7c\xcc\xec\x42\
\xf8\x1b\x27\x20\x36\x71\x26\x2c\xda\x2f\x9d\x2f\xc1\x28\x95\x7a\
\x5f\xcf\xe4\x8a\x58\x74\xc4\x3c\x84\x1a\x92\x78\x60\x83\x86\xf7\
\xbb\x4d\xac\x4f\x11\x83\x0a\x54\xe2\xca\x67\x12\xa8\xb8\xef\x2d\
\x34\x75\x67\x91\x26\x36\xe2\xaf\x18\x87\x60\x55\x0d\x2c\x99\xd5\
\xb0\x75\xe7\xcc\xd8\x8e\x0b\x20\x60\x40\xff\xb8\xb4\x81\x3f\xcb\
\xa6\x3b\x63\xd3\x3e\x66\x4c\xf8\xa3\x02\x80\x31\xc8\xa5\x80\x83\
\xb4\x18\xc8\xfa\x68\x2e\x80\x85\x2d\xb8\x5c\x7f\x0c\x29\xff\xdc\
\x97\x7f\xb6\x06\x50\xf8\xb2\xe2\x5b\xe8\xa3\xf7\x7d\x53\x6c\xb6\
\x16\xfc\xfb\x88\x00\x60\x0d\x04\x00\xb6\x36\x3c\x21\xa8\x65\x6d\
\x87\x33\xad\x67\xeb\xd7\x84\x47\x82\x55\x57\xc5\xb6\x18\x0e\xc2\
\x6e\x00\x33\xa6\x08\xb9\x16\xb3\xea\x74\x3b\x5b\xc0\x56\x94\x28\
\xf8\xd3\xaf\xbe\x87\xf7\xb4\xd1\xa8\xae\x6d\x80\x59\xcc\xf5\x7e\
\x5e\xd8\xab\xe1\x1f\x6d\x5e\xac\x68\x2d\x60\xf7\x46\xbf\xa4\xe9\
\xf8\x7d\xb3\xc6\x46\x10\x2b\x6c\xc4\xba\x64\x2d\x56\x77\x15\x31\
\x8a\x58\x49\x81\xdc\x0e\xc2\x13\xcc\x9e\x50\x89\xbd\x26\x5a\x48\
\x10\x78\xac\x8d\x9b\x78\xa7\xad\x88\x97\x9b\x4c\x3c\xdf\x3c\x0a\
\xdd\xae\x46\x62\x31\x7e\x89\xc8\x6b\x66\x3f\x7f\x5f\x26\x72\x93\
\x62\x9b\xbe\x2d\x53\x9f\xa4\xf8\x66\xa9\x20\x8f\x7c\x1a\xaf\x6e\
\xe2\x79\x80\x86\xcc\x17\xe4\xe8\x77\x80\x5c\x97\x33\xf7\xad\xc1\
\x67\xf7\x2a\xa1\xb5\xc7\xc0\xf2\x4e\x03\xef\xb4\x14\xf1\xcc\x46\
\x72\x1b\x5c\x7b\x20\x17\xf3\x20\xe2\xf3\x82\xbb\xe7\x08\xb0\x59\
\x1f\xbc\xa2\xb0\x3f\xb5\x97\xb4\xab\x33\x6a\x4c\x00\xa1\x6c\xf9\
\x9d\x19\x8a\x65\x20\xe8\xef\x42\xf4\x07\x8c\xfe\x41\xde\xfe\x71\
\x9b\x8f\x9d\x75\xe8\x37\x8e\x6d\x17\x73\x01\x9c\x81\x90\xff\x86\
\x01\x58\x5b\xbb\xb6\xda\xc0\xc0\x8d\x65\x6e\x49\xeb\xcb\x05\x2d\
\x7d\x00\xd0\x07\x04\x9b\x07\x7e\xb4\xed\xc0\xfc\x47\x67\x00\xd6\
\x00\x10\x08\xf8\x3c\xf8\xd7\x9b\xab\x70\xd6\x7f\x3f\x83\xc8\xa8\
\x09\x9b\xcd\xb4\x77\x52\x67\x05\x03\x17\x1d\x30\x06\x57\x2f\xae\
\xa4\x9f\xcd\x01\x31\x00\x5e\x3c\x54\x34\x4a\x18\x1d\x34\x51\x17\
\xe0\x88\x7f\x99\x19\x18\x58\xd9\x94\x80\x9b\x68\xbf\x65\x16\x07\
\xd0\x63\xbe\xc9\x3b\x0b\xc0\x2a\xb2\xac\x33\x1b\xed\xfd\x79\xc4\
\x56\x5d\xd4\x8f\x06\x6f\x0e\xef\xe6\x8b\xf8\xcd\x4b\x69\xec\x3d\
\xc6\x0d\x1f\x51\x79\x8e\x15\xc8\xc6\x11\x0a\xaf\x1b\x33\x1a\x80\
\x59\x8d\x5e\x9c\x3e\x07\xe8\xce\x94\xf0\xf2\x86\x1c\x6e\x79\x23\
\x8d\x47\xd6\x5b\x70\xf3\xdc\xc3\x7e\x57\x47\x66\x01\x5a\x9b\xb3\
\x1e\x27\x6e\xc1\x0a\x4f\x1b\x91\x16\x3c\xb5\xbe\x88\x27\x96\x25\
\x70\xcc\xec\x6a\x24\x72\x86\x04\x82\x53\x86\x4d\xc7\x6b\x2a\x3c\
\x38\xbc\xd2\x83\x23\xa6\xfa\x71\x19\x7d\x81\x6b\x3a\x8b\x78\x70\
\x45\x06\x7f\x7c\x33\x81\xa6\xbc\x87\x80\xc7\xf5\xb1\x12\xe6\x72\
\x6f\x18\x5b\x82\x43\xf9\x1e\xd0\x37\x73\x23\xca\x00\xe0\xd6\xb7\
\x74\x17\xfa\xbb\x0d\x96\xf5\x6f\xee\xd7\x0f\xc0\x00\x76\xcd\x18\
\x00\x4f\xd7\xd1\x3f\x9e\x0b\xd0\xdf\xaa\xdb\x75\xf6\xe5\x9f\xad\
\xed\x2a\xb1\xb5\x03\xa9\x5d\x39\xd7\x3f\x80\x01\x58\x76\x24\xbf\
\x33\x34\x0e\x46\xe3\x5e\x0e\x95\x1d\x28\x19\xb2\xc2\xd9\xb0\xdb\
\xb1\xae\x56\x3f\x36\x61\xd9\x80\xc9\xae\x01\xdd\xc1\x2e\x98\x03\
\x94\x8c\x53\x71\x3c\x2a\xdb\x24\x80\xd8\x62\x91\x01\xed\x93\x2d\
\x1a\x03\x8e\x85\x2d\x1d\x88\x29\xf8\xb4\x12\x1e\x5c\x6b\xe1\xab\
\x77\xaf\xc5\x55\x47\xd4\x62\x54\x5d\x8c\x3e\x59\x97\x78\x01\x5b\
\xe9\x5c\x3f\x63\xeb\xf7\xba\x70\xe4\xf4\x30\x0e\x9b\x12\xc0\x2f\
\x9f\x69\xc1\xf7\x5e\x24\xa6\x11\x08\xf7\xa6\xe5\x6c\x37\x6a\x20\
\x00\x88\x75\x93\xe3\x36\x7a\xdd\x92\x8c\xa9\xe3\x2b\x0f\x77\xa1\
\x90\x4d\xe1\x88\xd9\xf5\xf0\xfa\xfc\xc2\x4a\x8a\x74\x2f\xf0\xf5\
\x29\xfe\x7f\xf6\xae\x3d\x46\xae\xaa\x8c\xff\xe6\xce\x9d\xf7\xec\
\xce\xec\xce\x6e\xb7\x5b\xb6\xed\x52\xba\x65\xdb\x42\x6d\x4b\x01\
\x41\x4c\x45\x7c\x03\x82\x31\xc1\x10\x35\x24\x04\x12\x13\xd1\x48\
\x9a\xa8\x91\x18\x05\xf5\x0f\x0d\x88\x09\x6a\x48\x8c\x51\x21\x5a\
\x40\x4b\x83\x36\xb5\x40\x79\x75\xcb\xab\x2f\x4a\xcb\x62\xbb\xbb\
\xdd\x2e\xbb\x2d\xfb\x7e\xcd\xec\xcc\xdc\x3b\xf7\xe5\x77\xce\xbd\
\x77\x76\x66\x77\x8b\x15\x85\x99\x9d\x39\xbf\xe4\x64\xe7\x79\xf7\
\xdc\x33\xdf\xf9\x9d\xdf\xf7\x9d\xef\x9c\x93\xef\x18\x1e\x5c\xd8\
\xe0\xc7\xb6\xad\x01\x5c\xdf\x36\x83\x6f\xec\x1c\xc2\x9b\x69\x72\
\x05\x7c\x1f\x4c\xe6\x98\x35\x87\x14\x0a\xad\xd2\x2b\xcd\x2a\x04\
\x16\xbf\x2d\x54\x0b\xff\x17\x17\xa0\x1a\x63\x00\xcc\x28\xce\x49\
\x00\x56\xb1\x9c\xf7\x14\x48\x3a\xb3\xc0\x4f\x67\x1d\x5e\x2f\x18\
\xe1\x0b\x55\xc0\xff\x22\xe1\xff\x77\xf7\x86\x8a\x64\xcd\x3f\xdb\
\x0f\xec\x20\x4d\xea\xc0\xbc\x83\xcf\x27\x00\x2f\x27\x0a\xa9\xe8\
\x4c\xc1\x59\xff\xdf\xe0\x2b\xea\x74\x7e\x50\xe6\xec\x09\xbe\xac\
\xb0\xce\xc9\xd4\x14\x5f\x71\x37\x87\x00\x0c\x92\xfd\x2c\x03\x0f\
\xf9\x6b\x5a\xf6\xd9\x79\x8c\x80\xe8\x2f\x8b\xba\x3f\x7a\xca\x8f\
\x17\x7b\xba\x70\x7d\xab\x85\xeb\xd6\x35\x90\x1b\x90\x40\xa2\xae\
\x16\x12\x9b\x92\x24\xa9\x9e\xd3\xed\xd3\x91\xd9\x48\xcd\x0c\xff\
\x5b\x9f\x58\x8a\x63\xbd\x6f\xe2\x6f\xc3\x1e\x84\x43\x41\xfb\xda\
\x6c\x14\x33\xad\xf9\x0a\xc0\x51\x7a\x70\x56\x03\xb2\xb9\x8f\x41\
\x23\x82\xdb\xff\x31\x8e\x2b\x3b\x06\x70\x63\x7b\x14\x57\x5f\xdc\
\x88\x95\x4b\xe3\xfc\x74\x64\x36\x31\xca\x09\x81\xfe\xa7\x42\x84\
\xa8\x10\x23\x5c\xdc\x52\x8b\x9f\x6d\x9d\xc6\x2d\x4f\x0c\x22\x57\
\xdb\x5c\xa4\x3c\x3e\xb0\xdf\xb0\x30\xb6\x60\x14\x8f\xfa\xae\x42\
\x90\x1d\x42\x70\x55\x83\x57\x9a\x3f\xa5\x68\xfd\x87\x08\x22\xcf\
\x23\xd1\x4b\xbb\xc8\xa3\x74\x41\x40\x6e\xd4\xf3\x9d\x6e\xf7\x15\
\x37\x45\xd2\xcd\x85\x37\x2c\x3b\x7b\xd0\x9a\xe3\xdb\x7f\xd8\x81\
\x9b\xf3\x51\x00\xf3\x3b\x83\x95\x8f\x7b\xb0\xd1\x15\x0b\xac\x8e\
\x73\x8f\x1e\xb7\xe6\x12\x00\x58\xac\xc4\x80\x44\x65\x30\xa5\x61\
\x38\xad\xa3\xb9\xce\xcd\x31\xf0\x60\x4d\x4b\x02\xc6\xf1\x19\xfa\
\x7e\x63\xd1\x75\x59\xfb\x25\xfc\x16\xda\xea\xbd\x79\x97\x81\x19\
\xea\xe0\x58\x12\x43\xd3\x2a\xac\x04\xcb\xd8\x23\xff\xdc\x2b\xa3\
\x5b\x6f\xc6\x83\x6f\xa7\xf1\xf0\xb1\x11\xac\x0e\xbf\x83\x8d\x4b\
\x24\x5c\xb6\x22\x8a\x4b\x56\xd4\x63\xed\x8a\x04\x22\x35\xf6\x9c\
\x3f\x0b\x24\x5a\x3e\x92\xe9\xab\x83\x78\xec\xe4\x30\xcc\xe0\x0a\
\xfe\x3f\xe7\xd6\xbd\xf0\x7e\x4d\xe7\x7e\xd9\x1d\xb1\xce\xcd\xf8\
\x4b\xf1\xc7\xb1\x67\x32\x8c\x3d\xcf\x4d\xa1\x65\x5f\x37\x56\x47\
\x73\xf8\xd8\xca\x10\xd6\xb6\xc4\xf0\x91\x95\x09\x2c\x5f\x96\x80\
\x0e\xc9\x3e\xad\x39\xab\xe1\xd2\xd6\x3a\x5c\xe4\xef\xc2\x1b\x4a\
\x1d\x42\xfe\x0f\xdf\x64\x17\xb2\x23\xd7\x65\x70\xd5\x80\xad\x14\
\x3c\x45\xb3\x0d\x85\xf1\x83\x85\x2e\xc2\x42\x60\xa6\x61\x55\x61\
\x22\x10\x1f\x19\x74\x52\x00\xd2\xbc\x66\x76\xb3\xcd\x75\xb3\x60\
\x09\xad\x93\x10\x33\x1b\x34\x2c\xdf\x8c\x70\x2b\x9f\xee\x6b\x38\
\xd3\x77\x56\xfe\x2f\xef\x08\x26\x93\xea\xfa\x02\xa4\xc8\x3e\xe7\
\x9d\xfd\x2c\xec\xd3\x70\x6d\x32\xd1\x49\x1d\xe8\x98\xce\x99\x38\
\x76\x36\x83\x4d\x17\xf8\xf9\x67\xb2\x9a\x8e\x6b\xd6\x35\xa3\xed\
\xa5\xe3\x38\xa5\xa8\x88\xf8\x66\x13\x81\x58\x2a\xf0\xe7\x2e\x0e\
\x60\x55\x9d\x04\x25\x67\x77\x40\x26\x5f\x5f\xef\xec\xc3\x94\x27\
\x8c\x35\x11\x3b\xa1\x28\x10\x90\x70\x31\xf9\xdf\xb5\x44\x04\x7f\
\x3c\x2e\xe3\xa4\x21\xe3\xc4\x88\x82\x3f\xf7\x25\x11\xd6\x4e\x63\
\x6d\x5d\x2f\x7e\xf5\xd5\x0d\x58\x47\x64\xc0\xd4\x00\x0b\x46\x26\
\xa2\x3e\x18\xa9\x31\x58\x4d\x2d\xfc\x5e\x78\xdd\xad\xe2\xfb\x65\
\xaa\x81\xfd\xc6\x16\x57\x7b\x3a\x42\xf4\xcf\x57\xc7\x25\x84\x03\
\x1e\x24\x42\x5e\x6c\x48\x44\x71\x60\xc0\x83\x67\xcf\xc6\x31\x4a\
\x9f\xed\xe8\x9c\x01\x0e\x4e\xa0\x51\x3e\x8b\xdb\x2e\x5f\x82\xef\
\xdd\xbc\x9e\x9f\xf0\xcb\xc4\x4a\x94\x94\x46\xd8\x60\xc7\xaf\x67\
\x88\x80\xa2\x76\xe0\xa7\xc4\x30\x9c\xa2\xc1\x8d\x0f\x58\x0e\x19\
\x78\x78\xdc\x80\x3d\x66\x2a\xc1\x39\xa0\x7d\x01\x29\x60\xf1\x6f\
\x1a\x66\x69\xb7\x04\x29\x11\x01\xd8\xc7\x38\x5b\x5e\xab\x60\x56\
\xc0\x95\xf9\x76\xa7\xd7\xf3\x89\x38\x56\x51\x04\xb6\xdc\x91\x0f\
\x02\x3a\x53\x7a\x6e\x87\xb0\xf2\x45\x5f\x50\x01\xd8\xdf\x31\x16\
\x20\x00\x83\x07\x01\xdd\x28\xf8\xae\x13\x29\xdc\xba\x31\xca\x47\
\xff\x1c\x11\xc2\x92\x86\x18\xee\xbb\x7e\x05\xee\x7e\x66\x02\xef\
\x6a\xb5\x5c\x8a\xb2\xef\x5f\xde\xe4\xc3\xf7\xae\x89\xe6\xb3\x09\
\xd9\xd6\xd4\xd3\xd3\x49\xec\x78\xad\x0f\x88\x6c\xc2\x35\x4d\x16\
\x7e\xf9\x85\x7a\x72\x57\x98\xa1\x4a\x44\x30\x26\x4e\xf7\x9d\xc6\
\x13\x03\xe4\x6b\xd3\x88\x2f\x07\x42\x50\xcc\x26\x1c\x4c\x2b\x38\
\x3d\x65\xe2\x92\xe5\xba\xe3\xeb\x5b\x98\x9c\x9a\xe6\xf7\xe1\xde\
\x8b\x1b\x04\x74\xeb\xce\x7c\xfa\xda\x20\xcb\x4c\x24\x22\xca\xa8\
\xa8\x91\x2d\xde\x41\xee\xbf\xae\x0e\x9b\x96\x07\xb9\x8f\xcf\x76\
\x49\xda\x47\xca\x65\xdf\xbf\xce\x42\xa9\xbd\x00\xfe\x68\x0c\x56\
\x34\x8e\xa1\x8c\x8e\x97\xc6\x2c\x6c\xd3\x34\x98\x3c\x6c\xef\x41\
\x26\xa3\x20\x93\x4e\x03\x7e\xa7\xfd\xca\x6c\x5d\xb4\x3b\xc0\x73\
\x77\x81\x85\x58\x3c\xf6\xd4\xa2\xec\xb8\x06\x2c\xa0\x58\x98\xb0\
\xe4\xe6\x9f\x70\x02\x70\xa6\x62\xab\x8e\x00\x4c\x27\xf0\xe3\x4e\
\xc1\xe9\x8e\x71\x99\x05\x9d\xbf\x1c\x24\xfd\xfb\x72\x01\xa4\x62\
\x9f\xd8\x3c\x87\x4f\x5c\xf4\x3d\xe3\x1c\x2e\x80\xe5\xe4\x4c\xd0\
\x28\x1a\xa0\xeb\xbe\xd8\xa7\xe1\x9f\x6f\x4d\xe0\xa6\x4d\x8d\x98\
\xce\x1a\xc8\xa8\x3a\x3e\xbd\xb1\x05\x3b\x1a\x93\x78\xba\x2b\x83\
\xd1\x8c\x1d\x40\xbb\x61\x6d\x14\x0d\x35\x32\xf9\xd1\x26\x37\xc6\
\x48\xc0\x87\x5f\xff\x75\x2f\x0e\x4d\x04\x11\x58\x13\xc7\x0b\xbd\
\x29\xf4\x4f\x84\xd0\xd2\x10\x26\xb5\xa0\xc3\x47\xc3\xd6\x8f\x6f\
\x6e\x43\xe4\xf9\x11\x1c\x1c\xd7\x78\x42\x4f\x30\xe0\xc5\x17\xaf\
\xa8\xc5\xd6\xb6\x1a\x64\x34\x7b\x1d\x02\xfb\x81\xf6\xbf\x79\x9a\
\xa4\x43\x82\x4f\xff\x71\x17\x80\xea\x3e\x99\xca\xe5\xeb\xce\x5c\
\x8b\x75\xab\x9a\xf1\x9b\x5b\x89\xa4\x7c\x41\xa8\xaa\x8a\xbb\x9f\
\x1a\xa2\xfa\x49\xd8\xb2\x32\x88\xa4\x6a\x62\x86\xc8\x6b\x73\xdb\
\x12\xfc\xfa\x46\x1d\xbf\x3b\xa6\x60\x32\x27\xf3\xce\xb1\x72\x99\
\x0f\xdb\xae\x8e\xf1\xf5\x08\x06\xd9\x07\x9b\x2a\x3c\xd9\x35\x80\
\xde\x31\x15\xf2\x0a\xd9\x0e\x76\x96\xa9\x21\xcc\xcd\x49\xd0\x1c\
\x12\x90\x24\x3b\x2b\x31\x1f\x3c\x74\xdd\x04\xf7\x77\xaf\xbe\x59\
\x00\x16\x58\xd2\xb8\x7c\x9a\x8d\xde\x5b\x15\xb1\x71\x84\xab\x00\
\x4c\xab\x58\x01\xb0\xe7\xff\xc9\x05\x58\x58\x01\x98\xb3\xa3\xad\
\x65\xef\xa1\x70\xef\xde\x11\x5c\x44\xd2\x7e\x5d\x6b\x82\x7c\x64\
\x9d\x27\xd9\xac\x5a\x1a\xc5\xb7\x97\xd9\x23\x3e\xeb\xf1\x39\x32\
\xac\x2c\xcf\xe1\x97\x50\x13\xf6\xe3\xc9\x3d\x2f\xe3\x67\xbb\xba\
\x20\xb7\x6d\x85\xdf\xa3\xa3\x2f\x69\xe0\x27\x7b\xce\xe0\x37\xb7\
\xb4\x52\xe7\xf7\xf1\x29\xc0\xfa\x58\x04\x0f\x7c\xb9\x15\x13\x29\
\x8d\xe7\xe3\xd7\x86\x64\xfa\xae\x4d\x22\x6c\xba\x2a\x56\x13\x46\
\xc7\xab\x47\xb1\xfd\xd0\x30\x02\x6d\xed\x24\x48\x72\x76\x10\x90\
\xea\xdb\x43\x1d\x54\xf2\xd8\xf7\x6a\x07\x71\x25\x7c\xe9\x8a\x16\
\xbe\x88\xe7\xd0\xdb\x7d\x88\xe5\x86\xf0\xdb\x03\x61\x7c\xb4\xd9\
\x83\x4f\x5e\xda\x84\x24\x91\x17\x9b\xc1\xb8\xe9\xf2\x16\x7c\x76\
\x83\x86\xc9\xb4\xce\xeb\xca\x48\x8b\xd5\x5f\xa1\xfa\xf8\x65\x7a\
\x4c\x76\xf2\xe0\xe3\x2f\x61\x58\x5e\x8a\x28\xdb\x64\xd4\xd0\x17\
\x8f\x2d\x50\xc9\x15\xc5\x0c\x3c\xb3\xc1\x43\xc7\x5d\xb0\x0f\xbf\
\xa9\x32\x05\xa0\xd1\xc8\xa1\xa8\x1a\x2c\x59\xca\xa7\xdd\x5a\x56\
\x65\x6c\x02\xe1\x12\x40\x90\xfc\x71\xb6\xb8\xc6\x4b\x6e\x0e\xfb\
\x1b\xf0\xc9\x0e\x01\x9c\x3b\x08\xe8\xf5\xb0\xcf\xca\xa4\x20\xec\
\xd7\x58\xe7\x61\x9d\xca\x26\x00\xc3\x4e\xfe\xa1\xf7\x7a\x32\x32\
\x6e\xfb\x4b\x2f\xee\xbb\x6e\x0a\xd7\x6e\x68\x21\xb9\xee\xe7\x01\
\xb6\xac\xb3\xca\x90\x47\xab\xc9\xca\xc2\x41\x2f\xb4\x9c\x8a\xdf\
\x3f\xf1\x2c\x7e\xf8\xe4\xdb\xc8\xae\xfc\x28\xf9\xfc\x41\xe2\x1f\
\x0d\x21\xd9\x83\x1d\x3d\xf4\xf7\xf1\x13\xb8\xe7\xf3\x2b\xb0\xb4\
\x91\x9f\x52\x03\x1a\x9c\x11\x8d\xf8\x51\xe3\x6c\x6a\x62\x2f\x34\
\xf2\x71\xa3\x7d\xe1\xe5\xc3\xf8\xce\xef\xf6\x21\xbd\x64\x13\x82\
\xd4\x39\xdd\xce\xc8\x62\x0b\xbb\xbb\x53\xb8\x63\x30\x82\xd5\xcb\
\x62\xa4\x4a\x6c\xc2\xe3\xea\xc3\x2b\xa3\x2e\x12\x44\x4c\x56\xd1\
\x4f\x1f\xbf\xeb\xa9\x41\xfc\x22\x93\xc5\x67\x36\x5d\x40\xef\xf9\
\x90\xd3\xa9\xbe\x74\xad\x86\x98\xcc\xeb\xae\x5b\xac\x83\x10\x69\
\x85\x24\x4c\x91\xab\xf1\xa3\x3f\xec\xc6\xdf\x4e\x51\x5b\xb6\xad\
\x84\xa5\x6b\x58\xac\x3b\x02\xe8\xce\x88\x6f\x38\x6e\x80\x1d\x23\
\xa0\xd7\xf5\x2a\x74\x01\x58\x4a\xab\x92\xcb\x41\xb2\xbc\x8b\x4e\
\xe2\x9f\xd7\xfd\xd1\xaf\xfc\xca\xc9\x11\x9c\x7e\x27\xcb\x3b\x66\
\x90\x3a\xff\x91\x93\x03\x7c\x14\xe0\x9d\x66\x81\x51\x8c\xed\x7b\
\xd1\x3f\xa9\xe0\x99\x43\xbd\x50\x94\x2c\x1f\x05\x83\x64\x21\x13\
\xc9\x0c\xa4\x80\x65\x7f\xcf\x31\x94\x20\x5d\xa8\x47\x8d\xe0\xb6\
\x1d\x43\xf8\xd4\xcb\xfd\xb8\x79\x63\x23\x2e\x5d\x1e\x47\x22\x1e\
\xe1\x6b\x0e\x34\x4d\xc7\x74\x2a\x83\xa3\xdd\x67\xf0\xc8\x73\x6f\
\x61\xdf\x59\x09\x72\xeb\x55\xf0\x47\x6a\x60\x69\xb9\xfc\xff\x64\
\xa4\xf4\x48\x97\x81\x83\x7d\xc7\xf0\x95\x4b\x42\xb8\xa6\xbd\x11\
\xcd\x75\x11\xbe\x03\x31\x1b\x8d\xd9\xb4\xe3\x4c\x3a\x8b\xae\xfe\
\x51\xec\x39\x70\x12\x4f\x1c\x19\xc5\x4c\xd3\x06\x84\xe2\x8d\x74\
\x9d\xd9\xce\xe8\x23\xd3\xee\x4f\x99\xb8\x73\x7b\x0f\xbe\xff\xf1\
\x38\xd5\x25\x86\x48\x38\xc8\xbf\x3f\x3c\x94\xc1\x2b\x47\xbb\xe9\
\xf7\xd6\x48\x79\x18\x18\xd4\x43\xb8\xfd\xc9\x21\xdc\x70\x70\x00\
\x37\x6e\x48\x60\x7d\x4b\x1d\x6a\xa2\x41\x9b\x20\x09\x19\x45\xc5\
\xd8\xe4\x0c\x0f\x56\x6e\xdf\xd7\x85\xc3\xa9\x18\x82\x17\x6e\x74\
\x94\x86\xb6\xb8\x07\x87\x02\xf7\x80\x11\x81\x41\x2a\x89\x29\x2f\
\xab\x84\xd2\xb7\x24\x67\x03\x7e\xf6\xa1\x37\x9e\x7f\xa6\x73\xec\
\x5a\xe6\x63\x56\x26\x48\xc2\x4e\x8f\x03\x53\x43\xb3\xb2\x80\x46\
\xb9\x60\xe3\x72\xea\xbd\x91\x05\x83\x58\x2c\x20\xa4\x51\xe7\xd4\
\x47\xcf\x90\x6e\xcc\xb8\x2b\x45\x20\xc7\xea\xe1\xab\x6b\x86\x35\
\x27\x6b\x92\x8f\x26\x2c\x71\x47\x55\x80\xd4\x04\x96\xfa\xb2\x68\
\x0c\x1a\x90\xad\x1c\x27\x00\x96\xbd\x77\x36\x4d\xed\x1b\x5f\x86\
\x40\xfd\x12\x2e\x37\xad\x85\xa2\xe7\xcc\x5d\xa0\x51\xc8\x9c\x99\
\x46\x8d\x39\x8d\xa5\x81\x1c\xc2\x5e\x93\x4f\x3b\xb2\x0e\x9c\x52\
\x74\xf4\x27\x49\xa5\x85\x1b\xe0\x6b\x68\x86\xec\x0f\xe6\x13\x7b\
\x8a\x2f\xe3\xe1\xb3\x0d\x52\x7a\x1c\x17\x05\x67\x10\x95\x54\xe8\
\x44\xf2\xe3\x33\x54\x0f\xc5\x0b\xdf\x92\x0b\x21\x87\x63\xbc\x1b\
\xb0\x55\x7e\xb9\x2c\xd5\x3b\x3d\x81\x96\x40\x16\x31\x9f\x0e\x3f\
\xec\xfd\x0e\x32\x44\x14\xa3\x33\x06\x26\x72\x21\x20\xb1\x0c\xc1\
\x58\x3d\x9c\x9c\xd9\xca\xb3\x12\x0f\x9b\x8a\x35\xb0\x6f\xdb\xe5\
\x9f\xf8\xf8\xea\xf8\x4b\x55\xa3\x00\xf8\xbe\xf8\x5c\x0e\xa3\x62\
\x11\xa8\x8d\x53\xe7\x4b\xcc\xf1\xf3\x8d\x05\x47\x7f\x77\x74\x60\
\x91\x7a\xef\xb2\x0b\x8b\x17\x38\x38\x99\x80\x0b\xa5\x29\xb3\x13\
\xa5\x58\x34\x1d\x0d\x4d\x18\x25\xa5\x31\xa4\x39\xe9\xc0\x24\xef\
\xa5\x7a\x19\x81\x26\xd9\x9e\x86\x22\x17\xe2\xbd\x9a\x9a\xcd\x1e\
\x7a\x6a\x63\x50\x10\x43\x0f\x91\x47\x5e\x6d\x90\xb6\xf7\xd4\x7a\
\xe1\x4f\xf8\x9c\xe8\xb5\xc9\x73\xfb\xcf\x55\x7f\x3f\xcb\xd6\x8d\
\x35\xa0\x5b\x8b\xdb\xd7\xa0\xe7\xbc\x1e\x7e\xd9\xb9\x0f\x3d\x4f\
\x5e\x81\xa0\x0f\x08\x2d\xc5\xbb\x44\x3e\x67\xb8\x2a\x72\x7c\xe1\
\x00\xa9\x95\x88\x6c\xbb\x18\xce\x7a\x82\x4a\x85\x65\x47\x7f\xab\
\x73\x35\xa0\x3b\x7f\x5c\xd1\x78\x3f\xc6\x6b\xbe\x8f\x20\x97\xc9\
\xfb\x1a\x3f\x6b\x8e\x1c\xea\x3c\x71\x30\x9f\xf9\x7c\x8d\xcb\x9d\
\x66\xf5\xf1\xac\x16\x6f\xd1\x1b\x7c\x31\xcf\x7f\x61\xa4\x45\xd7\
\x70\xea\x71\x2e\x07\x8f\x53\x14\x4f\xba\x2f\xfc\x9f\x8c\x68\x54\
\x54\x05\x0c\xa3\xfa\x32\x01\x51\x05\x0a\x40\x40\xe0\xfc\xc8\xdb\
\xa8\xce\x54\x60\x9b\x00\xc4\xb1\x97\x02\x82\x00\xaa\x6e\x53\x50\
\xcb\x12\x04\x20\x20\x50\xbd\x0a\x20\xbf\xce\x5d\xf8\x00\x02\x55\
\x0e\xab\x0a\x13\x81\x20\x14\x80\x80\xc0\xac\x02\xa8\x36\x17\xc0\
\xde\x62\x45\x9a\xdd\xa3\xa9\xe8\x3d\xe2\x87\x9c\xbe\xf0\x09\x9a\
\x02\x02\x8b\x72\x94\x07\x4b\xa7\xcc\x9f\xb7\x50\x7c\xc4\x93\x54\
\x7d\x04\x60\x0d\xbc\x61\xe0\xc4\x5b\xb0\x42\x81\xf9\x6f\xe6\x72\
\xb8\xf7\xae\x5b\xb0\xa5\xbd\x15\xd9\x9c\x26\x8c\x47\x60\xd1\x23\
\x14\x08\xe0\xbb\xf7\xfe\x1c\x9d\x27\xfa\x80\xfa\x66\xc0\x1f\x46\
\x7e\x1b\xd2\xac\x0a\x2b\x7b\x19\x3d\x68\xac\x22\x05\x90\x99\x50\
\x90\x1c\x04\xf4\xe0\x02\xef\xa9\xd8\xdc\x1c\xc0\xa7\xdb\x1b\x90\
\x56\x54\x61\x3d\x02\x8b\x1e\x91\x48\x08\x75\x2a\xd9\xfb\x70\xb7\
\xbd\x3b\x69\xa8\x76\x76\xe4\xcf\xb0\xcd\x11\x4b\x37\xd2\x95\x86\
\x00\x24\x6f\x07\x24\x79\x2d\x95\x55\xf3\xde\xf3\x1a\xfc\x50\x4a\
\x76\x1a\x0d\x2b\x02\x02\x8b\x1e\x32\xf5\x71\x96\xa0\x25\xfb\x59\
\xb6\x96\x7d\x92\x92\x4d\x00\x49\x7a\x7c\x90\x9e\x0c\x57\x17\x01\
\x00\x7b\x1d\xcd\xf3\x35\x2a\x4d\xf3\x5c\x84\xc2\xcd\x25\x05\x04\
\x16\x7b\x08\x60\xe1\x3d\xc1\x58\xca\xe7\x61\x2a\x8f\x52\x19\xa9\
\x2a\x02\xc8\xaa\xb9\x4e\x92\x3e\x7f\x42\xd0\xcf\x0e\xa1\xbb\x81\
\x5e\x5a\x4b\x25\x2c\x4c\x45\xa0\x0a\xc0\xa2\xdb\x6c\xc4\xdf\x4f\
\xe5\x31\x28\xb9\x0e\xc3\x34\x67\x4a\x55\x99\x92\x84\x20\x1f\xbe\
\xe7\x4e\xe5\x0f\x0f\x7d\xff\x78\xc0\xeb\xfd\x2d\x34\xfd\x61\x7a\
\xe9\x10\x66\xf7\x4e\x10\x10\xa8\x64\x39\x30\x0a\xcb\x7c\x8a\x1e\
\x3d\x00\x35\xf7\xf7\x07\x7f\xfa\xcd\xd1\xcb\xda\x57\x95\x4c\xea\
\x96\x44\x01\x6c\x5c\xd3\xca\xcb\x5b\xbd\x67\x46\x7e\xff\xd8\x9e\
\x9d\x53\x6a\xae\x86\x94\xc0\x05\xf4\x16\x8b\x09\x88\xe4\x00\x81\
\x0a\x04\x5f\x97\x69\xc0\xd4\x8e\xc1\x34\x1e\x83\xd7\x7f\x90\xed\
\x9c\x7a\xd5\xa6\x76\x7e\x94\x7a\x55\x29\x00\x17\xf7\xdf\xfd\x75\
\x5c\xb6\xb9\x7d\x9c\x64\xd0\xd3\xf4\xf4\x49\x2a\xdd\xc2\x50\x04\
\x2a\x73\xe4\x37\x75\xe8\xb9\x6e\xe4\x32\x7b\x31\xd6\x73\x1c\xe9\
\x31\x93\x05\x04\xb3\x4a\x69\x85\xaf\x5c\xea\x76\xb1\xf7\x44\x43\
\x0f\x95\xed\x60\x51\x51\xe0\x26\x2a\x9b\x60\xaf\x70\x15\x10\xa8\
\x8c\xd1\xdf\xd0\x46\x90\x9d\x7a\x1d\x93\xea\xeb\x50\x92\x19\x44\
\x1a\xec\x65\xd0\x25\x86\x5c\x26\x2d\xc4\x68\xf0\x38\x95\x33\x44\
\x95\x67\x98\x38\xa0\x92\x10\x86\x23\x50\x31\xea\x3f\x97\xee\x83\
\x3e\xdd\x89\x54\x72\x92\x2f\x82\x29\x71\x06\x60\x59\xb8\x00\x73\
\xc0\xa6\x45\x46\xa9\xec\xa1\x06\x1a\x11\x91\x00\x81\xca\x52\x00\
\x6c\x9f\x37\x28\x4e\x1a\x70\xd9\x58\xb7\x54\x5e\xed\xc4\xb6\x49\
\x55\x86\xa9\x4c\x89\x58\xa0\x40\xe5\xc9\x80\xf2\x33\x6a\xb9\xbc\
\xda\x88\xda\x47\xcd\x58\x50\xd3\x6c\xb3\x68\x91\x08\x24\x50\x11\
\x28\x67\x3b\x2e\x39\x01\xb0\x53\x64\x90\x51\xec\x27\x2c\x4d\x32\
\x93\x86\xc7\xd4\x2c\x78\x84\x02\x10\xa8\x60\x30\xbb\xd7\x14\xe7\
\x6c\xc0\x2a\x26\x80\xab\x36\xac\x41\x88\x11\x64\xd0\x4f\x0a\xc0\
\x8b\xf1\x6e\x99\x9f\x1b\x28\x20\x50\xc9\xd8\x48\x76\x1f\x4f\xb4\
\x20\x11\xab\xa9\x6e\x02\x78\x70\xdb\x6d\x45\xcf\x9f\x7f\x6e\x2f\
\xfa\xfa\x07\x84\x85\x08\x54\x34\x1e\xfe\xc1\x1d\xb8\xf2\xaa\xab\
\x4b\x5e\x0f\xa9\xdc\x1a\x46\x21\x69\x24\xc4\xbf\x40\xa5\x83\xbb\
\xbe\x65\x00\x49\xfc\x14\x02\x02\xd5\x0b\x41\x00\x02\x02\x82\x00\
\x04\x04\x04\x04\x01\x08\x08\x08\x08\x02\x10\x10\x10\x10\x04\x20\
\x20\x20\x50\xe1\x90\xcb\xb4\x5e\x92\xd8\x13\x50\xa0\x52\x50\xce\
\x76\x5c\x96\x0a\x40\xd3\xb4\x7e\x55\x55\xd3\xc2\x74\x04\x16\x33\
\xd8\xf9\x37\x64\xcb\x66\x7f\x7f\xbf\xaa\x28\x8a\x9b\xde\x6a\x09\
\x02\x78\xaf\x0a\x49\x12\x26\x26\x26\x76\x8f\x8e\x8e\xbe\xe9\x36\
\xa2\x80\xc0\x62\x84\xd7\xeb\xc5\xcc\xcc\x8c\xbe\x6b\xd7\xae\x77\
\x87\x86\x86\xd8\x66\x37\x6c\xff\x7f\xa3\x9c\x48\x40\x2a\xc7\x46\
\x7b\xed\xb5\xd7\x3a\x0e\x1f\x3e\xfc\xcc\xd4\xd4\xd4\x18\x23\x00\
\x49\x12\xa1\x0a\x81\xc5\x35\xf2\x33\x3b\x26\x15\x6b\x1e\x39\x72\
\x64\x72\xe7\xce\x9d\xfd\x34\xa0\xb1\xad\xbf\xa7\xc1\xf6\x04\x28\
\x23\x02\x28\xbb\x18\x80\x2c\xcb\xd8\xbd\x7b\x37\x6b\xac\xe7\xa8\
\xe3\xb7\xad\x5f\xbf\xfe\x73\xf1\x78\xbc\xce\xe7\xf3\x49\xac\x51\
\x45\x5c\x40\xa0\x9c\x3b\xbe\xe3\xc2\x5a\x4c\xf2\x1f\x3d\x7a\x74\
\x6a\xc7\x8e\x1d\x03\x27\x4e\x9c\x38\xab\xeb\x7a\x3f\xbd\x35\x48\
\x85\x6d\x01\x6e\x0a\x02\x78\x6f\xbf\x49\xdb\xbf\x7f\x7f\x57\x2a\
\x95\xda\xbe\x65\xcb\x96\x99\xcd\x9b\x37\x6f\x6d\x6f\x6f\x6f\x6d\
\x6c\x6c\x0c\x12\x11\x08\x45\x20\x50\x76\x60\x03\x93\x61\x18\xc8\
\x64\x32\xd6\xa9\x53\xa7\x52\x1d\x1d\x1d\xa3\x7b\xf7\xee\x1d\xee\
\xec\xec\x3c\x93\xcd\x66\x4f\xc1\xde\xf7\xf2\xac\x20\x80\xf3\x83\
\x39\x3e\x3e\x3e\xfd\xea\xab\xaf\x1e\xa5\xc6\xf3\x27\x93\x49\xab\
\xaf\xaf\x6f\x73\x5d\x5d\x5d\x63\x38\x1c\x8e\x10\x09\xb0\x7a\xbb\
\xc1\x01\x11\x24\x10\x28\x0b\x02\xa0\x51\x5f\x27\x5b\xd5\x7a\x7b\
\x7b\x93\x07\x0e\x1c\x18\x24\x05\xd0\x4f\xf6\xdb\x4b\x6f\x9f\x74\
\x08\x80\x29\x5b\x55\xb8\x00\xe7\xd1\x9e\x4c\x49\x51\xe3\x4d\x10\
\x09\x1c\xa4\x32\x44\xcf\x5f\xa6\xd2\x4a\x65\x09\x15\xb6\x88\xda\
\x07\x91\xc7\x20\x50\x7e\x76\x6b\x3a\x9d\x7c\x8a\xca\xbb\x54\xd8\
\xe8\xdf\xeb\x3c\x4e\x97\xd3\xe8\x5f\xce\x04\x80\x82\x86\x1c\x87\
\xbd\x61\x68\xd6\x79\xcc\xce\x14\x8c\x50\xf1\x0b\x02\x10\x28\x43\
\x02\x60\x51\x7e\xc5\x21\x80\x61\xa7\xe3\x8f\x39\x9d\x5f\x47\x99\
\x4d\x03\xca\x65\xde\xa0\x2e\x09\x4c\x50\xc9\x38\x0d\x1a\x72\x46\
\x7f\xaf\x90\xff\x02\x65\x6a\xb3\x2e\x09\x64\x9c\xa2\x3a\xaf\x97\
\x5d\x04\xfb\xdf\x02\x0c\x00\x0b\x53\x81\x73\x51\x45\x40\xdb\x00\
\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
"
qt_resource_name = "\
\x00\x04\
\x00\x06\xfa\x5e\
\x00\x69\
\x00\x63\x00\x6f\x00\x6e\
\x00\x07\
\x09\xcb\xb6\x93\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x73\
\x00\x03\
\x00\x00\x78\xc3\
\x00\x72\
\x00\x65\x00\x73\
\x00\x03\
\x00\x00\x70\x37\
\x00\x69\
\x00\x6d\x00\x67\
\x00\x1a\
\x0d\x95\x42\xe7\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x62\x00\x61\x00\x63\x00\x6b\x00\x75\x00\x70\x00\x5f\x00\x64\x00\x69\x00\x73\
\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x13\
\x09\x34\xc1\x67\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x64\x00\x6f\x00\x77\x00\x6e\x00\x6c\x00\x6f\x00\x61\x00\x64\x00\x2e\x00\x70\
\x00\x6e\x00\x67\
\x00\x0f\
\x0d\xf5\x7d\xe7\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x75\x00\x74\x00\x66\x00\x38\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x19\
\x01\x96\x0f\x07\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x61\x00\x70\x00\x70\x00\x6c\x00\x79\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\
\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1c\
\x0b\x10\x37\x07\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x64\x00\x6f\x00\x77\x00\x6e\x00\x6c\x00\x6f\x00\x61\x00\x64\x00\x5f\x00\x64\
\x00\x69\x00\x73\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x18\
\x0c\x40\x62\x67\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x65\x00\x78\x00\x69\x00\x74\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\
\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0f\
\x08\x69\x7b\xe7\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x65\x00\x78\x00\x69\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x18\
\x0c\x12\xc4\x27\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x61\x00\x6e\x00\x73\x00\x69\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\
\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1b\
\x06\xc3\x72\x67\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x72\x00\x65\x00\x73\x00\x74\x00\x6f\x00\x72\x00\x65\x00\x5f\x00\x64\x00\x69\
\x00\x73\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x18\
\x0c\x81\x05\x67\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x75\x00\x74\x00\x66\x00\x38\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\
\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1a\
\x0d\xa7\xd8\x07\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x75\x00\x70\x00\x64\x00\x61\x00\x74\x00\x65\x00\x5f\x00\x64\x00\x69\x00\x73\
\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0f\
\x02\xf6\x79\x67\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x61\x00\x6e\x00\x73\x00\x69\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x06\x8e\xf4\xc7\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x75\x00\x70\x00\x64\x00\x61\x00\x74\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x10\
\x01\xda\x95\x47\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x61\x00\x70\x00\x70\x00\x6c\x00\x79\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x0c\xef\x75\x47\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x62\x00\x61\x00\x63\x00\x6b\x00\x75\x00\x70\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x12\
\x04\x27\x2f\xe7\
\x00\x62\
\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x5f\x00\x72\x00\x65\x00\x73\x00\x74\x00\x6f\x00\x72\x00\x65\x00\x2e\x00\x70\x00\x6e\
\x00\x67\
\x00\x05\
\x00\x6f\xa6\x53\
\x00\x69\
\x00\x63\x00\x6f\x00\x6e\x00\x73\
\x00\x14\
\x0d\x75\xab\xe7\
\x00\x75\
\x00\x74\x00\x6c\x00\x5f\x00\x69\x00\x63\x00\x6f\x00\x6e\x00\x40\x00\x32\x00\x35\x00\x36\x00\x78\x00\x32\x00\x35\x00\x36\x00\x2e\
\x00\x70\x00\x6e\x00\x67\
"
qt_resource_struct = "\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x16\
\x00\x00\x00\x0e\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x22\x00\x02\x00\x00\x00\x01\x00\x00\x00\x04\
\x00\x00\x00\x2e\x00\x02\x00\x00\x00\x01\x00\x00\x00\x05\
\x00\x00\x00\x0e\x00\x02\x00\x00\x00\x10\x00\x00\x00\x06\
\x00\x00\x00\xc4\x00\x00\x00\x00\x00\x01\x00\x00\x12\x2c\
\x00\x00\x02\xc2\x00\x00\x00\x00\x00\x01\x00\x00\x57\x58\
\x00\x00\x02\x76\x00\x00\x00\x00\x00\x01\x00\x00\x48\xda\
\x00\x00\x03\x10\x00\x00\x00\x00\x00\x01\x00\x00\x62\xfc\
\x00\x00\x02\x9a\x00\x00\x00\x00\x00\x01\x00\x00\x50\x67\
\x00\x00\x01\xca\x00\x00\x00\x00\x00\x01\x00\x00\x33\x9e\
\x00\x00\x01\x70\x00\x00\x00\x00\x00\x01\x00\x00\x25\x54\
\x00\x00\x00\x74\x00\x00\x00\x00\x00\x01\x00\x00\x04\xfc\
\x00\x00\x00\xfc\x00\x00\x00\x00\x00\x01\x00\x00\x18\xef\
\x00\x00\x01\x94\x00\x00\x00\x00\x00\x01\x00\x00\x2c\x15\
\x00\x00\x01\x3a\x00\x00\x00\x00\x00\x01\x00\x00\x1e\x93\
\x00\x00\x02\x06\x00\x00\x00\x00\x00\x01\x00\x00\x3a\x5d\
\x00\x00\x02\xe8\x00\x00\x00\x00\x00\x01\x00\x00\x5e\x00\
\x00\x00\x00\x3a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x02\x3c\x00\x00\x00\x00\x00\x01\x00\x00\x41\xe9\
\x00\x00\x00\xa0\x00\x00\x00\x00\x00\x01\x00\x00\x0a\xa0\
\x00\x00\x00\x22\x00\x02\x00\x00\x00\x01\x00\x00\x00\x17\
\x00\x00\x00\x2e\x00\x02\x00\x00\x00\x01\x00\x00\x00\x18\
\x00\x00\x03\x3a\x00\x02\x00\x00\x00\x01\x00\x00\x00\x19\
\x00\x00\x03\x4a\x00\x00\x00\x00\x00\x01\x00\x00\x69\xb1\
"
def qInitResources():
QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
def qCleanupResources():
QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
qInitResources()
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# qdialog_slots.py : Qt slots response to signals on the main dialog.
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import shutil
import time
from PyQt4 import QtCore, QtGui
from language import LangUtil
from qdialog_d import QDialogDaemon
from util_ui import _translate
import sys
sys.path.append("..")
from util import RetrieveData
class QDialogSlots(QDialogDaemon):
"""
QDialogSlots class provides `Qt slots` to deal with the `Qt signals`
emitted by the widgets on the main dialog operated by users.
.. note:: This class is subclass of :class:`~gui.qdialog_d.QDialogDaemon`
class and parent class of :class:`~gui.hostsutil.HostsUtil`.
:ivar int ipv_id: An flag indicating current IP version setting. The
value could be 1 or 0:
====== ==========
ipv_id IP Version
====== ==========
1 IPv6
0 IPv4
====== ==========
.. seealso::
:meth:`~gui.qdialog_slots.QDialogSlots.on_IPVersion_changed`. in
this class.
:ivar str make_path: Temporary path to store generated hosts file. The
default value of :attr:`make_path` is "`./hosts`".
:ivar int mirror_id: Index number of current selected server from the
mirror list.
"""
_ipv_id = 0
make_path = "./hosts"
mirror_id = 0
def __init__(self):
"""
Initialize a new instance of this class.
"""
super(QDialogSlots, self).__init__()
def reject(self):
"""
Close this program while the reject signal is emitted.
.. note:: This method is the slot responses to the reject signal from
an instance of the main dialog.
"""
self.close()
return QtGui.QDialog.reject(self)
def close(self):
"""
Close this program while the close signal is emitted.
.. note:: This method is the slot responses to the close signal from
an instance of the main dialog.
"""
try:
RetrieveData.clear()
except:
pass
super(QDialogDaemon, self).close()
def mouseMoveEvent(self, e):
"""
Allow drag operations to set the new position for current cursor.
:param e: Current mouse event.
:type e: :class:`PyQt4.QtGui.QMouseEvent`
"""
if e.buttons() & QtCore.Qt.LeftButton:
try:
self.move(e.globalPos() - self.dragPos)
except AttributeError:
pass
e.accept()
def mousePressEvent(self, e):
"""
Allow press operation to set the new position for current dialog.
:param e: Current mouse event.
:type e: :class:`PyQt4.QtGui.QMouseEvent`
"""
if e.button() == QtCore.Qt.LeftButton:
self.dragPos = e.globalPos() - self.frameGeometry().topLeft()
e.accept()
def on_Mirror_changed(self, mirr_id):
"""
Change the current server selection.
.. note:: This method is the slot responses to the signal argument
:attr:`mirr_id` from SelectMirror widget while the value is
changed.
:param mirr_id: Index number of current mirror server.
"""
self.mirror_id = mirr_id
self.check_connection()
def on_IPVersion_changed(self, ipv_id):
"""
Change the current IP version setting.
.. note:: This method is the slot responses to the signal argument
:attr:`ipv_id` from SelectIP widget while the value is changed.
:param ipv_id: An flag indicating current IP version setting. The
value could be 1 or 0:
====== ==========
ipv_id IP Version
====== ==========
1 IPv6
0 IPv4
====== ==========
:type ipv_id: int
"""
if self._ipv_id != ipv_id:
self._ipv_id = ipv_id
if not RetrieveData.db_exists():
self.warning_no_datafile()
else:
self.set_func_list(0)
self.refresh_func_list()
def on_Selection_changed(self, item):
"""
Change the current selection of modules to be applied to hosts file.
.. note:: This method is the slot responses to the signal argument
:attr:`item` from Functionlist widget while the item selection is
changed.
:param item: Row number of the item listed in Functionlist which is
changed by user.
:type item: int
"""
ip_flag = self._ipv_id
func_id = self.ui.Functionlist.row(item)
if self._funcs[ip_flag][func_id] == 0:
self._funcs[ip_flag][func_id] = 1
else:
self._funcs[ip_flag][func_id] = 0
mutex = RetrieveData.get_ids(self.choice[ip_flag][func_id][2])
for c_id, c in enumerate(self.choice[ip_flag]):
if c[0] == self.choice[ip_flag][func_id][0]:
if c[1] in mutex and self._funcs[ip_flag][c_id] == 1:
self._funcs[ip_flag][c_id] = 0
self.refresh_func_list()
def on_Lang_changed(self, lang):
"""
Change the UI language setting.
.. note:: This method is the slot responses to the signal argument
:attr:`lang` from SelectLang widget while the value is changed.
:param lang: The language name which is selected by user.
.. note:: This string is typically in the format of IETF language
tag. For example: en_US, en_GB, etc.
.. seealso:: :attr:`language` in :class:`~gui.language.LangUtil`
class.
:type lang: str
"""
new_lang = LangUtil.get_locale_by_language(unicode(lang))
trans = QtCore.QTranslator()
from hostsutil import LANG_DIR
trans.load(LANG_DIR + new_lang)
self.app.removeTranslator(self._trans)
self.app.installTranslator(trans)
self._trans = trans
self.ui.retranslateUi(self)
self.init_main()
self.check_connection()
def on_MakeHosts_clicked(self):
"""
Start operations to make a hosts file.
.. note:: This method is the slot responses to the signal from
ButtonApply widget while the button is clicked.
.. note:: No operations would be called if current session does not
have the privileges to change the hosts file.
"""
if not self._writable:
self.warning_permission()
return
if self.question_apply():
self.make_path = "./hosts"
self.make_hosts("system")
else:
return
def on_MakeANSI_clicked(self):
"""
Export a hosts file encoded in ANSI.
.. note:: This method is the slot responses to the signal from
ButtonANSI widget while the button is clicked.
"""
self.make_path = self.export_hosts()
if unicode(self.make_path) != u'':
self.make_hosts("ansi")
def on_MakeUTF8_clicked(self):
"""
Export a hosts file encoded in UTF-8.
.. note:: This method is the slot responses to the signal from
ButtonUTF widget while the button is clicked.
"""
self.make_path = self.export_hosts()
if unicode(self.make_path) != u'':
self.make_hosts("utf-8")
def on_Backup_clicked(self):
"""
Backup the hosts file of current operating system.
.. note:: This method is the slot responses to the signal from
ButtonBackup widget while the button is clicked.
"""
l_time = time.localtime(time.time())
backtime = time.strftime("%Y-%m-%d-%H%M%S", l_time)
filename = "hosts_" + backtime + ".bak"
if self.platform == "OS X":
filename = "/Users/" + filename
filepath = QtGui.QFileDialog.getSaveFileName(
self, _translate("Util", "Backup hosts", None),
QtCore.QString(filename),
_translate("Util", "Backup File(*.bak)", None))
if unicode(filepath) != u'':
shutil.copy2(self.hosts_path, unicode(filepath))
self.info_complete()
def on_Restore_clicked(self):
"""
Restore a previously backed up hosts file.
.. note:: This method is the slot responses to the signal from
ButtonRestore widget while the button is clicked.
This method would call
.. note:: No operations would be called if current session does not
have the privileges to change the hosts file.
"""
if not self._writable:
self.warning_permission()
return
filename = ''
if self.platform == "OS X":
filename = "/Users/" + filename
filepath = QtGui.QFileDialog.getOpenFileName(
self, _translate("Util", "Restore hosts", None),
QtCore.QString(filename),
_translate("Util", "Backup File(*.bak)", None))
if unicode(filepath) != u'':
shutil.copy2(unicode(filepath), self.hosts_path)
self.info_complete()
def on_CheckUpdate_clicked(self):
"""
Retrieve update information (metadata) of the latest data file from a
specified server.
.. note:: This method is the slot responses to the signal from
ButtonCheck widget while the button is clicked.
"""
if self.choice != [[], []]:
self.refresh_func_list()
self.set_update_click_btns()
if self._update == {} or self._update["version"] == \
unicode(_translate("Util", "[Error]", None)):
self.check_update()
def on_FetchUpdate_clicked(self):
"""
Retrieve the latest hosts data file.
.. note:: This method is the slot responses to the signal from
ButtonUpdate widget while the button is clicked.
This method would call operations to
.. note:: Method :meth:`~gui.qdialog_slots.on_CheckUpdate_clicked`
would be called if no update information has been set,
.. note:: If the current data is up-to-date, no data file would be
retrieved.
"""
self.set_fetch_click_btns()
self._down_flag = 1
if self._update == {} or self._update["version"] == \
unicode(_translate("Util", "[Error]", None)):
self.check_update()
elif self.new_version():
self.fetch_update()
else:
self.info_uptodate()
self.finish_fetch()
def on_LinkActivated(self, url):
"""
Open external link in browser.
.. note:: This method is the slot responses to the signal from a Label
widget while the text with a hyperlink which is clicked by user.
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url)) | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __list_trans.py : Name of items from the function list to be localized
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
from util_ui import _translate
# Name of items from the function list to be localized
# __list_trans (list): A list containing names of function list items
# for translator to translate.
__list_trans = [
_translate("Util", "customize", None),
_translate("Util", "google", None),
_translate("Util", "google-apis", None),
_translate("Util", "google(cn)", None),
_translate("Util", "google(hk)", None),
_translate("Util", "google(us)", None),
_translate("Util", "google-apis(cn)", None),
_translate("Util", "google-apis(us)", None),
_translate("Util", "activation-helper", None),
_translate("Util", "facebook", None),
_translate("Util", "twitter", None),
_translate("Util", "youtube", None),
_translate("Util", "wikipedia", None),
_translate("Util", "institutions", None),
_translate("Util", "steam", None),
_translate("Util", "github", None),
_translate("Util", "dropbox", None),
_translate("Util", "wordpress", None),
_translate("Util", "others", None),
_translate("Util", "adblock-hostsx", None),
_translate("Util", "adblock-mvps", None),
_translate("Util", "adblock-mwsl", None),
_translate("Util", "adblock-yoyo", None), ]
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# _pyuic4.py : Tools update the UI code from UI design
#
# Copyleft (C) 2013 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
import os
PROJ_DIR = '../'
for root, dirs, files in os.walk(PROJ_DIR):
for f in files:
file_path = os.path.join(root, f)
out_path = os.path.join(PROJ_DIR, f.rsplit('.', 1)[0])
if f.endswith('.ui'):
os.system('pyuic4 -o %s.py -x %s' % (out_path, file_path))
print("make: %s.py" % out_path)
elif f.endswith('.qrc'):
os.system('pyrcc4 -o %s_rc.py %s' % (out_path, file_path))
print("make: %s_rc.py" % out_path)
else:
pass
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _pylupdate4.py : Tools to update the language files for UI
#
# Copyleft (C) 2013 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
import os
for root, dirs, files in os.walk('.'):
for f in files:
if f.endswith('.pro'):
os.system('pylupdate4 %s' % f)
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# qdialog_d.py : Operations on the main dialog.
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
import shutil
from zipfile import BadZipfile
from PyQt4 import QtCore, QtGui
from _checkconn import QSubChkConnection
from _checkupdate import QSubChkUpdate
from _make import QSubMakeHosts
from _update import QSubFetchUpdate
from qdialog_ui import QDialogUI
from util_ui import _translate
import sys
sys.path.append("..")
from util import RetrieveData, CommonUtil
class QDialogDaemon(QDialogUI):
"""
QDialogDaemon class contains methods used to manage the operations while
modifying the hosts file of current operating system. Including methods
to manage operations to update data file, download data file, configure
hosts, make hosts file, backup hosts file, and restore backup.
.. note:: This class is subclass of :class:`~gui.qdialog_ui.QDialogUI`
class and parent class of :class:`~gui.qdialog_slots.QDialogSlots`.
:ivar int_down_flag: An flag indicating the downloading status of
current session. 1 represents data file is being downloaded.
:ivar dict _update: Update information of the current data file on server.
:ivar int _writable: Indicating whether the program is run with admin/root
privileges. The value could be `1` or `0`.
.. seealso:: `_update` and `_writable` in
:class:`~tui.curses_d.CursesDaemon` class.
:ivar list _funcs: Two lists with the information of function list both
for IPv4 and IPv6 environment.
:ivar list choice: Two lists with the selection of functions both
for IPv4 and IPv6 environment.
:ivar list slices: Two lists with integers indicating the number of
function items from different parts listed in the function list.
.. seealso:: `_funcs`, `choice`, and `slices` in
:class:`~tui.curses_ui.CursesUI` class.
:ivar dict make_cfg: A set of module selection control bytes used to
control whether a specified method is used or not while generate a
hosts file.
.. seealso:: :attr:`make_cfg` in
:class:`~tui.curses_d.CursesDaemon` class.
:ivar str platform: Platform of current operating system. The value could
be `Windows`, `Linux`, `Unix`, `OS X`, and of course `Unknown`.
:ivar str hostname: The hostname of current operating system.
.. note:: This attribute would only be used on linux.
:ivar str hosts_path: The absolute path to the hosts file on current
operating system.
:ivar str make_mode: Operation mode for making hosts file. The valid value
could be one of `system`, `ansi`, and `utf-8`.
.. seealso:: :attr:`make_mode` in
:class:`~util.makehosts.MakeHosts` class.
:ivar str sys_eol: The End-Of-Line marker. This maker could typically be
one of `CR`, `LF`, or `CRLF`.
.. seealso:: :attr:`sys_eol` in
:class:`~tui.curses_ui.CursesUI` class.
"""
_down_flag = 0
_update = {}
_writable = 0
_funcs = [[], []]
choice = [[], []]
slices = [[], []]
make_cfg = {}
platform = ''
hostname = ''
hosts_path = ''
sys_eol = ''
make_mode = ''
def __init__(self):
super(QDialogDaemon, self).__init__()
self.set_platform()
self.set_platform_label()
def check_writable(self):
"""
Check if current session is ran with root privileges.
.. note:: IF current session does not has the write privileges to the
hosts file of current system, a warning message box would popup.
.. note:: ALL operation would change the `hosts` file on current
system could only be done while current session has write
privileges to the file.
"""
writable = CommonUtil.check_privileges()[1]
self._writable = writable
if not writable:
self.warning_permission()
def check_connection(self):
"""
Operations to check the connection to current server.
"""
thread = QSubChkConnection(self)
thread.trigger.connect(self.set_conn_status)
thread.start()
def check_update(self):
"""
Retrieve the metadata of the latest data file from a server.
"""
self.set_update_start_btns()
self.set_label_text(self.ui.labelLatestData, unicode(
_translate("Util", "Checking...", None)))
thread = QSubChkUpdate(self)
thread.trigger.connect(self.finish_update)
thread.start()
def fetch_update(self):
"""
Retrieve a new hosts data file from a server.
"""
self.set_fetch_start_btns()
thread = QSubFetchUpdate(self)
thread.prog_trigger.connect(self.set_down_progress)
thread.finish_trigger.connect(self.finish_fetch)
thread.start()
def fetch_update_after_check(self):
"""
Decide whether to retrieve a new data file from server or not after
checking update information from a mirror.
"""
if self._update["version"] == \
unicode(_translate("Util", "[Error]", None)):
self.finish_fetch(error=1)
elif self.new_version():
self.fetch_update()
else:
self.info_uptodate()
self.finish_fetch()
def export_hosts(self):
"""
Display the export dialog and get the path to save the exported hosts
file.
:return: Path to export a hosts file.
:rtype: str
"""
filename = "hosts"
if self.platform == "OS X":
filename = "/Users/" + filename
filepath = QtGui.QFileDialog.getSaveFileName(
self, _translate("Util", "Export hosts", None),
QtCore.QString(filename),
_translate("Util", "hosts File", None))
return filepath
def make_hosts(self, mode="system"):
"""
Make a new hosts file for current system.
:param mode: Operation mode for making hosts file. The valid value
could be one of `system`, `ansi`, and `utf-8`.
Default by `system`.
:type mode: str
"""
self.set_make_start_btns()
self.set_make_message(unicode(_translate(
"Util", "Building hosts file...", None)), 1)
# Avoid conflict while making hosts file
RetrieveData.disconnect_db()
self.make_mode = mode
self.set_config_bytes(mode)
thread = QSubMakeHosts(self)
thread.info_trigger.connect(self.set_make_progress)
thread.fina_trigger.connect(self.finish_make)
thread.move_trigger.connect(self.move_hosts)
thread.start()
def move_hosts(self):
"""
Move hosts file to the system path after making.
.. note:: This method is the slot responses to the move_trigger signal
from an instance of :class:`~gui._make.QSubMakeHosts` class while
making operations are finished.
.. seealso:: :attr:`move_trigger` in
:class:`~gui._make.QSubMakeHosts`.
"""
filepath = "hosts"
msg = unicode(
_translate("Util", "Copying new hosts file to\n"
"%s", None)) % self.hosts_path
self.set_make_message(msg)
try:
shutil.copy2(filepath, self.hosts_path)
except IOError:
self.warning_permission()
os.remove(filepath)
return
except OSError:
pass
msg = unicode(
_translate("Util", "Remove temporary file", None))
self.set_make_message(msg)
os.remove(filepath)
msg = unicode(
_translate("Util", "Operation completed", None))
self.set_make_message(msg)
self.info_complete()
def set_platform(self):
"""
Set the information of current operating system platform.
"""
system, hostname, path, encode, flag = CommonUtil.check_platform()
self.platform = system
self.hostname = hostname
self.hosts_path = path
self.plat_flag = flag
if encode == "win_ansi":
self.sys_eol = "\r\n"
else:
self.sys_eol = "\n"
def set_config_bytes(self, mode):
"""
Generate the module configuration byte words by the selection from
function list on the main dialog.
:param mode: Operation mode for making hosts file. The valid value
could be one of `system`, `ansi`, and `utf-8`.
.. seealso:: Method
:meth:`~gui.qdialog_d.QDialogDaemon.make_hosts`.
"""
ip_flag = self._ipv_id
selection = {}
if mode == "system":
localhost_word = {
"Windows": 0x0001, "Linux": 0x0002,
"Unix": 0x0002, "OS X": 0x0004}[self.platform]
else:
localhost_word = 0x0008
selection[0x02] = localhost_word
ch_parts = [0x08, 0x20 if ip_flag else 0x10, 0x40]
# Set customized module if exists
if os.path.isfile(self.custom):
ch_parts.insert(0, 0x04)
slices = self.slices[ip_flag]
for i, part in enumerate(ch_parts):
part_cfg = self._funcs[ip_flag][slices[i]:slices[i + 1]]
part_word = 0
for i, cfg in enumerate(part_cfg):
part_word += cfg << i
selection[part] = part_word
self.make_cfg = selection
def refresh_info(self, refresh=0):
"""
Reload the data file information and show them on the main dialog. The
information here includes both metadata and hosts module info from the
data file.
:param refresh: A flag indicating whether the information on main
dialog needs to be reloaded or not. The value could be `0` or `1`.
======= =============
refresh operation
======= =============
0 Do NOT reload
1 Reload
======= =============
:type refresh: int
"""
if refresh and RetrieveData.conn is not None:
RetrieveData.clear()
try:
RetrieveData.unpack()
RetrieveData.connect_db()
self.set_func_list(refresh)
self.refresh_func_list()
self.set_info()
except (BadZipfile, IOError, OSError):
self.warning_incorrect_datafile()
def finish_make(self, time, count):
"""
Start operations after making new hosts file.
.. note:: This method is the slot responses to the fina_trigger signal
values :attr:`time`, :attr:`count` from an instance of
:class:`~gui._make.QSubMakeHosts` class while making operations
are finished.
:param time: Total time uesd while generating the new hosts file.
:type time: str
:param count: Total number of hosts entries inserted into the new
hosts file.
:type count: int
.. seealso:: :attr:`fina_trigger` in
:class:`~gui._make.QSubMakeHosts` class.
"""
self.set_make_finish_btns()
RetrieveData.connect_db()
msg = unicode(
_translate("Util", "Notice: %i hosts entries has "
"\n been applied in %ssecs.", None))\
% (count, time)
self.set_make_message(msg)
self.set_down_progress(100, unicode(
_translate("Util", "Operation Completed Successfully!", None)))
def finish_update(self, update):
"""
Start operations after checking update.
.. note:: This method is the slot responses to the trigger signal
value :attr:`update` from an instance of
:class:`~gui._checkupdate.QSubChkUpdate` class while checking
operations are finished.
:param update: Metadata of the latest hosts data file on the server.
:type update: dict
.. seealso:: :attr:`trigger` in
:class:`~gui._checkupdate.QSubChkUpdate` class.
"""
self._update = update
self.set_label_text(self.ui.labelLatestData, update["version"])
if self._update["version"] == \
unicode(_translate("Util", "[Error]", None)):
self.set_conn_status(0)
else:
self.set_conn_status(1)
if self._down_flag:
self.fetch_update_after_check()
else:
self.set_update_finish_btns()
def finish_fetch(self, refresh=1, error=0):
"""
Start operations after downloading data file.
.. note:: This method is the slot responses to the finish_trigger
signal :attr:`refresh`, :attr:`error` from an instance of
:class:`~gui._update.QSubFetchUpdate` class while downloading is
finished.
:param refresh: An flag indicating whether the downloading progress is
successfully finished or not. Default by 1.
:type refresh: int.
:param error: An flag indicating whether the downloading
progress is successfully finished or not. Default by 0.
:type error: int
.. seealso:: :attr:`finish_trigger` in
:class:`~gui._update.QSubFetchUpdate` class.
"""
self._down_flag = 0
if error:
# Error occurred while downloading
self.set_down_progress(0, unicode(
_translate("Util", "Error", None)))
try:
os.remove(self.filename)
except:
pass
self.warning_download()
msg_title = "Warning"
msg = unicode(
_translate("Util", "Incorrect Data file!\n"
"Please use the \"Download\" key to \n"
"fetch a new data file.", None))
self.set_message(msg_title, msg)
self.set_conn_status(0)
else:
# Data file retrieved successfully
self.set_down_progress(100, unicode(
_translate("Util", "Download Complete", None)))
self.refresh_info(refresh)
self.set_fetch_finish_btns(error)
def new_version(self):
"""
Compare version of local data file to the version from the server.
:return: A flag indicating whether the local data file is up-to-date
or not.
:rtype: int
====== ============================================
Return File status
====== ============================================
1 The version of data file on server is newer.
0 The local data file is up-to-date.
====== ============================================
"""
local_ver = self._cur_ver
server_ver = self._update["version"]
local_ver = local_ver.split('.')
server_ver = server_ver.split('.')
for i, ver_num in enumerate(local_ver):
if server_ver[i] > ver_num:
return 1
return 0 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __doc__.py : Document in reST format of gui module.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
"""
.. _gui-module:
Graphical User Interface (GUI)
==============================
The following sections describe the objects and methods from the Graphical
User Interface (GUI) module of huhamhire-hosts HostsUtil. The methods to make
GUI here are based on `PyQT4 <http://pyqt.sourceforge.net/Docs/PyQt4/>`_.
HostsUtil(GUI)
--------------
.. autoclass:: gui.hostsutil.HostsUtil
:members:
.. automethod:: gui.hostsutil.HostsUtil.__del__
QDialogSlots
------------
.. autoclass:: gui.qdialog_slots.QDialogSlots
:members:
.. automethod:: gui.qdialog_slots.QDialogSlots.__init__
LangUtil
--------
.. autoclass:: gui.language.LangUtil
:members:
QDialogDaemon
-------------
.. autoclass:: gui.qdialog_d.QDialogDaemon
:members:
QDialogUI
---------
.. autoclass:: gui.qdialog_ui.QDialogUI
:members:
.. automethod:: gui.qdialog_ui.QDialogUI.__init__
QSubChkConnection
-----------------
.. autoclass:: gui._checkconn.QSubChkConnection
:members:
.. automethod:: gui._checkconn.QSubChkConnection.__init__
QSubChkUpdate
-------------
.. autoclass:: gui._checkupdate.QSubChkUpdate
:members:
.. automethod:: gui._checkupdate.QSubChkUpdate.__init__
QSubFetchUpdate
---------------
.. autoclass:: gui._update.QSubFetchUpdate
:members:
.. automethod:: gui._update.QSubFetchUpdate.__init__
QSubMakeHosts
-------------
.. autoclass:: gui._make.QSubMakeHosts
:members:
.. automethod:: gui._make.QSubMakeHosts.__init__
.. _qt-resource-modules:
Resource Modules
----------------
All Qt Project files and resource files are convented into python Resource
Modules in order to be used by `Hosts Setup Utility`. Including:
* util_ui.py: :class:`~gui.util_ui.Ui_Util` class organizing layout of the
main dialog for `Hosts Setup Utility`. This file is translated from the UI
project file `util_ui.ui`.
.. seealso:: `util_ui.ui` in :ref:`QT Project Files <qt-project-files>`.
* util_rc.py: Images resources used by the main dialog.
* style_rc.py: Images resources used by the default `Qt Stylesheet`.
.. seealso:: :ref:`QT Stylesheet <qt-stylesheet>`.
.. seealso:: `_pyuic4.py` in :ref:`QT Project Scripts <qt-project-scripts>`.
.. _qt-project-files:
QT Project Files
----------------
Qt Project Files and Qt resources files used to design the Qt user interface
are provided in the "`gui/pyqt/`" directory, including:
* util.pro: QT Project file containing configuration of current project.
* util.qrc: Resource file for main dialog generated by `Qt Designer`.
* style.qrc: Resource file for the default `Qt Style Sheet` generated by
`Qt Designer`.
.. seealso:: :ref:`QT Stylesheet <qt-stylesheet>`.
* util_ui.ui: UI project file for the main dialog designed with
`Qt designer`.
.. seealso::
`Qt Designer <http://qt-project.org/doc/qt-4.8/designer-manual.html>`_.
.. _qt-project-scripts:
QT Project Scripts
------------------
Scripts to help managing the Qt project are also provided in the "`gui/pyqt/`"
directory:
* _pylupdate4.py: Contains tools to update the language files for UI.
.. note:: This script would parse files declared as `SOURCES` in the Qt
project file (`gui/pyqt/util.pro`), and generate/update language files
declared as `TRANSLATIONS` in the Qt project file.
.. seealso:: :ref:`Language Files <qt-language-files>`.
* _pyuic4.py: Tools used to update the `UI module` and `Resource Modules`
from `UI file` and `Resources Files` designed with `Qt designer`.
.. seealso:: :ref:`Resource Modules <qt-resource-modules>`.
.. _qt-language-files:
Language Files
--------------
Since this GUI module of `Hosts Setup Utility` is based on :mod:`PyQt4`,
it is very easy to internationalization this utility with the ways Qt
provided.
The `Qt Language Files` are stored in "`gui/lang/`" directory with file
suffixes "`.qm`" and "`.ts`".
.. note:: **File Types**
`Hosts Setup Utility` makes use of two kinds of files:
* TS: `translation source files`
are human-readable XML files containing source phrases and their
translations. These files are usually created and updated by `lupdate`
and are specific to an application.
* QM: `Qt message files`
are binary files that contain translations used by an application at
run-time. These files are generated by lrelease, but can also be
generated by `Qt Linguist`.
.. note:: You can use `_pylupdate4.py` provided in "`gui/pyqt/`" directory to
generate/update `TS` files with the Qt project file. And then use
`Qt Linguist` to make a `QM` file.
.. seealso:: `_pylupdate4.py` in
:ref:`QT Project Scripts<qt-project-scripts>`.
.. seealso:: `Qt Linguist
<http://qt-project.org/doc/qt-4.8/linguist-translators.html>`_.
.. _qt-stylesheet:
QT Stylesheet
-------------
With the GUI module of `Hosts Setup Utility` is based on :mod:`PyQt4`, Qt
style sheets are also supported to customize the appearance of GUI widgets.
The `Qt Style Sheets` are stored in "`gui/theme/`" directory with file suffix
"`.qss`".
You can create yourown Qt style sheet and use it in method
:meth:`~gui.qdialog_ui.QDialogUI.set_stylesheet` to customize new appearance
of GUI widgets.
.. seealso:: Method :meth:`~gui.qdialog_ui.QDialogUI.set_stylesheet` in
:class:`~gui.qdialog_ui.QDialogUI` class.
.. note:: Qt Style Sheets are a powerful mechanism that allows you to
customize the appearance of widgets, in addition to what is already
possible by subclassing QStyle. The concepts, terminology, and syntax
of Qt Style Sheets are heavily inspired by HTML Cascading Style Sheets
(CSS) but adapted to the world of widgets.
.. seealso::
`QT Stylesheet <http://qt-project.org/doc/qt-4.8/stylesheet.html>`_.
""" | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# hostsutil.py : Main entrance to GUI module of Hosts Setup Utility.
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import sys
from zipfile import BadZipfile
from qdialog_slots import QDialogSlots
sys.path.append("..")
from util import RetrieveData, CommonUtil
# Path to store language files
LANG_DIR = "./gui/lang/"
class HostsUtil(QDialogSlots):
"""
HostsUtil class is the main entrance to the Graphical User Interface (GUI)
module of `Hosts Setup Utility`. This class contains methods to launch the
main dialog of this utility.
.. note:: This class is subclass of
:class:`~gui.qdialog_slots.QDialogSlots` class.
Typical usage to start a GUI session::
import gui
util = gui.HostsUtil()
util.start()
:ivar int init_flag: Times of the main dialog being initialized. This
value would be referenced for translator to set the language of the
main dialog.
:ivar str filename: Filename of the hosts data file containing data to
make hosts files from. Default by "`hostslist.data`".
:ivar str infofile: Filename of the info file containing metadata of the
hosts data file formatted in JSON. Default by "`hostslist.json`".
.. seealso:: :attr:`filename` and :attr:`infofile` in
:class:`~tui.curses_ui.CursesUI` class.
"""
init_flag = 0
# Data file related configuration
filename = "hostslist.data"
infofile = "hostsinfo.json"
def __init__(self):
super(HostsUtil, self).__init__()
def __del__(self):
"""
Clear up the temporary data file while TUI session is finished.
"""
try:
RetrieveData.clear()
except:
pass
def start(self):
"""
Start the GUI session.
.. note:: This method is the trigger to launch a GUI session of
`Hosts Setup Utility`.
"""
if not self.init_flag:
self.init_main()
self.show()
sys.exit(self.app.exec_())
def init_main(self):
"""
Set up the elements on the main dialog. Check the environment of
current operating system and current session.
* Load server list from a configuration file under working directory.
* Try to load the hosts data file under working directory if it
exists.
.. note:: IF hosts data file does not exists correctly in current
working directory, a warning message box would popup. And
operations to change the hosts file on current system could be
done only until a new data file has been downloaded.
.. seealso:: Method :meth:`~tui.hostsutil.HostsUtil.__init__` in
:class:`~tui.hostsutil.HostsUtil` class.
"""
self.ui.SelectMirror.clear()
self.set_version()
# Set mirrors
self.mirrors = CommonUtil.set_network("network.conf")
self.set_mirrors()
# Read data file and set function list
try:
RetrieveData.unpack()
RetrieveData.connect_db()
self.set_func_list(1)
self.refresh_func_list()
self.set_info()
except IOError:
self.warning_no_datafile()
except BadZipfile:
self.warning_incorrect_datafile()
# Check if current session have root privileges
self.check_writable()
self.init_flag += 1
if __name__ == "__main__":
HostsUtlMain = HostsUtil()
HostsUtlMain.start()
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# qdialog_ui.py : Draw the Graphical User Interface.
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
from PyQt4 import QtCore, QtGui
import sys
sys.path.append("..")
from util import RetrieveData, CommonUtil
from __version__ import __version__, __release__
from language import LangUtil
from util_ui import Ui_Util, _translate, _fromUtf8
# Path to store language files
LANG_DIR = "./gui/lang/"
class QDialogUI(QtGui.QDialog, object):
"""
CursesUI class contains methods to draw the Graphical User Interface (GUI)
of Hosts Setup Utility. The methods to make GUI here are based on
`PyQT4 <http://pyqt.sourceforge.net/Docs/PyQt4/>`_.
.. note:: This class is subclass of :class:`QtGui.QDialog` class
and :class:`object` class.
:ivar str _cur_ver: Current version of local hosts data file.
:ivar QtCore.QTranslator _trans: An instance of
:class:`QtCore.QTranslator` object indicating the current UI language
setting.
:ivar QtGui.QApplication app: An instance of :class:`QtGui.QApplication`
object to launch the Qt application.
:ivar list mirrors: Dictionaries containing `tag`, `test url`, and
`update url` of mirror servers.
:ivar str platform: Platform of current operating system. The value could
be `Windows`, `Linux`, `Unix`, `OS X`, and of course `Unknown`.
:ivar bool plat_flag: A flag indicating whether current operating system
is supported or not.
:ivar object ui: Form implementation declares layout of the main dialog
which is generated from a UI file designed by `Qt Designer`.
:ivar str custom: File name of User Customized Hosts File. Customized
hosts would be able to select if this file exists. The default file
name is ``custom.hosts``.
.. seealso:: :ref:`User Customized Hosts<intro-customize>`.
"""
_cur_ver = ""
_trans = None
app = None
mirrors = []
platform = ''
plat_flag = True
ui = None
custom = "custom.hosts"
def __init__(self):
"""
Initialize a new instance of this class. Set the UI object and current
translator of the main dialog.
"""
self.app = QtGui.QApplication(sys.argv)
super(QDialogUI, self).__init__()
self.ui = Ui_Util()
self.ui.setupUi(self)
self.set_style()
self.set_stylesheet()
# Set default UI language
trans = QtCore.QTranslator()
trans.load(LANG_DIR + "en_US")
self._trans = trans
self.app.installTranslator(trans)
self.set_languages()
def set_stylesheet(self):
"""
Set the style sheet of main dialog.
.. seealso:: :ref:`QT Stylesheet<qt-stylesheet>`.
"""
with open("./gui/theme/default.qss", "r") as qss:
self.app.setStyleSheet(qss.read())
def set_style(self):
"""
Set the main dialog with a window style depending on the os platform.
"""
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
system = self.platform
if system == "Windows":
pass
elif system == "Linux":
# Set window style for sudo users.
QtGui.QApplication.setStyle(
QtGui.QStyleFactory.create("Cleanlooks"))
elif system == "OS X":
pass
def set_languages(self):
"""
Set optional language selection items in the SelectLang widget.
"""
self.ui.SelectLang.clear()
langs = LangUtil.language
langs_not_found = []
for locale in langs:
if not os.path.isfile(LANG_DIR + locale + ".qm"):
langs_not_found.append(locale)
for locale in langs_not_found:
langs.pop(locale)
LangUtil.language = langs
if len(langs) <= 1:
self.ui.SelectLang.setEnabled(False)
# Block the signal while set the language selecions.
self.ui.SelectLang.blockSignals(True)
sys_locale = LangUtil.get_locale()
if sys_locale not in langs.keys():
sys_locale = "en_US"
for i, locale in enumerate(sorted(langs.keys())):
if sys_locale == locale:
select = i
lang = langs[locale]
self.ui.SelectLang.addItem(_fromUtf8(""))
self.ui.SelectLang.setItemText(i, lang)
self.ui.SelectLang.blockSignals(False)
self.ui.SelectLang.setCurrentIndex(select)
def set_mirrors(self):
"""
Set optional server list.
"""
for i, mirror in enumerate(self.mirrors):
self.ui.SelectMirror.addItem(_fromUtf8(""))
self.ui.SelectMirror.setItemText(
i, _translate("Util", mirror["tag"], None))
self.set_platform_label()
def set_label_color(self, label, color):
"""
Set the :attr:`color` of a :attr:`label`.
:param label: Label on the main dialog.
:type: :class:`PyQt4.QtGui.QLabel`
:param color: Color to be set on the label.
:type color: str
"""
if color == "GREEN":
rgb = "#37b158"
elif color == "RED":
rgb = "#e27867"
elif color == "BLACK":
rgb = "#b1b1b1"
else:
rgb = "#ffffff"
label.setStyleSheet("QLabel {color: %s}" % rgb)
def set_label_text(self, label, text):
"""
Set the :attr:`text` of a :attr:`label`.
:param label: Label on the main dialog.
:type: :class:`PyQt4.QtGui.QLabel`
:param text: Message to be set on the label.
:type text: unicode
"""
label.setText(_translate("Util", text, None))
def set_conn_status(self, status):
"""
Set the information of connection status to the current server
selected.
"""
if status == -1:
self.set_label_color(self.ui.labelConnStat, "BLACK")
self.set_label_text(self.ui.labelConnStat, unicode(
_translate("Util", "Checking...", None)))
elif status in [0, 1]:
if status:
color, stat = "GREEN", unicode(_translate(
"Util", "[OK]", None))
else:
color, stat = "RED", unicode(_translate(
"Util", "[Failed]", None))
self.set_label_color(self.ui.labelConnStat, color)
self.set_label_text(self.ui.labelConnStat, stat)
def set_version(self):
version = "".join(['v', __version__, ' ', __release__])
self.set_label_text(self.ui.VersionLabel, version)
def set_info(self):
"""
Set the information of the current local data file.
"""
info = RetrieveData.get_info()
ver = info["Version"]
self._cur_ver = ver
self.set_label_text(self.ui.labelVersionData, ver)
build = info["Buildtime"]
build = CommonUtil.timestamp_to_date(build)
self.set_label_text(self.ui.labelReleaseData, unicode(build))
def set_down_progress(self, progress, message):
"""
Set :attr:`progress` position of the progress bar with a
:attr:`message`.
:param progress: Progress position to be set on the progress bar.
:type progress: int
:param message: Message to be set on the progress bar.
:type message: str
"""
self.ui.Prog.setProperty("value", progress)
self.set_conn_status(1)
self.ui.Prog.setFormat(message)
def set_platform_label(self):
"""
Set the information of the label indicating current operating system
platform.
"""
color = "GREEN" if self.plat_flag else "RED"
self.set_label_color(self.ui.labelOSStat, color)
self.set_label_text(self.ui.labelOSStat, "[%s]" % self.platform)
def set_func_list(self, new=0):
"""
Draw the function list and decide whether to load the default
selection configuration or not.
:param new: A flag indicating whether to load the default selection
configuration or not. Default value is `0`.
=== ===================
new Operation
=== ===================
0 Use user config.
1 Use default config.
=== ===================
:type new: int
"""
self.ui.Functionlist.clear()
self.ui.FunctionsBox.setTitle(_translate(
"Util", "Functions", None))
if new:
for ip in range(2):
choice, defaults, slices = RetrieveData.get_choice(ip)
if os.path.isfile(self.custom):
choice.insert(0, [4, 1, 0, "customize"])
defaults[0x04] = [1]
for i in range(len(slices)):
slices[i] += 1
slices.insert(0, 0)
self.choice[ip] = choice
self.slices[ip] = slices
funcs = []
for func in choice:
if func[1] in defaults[func[0]]:
funcs.append(1)
else:
funcs.append(0)
self._funcs[ip] = funcs
def set_list_item_unchecked(self, item_id):
"""
Set a specified item to become unchecked in the function list.
:param item_id: Index number of a specified item in the function list.
:type: int
"""
self._funcs[self._ipv_id][item_id] = 0
item = self.ui.Functionlist.item(item_id)
item.setCheckState(QtCore.Qt.Unchecked)
def refresh_func_list(self):
"""
Refresh the items in the function list by user settings.
"""
ip_flag = self._ipv_id
self.ui.Functionlist.clear()
for f_id, func in enumerate(self.choice[self._ipv_id]):
item = QtGui.QListWidgetItem()
if self._funcs[ip_flag][f_id] == 1:
check = QtCore.Qt.Checked
else:
check = QtCore.Qt.Unchecked
item.setCheckState(check)
item.setText(_translate("Util", func[3], None))
self.ui.Functionlist.addItem(item)
def set_make_progress(self, mod_name, mod_num):
"""
Start operations to show progress while making hosts file.
.. note:: This method is the slot responses to the info_trigger signal
:attr:`mod_name`, :attr:`mod_num` from an instance of
:class:`~gui._make.QSubMakeHosts` class while making operations
are proceeding.
:param mod_name: Tag of a specified hosts module in current progress.
:type mod_name: str
:param mod_num: Number of current module in the operation sequence.
:type mod_num: int
.. seealso:: :attr:`info_trigger` in
:class:`~gui._make.QSubMakeHosts` class.
"""
total_mods_num = self._funcs[self._ipv_id].count(1) + 1
prog = 100 * mod_num / total_mods_num
self.ui.Prog.setProperty("value", prog)
module = unicode(_translate("Util", mod_name, None))
message = unicode(_translate(
"Util", "Applying module: %s(%s/%s)", None)
) % (module, mod_num, total_mods_num)
self.ui.Prog.setFormat(message)
self.set_make_message(message)
def set_message(self, title, message):
"""
Show a message box with a :attr:`message` and a :attr:`title`.
:param title: Title of the message box to be displayed.
:type title: unicode
:param message: Message in the message box.
:type message: unicode
"""
self.ui.FunctionsBox.setTitle(_translate("Util", title, None))
self.ui.Functionlist.clear()
item = QtGui.QListWidgetItem()
item.setText(message)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.ui.Functionlist.addItem(item)
def set_make_message(self, message, start=0):
"""
List message for the current operating progress while making the new
hosts file in function list.
:param message: Message to be displayed in the function list.
:type message: unicode
:param start: A flag indicating whether the message is the first one
in the making progress or not. Default value is `0`.
===== ==============
start Status
===== ==============
0 Not the first.
1 First.
===== ==============
:type start: int
"""
if start:
self.ui.FunctionsBox.setTitle(_translate(
"Util", "Progress", None))
self.ui.Functionlist.clear()
item = QtGui.QListWidgetItem()
item.setText("- " + message)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.ui.Functionlist.addItem(item)
def warning_permission(self):
"""
Show permission error warning message box.
"""
QtGui.QMessageBox.warning(
self, _translate("Util", "Warning", None),
_translate("Util",
"You do not have permissions to change the \n"
"hosts file.\n"
"Please run this program as Administrator/root\n"
"so it can modify your hosts file."
, None))
def warning_download(self):
"""
Show download error warning message box.
"""
QtGui.QMessageBox.warning(
self, _translate("Util", "Warning", None),
_translate("Util",
"Error retrieving data from the server.\n"
"Please try another server.", None))
def warning_incorrect_datafile(self):
"""
Show incorrect data file warning message box.
"""
msg_title = "Warning"
msg = unicode(_translate("Util",
"Incorrect Data file!\n"
"Please use the \"Download\" key to \n"
"fetch a new data file.", None))
self.set_message(unicode(msg_title), msg)
self.ui.ButtonApply.setEnabled(False)
self.ui.ButtonANSI.setEnabled(False)
self.ui.ButtonUTF.setEnabled(False)
def warning_no_datafile(self):
"""
Show no data file warning message box.
"""
msg_title = "Warning"
msg = unicode(_translate("Util",
"Data file not found!\n"
"Please use the \"Download\" key to \n"
"fetch a new data file.", None))
self.set_message(unicode(msg_title), msg)
self.ui.ButtonApply.setEnabled(False)
self.ui.ButtonANSI.setEnabled(False)
self.ui.ButtonUTF.setEnabled(False)
def question_apply(self):
"""
Show confirm question message box before applying hosts file.
:return: A flag indicating whether user has accepted to continue the
operations or not.
====== =========
return Operation
====== =========
True Continue
False Cancel
====== =========
:rtype: bool
"""
msg_title = unicode(_translate("Util", "Notice", None))
msg = unicode(_translate("Util",
"Are you sure you want to apply changes \n"
"to the hosts file on your system?\n\n"
"This operation could not be reverted if \n"
"you have not made a backup of your \n"
"current hosts file.", None))
choice = QtGui.QMessageBox.question(
self, msg_title, msg,
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.No
)
if choice == QtGui.QMessageBox.Yes:
return True
else:
return False
def info_uptodate(self):
"""
Draw data file is up-to-date message box.
"""
QtGui.QMessageBox.information(
self, _translate("Util", "Notice", None),
_translate("Util", "Data file is up-to-date.", None))
def info_complete(self):
"""
Draw operation complete message box.
"""
QtGui.QMessageBox.information(
self, _translate("Util", "Complete", None),
_translate("Util", "Operation completed", None))
def set_make_start_btns(self):
"""
Set button status while making hosts operations started.
"""
self.ui.Functionlist.setEnabled(False)
self.ui.SelectIP.setEnabled(False)
self.ui.ButtonCheck.setEnabled(False)
self.ui.ButtonUpdate.setEnabled(False)
self.ui.ButtonApply.setEnabled(False)
self.ui.ButtonANSI.setEnabled(False)
self.ui.ButtonUTF.setEnabled(False)
self.ui.ButtonExit.setEnabled(False)
def set_make_finish_btns(self):
"""
Set button status while making hosts operations finished.
"""
self.ui.Functionlist.setEnabled(True)
self.ui.SelectIP.setEnabled(True)
self.ui.ButtonCheck.setEnabled(True)
self.ui.ButtonUpdate.setEnabled(True)
self.ui.ButtonApply.setEnabled(False)
self.ui.ButtonANSI.setEnabled(False)
self.ui.ButtonUTF.setEnabled(False)
self.ui.ButtonExit.setEnabled(True)
def set_update_click_btns(self):
"""
Set button status while `CheckUpdate` button clicked.
"""
self.ui.ButtonApply.setEnabled(True)
self.ui.ButtonANSI.setEnabled(True)
self.ui.ButtonUTF.setEnabled(True)
def set_update_start_btns(self):
"""
Set button status while operations to check update of hosts data file
started.
"""
self.ui.SelectMirror.setEnabled(False)
self.ui.ButtonCheck.setEnabled(False)
self.ui.ButtonUpdate.setEnabled(False)
def set_update_finish_btns(self):
"""
Set button status while operations to check update of hosts data file
finished.
"""
self.ui.SelectMirror.setEnabled(True)
self.ui.ButtonCheck.setEnabled(True)
self.ui.ButtonUpdate.setEnabled(True)
def set_fetch_click_btns(self):
"""
Set button status while `FetchUpdate` button clicked.
"""
self.ui.Functionlist.setEnabled(False)
self.ui.ButtonApply.setEnabled(False)
self.ui.ButtonANSI.setEnabled(False)
self.ui.ButtonUTF.setEnabled(False)
def set_fetch_start_btns(self):
"""
Set button status while operations to retrieve hosts data file
started.
"""
self.ui.SelectMirror.setEnabled(False)
self.ui.ButtonCheck.setEnabled(False)
self.ui.ButtonUpdate.setEnabled(False)
self.ui.ButtonApply.setEnabled(False)
self.ui.ButtonANSI.setEnabled(False)
self.ui.ButtonUTF.setEnabled(False)
self.ui.ButtonExit.setEnabled(False)
def set_fetch_finish_btns(self, error=0):
"""
Set button status while operations to retrieve hosts data file
finished.
:param error: A flag indicating if error occurs while retrieving hosts
data file from the server.
:type error: int
"""
if error:
self.ui.ButtonApply.setEnabled(False)
self.ui.ButtonANSI.setEnabled(False)
self.ui.ButtonUTF.setEnabled(False)
else:
self.ui.ButtonApply.setEnabled(True)
self.ui.ButtonANSI.setEnabled(True)
self.ui.ButtonUTF.setEnabled(True)
self.ui.Functionlist.setEnabled(True)
self.ui.SelectMirror.setEnabled(True)
self.ui.ButtonCheck.setEnabled(True)
self.ui.ButtonUpdate.setEnabled(True)
self.ui.ButtonExit.setEnabled(True)
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __init__.py : Declare modules to be called in gui module.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
from hostsutil import HostsUtil
__all__ = ["HostsUtil"]
| Python |
# -*- coding: utf-8 -*-
# Resource object code
#
# Created: 周三 1月 22 13:03:07 2014
# by: The Resource Compiler for PyQt (Qt v4.8.5)
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore
qt_resource_data = "\
\x00\x00\x01\x57\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x09\x08\x06\x00\x00\x00\xe0\x91\x06\x10\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0e\xc4\x00\x00\x0e\xc4\
\x01\x95\x2b\x0e\x1b\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x7a\
\x25\x00\x00\x80\x83\x00\x00\xf9\xff\x00\x00\x80\xe9\x00\x00\x75\
\x30\x00\x00\xea\x60\x00\x00\x3a\x98\x00\x00\x17\x6f\x92\x5f\xc5\
\x46\x00\x00\x00\xdd\x49\x44\x41\x54\x78\xda\x5c\x8e\xb1\x4e\x84\
\x40\x18\x84\x67\xef\x4c\x2c\xc8\xd9\x2c\x0d\x58\x50\x1b\x0b\xc3\
\xfa\x24\x77\xbd\x0d\x85\x4f\x40\x0b\xbb\xcb\x3b\xd0\x68\x41\x72\
\xc5\xd2\x28\x4f\x02\xcf\xb1\x97\x40\x61\xd4\xc2\xc4\x62\x2c\xbc\
\x4d\xd0\x49\xfe\xbf\xf8\x32\xff\x3f\x23\x48\xc2\x5a\x3b\x00\x80\
\xd6\xfa\x80\xb3\xac\xb5\x03\x49\x18\x63\x0e\x5b\x21\xc4\x90\xe7\
\xf9\x3e\x49\x92\x9b\xbe\xef\xef\xca\xb2\x7c\xf5\xde\xbf\x04\xe6\
\x9c\xbb\xbd\x20\xf9\x19\xae\x95\x52\xfb\x2c\xcb\xbe\xa5\x94\x01\
\x81\xe4\x9b\x38\xbf\x3c\x2a\xa5\x1e\xf0\x4f\xe3\x38\x3e\x37\x4d\
\xf3\x28\x48\x02\x00\xba\xae\x7b\x97\x52\xee\x82\x61\x59\x96\x8f\
\xa2\x28\xae\x00\x60\x03\x00\xc6\x98\xe3\xda\x00\x00\x71\x1c\xef\
\xb4\xd6\x4f\x00\xb0\x05\xf0\x27\x6a\x9e\x67\x44\x51\x04\x00\x48\
\xd3\xf4\xde\x39\x77\xbd\x21\xf9\xb5\xea\x70\x6a\xdb\xf6\x72\x9a\
\xa6\xd3\xaa\xf8\xef\xaa\xeb\xda\x57\x55\xe5\x49\x22\xcc\x9a\xfd\
\x0c\x00\x24\xab\x6e\xfa\x96\x21\xfc\xb8\x00\x00\x00\x00\x49\x45\
\x4e\x44\xae\x42\x60\x82\
\x00\x00\x03\xf0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x07\x00\x00\x00\x05\x08\x04\x00\x00\x00\x23\x93\x3e\x53\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x03\x18\x69\x43\x43\x50\x50\x68\x6f\
\x74\x6f\x73\x68\x6f\x70\x20\x49\x43\x43\x20\x70\x72\x6f\x66\x69\
\x6c\x65\x00\x00\x78\xda\x63\x60\x60\x9e\xe0\xe8\xe2\xe4\xca\x24\
\xc0\xc0\x50\x50\x54\x52\xe4\x1e\xe4\x18\x19\x11\x19\xa5\xc0\x7e\
\x9e\x81\x8d\x81\x99\x81\x81\x81\x81\x81\x21\x31\xb9\xb8\xc0\x31\
\x20\xc0\x87\x81\x81\x81\x21\x2f\x3f\x2f\x95\x01\x15\x30\x32\x30\
\x7c\xbb\xc6\xc0\xc8\xc0\xc0\xc0\x70\x59\xd7\xd1\xc5\xc9\x95\x81\
\x34\xc0\x9a\x5c\x50\x54\xc2\xc0\xc0\x70\x80\x81\x81\xc1\x28\x25\
\xb5\x38\x99\x81\x81\xe1\x0b\x03\x03\x43\x7a\x79\x49\x41\x09\x03\
\x03\x63\x0c\x03\x03\x83\x48\x52\x76\x41\x09\x03\x03\x63\x01\x03\
\x03\x83\x48\x76\x48\x90\x33\x03\x03\x63\x0b\x03\x03\x13\x4f\x49\
\x6a\x45\x09\x03\x03\x03\x83\x73\x7e\x41\x65\x51\x66\x7a\x46\x89\
\x82\xa1\xa5\xa5\xa5\x82\x63\x4a\x7e\x52\xaa\x42\x70\x65\x71\x49\
\x6a\x6e\xb1\x82\x67\x5e\x72\x7e\x51\x41\x7e\x51\x62\x49\x6a\x0a\
\x03\x03\x03\xd4\x0e\x06\x06\x06\x06\x5e\x97\xfc\x12\x05\xf7\xc4\
\xcc\x3c\x05\x23\x03\x55\x06\x2a\x83\x88\xc8\x28\x05\x08\x0b\x11\
\x3e\x08\x31\x04\x48\x2e\x2d\x2a\x83\x07\x25\x03\x83\x00\x83\x02\
\x83\x01\x83\x03\x43\x00\x43\x22\x43\x3d\xc3\x02\x86\xa3\x0c\x6f\
\x18\xc5\x19\x5d\x18\x4b\x19\x57\x30\xde\x63\x12\x63\x0a\x62\x9a\
\xc0\x74\x81\x59\x98\x39\x92\x79\x21\xf3\x1b\x16\x4b\x96\x0e\x96\
\x5b\xac\x7a\xac\xad\xac\xf7\xd8\x2c\xd9\xa6\xb1\x7d\x63\x0f\x67\
\xdf\xcd\xa1\xc4\xd1\xc5\xf1\x85\x33\x91\xf3\x02\x97\x23\xd7\x16\
\x6e\x4d\xee\x05\x3c\x52\x3c\x53\x79\x85\x78\x27\xf1\x09\xf3\x4d\
\xe3\x97\xe1\x5f\x2c\xa0\x23\xb0\x43\xd0\x55\xf0\x8a\x50\xaa\xd0\
\x0f\xe1\x5e\x11\x15\x91\xbd\xa2\xe1\xa2\x5f\xc4\x26\x89\x1b\x89\
\x5f\x91\xa8\x90\x94\x93\x3c\x26\x95\x2f\x2d\x2d\x7d\x42\xa6\x4c\
\x56\x5d\xf6\x96\x5c\x9f\xbc\x8b\xfc\x1f\x85\xad\x8a\x85\x4a\x7a\
\x4a\x6f\x95\xd7\xaa\x14\xa8\x9a\xa8\xfe\x54\x3b\xa8\xde\xa5\x11\
\xaa\xa9\xa4\xf9\x41\xeb\x80\xf6\x24\x9d\x54\x5d\x2b\x3d\x41\xbd\
\x57\xfa\x47\x0c\x16\x18\xd6\x1a\xc5\x18\xdb\x9a\xc8\x9b\x32\x9b\
\xbe\x34\xbb\x60\xbe\xd3\x62\x89\xe5\x04\xab\x3a\xeb\x5c\x9b\x38\
\xdb\x40\x3b\x57\x7b\x6b\x07\x63\x47\x1d\x27\x35\x67\x25\x17\x05\
\x57\x79\x37\x05\x77\x65\x0f\x75\x4f\x5d\x2f\x13\x6f\x1b\x1f\x77\
\xdf\x60\xbf\x04\xff\xfc\x80\xfa\xc0\x89\x41\x4b\x83\x77\x85\x5c\
\x0c\x7d\x19\xce\x14\x21\x17\x69\x15\x15\x11\x5d\x11\x33\x33\x76\
\x4f\xdc\x83\x04\xb6\x44\xdd\xa4\xb0\xe4\x86\x94\x35\xa9\x37\xd3\
\x39\x32\x2c\x32\x33\xb3\xe6\x66\x5f\xcc\x65\xcf\xb3\xcf\xaf\x28\
\xd8\x54\xf8\xae\x58\xbb\x24\xab\x74\x55\xd9\x9b\x0a\xfd\xca\x92\
\xaa\x5d\x35\x8c\xb5\x5e\x75\x53\xeb\x1f\x36\xea\x35\xd5\x34\x9f\
\x6d\x95\x6b\x2b\x6c\x3f\xda\x29\xdd\x55\xd4\x7d\xba\x57\xb5\xaf\
\xb1\xff\xee\x44\x9b\x49\xb3\x27\xff\x9d\x1a\x3f\xed\xf0\x0c\x8d\
\x99\xfd\xb3\xbe\xcf\x49\x98\x7b\x7a\xbe\xf9\x82\xa5\x8b\x44\x16\
\xb7\x2e\xf9\xb6\x2c\x73\xf9\xbd\x95\x21\xab\x4e\xaf\x71\x59\xbb\
\x6f\xbd\xe5\x86\x6d\x9b\x4c\x36\x6f\xd9\x6a\xb2\x6d\xfb\x0e\xab\
\x9d\xfb\x77\xbb\xee\x39\xbb\x2f\x6c\xff\x83\x83\x39\x87\x7e\x1e\
\x69\x3f\x26\x7e\x7c\xc5\x49\xeb\x53\xe7\xce\x24\x9f\xfd\x75\x7e\
\xd2\x45\xed\x4b\x47\xaf\x24\x5e\xfd\x77\x7d\xce\x4d\x9b\x5b\x77\
\xef\xd4\xdf\x53\xbe\x7f\xe2\x61\xde\x63\xb1\x27\xfb\x9f\x65\xbe\
\x10\x79\x79\xf0\x75\xfe\x5b\xf9\x77\x17\x3e\x34\x7d\x32\xfd\xfc\
\xea\xeb\x82\xef\xe1\x3f\x05\x7e\x9d\xfa\xd3\xfa\xcf\xf1\xff\x7f\
\x00\x0d\x00\x0f\x34\xfa\x96\xf1\x5d\x00\x00\x00\x20\x63\x48\x52\
\x4d\x00\x00\x7a\x25\x00\x00\x80\x83\x00\x00\xf9\xff\x00\x00\x80\
\xe9\x00\x00\x75\x30\x00\x00\xea\x60\x00\x00\x3a\x98\x00\x00\x17\
\x6f\x92\x5f\xc5\x46\x00\x00\x00\x52\x49\x44\x41\x54\x78\xda\x62\
\x58\xf5\xe9\xca\x3f\x18\x5c\xfe\x9e\x21\xd3\xff\xc4\x8f\xab\xbf\
\xaf\xfe\xbe\xfa\xfb\xd0\x97\x68\x63\x86\xff\x0c\x85\x6b\xf7\x7e\
\xdc\xfb\x71\xf3\x87\xcc\xbc\xff\x0c\x0c\xff\x19\x18\x98\x73\xce\
\xce\xbd\x1f\x39\xff\x3f\xc3\x7f\x06\x86\xff\x0c\xff\x19\x14\xdd\
\x2c\xb6\xfe\x67\xf8\xcf\xf0\x9f\x01\x30\x00\x6a\x5f\x2c\x67\x74\
\xda\xec\xfb\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
"
qt_resource_name = "\
\x00\x03\
\x00\x00\x78\xa3\
\x00\x71\
\x00\x73\x00\x73\
\x00\x03\
\x00\x00\x78\xc3\
\x00\x72\
\x00\x65\x00\x73\
\x00\x03\
\x00\x00\x70\x37\
\x00\x69\
\x00\x6d\x00\x67\
\x00\x05\
\x00\x7a\xc0\x25\
\x00\x73\
\x00\x74\x00\x79\x00\x6c\x00\x65\
\x00\x0c\
\x04\x56\x23\x67\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0e\
\x04\xa2\xfc\xa7\
\x00\x64\
\x00\x6f\x00\x77\x00\x6e\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x2e\x00\x70\x00\x6e\x00\x67\
"
qt_resource_struct = "\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x0c\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x18\x00\x02\x00\x00\x00\x01\x00\x00\x00\x04\
\x00\x00\x00\x24\x00\x02\x00\x00\x00\x02\x00\x00\x00\x05\
\x00\x00\x00\x34\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x00\x52\x00\x00\x00\x00\x00\x01\x00\x00\x01\x5b\
"
def qInitResources():
QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
def qCleanupResources():
QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
qInitResources()
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _checkupdate.py: Check update info of the latest data file.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import json
import socket
import urllib
from PyQt4 import QtCore
from util_ui import _translate
class QSubChkUpdate(QtCore.QThread):
"""
QSubChkConnection is a subclass of :class:`PyQt4.QtCore.QThread`. This
class contains methods to retrieve the metadata of the latest hosts data
file.
.. inheritance-diagram:: gui._checkupdate.QSubChkUpdate
:parts: 1
.. note:: The instance of this class should be created in an individual
thread. And an instance of class should be set as :attr:`parent`
here.
:ivar PyQt4.QtCore.pyqtSignal trigger: An instance of
:class:`PyQt4.QtCore.pyqtSignal` to emit signal to the main dialog
which indicates current status.
.. note:: The signal :attr:`trigger` should be a dictionary (`dict`)
containing metadata of the latest hosts data file.
.. seealso:: Method :meth:`~gui.qdialog_d.QDialogDaemon.finish_update`
in :class:`~gui.qdialog_d.QDialogDaemon` class.
"""
trigger = QtCore.pyqtSignal(dict)
def __init__(self, parent):
"""
Initialize a new instance of this class. Retrieve mirror settings from
the main dialog to check the update information.
:param parent: An instance of :class:`~gui.qdialog_d.QDialogDaemon`
class to fetch settings from.
:type parent: :class:`~gui.qdialog_d.QDialogDaemon`
.. warning:: :attr:`parent` MUST NOT be set as `None`.
"""
super(QSubChkUpdate, self).__init__(parent)
self.url = parent.mirrors[parent.mirror_id]["update"] + parent.infofile
def run(self):
"""
Start operations to retrieve the metadata of the latest hosts data
file.
"""
try:
socket.setdefaulttimeout(5)
urlobj = urllib.urlopen(self.url)
j_str = urlobj.read()
urlobj.close()
info = json.loads(j_str)
self.trigger.emit(info)
except:
info = {"version": unicode(_translate("Util", "[Error]", None))}
self.trigger.emit(info) | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _make.py: Make a new hosts file.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import time
from PyQt4 import QtCore
import sys
sys.path.append("..")
from util import RetrieveData
from util import MakeHosts
class QSubMakeHosts(QtCore.QThread, MakeHosts):
"""
QSubMakeHosts is a subclass of :class:`PyQt4.QtCore.QThread` and class
:class:`~util.makehosts.MakeHosts`. This class contains methods to make a
new hosts file for client.
.. inheritance-diagram:: gui._make.QSubMakeHosts
:parts: 1
.. note:: The instance of this class should be created in an individual
thread. And an instance of class should be set as :attr:`parent`
here.
:ivar PyQt4.QtCore.pyqtSignal info_trigger: An instance of
:class:`PyQt4.QtCore.pyqtSignal` to emit signal to the main dialog
which indicates the current operation.
.. note:: The signal :attr:`info_trigger` should be a tuple of
(`mod_name`, mod_num`):
* mod_name(`str`): Tag of a specified hosts module in current
progress.
* mod_num(`int`): Number of current module in the operation
sequence.
.. seealso:: Method
:meth:`~gui.qdialog_ui.QDialogUI.set_make_progress`
in :class:`~gui.qdialog_ui.QDialogUI` class.
:ivar PyQt4.QtCore.pyqtSignal fina_trigger: An instance of
:class:`PyQt4.QtCore.pyqtSignal` to emit signal to the main dialog
which notifies statistics to the main dialog.
.. note:: The signal :attr:`fina_trigger` should be a tuple of
(`time`, count`):
* time(`str`): Total time uesd while generating the new hosts
file.
* count(`int`): Total number of hosts entries inserted into the
new hosts file.
.. seealso:: Method :meth:`~gui.qdialog_d.QDialogDaemon.finish_make`
in :class:`~gui.qdialog_d.QDialogDaemon` class.
:ivar PyQt4.QtCore.pyqtSignal move_trigger: An instance of
:class:`PyQt4.QtCore.pyqtSignal` to notify the main dialog while new
hosts is being moved to specified path on current operating system.
.. note:: This signal does not send any data.
.. seealso:: Method :meth:`~gui.qdialog_d.QDialogDaemon.move_hosts`
in :class:`~gui.qdialog_d.QDialogDaemon` class.
.. seealso:: :class:`util.makehosts.MakeHosts` class.
"""
info_trigger = QtCore.pyqtSignal(str, int)
fina_trigger = QtCore.pyqtSignal(str, int)
move_trigger = QtCore.pyqtSignal()
def __init__(self, parent):
"""
Initialize a new instance of this class. Retrieve configuration from
the main dialog to make a new hosts file.
:param parent: An instance of :class:`~gui.qdialog_d.QDialogDaemon`
class to fetch settings from.
:type parent: :class:`~gui.qdialog_d.QDialogDaemon`
.. warning:: :attr:`parent` MUST NOT be set as `None`.
"""
QtCore.QThread.__init__(self, parent)
MakeHosts.__init__(self, parent)
def run(self):
"""
Start operations to retrieve data from the data file and generate new
hosts file.
"""
start_time = time.time()
self.make()
end_time = time.time()
total_time = "%.4f" % (end_time - start_time)
self.fina_trigger.emit(total_time, self.count)
if self.make_mode == "system":
self.move_trigger.emit()
def get_hosts(self, make_cfg):
"""
Make the new hosts file by the configuration defined by `make_cfg`
from function list on the main dialog.
:param make_cfg: Module settings in byte word format.
:type make_cfg: dict
.. seealso:: :attr:`make_cfg` in :class:`~tui.curses_d.CursesDaemon`
class.
"""
for part_id in sorted(make_cfg.keys()):
mod_cfg = make_cfg[part_id]
if not RetrieveData.chk_mutex(part_id, mod_cfg):
return
mods = RetrieveData.get_ids(mod_cfg)
for mod_id in mods:
self.mod_num += 1
hosts, mod_name = RetrieveData.get_host(part_id, mod_id)
self.info_trigger.emit(mod_name, self.mod_num)
if part_id == 0x02:
self.write_localhost_mod(hosts)
elif part_id == 0x04:
self.write_customized()
else:
self.write_common_mod(hosts, mod_name)
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _build.py : Tools to make packages for different platforms
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
import sys
import shutil
from __version__ import __version__
SCRIPT = "hoststool.py"
SCRIPT_DIR = os.getcwd() + '/'
RELEASE_DIR = "../release/"
# Shared package settings and metadata
NAME = "HostsUtl"
VERSION = __version__
DESCRIPTION = "HostsUtl - Hosts Setup Utility"
AUTHOR = "Hamhire Hu"
AUTHOR_EMAIL = "hosts@huhamhire.com",
LICENSE = "Public Domain, Python, BSD, GPLv3 (see LICENSE)",
URL = "https://hosts.huhamhire.com",
CLASSIFIERS = [
"Development Status :: 4 - Beta",
"Environment :: MacOS X",
"Environment :: Win32 (MS Windows)",
"Environment :: X11 Applications :: Qt",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Other Audience",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Python Software Foundation License",
"License :: OSI Approved :: BSD License",
"License :: OSI Approved :: GNU General Public License v3",
"License :: Public Domain",
"Natural Language :: English",
"Natural Language :: Chinese (Simplified)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7",
"Topic :: Communications",
"Topic :: Database",
"Topic :: Desktop Environment",
"Topic :: Documentation",
"Topic :: Internet :: Name Service (DNS)",
"Topic :: System :: Networking",
"Topic :: Software Development :: Documentation",
"Topic :: Text Processing",
"Topic :: CommonUtil",
]
DATA_FILES = [
("gui/lang", [
"gui/lang/en_US.qm",
"gui/lang/zh_CN.qm",
"gui/lang/zh_TW.qm",
]),
("gui/theme", [
"gui/theme/default.qss",
]),
(".", [
"LICENSE",
"README.rst",
"network.conf",
]),
]
if sys.argv > 1:
tar_flag = 0
includes = []
excludes = []
file_path = lambda rel_path: SCRIPT_DIR + rel_path
if sys.argv[1] == "py2tar":
# Pack up script package for Linux users
includes = [
"*.py",
"gui/lang/*.qm",
"gui/theme/*.qss",
"*/*.py",
"LICENSE",
"README.rst",
"network.conf",
]
excludes = [
"_build.py",
"_pylupdate4.py",
"_pyuic4.py",
".gitattributes",
".gitignore",
]
ex_files = []
prefix = "HostsTool-x11-gpl-"
tar_flag = 1
elif sys.argv[1] == "py2source":
# Pack up source package for Linux users
includes = ["*"]
excludes = [
".gitattributes",
".gitignore",
"hostslist.data",
]
ex_files = []
prefix = "HostsTool-source-gpl-"
tar_flag = 1
else:
prefix = "Error"
ex_files = []
if tar_flag:
import glob
import tarfile
TAR_NAME = prefix + VERSION + ".tar.gz"
RELEASE_PATH = RELEASE_DIR + TAR_NAME
if not os.path.exists(RELEASE_DIR):
os.mkdir(RELEASE_DIR)
if os.path.isfile(RELEASE_PATH):
os.remove(RELEASE_PATH)
rel_len = len(SCRIPT_DIR)
tar = tarfile.open(RELEASE_PATH, "w|gz")
for name_format in excludes:
ex_files.extend(glob.glob(file_path(name_format)))
for name_format in includes:
files = glob.glob(file_path(name_format))
for src_file in files:
if src_file not in ex_files:
tar_path = os.path.join(prefix + VERSION,
src_file[rel_len:])
tar.add(src_file, tar_path)
print "compressing: %s" % src_file
tar.close()
exit(1)
from util import CommonUtil
system = CommonUtil.check_platform()[0]
if system == "Windows":
# Build binary executables for Windows
import struct
import zipfile
from distutils.core import setup
import py2exe
# Set working directories
WORK_DIR = SCRIPT_DIR + "work/"
DIR_NAME = "HostsTool"
DIST_DIR = WORK_DIR + DIR_NAME + '/'
WIN_OPTIONS = {
"includes": ["sip"],
"excludes": ["_scproxy", "_sysconfigdata"],
"dll_excludes": ["MSVCP90.dll"],
"dist_dir": DIST_DIR,
"compressed": 1,
"optimize": 2,
}
# Clean work space before build
if os.path.exists(DIST_DIR):
shutil.rmtree(DIST_DIR)
# Build Executable
print " Building Executable ".center(78, '=')
EXE_NAME = SCRIPT.split(".")[0]
setup(
name=NAME,
version=VERSION,
options={"py2exe": WIN_OPTIONS},
console=[
{"script": SCRIPT,
"dest_base": "hoststool_tui",
"uac_info": "highestAvailable",
},
],
windows=[
{"script": SCRIPT,
"icon_resources": [(1, "res/img/icons/hosts_utl.ico")],
"dest_base": EXE_NAME,
"uac_info": "highestAvailable",
},
],
description=DESCRIPTION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
zipfile="lib/shared.lib",
data_files=DATA_FILES,
classifiers=CLASSIFIERS,
)
# Clean work directory after build
shutil.rmtree(SCRIPT_DIR + "build/")
# Pack up executable to ZIP file
print " Compressing to ZIP ".center(78, '=')
if struct.calcsize("P") * 8 == 64:
PLAT = "x64"
elif struct.calcsize("P") * 8 == 32:
PLAT = "x86"
else:
PLAT = "unknown"
DIR_NAME = DIR_NAME + '-win-gpl-' + VERSION + '-' + PLAT
ZIP_NAME = DIR_NAME + ".zip"
ZIP_FILE = WORK_DIR + ZIP_NAME
compressed = zipfile.ZipFile(ZIP_FILE, 'w', zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk(DIST_DIR):
rel_path = os.path.relpath(root, os.path.dirname(DIST_DIR))
for name in files:
print "compressing: %s" % os.path.join(root, name)
compressed.write(
os.path.join(root, name),
os.path.join(DIR_NAME, rel_path, name))
compressed.close()
# Move ZIP file to release directory
RELEASE_PATH = RELEASE_DIR + ZIP_NAME
if not os.path.exists(RELEASE_DIR):
os.mkdir(RELEASE_DIR)
if os.path.isfile(RELEASE_PATH):
os.remove(RELEASE_PATH)
shutil.move(ZIP_FILE, RELEASE_PATH)
shutil.rmtree(WORK_DIR)
print "Done!"
elif system == "OS X":
# Build binary executables for Mac OS X
from setuptools import setup
# Set working directories
WORK_DIR = SCRIPT_DIR + "work/"
RES_DIR = SCRIPT_DIR + "res/mac/"
APP_NAME = "HostsTool.app"
APP_PATH = WORK_DIR + APP_NAME
DIST_DIR = APP_PATH + "/Contents/"
# Set build configuration
MAC_OPTIONS = {
"iconfile": "res/img/icons/hosts_utl.icns",
"includes": ["sip", "PyQt4.QtCore", "PyQt4.QtGui"],
"excludes": [
"PyQt4.QtDBus",
"PyQt4.QtDeclarative",
"PyQt4.QtDesigner",
"PyQt4.QtHelp",
"PyQt4.QtMultimedia",
"PyQt4.QtNetwork",
"PyQt4.QtOpenGL",
"PyQt4.QtScript",
"PyQt4.QtScriptTools",
"PyQt4.QtSql",
"PyQt4.QtSvg",
"PyQt4.QtTest",
"PyQt4.QtWebKit",
"PyQt4.QtXml",
"PyQt4.QtXmlPatterns",
"PyQt4.phonon"],
"compressed": 1,
"dist_dir": DIST_DIR,
"optimize": 2,
"plist": {
"CFBundleAllowMixedLocalizations": True,
"CFBundleSignature": "hamh",
"CFBundleIdentifier": "org.pythonmac.huhamhire.HostsTool",
"NSHumanReadableCopyright": "(C) 2014, huhamhire hosts Team"}
}
# Clean work space before build
if os.path.exists(APP_PATH):
shutil.rmtree(APP_PATH)
if not os.path.exists(WORK_DIR):
os.mkdir(WORK_DIR)
# Make daemon APP
OSAC_CMD = "osacompile -o %s %sHostsUtl.scpt" % (APP_PATH, RES_DIR)
os.system(OSAC_CMD)
# Build APP
print " Building Application ".center(78, '=')
setup(
app=[SCRIPT],
name=NAME,
version=VERSION,
options={"py2app": MAC_OPTIONS},
setup_requires=["py2app"],
description=DESCRIPTION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
data_files=DATA_FILES,
classifiers=CLASSIFIERS,
)
# Clean work directory after build
os.remove(DIST_DIR + "Resources/applet.icns")
shutil.copy2(
SCRIPT_DIR + "res/img/icons/hosts_utl.icns",
DIST_DIR + "Resources/applet.icns")
shutil.copy2(RES_DIR + "Info.plist", DIST_DIR + "Info.plist")
shutil.rmtree(SCRIPT_DIR + "build/")
# Pack APP to DMG file
VDMG_DIR = WORK_DIR + "package_vdmg/"
DMG_TMP = WORK_DIR + "pack_tmp.dmg"
DMG_RES_DIR = RES_DIR + "dmg/"
VOL_NAME = "HostsTool"
DMG_NAME = VOL_NAME + "-mac-gpl-" + VERSION + ".dmg"
DMG_PATH = WORK_DIR + DMG_NAME
# Clean work space before pack up
if os.path.exists(VDMG_DIR):
shutil.rmtree(VDMG_DIR)
if os.path.isfile(DMG_TMP):
os.remove(DMG_TMP)
if os.path.isfile(DMG_PATH):
os.remove(DMG_PATH)
# Prepare files in DMG package
os.mkdir(VDMG_DIR)
shutil.move(APP_PATH, VDMG_DIR)
os.symlink("/Applications", VDMG_DIR + " ")
shutil.copy2(DMG_RES_DIR + "background.png", VDMG_DIR + ".background.png")
shutil.copy2(DMG_RES_DIR + "DS_Store_dmg", VDMG_DIR + ".DS_Store")
# Make DMG file
print " Making DMG Package ".center(78, '=')
MK_CMD = (
"hdiutil makehybrid -hfs -hfs-volume-name %s "
"-hfs-openfolder %s %s -o %s" % (
VOL_NAME, VDMG_DIR, VDMG_DIR, DMG_TMP))
PACK_CMD = "hdiutil convert -format UDZO %s -o %s" % (DMG_TMP, DMG_PATH)
os.system(MK_CMD)
os.system(PACK_CMD)
# Clean work directory after make DMG package
shutil.rmtree(VDMG_DIR)
os.remove(DMG_TMP)
# Move DMG file to release directory
RELEASE_PATH = RELEASE_DIR + DMG_NAME
if not os.path.exists(RELEASE_DIR):
os.mkdir(RELEASE_DIR)
if os.path.isfile(RELEASE_PATH):
os.remove(RELEASE_PATH)
print "moving DMG file to: %s" % RELEASE_PATH
shutil.move(DMG_PATH, RELEASE_PATH)
shutil.rmtree(WORK_DIR)
print "Done!"
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# retrievedata.py : Retrieve data from the hosts data file.
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
import sqlite3
import zipfile
DATAFILE = "./hostslist.data"
DATABASE = "./hostslist.s3db"
class RetrieveData(object):
"""
RetrieveData class contains a set of tools to retrieve information from
the hosts data file.
.. note:: All methods from this class are declared as `classmethod`.
:ivar sqlite3.connect conn: An instance of :class:`sqlite3.connect`
object to set up connection to a SQLite database.
:ivar sqlite3.connect.cursor _cur: An instance of
:class:`sqlite3.connect.cursor` object to process SQL queries in the
database.
:ivar str _db: Filename of a SQLite database file.
"""
conn = None
_cur = None
_database = None
@classmethod
def db_exists(cls, database=DATABASE):
"""
Check whether the :attr:`database` file exists or not.
.. note:: This is a `classmethod`.
:param database: Path to a SQLite database file.
`./hostslist.s3db` by default.
:type database: str
:return: A flag indicating whether the database file exists or not.
:rtype: bool
"""
return os.path.isfile(database)
@classmethod
def connect_db(cls, database=DATABASE):
"""
Set up connection with a SQLite :attr:`database`.
.. note:: This is a `classmethod`.
:param database: Path to a SQLite database file.
`./hostslist.s3db` by default.
:type database: str
"""
cls.conn = sqlite3.connect(database)
cls._cur = cls.conn.cursor()
cls._database = database
@classmethod
def disconnect_db(cls):
"""
Close the connection with a SQLite database.
.. note:: This is a `classmethod`.
"""
cls.conn.close()
@classmethod
def get_info(cls):
"""
Retrieve the metadata of current data file.
.. note:: This is a `classmethod`.
:return: Metadata of current data file. The metadata here is a
dictionary while the `Keys` are made of `Section Name` and
`Values` are made of `Information` defined in the hosts data file.
:rtype: dict
"""
cls._cur.execute("SELECT sect, info FROM info;")
info = dict(cls._cur.fetchall())
return info
@classmethod
def get_head(cls):
"""
Retrieve the head information from hosts data file.
.. note:: This is a `classmethod`.
:return: Lines of hosts head information.
:rtype: list
"""
cls._cur.execute("SELECT str FROM hosts_head ORDER BY ln;")
head = cls._cur.fetchall()
return head
@classmethod
def get_ids(cls, id_cfg):
"""
Calculate the id numbers covered by config word :attr:`id_cfg`.
.. note:: This is a `classmethod`.
:param id_cfg: A hexadecimal config word of id selections.
:type id_cfg: int
:return: ID numbers covered by config word.
:rtype: list
"""
cfg = bin(id_cfg)[:1:-1]
ids = []
for i, id_en in enumerate(cfg):
if int(id_en):
ids.append(0b1 << i)
return ids
@classmethod
def get_host(cls, part_id, mod_id):
"""
Retrieve the hosts module specified by :attr:`mod_id` from a part
specified by :attr:`part_id` in the data file.
.. note:: This is a `classmethod`.
:param part_id: ID number of a specified part from the hosts data
file.
.. note:: ID number is usually an 8-bit control byte.
:type part_id: int
:param mod_id: ID number of a specified module from a specified part.
.. note:: ID number is usually an 8-bit control byte.
:type mod_id: int
.. seealso:: :attr:`make_cfg` in
:class:`~tui.curses_d.CursesDaemon` class.
:return: hosts, mod_name
* hosts(`list`): Hosts entries from a specified module.
* mod_name(`str`): Name of a specified module.
:rtype: list, str
"""
if part_id == 0x04:
return None, "customize"
cls._cur.execute("""
SELECT part_name FROM parts
WHERE part_id=:part_id;
""", (part_id, ))
part_name = cls._cur.fetchone()[0]
cls._cur.execute("""
SELECT ip, host FROM %s
WHERE cate=%s;
""" % (part_name, mod_id))
hosts = cls._cur.fetchall()
cls._cur.execute("""
SELECT mod_name FROM modules
WHERE part_id=:part_id AND mod_id=:mod_id;
""", (part_id, mod_id))
mod_name = cls._cur.fetchone()[0]
return hosts, mod_name
@classmethod
def get_choice(cls, flag_v6=False):
"""
Retrieve module selection items from the hosts data file with default
selection for users.
.. note:: This is a `classmethod`.
:param flag_v6: A flag indicating whether to receive IPv6 hosts
entries or the IPv4 ones. Default by `False`.
=============== =======
:attr:`flag_v6` hosts
=============== =======
True IPv6
False IPv4
=============== =======
:type flag_v6: bool
:return: modules, defaults, slices
* modules(`list`): Information of modules for users to select.
* defaults(`dict`): Default selection config for selected parts.
* slices(`list`): Numbers of modules in each part.
:rtype: list, dict, list
"""
ch_parts = (0x08, 0x20 if flag_v6 else 0x10, 0x40)
cls._cur.execute("""
SELECT * FROM modules
WHERE part_id IN (:id_shared, :id_ipv, :id_adblock);
""", ch_parts)
modules = cls._cur.fetchall()
cls._cur.execute("""
SELECT part_id, part_default FROM parts
WHERE part_id IN (:id_shared, :id_ipv, :id_adblock);
""", ch_parts)
default_cfg = cls._cur.fetchall()
defaults = {}
for default in default_cfg:
defaults[default[0]] = cls.get_ids(default[1])
slices = [0]
for ch_part in ch_parts:
cls._cur.execute("""
SELECT COUNT(mod_id) FROM modules
WHERE part_id=:ch_part;
""", (ch_part, ))
slices.append(cls._cur.fetchone()[0])
for s in range(1, len(slices)):
slices[s] += slices[s - 1]
return modules, defaults, slices
@classmethod
def chk_mutex(cls, part_id, mod_cfg):
"""
Check if there is conflict in user selections :attr:`mod_cfg` from a
part specified by :attr:`part_id` in the data file.
.. note:: A conflict may happen while one module selected is declared
in `mutex` word of ano module selected at the same time.
.. note:: This is a `classmethod`.
:param part_id: ID number of a specified part from the hosts data
file.
.. note:: ID number is usually an 8-bit control byte.
.. seealso:: :meth:`~util.retrievedata.get_host`.
:type part_id: int
:param mod_cfg: A 16-bit config word indicating module selections of a
specified part.
.. note::
If modules in specified part whose IDs are `0x0002` and
`0x0010`, the value here should be `0x0002 + 0x0010 = 0x0012`,
which is `0b0000000000000010 + 0b0000000000010000 =
0b0000000000010010` in binary.
:type: int
.. seealso:: :attr:`make_cfg` in
:class:`~tui.curses_d.CursesDaemon` class.
:return: A flag indicating whether there is a conflict or not.
====== ============
Return Status
====== ============
True Conflict
False No conflicts
====== ============
:rtype: bool
"""
if part_id == 0x04:
return True
cls._cur.execute("""
SELECT mod_id, mutex FROM modules
WHERE part_id=:part_id;
""", (part_id, ))
mutex_tuple = dict(cls._cur.fetchall())
mutex_info = []
mod_info = cls.get_ids(mod_cfg)
for mod_id in mod_info:
mutex_info.extend(cls.get_ids(mutex_tuple[mod_id]))
mutex_info = set(mutex_info)
for mod_id in mod_info:
if mod_id in mutex_info:
return False
return True
@classmethod
def unpack(cls, datafile=DATAFILE, database=DATABASE):
"""
Unzip the archived :attr:`datafile` to a SQLite database file
:attr:`database`.
.. note:: This is a `classmethod`.
:param datafile: Path to the zipped data file. `./hostslist.data` by
default.
:type datafile: str
:param database: Path to a SQLite database file. `./hostslist.s3db` by
default.
:type database: str
"""
datafile = zipfile.ZipFile(datafile, "r")
path, filename = os.path.split(database)
datafile.extract(filename, path)
@classmethod
def clear(cls):
"""
Close connection to the database and delete the database file.
.. note:: This is a `classmethod`.
"""
cls.conn.close()
os.remove(cls._database)
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# makehosts.py: Make a hosts file.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
import time
from retrievedata import RetrieveData
class MakeHosts(object):
"""
MakeHosts class contains methods to make a hosts file with host entries
from a single data file.
:ivar str make_mode: Operation mode for making hosts file. The valid value
could be one of `system`, `ansi`, and `utf-8`.
.. seealso:: :attr:`make_mode` in
:class:`~gui.qdialog_d.QDialogDaemon` class.
:ivar str custom: File name of User Customized Hosts file.
.. seealso:: :ref:`User Customized Hosts<intro-customize>`.
:ivar str hostname: File Name of hosts file.
:ivar file hosts_file: The hosts file to write hosts to.
:ivar int mod_num: Total number of modules written to hosts file.
:ivar int count: Number of the module being processed currently in the
operation sequence.
:ivar dict make_cfg: Configuration to make a new hosts file.
:ivar str eol: End-of-Line used by the hosts file created.
:ivar time make_time: Timestamp of making hosts file.
.. seealso:: :class:`gui._make.QSubMakeHosts` class and
:class:`tui.curses_d.CursesDaemon` class.
"""
make_mode = ""
custom = ""
hostname = ""
hosts_file = None
make_cfg = {}
mod_num = 0
count = 0
eol = ""
make_time = None
def __init__(self, parent):
"""
Retrieve configuration from the main dialog to make a new hosts file.
:param parent: An instance of :class:`~tui.curses_d.CursesDaemon`
class to retrieve configuration with.
:type parent: :class:`~tui.curses_d.CursesDaemon`
.. warning:: :attr:`parent` MUST NOT be set as `None`.
"""
self.count = 0
self.make_cfg = parent.make_cfg
self.hostname = parent.hostname
self.custom = parent.custom
make_path = parent.make_path
self.make_mode = parent.make_mode
if self.make_mode == "system":
self.eol = parent.sys_eol
self.hosts_file = open("hosts", "wb")
elif self.make_mode == "ansi":
self.eol = "\r\n"
self.hosts_file = open(unicode(make_path), "wb")
elif self.make_mode == "utf-8":
self.eol = "\n"
self.hosts_file = open(unicode(make_path), "wb")
def make(self):
"""
Start operations to retrieve data from the data file and make the new
hosts file for the current operating system.
"""
RetrieveData.connect_db()
self.make_time = time.time()
self.write_head()
self.write_info()
self.get_hosts(self.make_cfg)
self.hosts_file.close()
RetrieveData.disconnect_db()
def get_hosts(self, make_cfg):
"""
Make the new hosts file by the configuration defined by `make_cfg`
from function list on the main dialog.
:param make_cfg: Module settings in byte word format.
:type make_cfg: dict
.. seealso:: :attr:`make_cfg` in :class:`~tui.curses_d.CursesDaemon`
class.
"""
for part_id in sorted(make_cfg.keys()):
mod_cfg = make_cfg[part_id]
if not RetrieveData.chk_mutex(part_id, mod_cfg):
return
mods = RetrieveData.get_ids(mod_cfg)
for mod_id in mods:
self.mod_num += 1
hosts, mod_name = RetrieveData.get_host(part_id, mod_id)
if part_id == 0x02:
self.write_localhost_mod(hosts)
elif part_id == 0x04:
self.write_customized()
else:
self.write_common_mod(hosts, mod_name)
def write_head(self):
"""
Write the head part into the new hosts file.
"""
for head_str in RetrieveData.get_head():
self.hosts_file.write("%s%s" % (head_str[0], self.eol))
def write_info(self):
"""
Write the information part into the new hosts file.
"""
info = RetrieveData.get_info()
info_lines = [
"#",
"# %s: %s" % ("Version", info["Version"]),
"# %s: %s" % ("BuildTime", info["Buildtime"]),
"# %s: %s" % ("ApplyTime", int(self.make_time)),
"#"
]
for line in info_lines:
self.hosts_file.write("%s%s" % (line, self.eol))
def write_common_mod(self, hosts, mod_name):
"""
Write hosts entries :attr:`hosts` from a module named `hosts` in the
hosts data file..
:param hosts: Hosts entries from a part in the data file.
:type hosts: list
:param mod_name: Name of a module from the data file.
:type mod_name: str
"""
self.hosts_file.write(
"%s# Section Start: %s%s" % (self.eol, mod_name, self.eol))
for host in hosts:
ip = host[0]
if len(ip) < 16:
ip = ip.ljust(16)
self.hosts_file.write("%s %s%s" % (ip, host[1], self.eol))
self.count += 1
self.hosts_file.write("# Section End: %s%s" % (mod_name, self.eol))
def write_customized(self):
"""
Write user customized hosts list into the hosts file if the customized
hosts file exists.
"""
if os.path.isfile(self.custom):
custom_file = open(unicode(self.custom), "r")
lines = custom_file.readlines()
self.hosts_file.write(
"%s# Section Start: Customized%s" % (self.eol, self.eol))
for line in lines:
line = line.strip("\n")
entry = line.split(" ", 1)
if line.startswith("#"):
self.hosts_file.write(line + self.eol)
elif len(entry) > 1:
ip = entry[0]
if len(ip) < 16:
ip = entry[0].ljust(16)
self.hosts_file.write(
"%s %s%s" % (ip, entry[1], self.eol)
)
else:
pass
self.hosts_file.write("# Section End: Customized%s" % self.eol)
def write_localhost_mod(self, hosts):
"""
Write localhost entries :attr:`hosts` into the hosts file.
:param hosts: Hosts entries from a part in the data file.
:type hosts: list
"""
self.hosts_file.write(
"%s# Section Start: Localhost%s" % (self.eol, self.eol))
for host in hosts:
if "#Replace" in host[1]:
host = (host[0], self.hostname)
ip = host[0]
if len(ip) < 16:
ip = ip.ljust(16)
self.hosts_file.write("%s %s%s" % (ip, host[1], self.eol))
self.count += 1
self.hosts_file.write("# Section End: Localhost%s" % self.eol) | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __doc__.py : Document in reST format of util module.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
"""
Shared Utilities
================
The module described in this chapter provides shared utilities
CommonUtil
----------
.. autoclass:: util.common.CommonUtil
:members:
MakeHosts
---------
.. autoclass:: util.makehosts.MakeHosts
:members:
.. automethod:: util.makehosts.MakeHosts.__init__
RetrieveData
------------
.. autoclass:: util.retrievedata.RetrieveData
:members:
""" | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __init__.py: Declare modules to be called in util module.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
from common import CommonUtil
from makehosts import MakeHosts
from retrievedata import RetrieveData
__all__ = ["CommonUtil", "MakeHosts", "RetrieveData"] | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# common.py : Basic utilities used by Hosts Setup Utility.
#
# Copyleft (C) 2013 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import ConfigParser
import math
import os
import sys
import socket
import time
class CommonUtil(object):
"""
CommonUtil class contains a set of basic tools for Hosts Setup Utility to
use.
.. note:: All methods from this class are declared as `classmethod`.
"""
@classmethod
def check_connection(cls, link):
"""
Check connect to a specified server by :attr:`link`.
.. note:: This is a `classmethod`.
:param link: The link to a specified server. This string could be a
domain name or the IP address of a server.
:type link: str
:return: A flag indicating whether the connection status is good or
not.
==== ======
flag Status
==== ======
1 OK
0 Error
==== ======
:rtype: int
"""
try:
timeout = 3
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(timeout)
sock.connect((link, 80))
sock.close()
return 1
except:
return 0
@classmethod
def check_platform(cls):
"""
Check information about current operating system.
.. note:: This is a `classmethod`.
:return: system, hostname, path, encode, flag
* system(`str`): Operating system of current session.
* hostname(`str`): Hostname of current machine.
* path(`str`): Path to hosts on current operating system.
* encode(`str`): Default encoding of current OS.
* flag(`int`): A flag indicating whether the current OS is
supported or not.
==== ===========
flag Status
==== ===========
1 supported
2 unsupported
==== ===========
:rtype: str, str, str, str, int
"""
hostname = socket.gethostname()
if os.name == "nt":
system = "Windows"
path = os.getenv("WINDIR") + "\\System32\\drivers\\etc\\hosts"
encode = "win_ansi"
elif os.name == "posix":
path = "/etc/hosts"
encode = "unix_utf8"
if sys.platform == "darwin":
system = "OS X"
# Remove the ".local" suffix
hostname = hostname[0:-6]
else:
system = ["Unix", "Linux"][sys.platform.startswith('linux')]
else:
return "Unknown", '', '', 0
return system, hostname, path, encode, 1
@classmethod
def check_privileges(cls):
"""
Check whether the current session has privileges to change the hosts
file of current operating system.
.. note:: This is a `classmethod`.
:return: username, flag
* username(`str`): Username of the user running current session.
* flag(`bool`): A flag indicating whether the current session has
write privileges to the hosts file or not.
:rtype: str, bool
"""
if os.name == 'nt':
try:
# Only windows users with admin privileges can read the
# C:\windows\temp
os.listdir(os.sep.join([
os.environ.get('SystemRoot', 'C:\windows'), 'temp']))
except:
return os.environ['USERNAME'], False
else:
return os.environ['USERNAME'], True
else:
# Check wirte privileges to the hosts file for current user
w_flag = os.access("/etc/hosts", os.W_OK)
try:
return os.environ['USERNAME'], w_flag
except KeyError:
return os.environ['USER'], w_flag
@classmethod
def set_network(cls, conf_file="network.conf"):
"""
Get configurations for mirrors to connect to.
.. note:: This is a `classmethod`.
:param conf_file: Path to a configuration file containing which
contains the server list.
:type conf_file: str
:return: `tag`, `test url`, and `update url` of the servers listed in
the configuration file.
Definition of the dictionary returned:
======== ===================================================
Key Value
======== ===================================================
tag `Tag` string of a specified server.
label Name of a specified server.
test_url `URL` to test the connection to a server.
update `URL` containing the directory to get latest hosts\
data file.
======== ===================================================
:rtype: dict
"""
conf = ConfigParser.ConfigParser()
conf.read(conf_file)
mirrors = []
for sec in conf.sections():
mirror = {"tag": sec,
"label": conf.get(sec, "label"),
"test_url": conf.get(sec, "server"),
"update": conf.get(sec, "update"), }
mirrors.append(mirror)
return mirrors
@classmethod
def timestamp_to_date(cls, timestamp):
"""
Transform unix :attr:`timestamp` to a data string in ISO format.
.. note:: This is a `classmethod`.
:param timestamp: A unix timestamp indicating a specified time.
:type timestamp: number
.. note:: The :attr:`timestamp` could be `int` or `float`.
:return: Date in ISO format, which is `YY-mm-dd` in specific.
:rtype: str
"""
l_time = time.localtime(float(timestamp))
iso_format = "%Y-%m-%d"
date = time.strftime(iso_format, l_time)
return date
@classmethod
def convert_size(cls, bufferbytes):
"""
Convert byte size :attr:`bufferbytes` of a file into a size string.
.. note:: This is a `classmethod`.
:param bufferbytes: The size of a file counted in bytes.
:type bufferbytes: int
:return: A readable size string.
:rtype: str
"""
if bufferbytes == 0:
return "0 B"
l_unit = int(math.log(bufferbytes, 0x400))
units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
formats = ['%.2f', '%.1f', '%d']
size = bufferbytes / math.pow(0x400, l_unit)
l_num = int(math.log(size, 10))
if l_unit >= len(units):
l_unit = len(units) - 1
if l_num >= len(formats):
l_num = len(formats) - 1
return ''.join([formats[l_num], ' ', units[l_unit]]) % size
@classmethod
def cut_message(cls, msg, cut):
"""
Cut english message (:attr:`msg`) into lines with specified length
(:attr:`cut`).
.. note:: This is a `classmethod`.
:param msg: The message to be cut.
:type msg: str
:param cut: The length for each line of the message.
:type cut: int
:return: Lines cut from the message.
:rtype: list
"""
delimiter = [" ", "\n"]
msgs = []
while len(msg) >= cut:
if "\n" in msg[:cut-1]:
[line, msg] = msg.split("\n", 1)
else:
if (msg[cut-1] not in delimiter) and \
(msg[cut] not in delimiter):
cut_len = cut - 1
hyphen = " " if msg[cut-2] in delimiter else "-"
else:
cut_len = cut
hyphen = " "
line = msg[:cut_len] + hyphen
msg = msg[cut_len:]
msgs.append(line)
msgs.append(msg)
return msgs
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _update.py: Retrieve hosts data file.
#
# Copyleft (C) 2013 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
import socket
import urllib
class FetchUpdate(object):
"""
FetchUpdate class contains methods to retrieve the latest hosts data file
from the project server.
:ivar str url: The URL of the latest hosts data file.
:ivar str path: Destination path to save the data file downloaded.
:ivar str tmp_path: Temporary path to save the data file while
downloading.
:ivar int file_size: Size of the data file in bytes.
:ivar CursesDaemon parent: An instance of
:class:`~tui.curses_d.CursesDaemon` class to get configuration with.
"""
def __init__(self, parent):
"""
Initialize a new instance of this class
:param parent: An instance of :class:`~tui.curses_d.CursesDaemon`
class to get configuration with.
:type parent: :class:`~tui.curses_d.CursesDaemon`
"""
mirror_id = parent.settings[0][1]
mirror = parent.settings[0][2][mirror_id]
self.url = mirror["update"] + parent.filename
self.path = "./" + parent.filename
self.tmp_path = self.path + ".download"
self.file_size = parent._update["size"]
self.parent = parent
def get_file(self):
"""
Fetch the latest hosts data file from project server.
"""
socket.setdefaulttimeout(10)
try:
urllib.urlretrieve(self.url, self.tmp_path,
self.parent.process_bar)
self.replace_old()
except Exception, e:
raise e
def replace_old(self):
"""
Replace the old hosts data file with the new one.
"""
if os.path.isfile(self.path):
os.remove(self.path)
os.rename(self.tmp_path, self.path) | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __doc__.py Document in reST format of tui module.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
"""
.. _tui-module:
Text-based User Interface (TUI)
===============================
The following sections describe the objects and methods from the Text-based
User Interface (TUI) module of huhamhire-hosts HostsUtil. The methods to make
TUI here are based on
`curses <http://docs.python.org/2/library/curses.html>`_.
HostsUtil(TUI)
--------------
.. autoclass:: tui.hostsutil.HostsUtil
:members:
.. automethod:: tui.hostsutil.HostsUtil.__init__
.. automethod:: tui.hostsutil.HostsUtil.__del__
CursesDaemon
------------
.. autoclass:: tui.curses_d.CursesDaemon
:members:
CursesUI
--------
.. autoclass:: tui.curses_ui.CursesUI
:members:
.. automethod:: tui.curses_ui.CursesUI.__init__
.. automethod:: tui.curses_ui.CursesUI.__del__
FetchUpdate
-----------
.. autoclass:: tui._update.FetchUpdate
:members:
.. automethod:: tui._update.FetchUpdate.__init__
""" | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# hostsutil.py: Start a TUI session of `Hosts Setup Utility`.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
from zipfile import BadZipfile
from curses_d import CursesDaemon
import sys
sys.path.append("..")
from util import CommonUtil, RetrieveData
class HostsUtil(CursesDaemon):
"""
HostsUtil class in :mod:`tui` module is the main entrance to the
Text-based User Interface (TUI) mode of `Hosts Setup Utility`. This class
contains methods to start a TUI session of `Hosts Setup Utility`.
.. note:: This class is subclass of :class:`~tui.curses_d.CursesDaemon`
class.
.. inheritance-diagram:: tui.hostsutil.HostsUtil
:parts: 2
Typical usage to start a TUI session::
import tui
util = tui.HostsUtil()
util.start()
:ivar str platform: Platform of current operating system. The value could
be `Windows`, `Linux`, `Unix`, `OS X`, and of course `Unknown`.
:ivar str hostname: The hostname of current operating system.
.. note:: This attribute would only be used on linux.
:ivar str hosts_path: The absolute path to the hosts file on current
operating system.
.. seealso:: :attr:`platform`, :attr:`hostname`, :attr:`hosts_path` in
:class:`~tui.curses_d.CursesDaemon` class.
:ivar str sys_eol: The End-Of-Line marker. This maker could typically be
one of `CR`, `LF`, or `CRLF`.
.. seealso:: :attr:`sys_eol` in :class:`~tui.curses_ui.CursesUI`
class.
"""
platform = ""
hostname = ""
hosts_path = ""
sys_eol = ""
def __init__(self):
"""
Initialize a new TUI session.
* Load server list from a configuration file under working directory.
* Try to load the hosts data file under working directory if it
exists.
.. note:: IF hosts data file does not exists correctly in current
working directory, a warning message box would popup. And
operations to change the hosts file on current system could be
done only until a new data file has been downloaded.
.. seealso:: :meth:`~tui.curses_d.CursesDaemon.session_daemon` method
in :class:`~tui.curses_d.CursesDaemon`.
.. seealso:: :meth:`~gui.hostsutil.HostsUtil.init_main` in
:class:`~gui.hostsutil.HostsUtil` class.
"""
super(HostsUtil, self).__init__()
# Set mirrors
self.settings[0][2] = CommonUtil.set_network("network.conf")
# Read data file and set function list
try:
self.set_platform()
RetrieveData.unpack()
RetrieveData.connect_db()
self.set_info()
self.set_func_list()
except IOError:
self.messagebox("No data file found! Press F6 to get data file "
"first.", 1)
except BadZipfile:
self.messagebox("Incorrect Data file! Press F6 to get a new data "
"file first.", 1)
def __del__(self):
"""
Reset the terminal and clear up the temporary data file while TUI
session is finished.
"""
super(HostsUtil, self).__del__()
try:
RetrieveData.clear()
except:
pass
def start(self):
"""
Start the TUI session.
.. note:: This method is the trigger to start a TUI session of
`Hosts Setup Utility`.
"""
while True:
# Reload
if self.session_daemon():
self.__del__()
self.__init__()
else:
break
def set_platform(self):
"""
Set the information about current operating system.
"""
system, hostname, path, encode, flag = CommonUtil.check_platform()
color = "GREEN" if flag else "RED"
self.platform = system
self.statusinfo[1][1] = system
self.hostname = hostname
self.hosts_path = path
self.statusinfo[1][2] = color
if encode == "win_ansi":
self.sys_eol = "\r\n"
else:
self.sys_eol = "\n"
def set_func_list(self):
"""
Set the function selection list in TUI session.
"""
for ip in range(2):
choice, defaults, slices = RetrieveData.get_choice(ip)
if os.path.isfile(self.custom):
choice.insert(0, [4, 1, 0, "customize"])
defaults[0x04] = [1]
for i in range(len(slices)):
slices[i] += 1
slices.insert(0, 0)
self.choice[ip] = choice
self.slices[ip] = slices
funcs = []
for func in choice:
if func[1] in defaults[func[0]]:
funcs.append(1)
else:
funcs.append(0)
self._funcs[ip] = funcs
def set_info(self):
"""
Set the information of the current local data file.
"""
info = RetrieveData.get_info()
build = info["Buildtime"]
self.hostsinfo["Version"] = info["Version"]
self.hostsinfo["Release"] = CommonUtil.timestamp_to_date(build)
if __name__ == "__main__":
main = HostsUtil()
main.start()
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# curses_d.py: Operations for TUI window.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import curses
import json
import os
import shutil
import socket
import urllib
import sys
from curses_ui import CursesUI
from _update import FetchUpdate
sys.path.append("..")
from util import CommonUtil, RetrieveData
from util import MakeHosts
class CursesDaemon(CursesUI):
"""
CursesDaemon class contains methods to deal with the operations related to
the TUI window of `Hosts Setup Utility`. Including methods to interactive
with users.
.. note:: This class is subclass of :class:`~tui.curses_ui.CursesUI`
class.
:ivar dict _update: Update information of the current data file on server.
:ivar int _writable: Indicating whether the program is run with admin/root
privileges. The value could be `1` or `0`.
.. seealso:: `_update` and `_writable` in
:class:`~gui.qdialog_d.QDialogDaemon` class.
:ivar dict make_cfg: A set of module selection control bytes used to
control whether a specified method is used or not while generate a
hosts file.
* `Keys` of :attr:`make_cfg` are typically 8-bit control byte
indicating which part of the hosts data file would be effected by
the corresponding `Value`.
+----+----------------+
|Key |Part |
+====+================+
|0x02|Localhost |
+----+----------------+
|0x08|Shared hosts |
+----+----------------+
|0x10|IPv4 hosts |
+----+----------------+
|0x20|IPv6 hosts |
+----+----------------+
|0x40|AD block hosts |
+----+----------------+
* `Values` of :attr:`make_cfg` are typically 16-bit control bytes that
decides which of the modules in a specified part would be inserted
into the `hosts` file.
* `Value` of `Localhost` part. The Value used in `Localhost` part
are usually bytes indicating the current operating system.
+---------------+-------------------+
|Hex |OS |
+===============+===================+
|0x0001 |Windows |
+---------------+-------------------+
|0x0002 |Linux, Unix |
+---------------+-------------------+
|0x0004 |Mac OS X |
+---------------+-------------------+
* `Values` of `Shared hosts`, `IPv4 hosts`, `IPv6 hosts`, and
`AD block hosts` parts are usually sum of module IDs selected
by user.
.. note::
If modules in specified part whose IDs are `0x0002` and
`0x0010`, the value here should be `0x0002 + 0x0010 = 0x0012`,
which is `0b0000000000000010 + 0b0000000000010000 =
0b0000000000010010` in binary.
.. warning::
Only one bit could be `1` in the binary form of a module ID,
which means `0b0000000000010010` is an INVALID module ID while
it could be a VALID `Value` in `make_cfg`.
:ivar str platform: Platform of current operating system. The value could
be `Windows`, `Linux`, `Unix`, `OS X`, and of course `Unknown`.
:ivar str hostname: The hostname of current operating system.
.. note:: This attribute would only be used on linux.
:ivar str hosts_path: The absolute path to the hosts file on current
operating system.
:ivar str make_mode: Operation mode for making hosts file. The valid value
could be one of `system`, `ansi`, and `utf-8`.
.. seealso:: :attr:`make_mode` in
:class:`~util.makehosts.MakeHosts` class.
:ivar str make_path: Temporary path to store generated hosts file. The
default value of :attr:`make_path` is "`./hosts`".
:ivar list _ops_keys: Hot keys used to start a specified operation.
Default operation keys are `F5`, `F6`, and `F10`.
:ivar list _hot_keys: Hot keys used to select a item or confirm an
operation. And the default :attr:`_hot_keys` is defined as::
_hot_keys = [curses.KEY_UP, curses.KEY_DOWN, 10, 32]
.. seealso:: :attr:`~tui.curses_ui.CursesUI.funckeys` in
:class:`~tui.curses_ui.CursesUI` class.
"""
_update = {}
_writable = 0
make_cfg = {}
platform = ''
hostname = ''
hosts_path = ''
make_mode = ''
make_path = "./hosts"
_ops_keys = [curses.KEY_F5, curses.KEY_F6, curses.KEY_F10]
_hot_keys = [curses.KEY_UP, curses.KEY_DOWN, 10, 32]
def __init__(self):
super(CursesDaemon, self).__init__()
self.check_writable()
def check_writable(self):
"""
Check if current session has write privileges to the hosts file.
.. note:: IF current session does not has the write privileges to the
hosts file of current system, a warning message box would popup.
.. note:: ALL operation would change the `hosts` file on current
system could only be done while current session has write
privileges to the file.
"""
self._writable = CommonUtil.check_privileges()[1]
if not self._writable:
self.messagebox("Please check if you have writing\n"
"privileges to the hosts file!", 1)
exit()
def session_daemon(self):
"""
Operations processed while running a TUI session of `Hosts Setup
Utility`.
:return: A flag indicating whether to reload the current session or
all operations have been finished. The return value could only be
`0` or `1`. To be specific:
==== =========
flag operation
==== =========
0 Finish
1 Reload
==== =========
.. note:: Reload operation is called only when a new data file is
retrieved from server.
:rtype: int
.. note:: IF hosts data file does not exists in current working
directory, a warning message box would popup. And operations to
change the hosts file on current system could be done only until
a new data file has been downloaded.
"""
screen = self._stdscr.subwin(0, 0, 0, 0)
screen.keypad(1)
# Draw Menu
self.banner()
self.footer()
# Key Press Operations
key_in = None
tab = 0
pos = 0
tab_entry = [self.configure_settings, self.select_func]
while key_in != 27:
self.setup_menu()
self.status()
self.process_bar(0, 0, 0, 0)
for i, sec in enumerate(tab_entry):
tab_entry[i](pos if i == tab else None)
if key_in is None:
test = self.settings[0][2][0]["test_url"]
self.check_connection(test)
key_in = screen.getch()
if key_in == 9:
if self.choice == [[], []]:
tab = 0
else:
tab = not tab
pos = 0
elif key_in in self._hot_keys:
pos = tab_entry[tab](pos, key_in)
elif key_in in self._ops_keys:
if key_in == curses.KEY_F10:
if self._funcs == [[], []]:
self.messagebox("No data file found! Press F6 to get "
"data file first.", 1)
else:
msg = "Apply Changes to hosts file?"
confirm = self.messagebox(msg, 2)
if confirm:
self.set_config_bytes()
self.make_mode = "system"
maker = MakeHosts(self)
maker.make()
self.move_hosts()
elif key_in == curses.KEY_F5:
self._update = self.check_update()
elif key_in == curses.KEY_F6:
if self._update == {}:
self._update = self.check_update()
# Check if data file up-to-date
if self.new_version():
self.fetch_update()
return 1
else:
self.messagebox("Data file is up-to-date!", 1)
else:
pass
return 0
def configure_settings(self, pos=None, key_in=None):
"""
Perform operations to config settings if `Configure Setting` frame is
active, or just draw the `Configure Setting` frame with no items
selected while it is inactive.
.. note:: Whether the `Configure Setting` frame is inactive is decided
by if :attr:`pos` is `None` or not.
=========== ========
:attr:`pos` Status
=========== ========
None Inactive
int Active
=========== ========
:param pos: Index of selected item in `Configure Setting` frame. The
default value of `pos` is `None`.
:type pos: int or None
:param key_in: A flag indicating the key pressed by user. The default
value of `key_in` is `None`.
:type key_in: int or None
:return: Index of selected item in `Configure Setting` frame.
:rtype: int or None
"""
id_num = range(len(self.settings))
if pos is not None:
if key_in == curses.KEY_DOWN:
pos = list(id_num[1:] + id_num[:1])[pos]
elif key_in == curses.KEY_UP:
pos = list(id_num[-1:] + id_num[:-1])[pos]
elif key_in in [10, 32]:
self.sub_selection(pos)
self.info(pos, 0)
self.configure_settings_frame(pos)
return pos
def select_func(self, pos=None, key_in=None):
"""
Perform operations if `function selection list` is active, or just
draw the `function selection list` with no items selected while it is
inactive.
.. note:: Whether the `function selection list` is inactive is decided
by if :attr:`pos` is `None` or not.
.. seealso:: :meth:`~tui.curses_d.CursesDaemon.configure_settings`.
:param pos: Index of selected item in `function selection list`. The
default value of `pos` is `None`.
:type pos: int or None
:param key_in: A flag indicating the key pressed by user. The default
value of `key_in` is `None`.
:type key_in: int or None
:return: Index of selected item in `function selection list`.
:rtype: int or None
"""
list_height = 15
ip = self.settings[1][1]
# Key Press Operations
item_len = len(self.choice[ip])
item_sup, item_inf = self._item_sup, self._item_inf
if pos is not None:
if item_len > list_height:
if pos <= 1:
item_sup = 0
item_inf = list_height - 1
elif pos >= item_len - 2:
item_sup = item_len - list_height + 1
item_inf = item_len
else:
item_sup = 0
item_inf = item_len
if key_in == curses.KEY_DOWN:
pos += 1
if pos >= item_len:
pos = 0
if pos not in range(item_sup, item_inf):
item_sup += 2 if item_sup == 0 else 1
item_inf += 1
elif key_in == curses.KEY_UP:
pos -= 1
if pos < 0:
pos = item_len - 1
if pos not in range(item_sup, item_inf):
item_inf -= 2 if item_inf == item_len else 1
item_sup -= 1
elif key_in in [10, 32]:
self._funcs[ip][pos] = not self._funcs[ip][pos]
mutex = RetrieveData.get_ids(self.choice[ip][pos][2])
for c_id, c in enumerate(self.choice[ip]):
if c[0] == self.choice[ip][pos][0]:
if c[1] in mutex and self._funcs[ip][c_id] == 1:
self._funcs[ip][c_id] = 0
self.info(pos, 1)
else:
item_sup = 0
if item_len > list_height:
item_inf = list_height - 1
else:
item_inf = item_len
self.show_funclist(pos, item_sup, item_inf)
return pos
def sub_selection(self, pos):
"""
Let user to choose settings from `Selection Dialog` specified by
:attr:`pos`.
:param pos: Index of selected item in `Configure Setting` frame.
:type pos: int
.. warning:: The value of `pos` MUST NOT be `None`.
.. seealso:: :meth:`~tui.curses_ui.CursesUI.sub_selection_dialog` in
:class:`~tui.curses_ui.CursesUI`.
"""
screen = self.sub_selection_dialog(pos)
i_pos = self.settings[pos][1]
# Key Press Operations
id_num = range(len(self.settings[pos][2]))
key_in = None
while key_in != 27:
self.sub_selection_dialog_items(pos, i_pos, screen)
key_in = screen.getch()
if key_in == curses.KEY_DOWN:
i_pos = list(id_num[1:] + id_num[:1])[i_pos]
elif key_in == curses.KEY_UP:
i_pos = list(id_num[-1:] + id_num[:-1])[i_pos]
elif key_in in [10, 32]:
if pos == 0 and i_pos != self.settings[pos][1]:
test = self.settings[pos][2][i_pos]["test_url"]
self.check_connection(test)
self.settings[pos][1] = i_pos
return
def check_connection(self, url):
"""
Check connection status to the server currently selected by user and
show a status box indicating current operation.
:param url: The link of the server chose by user.This string could be
a domain name or the IP address of a server.
.. seealso:: :attr:`link` in
:meth:`~util.common.CommonUtil.check_connection`.
:type url: str
:return: A flag indicating connection status is good or not.
.. seealso:: :meth:`~util.common.CommonUtil.check_connection`. in
:class:`~util.common.CommonUtil` class.
:rtype: int
"""
self.messagebox("Checking Server Status...")
conn = CommonUtil.check_connection(url)
if conn:
self.statusinfo[0][1] = "OK"
self.statusinfo[0][2] = "GREEN"
else:
self.statusinfo[0][1] = "Error"
self.statusinfo[0][2] = "RED"
self.status()
return conn
def check_update(self):
"""
Check the metadata of the latest hosts data file from server and
show a status box indicating current operation.
:return: A dictionary containing the `Version`, `Release Date` of
current hosts data file and the `Latest Version` of the data file
on server.
IF error occurs while checking update, the dictionary would be
defined as::
{"version": "[Error]"}
:rtype: dict
"""
self.messagebox("Checking Update...")
srv_id = self.settings[0][1]
url = self.settings[0][2][srv_id]["update"] + self.infofile
try:
socket.setdefaulttimeout(5)
url_obj = urllib.urlopen(url)
j_str = url_obj.read()
url_obj.close()
info = json.loads(j_str)
except:
info = {"version": "[Error]"}
self.hostsinfo["Latest"] = info["version"]
self.status()
return info
def new_version(self):
"""
Compare version of local data file to the version from the server.
:return: A flag indicating whether the local data file is up-to-date
or not.
====== ============================================
Return Data file status
====== ============================================
1 The version of data file on server is newer.
0 The local data file is up-to-date.
====== ============================================
:rtype: int
"""
local_ver = self.hostsinfo["Version"]
if local_ver == "N/A":
return 1
server_ver = self._update["version"]
local_ver = local_ver.split('.')
server_ver = server_ver.split('.')
for i, ver_num in enumerate(local_ver):
if server_ver[i] > ver_num:
return 1
return 0
def fetch_update(self):
"""
Retrieve the latest hosts data file from server and show a status box
indicating current operation.
"""
self.messagebox("Downloading...")
fetch_d = FetchUpdate(self)
fetch_d.get_file()
def set_config_bytes(self):
"""
Calculate the module configuration byte words by the selection from
function list on the main dialog.
"""
ip_flag = self.settings[1][1]
selection = {}
localhost_word = {
"Windows": 0x0001, "Linux": 0x0002,
"Unix": 0x0002, "OS X": 0x0004}[self.platform]
selection[0x02] = localhost_word
ch_parts = [0x08, 0x20 if ip_flag else 0x10, 0x40]
# Set customized module if exists
if os.path.isfile(self.custom):
ch_parts.insert(0, 0x04)
slices = self.slices[ip_flag]
for i, part in enumerate(ch_parts):
part_cfg = self._funcs[ip_flag][slices[i]:slices[i + 1]]
part_word = 0
for i, cfg in enumerate(part_cfg):
part_word += cfg << i
selection[part] = part_word
self.make_cfg = selection
def move_hosts(self):
"""
Move hosts file to the system path after making operations are
finished.
"""
filepath = "hosts"
try:
shutil.copy2(filepath, self.hosts_path)
except IOError:
os.remove(filepath)
return
os.remove(filepath)
self.messagebox("Operation completed!", 1)
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __init__.py: Declare modules to be called in tui module.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
from hostsutil import HostsUtil
__all__ = ["HostsUtil"]
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# curses_ui.py: Draw TUI using curses.
#
# Copyleft (C) 2014 - huhamhire <me@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import curses
import locale
import sys
sys.path.append("..")
from util import CommonUtil
from __version__ import __version__, __release__
class CursesUI(object):
"""
CursesUI class contains methods to draw the Text-based User Interface
(TUI) of Hosts Setup Utility. The methods to make TUI here are based on
`curses <http://docs.python.org/2/library/curses.html>`_.
:ivar str __title: Title of the TUI utility.
:ivar str __copyleft: Copyleft information of the TUI utility.
:ivar WindowObject _stdscr: A **WindowObject** which represents the whole
screen.
:ivar int _item_sup: Upper bound of item index from `function selection
list`.
:ivar int _item_inf: Lower bound of item index from `function selection
list`.
:ivar str _make_path: Temporary path to store the hosts file in while
building. The default _make_path is `./hosts`.
:ivar list _funcs: Two lists with the information of function list both
for IPv4 and IPv6 environment.
:ivar list choice: Two lists with the selection of functions both
for IPv4 and IPv6 environment.
:ivar list slices: Two lists with integers indicating the number of
function items from different parts listed in the function list.
.. seealso:: `_funcs`, `choice`, and `slices` in
:class:`~gui.qdialog_d.QDialogDaemon` class.
:ivar str sys_eol: The End-Of-Line marker. This maker could typically be
one of `CR`, `LF`, or `CRLF`.
.. seealso:: :attr:`sys_eol` in
:class:`~gui.qdialog_d.QDialogDaemon` class.
:ivar list colorpairs: Tuples of `(foreground-color, background-color)`
used while drawing TUI.
The default colorpairs is defined as::
colorpairs = [(curses.COLOR_WHITE, curses.COLOR_BLUE),
(curses.COLOR_WHITE, curses.COLOR_RED),
(curses.COLOR_YELLOW, curses.COLOR_BLUE),
(curses.COLOR_BLUE, curses.COLOR_WHITE),
(curses.COLOR_WHITE, curses.COLOR_WHITE),
(curses.COLOR_BLACK, curses.COLOR_WHITE),
(curses.COLOR_GREEN, curses.COLOR_WHITE),
(curses.COLOR_WHITE, curses.COLOR_BLACK),
(curses.COLOR_RED, curses.COLOR_WHITE), ]
:ivar list settings: Two list containing the server selection and IP
protocol version of current session.
The settings should be like::
settings = [["Server", 0, []],
["IP Version", 0, ["IPv4", "IPv6"]]]
:ivar list funckeys: Lists of hot keys with their function to be shown on
TUI.
The default :attr:`funckeys` is defined as::
funckeys = [["", "Select Item"], ["Tab", "Select Field"],
["Enter", "Set Item"], ["F5", "Check Update"],
["F6", "Fetch Update"], ["F10", "Apply Changes"],
["Esc", "Exit"]]
:ivar list statusinfo: Two lists containing the connection and OS checking
status of current session.
The default :attr:`statusinfo` is defined as::
statusinfo = [["Connection", "N/A", "GREEN"],
["OS", "N/A", "GREEN"]]
:ivar dict hostsinfo: Containing the `Version`, `Release Date` of current
hosts data file and the `Latest Version` of the data file on server.
The default hostsinfo is defined as::
hostsinfo = {"Version": "N/A", "Release": "N/A", "Latest": "N/A"}
.. note:: IF the hosts data file does NOT exist in current working
directory, OR the file metadata has NOT been checked, the values
here would just be `N/A`.
:ivar str filename: Filename of the hosts data file containing data to
make hosts files from. Default by "`hostslist.data`".
:ivar str infofile: Filename of the info file containing metadata of the
hosts data file formatted in JSON. Default by "`hostslist.json`".
.. seealso:: :attr:`filename` and :attr:`infofile` in
:class:`~gui.hostsutil.HostsUtil` class.
:ivar str custom: File name of User Customized Hosts File. Customized
hosts would be able to select if this file exists. The default file
name is ``custom.hosts``.
.. seealso:: :ref:`User Customized Hosts<intro-customize>`.
"""
__title = "HOSTS SETUP UTILITY"
version = "".join(['v', __version__, ' ', __release__])
__copyleft = "%s Copyleft 2011-2014, huhamhire-hosts Team" % version
_stdscr = None
_item_sup = 0
_item_inf = 0
_make_path = "./hosts"
_funcs = [[], []]
choice = [[], []]
slices = [[], []]
sys_eol = ""
colorpairs = [(curses.COLOR_WHITE, curses.COLOR_BLUE),
(curses.COLOR_WHITE, curses.COLOR_RED),
(curses.COLOR_YELLOW, curses.COLOR_BLUE),
(curses.COLOR_BLUE, curses.COLOR_WHITE),
(curses.COLOR_WHITE, curses.COLOR_WHITE),
(curses.COLOR_BLACK, curses.COLOR_WHITE),
(curses.COLOR_GREEN, curses.COLOR_WHITE),
(curses.COLOR_WHITE, curses.COLOR_BLACK),
(curses.COLOR_RED, curses.COLOR_WHITE), ]
settings = [["Server", 0, []],
["IP Version", 0, ["IPv4", "IPv6"]]]
funckeys = [["", "Select Item"], ["Tab", "Select Field"],
["Enter", "Set Item"], ["F5", "Check Update"],
["F6", "Fetch Update"], ["F10", "Apply Changes"],
["Esc", "Exit"]]
statusinfo = [["Connection", "N/A", "GREEN"], ["OS", "N/A", "GREEN"]]
hostsinfo = {"Version": "N/A", "Release": "N/A", "Latest": "N/A"}
filename = "hostslist.data"
infofile = "hostsinfo.json"
custom = "custom.hosts"
def __init__(self):
"""
Initialize a new TUI window in terminal.
"""
locale.setlocale(locale.LC_ALL, '')
self._stdscr = curses.initscr()
curses.start_color()
curses.noecho()
curses.cbreak()
curses.curs_set(0)
# Set colors
curses.use_default_colors()
for i, color in enumerate(self.colorpairs):
curses.init_pair(i + 1, *color)
def __del__(self):
"""
Reset terminal before quit.
"""
curses.nocbreak()
curses.echo()
curses.endwin()
def banner(self):
"""
Draw the banner in the TUI window.
"""
screen = self._stdscr.subwin(2, 80, 0, 0)
screen.bkgd(' ', curses.color_pair(1))
# Set local variable
title = curses.A_NORMAL
title += curses.A_BOLD
normal = curses.color_pair(4)
# Print title
screen.addstr(0, 0, self.__title.center(79), title)
screen.addstr(1, 0, "Setup".center(10), normal)
screen.refresh()
def footer(self):
"""
Draw the footer in the TUI window.
"""
screen = self._stdscr.subwin(1, 80, 23, 0)
screen.bkgd(' ', curses.color_pair(1))
# Set local variable
normal = curses.A_NORMAL
# Copyright info
copyleft = self.__copyleft
screen.addstr(0, 0, copyleft.center(79), normal)
screen.refresh()
def configure_settings_frame(self, pos=None):
"""
Draw `Configure Setting` frame with a index number (`pos`) of the item
selected.
:param pos: Index of selected item in `Configure Setting` frame. The
default value of `pos` is `None`.
:type pos: int or None
.. note:: None of the items in `Configure Setting` frame would be
selected if pos is `None`.
"""
self._stdscr.keypad(1)
screen = self._stdscr.subwin(8, 25, 2, 0)
screen.bkgd(' ', curses.color_pair(4))
# Set local variable
normal = curses.A_NORMAL
select = curses.color_pair(5)
select += curses.A_BOLD
for p, item in enumerate(self.settings):
item_str = item[0].ljust(12)
screen.addstr(3 + p, 2, item_str, select if p == pos else normal)
if p:
choice = "[%s]" % item[2][item[1]]
else:
choice = "[%s]" % item[2][item[1]]["label"]
screen.addstr(3 + p, 15, ''.ljust(10), normal)
screen.addstr(3 + p, 15, choice, select if p == pos else normal)
screen.refresh()
def status(self):
"""
Draw `Status` frame and `Hosts File` frame in the TUI window.
"""
screen = self._stdscr.subwin(11, 25, 10, 0)
screen.bkgd(' ', curses.color_pair(4))
# Set local variable
normal = curses.A_NORMAL
green = curses.color_pair(7)
red = curses.color_pair(9)
# Status info
for i, stat in enumerate(self.statusinfo):
screen.addstr(2 + i, 2, stat[0], normal)
stat_str = ''.join(['[', stat[1], ']']).ljust(9)
screen.addstr(2 + i, 15, stat_str,
green if stat[2] == "GREEN" else red)
# Hosts file info
i = 0
for key, info in self.hostsinfo.items():
screen.addstr(7 + i, 2, key, normal)
screen.addstr(7 + i, 15, info, normal)
i += 1
screen.refresh()
def show_funclist(self, pos, item_sup, item_inf):
"""
Draw `function selection list` frame with a index number of the item
selected and the range of items to be displayed.
:param pos: Index of selected item in `function selection list`.
:type pos: int or None
:param item_sup: Upper bound of item index from `function selection
list`.
:type item_sup: int
:param item_inf: Lower bound of item index from `function selection
list`.
:type item_inf: int
"""
# Set UI variable
screen = self._stdscr.subwin(18, 26, 2, 26)
screen.bkgd(' ', curses.color_pair(4))
normal = curses.A_NORMAL
select = curses.color_pair(5)
select += curses.A_BOLD
list_height = 15
# Set local variable
ip = self.settings[1][1]
item_len = len(self.choice[ip])
# Function list
items_show = self.choice[ip][item_sup:item_inf]
items_selec = self._funcs[ip][item_sup:item_inf]
for p, item in enumerate(items_show):
sel_ch = '+' if items_selec[p] else ' '
item_str = ("[%s] %s" % (sel_ch, item[3])).ljust(23)
item_pos = pos - item_sup if pos is not None else None
highlight = select if p == item_pos else normal
if item_len > list_height:
if item_inf - item_sup == list_height - 2:
screen.addstr(4 + p, 2, item_str, highlight)
elif item_inf == item_len:
screen.addstr(4 + p, 2, item_str, highlight)
elif item_sup == 0:
screen.addstr(3 + p, 2, item_str, highlight)
else:
screen.addstr(3 + p, 2, item_str, highlight)
if item_len > list_height:
if item_inf - item_sup == list_height - 2:
screen.addstr(3, 2, " More ".center(23, '.'), normal)
screen.addch(3, 15, curses.ACS_UARROW)
screen.addstr(17, 2, " More ".center(23, '.'), normal)
screen.addch(17, 15, curses.ACS_DARROW)
elif item_inf == item_len:
screen.addstr(3, 2, " More ".center(23, '.'), normal)
screen.addch(3, 15, curses.ACS_UARROW)
elif item_sup == 0:
screen.addstr(17, 2, " More ".center(23, '.'), normal)
screen.addch(17, 15, curses.ACS_DARROW)
else:
for line_i in range(list_height - item_len):
screen.addstr(17 - line_i, 2, ' ' * 23, normal)
if not items_show:
screen.addstr(4, 2, "No data file!".center(23), normal)
screen.refresh()
self._item_sup, self._item_inf = item_sup, item_inf
def info(self, pos, tab):
"""
Draw `Information` frame with a index number (`pos`) of the item
selected from the frame specified by `tab`.
:param pos: Index of selected item in a specified frame.
:type pos: int
:param tab: Index of the frame to select items from.
:type tab: int
.. warning:: Both of `pos` and `tab` in this method could not be
set to `None`.
"""
screen = self._stdscr.subwin(18, 24, 2, 52)
screen.bkgd(' ', curses.color_pair(4))
normal = curses.A_NORMAL
if tab:
ip = self.settings[1][1]
info_str = self.choice[ip][pos][3]
else:
info_str = self.settings[pos][0]
# Clear Expired Infomotion
for i in range(6):
screen.addstr(1 + i, 2, ''.ljust(22), normal)
screen.addstr(1, 2, info_str, normal)
# Key Info Offset
k_info_y = 10
k_info_x_key = 2
k_info_x_text = 10
# Arrow Keys
screen.addch(k_info_y, k_info_x_key, curses.ACS_UARROW, normal)
screen.addch(k_info_y, k_info_x_key + 1, curses.ACS_DARROW, normal)
# Show Key Info
for i, keyinfo in enumerate(self.funckeys):
screen.addstr(k_info_y + i, k_info_x_key, keyinfo[0], normal)
screen.addstr(k_info_y + i, k_info_x_text, keyinfo[1], normal)
screen.refresh()
def process_bar(self, done, block, total, mode=1):
"""
Draw `Process Bar` at the bottom which is used to indicate progress of
downloading operation.
.. note:: This method is a callback function responses to
:meth:`urllib.urlretrieve` method while fetching hosts data
file.
:param done: Block count of packaged retrieved.
:type done: int
:param block: Block size of the data pack retrieved.
:type block: int
:param total: Total size of the hosts data file.
:type total: int
:param mode: A flag indicating the status of `Process Bar`.
The default value of `mode` is `1`.
==== ====================================
mode `Process Bar` status
==== ====================================
1 Downloading operation is processing.
0 Not downloading.
==== ====================================
:type mode: int
"""
screen = self._stdscr.subwin(2, 80, 20, 0)
screen.bkgd(' ', curses.color_pair(4))
normal = curses.A_NORMAL
line_width = 76
prog_len = line_width - 20
# Progress Bar
if mode:
done *= block
prog = 1.0 * prog_len * done / total
progress = ''.join(['=' * int(prog), '-' * int(2 * prog % 2)])
progress = progress.ljust(prog_len)
total = CommonUtil.convert_size(total).ljust(7)
done = CommonUtil.convert_size(done).rjust(7)
else:
progress = ' ' * prog_len
done = total = 'N/A'.center(7)
# Show Progress
prog_bar = "[%s] %s | %s" % (progress, done, total)
screen.addstr(1, 2, prog_bar, normal)
screen.refresh()
def sub_selection_dialog(self, pos):
"""
Draw a `Selection Dialog` on screen used to make configurations.
:param pos: Index of selected item in `Configure Setting` frame.
:type pos: int
.. warning:: The value of `pos` MUST NOT be `None`.
:return: A **WindowObject** which represents the selection dialog.
:rtype: WindowObject
"""
i_len = len(self.settings[pos][2])
# Draw Shadow
shadow = curses.newwin(i_len + 2, 18, 13 - i_len / 2, 31)
shadow.bkgd(' ', curses.color_pair(8))
shadow.refresh()
# Draw Subwindow
screen = curses.newwin(i_len + 2, 18, 12 - i_len / 2, 30)
screen.box()
screen.bkgd(' ', curses.color_pair(1))
screen.keypad(1)
# Set local variable
normal = curses.A_NORMAL
# Title of Subwindow
screen.addstr(0, 3, self.settings[pos][0].center(12), normal)
return screen
def sub_selection_dialog_items(self, pos, i_pos, screen):
"""
Draw items in `Selection Dialog`.
:param pos: Index of selected item in `Configure Setting` frame.
:type pos: int
:param i_pos: Index of selected item in `Selection Dialog`.
:type i_pos: int
:param screen: A **WindowObject** which represents the selection
dialog.
:type screen: WindowObject
"""
# Set local variable
normal = curses.A_NORMAL
select = normal + curses.A_BOLD
for p, item in enumerate(self.settings[pos][2]):
item_str = item if pos else item["tag"]
screen.addstr(1 + p, 2, item_str,
select if p == i_pos else normal)
screen.refresh()
def setup_menu(self):
"""
Draw the main frame of `Setup` tab in the TUI window.
"""
screen = self._stdscr.subwin(21, 80, 2, 0)
screen.box()
screen.bkgd(' ', curses.color_pair(4))
# Configuration Section
screen.addch(0, 26, curses.ACS_BSSS)
screen.vline(1, 26, curses.ACS_VLINE, 17)
# Status Section
screen.addch(7, 0, curses.ACS_SSSB)
screen.addch(7, 26, curses.ACS_SBSS)
screen.hline(7, 1, curses.ACS_HLINE, 25)
# Select Functions Section
screen.addch(0, 52, curses.ACS_BSSS)
screen.vline(1, 52, curses.ACS_VLINE, 17)
# Process Bar Section
screen.addch(18, 0, curses.ACS_SSSB)
screen.addch(18, 79, curses.ACS_SBSS)
screen.hline(18, 1, curses.ACS_HLINE, 78)
screen.addch(18, 26, curses.ACS_SSBS)
screen.addch(18, 52, curses.ACS_SSBS)
# Section Titles
title = curses.color_pair(6)
subtitles = [["Configure Settings", (1, 2)], ["Status", (8, 2)],
["Hosts File", (13, 2)], ["Select Functions", (1, 28)]]
for s_title in subtitles:
cord = s_title[1]
screen.addstr(cord[0], cord[1], s_title[0], title)
screen.hline(cord[0] + 1, cord[1], curses.ACS_HLINE, 23)
screen.refresh()
@staticmethod
def messagebox(msg, mode=0):
"""
Draw a `Message Box` with :attr:`msg` in a specified type defined by
:attr:`mode`.
.. note:: This is a `static` method.
:param msg: The information to be displayed in message box.
:type msg: str
:param mode: A flag indicating the type of message box to be
displayed. The default value of `mode` is `0`.
==== ===========================================================
mode Message Box Type
==== ===========================================================
0 A simple message box showing a message without any buttons.
1 A message box with an `OK` button for user to confirm.
2 A message box with `OK` and `Cancel` buttons for user to
choose.
==== ===========================================================
:type mode: int
:return: A flag indicating the choice made by user.
====== =====================================================
Return Condition
====== =====================================================
0 #. No button is pressed while :attr:`mode` is `0`.
#. `OK` button pressed while :attr:`mode` is `1`.
#. `Cancel` button pressed while :attr:`mode` is `2`.
1 `OK` button pressed while :attr:`mode` is `2`.
====== =====================================================
:rtype: int
"""
pos_x = 24 if mode == 0 else 20
pos_y = 10
width = 30 if mode == 0 else 40
height = 2
messages = CommonUtil.cut_message(msg, width - 4)
height += len(messages)
if mode:
height += 2
# Draw Shadow
shadow = curses.newwin(height, width, pos_y + 1, pos_x + 1)
shadow.bkgd(' ', curses.color_pair(8))
shadow.refresh()
# Draw Subwindow
screen = curses.newwin(height, width, pos_y, pos_x)
screen.box()
screen.bkgd(' ', curses.color_pair(2))
screen.keypad(1)
# Set local variable
normal = curses.A_NORMAL
select = curses.A_REVERSE
# Insert messages
for i in range(len(messages)):
screen.addstr(1 + i, 2, messages[i].center(width - 4), normal)
if mode == 0:
screen.refresh()
else:
# Draw subwindow frame
line_height = 1 + len(messages)
screen.hline(line_height, 1, curses.ACS_HLINE, width - 2)
screen.addch(line_height, 0, curses.ACS_SSSB)
screen.addch(line_height, width - 1, curses.ACS_SBSS)
tab = 0
key_in = None
while key_in != 27:
if mode == 1:
choices = ["OK"]
elif mode == 2:
choices = ["OK", "Cancel"]
else:
return 0
for i, item in enumerate(choices):
item_str = ''.join(['[', item, ']'])
tab_pos_x = 6 + 20 * i if mode == 2 else 18
screen.addstr(line_height + 1, tab_pos_x, item_str,
select if i == tab else normal)
screen.refresh()
key_in = screen.getch()
if mode == 2:
# OK or Cancel
if key_in in [9, curses.KEY_LEFT, curses.KEY_RIGHT]:
tab = [1, 0][tab]
if key_in in [ord('a'), ord('c')]:
key_in -= (ord('a') - ord('A'))
if key_in in [ord('C'), ord('O')]:
return [ord('C'), ord('O')].index(key_in)
if key_in in [10, 32]:
return not tab
return 0
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __version__.py : Version info for Hosts Setup Tool.
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__version__ = "1.9.8-SE"
__release__ = "beta"
__revision__ = "$Id$" | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# hoststool.py : Launch the utility.
#
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================
__author__ = "huhamhire <me@huhamhire.com>"
import os
from optparse import OptionParser
import gui
import tui
from __version__ import __version__
import sys
sys.path.append("..")
from util import CommonUtil
class UtilLauncher(object):
"""
HostsUtil class is the entrance to launch `Hosts Setup Utility`. This
class contains methods for user to decide whether to start a session in
Graphical User Interface (GUI) mode or in Text-based User Interface (TUI)
mode.
Usage can be printed to screen via terminal by using ``-h`` or ``--help``
argument. The help message would be like this::
Usage: hoststool.py [-g] [-t] [-h] [--version]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-g, --graphicui launch in GUI(QT) mode
-t, --textui launch in TUI(Curses) mode
.. seealso:: :ref:`Get Started <intro-get-started>`.
.. note:: All methods from this class are declared as `classmethod`.
"""
@classmethod
def launch(cls):
"""
Launch `Hosts Setup Utility`.
.. note:: This is a `classmethod`.
"""
options, args = cls.set_commands()
if options.tui:
cls.launch_tui()
elif options.gui:
cls.launch_gui()
@classmethod
def set_commands(cls):
"""
Set the command options and arguments to launch `Hosts Setup Utility`.
.. note:: This is a `classmethod`.
:return: :meth:`hoststool.UtilLauncher.set_commands` returns two
values:
(:attr:`options`, :attr:`args`)
* options(`optparse.Values`): An instance of
:class:`optparse.Values` containing values for all of your
options—e.g. if --file takes a single string argument, then
options.file will be the filename supplied by the user, or None
if the user did not supply that option args, the list of
positional arguments leftover after parsing options.
* args(`list`): Positional arguments leftover after parsing
options.
.. seealso:: `OptionParser
<http://docs.python.org/2/library/optparse.html>`_.
:rtype: :class:`optparse.Values`, list
"""
usage = "usage: %prog [-g] [-t] [-h] [--version]"
version = "Hosts Setup Utility v" + __version__
parser = OptionParser(usage=usage, version=version)
parser.add_option("-g", "--graphicui", dest="gui",
default=True, action="store_true",
help="launch in GUI(QT) mode")
parser.add_option("-t", "--textui", dest="tui",
default=False, action="store_true",
help="launch in TUI(Curses) mode ")
return parser.parse_args()
@classmethod
def get_custom_conf_path(cls):
if not CommonUtil.check_platform()[0] == "Windows":
path = os.path.expanduser('~/.custom.hosts')
if not os.path.isfile(path):
path = os.path.expanduser('~/custom.hosts')
if os.path.isfile(path):
return path
return None
@classmethod
def launch_gui(cls):
"""
Start a Graphical User Interface (GUI) session of
`Hosts Setup Utility`.
.. note:: This is a `classmethod`.
"""
main = gui.HostsUtil()
main.custom = UtilLauncher.get_custom_conf_path()
main.start()
@classmethod
def launch_tui(cls):
"""
Start a Text-based User Interface (TUI) session of
`Hosts Setup Utility`.
.. note:: This is a `classmethod`.
"""
# Set code page for Windows
system = CommonUtil.check_platform()[0]
cp = "437"
if system == "Windows":
chcp = os.popen("chcp")
cp = chcp.read().split()[-1]
chcp.close()
os.popen("chcp 437")
main = tui.HostsUtil()
main.custom = UtilLauncher.get_custom_conf_path()
main.start()
# Restore the default code page for Windows
if system == "Windows":
os.popen("chcp " + cp)
if __name__ == "__main__":
UtilLauncher.launch() | Python |
#! /usr/local/bin/python
import os
import sys
#BASIC SCRIPT PRESETS
width = 320 # Width of your game in 'true' pixels (ignoring zoom)
height = 240 # Height of your game in 'true' pixels
zoom = 2 # How chunky you want your pixels
src = 'src/' # Name of the source folder under the project folder (if there is one!)
preloader = 'Preloader' # Name of the preloader class
flexBuilder = True # Whether or not to generate a Default.css file
menuState = 'MenuState' # Name of menu state class
playState = 'PlayState' # Name of play state class
#Get name of project
if len(sys.argv) <= 1:
sys.exit(0)
project = sys.argv[1]
#Generate basic game class
filename = project+'/'+src+project+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.*;\r\n')
lines.append('\t[SWF(width="'+str(width*zoom)+'", height="'+str(height*zoom)+'", backgroundColor="#000000")]\r\n')
lines.append('\t[Frame(factoryClass="Preloader")]\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+project+' extends FlxGame\r\n')
lines.append('\t{\r\n')
lines.append('\t\tpublic function '+project+'()\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tsuper('+str(width)+','+str(height)+','+menuState+','+str(zoom)+');\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
#Generate preloader
filename = project+'/'+src+preloader+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.system.FlxPreloader;\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+preloader+' extends FlxPreloader\r\n')
lines.append('\t{\r\n')
lines.append('\t\tpublic function '+preloader+'()\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tclassName = "'+project+'";\r\n')
lines.append('\t\t\tsuper();\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
#Generate Default.css
if flexBuilder:
filename = project+'/'+src+'Default.css';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
fo.write('Add this: "-defaults-css-url Default.css"\nto the project\'s additonal compiler arguments.')
fo.close()
#Generate game menu
filename = project+'/'+src+menuState+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.*;\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+menuState+' extends FlxState\r\n')
lines.append('\t{\r\n')
lines.append('\t\toverride public function create():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tvar t:FlxText;\r\n')
lines.append('\t\t\tt = new FlxText(0,FlxG.height/2-10,FlxG.width,"'+project+'");\r\n')
lines.append('\t\t\tt.size = 16;\r\n')
lines.append('\t\t\tt.alignment = "center";\r\n')
lines.append('\t\t\tadd(t);\r\n')
lines.append('\t\t\tt = new FlxText(FlxG.width/2-50,FlxG.height-20,100,"click to play");\r\n')
lines.append('\t\t\tt.alignment = "center";\r\n')
lines.append('\t\t\tadd(t);\r\n')
lines.append('\t\t\t\r\n')
lines.append('\t\t\tFlxG.mouse.show();\r\n')
lines.append('\t\t}\r\n')
lines.append('\r\n')
lines.append('\t\toverride public function update():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tsuper.update();\r\n')
lines.append('\r\n')
lines.append('\t\t\tif(FlxG.mouse.justPressed())\r\n')
lines.append('\t\t\t{\r\n')
lines.append('\t\t\t\tFlxG.mouse.hide();\r\n')
lines.append('\t\t\t\tFlxG.switchState(new PlayState());\r\n')
lines.append('\t\t\t}\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
#Generate basic game state
filename = project+'/'+src+playState+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.*;\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+playState+' extends FlxState\r\n')
lines.append('\t{\r\n')
lines.append('\t\toverride public function create():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tadd(new FlxText(0,0,100,"INSERT GAME HERE"));\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
print('Successfully generated game class, preloader, menu state, and play state.') | Python |
#! /usr/local/bin/python
import os
import sys
#BASIC SCRIPT PRESETS
width = 320 # Width of your game in 'true' pixels (ignoring zoom)
height = 240 # Height of your game in 'true' pixels
zoom = 2 # How chunky you want your pixels
src = 'src/' # Name of the source folder under the project folder (if there is one!)
preloader = 'Preloader' # Name of the preloader class
flexBuilder = True # Whether or not to generate a Default.css file
menuState = 'MenuState' # Name of menu state class
playState = 'PlayState' # Name of play state class
#Get name of project
if len(sys.argv) <= 1:
sys.exit(0)
project = sys.argv[1]
#Generate basic game class
filename = project+'/'+src+project+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.*;\r\n')
lines.append('\t[SWF(width="'+str(width*zoom)+'", height="'+str(height*zoom)+'", backgroundColor="#000000")]\r\n')
lines.append('\t[Frame(factoryClass="Preloader")]\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+project+' extends FlxGame\r\n')
lines.append('\t{\r\n')
lines.append('\t\tpublic function '+project+'()\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tsuper('+str(width)+','+str(height)+','+menuState+','+str(zoom)+');\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
#Generate preloader
filename = project+'/'+src+preloader+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.system.FlxPreloader;\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+preloader+' extends FlxPreloader\r\n')
lines.append('\t{\r\n')
lines.append('\t\tpublic function '+preloader+'()\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tclassName = "'+project+'";\r\n')
lines.append('\t\t\tsuper();\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
#Generate Default.css
if flexBuilder:
filename = project+'/'+src+'Default.css';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
fo.write('Add this: "-defaults-css-url Default.css"\nto the project\'s additonal compiler arguments.')
fo.close()
#Generate game menu
filename = project+'/'+src+menuState+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.*;\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+menuState+' extends FlxState\r\n')
lines.append('\t{\r\n')
lines.append('\t\toverride public function create():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tvar t:FlxText;\r\n')
lines.append('\t\t\tt = new FlxText(0,FlxG.height/2-10,FlxG.width,"'+project+'");\r\n')
lines.append('\t\t\tt.size = 16;\r\n')
lines.append('\t\t\tt.alignment = "center";\r\n')
lines.append('\t\t\tadd(t);\r\n')
lines.append('\t\t\tt = new FlxText(FlxG.width/2-50,FlxG.height-20,100,"click to play");\r\n')
lines.append('\t\t\tt.alignment = "center";\r\n')
lines.append('\t\t\tadd(t);\r\n')
lines.append('\t\t\t\r\n')
lines.append('\t\t\tFlxG.mouse.show();\r\n')
lines.append('\t\t}\r\n')
lines.append('\r\n')
lines.append('\t\toverride public function update():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tsuper.update();\r\n')
lines.append('\r\n')
lines.append('\t\t\tif(FlxG.mouse.justPressed())\r\n')
lines.append('\t\t\t{\r\n')
lines.append('\t\t\t\tFlxG.mouse.hide();\r\n')
lines.append('\t\t\t\tFlxG.switchState(new PlayState());\r\n')
lines.append('\t\t\t}\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
#Generate basic game state
filename = project+'/'+src+playState+'.as';
try:
fo = open(filename, 'w')
except IOError:
print('Can\'t open '+filename+' for writing.')
sys.exit(0)
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.*;\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+playState+' extends FlxState\r\n')
lines.append('\t{\r\n')
lines.append('\t\toverride public function create():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tadd(new FlxText(0,0,100,"INSERT GAME HERE"));\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
fo.writelines(lines)
fo.close()
print('Successfully generated game class, preloader, menu state, and play state.') | Python |
#====================================================================
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation. For more
# information on the Apache Software Foundation, please see
# <http://www.apache.org/>.
#
import os
import re
import tempfile
import shutil
ignore_pattern = re.compile('^(.svn|target|bin|classes)')
java_pattern = re.compile('^.*\.java')
annot_pattern = re.compile('import org\.apache\.http\.annotation\.')
def process_dir(dir):
files = os.listdir(dir)
for file in files:
f = os.path.join(dir, file)
if os.path.isdir(f):
if not ignore_pattern.match(file):
process_dir(f)
else:
if java_pattern.match(file):
process_source(f)
def process_source(filename):
tmp = tempfile.mkstemp()
tmpfd = tmp[0]
tmpfile = tmp[1]
try:
changed = False
dst = os.fdopen(tmpfd, 'w')
try:
src = open(filename)
try:
for line in src:
if annot_pattern.match(line):
changed = True
line = line.replace('import org.apache.http.annotation.', 'import net.jcip.annotations.')
dst.write(line)
finally:
src.close()
finally:
dst.close();
if changed:
shutil.move(tmpfile, filename)
else:
os.remove(tmpfile)
except:
os.remove(tmpfile)
process_dir('.')
| Python |
#!/usr/bin/env python
# -*- encoding:utf8 -*-
# protoc-gen-erl
# Google's Protocol Buffers project, ported to lua.
# https://code.google.com/p/protoc-gen-lua/
#
# Copyright (c) 2010 , 林卓毅 (Zhuoyi Lin) netsnail@gmail.com
# All rights reserved.
#
# Use, modification and distribution are subject to the "New BSD License"
# as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
import sys
import os.path as path
from cStringIO import StringIO
import plugin_pb2
import google.protobuf.descriptor_pb2 as descriptor_pb2
_packages = {}
_files = {}
_message = {}
FDP = plugin_pb2.descriptor_pb2.FieldDescriptorProto
if sys.platform == "win32":
import msvcrt, os
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
class CppType:
CPPTYPE_INT32 = 1
CPPTYPE_INT64 = 2
CPPTYPE_UINT32 = 3
CPPTYPE_UINT64 = 4
CPPTYPE_DOUBLE = 5
CPPTYPE_FLOAT = 6
CPPTYPE_BOOL = 7
CPPTYPE_ENUM = 8
CPPTYPE_STRING = 9
CPPTYPE_MESSAGE = 10
CPP_TYPE ={
FDP.TYPE_DOUBLE : CppType.CPPTYPE_DOUBLE,
FDP.TYPE_FLOAT : CppType.CPPTYPE_FLOAT,
FDP.TYPE_INT64 : CppType.CPPTYPE_INT64,
FDP.TYPE_UINT64 : CppType.CPPTYPE_UINT64,
FDP.TYPE_INT32 : CppType.CPPTYPE_INT32,
FDP.TYPE_FIXED64 : CppType.CPPTYPE_UINT64,
FDP.TYPE_FIXED32 : CppType.CPPTYPE_UINT32,
FDP.TYPE_BOOL : CppType.CPPTYPE_BOOL,
FDP.TYPE_STRING : CppType.CPPTYPE_STRING,
FDP.TYPE_MESSAGE : CppType.CPPTYPE_MESSAGE,
FDP.TYPE_BYTES : CppType.CPPTYPE_STRING,
FDP.TYPE_UINT32 : CppType.CPPTYPE_UINT32,
FDP.TYPE_ENUM : CppType.CPPTYPE_ENUM,
FDP.TYPE_SFIXED32 : CppType.CPPTYPE_INT32,
FDP.TYPE_SFIXED64 : CppType.CPPTYPE_INT64,
FDP.TYPE_SINT32 : CppType.CPPTYPE_INT32,
FDP.TYPE_SINT64 : CppType.CPPTYPE_INT64
}
def printerr(*args):
sys.stderr.write(" ".join(args))
sys.stderr.write("\n")
sys.stderr.flush()
class TreeNode(object):
def __init__(self, name, parent=None, filename=None, package=None):
super(TreeNode, self).__init__()
self.child = []
self.parent = parent
self.filename = filename
self.package = package
if parent:
self.parent.add_child(self)
self.name = name
def add_child(self, child):
self.child.append(child)
def find_child(self, child_names):
if child_names:
for i in self.child:
if i.name == child_names[0]:
return i.find_child(child_names[1:])
raise StandardError
else:
return self
def get_child(self, child_name):
for i in self.child:
if i.name == child_name:
return i
return None
def get_path(self, end = None):
pos = self
out = []
while pos and pos != end:
out.append(pos.name)
pos = pos.parent
out.reverse()
return '.'.join(out)
def get_global_name(self):
return self.get_path()
def get_local_name(self):
pos = self
while pos.parent:
pos = pos.parent
if self.package and pos.name == self.package[-1]:
break
return self.get_path(pos)
def __str__(self):
return self.to_string(0)
def __repr__(self):
return str(self)
def to_string(self, indent = 0):
return ' '*indent + '<TreeNode ' + self.name + '(\n' + \
','.join([i.to_string(indent + 4) for i in self.child]) + \
' '*indent +')>\n'
class Env(object):
filename = None
package = None
extend = None
descriptor = None
message = None
context = None
register = None
def __init__(self):
self.message_tree = TreeNode('')
self.scope = self.message_tree
def get_global_name(self):
return self.scope.get_global_name()
def get_local_name(self):
return self.scope.get_local_name()
def get_ref_name(self, type_name):
try:
node = self.lookup_name(type_name)
except:
# if the child doesn't be founded, it must be in this file
return type_name[len('.'.join(self.package)) + 2:]
if node.filename != self.filename:
return node.filename + '_pb.' + node.get_local_name()
return node.get_local_name()
def lookup_name(self, name):
names = name.split('.')
if names[0] == '':
return self.message_tree.find_child(names[1:])
else:
return self.scope.parent.find_child(names)
def enter_package(self, package):
if not package:
return self.message_tree
names = package.split('.')
pos = self.message_tree
for i, name in enumerate(names):
new_pos = pos.get_child(name)
if new_pos:
pos = new_pos
else:
return self._build_nodes(pos, names[i:])
return pos
def enter_file(self, filename, package):
self.filename = filename
self.package = package.split('.')
self._init_field()
self.scope = self.enter_package(package)
def exit_file(self):
self._init_field()
self.filename = None
self.package = []
self.scope = self.scope.parent
def enter(self, message_name):
self.scope = TreeNode(message_name, self.scope, self.filename,
self.package)
def exit(self):
self.scope = self.scope.parent
def _init_field(self):
self.descriptor = []
self.context = []
self.message = []
self.register = []
def _build_nodes(self, node, names):
parent = node
for i in names:
parent = TreeNode(i, parent, self.filename, self.package)
return parent
class Writer(object):
def __init__(self, prefix=None):
self.io = StringIO()
self.__indent = ''
self.__prefix = prefix
def getvalue(self):
return self.io.getvalue()
def __enter__(self):
self.__indent += ' '
return self
def __exit__(self, type, value, trackback):
self.__indent = self.__indent[:-4]
def __call__(self, data):
self.io.write(self.__indent)
if self.__prefix:
self.io.write(self.__prefix)
self.io.write(data)
DEFAULT_VALUE = {
FDP.TYPE_DOUBLE : '0.0',
FDP.TYPE_FLOAT : '0.0',
FDP.TYPE_INT64 : '0',
FDP.TYPE_UINT64 : '0',
FDP.TYPE_INT32 : '0',
FDP.TYPE_FIXED64 : '0',
FDP.TYPE_FIXED32 : '0',
FDP.TYPE_BOOL : 'false',
FDP.TYPE_STRING : '""',
FDP.TYPE_MESSAGE : 'nil',
FDP.TYPE_BYTES : '""',
FDP.TYPE_UINT32 : '0',
FDP.TYPE_ENUM : '1',
FDP.TYPE_SFIXED32 : '0',
FDP.TYPE_SFIXED64 : '0',
FDP.TYPE_SINT32 : '0',
FDP.TYPE_SINT64 : '0',
}
def code_gen_enum_item(index, enum_value, env):
full_name = env.get_local_name() + '.' + enum_value.name
obj_name = full_name.upper().replace('.', '_') + '_ENUM'
env.descriptor.append(
"local %s = protobuf.EnumValueDescriptor();\n"% obj_name
)
context = Writer(obj_name)
context('.name = "%s"\n' % enum_value.name)
context('.index = %d\n' % index)
context('.number = %d\n' % enum_value.number)
env.context.append(context.getvalue())
return obj_name
def code_gen_enum(enum_desc, env):
env.enter(enum_desc.name)
full_name = env.get_local_name()
obj_name = full_name.upper().replace('.', '_')
env.descriptor.append(
"local %s = protobuf.EnumDescriptor();\n"% obj_name
)
context = Writer(obj_name)
context('.name = "%s"\n' % enum_desc.name)
context('.full_name = "%s"\n' % env.get_global_name())
values = []
for i, enum_value in enumerate(enum_desc.value):
values.append(code_gen_enum_item(i, enum_value, env))
context('.values = {%s}\n' % ','.join(values))
env.context.append(context.getvalue())
env.exit()
return obj_name
def code_gen_field(index, field_desc, env):
full_name = env.get_local_name() + '.' + field_desc.name
obj_name = full_name.upper().replace('.', '_') + '_FIELD'
env.descriptor.append(
"local %s = protobuf.FieldDescriptor();\n"% obj_name
)
context = Writer(obj_name)
context('.name = "%s"\n' % field_desc.name)
context('.full_name = "%s"\n' % (
env.get_global_name() + '.' + field_desc.name))
context('.number = %d\n' % field_desc.number)
context('.index = %d\n' % index)
context('.label = %d\n' % field_desc.label)
if field_desc.HasField("default_value"):
context('.has_default_value = true\n')
value = field_desc.default_value
if field_desc.type == FDP.TYPE_STRING:
context('.default_value = "%s"\n'%value)
else:
context('.default_value = %s\n'%value)
else:
context('.has_default_value = false\n')
if field_desc.label == FDP.LABEL_REPEATED:
default_value = "{}"
elif field_desc.HasField('type_name'):
default_value = "nil"
else:
default_value = DEFAULT_VALUE[field_desc.type]
context('.default_value = %s\n' % default_value)
if field_desc.HasField('type_name'):
type_name = env.get_ref_name(field_desc.type_name).upper().replace('.', '_')
if field_desc.type == FDP.TYPE_MESSAGE:
context('.message_type = %s\n' % type_name)
else:
context('.enum_type = %s\n' % type_name)
if field_desc.HasField('extendee'):
type_name = env.get_ref_name(field_desc.extendee)
env.register.append(
"%s.RegisterExtension(%s)\n" % (type_name, obj_name)
)
context('.type = %d\n' % field_desc.type)
context('.cpp_type = %d\n\n' % CPP_TYPE[field_desc.type])
env.context.append(context.getvalue())
return obj_name
def code_gen_message(message_descriptor, env, containing_type = None):
env.enter(message_descriptor.name)
full_name = env.get_local_name()
obj_name = full_name.upper().replace('.', '_')
env.descriptor.append(
"local %s = protobuf.Descriptor();\n"% obj_name
)
context = Writer(obj_name)
context('.name = "%s"\n' % message_descriptor.name)
context('.full_name = "%s"\n' % env.get_global_name())
nested_types = []
for msg_desc in message_descriptor.nested_type:
msg_name = code_gen_message(msg_desc, env, obj_name)
nested_types.append(msg_name)
context('.nested_types = {%s}\n' % ', '.join(nested_types))
enums = []
for enum_desc in message_descriptor.enum_type:
enums.append(code_gen_enum(enum_desc, env))
context('.enum_types = {%s}\n' % ', '.join(enums))
fields = []
for i, field_desc in enumerate(message_descriptor.field):
fields.append(code_gen_field(i, field_desc, env))
context('.fields = {%s}\n' % ', '.join(fields))
if len(message_descriptor.extension_range) > 0:
context('.is_extendable = true\n')
else:
context('.is_extendable = false\n')
extensions = []
for i, field_desc in enumerate(message_descriptor.extension):
extensions.append(code_gen_field(i, field_desc, env))
context('.extensions = {%s}\n' % ', '.join(extensions))
if containing_type:
context('.containing_type = %s\n' % containing_type)
env.message.append('%s = protobuf.Message(%s)\n' % (full_name,
obj_name))
env.context.append(context.getvalue())
env.exit()
return obj_name
def write_header(writer):
writer("""-- Generated By protoc-gen-lua Do not Edit
""")
def code_gen_file(proto_file, env, is_gen):
filename = path.splitext(proto_file.name)[0]
env.enter_file(filename, proto_file.package)
includes = []
for f in proto_file.dependency:
inc_file = path.splitext(f)[0]
includes.append(inc_file)
# for field_desc in proto_file.extension:
# code_gen_extensions(field_desc, field_desc.name, env)
for enum_desc in proto_file.enum_type:
code_gen_enum(enum_desc, env)
for enum_value in enum_desc.value:
env.message.append('%s = %d\n' % (enum_value.name,
enum_value.number))
for msg_desc in proto_file.message_type:
code_gen_message(msg_desc, env)
if is_gen:
lua = Writer()
write_header(lua)
lua('local protobuf = require "protobuf"\n')
for i in includes:
lua('local %s_pb = require("%s_pb")\n' % (i, i))
lua("module('%s_pb')\n" % env.filename)
lua('\n\n')
map(lua, env.descriptor)
lua('\n')
map(lua, env.context)
lua('\n')
env.message.sort()
map(lua, env.message)
lua('\n')
map(lua, env.register)
_files[env.filename+ '_pb.lua'] = lua.getvalue()
env.exit_file()
def main():
plugin_require_bin = sys.stdin.read()
code_gen_req = plugin_pb2.CodeGeneratorRequest()
code_gen_req.ParseFromString(plugin_require_bin)
env = Env()
for proto_file in code_gen_req.proto_file:
code_gen_file(proto_file, env,
proto_file.name in code_gen_req.file_to_generate)
code_generated = plugin_pb2.CodeGeneratorResponse()
for k in _files:
file_desc = code_generated.file.add()
file_desc.name = k
file_desc.content = _files[k]
sys.stdout.write(code_generated.SerializeToString())
if __name__ == "__main__":
main()
| Python |
#!/usr/bin/python
#
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__author__ = 'afshar@google.com (Ali Afshar)'
# Add the library location to the path
import sys
sys.path.insert(0, 'lib')
import os
import httplib2
import sessions
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from apiclient.discovery import build
from apiclient.http import MediaUpload
from oauth2client.client import flow_from_clientsecrets
from oauth2client.client import FlowExchangeError
from oauth2client.client import AccessTokenRefreshError
from oauth2client.appengine import CredentialsProperty
from oauth2client.appengine import StorageByKeyName
from oauth2client.appengine import simplejson as json
ALL_SCOPES = ('https://www.googleapis.com/auth/drive.file '
'https://www.googleapis.com/auth/userinfo.email '
'https://www.googleapis.com/auth/userinfo.profile')
def SibPath(name):
"""Generate a path that is a sibling of this file.
Args:
name: Name of sibling file.
Returns:
Path to sibling file.
"""
return os.path.join(os.path.dirname(__file__), name)
# Load the secret that is used for client side sessions
# Create one of these for yourself with, for example:
# python -c "import os; print os.urandom(64)" > session-secret
SESSION_SECRET = open(SibPath('session.secret')).read()
INDEX_HTML = open(SibPath('index.html')).read()
class Credentials(db.Model):
"""Datastore entity for storing OAuth2.0 credentials.
The CredentialsProperty is provided by the Google API Python Client, and is
used by the Storage classes to store OAuth 2.0 credentials in the data store."""
credentials = CredentialsProperty()
def CreateService(service, version, creds):
"""Create a Google API service.
Load an API service from a discovery document and authorize it with the
provided credentials.
Args:
service: Service name (e.g 'drive', 'oauth2').
version: Service version (e.g 'v1').
creds: Credentials used to authorize service.
Returns:
Authorized Google API service.
"""
# Instantiate an Http instance
http = httplib2.Http()
# Authorize the Http instance with the passed credentials
creds.authorize(http)
# Build a service from the passed discovery document path
return build(service, version, http=http)
class DriveState(object):
"""Store state provided by Drive."""
def __init__(self, state):
"""Create a new instance of drive state.
Parse and load the JSON state parameter.
Args:
state: State query parameter as a string.
"""
if state:
state_data = json.loads(state)
self.action = state_data['action']
self.ids = map(str, state_data.get('ids', []))
else:
self.action = 'create'
self.ids = []
@classmethod
def FromRequest(cls, request):
"""Create a Drive State instance from an HTTP request.
Args:
cls: Type this class method is called against.
request: HTTP request.
"""
return DriveState(request.get('state'))
class BaseDriveHandler(webapp.RequestHandler):
"""Base request handler for drive applications.
Adds Authorization support for Drive.
"""
def CreateOAuthFlow(self):
"""Create OAuth2.0 flow controller
This controller can be used to perform all parts of the OAuth 2.0 dance
including exchanging an Authorization code.
Args:
request: HTTP request to create OAuth2.0 flow for
Returns:
OAuth2.0 Flow instance suitable for performing OAuth2.0.
"""
flow = flow_from_clientsecrets('client_secrets.json', scope='')
# Dynamically set the redirect_uri based on the request URL. This is extremely
# convenient for debugging to an alternative host without manually setting the
# redirect URI.
flow.redirect_uri = self.request.url.split('?', 1)[0].rsplit('/', 1)[0]
return flow
def GetCodeCredentials(self):
"""Create OAuth 2.0 credentials by extracting a code and performing OAuth2.0.
The authorization code is extracted form the URI parameters. If it is absent,
None is returned immediately. Otherwise, if it is present, it is used to
perform step 2 of the OAuth 2.0 web server flow.
Once a token is received, the user information is fetched from the userinfo
service and stored in the session. The token is saved in the datastore against
the user ID received from the userinfo service.
Args:
request: HTTP request used for extracting an authorization code and the
session information.
Returns:
OAuth2.0 credentials suitable for authorizing clients or None if
Authorization could not take place.
"""
# Other frameworks use different API to get a query parameter.
code = self.request.get('code')
if not code:
# returns None to indicate that no code was passed from Google Drive.
return None
# Auth flow is a controller that is loaded with the client information,
# including client_id, client_secret, redirect_uri etc
oauth_flow = self.CreateOAuthFlow()
# Perform the exchange of the code. If there is a failure with exchanging
# the code, return None.
try:
creds = oauth_flow.step2_exchange(code)
except FlowExchangeError:
return None
# Create an API service that can use the userinfo API. Authorize it with our
# credentials that we gained from the code exchange.
users_service = CreateService('oauth2', 'v2', creds)
# Make a call against the userinfo service to retrieve the user's information.
# In this case we are interested in the user's "id" field.
userid = users_service.userinfo().get().execute().get('id')
# Store the user id in the user's cookie-based session.
session = sessions.LilCookies(self, SESSION_SECRET)
session.set_secure_cookie(name='userid', value=userid)
# Store the credentials in the data store using the userid as the key.
StorageByKeyName(Credentials, userid, 'credentials').put(creds)
return creds
def GetSessionCredentials(self):
"""Get OAuth 2.0 credentials for an HTTP session.
If the user has a user id stored in their cookie session, extract that value
and use it to load that user's credentials from the data store.
Args:
request: HTTP request to use session from.
Returns:
OAuth2.0 credentials suitable for authorizing clients.
"""
# Try to load the user id from the session
session = sessions.LilCookies(self, SESSION_SECRET)
userid = session.get_secure_cookie(name='userid')
if not userid:
# return None to indicate that no credentials could be loaded from the
# session.
return None
# Load the credentials from the data store, using the userid as a key.
creds = StorageByKeyName(Credentials, userid, 'credentials').get()
# if the credentials are invalid, return None to indicate that the credentials
# cannot be used.
if creds and creds.invalid:
return None
return creds
def RedirectAuth(self):
"""Redirect a handler to an authorization page.
Used when a handler fails to fetch credentials suitable for making Drive API
requests. The request is redirected to an OAuth 2.0 authorization approval
page and on approval, are returned to application.
Args:
handler: webapp.RequestHandler to redirect.
"""
flow = self.CreateOAuthFlow()
# Manually add the required scopes. Since this redirect does not originate
# from the Google Drive UI, which authomatically sets the scopes that are
# listed in the API Console.
flow.scope = ALL_SCOPES
# Create the redirect URI by performing step 1 of the OAuth 2.0 web server
# flow.
uri = flow.step1_get_authorize_url(flow.redirect_uri)
# Perform the redirect.
self.redirect(uri)
def RespondJSON(self, data):
"""Generate a JSON response and return it to the client.
Args:
data: The data that will be converted to JSON to return.
"""
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps(data))
def CreateAuthorizedService(self, service, version):
"""Create an authorize service instance.
The service can only ever retrieve the credentials from the session.
Args:
service: Service name (e.g 'drive', 'oauth2').
version: Service version (e.g 'v1').
Returns:
Authorized service or redirect to authorization flow if no credentials.
"""
# For the service, the session holds the credentials
creds = self.GetSessionCredentials()
if creds:
# If the session contains credentials, use them to create a Drive service
# instance.
return CreateService(service, version, creds)
else:
# If no credentials could be loaded from the session, redirect the user to
# the authorization page.
self.RedirectAuth()
def CreateDrive(self):
"""Create a drive client instance."""
return self.CreateAuthorizedService('drive', 'v2')
def CreateUserInfo(self):
"""Create a user info client instance."""
return self.CreateAuthorizedService('oauth2', 'v2')
class MainPage(BaseDriveHandler):
"""Web handler for the main page.
Handles requests and returns the user interface for Open With and Create
cases. Responsible for parsing the state provided from the Drive UI and acting
appropriately.
"""
def get(self):
"""Handle GET for Create New and Open With.
This creates an authorized client, and checks whether a resource id has
been passed or not. If a resource ID has been passed, this is the Open
With use-case, otherwise it is the Create New use-case.
"""
# Generate a state instance for the request, this includes the action, and
# the file id(s) that have been sent from the Drive user interface.
drive_state = DriveState.FromRequest(self.request)
if drive_state.action == 'open' and len(drive_state.ids) > 0:
code = self.request.get('code')
if code:
code = '?code=%s' % code
self.redirect('/#edit/%s%s' % (drive_state.ids[0], code))
return
# Fetch the credentials by extracting an OAuth 2.0 authorization code from
# the request URL. If the code is not present, redirect to the OAuth 2.0
# authorization URL.
creds = self.GetCodeCredentials()
if not creds:
return self.RedirectAuth()
# Extract the numerical portion of the client_id from the stored value in
# the OAuth flow. You could also store this value as a separate variable
# somewhere.
client_id = self.CreateOAuthFlow().client_id.split('.')[0].split('-')[0]
self.RenderTemplate()
def RenderTemplate(self):
"""Render a named template in a context."""
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(INDEX_HTML)
class ServiceHandler(BaseDriveHandler):
"""Web handler for the service to read and write to Drive."""
def post(self):
"""Called when HTTP POST requests are received by the web application.
The POST body is JSON which is deserialized and used as values to create a
new file in Drive. The authorization access token for this action is
retreived from the data store.
"""
# Create a Drive service
service = self.CreateDrive()
if service is None:
return
# Load the data that has been posted as JSON
data = self.RequestJSON()
# Create a new file data structure.
resource = {
'title': data['title'],
'description': data['description'],
'mimeType': data['mimeType'],
}
try:
# Make an insert request to create a new file. A MediaInMemoryUpload
# instance is used to upload the file body.
resource = service.files().insert(
body=resource,
media_body=MediaInMemoryUpload(
data.get('content', ''),
data['mimeType'],
resumable=True)
).execute()
# Respond with the new file id as JSON.
self.RespondJSON(resource['id'])
except AccessTokenRefreshError:
# In cases where the access token has expired and cannot be refreshed
# (e.g. manual token revoking) redirect the user to the authorization page
# to authorize.
self.RedirectAuth()
def get(self):
"""Called when HTTP GET requests are received by the web application.
Use the query parameter file_id to fetch the required file's metadata then
content and return it as a JSON object.
Since DrEdit deals with text files, it is safe to dump the content directly
into JSON, but this is not the case with binary files, where something like
Base64 encoding is more appropriate.
"""
# Create a Drive service
service = self.CreateDrive()
if service is None:
return
try:
# Requests are expected to pass the file_id query parameter.
file_id = self.request.get('file_id')
if file_id:
# Fetch the file metadata by making the service.files().get method of
# the Drive API.
f = service.files().get(fileId=file_id).execute()
downloadUrl = f.get('downloadUrl')
# If a download URL is provided in the file metadata, use it to make an
# authorized request to fetch the file ontent. Set this content in the
# data to return as the 'content' field. If there is no downloadUrl,
# just set empty content.
if downloadUrl:
resp, f['content'] = service._http.request(downloadUrl)
else:
f['content'] = ''
else:
f = None
# Generate a JSON response with the file data and return to the client.
self.RespondJSON(f)
except AccessTokenRefreshError:
# Catch AccessTokenRefreshError which occurs when the API client library
# fails to refresh a token. This occurs, for example, when a refresh token
# is revoked. When this happens the user is redirected to the
# Authorization URL.
self.RedirectAuth()
def put(self):
"""Called when HTTP PUT requests are received by the web application.
The PUT body is JSON which is deserialized and used as values to update
a file in Drive. The authorization access token for this action is
retreived from the data store.
"""
# Create a Drive service
service = self.CreateDrive()
if service is None:
return
# Load the data that has been posted as JSON
data = self.RequestJSON()
try:
# Create a new file data structure.
content = data.get('content')
if 'content' in data:
data.pop('content')
if content is not None:
# Make an update request to update the file. A MediaInMemoryUpload
# instance is used to upload the file body. Because of a limitation, this
# request must be made in two parts, the first to update the metadata, and
# the second to update the body.
resource = service.files().update(
fileId=data['resource_id'],
newRevision=self.request.get('newRevision', False),
body=data,
media_body=MediaInMemoryUpload(
content, data['mimeType'], resumable=True)
).execute()
else:
# Only update the metadata, a patch request is prefered but not yet
# supported on Google App Engine; see
# http://code.google.com/p/googleappengine/issues/detail?id=6316.
resource = service.files().update(
fileId=data['resource_id'],
newRevision=self.request.get('newRevision', False),
body=data).execute()
# Respond with the new file id as JSON.
self.RespondJSON(resource['id'])
except AccessTokenRefreshError:
# In cases where the access token has expired and cannot be refreshed
# (e.g. manual token revoking) redirect the user to the authorization page
# to authorize.
self.RedirectAuth()
def RequestJSON(self):
"""Load the request body as JSON.
Returns:
Request body loaded as JSON or None if there is no request body.
"""
if self.request.body:
return json.loads(self.request.body)
class UserHandler(BaseDriveHandler):
"""Web handler for the service to read user information."""
def get(self):
"""Called when HTTP GET requests are received by the web application."""
# Create a Drive service
service = self.CreateUserInfo()
if service is None:
return
try:
result = service.userinfo().get().execute()
# Generate a JSON response with the file data and return to the client.
self.RespondJSON(result)
except AccessTokenRefreshError:
# Catch AccessTokenRefreshError which occurs when the API client library
# fails to refresh a token. This occurs, for example, when a refresh token
# is revoked. When this happens the user is redirected to the
# Authorization URL.
self.RedirectAuth()
class AboutHandler(BaseDriveHandler):
"""Web handler for the service to read user information."""
def get(self):
"""Called when HTTP GET requests are received by the web application."""
# Create a Drive service
service = self.CreateDrive()
if service is None:
return
try:
result = service.about().get().execute()
# Generate a JSON response with the file data and return to the client.
self.RespondJSON(result)
except AccessTokenRefreshError:
# Catch AccessTokenRefreshError which occurs when the API client library
# fails to refresh a token. This occurs, for example, when a refresh token
# is revoked. When this happens the user is redirected to the
# Authorization URL.
self.RedirectAuth()
class MediaInMemoryUpload(MediaUpload):
"""MediaUpload for a chunk of bytes.
Construct a MediaFileUpload and pass as the media_body parameter of the
method. For example, if we had a service that allowed plain text:
"""
def __init__(self, body, mimetype='application/octet-stream',
chunksize=256*1024, resumable=False):
"""Create a new MediaBytesUpload.
Args:
body: string, Bytes of body content.
mimetype: string, Mime-type of the file or default of
'application/octet-stream'.
chunksize: int, File will be uploaded in chunks of this many bytes. Only
used if resumable=True.
resumable: bool, True if this is a resumable upload. False means upload
in a single request.
"""
self._body = body
self._mimetype = mimetype
self._resumable = resumable
self._chunksize = chunksize
def chunksize(self):
"""Chunk size for resumable uploads.
Returns:
Chunk size in bytes.
"""
return self._chunksize
def mimetype(self):
"""Mime type of the body.
Returns:
Mime type.
"""
return self._mimetype
def size(self):
"""Size of upload.
Returns:
Size of the body.
"""
return len(self._body)
def resumable(self):
"""Whether this upload is resumable.
Returns:
True if resumable upload or False.
"""
return self._resumable
def getbytes(self, begin, length):
"""Get bytes from the media.
Args:
begin: int, offset from beginning of file.
length: int, number of bytes to read, starting at begin.
Returns:
A string of bytes read. May be shorter than length if EOF was reached
first.
"""
return self._body[begin:begin + length]
# Create an WSGI application suitable for running on App Engine
application = webapp.WSGIApplication(
[('/', MainPage), ('/svc', ServiceHandler), ('/about', AboutHandler),
('/user', UserHandler)],
# XXX Set to False in production.
debug=True
)
def main():
"""Main entry point for executing a request with this handler."""
run_wsgi_app(application)
if __name__ == "__main__":
main()
| Python |
#!/usr/bin/python
#
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__author__ = 'afshar@google.com (Ali Afshar)'
import os
import httplib2
import sessions
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from apiclient.discovery import build_from_document
from apiclient.http import MediaUpload
from oauth2client import client
from oauth2client.appengine import CredentialsProperty
from oauth2client.appengine import StorageByKeyName
from oauth2client.appengine import simplejson as json
APIS_BASE = 'https://www.googleapis.com'
ALL_SCOPES = ('https://www.googleapis.com/auth/drive.file '
'https://www.googleapis.com/auth/userinfo.email '
'https://www.googleapis.com/auth/userinfo.profile')
CODE_PARAMETER = 'code'
STATE_PARAMETER = 'state'
SESSION_SECRET = open('session.secret').read()
DRIVE_DISCOVERY_DOC = open('drive.json').read()
USERS_DISCOVERY_DOC = open('users.json').read()
class Credentials(db.Model):
"""Datastore entity for storing OAuth2.0 credentials."""
credentials = CredentialsProperty()
def CreateOAuthFlow(request):
"""Create OAuth2.0 flow controller
Args:
request: HTTP request to create OAuth2.0 flow for
Returns:
OAuth2.0 Flow instance suitable for performing OAuth2.0.
"""
flow = client.flow_from_clientsecrets('client-debug.json', scope='')
flow.redirect_uri = request.url.split('?', 1)[0].rstrip('/')
return flow
def GetCodeCredentials(request):
"""Create OAuth2.0 credentials by extracting a code and performing OAuth2.0.
Args:
request: HTTP request used for extracting an authorization code.
Returns:
OAuth2.0 credentials suitable for authorizing clients.
"""
code = request.get(CODE_PARAMETER)
if code:
oauth_flow = CreateOAuthFlow(request)
creds = oauth_flow.step2_exchange(code)
users_service = CreateService(USERS_DISCOVERY_DOC, creds)
userid = users_service.userinfo().get().execute().get('id')
request.session.set_secure_cookie(name='userid', value=userid)
StorageByKeyName(Credentials, userid, 'credentials').put(creds)
return creds
def GetSessionCredentials(request):
"""Get OAuth2.0 credentials for an HTTP session.
Args:
request: HTTP request to use session from.
Returns:
OAuth2.0 credentials suitable for authorizing clients.
"""
userid = request.session.get_secure_cookie(name='userid')
if userid:
creds = StorageByKeyName(Credentials, userid, 'credentials').get()
if creds and not creds.invalid:
return creds
def CreateService(discovery_doc, creds):
"""Create a Google API service.
Args:
discovery_doc: Discovery doc used to configure service.
creds: Credentials used to authorize service.
Returns:
Authorized Google API service.
"""
http = httplib2.Http()
creds.authorize(http)
return build_from_document(discovery_doc, APIS_BASE, http=http)
def RedirectAuth(handler):
"""Redirect a handler to an authorization page.
Args:
handler: webapp.RequestHandler to redirect.
"""
flow = CreateOAuthFlow(handler.request)
flow.scope = ALL_SCOPES
uri = flow.step1_get_authorize_url(flow.redirect_uri)
handler.redirect(uri)
def CreateDrive(handler):
"""Create a fully authorized drive service for this handler.
Args:
handler: RequestHandler from which drive service is generated.
Returns:
Authorized drive service, generated from the handler request.
"""
request = handler.request
request.session = sessions.LilCookies(handler, SESSION_SECRET)
creds = GetCodeCredentials(request) or GetSessionCredentials(request)
if creds:
return CreateService(DRIVE_DISCOVERY_DOC, creds)
else:
RedirectAuth(handler)
def ServiceEnabled(view):
"""Decorator to inject an authorized service into an HTTP handler.
Args:
view: HTTP request handler method.
Returns:
Decorated handler which accepts the service as a parameter.
"""
def ServiceDecoratedView(handler, view=view):
service = CreateDrive(handler)
response_data = view(handler, service)
handler.response.headers['Content-Type'] = 'text/html'
handler.response.out.write(response_data)
return ServiceDecoratedView
def ServiceEnabledJson(view):
"""Decorator to inject an authorized service into a JSON HTTP handler.
Args:
view: HTTP request handler method.
Returns:
Decorated handler which accepts the service as a parameter.
"""
def ServiceDecoratedView(handler, view=view):
service = CreateDrive(handler)
if handler.request.body:
data = json.loads(handler.request.body)
else:
data = None
response_data = json.dumps(view(handler, service, data))
handler.response.headers['Content-Type'] = 'application/json'
handler.response.out.write(response_data)
return ServiceDecoratedView
class DriveState(object):
"""Store state provided by Drive."""
def __init__(self, state):
self.ParseState(state)
@classmethod
def FromRequest(cls, request):
"""Create a Drive State instance from an HTTP request.
Args:
cls: Type this class method is called against.
request: HTTP request.
"""
return DriveState(request.get(STATE_PARAMETER))
def ParseState(self, state):
"""Parse a state parameter and set internal values.
Args:
state: State parameter to parse.
"""
if state.startswith('{'):
self.ParseJsonState(state)
else:
self.ParsePlainState(state)
def ParseJsonState(self, state):
"""Parse a state parameter that is JSON.
Args:
state: State parameter to parse
"""
state_data = json.loads(state)
self.action = state_data['action']
self.ids = map(str, state_data.get('ids', []))
def ParsePlainState(self, state):
"""Parse a state parameter that is a plain resource id or missing.
Args:
state: State parameter to parse
"""
if state:
self.action = 'open'
self.ids = [state]
else:
self.action = 'create'
self.ids = []
class MediaInMemoryUpload(MediaUpload):
"""MediaUpload for a chunk of bytes.
Construct a MediaFileUpload and pass as the media_body parameter of the
method. For example, if we had a service that allowed plain text:
"""
def __init__(self, body, mimetype='application/octet-stream',
chunksize=256*1024, resumable=False):
"""Create a new MediaBytesUpload.
Args:
body: string, Bytes of body content.
mimetype: string, Mime-type of the file or default of
'application/octet-stream'.
chunksize: int, File will be uploaded in chunks of this many bytes. Only
used if resumable=True.
resumable: bool, True if this is a resumable upload. False means upload
in a single request.
"""
self._body = body
self._mimetype = mimetype
self._resumable = resumable
self._chunksize = chunksize
def chunksize(self):
"""Chunk size for resumable uploads.
Returns:
Chunk size in bytes.
"""
return self._chunksize
def mimetype(self):
"""Mime type of the body.
Returns:
Mime type.
"""
return self._mimetype
def size(self):
"""Size of upload.
Returns:
Size of the body.
"""
return len(self._body)
def resumable(self):
"""Whether this upload is resumable.
Returns:
True if resumable upload or False.
"""
return self._resumable
def getbytes(self, begin, length):
"""Get bytes from the media.
Args:
begin: int, offset from beginning of file.
length: int, number of bytes to read, starting at begin.
Returns:
A string of bytes read. May be shorter than length if EOF was reached
first.
"""
return self._body[begin:begin + length]
def RenderTemplate(name, **context):
"""Render a named template in a context.
Args:
name: Template name.
context: Keyword arguments to render as template variables.
"""
return template.render(name, context)
| Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import base64
import urllib
import time
import random
import urlparse
import hmac
import binascii
import httplib2
try:
from urlparse import parse_qs
parse_qs # placate pyflakes
except ImportError:
# fall back for Python 2.5
from cgi import parse_qs
try:
from hashlib import sha1
sha = sha1
except ImportError:
# hashlib was added in Python 2.5
import sha
import _version
__version__ = _version.__version__
OAUTH_VERSION = '1.0' # Hi Blaine!
HTTP_METHOD = 'GET'
SIGNATURE_METHOD = 'PLAINTEXT'
class Error(RuntimeError):
"""Generic exception class."""
def __init__(self, message='OAuth error occurred.'):
self._message = message
@property
def message(self):
"""A hack to get around the deprecation errors in 2.6."""
return self._message
def __str__(self):
return self._message
class MissingSignature(Error):
pass
def build_authenticate_header(realm=''):
"""Optional WWW-Authenticate header (401 error)"""
return {'WWW-Authenticate': 'OAuth realm="%s"' % realm}
def build_xoauth_string(url, consumer, token=None):
"""Build an XOAUTH string for use in SMTP/IMPA authentication."""
request = Request.from_consumer_and_token(consumer, token,
"GET", url)
signing_method = SignatureMethod_HMAC_SHA1()
request.sign_request(signing_method, consumer, token)
params = []
for k, v in sorted(request.iteritems()):
if v is not None:
params.append('%s="%s"' % (k, escape(v)))
return "%s %s %s" % ("GET", url, ','.join(params))
def to_unicode(s):
""" Convert to unicode, raise exception with instructive error
message if s is not unicode, ascii, or utf-8. """
if not isinstance(s, unicode):
if not isinstance(s, str):
raise TypeError('You are required to pass either unicode or string here, not: %r (%s)' % (type(s), s))
try:
s = s.decode('utf-8')
except UnicodeDecodeError, le:
raise TypeError('You are required to pass either a unicode object or a utf-8 string here. You passed a Python string object which contained non-utf-8: %r. The UnicodeDecodeError that resulted from attempting to interpret it as utf-8 was: %s' % (s, le,))
return s
def to_utf8(s):
return to_unicode(s).encode('utf-8')
def to_unicode_if_string(s):
if isinstance(s, basestring):
return to_unicode(s)
else:
return s
def to_utf8_if_string(s):
if isinstance(s, basestring):
return to_utf8(s)
else:
return s
def to_unicode_optional_iterator(x):
"""
Raise TypeError if x is a str containing non-utf8 bytes or if x is
an iterable which contains such a str.
"""
if isinstance(x, basestring):
return to_unicode(x)
try:
l = list(x)
except TypeError, e:
assert 'is not iterable' in str(e)
return x
else:
return [ to_unicode(e) for e in l ]
def to_utf8_optional_iterator(x):
"""
Raise TypeError if x is a str or if x is an iterable which
contains a str.
"""
if isinstance(x, basestring):
return to_utf8(x)
try:
l = list(x)
except TypeError, e:
assert 'is not iterable' in str(e)
return x
else:
return [ to_utf8_if_string(e) for e in l ]
def escape(s):
"""Escape a URL including any /."""
return urllib.quote(s.encode('utf-8'), safe='~')
def generate_timestamp():
"""Get seconds since epoch (UTC)."""
return int(time.time())
def generate_nonce(length=8):
"""Generate pseudorandom number."""
return ''.join([str(random.randint(0, 9)) for i in range(length)])
def generate_verifier(length=8):
"""Generate pseudorandom number."""
return ''.join([str(random.randint(0, 9)) for i in range(length)])
class Consumer(object):
"""A consumer of OAuth-protected services.
The OAuth consumer is a "third-party" service that wants to access
protected resources from an OAuth service provider on behalf of an end
user. It's kind of the OAuth client.
Usually a consumer must be registered with the service provider by the
developer of the consumer software. As part of that process, the service
provider gives the consumer a *key* and a *secret* with which the consumer
software can identify itself to the service. The consumer will include its
key in each request to identify itself, but will use its secret only when
signing requests, to prove that the request is from that particular
registered consumer.
Once registered, the consumer can then use its consumer credentials to ask
the service provider for a request token, kicking off the OAuth
authorization process.
"""
key = None
secret = None
def __init__(self, key, secret):
self.key = key
self.secret = secret
if self.key is None or self.secret is None:
raise ValueError("Key and secret must be set.")
def __str__(self):
data = {'oauth_consumer_key': self.key,
'oauth_consumer_secret': self.secret}
return urllib.urlencode(data)
class Token(object):
"""An OAuth credential used to request authorization or a protected
resource.
Tokens in OAuth comprise a *key* and a *secret*. The key is included in
requests to identify the token being used, but the secret is used only in
the signature, to prove that the requester is who the server gave the
token to.
When first negotiating the authorization, the consumer asks for a *request
token* that the live user authorizes with the service provider. The
consumer then exchanges the request token for an *access token* that can
be used to access protected resources.
"""
key = None
secret = None
callback = None
callback_confirmed = None
verifier = None
def __init__(self, key, secret):
self.key = key
self.secret = secret
if self.key is None or self.secret is None:
raise ValueError("Key and secret must be set.")
def set_callback(self, callback):
self.callback = callback
self.callback_confirmed = 'true'
def set_verifier(self, verifier=None):
if verifier is not None:
self.verifier = verifier
else:
self.verifier = generate_verifier()
def get_callback_url(self):
if self.callback and self.verifier:
# Append the oauth_verifier.
parts = urlparse.urlparse(self.callback)
scheme, netloc, path, params, query, fragment = parts[:6]
if query:
query = '%s&oauth_verifier=%s' % (query, self.verifier)
else:
query = 'oauth_verifier=%s' % self.verifier
return urlparse.urlunparse((scheme, netloc, path, params,
query, fragment))
return self.callback
def to_string(self):
"""Returns this token as a plain string, suitable for storage.
The resulting string includes the token's secret, so you should never
send or store this string where a third party can read it.
"""
data = {
'oauth_token': self.key,
'oauth_token_secret': self.secret,
}
if self.callback_confirmed is not None:
data['oauth_callback_confirmed'] = self.callback_confirmed
return urllib.urlencode(data)
@staticmethod
def from_string(s):
"""Deserializes a token from a string like one returned by
`to_string()`."""
if not len(s):
raise ValueError("Invalid parameter string.")
params = parse_qs(s, keep_blank_values=False)
if not len(params):
raise ValueError("Invalid parameter string.")
try:
key = params['oauth_token'][0]
except Exception:
raise ValueError("'oauth_token' not found in OAuth request.")
try:
secret = params['oauth_token_secret'][0]
except Exception:
raise ValueError("'oauth_token_secret' not found in "
"OAuth request.")
token = Token(key, secret)
try:
token.callback_confirmed = params['oauth_callback_confirmed'][0]
except KeyError:
pass # 1.0, no callback confirmed.
return token
def __str__(self):
return self.to_string()
def setter(attr):
name = attr.__name__
def getter(self):
try:
return self.__dict__[name]
except KeyError:
raise AttributeError(name)
def deleter(self):
del self.__dict__[name]
return property(getter, attr, deleter)
class Request(dict):
"""The parameters and information for an HTTP request, suitable for
authorizing with OAuth credentials.
When a consumer wants to access a service's protected resources, it does
so using a signed HTTP request identifying itself (the consumer) with its
key, and providing an access token authorized by the end user to access
those resources.
"""
version = OAUTH_VERSION
def __init__(self, method=HTTP_METHOD, url=None, parameters=None,
body='', is_form_encoded=False):
if url is not None:
self.url = to_unicode(url)
self.method = method
if parameters is not None:
for k, v in parameters.iteritems():
k = to_unicode(k)
v = to_unicode_optional_iterator(v)
self[k] = v
self.body = body
self.is_form_encoded = is_form_encoded
@setter
def url(self, value):
self.__dict__['url'] = value
if value is not None:
scheme, netloc, path, params, query, fragment = urlparse.urlparse(value)
# Exclude default port numbers.
if scheme == 'http' and netloc[-3:] == ':80':
netloc = netloc[:-3]
elif scheme == 'https' and netloc[-4:] == ':443':
netloc = netloc[:-4]
if scheme not in ('http', 'https'):
raise ValueError("Unsupported URL %s (%s)." % (value, scheme))
# Normalized URL excludes params, query, and fragment.
self.normalized_url = urlparse.urlunparse((scheme, netloc, path, None, None, None))
else:
self.normalized_url = None
self.__dict__['url'] = None
@setter
def method(self, value):
self.__dict__['method'] = value.upper()
def _get_timestamp_nonce(self):
return self['oauth_timestamp'], self['oauth_nonce']
def get_nonoauth_parameters(self):
"""Get any non-OAuth parameters."""
return dict([(k, v) for k, v in self.iteritems()
if not k.startswith('oauth_')])
def to_header(self, realm=''):
"""Serialize as a header for an HTTPAuth request."""
oauth_params = ((k, v) for k, v in self.items()
if k.startswith('oauth_'))
stringy_params = ((k, escape(str(v))) for k, v in oauth_params)
header_params = ('%s="%s"' % (k, v) for k, v in stringy_params)
params_header = ', '.join(header_params)
auth_header = 'OAuth realm="%s"' % realm
if params_header:
auth_header = "%s, %s" % (auth_header, params_header)
return {'Authorization': auth_header}
def to_postdata(self):
"""Serialize as post data for a POST request."""
d = {}
for k, v in self.iteritems():
d[k.encode('utf-8')] = to_utf8_optional_iterator(v)
# tell urlencode to deal with sequence values and map them correctly
# to resulting querystring. for example self["k"] = ["v1", "v2"] will
# result in 'k=v1&k=v2' and not k=%5B%27v1%27%2C+%27v2%27%5D
return urllib.urlencode(d, True).replace('+', '%20')
def to_url(self):
"""Serialize as a URL for a GET request."""
base_url = urlparse.urlparse(self.url)
try:
query = base_url.query
except AttributeError:
# must be python <2.5
query = base_url[4]
query = parse_qs(query)
for k, v in self.items():
query.setdefault(k, []).append(v)
try:
scheme = base_url.scheme
netloc = base_url.netloc
path = base_url.path
params = base_url.params
fragment = base_url.fragment
except AttributeError:
# must be python <2.5
scheme = base_url[0]
netloc = base_url[1]
path = base_url[2]
params = base_url[3]
fragment = base_url[5]
url = (scheme, netloc, path, params,
urllib.urlencode(query, True), fragment)
return urlparse.urlunparse(url)
def get_parameter(self, parameter):
ret = self.get(parameter)
if ret is None:
raise Error('Parameter not found: %s' % parameter)
return ret
def get_normalized_parameters(self):
"""Return a string that contains the parameters that must be signed."""
items = []
for key, value in self.iteritems():
if key == 'oauth_signature':
continue
# 1.0a/9.1.1 states that kvp must be sorted by key, then by value,
# so we unpack sequence values into multiple items for sorting.
if isinstance(value, basestring):
items.append((to_utf8_if_string(key), to_utf8(value)))
else:
try:
value = list(value)
except TypeError, e:
assert 'is not iterable' in str(e)
items.append((to_utf8_if_string(key), to_utf8_if_string(value)))
else:
items.extend((to_utf8_if_string(key), to_utf8_if_string(item)) for item in value)
# Include any query string parameters from the provided URL
query = urlparse.urlparse(self.url)[4]
url_items = self._split_url_string(query).items()
url_items = [(to_utf8(k), to_utf8(v)) for k, v in url_items if k != 'oauth_signature' ]
items.extend(url_items)
items.sort()
encoded_str = urllib.urlencode(items)
# Encode signature parameters per Oauth Core 1.0 protocol
# spec draft 7, section 3.6
# (http://tools.ietf.org/html/draft-hammer-oauth-07#section-3.6)
# Spaces must be encoded with "%20" instead of "+"
return encoded_str.replace('+', '%20').replace('%7E', '~')
def sign_request(self, signature_method, consumer, token):
"""Set the signature parameter to the result of sign."""
if not self.is_form_encoded:
# according to
# http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
# section 4.1.1 "OAuth Consumers MUST NOT include an
# oauth_body_hash parameter on requests with form-encoded
# request bodies."
self['oauth_body_hash'] = base64.b64encode(sha(self.body).digest())
if 'oauth_consumer_key' not in self:
self['oauth_consumer_key'] = consumer.key
if token and 'oauth_token' not in self:
self['oauth_token'] = token.key
self['oauth_signature_method'] = signature_method.name
self['oauth_signature'] = signature_method.sign(self, consumer, token)
@classmethod
def make_timestamp(cls):
"""Get seconds since epoch (UTC)."""
return str(int(time.time()))
@classmethod
def make_nonce(cls):
"""Generate pseudorandom number."""
return str(random.randint(0, 100000000))
@classmethod
def from_request(cls, http_method, http_url, headers=None, parameters=None,
query_string=None):
"""Combines multiple parameter sources."""
if parameters is None:
parameters = {}
# Headers
if headers and 'Authorization' in headers:
auth_header = headers['Authorization']
# Check that the authorization header is OAuth.
if auth_header[:6] == 'OAuth ':
auth_header = auth_header[6:]
try:
# Get the parameters from the header.
header_params = cls._split_header(auth_header)
parameters.update(header_params)
except:
raise Error('Unable to parse OAuth parameters from '
'Authorization header.')
# GET or POST query string.
if query_string:
query_params = cls._split_url_string(query_string)
parameters.update(query_params)
# URL parameters.
param_str = urlparse.urlparse(http_url)[4] # query
url_params = cls._split_url_string(param_str)
parameters.update(url_params)
if parameters:
return cls(http_method, http_url, parameters)
return None
@classmethod
def from_consumer_and_token(cls, consumer, token=None,
http_method=HTTP_METHOD, http_url=None, parameters=None,
body='', is_form_encoded=False):
if not parameters:
parameters = {}
defaults = {
'oauth_consumer_key': consumer.key,
'oauth_timestamp': cls.make_timestamp(),
'oauth_nonce': cls.make_nonce(),
'oauth_version': cls.version,
}
defaults.update(parameters)
parameters = defaults
if token:
parameters['oauth_token'] = token.key
if token.verifier:
parameters['oauth_verifier'] = token.verifier
return Request(http_method, http_url, parameters, body=body,
is_form_encoded=is_form_encoded)
@classmethod
def from_token_and_callback(cls, token, callback=None,
http_method=HTTP_METHOD, http_url=None, parameters=None):
if not parameters:
parameters = {}
parameters['oauth_token'] = token.key
if callback:
parameters['oauth_callback'] = callback
return cls(http_method, http_url, parameters)
@staticmethod
def _split_header(header):
"""Turn Authorization: header into parameters."""
params = {}
parts = header.split(',')
for param in parts:
# Ignore realm parameter.
if param.find('realm') > -1:
continue
# Remove whitespace.
param = param.strip()
# Split key-value.
param_parts = param.split('=', 1)
# Remove quotes and unescape the value.
params[param_parts[0]] = urllib.unquote(param_parts[1].strip('\"'))
return params
@staticmethod
def _split_url_string(param_str):
"""Turn URL string into parameters."""
parameters = parse_qs(param_str.encode('utf-8'), keep_blank_values=True)
for k, v in parameters.iteritems():
parameters[k] = urllib.unquote(v[0])
return parameters
class Client(httplib2.Http):
"""OAuthClient is a worker to attempt to execute a request."""
def __init__(self, consumer, token=None, cache=None, timeout=None,
proxy_info=None):
if consumer is not None and not isinstance(consumer, Consumer):
raise ValueError("Invalid consumer.")
if token is not None and not isinstance(token, Token):
raise ValueError("Invalid token.")
self.consumer = consumer
self.token = token
self.method = SignatureMethod_HMAC_SHA1()
httplib2.Http.__init__(self, cache=cache, timeout=timeout, proxy_info=proxy_info)
def set_signature_method(self, method):
if not isinstance(method, SignatureMethod):
raise ValueError("Invalid signature method.")
self.method = method
def request(self, uri, method="GET", body='', headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None):
DEFAULT_POST_CONTENT_TYPE = 'application/x-www-form-urlencoded'
if not isinstance(headers, dict):
headers = {}
if method == "POST":
headers['Content-Type'] = headers.get('Content-Type',
DEFAULT_POST_CONTENT_TYPE)
is_form_encoded = \
headers.get('Content-Type') == 'application/x-www-form-urlencoded'
if is_form_encoded and body:
parameters = parse_qs(body)
else:
parameters = None
req = Request.from_consumer_and_token(self.consumer,
token=self.token, http_method=method, http_url=uri,
parameters=parameters, body=body, is_form_encoded=is_form_encoded)
req.sign_request(self.method, self.consumer, self.token)
schema, rest = urllib.splittype(uri)
if rest.startswith('//'):
hierpart = '//'
else:
hierpart = ''
host, rest = urllib.splithost(rest)
realm = schema + ':' + hierpart + host
if is_form_encoded:
body = req.to_postdata()
elif method == "GET":
uri = req.to_url()
else:
headers.update(req.to_header(realm=realm))
return httplib2.Http.request(self, uri, method=method, body=body,
headers=headers, redirections=redirections,
connection_type=connection_type)
class Server(object):
"""A skeletal implementation of a service provider, providing protected
resources to requests from authorized consumers.
This class implements the logic to check requests for authorization. You
can use it with your web server or web framework to protect certain
resources with OAuth.
"""
timestamp_threshold = 300 # In seconds, five minutes.
version = OAUTH_VERSION
signature_methods = None
def __init__(self, signature_methods=None):
self.signature_methods = signature_methods or {}
def add_signature_method(self, signature_method):
self.signature_methods[signature_method.name] = signature_method
return self.signature_methods
def verify_request(self, request, consumer, token):
"""Verifies an api call and checks all the parameters."""
self._check_version(request)
self._check_signature(request, consumer, token)
parameters = request.get_nonoauth_parameters()
return parameters
def build_authenticate_header(self, realm=''):
"""Optional support for the authenticate header."""
return {'WWW-Authenticate': 'OAuth realm="%s"' % realm}
def _check_version(self, request):
"""Verify the correct version of the request for this server."""
version = self._get_version(request)
if version and version != self.version:
raise Error('OAuth version %s not supported.' % str(version))
def _get_version(self, request):
"""Return the version of the request for this server."""
try:
version = request.get_parameter('oauth_version')
except:
version = OAUTH_VERSION
return version
def _get_signature_method(self, request):
"""Figure out the signature with some defaults."""
try:
signature_method = request.get_parameter('oauth_signature_method')
except:
signature_method = SIGNATURE_METHOD
try:
# Get the signature method object.
signature_method = self.signature_methods[signature_method]
except:
signature_method_names = ', '.join(self.signature_methods.keys())
raise Error('Signature method %s not supported try one of the following: %s' % (signature_method, signature_method_names))
return signature_method
def _get_verifier(self, request):
return request.get_parameter('oauth_verifier')
def _check_signature(self, request, consumer, token):
timestamp, nonce = request._get_timestamp_nonce()
self._check_timestamp(timestamp)
signature_method = self._get_signature_method(request)
try:
signature = request.get_parameter('oauth_signature')
except:
raise MissingSignature('Missing oauth_signature.')
# Validate the signature.
valid = signature_method.check(request, consumer, token, signature)
if not valid:
key, base = signature_method.signing_base(request, consumer, token)
raise Error('Invalid signature. Expected signature base '
'string: %s' % base)
def _check_timestamp(self, timestamp):
"""Verify that timestamp is recentish."""
timestamp = int(timestamp)
now = int(time.time())
lapsed = now - timestamp
if lapsed > self.timestamp_threshold:
raise Error('Expired timestamp: given %d and now %s has a '
'greater difference than threshold %d' % (timestamp, now,
self.timestamp_threshold))
class SignatureMethod(object):
"""A way of signing requests.
The OAuth protocol lets consumers and service providers pick a way to sign
requests. This interface shows the methods expected by the other `oauth`
modules for signing requests. Subclass it and implement its methods to
provide a new way to sign requests.
"""
def signing_base(self, request, consumer, token):
"""Calculates the string that needs to be signed.
This method returns a 2-tuple containing the starting key for the
signing and the message to be signed. The latter may be used in error
messages to help clients debug their software.
"""
raise NotImplementedError
def sign(self, request, consumer, token):
"""Returns the signature for the given request, based on the consumer
and token also provided.
You should use your implementation of `signing_base()` to build the
message to sign. Otherwise it may be less useful for debugging.
"""
raise NotImplementedError
def check(self, request, consumer, token, signature):
"""Returns whether the given signature is the correct signature for
the given consumer and token signing the given request."""
built = self.sign(request, consumer, token)
return built == signature
class SignatureMethod_HMAC_SHA1(SignatureMethod):
name = 'HMAC-SHA1'
def signing_base(self, request, consumer, token):
if not hasattr(request, 'normalized_url') or request.normalized_url is None:
raise ValueError("Base URL for request is not set.")
sig = (
escape(request.method),
escape(request.normalized_url),
escape(request.get_normalized_parameters()),
)
key = '%s&' % escape(consumer.secret)
if token:
key += escape(token.secret)
raw = '&'.join(sig)
return key, raw
def sign(self, request, consumer, token):
"""Builds the base signature string."""
key, raw = self.signing_base(request, consumer, token)
hashed = hmac.new(key, raw, sha)
# Calculate the digest base 64.
return binascii.b2a_base64(hashed.digest())[:-1]
class SignatureMethod_PLAINTEXT(SignatureMethod):
name = 'PLAINTEXT'
def signing_base(self, request, consumer, token):
"""Concatenates the consumer key and secret with the token's
secret."""
sig = '%s&' % escape(consumer.secret)
if token:
sig = sig + escape(token.secret)
return sig, sig
def sign(self, request, consumer, token):
key, raw = self.signing_base(request, consumer, token)
return raw
| Python |
# This is the version of this source code.
manual_verstr = "1.5"
auto_build_num = "211"
verstr = manual_verstr + "." + auto_build_num
try:
from pyutil.version_class import Version as pyutil_Version
__version__ = pyutil_Version(verstr)
except (ImportError, ValueError):
# Maybe there is no pyutil installed.
from distutils.version import LooseVersion as distutils_Version
__version__ = distutils_Version(verstr)
| Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import oauth2
import imaplib
class IMAP4_SSL(imaplib.IMAP4_SSL):
"""IMAP wrapper for imaplib.IMAP4_SSL that implements XOAUTH."""
def authenticate(self, url, consumer, token):
if consumer is not None and not isinstance(consumer, oauth2.Consumer):
raise ValueError("Invalid consumer.")
if token is not None and not isinstance(token, oauth2.Token):
raise ValueError("Invalid token.")
imaplib.IMAP4_SSL.authenticate(self, 'XOAUTH',
lambda x: oauth2.build_xoauth_string(url, consumer, token))
| Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import oauth2
import smtplib
import base64
class SMTP(smtplib.SMTP):
"""SMTP wrapper for smtplib.SMTP that implements XOAUTH."""
def authenticate(self, url, consumer, token):
if consumer is not None and not isinstance(consumer, oauth2.Consumer):
raise ValueError("Invalid consumer.")
if token is not None and not isinstance(token, oauth2.Token):
raise ValueError("Invalid token.")
self.docmd('AUTH', 'XOAUTH %s' % \
base64.b64encode(oauth2.build_xoauth_string(url, consumer, token)))
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command-line tools for authenticating via OAuth 2.0
Do the OAuth 2.0 Web Server dance for a command line application. Stores the
generated credentials in a common file that is used by other example apps in
the same directory.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
__all__ = ['run']
import BaseHTTPServer
import gflags
import socket
import sys
import webbrowser
from client import FlowExchangeError
from client import OOB_CALLBACK_URN
try:
from urlparse import parse_qsl
except ImportError:
from cgi import parse_qsl
FLAGS = gflags.FLAGS
gflags.DEFINE_boolean('auth_local_webserver', True,
('Run a local web server to handle redirects during '
'OAuth authorization.'))
gflags.DEFINE_string('auth_host_name', 'localhost',
('Host name to use when running a local web server to '
'handle redirects during OAuth authorization.'))
gflags.DEFINE_multi_int('auth_host_port', [8080, 8090],
('Port to use when running a local web server to '
'handle redirects during OAuth authorization.'))
class ClientRedirectServer(BaseHTTPServer.HTTPServer):
"""A server to handle OAuth 2.0 redirects back to localhost.
Waits for a single request and parses the query parameters
into query_params and then stops serving.
"""
query_params = {}
class ClientRedirectHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""A handler for OAuth 2.0 redirects back to localhost.
Waits for a single request and parses the query parameters
into the servers query_params and then stops serving.
"""
def do_GET(s):
"""Handle a GET request.
Parses the query parameters and prints a message
if the flow has completed. Note that we can't detect
if an error occurred.
"""
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
query = s.path.split('?', 1)[-1]
query = dict(parse_qsl(query))
s.server.query_params = query
s.wfile.write("<html><head><title>Authentication Status</title></head>")
s.wfile.write("<body><p>The authentication flow has completed.</p>")
s.wfile.write("</body></html>")
def log_message(self, format, *args):
"""Do not log messages to stdout while running as command line program."""
pass
def run(flow, storage, http=None):
"""Core code for a command-line application.
Args:
flow: Flow, an OAuth 2.0 Flow to step through.
storage: Storage, a Storage to store the credential in.
http: An instance of httplib2.Http.request
or something that acts like it.
Returns:
Credentials, the obtained credential.
"""
if FLAGS.auth_local_webserver:
success = False
port_number = 0
for port in FLAGS.auth_host_port:
port_number = port
try:
httpd = ClientRedirectServer((FLAGS.auth_host_name, port),
ClientRedirectHandler)
except socket.error, e:
pass
else:
success = True
break
FLAGS.auth_local_webserver = success
if not success:
print 'Failed to start a local webserver listening on either port 8080'
print 'or port 9090. Please check your firewall settings and locally'
print 'running programs that may be blocking or using those ports.'
print
print 'Falling back to --noauth_local_webserver and continuing with',
print 'authorization.'
print
if FLAGS.auth_local_webserver:
oauth_callback = 'http://%s:%s/' % (FLAGS.auth_host_name, port_number)
else:
oauth_callback = OOB_CALLBACK_URN
authorize_url = flow.step1_get_authorize_url(oauth_callback)
if FLAGS.auth_local_webserver:
webbrowser.open(authorize_url, new=1, autoraise=True)
print 'Your browser has been opened to visit:'
print
print ' ' + authorize_url
print
print 'If your browser is on a different machine then exit and re-run this'
print 'application with the command-line parameter '
print
print ' --noauth_local_webserver'
print
else:
print 'Go to the following link in your browser:'
print
print ' ' + authorize_url
print
code = None
if FLAGS.auth_local_webserver:
httpd.handle_request()
if 'error' in httpd.query_params:
sys.exit('Authentication request was rejected.')
if 'code' in httpd.query_params:
code = httpd.query_params['code']
else:
print 'Failed to find "code" in the query parameters of the redirect.'
sys.exit('Try running with --noauth_local_webserver.')
else:
code = raw_input('Enter verification code: ').strip()
try:
credential = flow.step2_exchange(code, http)
except FlowExchangeError, e:
sys.exit('Authentication has failed: %s' % e)
storage.put(credential)
credential.set_store(storage)
print 'Authentication successful.'
return credential
| Python |
# Copyright 2011 Google Inc. All Rights Reserved.
"""Multi-credential file store with lock support.
This module implements a JSON credential store where multiple
credentials can be stored in one file. That file supports locking
both in a single process and across processes.
The credential themselves are keyed off of:
* client_id
* user_agent
* scope
The format of the stored data is like so:
{
'file_version': 1,
'data': [
{
'key': {
'clientId': '<client id>',
'userAgent': '<user agent>',
'scope': '<scope>'
},
'credential': {
# JSON serialized Credentials.
}
}
]
}
"""
__author__ = 'jbeda@google.com (Joe Beda)'
import base64
import errno
import logging
import os
import threading
from anyjson import simplejson
from client import Storage as BaseStorage
from client import Credentials
from locked_file import LockedFile
logger = logging.getLogger(__name__)
# A dict from 'filename'->_MultiStore instances
_multistores = {}
_multistores_lock = threading.Lock()
class Error(Exception):
"""Base error for this module."""
pass
class NewerCredentialStoreError(Error):
"""The credential store is a newer version that supported."""
pass
def get_credential_storage(filename, client_id, user_agent, scope,
warn_on_readonly=True):
"""Get a Storage instance for a credential.
Args:
filename: The JSON file storing a set of credentials
client_id: The client_id for the credential
user_agent: The user agent for the credential
scope: string or list of strings, Scope(s) being requested
warn_on_readonly: if True, log a warning if the store is readonly
Returns:
An object derived from client.Storage for getting/setting the
credential.
"""
filename = os.path.realpath(os.path.expanduser(filename))
_multistores_lock.acquire()
try:
multistore = _multistores.setdefault(
filename, _MultiStore(filename, warn_on_readonly))
finally:
_multistores_lock.release()
if type(scope) is list:
scope = ' '.join(scope)
return multistore._get_storage(client_id, user_agent, scope)
class _MultiStore(object):
"""A file backed store for multiple credentials."""
def __init__(self, filename, warn_on_readonly=True):
"""Initialize the class.
This will create the file if necessary.
"""
self._file = LockedFile(filename, 'r+b', 'rb')
self._thread_lock = threading.Lock()
self._read_only = False
self._warn_on_readonly = warn_on_readonly
self._create_file_if_needed()
# Cache of deserialized store. This is only valid after the
# _MultiStore is locked or _refresh_data_cache is called. This is
# of the form of:
#
# (client_id, user_agent, scope) -> OAuth2Credential
#
# If this is None, then the store hasn't been read yet.
self._data = None
class _Storage(BaseStorage):
"""A Storage object that knows how to read/write a single credential."""
def __init__(self, multistore, client_id, user_agent, scope):
self._multistore = multistore
self._client_id = client_id
self._user_agent = user_agent
self._scope = scope
def acquire_lock(self):
"""Acquires any lock necessary to access this Storage.
This lock is not reentrant.
"""
self._multistore._lock()
def release_lock(self):
"""Release the Storage lock.
Trying to release a lock that isn't held will result in a
RuntimeError.
"""
self._multistore._unlock()
def locked_get(self):
"""Retrieve credential.
The Storage lock must be held when this is called.
Returns:
oauth2client.client.Credentials
"""
credential = self._multistore._get_credential(
self._client_id, self._user_agent, self._scope)
if credential:
credential.set_store(self)
return credential
def locked_put(self, credentials):
"""Write a credential.
The Storage lock must be held when this is called.
Args:
credentials: Credentials, the credentials to store.
"""
self._multistore._update_credential(credentials, self._scope)
def locked_delete(self):
"""Delete a credential.
The Storage lock must be held when this is called.
Args:
credentials: Credentials, the credentials to store.
"""
self._multistore._delete_credential(self._client_id, self._user_agent,
self._scope)
def _create_file_if_needed(self):
"""Create an empty file if necessary.
This method will not initialize the file. Instead it implements a
simple version of "touch" to ensure the file has been created.
"""
if not os.path.exists(self._file.filename()):
old_umask = os.umask(0177)
try:
open(self._file.filename(), 'a+b').close()
finally:
os.umask(old_umask)
def _lock(self):
"""Lock the entire multistore."""
self._thread_lock.acquire()
self._file.open_and_lock()
if not self._file.is_locked():
self._read_only = True
if self._warn_on_readonly:
logger.warn('The credentials file (%s) is not writable. Opening in '
'read-only mode. Any refreshed credentials will only be '
'valid for this run.' % self._file.filename())
if os.path.getsize(self._file.filename()) == 0:
logger.debug('Initializing empty multistore file')
# The multistore is empty so write out an empty file.
self._data = {}
self._write()
elif not self._read_only or self._data is None:
# Only refresh the data if we are read/write or we haven't
# cached the data yet. If we are readonly, we assume is isn't
# changing out from under us and that we only have to read it
# once. This prevents us from whacking any new access keys that
# we have cached in memory but were unable to write out.
self._refresh_data_cache()
def _unlock(self):
"""Release the lock on the multistore."""
self._file.unlock_and_close()
self._thread_lock.release()
def _locked_json_read(self):
"""Get the raw content of the multistore file.
The multistore must be locked when this is called.
Returns:
The contents of the multistore decoded as JSON.
"""
assert self._thread_lock.locked()
self._file.file_handle().seek(0)
return simplejson.load(self._file.file_handle())
def _locked_json_write(self, data):
"""Write a JSON serializable data structure to the multistore.
The multistore must be locked when this is called.
Args:
data: The data to be serialized and written.
"""
assert self._thread_lock.locked()
if self._read_only:
return
self._file.file_handle().seek(0)
simplejson.dump(data, self._file.file_handle(), sort_keys=True, indent=2)
self._file.file_handle().truncate()
def _refresh_data_cache(self):
"""Refresh the contents of the multistore.
The multistore must be locked when this is called.
Raises:
NewerCredentialStoreError: Raised when a newer client has written the
store.
"""
self._data = {}
try:
raw_data = self._locked_json_read()
except Exception:
logger.warn('Credential data store could not be loaded. '
'Will ignore and overwrite.')
return
version = 0
try:
version = raw_data['file_version']
except Exception:
logger.warn('Missing version for credential data store. It may be '
'corrupt or an old version. Overwriting.')
if version > 1:
raise NewerCredentialStoreError(
'Credential file has file_version of %d. '
'Only file_version of 1 is supported.' % version)
credentials = []
try:
credentials = raw_data['data']
except (TypeError, KeyError):
pass
for cred_entry in credentials:
try:
(key, credential) = self._decode_credential_from_json(cred_entry)
self._data[key] = credential
except:
# If something goes wrong loading a credential, just ignore it
logger.info('Error decoding credential, skipping', exc_info=True)
def _decode_credential_from_json(self, cred_entry):
"""Load a credential from our JSON serialization.
Args:
cred_entry: A dict entry from the data member of our format
Returns:
(key, cred) where the key is the key tuple and the cred is the
OAuth2Credential object.
"""
raw_key = cred_entry['key']
client_id = raw_key['clientId']
user_agent = raw_key['userAgent']
scope = raw_key['scope']
key = (client_id, user_agent, scope)
credential = None
credential = Credentials.new_from_json(simplejson.dumps(cred_entry['credential']))
return (key, credential)
def _write(self):
"""Write the cached data back out.
The multistore must be locked.
"""
raw_data = {'file_version': 1}
raw_creds = []
raw_data['data'] = raw_creds
for (cred_key, cred) in self._data.items():
raw_key = {
'clientId': cred_key[0],
'userAgent': cred_key[1],
'scope': cred_key[2]
}
raw_cred = simplejson.loads(cred.to_json())
raw_creds.append({'key': raw_key, 'credential': raw_cred})
self._locked_json_write(raw_data)
def _get_credential(self, client_id, user_agent, scope):
"""Get a credential from the multistore.
The multistore must be locked.
Args:
client_id: The client_id for the credential
user_agent: The user agent for the credential
scope: A string for the scope(s) being requested
Returns:
The credential specified or None if not present
"""
key = (client_id, user_agent, scope)
return self._data.get(key, None)
def _update_credential(self, cred, scope):
"""Update a credential and write the multistore.
This must be called when the multistore is locked.
Args:
cred: The OAuth2Credential to update/set
scope: The scope(s) that this credential covers
"""
key = (cred.client_id, cred.user_agent, scope)
self._data[key] = cred
self._write()
def _delete_credential(self, client_id, user_agent, scope):
"""Delete a credential and write the multistore.
This must be called when the multistore is locked.
Args:
client_id: The client_id for the credential
user_agent: The user agent for the credential
scope: The scope(s) that this credential covers
"""
key = (client_id, user_agent, scope)
try:
del self._data[key]
except KeyError:
pass
self._write()
def _get_storage(self, client_id, user_agent, scope):
"""Get a Storage object to get/set a credential.
This Storage is a 'view' into the multistore.
Args:
client_id: The client_id for the credential
user_agent: The user agent for the credential
scope: A string for the scope(s) being requested
Returns:
A Storage object that can be used to get/set this cred
"""
return self._Storage(self, client_id, user_agent, scope)
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""An OAuth 2.0 client.
Tools for interacting with OAuth 2.0 protected resources.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import base64
import clientsecrets
import copy
import datetime
import httplib2
import logging
import os
import sys
import time
import urllib
import urlparse
from anyjson import simplejson
HAS_OPENSSL = False
try:
from oauth2client.crypt import Signer
from oauth2client.crypt import make_signed_jwt
from oauth2client.crypt import verify_signed_jwt_with_certs
HAS_OPENSSL = True
except ImportError:
pass
try:
from urlparse import parse_qsl
except ImportError:
from cgi import parse_qsl
logger = logging.getLogger(__name__)
# Expiry is stored in RFC3339 UTC format
EXPIRY_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
# Which certs to use to validate id_tokens received.
ID_TOKEN_VERIFICATON_CERTS = 'https://www.googleapis.com/oauth2/v1/certs'
# Constant to use for the out of band OAuth 2.0 flow.
OOB_CALLBACK_URN = 'urn:ietf:wg:oauth:2.0:oob'
class Error(Exception):
"""Base error for this module."""
pass
class FlowExchangeError(Error):
"""Error trying to exchange an authorization grant for an access token."""
pass
class AccessTokenRefreshError(Error):
"""Error trying to refresh an expired access token."""
pass
class UnknownClientSecretsFlowError(Error):
"""The client secrets file called for an unknown type of OAuth 2.0 flow. """
pass
class AccessTokenCredentialsError(Error):
"""Having only the access_token means no refresh is possible."""
pass
class VerifyJwtTokenError(Error):
"""Could on retrieve certificates for validation."""
pass
def _abstract():
raise NotImplementedError('You need to override this function')
class MemoryCache(object):
"""httplib2 Cache implementation which only caches locally."""
def __init__(self):
self.cache = {}
def get(self, key):
return self.cache.get(key)
def set(self, key, value):
self.cache[key] = value
def delete(self, key):
self.cache.pop(key, None)
class Credentials(object):
"""Base class for all Credentials objects.
Subclasses must define an authorize() method that applies the credentials to
an HTTP transport.
Subclasses must also specify a classmethod named 'from_json' that takes a JSON
string as input and returns an instaniated Credentials object.
"""
NON_SERIALIZED_MEMBERS = ['store']
def authorize(self, http):
"""Take an httplib2.Http instance (or equivalent) and
authorizes it for the set of credentials, usually by
replacing http.request() with a method that adds in
the appropriate headers and then delegates to the original
Http.request() method.
"""
_abstract()
def refresh(self, http):
"""Forces a refresh of the access_token.
Args:
http: httplib2.Http, an http object to be used to make the refresh
request.
"""
_abstract()
def apply(self, headers):
"""Add the authorization to the headers.
Args:
headers: dict, the headers to add the Authorization header to.
"""
_abstract()
def _to_json(self, strip):
"""Utility function for creating a JSON representation of an instance of Credentials.
Args:
strip: array, An array of names of members to not include in the JSON.
Returns:
string, a JSON representation of this instance, suitable to pass to
from_json().
"""
t = type(self)
d = copy.copy(self.__dict__)
for member in strip:
if member in d:
del d[member]
if 'token_expiry' in d and isinstance(d['token_expiry'], datetime.datetime):
d['token_expiry'] = d['token_expiry'].strftime(EXPIRY_FORMAT)
# Add in information we will need later to reconsistitue this instance.
d['_class'] = t.__name__
d['_module'] = t.__module__
return simplejson.dumps(d)
def to_json(self):
"""Creating a JSON representation of an instance of Credentials.
Returns:
string, a JSON representation of this instance, suitable to pass to
from_json().
"""
return self._to_json(Credentials.NON_SERIALIZED_MEMBERS)
@classmethod
def new_from_json(cls, s):
"""Utility class method to instantiate a Credentials subclass from a JSON
representation produced by to_json().
Args:
s: string, JSON from to_json().
Returns:
An instance of the subclass of Credentials that was serialized with
to_json().
"""
data = simplejson.loads(s)
# Find and call the right classmethod from_json() to restore the object.
module = data['_module']
try:
m = __import__(module)
except ImportError:
# In case there's an object from the old package structure, update it
module = module.replace('.apiclient', '')
m = __import__(module)
m = __import__(module, fromlist=module.split('.')[:-1])
kls = getattr(m, data['_class'])
from_json = getattr(kls, 'from_json')
return from_json(s)
@classmethod
def from_json(cls, s):
"""Instantiate a Credentials object from a JSON description of it.
The JSON should have been produced by calling .to_json() on the object.
Args:
data: dict, A deserialized JSON object.
Returns:
An instance of a Credentials subclass.
"""
return Credentials()
class Flow(object):
"""Base class for all Flow objects."""
pass
class Storage(object):
"""Base class for all Storage objects.
Store and retrieve a single credential. This class supports locking
such that multiple processes and threads can operate on a single
store.
"""
def acquire_lock(self):
"""Acquires any lock necessary to access this Storage.
This lock is not reentrant.
"""
pass
def release_lock(self):
"""Release the Storage lock.
Trying to release a lock that isn't held will result in a
RuntimeError.
"""
pass
def locked_get(self):
"""Retrieve credential.
The Storage lock must be held when this is called.
Returns:
oauth2client.client.Credentials
"""
_abstract()
def locked_put(self, credentials):
"""Write a credential.
The Storage lock must be held when this is called.
Args:
credentials: Credentials, the credentials to store.
"""
_abstract()
def locked_delete(self):
"""Delete a credential.
The Storage lock must be held when this is called.
"""
_abstract()
def get(self):
"""Retrieve credential.
The Storage lock must *not* be held when this is called.
Returns:
oauth2client.client.Credentials
"""
self.acquire_lock()
try:
return self.locked_get()
finally:
self.release_lock()
def put(self, credentials):
"""Write a credential.
The Storage lock must be held when this is called.
Args:
credentials: Credentials, the credentials to store.
"""
self.acquire_lock()
try:
self.locked_put(credentials)
finally:
self.release_lock()
def delete(self):
"""Delete credential.
Frees any resources associated with storing the credential.
The Storage lock must *not* be held when this is called.
Returns:
None
"""
self.acquire_lock()
try:
return self.locked_delete()
finally:
self.release_lock()
class OAuth2Credentials(Credentials):
"""Credentials object for OAuth 2.0.
Credentials can be applied to an httplib2.Http object using the authorize()
method, which then adds the OAuth 2.0 access token to each request.
OAuth2Credentials objects may be safely pickled and unpickled.
"""
def __init__(self, access_token, client_id, client_secret, refresh_token,
token_expiry, token_uri, user_agent, id_token=None):
"""Create an instance of OAuth2Credentials.
This constructor is not usually called by the user, instead
OAuth2Credentials objects are instantiated by the OAuth2WebServerFlow.
Args:
access_token: string, access token.
client_id: string, client identifier.
client_secret: string, client secret.
refresh_token: string, refresh token.
token_expiry: datetime, when the access_token expires.
token_uri: string, URI of token endpoint.
user_agent: string, The HTTP User-Agent to provide for this application.
id_token: object, The identity of the resource owner.
Notes:
store: callable, A callable that when passed a Credential
will store the credential back to where it came from.
This is needed to store the latest access_token if it
has expired and been refreshed.
"""
self.access_token = access_token
self.client_id = client_id
self.client_secret = client_secret
self.refresh_token = refresh_token
self.store = None
self.token_expiry = token_expiry
self.token_uri = token_uri
self.user_agent = user_agent
self.id_token = id_token
# True if the credentials have been revoked or expired and can't be
# refreshed.
self.invalid = False
def authorize(self, http):
"""Authorize an httplib2.Http instance with these credentials.
The modified http.request method will add authentication headers to each
request and will refresh access_tokens when a 401 is received on a
request. In addition the http.request method has a credentials property,
http.request.credentials, which is the Credentials object that authorized
it.
Args:
http: An instance of httplib2.Http
or something that acts like it.
Returns:
A modified instance of http that was passed in.
Example:
h = httplib2.Http()
h = credentials.authorize(h)
You can't create a new OAuth subclass of httplib2.Authenication
because it never gets passed the absolute URI, which is needed for
signing. So instead we have to overload 'request' with a closure
that adds in the Authorization header and then calls the original
version of 'request()'.
"""
request_orig = http.request
# The closure that will replace 'httplib2.Http.request'.
def new_request(uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
if not self.access_token:
logger.info('Attempting refresh to obtain initial access_token')
self._refresh(request_orig)
# Modify the request headers to add the appropriate
# Authorization header.
if headers is None:
headers = {}
self.apply(headers)
if self.user_agent is not None:
if 'user-agent' in headers:
headers['user-agent'] = self.user_agent + ' ' + headers['user-agent']
else:
headers['user-agent'] = self.user_agent
resp, content = request_orig(uri, method, body, headers,
redirections, connection_type)
if resp.status == 401:
logger.info('Refreshing due to a 401')
self._refresh(request_orig)
self.apply(headers)
return request_orig(uri, method, body, headers,
redirections, connection_type)
else:
return (resp, content)
# Replace the request method with our own closure.
http.request = new_request
# Set credentials as a property of the request method.
setattr(http.request, 'credentials', self)
return http
def refresh(self, http):
"""Forces a refresh of the access_token.
Args:
http: httplib2.Http, an http object to be used to make the refresh
request.
"""
self._refresh(http.request)
def apply(self, headers):
"""Add the authorization to the headers.
Args:
headers: dict, the headers to add the Authorization header to.
"""
headers['Authorization'] = 'Bearer ' + self.access_token
def to_json(self):
return self._to_json(Credentials.NON_SERIALIZED_MEMBERS)
@classmethod
def from_json(cls, s):
"""Instantiate a Credentials object from a JSON description of it. The JSON
should have been produced by calling .to_json() on the object.
Args:
data: dict, A deserialized JSON object.
Returns:
An instance of a Credentials subclass.
"""
data = simplejson.loads(s)
if 'token_expiry' in data and not isinstance(data['token_expiry'],
datetime.datetime):
try:
data['token_expiry'] = datetime.datetime.strptime(
data['token_expiry'], EXPIRY_FORMAT)
except:
data['token_expiry'] = None
retval = OAuth2Credentials(
data['access_token'],
data['client_id'],
data['client_secret'],
data['refresh_token'],
data['token_expiry'],
data['token_uri'],
data['user_agent'],
data.get('id_token', None))
retval.invalid = data['invalid']
return retval
@property
def access_token_expired(self):
"""True if the credential is expired or invalid.
If the token_expiry isn't set, we assume the token doesn't expire.
"""
if self.invalid:
return True
if not self.token_expiry:
return False
now = datetime.datetime.utcnow()
if now >= self.token_expiry:
logger.info('access_token is expired. Now: %s, token_expiry: %s',
now, self.token_expiry)
return True
return False
def set_store(self, store):
"""Set the Storage for the credential.
Args:
store: Storage, an implementation of Stroage object.
This is needed to store the latest access_token if it
has expired and been refreshed. This implementation uses
locking to check for updates before updating the
access_token.
"""
self.store = store
def _updateFromCredential(self, other):
"""Update this Credential from another instance."""
self.__dict__.update(other.__getstate__())
def __getstate__(self):
"""Trim the state down to something that can be pickled."""
d = copy.copy(self.__dict__)
del d['store']
return d
def __setstate__(self, state):
"""Reconstitute the state of the object from being pickled."""
self.__dict__.update(state)
self.store = None
def _generate_refresh_request_body(self):
"""Generate the body that will be used in the refresh request."""
body = urllib.urlencode({
'grant_type': 'refresh_token',
'client_id': self.client_id,
'client_secret': self.client_secret,
'refresh_token': self.refresh_token,
})
return body
def _generate_refresh_request_headers(self):
"""Generate the headers that will be used in the refresh request."""
headers = {
'content-type': 'application/x-www-form-urlencoded',
}
if self.user_agent is not None:
headers['user-agent'] = self.user_agent
return headers
def _refresh(self, http_request):
"""Refreshes the access_token.
This method first checks by reading the Storage object if available.
If a refresh is still needed, it holds the Storage lock until the
refresh is completed.
Args:
http_request: callable, a callable that matches the method signature of
httplib2.Http.request, used to make the refresh request.
Raises:
AccessTokenRefreshError: When the refresh fails.
"""
if not self.store:
self._do_refresh_request(http_request)
else:
self.store.acquire_lock()
try:
new_cred = self.store.locked_get()
if (new_cred and not new_cred.invalid and
new_cred.access_token != self.access_token):
logger.info('Updated access_token read from Storage')
self._updateFromCredential(new_cred)
else:
self._do_refresh_request(http_request)
finally:
self.store.release_lock()
def _do_refresh_request(self, http_request):
"""Refresh the access_token using the refresh_token.
Args:
http_request: callable, a callable that matches the method signature of
httplib2.Http.request, used to make the refresh request.
Raises:
AccessTokenRefreshError: When the refresh fails.
"""
body = self._generate_refresh_request_body()
headers = self._generate_refresh_request_headers()
logger.info('Refreshing access_token')
resp, content = http_request(
self.token_uri, method='POST', body=body, headers=headers)
if resp.status == 200:
# TODO(jcgregorio) Raise an error if loads fails?
d = simplejson.loads(content)
self.access_token = d['access_token']
self.refresh_token = d.get('refresh_token', self.refresh_token)
if 'expires_in' in d:
self.token_expiry = datetime.timedelta(
seconds=int(d['expires_in'])) + datetime.datetime.utcnow()
else:
self.token_expiry = None
if self.store:
self.store.locked_put(self)
else:
# An {'error':...} response body means the token is expired or revoked,
# so we flag the credentials as such.
logger.info('Failed to retrieve access token: %s' % content)
error_msg = 'Invalid response %s.' % resp['status']
try:
d = simplejson.loads(content)
if 'error' in d:
error_msg = d['error']
self.invalid = True
if self.store:
self.store.locked_put(self)
except:
pass
raise AccessTokenRefreshError(error_msg)
class AccessTokenCredentials(OAuth2Credentials):
"""Credentials object for OAuth 2.0.
Credentials can be applied to an httplib2.Http object using the
authorize() method, which then signs each request from that object
with the OAuth 2.0 access token. This set of credentials is for the
use case where you have acquired an OAuth 2.0 access_token from
another place such as a JavaScript client or another web
application, and wish to use it from Python. Because only the
access_token is present it can not be refreshed and will in time
expire.
AccessTokenCredentials objects may be safely pickled and unpickled.
Usage:
credentials = AccessTokenCredentials('<an access token>',
'my-user-agent/1.0')
http = httplib2.Http()
http = credentials.authorize(http)
Exceptions:
AccessTokenCredentialsExpired: raised when the access_token expires or is
revoked.
"""
def __init__(self, access_token, user_agent):
"""Create an instance of OAuth2Credentials
This is one of the few types if Credentials that you should contrust,
Credentials objects are usually instantiated by a Flow.
Args:
access_token: string, access token.
user_agent: string, The HTTP User-Agent to provide for this application.
Notes:
store: callable, a callable that when passed a Credential
will store the credential back to where it came from.
"""
super(AccessTokenCredentials, self).__init__(
access_token,
None,
None,
None,
None,
None,
user_agent)
@classmethod
def from_json(cls, s):
data = simplejson.loads(s)
retval = AccessTokenCredentials(
data['access_token'],
data['user_agent'])
return retval
def _refresh(self, http_request):
raise AccessTokenCredentialsError(
"The access_token is expired or invalid and can't be refreshed.")
class AssertionCredentials(OAuth2Credentials):
"""Abstract Credentials object used for OAuth 2.0 assertion grants.
This credential does not require a flow to instantiate because it
represents a two legged flow, and therefore has all of the required
information to generate and refresh its own access tokens. It must
be subclassed to generate the appropriate assertion string.
AssertionCredentials objects may be safely pickled and unpickled.
"""
def __init__(self, assertion_type, user_agent,
token_uri='https://accounts.google.com/o/oauth2/token',
**unused_kwargs):
"""Constructor for AssertionFlowCredentials.
Args:
assertion_type: string, assertion type that will be declared to the auth
server
user_agent: string, The HTTP User-Agent to provide for this application.
token_uri: string, URI for token endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
"""
super(AssertionCredentials, self).__init__(
None,
None,
None,
None,
None,
token_uri,
user_agent)
self.assertion_type = assertion_type
def _generate_refresh_request_body(self):
assertion = self._generate_assertion()
body = urllib.urlencode({
'assertion_type': self.assertion_type,
'assertion': assertion,
'grant_type': 'assertion',
})
return body
def _generate_assertion(self):
"""Generate the assertion string that will be used in the access token
request.
"""
_abstract()
if HAS_OPENSSL:
# PyOpenSSL is not a prerequisite for oauth2client, so if it is missing then
# don't create the SignedJwtAssertionCredentials or the verify_id_token()
# method.
class SignedJwtAssertionCredentials(AssertionCredentials):
"""Credentials object used for OAuth 2.0 Signed JWT assertion grants.
This credential does not require a flow to instantiate because it
represents a two legged flow, and therefore has all of the required
information to generate and refresh its own access tokens.
"""
MAX_TOKEN_LIFETIME_SECS = 3600 # 1 hour in seconds
def __init__(self,
service_account_name,
private_key,
scope,
private_key_password='notasecret',
user_agent=None,
token_uri='https://accounts.google.com/o/oauth2/token',
**kwargs):
"""Constructor for SignedJwtAssertionCredentials.
Args:
service_account_name: string, id for account, usually an email address.
private_key: string, private key in P12 format.
scope: string or list of strings, scope(s) of the credentials being
requested.
private_key_password: string, password for private_key.
user_agent: string, HTTP User-Agent to provide for this application.
token_uri: string, URI for token endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
kwargs: kwargs, Additional parameters to add to the JWT token, for
example prn=joe@xample.org."""
super(SignedJwtAssertionCredentials, self).__init__(
'http://oauth.net/grant_type/jwt/1.0/bearer',
user_agent,
token_uri=token_uri,
)
if type(scope) is list:
scope = ' '.join(scope)
self.scope = scope
self.private_key = private_key
self.private_key_password = private_key_password
self.service_account_name = service_account_name
self.kwargs = kwargs
@classmethod
def from_json(cls, s):
data = simplejson.loads(s)
retval = SignedJwtAssertionCredentials(
data['service_account_name'],
data['private_key'],
data['private_key_password'],
data['scope'],
data['user_agent'],
data['token_uri'],
data['kwargs']
)
retval.invalid = data['invalid']
return retval
def _generate_assertion(self):
"""Generate the assertion that will be used in the request."""
now = long(time.time())
payload = {
'aud': self.token_uri,
'scope': self.scope,
'iat': now,
'exp': now + SignedJwtAssertionCredentials.MAX_TOKEN_LIFETIME_SECS,
'iss': self.service_account_name
}
payload.update(self.kwargs)
logger.debug(str(payload))
return make_signed_jwt(
Signer.from_string(self.private_key, self.private_key_password),
payload)
# Only used in verify_id_token(), which is always calling to the same URI
# for the certs.
_cached_http = httplib2.Http(MemoryCache())
def verify_id_token(id_token, audience, http=None,
cert_uri=ID_TOKEN_VERIFICATON_CERTS):
"""Verifies a signed JWT id_token.
Args:
id_token: string, A Signed JWT.
audience: string, The audience 'aud' that the token should be for.
http: httplib2.Http, instance to use to make the HTTP request. Callers
should supply an instance that has caching enabled.
cert_uri: string, URI of the certificates in JSON format to
verify the JWT against.
Returns:
The deserialized JSON in the JWT.
Raises:
oauth2client.crypt.AppIdentityError if the JWT fails to verify.
"""
if http is None:
http = _cached_http
resp, content = http.request(cert_uri)
if resp.status == 200:
certs = simplejson.loads(content)
return verify_signed_jwt_with_certs(id_token, certs, audience)
else:
raise VerifyJwtTokenError('Status code: %d' % resp.status)
def _urlsafe_b64decode(b64string):
# Guard against unicode strings, which base64 can't handle.
b64string = b64string.encode('ascii')
padded = b64string + '=' * (4 - len(b64string) % 4)
return base64.urlsafe_b64decode(padded)
def _extract_id_token(id_token):
"""Extract the JSON payload from a JWT.
Does the extraction w/o checking the signature.
Args:
id_token: string, OAuth 2.0 id_token.
Returns:
object, The deserialized JSON payload.
"""
segments = id_token.split('.')
if (len(segments) != 3):
raise VerifyJwtTokenError(
'Wrong number of segments in token: %s' % id_token)
return simplejson.loads(_urlsafe_b64decode(segments[1]))
def credentials_from_code(client_id, client_secret, scope, code,
redirect_uri = 'postmessage',
http=None, user_agent=None,
token_uri='https://accounts.google.com/o/oauth2/token'):
"""Exchanges an authorization code for an OAuth2Credentials object.
Args:
client_id: string, client identifier.
client_secret: string, client secret.
scope: string or list of strings, scope(s) to request.
code: string, An authroization code, most likely passed down from
the client
redirect_uri: string, this is generally set to 'postmessage' to match the
redirect_uri that the client specified
http: httplib2.Http, optional http instance to use to do the fetch
token_uri: string, URI for token endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
Returns:
An OAuth2Credentials object.
Raises:
FlowExchangeError if the authorization code cannot be exchanged for an
access token
"""
flow = OAuth2WebServerFlow(client_id, client_secret, scope, user_agent,
'https://accounts.google.com/o/oauth2/auth',
token_uri)
# We primarily make this call to set up the redirect_uri in the flow object
uriThatWeDontReallyUse = flow.step1_get_authorize_url(redirect_uri)
credentials = flow.step2_exchange(code, http)
return credentials
def credentials_from_clientsecrets_and_code(filename, scope, code,
message = None,
redirect_uri = 'postmessage',
http=None):
"""Returns OAuth2Credentials from a clientsecrets file and an auth code.
Will create the right kind of Flow based on the contents of the clientsecrets
file or will raise InvalidClientSecretsError for unknown types of Flows.
Args:
filename: string, File name of clientsecrets.
scope: string or list of strings, scope(s) to request.
code: string, An authroization code, most likely passed down from
the client
message: string, A friendly string to display to the user if the
clientsecrets file is missing or invalid. If message is provided then
sys.exit will be called in the case of an error. If message in not
provided then clientsecrets.InvalidClientSecretsError will be raised.
redirect_uri: string, this is generally set to 'postmessage' to match the
redirect_uri that the client specified
http: httplib2.Http, optional http instance to use to do the fetch
Returns:
An OAuth2Credentials object.
Raises:
FlowExchangeError if the authorization code cannot be exchanged for an
access token
UnknownClientSecretsFlowError if the file describes an unknown kind of Flow.
clientsecrets.InvalidClientSecretsError if the clientsecrets file is
invalid.
"""
flow = flow_from_clientsecrets(filename, scope, message)
# We primarily make this call to set up the redirect_uri in the flow object
uriThatWeDontReallyUse = flow.step1_get_authorize_url(redirect_uri)
credentials = flow.step2_exchange(code, http)
return credentials
class OAuth2WebServerFlow(Flow):
"""Does the Web Server Flow for OAuth 2.0.
OAuth2Credentials objects may be safely pickled and unpickled.
"""
def __init__(self, client_id, client_secret, scope, user_agent=None,
auth_uri='https://accounts.google.com/o/oauth2/auth',
token_uri='https://accounts.google.com/o/oauth2/token',
**kwargs):
"""Constructor for OAuth2WebServerFlow.
Args:
client_id: string, client identifier.
client_secret: string client secret.
scope: string or list of strings, scope(s) of the credentials being
requested.
user_agent: string, HTTP User-Agent to provide for this application.
auth_uri: string, URI for authorization endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
token_uri: string, URI for token endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
**kwargs: dict, The keyword arguments are all optional and required
parameters for the OAuth calls.
"""
self.client_id = client_id
self.client_secret = client_secret
if type(scope) is list:
scope = ' '.join(scope)
self.scope = scope
self.user_agent = user_agent
self.auth_uri = auth_uri
self.token_uri = token_uri
self.params = {
'access_type': 'offline',
}
self.params.update(kwargs)
self.redirect_uri = None
def step1_get_authorize_url(self, redirect_uri=OOB_CALLBACK_URN):
"""Returns a URI to redirect to the provider.
Args:
redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob' for
a non-web-based application, or a URI that handles the callback from
the authorization server.
If redirect_uri is 'urn:ietf:wg:oauth:2.0:oob' then pass in the
generated verification code to step2_exchange,
otherwise pass in the query parameters received
at the callback uri to step2_exchange.
"""
self.redirect_uri = redirect_uri
query = {
'response_type': 'code',
'client_id': self.client_id,
'redirect_uri': redirect_uri,
'scope': self.scope,
}
query.update(self.params)
parts = list(urlparse.urlparse(self.auth_uri))
query.update(dict(parse_qsl(parts[4]))) # 4 is the index of the query part
parts[4] = urllib.urlencode(query)
return urlparse.urlunparse(parts)
def step2_exchange(self, code, http=None):
"""Exhanges a code for OAuth2Credentials.
Args:
code: string or dict, either the code as a string, or a dictionary
of the query parameters to the redirect_uri, which contains
the code.
http: httplib2.Http, optional http instance to use to do the fetch
Returns:
An OAuth2Credentials object that can be used to authorize requests.
Raises:
FlowExchangeError if a problem occured exchanging the code for a
refresh_token.
"""
if not (isinstance(code, str) or isinstance(code, unicode)):
if 'code' not in code:
if 'error' in code:
error_msg = code['error']
else:
error_msg = 'No code was supplied in the query parameters.'
raise FlowExchangeError(error_msg)
else:
code = code['code']
body = urllib.urlencode({
'grant_type': 'authorization_code',
'client_id': self.client_id,
'client_secret': self.client_secret,
'code': code,
'redirect_uri': self.redirect_uri,
'scope': self.scope,
})
headers = {
'content-type': 'application/x-www-form-urlencoded',
}
if self.user_agent is not None:
headers['user-agent'] = self.user_agent
if http is None:
http = httplib2.Http()
resp, content = http.request(self.token_uri, method='POST', body=body,
headers=headers)
if resp.status == 200:
# TODO(jcgregorio) Raise an error if simplejson.loads fails?
d = simplejson.loads(content)
access_token = d['access_token']
refresh_token = d.get('refresh_token', None)
token_expiry = None
if 'expires_in' in d:
token_expiry = datetime.datetime.utcnow() + datetime.timedelta(
seconds=int(d['expires_in']))
if 'id_token' in d:
d['id_token'] = _extract_id_token(d['id_token'])
logger.info('Successfully retrieved access token: %s' % content)
return OAuth2Credentials(access_token, self.client_id,
self.client_secret, refresh_token, token_expiry,
self.token_uri, self.user_agent,
id_token=d.get('id_token', None))
else:
logger.info('Failed to retrieve access token: %s' % content)
error_msg = 'Invalid response %s.' % resp['status']
try:
d = simplejson.loads(content)
if 'error' in d:
error_msg = d['error']
except:
pass
raise FlowExchangeError(error_msg)
def flow_from_clientsecrets(filename, scope, message=None):
"""Create a Flow from a clientsecrets file.
Will create the right kind of Flow based on the contents of the clientsecrets
file or will raise InvalidClientSecretsError for unknown types of Flows.
Args:
filename: string, File name of client secrets.
scope: string or list of strings, scope(s) to request.
message: string, A friendly string to display to the user if the
clientsecrets file is missing or invalid. If message is provided then
sys.exit will be called in the case of an error. If message in not
provided then clientsecrets.InvalidClientSecretsError will be raised.
Returns:
A Flow object.
Raises:
UnknownClientSecretsFlowError if the file describes an unknown kind of Flow.
clientsecrets.InvalidClientSecretsError if the clientsecrets file is
invalid.
"""
try:
client_type, client_info = clientsecrets.loadfile(filename)
if client_type in [clientsecrets.TYPE_WEB, clientsecrets.TYPE_INSTALLED]:
return OAuth2WebServerFlow(
client_info['client_id'],
client_info['client_secret'],
scope,
None, # user_agent
client_info['auth_uri'],
client_info['token_uri'])
except clientsecrets.InvalidClientSecretsError:
if message:
sys.exit(message)
else:
raise
else:
raise UnknownClientSecretsFlowError(
'This OAuth 2.0 flow is unsupported: "%s"' * client_type)
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for OAuth.
Utilities for making it easier to work with OAuth 2.0
credentials.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import os
import stat
import threading
from anyjson import simplejson
from client import Storage as BaseStorage
from client import Credentials
class Storage(BaseStorage):
"""Store and retrieve a single credential to and from a file."""
def __init__(self, filename):
self._filename = filename
self._lock = threading.Lock()
def acquire_lock(self):
"""Acquires any lock necessary to access this Storage.
This lock is not reentrant."""
self._lock.acquire()
def release_lock(self):
"""Release the Storage lock.
Trying to release a lock that isn't held will result in a
RuntimeError.
"""
self._lock.release()
def locked_get(self):
"""Retrieve Credential from file.
Returns:
oauth2client.client.Credentials
"""
credentials = None
try:
f = open(self._filename, 'rb')
content = f.read()
f.close()
except IOError:
return credentials
try:
credentials = Credentials.new_from_json(content)
credentials.set_store(self)
except ValueError:
pass
return credentials
def _create_file_if_needed(self):
"""Create an empty file if necessary.
This method will not initialize the file. Instead it implements a
simple version of "touch" to ensure the file has been created.
"""
if not os.path.exists(self._filename):
old_umask = os.umask(0177)
try:
open(self._filename, 'a+b').close()
finally:
os.umask(old_umask)
def locked_put(self, credentials):
"""Write Credentials to file.
Args:
credentials: Credentials, the credentials to store.
"""
self._create_file_if_needed()
f = open(self._filename, 'wb')
f.write(credentials.to_json())
f.close()
def locked_delete(self):
"""Delete Credentials file.
Args:
credentials: Credentials, the credentials to store.
"""
os.unlink(self._filename)
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""OAuth 2.0 utilities for Django.
Utilities for using OAuth 2.0 in conjunction with
the Django datastore.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import oauth2client
import base64
import pickle
from django.db import models
from oauth2client.client import Storage as BaseStorage
class CredentialsField(models.Field):
__metaclass__ = models.SubfieldBase
def get_internal_type(self):
return "TextField"
def to_python(self, value):
if value is None:
return None
if isinstance(value, oauth2client.client.Credentials):
return value
return pickle.loads(base64.b64decode(value))
def get_db_prep_value(self, value, connection, prepared=False):
if value is None:
return None
return base64.b64encode(pickle.dumps(value))
class FlowField(models.Field):
__metaclass__ = models.SubfieldBase
def get_internal_type(self):
return "TextField"
def to_python(self, value):
if value is None:
return None
if isinstance(value, oauth2client.client.Flow):
return value
return pickle.loads(base64.b64decode(value))
def get_db_prep_value(self, value, connection, prepared=False):
if value is None:
return None
return base64.b64encode(pickle.dumps(value))
class Storage(BaseStorage):
"""Store and retrieve a single credential to and from
the datastore.
This Storage helper presumes the Credentials
have been stored as a CredenialsField
on a db model class.
"""
def __init__(self, model_class, key_name, key_value, property_name):
"""Constructor for Storage.
Args:
model: db.Model, model class
key_name: string, key name for the entity that has the credentials
key_value: string, key value for the entity that has the credentials
property_name: string, name of the property that is an CredentialsProperty
"""
self.model_class = model_class
self.key_name = key_name
self.key_value = key_value
self.property_name = property_name
def locked_get(self):
"""Retrieve Credential from datastore.
Returns:
oauth2client.Credentials
"""
credential = None
query = {self.key_name: self.key_value}
entities = self.model_class.objects.filter(**query)
if len(entities) > 0:
credential = getattr(entities[0], self.property_name)
if credential and hasattr(credential, 'set_store'):
credential.set_store(self)
return credential
def locked_put(self, credentials):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
"""
args = {self.key_name: self.key_value}
entity = self.model_class(**args)
setattr(entity, self.property_name, credentials)
entity.save()
def locked_delete(self):
"""Delete Credentials from the datastore."""
query = {self.key_name: self.key_value}
entities = self.model_class.objects.filter(**query).delete()
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for Google App Engine
Utilities for making it easier to use OAuth 2.0 on Google App Engine.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import base64
import httplib2
import logging
import pickle
import time
import clientsecrets
from anyjson import simplejson
from client import AccessTokenRefreshError
from client import AssertionCredentials
from client import Credentials
from client import Flow
from client import OAuth2WebServerFlow
from client import Storage
from google.appengine.api import memcache
from google.appengine.api import users
from google.appengine.api import app_identity
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import login_required
from google.appengine.ext.webapp.util import run_wsgi_app
OAUTH2CLIENT_NAMESPACE = 'oauth2client#ns'
class InvalidClientSecretsError(Exception):
"""The client_secrets.json file is malformed or missing required fields."""
pass
class AppAssertionCredentials(AssertionCredentials):
"""Credentials object for App Engine Assertion Grants
This object will allow an App Engine application to identify itself to Google
and other OAuth 2.0 servers that can verify assertions. It can be used for
the purpose of accessing data stored under an account assigned to the App
Engine application itself.
This credential does not require a flow to instantiate because it represents
a two legged flow, and therefore has all of the required information to
generate and refresh its own access tokens.
"""
def __init__(self, scope, **kwargs):
"""Constructor for AppAssertionCredentials
Args:
scope: string or list of strings, scope(s) of the credentials being requested.
"""
if type(scope) is list:
scope = ' '.join(scope)
self.scope = scope
super(AppAssertionCredentials, self).__init__(
None,
None,
None)
@classmethod
def from_json(cls, json):
data = simplejson.loads(json)
return AppAssertionCredentials(data['scope'])
def _refresh(self, http_request):
"""Refreshes the access_token.
Since the underlying App Engine app_identity implementation does its own
caching we can skip all the storage hoops and just to a refresh using the
API.
Args:
http_request: callable, a callable that matches the method signature of
httplib2.Http.request, used to make the refresh request.
Raises:
AccessTokenRefreshError: When the refresh fails.
"""
try:
(token, _) = app_identity.get_access_token(self.scope)
except app_identity.Error, e:
raise AccessTokenRefreshError(str(e))
self.access_token = token
class FlowProperty(db.Property):
"""App Engine datastore Property for Flow.
Utility property that allows easy storage and retreival of an
oauth2client.Flow"""
# Tell what the user type is.
data_type = Flow
# For writing to datastore.
def get_value_for_datastore(self, model_instance):
flow = super(FlowProperty,
self).get_value_for_datastore(model_instance)
return db.Blob(pickle.dumps(flow))
# For reading from datastore.
def make_value_from_datastore(self, value):
if value is None:
return None
return pickle.loads(value)
def validate(self, value):
if value is not None and not isinstance(value, Flow):
raise db.BadValueError('Property %s must be convertible '
'to a FlowThreeLegged instance (%s)' %
(self.name, value))
return super(FlowProperty, self).validate(value)
def empty(self, value):
return not value
class CredentialsProperty(db.Property):
"""App Engine datastore Property for Credentials.
Utility property that allows easy storage and retrieval of
oath2client.Credentials
"""
# Tell what the user type is.
data_type = Credentials
# For writing to datastore.
def get_value_for_datastore(self, model_instance):
logging.info("get: Got type " + str(type(model_instance)))
cred = super(CredentialsProperty,
self).get_value_for_datastore(model_instance)
if cred is None:
cred = ''
else:
cred = cred.to_json()
return db.Blob(cred)
# For reading from datastore.
def make_value_from_datastore(self, value):
logging.info("make: Got type " + str(type(value)))
if value is None:
return None
if len(value) == 0:
return None
try:
credentials = Credentials.new_from_json(value)
except ValueError:
credentials = None
return credentials
def validate(self, value):
value = super(CredentialsProperty, self).validate(value)
logging.info("validate: Got type " + str(type(value)))
if value is not None and not isinstance(value, Credentials):
raise db.BadValueError('Property %s must be convertible '
'to a Credentials instance (%s)' %
(self.name, value))
#if value is not None and not isinstance(value, Credentials):
# return None
return value
class StorageByKeyName(Storage):
"""Store and retrieve a single credential to and from
the App Engine datastore.
This Storage helper presumes the Credentials
have been stored as a CredenialsProperty
on a datastore model class, and that entities
are stored by key_name.
"""
def __init__(self, model, key_name, property_name, cache=None):
"""Constructor for Storage.
Args:
model: db.Model, model class
key_name: string, key name for the entity that has the credentials
property_name: string, name of the property that is a CredentialsProperty
cache: memcache, a write-through cache to put in front of the datastore
"""
self._model = model
self._key_name = key_name
self._property_name = property_name
self._cache = cache
def locked_get(self):
"""Retrieve Credential from datastore.
Returns:
oauth2client.Credentials
"""
if self._cache:
json = self._cache.get(self._key_name)
if json:
return Credentials.new_from_json(json)
credential = None
entity = self._model.get_by_key_name(self._key_name)
if entity is not None:
credential = getattr(entity, self._property_name)
if credential and hasattr(credential, 'set_store'):
credential.set_store(self)
if self._cache:
self._cache.set(self._key_name, credential.to_json())
return credential
def locked_put(self, credentials):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
"""
entity = self._model.get_or_insert(self._key_name)
setattr(entity, self._property_name, credentials)
entity.put()
if self._cache:
self._cache.set(self._key_name, credentials.to_json())
def locked_delete(self):
"""Delete Credential from datastore."""
if self._cache:
self._cache.delete(self._key_name)
entity = self._model.get_by_key_name(self._key_name)
if entity is not None:
entity.delete()
class CredentialsModel(db.Model):
"""Storage for OAuth 2.0 Credentials
Storage of the model is keyed by the user.user_id().
"""
credentials = CredentialsProperty()
class OAuth2Decorator(object):
"""Utility for making OAuth 2.0 easier.
Instantiate and then use with oauth_required or oauth_aware
as decorators on webapp.RequestHandler methods.
Example:
decorator = OAuth2Decorator(
client_id='837...ent.com',
client_secret='Qh...wwI',
scope='https://www.googleapis.com/auth/plus')
class MainHandler(webapp.RequestHandler):
@decorator.oauth_required
def get(self):
http = decorator.http()
# http is authorized with the user's Credentials and can be used
# in API calls
"""
def __init__(self, client_id, client_secret, scope,
auth_uri='https://accounts.google.com/o/oauth2/auth',
token_uri='https://accounts.google.com/o/oauth2/token',
user_agent=None,
message=None, **kwargs):
"""Constructor for OAuth2Decorator
Args:
client_id: string, client identifier.
client_secret: string client secret.
scope: string or list of strings, scope(s) of the credentials being
requested.
auth_uri: string, URI for authorization endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
token_uri: string, URI for token endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
user_agent: string, User agent of your application, default to None.
message: Message to display if there are problems with the OAuth 2.0
configuration. The message may contain HTML and will be presented on the
web interface for any method that uses the decorator.
**kwargs: dict, Keyword arguments are be passed along as kwargs to the
OAuth2WebServerFlow constructor.
"""
self.flow = OAuth2WebServerFlow(client_id, client_secret, scope, user_agent,
auth_uri, token_uri, **kwargs)
self.credentials = None
self._request_handler = None
self._message = message
self._in_error = False
def _display_error_message(self, request_handler):
request_handler.response.out.write('<html><body>')
request_handler.response.out.write(self._message)
request_handler.response.out.write('</body></html>')
def oauth_required(self, method):
"""Decorator that starts the OAuth 2.0 dance.
Starts the OAuth dance for the logged in user if they haven't already
granted access for this application.
Args:
method: callable, to be decorated method of a webapp.RequestHandler
instance.
"""
def check_oauth(request_handler, *args, **kwargs):
if self._in_error:
self._display_error_message(request_handler)
return
user = users.get_current_user()
# Don't use @login_decorator as this could be used in a POST request.
if not user:
request_handler.redirect(users.create_login_url(
request_handler.request.uri))
return
# Store the request URI in 'state' so we can use it later
self.flow.params['state'] = request_handler.request.url
self._request_handler = request_handler
self.credentials = StorageByKeyName(
CredentialsModel, user.user_id(), 'credentials').get()
if not self.has_credentials():
return request_handler.redirect(self.authorize_url())
try:
method(request_handler, *args, **kwargs)
except AccessTokenRefreshError:
return request_handler.redirect(self.authorize_url())
return check_oauth
def oauth_aware(self, method):
"""Decorator that sets up for OAuth 2.0 dance, but doesn't do it.
Does all the setup for the OAuth dance, but doesn't initiate it.
This decorator is useful if you want to create a page that knows
whether or not the user has granted access to this application.
From within a method decorated with @oauth_aware the has_credentials()
and authorize_url() methods can be called.
Args:
method: callable, to be decorated method of a webapp.RequestHandler
instance.
"""
def setup_oauth(request_handler, *args, **kwargs):
if self._in_error:
self._display_error_message(request_handler)
return
user = users.get_current_user()
# Don't use @login_decorator as this could be used in a POST request.
if not user:
request_handler.redirect(users.create_login_url(
request_handler.request.uri))
return
self.flow.params['state'] = request_handler.request.url
self._request_handler = request_handler
self.credentials = StorageByKeyName(
CredentialsModel, user.user_id(), 'credentials').get()
method(request_handler, *args, **kwargs)
return setup_oauth
def has_credentials(self):
"""True if for the logged in user there are valid access Credentials.
Must only be called from with a webapp.RequestHandler subclassed method
that had been decorated with either @oauth_required or @oauth_aware.
"""
return self.credentials is not None and not self.credentials.invalid
def authorize_url(self):
"""Returns the URL to start the OAuth dance.
Must only be called from with a webapp.RequestHandler subclassed method
that had been decorated with either @oauth_required or @oauth_aware.
"""
callback = self._request_handler.request.relative_url('/oauth2callback')
url = self.flow.step1_get_authorize_url(callback)
user = users.get_current_user()
memcache.set(user.user_id(), pickle.dumps(self.flow),
namespace=OAUTH2CLIENT_NAMESPACE)
return str(url)
def http(self):
"""Returns an authorized http instance.
Must only be called from within an @oauth_required decorated method, or
from within an @oauth_aware decorated method where has_credentials()
returns True.
"""
return self.credentials.authorize(httplib2.Http())
class OAuth2DecoratorFromClientSecrets(OAuth2Decorator):
"""An OAuth2Decorator that builds from a clientsecrets file.
Uses a clientsecrets file as the source for all the information when
constructing an OAuth2Decorator.
Example:
decorator = OAuth2DecoratorFromClientSecrets(
os.path.join(os.path.dirname(__file__), 'client_secrets.json')
scope='https://www.googleapis.com/auth/plus')
class MainHandler(webapp.RequestHandler):
@decorator.oauth_required
def get(self):
http = decorator.http()
# http is authorized with the user's Credentials and can be used
# in API calls
"""
def __init__(self, filename, scope, message=None):
"""Constructor
Args:
filename: string, File name of client secrets.
scope: string or list of strings, scope(s) of the credentials being
requested.
message: string, A friendly string to display to the user if the
clientsecrets file is missing or invalid. The message may contain HTML and
will be presented on the web interface for any method that uses the
decorator.
"""
try:
client_type, client_info = clientsecrets.loadfile(filename)
if client_type not in [clientsecrets.TYPE_WEB, clientsecrets.TYPE_INSTALLED]:
raise InvalidClientSecretsError('OAuth2Decorator doesn\'t support this OAuth 2.0 flow.')
super(OAuth2DecoratorFromClientSecrets,
self).__init__(
client_info['client_id'],
client_info['client_secret'],
scope,
client_info['auth_uri'],
client_info['token_uri'],
message)
except clientsecrets.InvalidClientSecretsError:
self._in_error = True
if message is not None:
self._message = message
else:
self._message = "Please configure your application for OAuth 2.0"
def oauth2decorator_from_clientsecrets(filename, scope, message=None):
"""Creates an OAuth2Decorator populated from a clientsecrets file.
Args:
filename: string, File name of client secrets.
scope: string or list of strings, scope(s) of the credentials being
requested.
message: string, A friendly string to display to the user if the
clientsecrets file is missing or invalid. The message may contain HTML and
will be presented on the web interface for any method that uses the
decorator.
Returns: An OAuth2Decorator
"""
return OAuth2DecoratorFromClientSecrets(filename, scope, message)
class OAuth2Handler(webapp.RequestHandler):
"""Handler for the redirect_uri of the OAuth 2.0 dance."""
@login_required
def get(self):
error = self.request.get('error')
if error:
errormsg = self.request.get('error_description', error)
self.response.out.write(
'The authorization request failed: %s' % errormsg)
else:
user = users.get_current_user()
flow = pickle.loads(memcache.get(user.user_id(),
namespace=OAUTH2CLIENT_NAMESPACE))
# This code should be ammended with application specific error
# handling. The following cases should be considered:
# 1. What if the flow doesn't exist in memcache? Or is corrupt?
# 2. What if the step2_exchange fails?
if flow:
credentials = flow.step2_exchange(self.request.params)
StorageByKeyName(
CredentialsModel, user.user_id(), 'credentials').put(credentials)
self.redirect(str(self.request.get('state')))
else:
# TODO Add error handling here.
pass
application = webapp.WSGIApplication([('/oauth2callback', OAuth2Handler)])
def main():
run_wsgi_app(application)
| Python |
#!/usr/bin/python2.4
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import base64
import hashlib
import logging
import time
from OpenSSL import crypto
from anyjson import simplejson
CLOCK_SKEW_SECS = 300 # 5 minutes in seconds
AUTH_TOKEN_LIFETIME_SECS = 300 # 5 minutes in seconds
MAX_TOKEN_LIFETIME_SECS = 86400 # 1 day in seconds
class AppIdentityError(Exception):
pass
class Verifier(object):
"""Verifies the signature on a message."""
def __init__(self, pubkey):
"""Constructor.
Args:
pubkey, OpenSSL.crypto.PKey, The public key to verify with.
"""
self._pubkey = pubkey
def verify(self, message, signature):
"""Verifies a message against a signature.
Args:
message: string, The message to verify.
signature: string, The signature on the message.
Returns:
True if message was singed by the private key associated with the public
key that this object was constructed with.
"""
try:
crypto.verify(self._pubkey, signature, message, 'sha256')
return True
except:
return False
@staticmethod
def from_string(key_pem, is_x509_cert):
"""Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it is
expected to be an RSA key in PEM format.
Returns:
Verifier instance.
Raises:
OpenSSL.crypto.Error if the key_pem can't be parsed.
"""
if is_x509_cert:
pubkey = crypto.load_certificate(crypto.FILETYPE_PEM, key_pem)
else:
pubkey = crypto.load_privatekey(crypto.FILETYPE_PEM, key_pem)
return Verifier(pubkey)
class Signer(object):
"""Signs messages with a private key."""
def __init__(self, pkey):
"""Constructor.
Args:
pkey, OpenSSL.crypto.PKey, The private key to sign with.
"""
self._key = pkey
def sign(self, message):
"""Signs a message.
Args:
message: string, Message to be signed.
Returns:
string, The signature of the message for the given key.
"""
return crypto.sign(self._key, message, 'sha256')
@staticmethod
def from_string(key, password='notasecret'):
"""Construct a Signer instance from a string.
Args:
key: string, private key in P12 format.
password: string, password for the private key file.
Returns:
Signer instance.
Raises:
OpenSSL.crypto.Error if the key can't be parsed.
"""
pkey = crypto.load_pkcs12(key, password).get_privatekey()
return Signer(pkey)
def _urlsafe_b64encode(raw_bytes):
return base64.urlsafe_b64encode(raw_bytes).rstrip('=')
def _urlsafe_b64decode(b64string):
# Guard against unicode strings, which base64 can't handle.
b64string = b64string.encode('ascii')
padded = b64string + '=' * (4 - len(b64string) % 4)
return base64.urlsafe_b64decode(padded)
def _json_encode(data):
return simplejson.dumps(data, separators = (',', ':'))
def make_signed_jwt(signer, payload):
"""Make a signed JWT.
See http://self-issued.info/docs/draft-jones-json-web-token.html.
Args:
signer: crypt.Signer, Cryptographic signer.
payload: dict, Dictionary of data to convert to JSON and then sign.
Returns:
string, The JWT for the payload.
"""
header = {'typ': 'JWT', 'alg': 'RS256'}
segments = [
_urlsafe_b64encode(_json_encode(header)),
_urlsafe_b64encode(_json_encode(payload)),
]
signing_input = '.'.join(segments)
signature = signer.sign(signing_input)
segments.append(_urlsafe_b64encode(signature))
logging.debug(str(segments))
return '.'.join(segments)
def verify_signed_jwt_with_certs(jwt, certs, audience):
"""Verify a JWT against public certs.
See http://self-issued.info/docs/draft-jones-json-web-token.html.
Args:
jwt: string, A JWT.
certs: dict, Dictionary where values of public keys in PEM format.
audience: string, The audience, 'aud', that this JWT should contain. If
None then the JWT's 'aud' parameter is not verified.
Returns:
dict, The deserialized JSON payload in the JWT.
Raises:
AppIdentityError if any checks are failed.
"""
segments = jwt.split('.')
if (len(segments) != 3):
raise AppIdentityError(
'Wrong number of segments in token: %s' % jwt)
signed = '%s.%s' % (segments[0], segments[1])
signature = _urlsafe_b64decode(segments[2])
# Parse token.
json_body = _urlsafe_b64decode(segments[1])
try:
parsed = simplejson.loads(json_body)
except:
raise AppIdentityError('Can\'t parse token: %s' % json_body)
# Check signature.
verified = False
for (keyname, pem) in certs.items():
verifier = Verifier.from_string(pem, True)
if (verifier.verify(signed, signature)):
verified = True
break
if not verified:
raise AppIdentityError('Invalid token signature: %s' % jwt)
# Check creation timestamp.
iat = parsed.get('iat')
if iat is None:
raise AppIdentityError('No iat field in token: %s' % json_body)
earliest = iat - CLOCK_SKEW_SECS
# Check expiration timestamp.
now = long(time.time())
exp = parsed.get('exp')
if exp is None:
raise AppIdentityError('No exp field in token: %s' % json_body)
if exp >= now + MAX_TOKEN_LIFETIME_SECS:
raise AppIdentityError(
'exp field too far in future: %s' % json_body)
latest = exp + CLOCK_SKEW_SECS
if now < earliest:
raise AppIdentityError('Token used too early, %d < %d: %s' %
(now, earliest, json_body))
if now > latest:
raise AppIdentityError('Token used too late, %d > %d: %s' %
(now, latest, json_body))
# Check audience.
if audience is not None:
aud = parsed.get('aud')
if aud is None:
raise AppIdentityError('No aud field in token: %s' % json_body)
if aud != audience:
raise AppIdentityError('Wrong recipient, %s != %s: %s' %
(aud, audience, json_body))
return parsed
| Python |
# Copyright (C) 2011 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for reading OAuth 2.0 client secret files.
A client_secrets.json file contains all the information needed to interact with
an OAuth 2.0 protected service.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
from anyjson import simplejson
# Properties that make a client_secrets.json file valid.
TYPE_WEB = 'web'
TYPE_INSTALLED = 'installed'
VALID_CLIENT = {
TYPE_WEB: {
'required': [
'client_id',
'client_secret',
'redirect_uris',
'auth_uri',
'token_uri'],
'string': [
'client_id',
'client_secret'
]
},
TYPE_INSTALLED: {
'required': [
'client_id',
'client_secret',
'redirect_uris',
'auth_uri',
'token_uri'],
'string': [
'client_id',
'client_secret'
]
}
}
class Error(Exception):
"""Base error for this module."""
pass
class InvalidClientSecretsError(Error):
"""Format of ClientSecrets file is invalid."""
pass
def _validate_clientsecrets(obj):
if obj is None or len(obj) != 1:
raise InvalidClientSecretsError('Invalid file format.')
client_type = obj.keys()[0]
if client_type not in VALID_CLIENT.keys():
raise InvalidClientSecretsError('Unknown client type: %s.' % client_type)
client_info = obj[client_type]
for prop_name in VALID_CLIENT[client_type]['required']:
if prop_name not in client_info:
raise InvalidClientSecretsError(
'Missing property "%s" in a client type of "%s".' % (prop_name,
client_type))
for prop_name in VALID_CLIENT[client_type]['string']:
if client_info[prop_name].startswith('[['):
raise InvalidClientSecretsError(
'Property "%s" is not configured.' % prop_name)
return client_type, client_info
def load(fp):
obj = simplejson.load(fp)
return _validate_clientsecrets(obj)
def loads(s):
obj = simplejson.loads(s)
return _validate_clientsecrets(obj)
def loadfile(filename):
try:
fp = file(filename, 'r')
try:
obj = simplejson.load(fp)
finally:
fp.close()
except IOError:
raise InvalidClientSecretsError('File not found: "%s"' % filename)
return _validate_clientsecrets(obj)
| Python |
# Copyright 2011 Google Inc. All Rights Reserved.
"""Locked file interface that should work on Unix and Windows pythons.
This module first tries to use fcntl locking to ensure serialized access
to a file, then falls back on a lock file if that is unavialable.
Usage:
f = LockedFile('filename', 'r+b', 'rb')
f.open_and_lock()
if f.is_locked():
print 'Acquired filename with r+b mode'
f.file_handle().write('locked data')
else:
print 'Aquired filename with rb mode'
f.unlock_and_close()
"""
__author__ = 'cache@google.com (David T McWherter)'
import errno
import logging
import os
import time
logger = logging.getLogger(__name__)
class AlreadyLockedException(Exception):
"""Trying to lock a file that has already been locked by the LockedFile."""
pass
class _Opener(object):
"""Base class for different locking primitives."""
def __init__(self, filename, mode, fallback_mode):
"""Create an Opener.
Args:
filename: string, The pathname of the file.
mode: string, The preferred mode to access the file with.
fallback_mode: string, The mode to use if locking fails.
"""
self._locked = False
self._filename = filename
self._mode = mode
self._fallback_mode = fallback_mode
self._fh = None
def is_locked(self):
"""Was the file locked."""
return self._locked
def file_handle(self):
"""The file handle to the file. Valid only after opened."""
return self._fh
def filename(self):
"""The filename that is being locked."""
return self._filename
def open_and_lock(self, timeout, delay):
"""Open the file and lock it.
Args:
timeout: float, How long to try to lock for.
delay: float, How long to wait between retries.
"""
pass
def unlock_and_close(self):
"""Unlock and close the file."""
pass
class _PosixOpener(_Opener):
"""Lock files using Posix advisory lock files."""
def open_and_lock(self, timeout, delay):
"""Open the file and lock it.
Tries to create a .lock file next to the file we're trying to open.
Args:
timeout: float, How long to try to lock for.
delay: float, How long to wait between retries.
Raises:
AlreadyLockedException: if the lock is already acquired.
IOError: if the open fails.
"""
if self._locked:
raise AlreadyLockedException('File %s is already locked' %
self._filename)
self._locked = False
try:
self._fh = open(self._filename, self._mode)
except IOError, e:
# If we can't access with _mode, try _fallback_mode and don't lock.
if e.errno == errno.EACCES:
self._fh = open(self._filename, self._fallback_mode)
return
lock_filename = self._posix_lockfile(self._filename)
start_time = time.time()
while True:
try:
self._lock_fd = os.open(lock_filename,
os.O_CREAT|os.O_EXCL|os.O_RDWR)
self._locked = True
break
except OSError, e:
if e.errno != errno.EEXIST:
raise
if (time.time() - start_time) >= timeout:
logger.warn('Could not acquire lock %s in %s seconds' % (
lock_filename, timeout))
# Close the file and open in fallback_mode.
if self._fh:
self._fh.close()
self._fh = open(self._filename, self._fallback_mode)
return
time.sleep(delay)
def unlock_and_close(self):
"""Unlock a file by removing the .lock file, and close the handle."""
if self._locked:
lock_filename = self._posix_lockfile(self._filename)
os.unlink(lock_filename)
os.close(self._lock_fd)
self._locked = False
self._lock_fd = None
if self._fh:
self._fh.close()
def _posix_lockfile(self, filename):
"""The name of the lock file to use for posix locking."""
return '%s.lock' % filename
try:
import fcntl
class _FcntlOpener(_Opener):
"""Open, lock, and unlock a file using fcntl.lockf."""
def open_and_lock(self, timeout, delay):
"""Open the file and lock it.
Args:
timeout: float, How long to try to lock for.
delay: float, How long to wait between retries
Raises:
AlreadyLockedException: if the lock is already acquired.
IOError: if the open fails.
"""
if self._locked:
raise AlreadyLockedException('File %s is already locked' %
self._filename)
start_time = time.time()
try:
self._fh = open(self._filename, self._mode)
except IOError, e:
# If we can't access with _mode, try _fallback_mode and don't lock.
if e.errno == errno.EACCES:
self._fh = open(self._filename, self._fallback_mode)
return
# We opened in _mode, try to lock the file.
while True:
try:
fcntl.lockf(self._fh.fileno(), fcntl.LOCK_EX)
self._locked = True
return
except IOError, e:
# If not retrying, then just pass on the error.
if timeout == 0:
raise e
if e.errno != errno.EACCES:
raise e
# We could not acquire the lock. Try again.
if (time.time() - start_time) >= timeout:
logger.warn('Could not lock %s in %s seconds' % (
self._filename, timeout))
if self._fh:
self._fh.close()
self._fh = open(self._filename, self._fallback_mode)
return
time.sleep(delay)
def unlock_and_close(self):
"""Close and unlock the file using the fcntl.lockf primitive."""
if self._locked:
fcntl.lockf(self._fh.fileno(), fcntl.LOCK_UN)
self._locked = False
if self._fh:
self._fh.close()
except ImportError:
_FcntlOpener = None
try:
import pywintypes
import win32con
import win32file
class _Win32Opener(_Opener):
"""Open, lock, and unlock a file using windows primitives."""
# Error #33:
# 'The process cannot access the file because another process'
FILE_IN_USE_ERROR = 33
# Error #158:
# 'The segment is already unlocked.'
FILE_ALREADY_UNLOCKED_ERROR = 158
def open_and_lock(self, timeout, delay):
"""Open the file and lock it.
Args:
timeout: float, How long to try to lock for.
delay: float, How long to wait between retries
Raises:
AlreadyLockedException: if the lock is already acquired.
IOError: if the open fails.
"""
if self._locked:
raise AlreadyLockedException('File %s is already locked' %
self._filename)
start_time = time.time()
try:
self._fh = open(self._filename, self._mode)
except IOError, e:
# If we can't access with _mode, try _fallback_mode and don't lock.
if e.errno == errno.EACCES:
self._fh = open(self._filename, self._fallback_mode)
return
# We opened in _mode, try to lock the file.
while True:
try:
hfile = win32file._get_osfhandle(self._fh.fileno())
win32file.LockFileEx(
hfile,
(win32con.LOCKFILE_FAIL_IMMEDIATELY|
win32con.LOCKFILE_EXCLUSIVE_LOCK), 0, -0x10000,
pywintypes.OVERLAPPED())
self._locked = True
return
except pywintypes.error, e:
if timeout == 0:
raise e
# If the error is not that the file is already in use, raise.
if e[0] != _Win32Opener.FILE_IN_USE_ERROR:
raise
# We could not acquire the lock. Try again.
if (time.time() - start_time) >= timeout:
logger.warn('Could not lock %s in %s seconds' % (
self._filename, timeout))
if self._fh:
self._fh.close()
self._fh = open(self._filename, self._fallback_mode)
return
time.sleep(delay)
def unlock_and_close(self):
"""Close and unlock the file using the win32 primitive."""
if self._locked:
try:
hfile = win32file._get_osfhandle(self._fh.fileno())
win32file.UnlockFileEx(hfile, 0, -0x10000, pywintypes.OVERLAPPED())
except pywintypes.error, e:
if e[0] != _Win32Opener.FILE_ALREADY_UNLOCKED_ERROR:
raise
self._locked = False
if self._fh:
self._fh.close()
except ImportError:
_Win32Opener = None
class LockedFile(object):
"""Represent a file that has exclusive access."""
def __init__(self, filename, mode, fallback_mode, use_native_locking=True):
"""Construct a LockedFile.
Args:
filename: string, The path of the file to open.
mode: string, The mode to try to open the file with.
fallback_mode: string, The mode to use if locking fails.
use_native_locking: bool, Whether or not fcntl/win32 locking is used.
"""
opener = None
if not opener and use_native_locking:
if _Win32Opener:
opener = _Win32Opener(filename, mode, fallback_mode)
if _FcntlOpener:
opener = _FcntlOpener(filename, mode, fallback_mode)
if not opener:
opener = _PosixOpener(filename, mode, fallback_mode)
self._opener = opener
def filename(self):
"""Return the filename we were constructed with."""
return self._opener._filename
def file_handle(self):
"""Return the file_handle to the opened file."""
return self._opener.file_handle()
def is_locked(self):
"""Return whether we successfully locked the file."""
return self._opener.is_locked()
def open_and_lock(self, timeout=0, delay=0.05):
"""Open the file, trying to lock it.
Args:
timeout: float, The number of seconds to try to acquire the lock.
delay: float, The number of seconds to wait between retry attempts.
Raises:
AlreadyLockedException: if the lock is already acquired.
IOError: if the open fails.
"""
self._opener.open_and_lock(timeout, delay)
def unlock_and_close(self):
"""Unlock and close a file."""
self._opener.unlock_and_close()
| Python |
__version__ = "1.0c2"
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utility module to import a JSON module
Hides all the messy details of exactly where
we get a simplejson module from.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
try: # pragma: no cover
# Should work for Python2.6 and higher.
import json as simplejson
except ImportError: # pragma: no cover
try:
import simplejson
except ImportError:
# Try to import from django, should work on App Engine
from django.utils import simplejson
| Python |
import Cookie
import datetime
import time
import email.utils
import calendar
import base64
import hashlib
import hmac
import re
import logging
# Ripped from the Tornado Framework's web.py
# http://github.com/facebook/tornado/commit/39ac6d169a36a54bb1f6b9bf1fdebb5c9da96e09
#
# Tornado is licensed under the Apache Licence, Version 2.0
# (http://www.apache.org/licenses/LICENSE-2.0.html).
#
# Example:
# from vendor.prayls.lilcookies import LilCookies
# cookieutil = LilCookies(self, application_settings['cookie_secret'])
# cookieutil.set_secure_cookie(name = 'mykey', value = 'myvalue', expires_days= 365*100)
# cookieutil.get_secure_cookie(name = 'mykey')
class LilCookies:
@staticmethod
def _utf8(s):
if isinstance(s, unicode):
return s.encode("utf-8")
assert isinstance(s, str)
return s
@staticmethod
def _time_independent_equals(a, b):
if len(a) != len(b):
return False
result = 0
for x, y in zip(a, b):
result |= ord(x) ^ ord(y)
return result == 0
@staticmethod
def _signature_from_secret(cookie_secret, *parts):
""" Takes a secret salt value to create a signature for values in the `parts` param."""
hash = hmac.new(cookie_secret, digestmod=hashlib.sha1)
for part in parts: hash.update(part)
return hash.hexdigest()
@staticmethod
def _signed_cookie_value(cookie_secret, name, value):
""" Returns a signed value for use in a cookie.
This is helpful to have in its own method if you need to re-use this function for other needs. """
timestamp = str(int(time.time()))
value = base64.b64encode(value)
signature = LilCookies._signature_from_secret(cookie_secret, name, value, timestamp)
return "|".join([value, timestamp, signature])
@staticmethod
def _verified_cookie_value(cookie_secret, name, signed_value):
"""Returns the un-encrypted value given the signed value if it validates, or None."""
value = signed_value
if not value: return None
parts = value.split("|")
if len(parts) != 3: return None
signature = LilCookies._signature_from_secret(cookie_secret, name, parts[0], parts[1])
if not LilCookies._time_independent_equals(parts[2], signature):
logging.warning("Invalid cookie signature %r", value)
return None
timestamp = int(parts[1])
if timestamp < time.time() - 31 * 86400:
logging.warning("Expired cookie %r", value)
return None
try:
return base64.b64decode(parts[0])
except:
return None
def __init__(self, handler, cookie_secret):
"""You must specify the cookie_secret to use any of the secure methods.
It should be a long, random sequence of bytes to be used as the HMAC
secret for the signature.
"""
if len(cookie_secret) < 45:
raise ValueError("LilCookies cookie_secret should at least be 45 characters long, but got `%s`" % cookie_secret)
self.handler = handler
self.request = handler.request
self.response = handler.response
self.cookie_secret = cookie_secret
def cookies(self):
"""A dictionary of Cookie.Morsel objects."""
if not hasattr(self, "_cookies"):
self._cookies = Cookie.BaseCookie()
if "Cookie" in self.request.headers:
try:
self._cookies.load(self.request.headers["Cookie"])
except:
self.clear_all_cookies()
return self._cookies
def get_cookie(self, name, default=None):
"""Gets the value of the cookie with the given name, else default."""
if name in self.cookies():
return self._cookies[name].value
return default
def set_cookie(self, name, value, domain=None, expires=None, path="/",
expires_days=None, **kwargs):
"""Sets the given cookie name/value with the given options.
Additional keyword arguments are set on the Cookie.Morsel
directly.
See http://docs.python.org/library/cookie.html#morsel-objects
for available attributes.
"""
name = LilCookies._utf8(name)
value = LilCookies._utf8(value)
if re.search(r"[\x00-\x20]", name + value):
# Don't let us accidentally inject bad stuff
raise ValueError("Invalid cookie %r: %r" % (name, value))
if not hasattr(self, "_new_cookies"):
self._new_cookies = []
new_cookie = Cookie.BaseCookie()
self._new_cookies.append(new_cookie)
new_cookie[name] = value
if domain:
new_cookie[name]["domain"] = domain
if expires_days is not None and not expires:
expires = datetime.datetime.utcnow() + datetime.timedelta(days=expires_days)
if expires:
timestamp = calendar.timegm(expires.utctimetuple())
new_cookie[name]["expires"] = email.utils.formatdate(
timestamp, localtime=False, usegmt=True)
if path:
new_cookie[name]["path"] = path
for k, v in kwargs.iteritems():
new_cookie[name][k] = v
# The 2 lines below were not in Tornado. Instead, they output all their cookies to the headers at once before a response flush.
for vals in new_cookie.values():
self.response.headers._headers.append(('Set-Cookie', vals.OutputString(None)))
def clear_cookie(self, name, path="/", domain=None):
"""Deletes the cookie with the given name."""
expires = datetime.datetime.utcnow() - datetime.timedelta(days=365)
self.set_cookie(name, value="", path=path, expires=expires,
domain=domain)
def clear_all_cookies(self):
"""Deletes all the cookies the user sent with this request."""
for name in self.cookies().iterkeys():
self.clear_cookie(name)
def set_secure_cookie(self, name, value, expires_days=30, **kwargs):
"""Signs and timestamps a cookie so it cannot be forged.
To read a cookie set with this method, use get_secure_cookie().
"""
value = LilCookies._signed_cookie_value(self.cookie_secret, name, value)
self.set_cookie(name, value, expires_days=expires_days, **kwargs)
def get_secure_cookie(self, name, value=None):
"""Returns the given signed cookie if it validates, or None."""
if value is None: value = self.get_cookie(name)
return LilCookies._verified_cookie_value(self.cookie_secret, name, value)
def _cookie_signature(self, *parts):
return LilCookies._signature_from_secret(self.cookie_secret)
| Python |
# Copyright (C) 2007 Joe Gregorio
#
# Licensed under the MIT License
"""MIME-Type Parser
This module provides basic functions for handling mime-types. It can handle
matching mime-types against a list of media-ranges. See section 14.1 of the
HTTP specification [RFC 2616] for a complete explanation.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
Contents:
- parse_mime_type(): Parses a mime-type into its component parts.
- parse_media_range(): Media-ranges are mime-types with wild-cards and a 'q'
quality parameter.
- quality(): Determines the quality ('q') of a mime-type when
compared against a list of media-ranges.
- quality_parsed(): Just like quality() except the second parameter must be
pre-parsed.
- best_match(): Choose the mime-type with the highest quality ('q')
from a list of candidates.
"""
__version__ = '0.1.3'
__author__ = 'Joe Gregorio'
__email__ = 'joe@bitworking.org'
__license__ = 'MIT License'
__credits__ = ''
def parse_mime_type(mime_type):
"""Parses a mime-type into its component parts.
Carves up a mime-type and returns a tuple of the (type, subtype, params)
where 'params' is a dictionary of all the parameters for the media range.
For example, the media range 'application/xhtml;q=0.5' would get parsed
into:
('application', 'xhtml', {'q', '0.5'})
"""
parts = mime_type.split(';')
params = dict([tuple([s.strip() for s in param.split('=', 1)])\
for param in parts[1:]
])
full_type = parts[0].strip()
# Java URLConnection class sends an Accept header that includes a
# single '*'. Turn it into a legal wildcard.
if full_type == '*':
full_type = '*/*'
(type, subtype) = full_type.split('/')
return (type.strip(), subtype.strip(), params)
def parse_media_range(range):
"""Parse a media-range into its component parts.
Carves up a media range and returns a tuple of the (type, subtype,
params) where 'params' is a dictionary of all the parameters for the media
range. For example, the media range 'application/*;q=0.5' would get parsed
into:
('application', '*', {'q', '0.5'})
In addition this function also guarantees that there is a value for 'q'
in the params dictionary, filling it in with a proper default if
necessary.
"""
(type, subtype, params) = parse_mime_type(range)
if not params.has_key('q') or not params['q'] or \
not float(params['q']) or float(params['q']) > 1\
or float(params['q']) < 0:
params['q'] = '1'
return (type, subtype, params)
def fitness_and_quality_parsed(mime_type, parsed_ranges):
"""Find the best match for a mime-type amongst parsed media-ranges.
Find the best match for a given mime-type against a list of media_ranges
that have already been parsed by parse_media_range(). Returns a tuple of
the fitness value and the value of the 'q' quality parameter of the best
match, or (-1, 0) if no match was found. Just as for quality_parsed(),
'parsed_ranges' must be a list of parsed media ranges.
"""
best_fitness = -1
best_fit_q = 0
(target_type, target_subtype, target_params) =\
parse_media_range(mime_type)
for (type, subtype, params) in parsed_ranges:
type_match = (type == target_type or\
type == '*' or\
target_type == '*')
subtype_match = (subtype == target_subtype or\
subtype == '*' or\
target_subtype == '*')
if type_match and subtype_match:
param_matches = reduce(lambda x, y: x + y, [1 for (key, value) in \
target_params.iteritems() if key != 'q' and \
params.has_key(key) and value == params[key]], 0)
fitness = (type == target_type) and 100 or 0
fitness += (subtype == target_subtype) and 10 or 0
fitness += param_matches
if fitness > best_fitness:
best_fitness = fitness
best_fit_q = params['q']
return best_fitness, float(best_fit_q)
def quality_parsed(mime_type, parsed_ranges):
"""Find the best match for a mime-type amongst parsed media-ranges.
Find the best match for a given mime-type against a list of media_ranges
that have already been parsed by parse_media_range(). Returns the 'q'
quality parameter of the best match, 0 if no match was found. This function
bahaves the same as quality() except that 'parsed_ranges' must be a list of
parsed media ranges.
"""
return fitness_and_quality_parsed(mime_type, parsed_ranges)[1]
def quality(mime_type, ranges):
"""Return the quality ('q') of a mime-type against a list of media-ranges.
Returns the quality 'q' of a mime-type when compared against the
media-ranges in ranges. For example:
>>> quality('text/html','text/*;q=0.3, text/html;q=0.7,
text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5')
0.7
"""
parsed_ranges = [parse_media_range(r) for r in ranges.split(',')]
return quality_parsed(mime_type, parsed_ranges)
def best_match(supported, header):
"""Return mime-type with the highest quality ('q') from list of candidates.
Takes a list of supported mime-types and finds the best match for all the
media-ranges listed in header. The value of header must be a string that
conforms to the format of the HTTP Accept: header. The value of 'supported'
is a list of mime-types. The list of supported mime-types should be sorted
in order of increasing desirability, in case of a situation where there is
a tie.
>>> best_match(['application/xbel+xml', 'text/xml'],
'text/*;q=0.5,*/*; q=0.1')
'text/xml'
"""
split_header = _filter_blank(header.split(','))
parsed_header = [parse_media_range(r) for r in split_header]
weighted_matches = []
pos = 0
for mime_type in supported:
weighted_matches.append((fitness_and_quality_parsed(mime_type,
parsed_header), pos, mime_type))
pos += 1
weighted_matches.sort()
return weighted_matches[-1][0][1] and weighted_matches[-1][2] or ''
def _filter_blank(i):
for s in i:
if s.strip():
yield s
| Python |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Classes to encapsulate a single HTTP request.
The classes implement a command pattern, with every
object supporting an execute() method that does the
actuall HTTP request.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import StringIO
import base64
import copy
import gzip
import httplib2
import mimeparse
import mimetypes
import os
import urllib
import urlparse
import uuid
from email.generator import Generator
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
from email.parser import FeedParser
from errors import BatchError
from errors import HttpError
from errors import ResumableUploadError
from errors import UnexpectedBodyError
from errors import UnexpectedMethodError
from model import JsonModel
from oauth2client.anyjson import simplejson
DEFAULT_CHUNK_SIZE = 512*1024
class MediaUploadProgress(object):
"""Status of a resumable upload."""
def __init__(self, resumable_progress, total_size):
"""Constructor.
Args:
resumable_progress: int, bytes sent so far.
total_size: int, total bytes in complete upload, or None if the total
upload size isn't known ahead of time.
"""
self.resumable_progress = resumable_progress
self.total_size = total_size
def progress(self):
"""Percent of upload completed, as a float.
Returns:
the percentage complete as a float, returning 0.0 if the total size of
the upload is unknown.
"""
if self.total_size is not None:
return float(self.resumable_progress) / float(self.total_size)
else:
return 0.0
class MediaDownloadProgress(object):
"""Status of a resumable download."""
def __init__(self, resumable_progress, total_size):
"""Constructor.
Args:
resumable_progress: int, bytes received so far.
total_size: int, total bytes in complete download.
"""
self.resumable_progress = resumable_progress
self.total_size = total_size
def progress(self):
"""Percent of download completed, as a float.
Returns:
the percentage complete as a float, returning 0.0 if the total size of
the download is unknown.
"""
if self.total_size is not None:
return float(self.resumable_progress) / float(self.total_size)
else:
return 0.0
class MediaUpload(object):
"""Describes a media object to upload.
Base class that defines the interface of MediaUpload subclasses.
Note that subclasses of MediaUpload may allow you to control the chunksize
when upload a media object. It is important to keep the size of the chunk as
large as possible to keep the upload efficient. Other factors may influence
the size of the chunk you use, particularly if you are working in an
environment where individual HTTP requests may have a hardcoded time limit,
such as under certain classes of requests under Google App Engine.
"""
def chunksize(self):
"""Chunk size for resumable uploads.
Returns:
Chunk size in bytes.
"""
raise NotImplementedError()
def mimetype(self):
"""Mime type of the body.
Returns:
Mime type.
"""
return 'application/octet-stream'
def size(self):
"""Size of upload.
Returns:
Size of the body, or None of the size is unknown.
"""
return None
def resumable(self):
"""Whether this upload is resumable.
Returns:
True if resumable upload or False.
"""
return False
def getbytes(self, begin, end):
"""Get bytes from the media.
Args:
begin: int, offset from beginning of file.
length: int, number of bytes to read, starting at begin.
Returns:
A string of bytes read. May be shorter than length if EOF was reached
first.
"""
raise NotImplementedError()
def _to_json(self, strip=None):
"""Utility function for creating a JSON representation of a MediaUpload.
Args:
strip: array, An array of names of members to not include in the JSON.
Returns:
string, a JSON representation of this instance, suitable to pass to
from_json().
"""
t = type(self)
d = copy.copy(self.__dict__)
if strip is not None:
for member in strip:
del d[member]
d['_class'] = t.__name__
d['_module'] = t.__module__
return simplejson.dumps(d)
def to_json(self):
"""Create a JSON representation of an instance of MediaUpload.
Returns:
string, a JSON representation of this instance, suitable to pass to
from_json().
"""
return self._to_json()
@classmethod
def new_from_json(cls, s):
"""Utility class method to instantiate a MediaUpload subclass from a JSON
representation produced by to_json().
Args:
s: string, JSON from to_json().
Returns:
An instance of the subclass of MediaUpload that was serialized with
to_json().
"""
data = simplejson.loads(s)
# Find and call the right classmethod from_json() to restore the object.
module = data['_module']
m = __import__(module, fromlist=module.split('.')[:-1])
kls = getattr(m, data['_class'])
from_json = getattr(kls, 'from_json')
return from_json(s)
class MediaFileUpload(MediaUpload):
"""A MediaUpload for a file.
Construct a MediaFileUpload and pass as the media_body parameter of the
method. For example, if we had a service that allowed uploading images:
media = MediaFileUpload('cow.png', mimetype='image/png',
chunksize=1024*1024, resumable=True)
farm.animals()..insert(
id='cow',
name='cow.png',
media_body=media).execute()
"""
def __init__(self, filename, mimetype=None, chunksize=DEFAULT_CHUNK_SIZE, resumable=False):
"""Constructor.
Args:
filename: string, Name of the file.
mimetype: string, Mime-type of the file. If None then a mime-type will be
guessed from the file extension.
chunksize: int, File will be uploaded in chunks of this many bytes. Only
used if resumable=True.
resumable: bool, True if this is a resumable upload. False means upload
in a single request.
"""
self._filename = filename
self._size = os.path.getsize(filename)
self._fd = None
if mimetype is None:
(mimetype, encoding) = mimetypes.guess_type(filename)
self._mimetype = mimetype
self._chunksize = chunksize
self._resumable = resumable
def chunksize(self):
"""Chunk size for resumable uploads.
Returns:
Chunk size in bytes.
"""
return self._chunksize
def mimetype(self):
"""Mime type of the body.
Returns:
Mime type.
"""
return self._mimetype
def size(self):
"""Size of upload.
Returns:
Size of the body, or None of the size is unknown.
"""
return self._size
def resumable(self):
"""Whether this upload is resumable.
Returns:
True if resumable upload or False.
"""
return self._resumable
def getbytes(self, begin, length):
"""Get bytes from the media.
Args:
begin: int, offset from beginning of file.
length: int, number of bytes to read, starting at begin.
Returns:
A string of bytes read. May be shorted than length if EOF was reached
first.
"""
if self._fd is None:
self._fd = open(self._filename, 'rb')
self._fd.seek(begin)
return self._fd.read(length)
def to_json(self):
"""Creating a JSON representation of an instance of MediaFileUpload.
Returns:
string, a JSON representation of this instance, suitable to pass to
from_json().
"""
return self._to_json(['_fd'])
@staticmethod
def from_json(s):
d = simplejson.loads(s)
return MediaFileUpload(
d['_filename'], d['_mimetype'], d['_chunksize'], d['_resumable'])
class MediaIoBaseUpload(MediaUpload):
"""A MediaUpload for a io.Base objects.
Note that the Python file object is compatible with io.Base and can be used
with this class also.
fh = io.BytesIO('...Some data to upload...')
media = MediaIoBaseUpload(fh, mimetype='image/png',
chunksize=1024*1024, resumable=True)
farm.animals().insert(
id='cow',
name='cow.png',
media_body=media).execute()
"""
def __init__(self, fh, mimetype, chunksize=DEFAULT_CHUNK_SIZE,
resumable=False):
"""Constructor.
Args:
fh: io.Base or file object, The source of the bytes to upload. MUST be
opened in blocking mode, do not use streams opened in non-blocking mode.
mimetype: string, Mime-type of the file. If None then a mime-type will be
guessed from the file extension.
chunksize: int, File will be uploaded in chunks of this many bytes. Only
used if resumable=True.
resumable: bool, True if this is a resumable upload. False means upload
in a single request.
"""
self._fh = fh
self._mimetype = mimetype
self._chunksize = chunksize
self._resumable = resumable
self._size = None
try:
if hasattr(self._fh, 'fileno'):
fileno = self._fh.fileno()
# Pipes and such show up as 0 length files.
size = os.fstat(fileno).st_size
if size:
self._size = os.fstat(fileno).st_size
except IOError:
pass
def chunksize(self):
"""Chunk size for resumable uploads.
Returns:
Chunk size in bytes.
"""
return self._chunksize
def mimetype(self):
"""Mime type of the body.
Returns:
Mime type.
"""
return self._mimetype
def size(self):
"""Size of upload.
Returns:
Size of the body, or None of the size is unknown.
"""
return self._size
def resumable(self):
"""Whether this upload is resumable.
Returns:
True if resumable upload or False.
"""
return self._resumable
def getbytes(self, begin, length):
"""Get bytes from the media.
Args:
begin: int, offset from beginning of file.
length: int, number of bytes to read, starting at begin.
Returns:
A string of bytes read. May be shorted than length if EOF was reached
first.
"""
self._fh.seek(begin)
return self._fh.read(length)
def to_json(self):
"""This upload type is not serializable."""
raise NotImplementedError('MediaIoBaseUpload is not serializable.')
class MediaInMemoryUpload(MediaUpload):
"""MediaUpload for a chunk of bytes.
Construct a MediaFileUpload and pass as the media_body parameter of the
method.
"""
def __init__(self, body, mimetype='application/octet-stream',
chunksize=DEFAULT_CHUNK_SIZE, resumable=False):
"""Create a new MediaBytesUpload.
Args:
body: string, Bytes of body content.
mimetype: string, Mime-type of the file or default of
'application/octet-stream'.
chunksize: int, File will be uploaded in chunks of this many bytes. Only
used if resumable=True.
resumable: bool, True if this is a resumable upload. False means upload
in a single request.
"""
self._body = body
self._mimetype = mimetype
self._resumable = resumable
self._chunksize = chunksize
def chunksize(self):
"""Chunk size for resumable uploads.
Returns:
Chunk size in bytes.
"""
return self._chunksize
def mimetype(self):
"""Mime type of the body.
Returns:
Mime type.
"""
return self._mimetype
def size(self):
"""Size of upload.
Returns:
Size of the body, or None of the size is unknown.
"""
return len(self._body)
def resumable(self):
"""Whether this upload is resumable.
Returns:
True if resumable upload or False.
"""
return self._resumable
def getbytes(self, begin, length):
"""Get bytes from the media.
Args:
begin: int, offset from beginning of file.
length: int, number of bytes to read, starting at begin.
Returns:
A string of bytes read. May be shorter than length if EOF was reached
first.
"""
return self._body[begin:begin + length]
def to_json(self):
"""Create a JSON representation of a MediaInMemoryUpload.
Returns:
string, a JSON representation of this instance, suitable to pass to
from_json().
"""
t = type(self)
d = copy.copy(self.__dict__)
del d['_body']
d['_class'] = t.__name__
d['_module'] = t.__module__
d['_b64body'] = base64.b64encode(self._body)
return simplejson.dumps(d)
@staticmethod
def from_json(s):
d = simplejson.loads(s)
return MediaInMemoryUpload(base64.b64decode(d['_b64body']),
d['_mimetype'], d['_chunksize'],
d['_resumable'])
class MediaIoBaseDownload(object):
""""Download media resources.
Note that the Python file object is compatible with io.Base and can be used
with this class also.
Example:
request = farms.animals().get_media(id='cow')
fh = io.FileIO('cow.png', mode='wb')
downloader = MediaIoBaseDownload(fh, request, chunksize=1024*1024)
done = False
while done is False:
status, done = downloader.next_chunk()
if status:
print "Download %d%%." % int(status.progress() * 100)
print "Download Complete!"
"""
def __init__(self, fh, request, chunksize=DEFAULT_CHUNK_SIZE):
"""Constructor.
Args:
fh: io.Base or file object, The stream in which to write the downloaded
bytes.
request: apiclient.http.HttpRequest, the media request to perform in
chunks.
chunksize: int, File will be downloaded in chunks of this many bytes.
"""
self.fh_ = fh
self.request_ = request
self.uri_ = request.uri
self.chunksize_ = chunksize
self.progress_ = 0
self.total_size_ = None
self.done_ = False
def next_chunk(self):
"""Get the next chunk of the download.
Returns:
(status, done): (MediaDownloadStatus, boolean)
The value of 'done' will be True when the media has been fully
downloaded.
Raises:
apiclient.errors.HttpError if the response was not a 2xx.
httplib2.Error if a transport error has occured.
"""
headers = {
'range': 'bytes=%d-%d' % (
self.progress_, self.progress_ + self.chunksize_)
}
http = self.request_.http
http.follow_redirects = False
resp, content = http.request(self.uri_, headers=headers)
if resp.status in [301, 302, 303, 307, 308] and 'location' in resp:
self.uri_ = resp['location']
resp, content = http.request(self.uri_, headers=headers)
if resp.status in [200, 206]:
self.progress_ += len(content)
self.fh_.write(content)
if 'content-range' in resp:
content_range = resp['content-range']
length = content_range.rsplit('/', 1)[1]
self.total_size_ = int(length)
if self.progress_ == self.total_size_:
self.done_ = True
return MediaDownloadProgress(self.progress_, self.total_size_), self.done_
else:
raise HttpError(resp, content, self.uri_)
class HttpRequest(object):
"""Encapsulates a single HTTP request."""
def __init__(self, http, postproc, uri,
method='GET',
body=None,
headers=None,
methodId=None,
resumable=None):
"""Constructor for an HttpRequest.
Args:
http: httplib2.Http, the transport object to use to make a request
postproc: callable, called on the HTTP response and content to transform
it into a data object before returning, or raising an exception
on an error.
uri: string, the absolute URI to send the request to
method: string, the HTTP method to use
body: string, the request body of the HTTP request,
headers: dict, the HTTP request headers
methodId: string, a unique identifier for the API method being called.
resumable: MediaUpload, None if this is not a resumbale request.
"""
self.uri = uri
self.method = method
self.body = body
self.headers = headers or {}
self.methodId = methodId
self.http = http
self.postproc = postproc
self.resumable = resumable
self._in_error_state = False
# Pull the multipart boundary out of the content-type header.
major, minor, params = mimeparse.parse_mime_type(
headers.get('content-type', 'application/json'))
# The size of the non-media part of the request.
self.body_size = len(self.body or '')
# The resumable URI to send chunks to.
self.resumable_uri = None
# The bytes that have been uploaded.
self.resumable_progress = 0
def execute(self, http=None):
"""Execute the request.
Args:
http: httplib2.Http, an http object to be used in place of the
one the HttpRequest request object was constructed with.
Returns:
A deserialized object model of the response body as determined
by the postproc.
Raises:
apiclient.errors.HttpError if the response was not a 2xx.
httplib2.Error if a transport error has occured.
"""
if http is None:
http = self.http
if self.resumable:
body = None
while body is None:
_, body = self.next_chunk(http)
return body
else:
if 'content-length' not in self.headers:
self.headers['content-length'] = str(self.body_size)
resp, content = http.request(self.uri, self.method,
body=self.body,
headers=self.headers)
if resp.status >= 300:
raise HttpError(resp, content, self.uri)
return self.postproc(resp, content)
def next_chunk(self, http=None):
"""Execute the next step of a resumable upload.
Can only be used if the method being executed supports media uploads and
the MediaUpload object passed in was flagged as using resumable upload.
Example:
media = MediaFileUpload('cow.png', mimetype='image/png',
chunksize=1000, resumable=True)
request = farm.animals().insert(
id='cow',
name='cow.png',
media_body=media)
response = None
while response is None:
status, response = request.next_chunk()
if status:
print "Upload %d%% complete." % int(status.progress() * 100)
Returns:
(status, body): (ResumableMediaStatus, object)
The body will be None until the resumable media is fully uploaded.
Raises:
apiclient.errors.HttpError if the response was not a 2xx.
httplib2.Error if a transport error has occured.
"""
if http is None:
http = self.http
if self.resumable.size() is None:
size = '*'
else:
size = str(self.resumable.size())
if self.resumable_uri is None:
start_headers = copy.copy(self.headers)
start_headers['X-Upload-Content-Type'] = self.resumable.mimetype()
if size != '*':
start_headers['X-Upload-Content-Length'] = size
start_headers['content-length'] = str(self.body_size)
resp, content = http.request(self.uri, self.method,
body=self.body,
headers=start_headers)
if resp.status == 200 and 'location' in resp:
self.resumable_uri = resp['location']
else:
raise ResumableUploadError("Failed to retrieve starting URI.")
elif self._in_error_state:
# If we are in an error state then query the server for current state of
# the upload by sending an empty PUT and reading the 'range' header in
# the response.
headers = {
'Content-Range': 'bytes */%s' % size,
'content-length': '0'
}
resp, content = http.request(self.resumable_uri, 'PUT',
headers=headers)
status, body = self._process_response(resp, content)
if body:
# The upload was complete.
return (status, body)
data = self.resumable.getbytes(
self.resumable_progress, self.resumable.chunksize())
# A short read implies that we are at EOF, so finish the upload.
if len(data) < self.resumable.chunksize():
size = str(self.resumable_progress + len(data))
headers = {
'Content-Range': 'bytes %d-%d/%s' % (
self.resumable_progress, self.resumable_progress + len(data) - 1,
size)
}
try:
resp, content = http.request(self.resumable_uri, 'PUT',
body=data,
headers=headers)
except:
self._in_error_state = True
raise
return self._process_response(resp, content)
def _process_response(self, resp, content):
"""Process the response from a single chunk upload.
Args:
resp: httplib2.Response, the response object.
content: string, the content of the response.
Returns:
(status, body): (ResumableMediaStatus, object)
The body will be None until the resumable media is fully uploaded.
Raises:
apiclient.errors.HttpError if the response was not a 2xx or a 308.
"""
if resp.status in [200, 201]:
self._in_error_state = False
return None, self.postproc(resp, content)
elif resp.status == 308:
self._in_error_state = False
# A "308 Resume Incomplete" indicates we are not done.
self.resumable_progress = int(resp['range'].split('-')[1]) + 1
if 'location' in resp:
self.resumable_uri = resp['location']
else:
self._in_error_state = True
raise HttpError(resp, content, self.uri)
return (MediaUploadProgress(self.resumable_progress, self.resumable.size()),
None)
def to_json(self):
"""Returns a JSON representation of the HttpRequest."""
d = copy.copy(self.__dict__)
if d['resumable'] is not None:
d['resumable'] = self.resumable.to_json()
del d['http']
del d['postproc']
return simplejson.dumps(d)
@staticmethod
def from_json(s, http, postproc):
"""Returns an HttpRequest populated with info from a JSON object."""
d = simplejson.loads(s)
if d['resumable'] is not None:
d['resumable'] = MediaUpload.new_from_json(d['resumable'])
return HttpRequest(
http,
postproc,
uri=d['uri'],
method=d['method'],
body=d['body'],
headers=d['headers'],
methodId=d['methodId'],
resumable=d['resumable'])
class BatchHttpRequest(object):
"""Batches multiple HttpRequest objects into a single HTTP request.
Example:
from apiclient.http import BatchHttpRequest
def list_animals(request_id, response):
\"\"\"Do something with the animals list response.\"\"\"
pass
def list_farmers(request_id, response):
\"\"\"Do something with the farmers list response.\"\"\"
pass
service = build('farm', 'v2')
batch = BatchHttpRequest()
batch.add(service.animals().list(), list_animals)
batch.add(service.farmers().list(), list_farmers)
batch.execute(http)
"""
def __init__(self, callback=None, batch_uri=None):
"""Constructor for a BatchHttpRequest.
Args:
callback: callable, A callback to be called for each response, of the
form callback(id, response). The first parameter is the request id, and
the second is the deserialized response object.
batch_uri: string, URI to send batch requests to.
"""
if batch_uri is None:
batch_uri = 'https://www.googleapis.com/batch'
self._batch_uri = batch_uri
# Global callback to be called for each individual response in the batch.
self._callback = callback
# A map from id to request.
self._requests = {}
# A map from id to callback.
self._callbacks = {}
# List of request ids, in the order in which they were added.
self._order = []
# The last auto generated id.
self._last_auto_id = 0
# Unique ID on which to base the Content-ID headers.
self._base_id = None
# A map from request id to (headers, content) response pairs
self._responses = {}
# A map of id(Credentials) that have been refreshed.
self._refreshed_credentials = {}
def _refresh_and_apply_credentials(self, request, http):
"""Refresh the credentials and apply to the request.
Args:
request: HttpRequest, the request.
http: httplib2.Http, the global http object for the batch.
"""
# For the credentials to refresh, but only once per refresh_token
# If there is no http per the request then refresh the http passed in
# via execute()
creds = None
if request.http is not None and hasattr(request.http.request,
'credentials'):
creds = request.http.request.credentials
elif http is not None and hasattr(http.request, 'credentials'):
creds = http.request.credentials
if creds is not None:
if id(creds) not in self._refreshed_credentials:
creds.refresh(http)
self._refreshed_credentials[id(creds)] = 1
# Only apply the credentials if we are using the http object passed in,
# otherwise apply() will get called during _serialize_request().
if request.http is None or not hasattr(request.http.request,
'credentials'):
creds.apply(request.headers)
def _id_to_header(self, id_):
"""Convert an id to a Content-ID header value.
Args:
id_: string, identifier of individual request.
Returns:
A Content-ID header with the id_ encoded into it. A UUID is prepended to
the value because Content-ID headers are supposed to be universally
unique.
"""
if self._base_id is None:
self._base_id = uuid.uuid4()
return '<%s+%s>' % (self._base_id, urllib.quote(id_))
def _header_to_id(self, header):
"""Convert a Content-ID header value to an id.
Presumes the Content-ID header conforms to the format that _id_to_header()
returns.
Args:
header: string, Content-ID header value.
Returns:
The extracted id value.
Raises:
BatchError if the header is not in the expected format.
"""
if header[0] != '<' or header[-1] != '>':
raise BatchError("Invalid value for Content-ID: %s" % header)
if '+' not in header:
raise BatchError("Invalid value for Content-ID: %s" % header)
base, id_ = header[1:-1].rsplit('+', 1)
return urllib.unquote(id_)
def _serialize_request(self, request):
"""Convert an HttpRequest object into a string.
Args:
request: HttpRequest, the request to serialize.
Returns:
The request as a string in application/http format.
"""
# Construct status line
parsed = urlparse.urlparse(request.uri)
request_line = urlparse.urlunparse(
(None, None, parsed.path, parsed.params, parsed.query, None)
)
status_line = request.method + ' ' + request_line + ' HTTP/1.1\n'
major, minor = request.headers.get('content-type', 'application/json').split('/')
msg = MIMENonMultipart(major, minor)
headers = request.headers.copy()
if request.http is not None and hasattr(request.http.request,
'credentials'):
request.http.request.credentials.apply(headers)
# MIMENonMultipart adds its own Content-Type header.
if 'content-type' in headers:
del headers['content-type']
for key, value in headers.iteritems():
msg[key] = value
msg['Host'] = parsed.netloc
msg.set_unixfrom(None)
if request.body is not None:
msg.set_payload(request.body)
msg['content-length'] = str(len(request.body))
# Serialize the mime message.
fp = StringIO.StringIO()
# maxheaderlen=0 means don't line wrap headers.
g = Generator(fp, maxheaderlen=0)
g.flatten(msg, unixfrom=False)
body = fp.getvalue()
# Strip off the \n\n that the MIME lib tacks onto the end of the payload.
if request.body is None:
body = body[:-2]
return status_line.encode('utf-8') + body
def _deserialize_response(self, payload):
"""Convert string into httplib2 response and content.
Args:
payload: string, headers and body as a string.
Returns:
A pair (resp, content) like would be returned from httplib2.request.
"""
# Strip off the status line
status_line, payload = payload.split('\n', 1)
protocol, status, reason = status_line.split(' ', 2)
# Parse the rest of the response
parser = FeedParser()
parser.feed(payload)
msg = parser.close()
msg['status'] = status
# Create httplib2.Response from the parsed headers.
resp = httplib2.Response(msg)
resp.reason = reason
resp.version = int(protocol.split('/', 1)[1].replace('.', ''))
content = payload.split('\r\n\r\n', 1)[1]
return resp, content
def _new_id(self):
"""Create a new id.
Auto incrementing number that avoids conflicts with ids already used.
Returns:
string, a new unique id.
"""
self._last_auto_id += 1
while str(self._last_auto_id) in self._requests:
self._last_auto_id += 1
return str(self._last_auto_id)
def add(self, request, callback=None, request_id=None):
"""Add a new request.
Every callback added will be paired with a unique id, the request_id. That
unique id will be passed back to the callback when the response comes back
from the server. The default behavior is to have the library generate it's
own unique id. If the caller passes in a request_id then they must ensure
uniqueness for each request_id, and if they are not an exception is
raised. Callers should either supply all request_ids or nevery supply a
request id, to avoid such an error.
Args:
request: HttpRequest, Request to add to the batch.
callback: callable, A callback to be called for this response, of the
form callback(id, response). The first parameter is the request id, and
the second is the deserialized response object.
request_id: string, A unique id for the request. The id will be passed to
the callback with the response.
Returns:
None
Raises:
BatchError if a media request is added to a batch.
KeyError is the request_id is not unique.
"""
if request_id is None:
request_id = self._new_id()
if request.resumable is not None:
raise BatchError("Media requests cannot be used in a batch request.")
if request_id in self._requests:
raise KeyError("A request with this ID already exists: %s" % request_id)
self._requests[request_id] = request
self._callbacks[request_id] = callback
self._order.append(request_id)
def _execute(self, http, order, requests):
"""Serialize batch request, send to server, process response.
Args:
http: httplib2.Http, an http object to be used to make the request with.
order: list, list of request ids in the order they were added to the
batch.
request: list, list of request objects to send.
Raises:
httplib2.Error if a transport error has occured.
apiclient.errors.BatchError if the response is the wrong format.
"""
message = MIMEMultipart('mixed')
# Message should not write out it's own headers.
setattr(message, '_write_headers', lambda self: None)
# Add all the individual requests.
for request_id in order:
request = requests[request_id]
msg = MIMENonMultipart('application', 'http')
msg['Content-Transfer-Encoding'] = 'binary'
msg['Content-ID'] = self._id_to_header(request_id)
body = self._serialize_request(request)
msg.set_payload(body)
message.attach(msg)
body = message.as_string()
headers = {}
headers['content-type'] = ('multipart/mixed; '
'boundary="%s"') % message.get_boundary()
resp, content = http.request(self._batch_uri, 'POST', body=body,
headers=headers)
if resp.status >= 300:
raise HttpError(resp, content, self._batch_uri)
# Now break out the individual responses and store each one.
boundary, _ = content.split(None, 1)
# Prepend with a content-type header so FeedParser can handle it.
header = 'content-type: %s\r\n\r\n' % resp['content-type']
for_parser = header + content
parser = FeedParser()
parser.feed(for_parser)
mime_response = parser.close()
if not mime_response.is_multipart():
raise BatchError("Response not in multipart/mixed format.", resp,
content)
for part in mime_response.get_payload():
request_id = self._header_to_id(part['Content-ID'])
headers, content = self._deserialize_response(part.get_payload())
self._responses[request_id] = (headers, content)
def execute(self, http=None):
"""Execute all the requests as a single batched HTTP request.
Args:
http: httplib2.Http, an http object to be used in place of the one the
HttpRequest request object was constructed with. If one isn't supplied
then use a http object from the requests in this batch.
Returns:
None
Raises:
httplib2.Error if a transport error has occured.
apiclient.errors.BatchError if the response is the wrong format.
"""
# If http is not supplied use the first valid one given in the requests.
if http is None:
for request_id in self._order:
request = self._requests[request_id]
if request is not None:
http = request.http
break
if http is None:
raise ValueError("Missing a valid http object.")
self._execute(http, self._order, self._requests)
# Loop over all the requests and check for 401s. For each 401 request the
# credentials should be refreshed and then sent again in a separate batch.
redo_requests = {}
redo_order = []
for request_id in self._order:
headers, content = self._responses[request_id]
if headers['status'] == '401':
redo_order.append(request_id)
request = self._requests[request_id]
self._refresh_and_apply_credentials(request, http)
redo_requests[request_id] = request
if redo_requests:
self._execute(http, redo_order, redo_requests)
# Now process all callbacks that are erroring, and raise an exception for
# ones that return a non-2xx response? Or add extra parameter to callback
# that contains an HttpError?
for request_id in self._order:
headers, content = self._responses[request_id]
request = self._requests[request_id]
callback = self._callbacks[request_id]
response = None
exception = None
try:
r = httplib2.Response(headers)
response = request.postproc(r, content)
except HttpError, e:
exception = e
if callback is not None:
callback(request_id, response, exception)
if self._callback is not None:
self._callback(request_id, response, exception)
class HttpRequestMock(object):
"""Mock of HttpRequest.
Do not construct directly, instead use RequestMockBuilder.
"""
def __init__(self, resp, content, postproc):
"""Constructor for HttpRequestMock
Args:
resp: httplib2.Response, the response to emulate coming from the request
content: string, the response body
postproc: callable, the post processing function usually supplied by
the model class. See model.JsonModel.response() as an example.
"""
self.resp = resp
self.content = content
self.postproc = postproc
if resp is None:
self.resp = httplib2.Response({'status': 200, 'reason': 'OK'})
if 'reason' in self.resp:
self.resp.reason = self.resp['reason']
def execute(self, http=None):
"""Execute the request.
Same behavior as HttpRequest.execute(), but the response is
mocked and not really from an HTTP request/response.
"""
return self.postproc(self.resp, self.content)
class RequestMockBuilder(object):
"""A simple mock of HttpRequest
Pass in a dictionary to the constructor that maps request methodIds to
tuples of (httplib2.Response, content, opt_expected_body) that should be
returned when that method is called. None may also be passed in for the
httplib2.Response, in which case a 200 OK response will be generated.
If an opt_expected_body (str or dict) is provided, it will be compared to
the body and UnexpectedBodyError will be raised on inequality.
Example:
response = '{"data": {"id": "tag:google.c...'
requestBuilder = RequestMockBuilder(
{
'plus.activities.get': (None, response),
}
)
apiclient.discovery.build("plus", "v1", requestBuilder=requestBuilder)
Methods that you do not supply a response for will return a
200 OK with an empty string as the response content or raise an excpetion
if check_unexpected is set to True. The methodId is taken from the rpcName
in the discovery document.
For more details see the project wiki.
"""
def __init__(self, responses, check_unexpected=False):
"""Constructor for RequestMockBuilder
The constructed object should be a callable object
that can replace the class HttpResponse.
responses - A dictionary that maps methodIds into tuples
of (httplib2.Response, content). The methodId
comes from the 'rpcName' field in the discovery
document.
check_unexpected - A boolean setting whether or not UnexpectedMethodError
should be raised on unsupplied method.
"""
self.responses = responses
self.check_unexpected = check_unexpected
def __call__(self, http, postproc, uri, method='GET', body=None,
headers=None, methodId=None, resumable=None):
"""Implements the callable interface that discovery.build() expects
of requestBuilder, which is to build an object compatible with
HttpRequest.execute(). See that method for the description of the
parameters and the expected response.
"""
if methodId in self.responses:
response = self.responses[methodId]
resp, content = response[:2]
if len(response) > 2:
# Test the body against the supplied expected_body.
expected_body = response[2]
if bool(expected_body) != bool(body):
# Not expecting a body and provided one
# or expecting a body and not provided one.
raise UnexpectedBodyError(expected_body, body)
if isinstance(expected_body, str):
expected_body = simplejson.loads(expected_body)
body = simplejson.loads(body)
if body != expected_body:
raise UnexpectedBodyError(expected_body, body)
return HttpRequestMock(resp, content, postproc)
elif self.check_unexpected:
raise UnexpectedMethodError(methodId)
else:
model = JsonModel(False)
return HttpRequestMock(None, '{}', model.response)
class HttpMock(object):
"""Mock of httplib2.Http"""
def __init__(self, filename, headers=None):
"""
Args:
filename: string, absolute filename to read response from
headers: dict, header to return with response
"""
if headers is None:
headers = {'status': '200 OK'}
f = file(filename, 'r')
self.data = f.read()
f.close()
self.headers = headers
def request(self, uri,
method='GET',
body=None,
headers=None,
redirections=1,
connection_type=None):
return httplib2.Response(self.headers), self.data
class HttpMockSequence(object):
"""Mock of httplib2.Http
Mocks a sequence of calls to request returning different responses for each
call. Create an instance initialized with the desired response headers
and content and then use as if an httplib2.Http instance.
http = HttpMockSequence([
({'status': '401'}, ''),
({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),
({'status': '200'}, 'echo_request_headers'),
])
resp, content = http.request("http://examples.com")
There are special values you can pass in for content to trigger
behavours that are helpful in testing.
'echo_request_headers' means return the request headers in the response body
'echo_request_headers_as_json' means return the request headers in
the response body
'echo_request_body' means return the request body in the response body
'echo_request_uri' means return the request uri in the response body
"""
def __init__(self, iterable):
"""
Args:
iterable: iterable, a sequence of pairs of (headers, body)
"""
self._iterable = iterable
self.follow_redirects = True
def request(self, uri,
method='GET',
body=None,
headers=None,
redirections=1,
connection_type=None):
resp, content = self._iterable.pop(0)
if content == 'echo_request_headers':
content = headers
elif content == 'echo_request_headers_as_json':
content = simplejson.dumps(headers)
elif content == 'echo_request_body':
content = body
elif content == 'echo_request_uri':
content = uri
return httplib2.Response(resp), content
def set_user_agent(http, user_agent):
"""Set the user-agent on every request.
Args:
http - An instance of httplib2.Http
or something that acts like it.
user_agent: string, the value for the user-agent header.
Returns:
A modified instance of http that was passed in.
Example:
h = httplib2.Http()
h = set_user_agent(h, "my-app-name/6.0")
Most of the time the user-agent will be set doing auth, this is for the rare
cases where you are accessing an unauthenticated endpoint.
"""
request_orig = http.request
# The closure that will replace 'httplib2.Http.request'.
def new_request(uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
"""Modify the request headers to add the user-agent."""
if headers is None:
headers = {}
if 'user-agent' in headers:
headers['user-agent'] = user_agent + ' ' + headers['user-agent']
else:
headers['user-agent'] = user_agent
resp, content = request_orig(uri, method, body, headers,
redirections, connection_type)
return resp, content
http.request = new_request
return http
def tunnel_patch(http):
"""Tunnel PATCH requests over POST.
Args:
http - An instance of httplib2.Http
or something that acts like it.
Returns:
A modified instance of http that was passed in.
Example:
h = httplib2.Http()
h = tunnel_patch(h, "my-app-name/6.0")
Useful if you are running on a platform that doesn't support PATCH.
Apply this last if you are using OAuth 1.0, as changing the method
will result in a different signature.
"""
request_orig = http.request
# The closure that will replace 'httplib2.Http.request'.
def new_request(uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
"""Modify the request headers to add the user-agent."""
if headers is None:
headers = {}
if method == 'PATCH':
if 'oauth_token' in headers.get('authorization', ''):
logging.warning(
'OAuth 1.0 request made with Credentials after tunnel_patch.')
headers['x-http-method-override'] = "PATCH"
method = 'POST'
resp, content = request_orig(uri, method, body, headers,
redirections, connection_type)
return resp, content
http.request = new_request
return http
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for OAuth.
Utilities for making it easier to work with OAuth.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import copy
import httplib2
import logging
import oauth2 as oauth
import urllib
import urlparse
from anyjson import simplejson
try:
from urlparse import parse_qsl
except ImportError:
from cgi import parse_qsl
class Error(Exception):
"""Base error for this module."""
pass
class RequestError(Error):
"""Error occurred during request."""
pass
class MissingParameter(Error):
pass
class CredentialsInvalidError(Error):
pass
def _abstract():
raise NotImplementedError('You need to override this function')
def _oauth_uri(name, discovery, params):
"""Look up the OAuth URI from the discovery
document and add query parameters based on
params.
name - The name of the OAuth URI to lookup, one
of 'request', 'access', or 'authorize'.
discovery - Portion of discovery document the describes
the OAuth endpoints.
params - Dictionary that is used to form the query parameters
for the specified URI.
"""
if name not in ['request', 'access', 'authorize']:
raise KeyError(name)
keys = discovery[name]['parameters'].keys()
query = {}
for key in keys:
if key in params:
query[key] = params[key]
return discovery[name]['url'] + '?' + urllib.urlencode(query)
class Credentials(object):
"""Base class for all Credentials objects.
Subclasses must define an authorize() method
that applies the credentials to an HTTP transport.
"""
def authorize(self, http):
"""Take an httplib2.Http instance (or equivalent) and
authorizes it for the set of credentials, usually by
replacing http.request() with a method that adds in
the appropriate headers and then delegates to the original
Http.request() method.
"""
_abstract()
class Flow(object):
"""Base class for all Flow objects."""
pass
class Storage(object):
"""Base class for all Storage objects.
Store and retrieve a single credential.
"""
def get(self):
"""Retrieve credential.
Returns:
apiclient.oauth.Credentials
"""
_abstract()
def put(self, credentials):
"""Write a credential.
Args:
credentials: Credentials, the credentials to store.
"""
_abstract()
class OAuthCredentials(Credentials):
"""Credentials object for OAuth 1.0a
"""
def __init__(self, consumer, token, user_agent):
"""
consumer - An instance of oauth.Consumer.
token - An instance of oauth.Token constructed with
the access token and secret.
user_agent - The HTTP User-Agent to provide for this application.
"""
self.consumer = consumer
self.token = token
self.user_agent = user_agent
self.store = None
# True if the credentials have been revoked
self._invalid = False
@property
def invalid(self):
"""True if the credentials are invalid, such as being revoked."""
return getattr(self, "_invalid", False)
def set_store(self, store):
"""Set the storage for the credential.
Args:
store: callable, a callable that when passed a Credential
will store the credential back to where it came from.
This is needed to store the latest access_token if it
has been revoked.
"""
self.store = store
def __getstate__(self):
"""Trim the state down to something that can be pickled."""
d = copy.copy(self.__dict__)
del d['store']
return d
def __setstate__(self, state):
"""Reconstitute the state of the object from being pickled."""
self.__dict__.update(state)
self.store = None
def authorize(self, http):
"""Authorize an httplib2.Http instance with these Credentials
Args:
http - An instance of httplib2.Http
or something that acts like it.
Returns:
A modified instance of http that was passed in.
Example:
h = httplib2.Http()
h = credentials.authorize(h)
You can't create a new OAuth
subclass of httplib2.Authenication because
it never gets passed the absolute URI, which is
needed for signing. So instead we have to overload
'request' with a closure that adds in the
Authorization header and then calls the original version
of 'request()'.
"""
request_orig = http.request
signer = oauth.SignatureMethod_HMAC_SHA1()
# The closure that will replace 'httplib2.Http.request'.
def new_request(uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
"""Modify the request headers to add the appropriate
Authorization header."""
response_code = 302
http.follow_redirects = False
while response_code in [301, 302]:
req = oauth.Request.from_consumer_and_token(
self.consumer, self.token, http_method=method, http_url=uri)
req.sign_request(signer, self.consumer, self.token)
if headers is None:
headers = {}
headers.update(req.to_header())
if 'user-agent' in headers:
headers['user-agent'] = self.user_agent + ' ' + headers['user-agent']
else:
headers['user-agent'] = self.user_agent
resp, content = request_orig(uri, method, body, headers,
redirections, connection_type)
response_code = resp.status
if response_code in [301, 302]:
uri = resp['location']
# Update the stored credential if it becomes invalid.
if response_code == 401:
logging.info('Access token no longer valid: %s' % content)
self._invalid = True
if self.store is not None:
self.store(self)
raise CredentialsInvalidError("Credentials are no longer valid.")
return resp, content
http.request = new_request
return http
class TwoLeggedOAuthCredentials(Credentials):
"""Two Legged Credentials object for OAuth 1.0a.
The Two Legged object is created directly, not from a flow. Once you
authorize and httplib2.Http instance you can change the requestor and that
change will propogate to the authorized httplib2.Http instance. For example:
http = httplib2.Http()
http = credentials.authorize(http)
credentials.requestor = 'foo@example.info'
http.request(...)
credentials.requestor = 'bar@example.info'
http.request(...)
"""
def __init__(self, consumer_key, consumer_secret, user_agent):
"""
Args:
consumer_key: string, An OAuth 1.0 consumer key
consumer_secret: string, An OAuth 1.0 consumer secret
user_agent: string, The HTTP User-Agent to provide for this application.
"""
self.consumer = oauth.Consumer(consumer_key, consumer_secret)
self.user_agent = user_agent
self.store = None
# email address of the user to act on the behalf of.
self._requestor = None
@property
def invalid(self):
"""True if the credentials are invalid, such as being revoked.
Always returns False for Two Legged Credentials.
"""
return False
def getrequestor(self):
return self._requestor
def setrequestor(self, email):
self._requestor = email
requestor = property(getrequestor, setrequestor, None,
'The email address of the user to act on behalf of')
def set_store(self, store):
"""Set the storage for the credential.
Args:
store: callable, a callable that when passed a Credential
will store the credential back to where it came from.
This is needed to store the latest access_token if it
has been revoked.
"""
self.store = store
def __getstate__(self):
"""Trim the state down to something that can be pickled."""
d = copy.copy(self.__dict__)
del d['store']
return d
def __setstate__(self, state):
"""Reconstitute the state of the object from being pickled."""
self.__dict__.update(state)
self.store = None
def authorize(self, http):
"""Authorize an httplib2.Http instance with these Credentials
Args:
http - An instance of httplib2.Http
or something that acts like it.
Returns:
A modified instance of http that was passed in.
Example:
h = httplib2.Http()
h = credentials.authorize(h)
You can't create a new OAuth
subclass of httplib2.Authenication because
it never gets passed the absolute URI, which is
needed for signing. So instead we have to overload
'request' with a closure that adds in the
Authorization header and then calls the original version
of 'request()'.
"""
request_orig = http.request
signer = oauth.SignatureMethod_HMAC_SHA1()
# The closure that will replace 'httplib2.Http.request'.
def new_request(uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
"""Modify the request headers to add the appropriate
Authorization header."""
response_code = 302
http.follow_redirects = False
while response_code in [301, 302]:
# add in xoauth_requestor_id=self._requestor to the uri
if self._requestor is None:
raise MissingParameter(
'Requestor must be set before using TwoLeggedOAuthCredentials')
parsed = list(urlparse.urlparse(uri))
q = parse_qsl(parsed[4])
q.append(('xoauth_requestor_id', self._requestor))
parsed[4] = urllib.urlencode(q)
uri = urlparse.urlunparse(parsed)
req = oauth.Request.from_consumer_and_token(
self.consumer, None, http_method=method, http_url=uri)
req.sign_request(signer, self.consumer, None)
if headers is None:
headers = {}
headers.update(req.to_header())
if 'user-agent' in headers:
headers['user-agent'] = self.user_agent + ' ' + headers['user-agent']
else:
headers['user-agent'] = self.user_agent
resp, content = request_orig(uri, method, body, headers,
redirections, connection_type)
response_code = resp.status
if response_code in [301, 302]:
uri = resp['location']
if response_code == 401:
logging.info('Access token no longer valid: %s' % content)
# Do not store the invalid state of the Credentials because
# being 2LO they could be reinstated in the future.
raise CredentialsInvalidError("Credentials are invalid.")
return resp, content
http.request = new_request
return http
class FlowThreeLegged(Flow):
"""Does the Three Legged Dance for OAuth 1.0a.
"""
def __init__(self, discovery, consumer_key, consumer_secret, user_agent,
**kwargs):
"""
discovery - Section of the API discovery document that describes
the OAuth endpoints.
consumer_key - OAuth consumer key
consumer_secret - OAuth consumer secret
user_agent - The HTTP User-Agent that identifies the application.
**kwargs - The keyword arguments are all optional and required
parameters for the OAuth calls.
"""
self.discovery = discovery
self.consumer_key = consumer_key
self.consumer_secret = consumer_secret
self.user_agent = user_agent
self.params = kwargs
self.request_token = {}
required = {}
for uriinfo in discovery.itervalues():
for name, value in uriinfo['parameters'].iteritems():
if value['required'] and not name.startswith('oauth_'):
required[name] = 1
for key in required.iterkeys():
if key not in self.params:
raise MissingParameter('Required parameter %s not supplied' % key)
def step1_get_authorize_url(self, oauth_callback='oob'):
"""Returns a URI to redirect to the provider.
oauth_callback - Either the string 'oob' for a non-web-based application,
or a URI that handles the callback from the authorization
server.
If oauth_callback is 'oob' then pass in the
generated verification code to step2_exchange,
otherwise pass in the query parameters received
at the callback uri to step2_exchange.
"""
consumer = oauth.Consumer(self.consumer_key, self.consumer_secret)
client = oauth.Client(consumer)
headers = {
'user-agent': self.user_agent,
'content-type': 'application/x-www-form-urlencoded'
}
body = urllib.urlencode({'oauth_callback': oauth_callback})
uri = _oauth_uri('request', self.discovery, self.params)
resp, content = client.request(uri, 'POST', headers=headers,
body=body)
if resp['status'] != '200':
logging.error('Failed to retrieve temporary authorization: %s', content)
raise RequestError('Invalid response %s.' % resp['status'])
self.request_token = dict(parse_qsl(content))
auth_params = copy.copy(self.params)
auth_params['oauth_token'] = self.request_token['oauth_token']
return _oauth_uri('authorize', self.discovery, auth_params)
def step2_exchange(self, verifier):
"""Exhanges an authorized request token
for OAuthCredentials.
Args:
verifier: string, dict - either the verifier token, or a dictionary
of the query parameters to the callback, which contains
the oauth_verifier.
Returns:
The Credentials object.
"""
if not (isinstance(verifier, str) or isinstance(verifier, unicode)):
verifier = verifier['oauth_verifier']
token = oauth.Token(
self.request_token['oauth_token'],
self.request_token['oauth_token_secret'])
token.set_verifier(verifier)
consumer = oauth.Consumer(self.consumer_key, self.consumer_secret)
client = oauth.Client(consumer, token)
headers = {
'user-agent': self.user_agent,
'content-type': 'application/x-www-form-urlencoded'
}
uri = _oauth_uri('access', self.discovery, self.params)
resp, content = client.request(uri, 'POST', headers=headers)
if resp['status'] != '200':
logging.error('Failed to retrieve access token: %s', content)
raise RequestError('Invalid response %s.' % resp['status'])
oauth_params = dict(parse_qsl(content))
token = oauth.Token(
oauth_params['oauth_token'],
oauth_params['oauth_token_secret'])
return OAuthCredentials(consumer, token, self.user_agent)
| Python |
#!/usr/bin/python2.4
#
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Model objects for requests and responses.
Each API may support one or more serializations, such
as JSON, Atom, etc. The model classes are responsible
for converting between the wire format and the Python
object representation.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import gflags
import logging
import urllib
from errors import HttpError
from oauth2client.anyjson import simplejson
FLAGS = gflags.FLAGS
gflags.DEFINE_boolean('dump_request_response', False,
'Dump all http server requests and responses. '
)
def _abstract():
raise NotImplementedError('You need to override this function')
class Model(object):
"""Model base class.
All Model classes should implement this interface.
The Model serializes and de-serializes between a wire
format such as JSON and a Python object representation.
"""
def request(self, headers, path_params, query_params, body_value):
"""Updates outgoing requests with a serialized body.
Args:
headers: dict, request headers
path_params: dict, parameters that appear in the request path
query_params: dict, parameters that appear in the query
body_value: object, the request body as a Python object, which must be
serializable.
Returns:
A tuple of (headers, path_params, query, body)
headers: dict, request headers
path_params: dict, parameters that appear in the request path
query: string, query part of the request URI
body: string, the body serialized in the desired wire format.
"""
_abstract()
def response(self, resp, content):
"""Convert the response wire format into a Python object.
Args:
resp: httplib2.Response, the HTTP response headers and status
content: string, the body of the HTTP response
Returns:
The body de-serialized as a Python object.
Raises:
apiclient.errors.HttpError if a non 2xx response is received.
"""
_abstract()
class BaseModel(Model):
"""Base model class.
Subclasses should provide implementations for the "serialize" and
"deserialize" methods, as well as values for the following class attributes.
Attributes:
accept: The value to use for the HTTP Accept header.
content_type: The value to use for the HTTP Content-type header.
no_content_response: The value to return when deserializing a 204 "No
Content" response.
alt_param: The value to supply as the "alt" query parameter for requests.
"""
accept = None
content_type = None
no_content_response = None
alt_param = None
def _log_request(self, headers, path_params, query, body):
"""Logs debugging information about the request if requested."""
if FLAGS.dump_request_response:
logging.info('--request-start--')
logging.info('-headers-start-')
for h, v in headers.iteritems():
logging.info('%s: %s', h, v)
logging.info('-headers-end-')
logging.info('-path-parameters-start-')
for h, v in path_params.iteritems():
logging.info('%s: %s', h, v)
logging.info('-path-parameters-end-')
logging.info('body: %s', body)
logging.info('query: %s', query)
logging.info('--request-end--')
def request(self, headers, path_params, query_params, body_value):
"""Updates outgoing requests with a serialized body.
Args:
headers: dict, request headers
path_params: dict, parameters that appear in the request path
query_params: dict, parameters that appear in the query
body_value: object, the request body as a Python object, which must be
serializable by simplejson.
Returns:
A tuple of (headers, path_params, query, body)
headers: dict, request headers
path_params: dict, parameters that appear in the request path
query: string, query part of the request URI
body: string, the body serialized as JSON
"""
query = self._build_query(query_params)
headers['accept'] = self.accept
headers['accept-encoding'] = 'gzip, deflate'
if 'user-agent' in headers:
headers['user-agent'] += ' '
else:
headers['user-agent'] = ''
headers['user-agent'] += 'google-api-python-client/1.0'
if body_value is not None:
headers['content-type'] = self.content_type
body_value = self.serialize(body_value)
self._log_request(headers, path_params, query, body_value)
return (headers, path_params, query, body_value)
def _build_query(self, params):
"""Builds a query string.
Args:
params: dict, the query parameters
Returns:
The query parameters properly encoded into an HTTP URI query string.
"""
if self.alt_param is not None:
params.update({'alt': self.alt_param})
astuples = []
for key, value in params.iteritems():
if type(value) == type([]):
for x in value:
x = x.encode('utf-8')
astuples.append((key, x))
else:
if getattr(value, 'encode', False) and callable(value.encode):
value = value.encode('utf-8')
astuples.append((key, value))
return '?' + urllib.urlencode(astuples)
def _log_response(self, resp, content):
"""Logs debugging information about the response if requested."""
if FLAGS.dump_request_response:
logging.info('--response-start--')
for h, v in resp.iteritems():
logging.info('%s: %s', h, v)
if content:
logging.info(content)
logging.info('--response-end--')
def response(self, resp, content):
"""Convert the response wire format into a Python object.
Args:
resp: httplib2.Response, the HTTP response headers and status
content: string, the body of the HTTP response
Returns:
The body de-serialized as a Python object.
Raises:
apiclient.errors.HttpError if a non 2xx response is received.
"""
self._log_response(resp, content)
# Error handling is TBD, for example, do we retry
# for some operation/error combinations?
if resp.status < 300:
if resp.status == 204:
# A 204: No Content response should be treated differently
# to all the other success states
return self.no_content_response
return self.deserialize(content)
else:
logging.debug('Content from bad request was: %s' % content)
raise HttpError(resp, content)
def serialize(self, body_value):
"""Perform the actual Python object serialization.
Args:
body_value: object, the request body as a Python object.
Returns:
string, the body in serialized form.
"""
_abstract()
def deserialize(self, content):
"""Perform the actual deserialization from response string to Python
object.
Args:
content: string, the body of the HTTP response
Returns:
The body de-serialized as a Python object.
"""
_abstract()
class JsonModel(BaseModel):
"""Model class for JSON.
Serializes and de-serializes between JSON and the Python
object representation of HTTP request and response bodies.
"""
accept = 'application/json'
content_type = 'application/json'
alt_param = 'json'
def __init__(self, data_wrapper=False):
"""Construct a JsonModel.
Args:
data_wrapper: boolean, wrap requests and responses in a data wrapper
"""
self._data_wrapper = data_wrapper
def serialize(self, body_value):
if (isinstance(body_value, dict) and 'data' not in body_value and
self._data_wrapper):
body_value = {'data': body_value}
return simplejson.dumps(body_value)
def deserialize(self, content):
body = simplejson.loads(content)
if isinstance(body, dict) and 'data' in body:
body = body['data']
return body
@property
def no_content_response(self):
return {}
class RawModel(JsonModel):
"""Model class for requests that don't return JSON.
Serializes and de-serializes between JSON and the Python
object representation of HTTP request, and returns the raw bytes
of the response body.
"""
accept = '*/*'
content_type = 'application/json'
alt_param = None
def deserialize(self, content):
return content
@property
def no_content_response(self):
return ''
class MediaModel(JsonModel):
"""Model class for requests that return Media.
Serializes and de-serializes between JSON and the Python
object representation of HTTP request, and returns the raw bytes
of the response body.
"""
accept = '*/*'
content_type = 'application/json'
alt_param = 'media'
def deserialize(self, content):
return content
@property
def no_content_response(self):
return ''
class ProtocolBufferModel(BaseModel):
"""Model class for protocol buffers.
Serializes and de-serializes the binary protocol buffer sent in the HTTP
request and response bodies.
"""
accept = 'application/x-protobuf'
content_type = 'application/x-protobuf'
alt_param = 'proto'
def __init__(self, protocol_buffer):
"""Constructs a ProtocolBufferModel.
The serialzed protocol buffer returned in an HTTP response will be
de-serialized using the given protocol buffer class.
Args:
protocol_buffer: The protocol buffer class used to de-serialize a
response from the API.
"""
self._protocol_buffer = protocol_buffer
def serialize(self, body_value):
return body_value.SerializeToString()
def deserialize(self, content):
return self._protocol_buffer.FromString(content)
@property
def no_content_response(self):
return self._protocol_buffer()
def makepatch(original, modified):
"""Create a patch object.
Some methods support PATCH, an efficient way to send updates to a resource.
This method allows the easy construction of patch bodies by looking at the
differences between a resource before and after it was modified.
Args:
original: object, the original deserialized resource
modified: object, the modified deserialized resource
Returns:
An object that contains only the changes from original to modified, in a
form suitable to pass to a PATCH method.
Example usage:
item = service.activities().get(postid=postid, userid=userid).execute()
original = copy.deepcopy(item)
item['object']['content'] = 'This is updated.'
service.activities.patch(postid=postid, userid=userid,
body=makepatch(original, item)).execute()
"""
patch = {}
for key, original_value in original.iteritems():
modified_value = modified.get(key, None)
if modified_value is None:
# Use None to signal that the element is deleted
patch[key] = None
elif original_value != modified_value:
if type(original_value) == type({}):
# Recursively descend objects
patch[key] = makepatch(original_value, modified_value)
else:
# In the case of simple types or arrays we just replace
patch[key] = modified_value
else:
# Don't add anything to patch if there's no change
pass
for key in modified:
if key not in original:
patch[key] = modified[key]
return patch
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Client for discovery based APIs
A client library for Google's discovery based APIs.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
__all__ = [
'build',
'build_from_document'
'fix_method_name',
'key2param'
]
import copy
import httplib2
import logging
import os
import random
import re
import uritemplate
import urllib
import urlparse
import mimeparse
import mimetypes
try:
from urlparse import parse_qsl
except ImportError:
from cgi import parse_qsl
from apiclient.errors import HttpError
from apiclient.errors import InvalidJsonError
from apiclient.errors import MediaUploadSizeError
from apiclient.errors import UnacceptableMimeTypeError
from apiclient.errors import UnknownApiNameOrVersion
from apiclient.errors import UnknownLinkType
from apiclient.http import HttpRequest
from apiclient.http import MediaFileUpload
from apiclient.http import MediaUpload
from apiclient.model import JsonModel
from apiclient.model import MediaModel
from apiclient.model import RawModel
from apiclient.schema import Schemas
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
from oauth2client.anyjson import simplejson
logger = logging.getLogger(__name__)
URITEMPLATE = re.compile('{[^}]*}')
VARNAME = re.compile('[a-zA-Z0-9_-]+')
DISCOVERY_URI = ('https://www.googleapis.com/discovery/v1/apis/'
'{api}/{apiVersion}/rest')
DEFAULT_METHOD_DOC = 'A description of how to use this function'
# Parameters accepted by the stack, but not visible via discovery.
STACK_QUERY_PARAMETERS = ['trace', 'pp', 'userip', 'strict']
# Python reserved words.
RESERVED_WORDS = ['and', 'assert', 'break', 'class', 'continue', 'def', 'del',
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from',
'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or',
'pass', 'print', 'raise', 'return', 'try', 'while' ]
def fix_method_name(name):
"""Fix method names to avoid reserved word conflicts.
Args:
name: string, method name.
Returns:
The name with a '_' prefixed if the name is a reserved word.
"""
if name in RESERVED_WORDS:
return name + '_'
else:
return name
def _add_query_parameter(url, name, value):
"""Adds a query parameter to a url.
Replaces the current value if it already exists in the URL.
Args:
url: string, url to add the query parameter to.
name: string, query parameter name.
value: string, query parameter value.
Returns:
Updated query parameter. Does not update the url if value is None.
"""
if value is None:
return url
else:
parsed = list(urlparse.urlparse(url))
q = dict(parse_qsl(parsed[4]))
q[name] = value
parsed[4] = urllib.urlencode(q)
return urlparse.urlunparse(parsed)
def key2param(key):
"""Converts key names into parameter names.
For example, converting "max-results" -> "max_results"
Args:
key: string, the method key name.
Returns:
A safe method name based on the key name.
"""
result = []
key = list(key)
if not key[0].isalpha():
result.append('x')
for c in key:
if c.isalnum():
result.append(c)
else:
result.append('_')
return ''.join(result)
def build(serviceName,
version,
http=None,
discoveryServiceUrl=DISCOVERY_URI,
developerKey=None,
model=None,
requestBuilder=HttpRequest):
"""Construct a Resource for interacting with an API.
Construct a Resource object for interacting with an API. The serviceName and
version are the names from the Discovery service.
Args:
serviceName: string, name of the service.
version: string, the version of the service.
http: httplib2.Http, An instance of httplib2.Http or something that acts
like it that HTTP requests will be made through.
discoveryServiceUrl: string, a URI Template that points to the location of
the discovery service. It should have two parameters {api} and
{apiVersion} that when filled in produce an absolute URI to the discovery
document for that service.
developerKey: string, key obtained from
https://code.google.com/apis/console.
model: apiclient.Model, converts to and from the wire format.
requestBuilder: apiclient.http.HttpRequest, encapsulator for an HTTP
request.
Returns:
A Resource object with methods for interacting with the service.
"""
params = {
'api': serviceName,
'apiVersion': version
}
if http is None:
http = httplib2.Http()
requested_url = uritemplate.expand(discoveryServiceUrl, params)
# REMOTE_ADDR is defined by the CGI spec [RFC3875] as the environment
# variable that contains the network address of the client sending the
# request. If it exists then add that to the request for the discovery
# document to avoid exceeding the quota on discovery requests.
if 'REMOTE_ADDR' in os.environ:
requested_url = _add_query_parameter(requested_url, 'userIp',
os.environ['REMOTE_ADDR'])
logger.info('URL being requested: %s' % requested_url)
resp, content = http.request(requested_url)
if resp.status == 404:
raise UnknownApiNameOrVersion("name: %s version: %s" % (serviceName,
version))
if resp.status >= 400:
raise HttpError(resp, content, requested_url)
try:
service = simplejson.loads(content)
except ValueError, e:
logger.error('Failed to parse as JSON: ' + content)
raise InvalidJsonError()
return build_from_document(content, discoveryServiceUrl, http=http,
developerKey=developerKey, model=model, requestBuilder=requestBuilder)
def build_from_document(
service,
base,
future=None,
http=None,
developerKey=None,
model=None,
requestBuilder=HttpRequest):
"""Create a Resource for interacting with an API.
Same as `build()`, but constructs the Resource object from a discovery
document that is it given, as opposed to retrieving one over HTTP.
Args:
service: string, discovery document.
base: string, base URI for all HTTP requests, usually the discovery URI.
future: string, discovery document with future capabilities (deprecated).
http: httplib2.Http, An instance of httplib2.Http or something that acts
like it that HTTP requests will be made through.
developerKey: string, Key for controlling API usage, generated
from the API Console.
model: Model class instance that serializes and de-serializes requests and
responses.
requestBuilder: Takes an http request and packages it up to be executed.
Returns:
A Resource object with methods for interacting with the service.
"""
# future is no longer used.
future = {}
service = simplejson.loads(service)
base = urlparse.urljoin(base, service['basePath'])
schema = Schemas(service)
if model is None:
features = service.get('features', [])
model = JsonModel('dataWrapper' in features)
resource = _createResource(http, base, model, requestBuilder, developerKey,
service, service, schema)
return resource
def _cast(value, schema_type):
"""Convert value to a string based on JSON Schema type.
See http://tools.ietf.org/html/draft-zyp-json-schema-03 for more details on
JSON Schema.
Args:
value: any, the value to convert
schema_type: string, the type that value should be interpreted as
Returns:
A string representation of 'value' based on the schema_type.
"""
if schema_type == 'string':
if type(value) == type('') or type(value) == type(u''):
return value
else:
return str(value)
elif schema_type == 'integer':
return str(int(value))
elif schema_type == 'number':
return str(float(value))
elif schema_type == 'boolean':
return str(bool(value)).lower()
else:
if type(value) == type('') or type(value) == type(u''):
return value
else:
return str(value)
MULTIPLIERS = {
"KB": 2 ** 10,
"MB": 2 ** 20,
"GB": 2 ** 30,
"TB": 2 ** 40,
}
def _media_size_to_long(maxSize):
"""Convert a string media size, such as 10GB or 3TB into an integer.
Args:
maxSize: string, size as a string, such as 2MB or 7GB.
Returns:
The size as an integer value.
"""
if len(maxSize) < 2:
return 0
units = maxSize[-2:].upper()
multiplier = MULTIPLIERS.get(units, 0)
if multiplier:
return int(maxSize[:-2]) * multiplier
else:
return int(maxSize)
def _createResource(http, baseUrl, model, requestBuilder,
developerKey, resourceDesc, rootDesc, schema):
"""Build a Resource from the API description.
Args:
http: httplib2.Http, Object to make http requests with.
baseUrl: string, base URL for the API. All requests are relative to this
URI.
model: apiclient.Model, converts to and from the wire format.
requestBuilder: class or callable that instantiates an
apiclient.HttpRequest object.
developerKey: string, key obtained from
https://code.google.com/apis/console
resourceDesc: object, section of deserialized discovery document that
describes a resource. Note that the top level discovery document
is considered a resource.
rootDesc: object, the entire deserialized discovery document.
schema: object, mapping of schema names to schema descriptions.
Returns:
An instance of Resource with all the methods attached for interacting with
that resource.
"""
class Resource(object):
"""A class for interacting with a resource."""
def __init__(self):
self._http = http
self._baseUrl = baseUrl
self._model = model
self._developerKey = developerKey
self._requestBuilder = requestBuilder
def createMethod(theclass, methodName, methodDesc, rootDesc):
"""Creates a method for attaching to a Resource.
Args:
theclass: type, the class to attach methods to.
methodName: string, name of the method to use.
methodDesc: object, fragment of deserialized discovery document that
describes the method.
rootDesc: object, the entire deserialized discovery document.
"""
methodName = fix_method_name(methodName)
pathUrl = methodDesc['path']
httpMethod = methodDesc['httpMethod']
methodId = methodDesc['id']
mediaPathUrl = None
accept = []
maxSize = 0
if 'mediaUpload' in methodDesc:
mediaUpload = methodDesc['mediaUpload']
# TODO(jcgregorio) Use URLs from discovery once it is updated.
parsed = list(urlparse.urlparse(baseUrl))
basePath = parsed[2]
mediaPathUrl = '/upload' + basePath + pathUrl
accept = mediaUpload['accept']
maxSize = _media_size_to_long(mediaUpload.get('maxSize', ''))
if 'parameters' not in methodDesc:
methodDesc['parameters'] = {}
# Add in the parameters common to all methods.
for name, desc in rootDesc.get('parameters', {}).iteritems():
methodDesc['parameters'][name] = desc
# Add in undocumented query parameters.
for name in STACK_QUERY_PARAMETERS:
methodDesc['parameters'][name] = {
'type': 'string',
'location': 'query'
}
if httpMethod in ['PUT', 'POST', 'PATCH'] and 'request' in methodDesc:
methodDesc['parameters']['body'] = {
'description': 'The request body.',
'type': 'object',
'required': True,
}
if 'request' in methodDesc:
methodDesc['parameters']['body'].update(methodDesc['request'])
else:
methodDesc['parameters']['body']['type'] = 'object'
if 'mediaUpload' in methodDesc:
methodDesc['parameters']['media_body'] = {
'description': 'The filename of the media request body.',
'type': 'string',
'required': False,
}
if 'body' in methodDesc['parameters']:
methodDesc['parameters']['body']['required'] = False
argmap = {} # Map from method parameter name to query parameter name
required_params = [] # Required parameters
repeated_params = [] # Repeated parameters
pattern_params = {} # Parameters that must match a regex
query_params = [] # Parameters that will be used in the query string
path_params = {} # Parameters that will be used in the base URL
param_type = {} # The type of the parameter
enum_params = {} # Allowable enumeration values for each parameter
if 'parameters' in methodDesc:
for arg, desc in methodDesc['parameters'].iteritems():
param = key2param(arg)
argmap[param] = arg
if desc.get('pattern', ''):
pattern_params[param] = desc['pattern']
if desc.get('enum', ''):
enum_params[param] = desc['enum']
if desc.get('required', False):
required_params.append(param)
if desc.get('repeated', False):
repeated_params.append(param)
if desc.get('location') == 'query':
query_params.append(param)
if desc.get('location') == 'path':
path_params[param] = param
param_type[param] = desc.get('type', 'string')
for match in URITEMPLATE.finditer(pathUrl):
for namematch in VARNAME.finditer(match.group(0)):
name = key2param(namematch.group(0))
path_params[name] = name
if name in query_params:
query_params.remove(name)
def method(self, **kwargs):
# Don't bother with doc string, it will be over-written by createMethod.
for name in kwargs.iterkeys():
if name not in argmap:
raise TypeError('Got an unexpected keyword argument "%s"' % name)
# Remove args that have a value of None.
keys = kwargs.keys()
for name in keys:
if kwargs[name] is None:
del kwargs[name]
for name in required_params:
if name not in kwargs:
raise TypeError('Missing required parameter "%s"' % name)
for name, regex in pattern_params.iteritems():
if name in kwargs:
if isinstance(kwargs[name], basestring):
pvalues = [kwargs[name]]
else:
pvalues = kwargs[name]
for pvalue in pvalues:
if re.match(regex, pvalue) is None:
raise TypeError(
'Parameter "%s" value "%s" does not match the pattern "%s"' %
(name, pvalue, regex))
for name, enums in enum_params.iteritems():
if name in kwargs:
# We need to handle the case of a repeated enum
# name differently, since we want to handle both
# arg='value' and arg=['value1', 'value2']
if (name in repeated_params and
not isinstance(kwargs[name], basestring)):
values = kwargs[name]
else:
values = [kwargs[name]]
for value in values:
if value not in enums:
raise TypeError(
'Parameter "%s" value "%s" is not an allowed value in "%s"' %
(name, value, str(enums)))
actual_query_params = {}
actual_path_params = {}
for key, value in kwargs.iteritems():
to_type = param_type.get(key, 'string')
# For repeated parameters we cast each member of the list.
if key in repeated_params and type(value) == type([]):
cast_value = [_cast(x, to_type) for x in value]
else:
cast_value = _cast(value, to_type)
if key in query_params:
actual_query_params[argmap[key]] = cast_value
if key in path_params:
actual_path_params[argmap[key]] = cast_value
body_value = kwargs.get('body', None)
media_filename = kwargs.get('media_body', None)
if self._developerKey:
actual_query_params['key'] = self._developerKey
model = self._model
# If there is no schema for the response then presume a binary blob.
if methodName.endswith('_media'):
model = MediaModel()
elif 'response' not in methodDesc:
model = RawModel()
headers = {}
headers, params, query, body = model.request(headers,
actual_path_params, actual_query_params, body_value)
expanded_url = uritemplate.expand(pathUrl, params)
url = urlparse.urljoin(self._baseUrl, expanded_url + query)
resumable = None
multipart_boundary = ''
if media_filename:
# Ensure we end up with a valid MediaUpload object.
if isinstance(media_filename, basestring):
(media_mime_type, encoding) = mimetypes.guess_type(media_filename)
if media_mime_type is None:
raise UnknownFileType(media_filename)
if not mimeparse.best_match([media_mime_type], ','.join(accept)):
raise UnacceptableMimeTypeError(media_mime_type)
media_upload = MediaFileUpload(media_filename, media_mime_type)
elif isinstance(media_filename, MediaUpload):
media_upload = media_filename
else:
raise TypeError('media_filename must be str or MediaUpload.')
# Check the maxSize
if maxSize > 0 and media_upload.size() > maxSize:
raise MediaUploadSizeError("Media larger than: %s" % maxSize)
# Use the media path uri for media uploads
expanded_url = uritemplate.expand(mediaPathUrl, params)
url = urlparse.urljoin(self._baseUrl, expanded_url + query)
if media_upload.resumable():
url = _add_query_parameter(url, 'uploadType', 'resumable')
if media_upload.resumable():
# This is all we need to do for resumable, if the body exists it gets
# sent in the first request, otherwise an empty body is sent.
resumable = media_upload
else:
# A non-resumable upload
if body is None:
# This is a simple media upload
headers['content-type'] = media_upload.mimetype()
body = media_upload.getbytes(0, media_upload.size())
url = _add_query_parameter(url, 'uploadType', 'media')
else:
# This is a multipart/related upload.
msgRoot = MIMEMultipart('related')
# msgRoot should not write out it's own headers
setattr(msgRoot, '_write_headers', lambda self: None)
# attach the body as one part
msg = MIMENonMultipart(*headers['content-type'].split('/'))
msg.set_payload(body)
msgRoot.attach(msg)
# attach the media as the second part
msg = MIMENonMultipart(*media_upload.mimetype().split('/'))
msg['Content-Transfer-Encoding'] = 'binary'
payload = media_upload.getbytes(0, media_upload.size())
msg.set_payload(payload)
msgRoot.attach(msg)
body = msgRoot.as_string()
multipart_boundary = msgRoot.get_boundary()
headers['content-type'] = ('multipart/related; '
'boundary="%s"') % multipart_boundary
url = _add_query_parameter(url, 'uploadType', 'multipart')
logger.info('URL being requested: %s' % url)
return self._requestBuilder(self._http,
model.response,
url,
method=httpMethod,
body=body,
headers=headers,
methodId=methodId,
resumable=resumable)
docs = [methodDesc.get('description', DEFAULT_METHOD_DOC), '\n\n']
if len(argmap) > 0:
docs.append('Args:\n')
# Skip undocumented params and params common to all methods.
skip_parameters = rootDesc.get('parameters', {}).keys()
skip_parameters.append(STACK_QUERY_PARAMETERS)
for arg in argmap.iterkeys():
if arg in skip_parameters:
continue
repeated = ''
if arg in repeated_params:
repeated = ' (repeated)'
required = ''
if arg in required_params:
required = ' (required)'
paramdesc = methodDesc['parameters'][argmap[arg]]
paramdoc = paramdesc.get('description', 'A parameter')
if '$ref' in paramdesc:
docs.append(
(' %s: object, %s%s%s\n The object takes the'
' form of:\n\n%s\n\n') % (arg, paramdoc, required, repeated,
schema.prettyPrintByName(paramdesc['$ref'])))
else:
paramtype = paramdesc.get('type', 'string')
docs.append(' %s: %s, %s%s%s\n' % (arg, paramtype, paramdoc, required,
repeated))
enum = paramdesc.get('enum', [])
enumDesc = paramdesc.get('enumDescriptions', [])
if enum and enumDesc:
docs.append(' Allowed values\n')
for (name, desc) in zip(enum, enumDesc):
docs.append(' %s - %s\n' % (name, desc))
if 'response' in methodDesc:
if methodName.endswith('_media'):
docs.append('\nReturns:\n The media object as a string.\n\n ')
else:
docs.append('\nReturns:\n An object of the form:\n\n ')
docs.append(schema.prettyPrintSchema(methodDesc['response']))
setattr(method, '__doc__', ''.join(docs))
setattr(theclass, methodName, method)
def createNextMethod(theclass, methodName, methodDesc, rootDesc):
"""Creates any _next methods for attaching to a Resource.
The _next methods allow for easy iteration through list() responses.
Args:
theclass: type, the class to attach methods to.
methodName: string, name of the method to use.
methodDesc: object, fragment of deserialized discovery document that
describes the method.
rootDesc: object, the entire deserialized discovery document.
"""
methodName = fix_method_name(methodName)
methodId = methodDesc['id'] + '.next'
def methodNext(self, previous_request, previous_response):
"""Retrieves the next page of results.
Args:
previous_request: The request for the previous page.
previous_response: The response from the request for the previous page.
Returns:
A request object that you can call 'execute()' on to request the next
page. Returns None if there are no more items in the collection.
"""
# Retrieve nextPageToken from previous_response
# Use as pageToken in previous_request to create new request.
if 'nextPageToken' not in previous_response:
return None
request = copy.copy(previous_request)
pageToken = previous_response['nextPageToken']
parsed = list(urlparse.urlparse(request.uri))
q = parse_qsl(parsed[4])
# Find and remove old 'pageToken' value from URI
newq = [(key, value) for (key, value) in q if key != 'pageToken']
newq.append(('pageToken', pageToken))
parsed[4] = urllib.urlencode(newq)
uri = urlparse.urlunparse(parsed)
request.uri = uri
logger.info('URL being requested: %s' % uri)
return request
setattr(theclass, methodName, methodNext)
# Add basic methods to Resource
if 'methods' in resourceDesc:
for methodName, methodDesc in resourceDesc['methods'].iteritems():
createMethod(Resource, methodName, methodDesc, rootDesc)
# Add in _media methods. The functionality of the attached method will
# change when it sees that the method name ends in _media.
if methodDesc.get('supportsMediaDownload', False):
createMethod(Resource, methodName + '_media', methodDesc, rootDesc)
# Add in nested resources
if 'resources' in resourceDesc:
def createResourceMethod(theclass, methodName, methodDesc, rootDesc):
"""Create a method on the Resource to access a nested Resource.
Args:
theclass: type, the class to attach methods to.
methodName: string, name of the method to use.
methodDesc: object, fragment of deserialized discovery document that
describes the method.
rootDesc: object, the entire deserialized discovery document.
"""
methodName = fix_method_name(methodName)
def methodResource(self):
return _createResource(self._http, self._baseUrl, self._model,
self._requestBuilder, self._developerKey,
methodDesc, rootDesc, schema)
setattr(methodResource, '__doc__', 'A collection resource.')
setattr(methodResource, '__is_resource__', True)
setattr(theclass, methodName, methodResource)
for methodName, methodDesc in resourceDesc['resources'].iteritems():
createResourceMethod(Resource, methodName, methodDesc, rootDesc)
# Add _next() methods
# Look for response bodies in schema that contain nextPageToken, and methods
# that take a pageToken parameter.
if 'methods' in resourceDesc:
for methodName, methodDesc in resourceDesc['methods'].iteritems():
if 'response' in methodDesc:
responseSchema = methodDesc['response']
if '$ref' in responseSchema:
responseSchema = schema.get(responseSchema['$ref'])
hasNextPageToken = 'nextPageToken' in responseSchema.get('properties',
{})
hasPageToken = 'pageToken' in methodDesc.get('parameters', {})
if hasNextPageToken and hasPageToken:
createNextMethod(Resource, methodName + '_next',
resourceDesc['methods'][methodName],
methodName)
return Resource()
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for OAuth.
Utilities for making it easier to work with OAuth 1.0 credentials.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import pickle
import threading
from apiclient.oauth import Storage as BaseStorage
class Storage(BaseStorage):
"""Store and retrieve a single credential to and from a file."""
def __init__(self, filename):
self._filename = filename
self._lock = threading.Lock()
def get(self):
"""Retrieve Credential from file.
Returns:
apiclient.oauth.Credentials
"""
self._lock.acquire()
try:
f = open(self._filename, 'r')
credentials = pickle.loads(f.read())
f.close()
credentials.set_store(self.put)
except:
credentials = None
self._lock.release()
return credentials
def put(self, credentials):
"""Write a pickled Credentials to file.
Args:
credentials: Credentials, the credentials to store.
"""
self._lock.acquire()
f = open(self._filename, 'w')
f.write(pickle.dumps(credentials))
f.close()
self._lock.release()
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import apiclient
import base64
import pickle
from django.db import models
class OAuthCredentialsField(models.Field):
__metaclass__ = models.SubfieldBase
def db_type(self):
return 'VARCHAR'
def to_python(self, value):
if value is None:
return None
if isinstance(value, apiclient.oauth.Credentials):
return value
return pickle.loads(base64.b64decode(value))
def get_db_prep_value(self, value):
return base64.b64encode(pickle.dumps(value))
class FlowThreeLeggedField(models.Field):
__metaclass__ = models.SubfieldBase
def db_type(self):
return 'VARCHAR'
def to_python(self, value):
print "In to_python", value
if value is None:
return None
if isinstance(value, apiclient.oauth.FlowThreeLegged):
return value
return pickle.loads(base64.b64decode(value))
def get_db_prep_value(self, value):
return base64.b64encode(pickle.dumps(value))
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for Google App Engine
Utilities for making it easier to use the
Google API Client for Python on Google App Engine.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import pickle
from google.appengine.ext import db
from apiclient.oauth import OAuthCredentials
from apiclient.oauth import FlowThreeLegged
class FlowThreeLeggedProperty(db.Property):
"""Utility property that allows easy
storage and retreival of an
apiclient.oauth.FlowThreeLegged"""
# Tell what the user type is.
data_type = FlowThreeLegged
# For writing to datastore.
def get_value_for_datastore(self, model_instance):
flow = super(FlowThreeLeggedProperty,
self).get_value_for_datastore(model_instance)
return db.Blob(pickle.dumps(flow))
# For reading from datastore.
def make_value_from_datastore(self, value):
if value is None:
return None
return pickle.loads(value)
def validate(self, value):
if value is not None and not isinstance(value, FlowThreeLegged):
raise BadValueError('Property %s must be convertible '
'to a FlowThreeLegged instance (%s)' %
(self.name, value))
return super(FlowThreeLeggedProperty, self).validate(value)
def empty(self, value):
return not value
class OAuthCredentialsProperty(db.Property):
"""Utility property that allows easy
storage and retrieval of
apiclient.oath.OAuthCredentials
"""
# Tell what the user type is.
data_type = OAuthCredentials
# For writing to datastore.
def get_value_for_datastore(self, model_instance):
cred = super(OAuthCredentialsProperty,
self).get_value_for_datastore(model_instance)
return db.Blob(pickle.dumps(cred))
# For reading from datastore.
def make_value_from_datastore(self, value):
if value is None:
return None
return pickle.loads(value)
def validate(self, value):
if value is not None and not isinstance(value, OAuthCredentials):
raise BadValueError('Property %s must be convertible '
'to an OAuthCredentials instance (%s)' %
(self.name, value))
return super(OAuthCredentialsProperty, self).validate(value)
def empty(self, value):
return not value
class StorageByKeyName(object):
"""Store and retrieve a single credential to and from
the App Engine datastore.
This Storage helper presumes the Credentials
have been stored as a CredenialsProperty
on a datastore model class, and that entities
are stored by key_name.
"""
def __init__(self, model, key_name, property_name):
"""Constructor for Storage.
Args:
model: db.Model, model class
key_name: string, key name for the entity that has the credentials
property_name: string, name of the property that is a CredentialsProperty
"""
self.model = model
self.key_name = key_name
self.property_name = property_name
def get(self):
"""Retrieve Credential from datastore.
Returns:
Credentials
"""
entity = self.model.get_or_insert(self.key_name)
credential = getattr(entity, self.property_name)
if credential and hasattr(credential, 'set_store'):
credential.set_store(self.put)
return credential
def put(self, credentials):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
"""
entity = self.model.get_or_insert(self.key_name)
setattr(entity, self.property_name, credentials)
entity.put()
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command-line tools for authenticating via OAuth 1.0
Do the OAuth 1.0 Three Legged Dance for
a command line application. Stores the generated
credentials in a common file that is used by
other example apps in the same directory.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
__all__ = ["run"]
import BaseHTTPServer
import gflags
import logging
import socket
import sys
from optparse import OptionParser
from apiclient.oauth import RequestError
try:
from urlparse import parse_qsl
except ImportError:
from cgi import parse_qsl
FLAGS = gflags.FLAGS
gflags.DEFINE_boolean('auth_local_webserver', True,
('Run a local web server to handle redirects during '
'OAuth authorization.'))
gflags.DEFINE_string('auth_host_name', 'localhost',
('Host name to use when running a local web server to '
'handle redirects during OAuth authorization.'))
gflags.DEFINE_multi_int('auth_host_port', [8080, 8090],
('Port to use when running a local web server to '
'handle redirects during OAuth authorization.'))
class ClientRedirectServer(BaseHTTPServer.HTTPServer):
"""A server to handle OAuth 1.0 redirects back to localhost.
Waits for a single request and parses the query parameters
into query_params and then stops serving.
"""
query_params = {}
class ClientRedirectHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""A handler for OAuth 1.0 redirects back to localhost.
Waits for a single request and parses the query parameters
into the servers query_params and then stops serving.
"""
def do_GET(s):
"""Handle a GET request
Parses the query parameters and prints a message
if the flow has completed. Note that we can't detect
if an error occurred.
"""
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
query = s.path.split('?', 1)[-1]
query = dict(parse_qsl(query))
s.server.query_params = query
s.wfile.write("<html><head><title>Authentication Status</title></head>")
s.wfile.write("<body><p>The authentication flow has completed.</p>")
s.wfile.write("</body></html>")
def log_message(self, format, *args):
"""Do not log messages to stdout while running as command line program."""
pass
def run(flow, storage):
"""Core code for a command-line application.
Args:
flow: Flow, an OAuth 1.0 Flow to step through.
storage: Storage, a Storage to store the credential in.
Returns:
Credentials, the obtained credential.
Exceptions:
RequestError: if step2 of the flow fails.
Args:
"""
if FLAGS.auth_local_webserver:
success = False
port_number = 0
for port in FLAGS.auth_host_port:
port_number = port
try:
httpd = BaseHTTPServer.HTTPServer((FLAGS.auth_host_name, port),
ClientRedirectHandler)
except socket.error, e:
pass
else:
success = True
break
FLAGS.auth_local_webserver = success
if FLAGS.auth_local_webserver:
oauth_callback = 'http://%s:%s/' % (FLAGS.auth_host_name, port_number)
else:
oauth_callback = 'oob'
authorize_url = flow.step1_get_authorize_url(oauth_callback)
print 'Go to the following link in your browser:'
print authorize_url
print
if FLAGS.auth_local_webserver:
print 'If your browser is on a different machine then exit and re-run this'
print 'application with the command-line parameter --noauth_local_webserver.'
print
if FLAGS.auth_local_webserver:
httpd.handle_request()
if 'error' in httpd.query_params:
sys.exit('Authentication request was rejected.')
if 'oauth_verifier' in httpd.query_params:
code = httpd.query_params['oauth_verifier']
else:
accepted = 'n'
while accepted.lower() == 'n':
accepted = raw_input('Have you authorized me? (y/n) ')
code = raw_input('What is the verification code? ').strip()
try:
credentials = flow.step2_exchange(code)
except RequestError:
sys.exit('The authentication has failed.')
storage.put(credentials)
credentials.set_store(storage.put)
print "You have successfully authenticated."
return credentials
| Python |
#!/usr/bin/python2.4
#
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Errors for the library.
All exceptions defined by the library
should be defined in this file.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
from oauth2client.anyjson import simplejson
class Error(Exception):
"""Base error for this module."""
pass
class HttpError(Error):
"""HTTP data was invalid or unexpected."""
def __init__(self, resp, content, uri=None):
self.resp = resp
self.content = content
self.uri = uri
def _get_reason(self):
"""Calculate the reason for the error from the response content."""
if self.resp.get('content-type', '').startswith('application/json'):
try:
data = simplejson.loads(self.content)
reason = data['error']['message']
except (ValueError, KeyError):
reason = self.content
else:
reason = self.resp.reason
return reason
def __repr__(self):
if self.uri:
return '<HttpError %s when requesting %s returned "%s">' % (
self.resp.status, self.uri, self._get_reason())
else:
return '<HttpError %s "%s">' % (self.resp.status, self._get_reason())
__str__ = __repr__
class InvalidJsonError(Error):
"""The JSON returned could not be parsed."""
pass
class UnknownLinkType(Error):
"""Link type unknown or unexpected."""
pass
class UnknownApiNameOrVersion(Error):
"""No API with that name and version exists."""
pass
class UnacceptableMimeTypeError(Error):
"""That is an unacceptable mimetype for this operation."""
pass
class MediaUploadSizeError(Error):
"""Media is larger than the method can accept."""
pass
class ResumableUploadError(Error):
"""Error occured during resumable upload."""
pass
class BatchError(HttpError):
"""Error occured during batch operations."""
def __init__(self, reason, resp=None, content=None):
self.resp = resp
self.content = content
self.reason = reason
def __repr__(self):
return '<BatchError %s "%s">' % (self.resp.status, self.reason)
__str__ = __repr__
class UnexpectedMethodError(Error):
"""Exception raised by RequestMockBuilder on unexpected calls."""
def __init__(self, methodId=None):
"""Constructor for an UnexpectedMethodError."""
super(UnexpectedMethodError, self).__init__(
'Received unexpected call %s' % methodId)
class UnexpectedBodyError(Error):
"""Exception raised by RequestMockBuilder on unexpected bodies."""
def __init__(self, expected, provided):
"""Constructor for an UnexpectedMethodError."""
super(UnexpectedBodyError, self).__init__(
'Expected: [%s] - Provided: [%s]' % (expected, provided))
| Python |
__version__ = "1.0c2"
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Schema processing for discovery based APIs
Schemas holds an APIs discovery schemas. It can return those schema as
deserialized JSON objects, or pretty print them as prototype objects that
conform to the schema.
For example, given the schema:
schema = \"\"\"{
"Foo": {
"type": "object",
"properties": {
"etag": {
"type": "string",
"description": "ETag of the collection."
},
"kind": {
"type": "string",
"description": "Type of the collection ('calendar#acl').",
"default": "calendar#acl"
},
"nextPageToken": {
"type": "string",
"description": "Token used to access the next
page of this result. Omitted if no further results are available."
}
}
}
}\"\"\"
s = Schemas(schema)
print s.prettyPrintByName('Foo')
Produces the following output:
{
"nextPageToken": "A String", # Token used to access the
# next page of this result. Omitted if no further results are available.
"kind": "A String", # Type of the collection ('calendar#acl').
"etag": "A String", # ETag of the collection.
},
The constructor takes a discovery document in which to look up named schema.
"""
# TODO(jcgregorio) support format, enum, minimum, maximum
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import copy
from oauth2client.anyjson import simplejson
class Schemas(object):
"""Schemas for an API."""
def __init__(self, discovery):
"""Constructor.
Args:
discovery: object, Deserialized discovery document from which we pull
out the named schema.
"""
self.schemas = discovery.get('schemas', {})
# Cache of pretty printed schemas.
self.pretty = {}
def _prettyPrintByName(self, name, seen=None, dent=0):
"""Get pretty printed object prototype from the schema name.
Args:
name: string, Name of schema in the discovery document.
seen: list of string, Names of schema already seen. Used to handle
recursive definitions.
Returns:
string, A string that contains a prototype object with
comments that conforms to the given schema.
"""
if seen is None:
seen = []
if name in seen:
# Do not fall into an infinite loop over recursive definitions.
return '# Object with schema name: %s' % name
seen.append(name)
if name not in self.pretty:
self.pretty[name] = _SchemaToStruct(self.schemas[name],
seen, dent).to_str(self._prettyPrintByName)
seen.pop()
return self.pretty[name]
def prettyPrintByName(self, name):
"""Get pretty printed object prototype from the schema name.
Args:
name: string, Name of schema in the discovery document.
Returns:
string, A string that contains a prototype object with
comments that conforms to the given schema.
"""
# Return with trailing comma and newline removed.
return self._prettyPrintByName(name, seen=[], dent=1)[:-2]
def _prettyPrintSchema(self, schema, seen=None, dent=0):
"""Get pretty printed object prototype of schema.
Args:
schema: object, Parsed JSON schema.
seen: list of string, Names of schema already seen. Used to handle
recursive definitions.
Returns:
string, A string that contains a prototype object with
comments that conforms to the given schema.
"""
if seen is None:
seen = []
return _SchemaToStruct(schema, seen, dent).to_str(self._prettyPrintByName)
def prettyPrintSchema(self, schema):
"""Get pretty printed object prototype of schema.
Args:
schema: object, Parsed JSON schema.
Returns:
string, A string that contains a prototype object with
comments that conforms to the given schema.
"""
# Return with trailing comma and newline removed.
return self._prettyPrintSchema(schema, dent=1)[:-2]
def get(self, name):
"""Get deserialized JSON schema from the schema name.
Args:
name: string, Schema name.
"""
return self.schemas[name]
class _SchemaToStruct(object):
"""Convert schema to a prototype object."""
def __init__(self, schema, seen, dent=0):
"""Constructor.
Args:
schema: object, Parsed JSON schema.
seen: list, List of names of schema already seen while parsing. Used to
handle recursive definitions.
dent: int, Initial indentation depth.
"""
# The result of this parsing kept as list of strings.
self.value = []
# The final value of the parsing.
self.string = None
# The parsed JSON schema.
self.schema = schema
# Indentation level.
self.dent = dent
# Method that when called returns a prototype object for the schema with
# the given name.
self.from_cache = None
# List of names of schema already seen while parsing.
self.seen = seen
def emit(self, text):
"""Add text as a line to the output.
Args:
text: string, Text to output.
"""
self.value.extend([" " * self.dent, text, '\n'])
def emitBegin(self, text):
"""Add text to the output, but with no line terminator.
Args:
text: string, Text to output.
"""
self.value.extend([" " * self.dent, text])
def emitEnd(self, text, comment):
"""Add text and comment to the output with line terminator.
Args:
text: string, Text to output.
comment: string, Python comment.
"""
if comment:
divider = '\n' + ' ' * (self.dent + 2) + '# '
lines = comment.splitlines()
lines = [x.rstrip() for x in lines]
comment = divider.join(lines)
self.value.extend([text, ' # ', comment, '\n'])
else:
self.value.extend([text, '\n'])
def indent(self):
"""Increase indentation level."""
self.dent += 1
def undent(self):
"""Decrease indentation level."""
self.dent -= 1
def _to_str_impl(self, schema):
"""Prototype object based on the schema, in Python code with comments.
Args:
schema: object, Parsed JSON schema file.
Returns:
Prototype object based on the schema, in Python code with comments.
"""
stype = schema.get('type')
if stype == 'object':
self.emitEnd('{', schema.get('description', ''))
self.indent()
for pname, pschema in schema.get('properties', {}).iteritems():
self.emitBegin('"%s": ' % pname)
self._to_str_impl(pschema)
self.undent()
self.emit('},')
elif '$ref' in schema:
schemaName = schema['$ref']
description = schema.get('description', '')
s = self.from_cache(schemaName, self.seen)
parts = s.splitlines()
self.emitEnd(parts[0], description)
for line in parts[1:]:
self.emit(line.rstrip())
elif stype == 'boolean':
value = schema.get('default', 'True or False')
self.emitEnd('%s,' % str(value), schema.get('description', ''))
elif stype == 'string':
value = schema.get('default', 'A String')
self.emitEnd('"%s",' % str(value), schema.get('description', ''))
elif stype == 'integer':
value = schema.get('default', '42')
self.emitEnd('%s,' % str(value), schema.get('description', ''))
elif stype == 'number':
value = schema.get('default', '3.14')
self.emitEnd('%s,' % str(value), schema.get('description', ''))
elif stype == 'null':
self.emitEnd('None,', schema.get('description', ''))
elif stype == 'any':
self.emitEnd('"",', schema.get('description', ''))
elif stype == 'array':
self.emitEnd('[', schema.get('description'))
self.indent()
self.emitBegin('')
self._to_str_impl(schema['items'])
self.undent()
self.emit('],')
else:
self.emit('Unknown type! %s' % stype)
self.emitEnd('', '')
self.string = ''.join(self.value)
return self.string
def to_str(self, from_cache):
"""Prototype object based on the schema, in Python code with comments.
Args:
from_cache: callable(name, seen), Callable that retrieves an object
prototype for a schema with the given name. Seen is a list of schema
names already seen as we recursively descend the schema definition.
Returns:
Prototype object based on the schema, in Python code with comments.
The lines of the code will all be properly indented.
"""
self.from_cache = from_cache
return self._to_str_impl(self.schema)
| Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utility module to import a JSON module
Hides all the messy details of exactly where
we get a simplejson module from.
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
try: # pragma: no cover
import simplejson
except ImportError: # pragma: no cover
try:
# Try to import from django, should work on App Engine
from django.utils import simplejson
except ImportError:
# Should work for Python2.6 and higher.
import json as simplejson
| Python |
# Early, and incomplete implementation of -04.
#
import re
import urllib
RESERVED = ":/?#[]@!$&'()*+,;="
OPERATOR = "+./;?|!@"
EXPLODE = "*+"
MODIFIER = ":^"
TEMPLATE = re.compile(r"{(?P<operator>[\+\./;\?|!@])?(?P<varlist>[^}]+)}", re.UNICODE)
VAR = re.compile(r"^(?P<varname>[^=\+\*:\^]+)((?P<explode>[\+\*])|(?P<partial>[:\^]-?[0-9]+))?(=(?P<default>.*))?$", re.UNICODE)
def _tostring(varname, value, explode, operator, safe=""):
if type(value) == type([]):
if explode == "+":
return ",".join([varname + "." + urllib.quote(x, safe) for x in value])
else:
return ",".join([urllib.quote(x, safe) for x in value])
if type(value) == type({}):
keys = value.keys()
keys.sort()
if explode == "+":
return ",".join([varname + "." + urllib.quote(key, safe) + "," + urllib.quote(value[key], safe) for key in keys])
else:
return ",".join([urllib.quote(key, safe) + "," + urllib.quote(value[key], safe) for key in keys])
else:
return urllib.quote(value, safe)
def _tostring_path(varname, value, explode, operator, safe=""):
joiner = operator
if type(value) == type([]):
if explode == "+":
return joiner.join([varname + "." + urllib.quote(x, safe) for x in value])
elif explode == "*":
return joiner.join([urllib.quote(x, safe) for x in value])
else:
return ",".join([urllib.quote(x, safe) for x in value])
elif type(value) == type({}):
keys = value.keys()
keys.sort()
if explode == "+":
return joiner.join([varname + "." + urllib.quote(key, safe) + joiner + urllib.quote(value[key], safe) for key in keys])
elif explode == "*":
return joiner.join([urllib.quote(key, safe) + joiner + urllib.quote(value[key], safe) for key in keys])
else:
return ",".join([urllib.quote(key, safe) + "," + urllib.quote(value[key], safe) for key in keys])
else:
if value:
return urllib.quote(value, safe)
else:
return ""
def _tostring_query(varname, value, explode, operator, safe=""):
joiner = operator
varprefix = ""
if operator == "?":
joiner = "&"
varprefix = varname + "="
if type(value) == type([]):
if 0 == len(value):
return ""
if explode == "+":
return joiner.join([varname + "=" + urllib.quote(x, safe) for x in value])
elif explode == "*":
return joiner.join([urllib.quote(x, safe) for x in value])
else:
return varprefix + ",".join([urllib.quote(x, safe) for x in value])
elif type(value) == type({}):
if 0 == len(value):
return ""
keys = value.keys()
keys.sort()
if explode == "+":
return joiner.join([varname + "." + urllib.quote(key, safe) + "=" + urllib.quote(value[key], safe) for key in keys])
elif explode == "*":
return joiner.join([urllib.quote(key, safe) + "=" + urllib.quote(value[key], safe) for key in keys])
else:
return varprefix + ",".join([urllib.quote(key, safe) + "," + urllib.quote(value[key], safe) for key in keys])
else:
if value:
return varname + "=" + urllib.quote(value, safe)
else:
return varname
TOSTRING = {
"" : _tostring,
"+": _tostring,
";": _tostring_query,
"?": _tostring_query,
"/": _tostring_path,
".": _tostring_path,
}
def expand(template, vars):
def _sub(match):
groupdict = match.groupdict()
operator = groupdict.get('operator')
if operator is None:
operator = ''
varlist = groupdict.get('varlist')
safe = "@"
if operator == '+':
safe = RESERVED
varspecs = varlist.split(",")
varnames = []
defaults = {}
for varspec in varspecs:
m = VAR.search(varspec)
groupdict = m.groupdict()
varname = groupdict.get('varname')
explode = groupdict.get('explode')
partial = groupdict.get('partial')
default = groupdict.get('default')
if default:
defaults[varname] = default
varnames.append((varname, explode, partial))
retval = []
joiner = operator
prefix = operator
if operator == "+":
prefix = ""
joiner = ","
if operator == "?":
joiner = "&"
if operator == "":
joiner = ","
for varname, explode, partial in varnames:
if varname in vars:
value = vars[varname]
#if not value and (type(value) == type({}) or type(value) == type([])) and varname in defaults:
if not value and value != "" and varname in defaults:
value = defaults[varname]
elif varname in defaults:
value = defaults[varname]
else:
continue
retval.append(TOSTRING[operator](varname, value, explode, operator, safe=safe))
if "".join(retval):
return prefix + joiner.join(retval)
else:
return ""
return TEMPLATE.sub(_sub, template)
| Python |
#!/usr/bin/env python
# Copyright (c) 2010, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Module to enforce different constraints on flags.
A validator represents an invariant, enforced over a one or more flags.
See 'FLAGS VALIDATORS' in gflags.py's docstring for a usage manual.
"""
__author__ = 'olexiy@google.com (Olexiy Oryeshko)'
class Error(Exception):
"""Thrown If validator constraint is not satisfied."""
class Validator(object):
"""Base class for flags validators.
Users should NOT overload these classes, and use gflags.Register...
methods instead.
"""
# Used to assign each validator an unique insertion_index
validators_count = 0
def __init__(self, checker, message):
"""Constructor to create all validators.
Args:
checker: function to verify the constraint.
Input of this method varies, see SimpleValidator and
DictionaryValidator for a detailed description.
message: string, error message to be shown to the user
"""
self.checker = checker
self.message = message
Validator.validators_count += 1
# Used to assert validators in the order they were registered (CL/18694236)
self.insertion_index = Validator.validators_count
def Verify(self, flag_values):
"""Verify that constraint is satisfied.
flags library calls this method to verify Validator's constraint.
Args:
flag_values: gflags.FlagValues, containing all flags
Raises:
Error: if constraint is not satisfied.
"""
param = self._GetInputToCheckerFunction(flag_values)
if not self.checker(param):
raise Error(self.message)
def GetFlagsNames(self):
"""Return the names of the flags checked by this validator.
Returns:
[string], names of the flags
"""
raise NotImplementedError('This method should be overloaded')
def PrintFlagsWithValues(self, flag_values):
raise NotImplementedError('This method should be overloaded')
def _GetInputToCheckerFunction(self, flag_values):
"""Given flag values, construct the input to be given to checker.
Args:
flag_values: gflags.FlagValues, containing all flags.
Returns:
Return type depends on the specific validator.
"""
raise NotImplementedError('This method should be overloaded')
class SimpleValidator(Validator):
"""Validator behind RegisterValidator() method.
Validates that a single flag passes its checker function. The checker function
takes the flag value and returns True (if value looks fine) or, if flag value
is not valid, either returns False or raises an Exception."""
def __init__(self, flag_name, checker, message):
"""Constructor.
Args:
flag_name: string, name of the flag.
checker: function to verify the validator.
input - value of the corresponding flag (string, boolean, etc).
output - Boolean. Must return True if validator constraint is satisfied.
If constraint is not satisfied, it should either return False or
raise Error.
message: string, error message to be shown to the user if validator's
condition is not satisfied
"""
super(SimpleValidator, self).__init__(checker, message)
self.flag_name = flag_name
def GetFlagsNames(self):
return [self.flag_name]
def PrintFlagsWithValues(self, flag_values):
return 'flag --%s=%s' % (self.flag_name, flag_values[self.flag_name].value)
def _GetInputToCheckerFunction(self, flag_values):
"""Given flag values, construct the input to be given to checker.
Args:
flag_values: gflags.FlagValues
Returns:
value of the corresponding flag.
"""
return flag_values[self.flag_name].value
class DictionaryValidator(Validator):
"""Validator behind RegisterDictionaryValidator method.
Validates that flag values pass their common checker function. The checker
function takes flag values and returns True (if values look fine) or,
if values are not valid, either returns False or raises an Exception.
"""
def __init__(self, flag_names, checker, message):
"""Constructor.
Args:
flag_names: [string], containing names of the flags used by checker.
checker: function to verify the validator.
input - dictionary, with keys() being flag_names, and value for each
key being the value of the corresponding flag (string, boolean, etc).
output - Boolean. Must return True if validator constraint is satisfied.
If constraint is not satisfied, it should either return False or
raise Error.
message: string, error message to be shown to the user if validator's
condition is not satisfied
"""
super(DictionaryValidator, self).__init__(checker, message)
self.flag_names = flag_names
def _GetInputToCheckerFunction(self, flag_values):
"""Given flag values, construct the input to be given to checker.
Args:
flag_values: gflags.FlagValues
Returns:
dictionary, with keys() being self.lag_names, and value for each key
being the value of the corresponding flag (string, boolean, etc).
"""
return dict([key, flag_values[key].value] for key in self.flag_names)
def PrintFlagsWithValues(self, flag_values):
prefix = 'flags '
flags_with_values = []
for key in self.flag_names:
flags_with_values.append('%s=%s' % (key, flag_values[key].value))
return prefix + ', '.join(flags_with_values)
def GetFlagsNames(self):
return self.flag_names
| Python |
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of Dan Haim nor the names of his contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.
This module provides a standard socket-like interface for Python
for tunneling connections through SOCKS proxies.
"""
"""
Minor modifications made by Christopher Gilbert (http://motomastyle.com/)
for use in PyLoris (http://pyloris.sourceforge.net/)
Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/)
mainly to merge bug fixes found in Sourceforge
"""
import base64
import socket
import struct
import sys
if getattr(socket, 'socket', None) is None:
raise ImportError('socket.socket missing, proxy support unusable')
PROXY_TYPE_SOCKS4 = 1
PROXY_TYPE_SOCKS5 = 2
PROXY_TYPE_HTTP = 3
PROXY_TYPE_HTTP_NO_TUNNEL = 4
_defaultproxy = None
_orgsocket = socket.socket
class ProxyError(Exception): pass
class GeneralProxyError(ProxyError): pass
class Socks5AuthError(ProxyError): pass
class Socks5Error(ProxyError): pass
class Socks4Error(ProxyError): pass
class HTTPError(ProxyError): pass
_generalerrors = ("success",
"invalid data",
"not connected",
"not available",
"bad proxy type",
"bad input")
_socks5errors = ("succeeded",
"general SOCKS server failure",
"connection not allowed by ruleset",
"Network unreachable",
"Host unreachable",
"Connection refused",
"TTL expired",
"Command not supported",
"Address type not supported",
"Unknown error")
_socks5autherrors = ("succeeded",
"authentication is required",
"all offered authentication methods were rejected",
"unknown username or invalid password",
"unknown error")
_socks4errors = ("request granted",
"request rejected or failed",
"request rejected because SOCKS server cannot connect to identd on the client",
"request rejected because the client program and identd report different user-ids",
"unknown error")
def setdefaultproxy(proxytype=None, addr=None, port=None, rdns=True, username=None, password=None):
"""setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets a default proxy which all further socksocket objects will use,
unless explicitly changed.
"""
global _defaultproxy
_defaultproxy = (proxytype, addr, port, rdns, username, password)
def wrapmodule(module):
"""wrapmodule(module)
Attempts to replace a module's socket library with a SOCKS socket. Must set
a default proxy using setdefaultproxy(...) first.
This will only work on modules that import socket directly into the namespace;
most of the Python Standard Library falls into this category.
"""
if _defaultproxy != None:
module.socket.socket = socksocket
else:
raise GeneralProxyError((4, "no proxy specified"))
class socksocket(socket.socket):
"""socksocket([family[, type[, proto]]]) -> socket object
Open a SOCKS enabled socket. The parameters are the same as
those of the standard socket init. In order for SOCKS to work,
you must specify family=AF_INET, type=SOCK_STREAM and proto=0.
"""
def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):
_orgsocket.__init__(self, family, type, proto, _sock)
if _defaultproxy != None:
self.__proxy = _defaultproxy
else:
self.__proxy = (None, None, None, None, None, None)
self.__proxysockname = None
self.__proxypeername = None
self.__httptunnel = True
def __recvall(self, count):
"""__recvall(count) -> data
Receive EXACTLY the number of bytes requested from the socket.
Blocks until the required number of bytes have been received.
"""
data = self.recv(count)
while len(data) < count:
d = self.recv(count-len(data))
if not d: raise GeneralProxyError((0, "connection closed unexpectedly"))
data = data + d
return data
def sendall(self, content, *args):
""" override socket.socket.sendall method to rewrite the header
for non-tunneling proxies if needed
"""
if not self.__httptunnel:
content = self.__rewriteproxy(content)
return super(socksocket, self).sendall(content, *args)
def __rewriteproxy(self, header):
""" rewrite HTTP request headers to support non-tunneling proxies
(i.e. those which do not support the CONNECT method).
This only works for HTTP (not HTTPS) since HTTPS requires tunneling.
"""
host, endpt = None, None
hdrs = header.split("\r\n")
for hdr in hdrs:
if hdr.lower().startswith("host:"):
host = hdr
elif hdr.lower().startswith("get") or hdr.lower().startswith("post"):
endpt = hdr
if host and endpt:
hdrs.remove(host)
hdrs.remove(endpt)
host = host.split(" ")[1]
endpt = endpt.split(" ")
if (self.__proxy[4] != None and self.__proxy[5] != None):
hdrs.insert(0, self.__getauthheader())
hdrs.insert(0, "Host: %s" % host)
hdrs.insert(0, "%s http://%s%s %s" % (endpt[0], host, endpt[1], endpt[2]))
return "\r\n".join(hdrs)
def __getauthheader(self):
auth = self.__proxy[4] + ":" + self.__proxy[5]
return "Proxy-Authorization: Basic " + base64.b64encode(auth)
def setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None):
"""setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets the proxy to be used.
proxytype - The type of the proxy to be used. Three types
are supported: PROXY_TYPE_SOCKS4 (including socks4a),
PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
addr - The address of the server (IP or DNS).
port - The port of the server. Defaults to 1080 for SOCKS
servers and 8080 for HTTP proxy servers.
rdns - Should DNS queries be preformed on the remote side
(rather than the local side). The default is True.
Note: This has no effect with SOCKS4 servers.
username - Username to authenticate with to the server.
The default is no authentication.
password - Password to authenticate with to the server.
Only relevant when username is also provided.
"""
self.__proxy = (proxytype, addr, port, rdns, username, password)
def __negotiatesocks5(self, destaddr, destport):
"""__negotiatesocks5(self,destaddr,destport)
Negotiates a connection through a SOCKS5 server.
"""
# First we'll send the authentication packages we support.
if (self.__proxy[4]!=None) and (self.__proxy[5]!=None):
# The username/password details were supplied to the
# setproxy method so we support the USERNAME/PASSWORD
# authentication (in addition to the standard none).
self.sendall(struct.pack('BBBB', 0x05, 0x02, 0x00, 0x02))
else:
# No username/password were entered, therefore we
# only support connections with no authentication.
self.sendall(struct.pack('BBB', 0x05, 0x01, 0x00))
# We'll receive the server's response to determine which
# method was selected
chosenauth = self.__recvall(2)
if chosenauth[0:1] != chr(0x05).encode():
self.close()
raise GeneralProxyError((1, _generalerrors[1]))
# Check the chosen authentication method
if chosenauth[1:2] == chr(0x00).encode():
# No authentication is required
pass
elif chosenauth[1:2] == chr(0x02).encode():
# Okay, we need to perform a basic username/password
# authentication.
self.sendall(chr(0x01).encode() + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5])
authstat = self.__recvall(2)
if authstat[0:1] != chr(0x01).encode():
# Bad response
self.close()
raise GeneralProxyError((1, _generalerrors[1]))
if authstat[1:2] != chr(0x00).encode():
# Authentication failed
self.close()
raise Socks5AuthError((3, _socks5autherrors[3]))
# Authentication succeeded
else:
# Reaching here is always bad
self.close()
if chosenauth[1] == chr(0xFF).encode():
raise Socks5AuthError((2, _socks5autherrors[2]))
else:
raise GeneralProxyError((1, _generalerrors[1]))
# Now we can request the actual connection
req = struct.pack('BBB', 0x05, 0x01, 0x00)
# If the given destination address is an IP address, we'll
# use the IPv4 address request even if remote resolving was specified.
try:
ipaddr = socket.inet_aton(destaddr)
req = req + chr(0x01).encode() + ipaddr
except socket.error:
# Well it's not an IP number, so it's probably a DNS name.
if self.__proxy[3]:
# Resolve remotely
ipaddr = None
req = req + chr(0x03).encode() + chr(len(destaddr)).encode() + destaddr
else:
# Resolve locally
ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
req = req + chr(0x01).encode() + ipaddr
req = req + struct.pack(">H", destport)
self.sendall(req)
# Get the response
resp = self.__recvall(4)
if resp[0:1] != chr(0x05).encode():
self.close()
raise GeneralProxyError((1, _generalerrors[1]))
elif resp[1:2] != chr(0x00).encode():
# Connection failed
self.close()
if ord(resp[1:2])<=8:
raise Socks5Error((ord(resp[1:2]), _socks5errors[ord(resp[1:2])]))
else:
raise Socks5Error((9, _socks5errors[9]))
# Get the bound address/port
elif resp[3:4] == chr(0x01).encode():
boundaddr = self.__recvall(4)
elif resp[3:4] == chr(0x03).encode():
resp = resp + self.recv(1)
boundaddr = self.__recvall(ord(resp[4:5]))
else:
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
boundport = struct.unpack(">H", self.__recvall(2))[0]
self.__proxysockname = (boundaddr, boundport)
if ipaddr != None:
self.__proxypeername = (socket.inet_ntoa(ipaddr), destport)
else:
self.__proxypeername = (destaddr, destport)
def getproxysockname(self):
"""getsockname() -> address info
Returns the bound IP address and port number at the proxy.
"""
return self.__proxysockname
def getproxypeername(self):
"""getproxypeername() -> address info
Returns the IP and port number of the proxy.
"""
return _orgsocket.getpeername(self)
def getpeername(self):
"""getpeername() -> address info
Returns the IP address and port number of the destination
machine (note: getproxypeername returns the proxy)
"""
return self.__proxypeername
def __negotiatesocks4(self,destaddr,destport):
"""__negotiatesocks4(self,destaddr,destport)
Negotiates a connection through a SOCKS4 server.
"""
# Check if the destination address provided is an IP address
rmtrslv = False
try:
ipaddr = socket.inet_aton(destaddr)
except socket.error:
# It's a DNS name. Check where it should be resolved.
if self.__proxy[3]:
ipaddr = struct.pack("BBBB", 0x00, 0x00, 0x00, 0x01)
rmtrslv = True
else:
ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
# Construct the request packet
req = struct.pack(">BBH", 0x04, 0x01, destport) + ipaddr
# The username parameter is considered userid for SOCKS4
if self.__proxy[4] != None:
req = req + self.__proxy[4]
req = req + chr(0x00).encode()
# DNS name if remote resolving is required
# NOTE: This is actually an extension to the SOCKS4 protocol
# called SOCKS4A and may not be supported in all cases.
if rmtrslv:
req = req + destaddr + chr(0x00).encode()
self.sendall(req)
# Get the response from the server
resp = self.__recvall(8)
if resp[0:1] != chr(0x00).encode():
# Bad data
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
if resp[1:2] != chr(0x5A).encode():
# Server returned an error
self.close()
if ord(resp[1:2]) in (91, 92, 93):
self.close()
raise Socks4Error((ord(resp[1:2]), _socks4errors[ord(resp[1:2]) - 90]))
else:
raise Socks4Error((94, _socks4errors[4]))
# Get the bound address/port
self.__proxysockname = (socket.inet_ntoa(resp[4:]), struct.unpack(">H", resp[2:4])[0])
if rmtrslv != None:
self.__proxypeername = (socket.inet_ntoa(ipaddr), destport)
else:
self.__proxypeername = (destaddr, destport)
def __negotiatehttp(self, destaddr, destport):
"""__negotiatehttp(self,destaddr,destport)
Negotiates a connection through an HTTP server.
"""
# If we need to resolve locally, we do this now
if not self.__proxy[3]:
addr = socket.gethostbyname(destaddr)
else:
addr = destaddr
headers = ["CONNECT ", addr, ":", str(destport), " HTTP/1.1\r\n"]
headers += ["Host: ", destaddr, "\r\n"]
if (self.__proxy[4] != None and self.__proxy[5] != None):
headers += [self.__getauthheader(), "\r\n"]
headers.append("\r\n")
self.sendall("".join(headers).encode())
# We read the response until we get the string "\r\n\r\n"
resp = self.recv(1)
while resp.find("\r\n\r\n".encode()) == -1:
resp = resp + self.recv(1)
# We just need the first line to check if the connection
# was successful
statusline = resp.splitlines()[0].split(" ".encode(), 2)
if statusline[0] not in ("HTTP/1.0".encode(), "HTTP/1.1".encode()):
self.close()
raise GeneralProxyError((1, _generalerrors[1]))
try:
statuscode = int(statusline[1])
except ValueError:
self.close()
raise GeneralProxyError((1, _generalerrors[1]))
if statuscode != 200:
self.close()
raise HTTPError((statuscode, statusline[2]))
self.__proxysockname = ("0.0.0.0", 0)
self.__proxypeername = (addr, destport)
def connect(self, destpair):
"""connect(self, despair)
Connects to the specified destination through a proxy.
destpar - A tuple of the IP/DNS address and the port number.
(identical to socket's connect).
To select the proxy server use setproxy().
"""
# Do a minimal input check first
if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int):
raise GeneralProxyError((5, _generalerrors[5]))
if self.__proxy[0] == PROXY_TYPE_SOCKS5:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 1080
_orgsocket.connect(self, (self.__proxy[1], portnum))
self.__negotiatesocks5(destpair[0], destpair[1])
elif self.__proxy[0] == PROXY_TYPE_SOCKS4:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 1080
_orgsocket.connect(self,(self.__proxy[1], portnum))
self.__negotiatesocks4(destpair[0], destpair[1])
elif self.__proxy[0] == PROXY_TYPE_HTTP:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 8080
_orgsocket.connect(self,(self.__proxy[1], portnum))
self.__negotiatehttp(destpair[0], destpair[1])
elif self.__proxy[0] == PROXY_TYPE_HTTP_NO_TUNNEL:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 8080
_orgsocket.connect(self,(self.__proxy[1],portnum))
if destpair[1] == 443:
self.__negotiatehttp(destpair[0],destpair[1])
else:
self.__httptunnel = False
elif self.__proxy[0] == None:
_orgsocket.connect(self, (destpair[0], destpair[1]))
else:
raise GeneralProxyError((4, _generalerrors[4]))
| Python |
"""
iri2uri
Converts an IRI to a URI.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyright 2006, Joe Gregorio"
__contributors__ = []
__version__ = "1.0.0"
__license__ = "MIT"
__history__ = """
"""
import urlparse
# Convert an IRI to a URI following the rules in RFC 3987
#
# The characters we need to enocde and escape are defined in the spec:
#
# iprivate = %xE000-F8FF / %xF0000-FFFFD / %x100000-10FFFD
# ucschar = %xA0-D7FF / %xF900-FDCF / %xFDF0-FFEF
# / %x10000-1FFFD / %x20000-2FFFD / %x30000-3FFFD
# / %x40000-4FFFD / %x50000-5FFFD / %x60000-6FFFD
# / %x70000-7FFFD / %x80000-8FFFD / %x90000-9FFFD
# / %xA0000-AFFFD / %xB0000-BFFFD / %xC0000-CFFFD
# / %xD0000-DFFFD / %xE1000-EFFFD
escape_range = [
(0xA0, 0xD7FF ),
(0xE000, 0xF8FF ),
(0xF900, 0xFDCF ),
(0xFDF0, 0xFFEF),
(0x10000, 0x1FFFD ),
(0x20000, 0x2FFFD ),
(0x30000, 0x3FFFD),
(0x40000, 0x4FFFD ),
(0x50000, 0x5FFFD ),
(0x60000, 0x6FFFD),
(0x70000, 0x7FFFD ),
(0x80000, 0x8FFFD ),
(0x90000, 0x9FFFD),
(0xA0000, 0xAFFFD ),
(0xB0000, 0xBFFFD ),
(0xC0000, 0xCFFFD),
(0xD0000, 0xDFFFD ),
(0xE1000, 0xEFFFD),
(0xF0000, 0xFFFFD ),
(0x100000, 0x10FFFD)
]
def encode(c):
retval = c
i = ord(c)
for low, high in escape_range:
if i < low:
break
if i >= low and i <= high:
retval = "".join(["%%%2X" % ord(o) for o in c.encode('utf-8')])
break
return retval
def iri2uri(uri):
"""Convert an IRI to a URI. Note that IRIs must be
passed in a unicode strings. That is, do not utf-8 encode
the IRI before passing it into the function."""
if isinstance(uri ,unicode):
(scheme, authority, path, query, fragment) = urlparse.urlsplit(uri)
authority = authority.encode('idna')
# For each character in 'ucschar' or 'iprivate'
# 1. encode as utf-8
# 2. then %-encode each octet of that utf-8
uri = urlparse.urlunsplit((scheme, authority, path, query, fragment))
uri = "".join([encode(c) for c in uri])
return uri
if __name__ == "__main__":
import unittest
class Test(unittest.TestCase):
def test_uris(self):
"""Test that URIs are invariant under the transformation."""
invariant = [
u"ftp://ftp.is.co.za/rfc/rfc1808.txt",
u"http://www.ietf.org/rfc/rfc2396.txt",
u"ldap://[2001:db8::7]/c=GB?objectClass?one",
u"mailto:John.Doe@example.com",
u"news:comp.infosystems.www.servers.unix",
u"tel:+1-816-555-1212",
u"telnet://192.0.2.16:80/",
u"urn:oasis:names:specification:docbook:dtd:xml:4.1.2" ]
for uri in invariant:
self.assertEqual(uri, iri2uri(uri))
def test_iri(self):
""" Test that the right type of escaping is done for each part of the URI."""
self.assertEqual("http://xn--o3h.com/%E2%98%84", iri2uri(u"http://\N{COMET}.com/\N{COMET}"))
self.assertEqual("http://bitworking.org/?fred=%E2%98%84", iri2uri(u"http://bitworking.org/?fred=\N{COMET}"))
self.assertEqual("http://bitworking.org/#%E2%98%84", iri2uri(u"http://bitworking.org/#\N{COMET}"))
self.assertEqual("#%E2%98%84", iri2uri(u"#\N{COMET}"))
self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}"))
self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}")))
self.assertNotEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}".encode('utf-8')))
unittest.main()
| Python |
from __future__ import generators
"""
httplib2
A caching http interface that supports ETags and gzip
to conserve bandwidth.
Requires Python 2.3 or later
Changelog:
2007-08-18, Rick: Modified so it's able to use a socks proxy if needed.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyright 2006, Joe Gregorio"
__contributors__ = ["Thomas Broyer (t.broyer@ltgt.net)",
"James Antill",
"Xavier Verges Farrero",
"Jonathan Feinberg",
"Blair Zajac",
"Sam Ruby",
"Louis Nyffenegger"]
__license__ = "MIT"
__version__ = "0.7.2"
import re
import sys
import email
import email.Utils
import email.Message
import email.FeedParser
import StringIO
import gzip
import zlib
import httplib
import urlparse
import base64
import os
import copy
import calendar
import time
import random
import errno
# remove depracated warning in python2.6
try:
from hashlib import sha1 as _sha, md5 as _md5
except ImportError:
import sha
import md5
_sha = sha.new
_md5 = md5.new
import hmac
from gettext import gettext as _
import socket
try:
from httplib2 import socks
except ImportError:
socks = None
# Build the appropriate socket wrapper for ssl
try:
import ssl # python 2.6
ssl_SSLError = ssl.SSLError
def _ssl_wrap_socket(sock, key_file, cert_file,
disable_validation, ca_certs):
if disable_validation:
cert_reqs = ssl.CERT_NONE
else:
cert_reqs = ssl.CERT_REQUIRED
# We should be specifying SSL version 3 or TLS v1, but the ssl module
# doesn't expose the necessary knobs. So we need to go with the default
# of SSLv23.
return ssl.wrap_socket(sock, keyfile=key_file, certfile=cert_file,
cert_reqs=cert_reqs, ca_certs=ca_certs)
except (AttributeError, ImportError):
ssl_SSLError = None
def _ssl_wrap_socket(sock, key_file, cert_file,
disable_validation, ca_certs):
if not disable_validation:
raise CertificateValidationUnsupported(
"SSL certificate validation is not supported without "
"the ssl module installed. To avoid this error, install "
"the ssl module, or explicity disable validation.")
ssl_sock = socket.ssl(sock, key_file, cert_file)
return httplib.FakeSocket(sock, ssl_sock)
if sys.version_info >= (2,3):
from iri2uri import iri2uri
else:
def iri2uri(uri):
return uri
def has_timeout(timeout): # python 2.6
if hasattr(socket, '_GLOBAL_DEFAULT_TIMEOUT'):
return (timeout is not None and timeout is not socket._GLOBAL_DEFAULT_TIMEOUT)
return (timeout is not None)
__all__ = ['Http', 'Response', 'ProxyInfo', 'HttpLib2Error',
'RedirectMissingLocation', 'RedirectLimit', 'FailedToDecompressContent',
'UnimplementedDigestAuthOptionError', 'UnimplementedHmacDigestAuthOptionError',
'debuglevel', 'ProxiesUnavailableError']
# The httplib debug level, set to a non-zero value to get debug output
debuglevel = 0
# Python 2.3 support
if sys.version_info < (2,4):
def sorted(seq):
seq.sort()
return seq
# Python 2.3 support
def HTTPResponse__getheaders(self):
"""Return list of (header, value) tuples."""
if self.msg is None:
raise httplib.ResponseNotReady()
return self.msg.items()
if not hasattr(httplib.HTTPResponse, 'getheaders'):
httplib.HTTPResponse.getheaders = HTTPResponse__getheaders
# All exceptions raised here derive from HttpLib2Error
class HttpLib2Error(Exception): pass
# Some exceptions can be caught and optionally
# be turned back into responses.
class HttpLib2ErrorWithResponse(HttpLib2Error):
def __init__(self, desc, response, content):
self.response = response
self.content = content
HttpLib2Error.__init__(self, desc)
class RedirectMissingLocation(HttpLib2ErrorWithResponse): pass
class RedirectLimit(HttpLib2ErrorWithResponse): pass
class FailedToDecompressContent(HttpLib2ErrorWithResponse): pass
class UnimplementedDigestAuthOptionError(HttpLib2ErrorWithResponse): pass
class UnimplementedHmacDigestAuthOptionError(HttpLib2ErrorWithResponse): pass
class MalformedHeader(HttpLib2Error): pass
class RelativeURIError(HttpLib2Error): pass
class ServerNotFoundError(HttpLib2Error): pass
class ProxiesUnavailableError(HttpLib2Error): pass
class CertificateValidationUnsupported(HttpLib2Error): pass
class SSLHandshakeError(HttpLib2Error): pass
class NotSupportedOnThisPlatform(HttpLib2Error): pass
class CertificateHostnameMismatch(SSLHandshakeError):
def __init__(self, desc, host, cert):
HttpLib2Error.__init__(self, desc)
self.host = host
self.cert = cert
# Open Items:
# -----------
# Proxy support
# Are we removing the cached content too soon on PUT (only delete on 200 Maybe?)
# Pluggable cache storage (supports storing the cache in
# flat files by default. We need a plug-in architecture
# that can support Berkeley DB and Squid)
# == Known Issues ==
# Does not handle a resource that uses conneg and Last-Modified but no ETag as a cache validator.
# Does not handle Cache-Control: max-stale
# Does not use Age: headers when calculating cache freshness.
# The number of redirections to follow before giving up.
# Note that only GET redirects are automatically followed.
# Will also honor 301 requests by saving that info and never
# requesting that URI again.
DEFAULT_MAX_REDIRECTS = 5
# Default CA certificates file bundled with httplib2.
CA_CERTS = os.path.join(
os.path.dirname(os.path.abspath(__file__ )), "cacerts.txt")
# Which headers are hop-by-hop headers by default
HOP_BY_HOP = ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade']
def _get_end2end_headers(response):
hopbyhop = list(HOP_BY_HOP)
hopbyhop.extend([x.strip() for x in response.get('connection', '').split(',')])
return [header for header in response.keys() if header not in hopbyhop]
URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?")
def parse_uri(uri):
"""Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
"""
groups = URI.match(uri).groups()
return (groups[1], groups[3], groups[4], groups[6], groups[8])
def urlnorm(uri):
(scheme, authority, path, query, fragment) = parse_uri(uri)
if not scheme or not authority:
raise RelativeURIError("Only absolute URIs are allowed. uri = %s" % uri)
authority = authority.lower()
scheme = scheme.lower()
if not path:
path = "/"
# Could do syntax based normalization of the URI before
# computing the digest. See Section 6.2.2 of Std 66.
request_uri = query and "?".join([path, query]) or path
scheme = scheme.lower()
defrag_uri = scheme + "://" + authority + request_uri
return scheme, authority, request_uri, defrag_uri
# Cache filename construction (original borrowed from Venus http://intertwingly.net/code/venus/)
re_url_scheme = re.compile(r'^\w+://')
re_slash = re.compile(r'[?/:|]+')
def safename(filename):
"""Return a filename suitable for the cache.
Strips dangerous and common characters to create a filename we
can use to store the cache in.
"""
try:
if re_url_scheme.match(filename):
if isinstance(filename,str):
filename = filename.decode('utf-8')
filename = filename.encode('idna')
else:
filename = filename.encode('idna')
except UnicodeError:
pass
if isinstance(filename,unicode):
filename=filename.encode('utf-8')
filemd5 = _md5(filename).hexdigest()
filename = re_url_scheme.sub("", filename)
filename = re_slash.sub(",", filename)
# limit length of filename
if len(filename)>200:
filename=filename[:200]
return ",".join((filename, filemd5))
NORMALIZE_SPACE = re.compile(r'(?:\r\n)?[ \t]+')
def _normalize_headers(headers):
return dict([ (key.lower(), NORMALIZE_SPACE.sub(value, ' ').strip()) for (key, value) in headers.iteritems()])
def _parse_cache_control(headers):
retval = {}
if headers.has_key('cache-control'):
parts = headers['cache-control'].split(',')
parts_with_args = [tuple([x.strip().lower() for x in part.split("=", 1)]) for part in parts if -1 != part.find("=")]
parts_wo_args = [(name.strip().lower(), 1) for name in parts if -1 == name.find("=")]
retval = dict(parts_with_args + parts_wo_args)
return retval
# Whether to use a strict mode to parse WWW-Authenticate headers
# Might lead to bad results in case of ill-formed header value,
# so disabled by default, falling back to relaxed parsing.
# Set to true to turn on, usefull for testing servers.
USE_WWW_AUTH_STRICT_PARSING = 0
# In regex below:
# [^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+ matches a "token" as defined by HTTP
# "(?:[^\0-\x08\x0A-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?" matches a "quoted-string" as defined by HTTP, when LWS have already been replaced by a single space
# Actually, as an auth-param value can be either a token or a quoted-string, they are combined in a single pattern which matches both:
# \"?((?<=\")(?:[^\0-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?(?=\")|(?<!\")[^\0-\x08\x0A-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+(?!\"))\"?
WWW_AUTH_STRICT = re.compile(r"^(?:\s*(?:,\s*)?([^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+)\s*=\s*\"?((?<=\")(?:[^\0-\x08\x0A-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?(?=\")|(?<!\")[^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+(?!\"))\"?)(.*)$")
WWW_AUTH_RELAXED = re.compile(r"^(?:\s*(?:,\s*)?([^ \t\r\n=]+)\s*=\s*\"?((?<=\")(?:[^\\\"]|\\.)*?(?=\")|(?<!\")[^ \t\r\n,]+(?!\"))\"?)(.*)$")
UNQUOTE_PAIRS = re.compile(r'\\(.)')
def _parse_www_authenticate(headers, headername='www-authenticate'):
"""Returns a dictionary of dictionaries, one dict
per auth_scheme."""
retval = {}
if headers.has_key(headername):
try:
authenticate = headers[headername].strip()
www_auth = USE_WWW_AUTH_STRICT_PARSING and WWW_AUTH_STRICT or WWW_AUTH_RELAXED
while authenticate:
# Break off the scheme at the beginning of the line
if headername == 'authentication-info':
(auth_scheme, the_rest) = ('digest', authenticate)
else:
(auth_scheme, the_rest) = authenticate.split(" ", 1)
# Now loop over all the key value pairs that come after the scheme,
# being careful not to roll into the next scheme
match = www_auth.search(the_rest)
auth_params = {}
while match:
if match and len(match.groups()) == 3:
(key, value, the_rest) = match.groups()
auth_params[key.lower()] = UNQUOTE_PAIRS.sub(r'\1', value) # '\\'.join([x.replace('\\', '') for x in value.split('\\\\')])
match = www_auth.search(the_rest)
retval[auth_scheme.lower()] = auth_params
authenticate = the_rest.strip()
except ValueError:
raise MalformedHeader("WWW-Authenticate")
return retval
def _entry_disposition(response_headers, request_headers):
"""Determine freshness from the Date, Expires and Cache-Control headers.
We don't handle the following:
1. Cache-Control: max-stale
2. Age: headers are not used in the calculations.
Not that this algorithm is simpler than you might think
because we are operating as a private (non-shared) cache.
This lets us ignore 's-maxage'. We can also ignore
'proxy-invalidate' since we aren't a proxy.
We will never return a stale document as
fresh as a design decision, and thus the non-implementation
of 'max-stale'. This also lets us safely ignore 'must-revalidate'
since we operate as if every server has sent 'must-revalidate'.
Since we are private we get to ignore both 'public' and
'private' parameters. We also ignore 'no-transform' since
we don't do any transformations.
The 'no-store' parameter is handled at a higher level.
So the only Cache-Control parameters we look at are:
no-cache
only-if-cached
max-age
min-fresh
"""
retval = "STALE"
cc = _parse_cache_control(request_headers)
cc_response = _parse_cache_control(response_headers)
if request_headers.has_key('pragma') and request_headers['pragma'].lower().find('no-cache') != -1:
retval = "TRANSPARENT"
if 'cache-control' not in request_headers:
request_headers['cache-control'] = 'no-cache'
elif cc.has_key('no-cache'):
retval = "TRANSPARENT"
elif cc_response.has_key('no-cache'):
retval = "STALE"
elif cc.has_key('only-if-cached'):
retval = "FRESH"
elif response_headers.has_key('date'):
date = calendar.timegm(email.Utils.parsedate_tz(response_headers['date']))
now = time.time()
current_age = max(0, now - date)
if cc_response.has_key('max-age'):
try:
freshness_lifetime = int(cc_response['max-age'])
except ValueError:
freshness_lifetime = 0
elif response_headers.has_key('expires'):
expires = email.Utils.parsedate_tz(response_headers['expires'])
if None == expires:
freshness_lifetime = 0
else:
freshness_lifetime = max(0, calendar.timegm(expires) - date)
else:
freshness_lifetime = 0
if cc.has_key('max-age'):
try:
freshness_lifetime = int(cc['max-age'])
except ValueError:
freshness_lifetime = 0
if cc.has_key('min-fresh'):
try:
min_fresh = int(cc['min-fresh'])
except ValueError:
min_fresh = 0
current_age += min_fresh
if freshness_lifetime > current_age:
retval = "FRESH"
return retval
def _decompressContent(response, new_content):
content = new_content
try:
encoding = response.get('content-encoding', None)
if encoding in ['gzip', 'deflate']:
if encoding == 'gzip':
content = gzip.GzipFile(fileobj=StringIO.StringIO(new_content)).read()
if encoding == 'deflate':
content = zlib.decompress(content)
response['content-length'] = str(len(content))
# Record the historical presence of the encoding in a way the won't interfere.
response['-content-encoding'] = response['content-encoding']
del response['content-encoding']
except IOError:
content = ""
raise FailedToDecompressContent(_("Content purported to be compressed with %s but failed to decompress.") % response.get('content-encoding'), response, content)
return content
def _updateCache(request_headers, response_headers, content, cache, cachekey):
if cachekey:
cc = _parse_cache_control(request_headers)
cc_response = _parse_cache_control(response_headers)
if cc.has_key('no-store') or cc_response.has_key('no-store'):
cache.delete(cachekey)
else:
info = email.Message.Message()
for key, value in response_headers.iteritems():
if key not in ['status','content-encoding','transfer-encoding']:
info[key] = value
# Add annotations to the cache to indicate what headers
# are variant for this request.
vary = response_headers.get('vary', None)
if vary:
vary_headers = vary.lower().replace(' ', '').split(',')
for header in vary_headers:
key = '-varied-%s' % header
try:
info[key] = request_headers[header]
except KeyError:
pass
status = response_headers.status
if status == 304:
status = 200
status_header = 'status: %d\r\n' % status
header_str = info.as_string()
header_str = re.sub("\r(?!\n)|(?<!\r)\n", "\r\n", header_str)
text = "".join([status_header, header_str, content])
cache.set(cachekey, text)
def _cnonce():
dig = _md5("%s:%s" % (time.ctime(), ["0123456789"[random.randrange(0, 9)] for i in range(20)])).hexdigest()
return dig[:16]
def _wsse_username_token(cnonce, iso_now, password):
return base64.b64encode(_sha("%s%s%s" % (cnonce, iso_now, password)).digest()).strip()
# For credentials we need two things, first
# a pool of credential to try (not necesarily tied to BAsic, Digest, etc.)
# Then we also need a list of URIs that have already demanded authentication
# That list is tricky since sub-URIs can take the same auth, or the
# auth scheme may change as you descend the tree.
# So we also need each Auth instance to be able to tell us
# how close to the 'top' it is.
class Authentication(object):
def __init__(self, credentials, host, request_uri, headers, response, content, http):
(scheme, authority, path, query, fragment) = parse_uri(request_uri)
self.path = path
self.host = host
self.credentials = credentials
self.http = http
def depth(self, request_uri):
(scheme, authority, path, query, fragment) = parse_uri(request_uri)
return request_uri[len(self.path):].count("/")
def inscope(self, host, request_uri):
# XXX Should we normalize the request_uri?
(scheme, authority, path, query, fragment) = parse_uri(request_uri)
return (host == self.host) and path.startswith(self.path)
def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header. Over-rise this in sub-classes."""
pass
def response(self, response, content):
"""Gives us a chance to update with new nonces
or such returned from the last authorized response.
Over-rise this in sub-classes if necessary.
Return TRUE is the request is to be retried, for
example Digest may return stale=true.
"""
return False
class BasicAuthentication(Authentication):
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header."""
headers['authorization'] = 'Basic ' + base64.b64encode("%s:%s" % self.credentials).strip()
class DigestAuthentication(Authentication):
"""Only do qop='auth' and MD5, since that
is all Apache currently implements"""
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
challenge = _parse_www_authenticate(response, 'www-authenticate')
self.challenge = challenge['digest']
qop = self.challenge.get('qop', 'auth')
self.challenge['qop'] = ('auth' in [x.strip() for x in qop.split()]) and 'auth' or None
if self.challenge['qop'] is None:
raise UnimplementedDigestAuthOptionError( _("Unsupported value for qop: %s." % qop))
self.challenge['algorithm'] = self.challenge.get('algorithm', 'MD5').upper()
if self.challenge['algorithm'] != 'MD5':
raise UnimplementedDigestAuthOptionError( _("Unsupported value for algorithm: %s." % self.challenge['algorithm']))
self.A1 = "".join([self.credentials[0], ":", self.challenge['realm'], ":", self.credentials[1]])
self.challenge['nc'] = 1
def request(self, method, request_uri, headers, content, cnonce = None):
"""Modify the request headers"""
H = lambda x: _md5(x).hexdigest()
KD = lambda s, d: H("%s:%s" % (s, d))
A2 = "".join([method, ":", request_uri])
self.challenge['cnonce'] = cnonce or _cnonce()
request_digest = '"%s"' % KD(H(self.A1), "%s:%s:%s:%s:%s" % (self.challenge['nonce'],
'%08x' % self.challenge['nc'],
self.challenge['cnonce'],
self.challenge['qop'], H(A2)
))
headers['authorization'] = 'Digest username="%s", realm="%s", nonce="%s", uri="%s", algorithm=%s, response=%s, qop=%s, nc=%08x, cnonce="%s"' % (
self.credentials[0],
self.challenge['realm'],
self.challenge['nonce'],
request_uri,
self.challenge['algorithm'],
request_digest,
self.challenge['qop'],
self.challenge['nc'],
self.challenge['cnonce'],
)
if self.challenge.get('opaque'):
headers['authorization'] += ', opaque="%s"' % self.challenge['opaque']
self.challenge['nc'] += 1
def response(self, response, content):
if not response.has_key('authentication-info'):
challenge = _parse_www_authenticate(response, 'www-authenticate').get('digest', {})
if 'true' == challenge.get('stale'):
self.challenge['nonce'] = challenge['nonce']
self.challenge['nc'] = 1
return True
else:
updated_challenge = _parse_www_authenticate(response, 'authentication-info').get('digest', {})
if updated_challenge.has_key('nextnonce'):
self.challenge['nonce'] = updated_challenge['nextnonce']
self.challenge['nc'] = 1
return False
class HmacDigestAuthentication(Authentication):
"""Adapted from Robert Sayre's code and DigestAuthentication above."""
__author__ = "Thomas Broyer (t.broyer@ltgt.net)"
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
challenge = _parse_www_authenticate(response, 'www-authenticate')
self.challenge = challenge['hmacdigest']
# TODO: self.challenge['domain']
self.challenge['reason'] = self.challenge.get('reason', 'unauthorized')
if self.challenge['reason'] not in ['unauthorized', 'integrity']:
self.challenge['reason'] = 'unauthorized'
self.challenge['salt'] = self.challenge.get('salt', '')
if not self.challenge.get('snonce'):
raise UnimplementedHmacDigestAuthOptionError( _("The challenge doesn't contain a server nonce, or this one is empty."))
self.challenge['algorithm'] = self.challenge.get('algorithm', 'HMAC-SHA-1')
if self.challenge['algorithm'] not in ['HMAC-SHA-1', 'HMAC-MD5']:
raise UnimplementedHmacDigestAuthOptionError( _("Unsupported value for algorithm: %s." % self.challenge['algorithm']))
self.challenge['pw-algorithm'] = self.challenge.get('pw-algorithm', 'SHA-1')
if self.challenge['pw-algorithm'] not in ['SHA-1', 'MD5']:
raise UnimplementedHmacDigestAuthOptionError( _("Unsupported value for pw-algorithm: %s." % self.challenge['pw-algorithm']))
if self.challenge['algorithm'] == 'HMAC-MD5':
self.hashmod = _md5
else:
self.hashmod = _sha
if self.challenge['pw-algorithm'] == 'MD5':
self.pwhashmod = _md5
else:
self.pwhashmod = _sha
self.key = "".join([self.credentials[0], ":",
self.pwhashmod.new("".join([self.credentials[1], self.challenge['salt']])).hexdigest().lower(),
":", self.challenge['realm']
])
self.key = self.pwhashmod.new(self.key).hexdigest().lower()
def request(self, method, request_uri, headers, content):
"""Modify the request headers"""
keys = _get_end2end_headers(headers)
keylist = "".join(["%s " % k for k in keys])
headers_val = "".join([headers[k] for k in keys])
created = time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime())
cnonce = _cnonce()
request_digest = "%s:%s:%s:%s:%s" % (method, request_uri, cnonce, self.challenge['snonce'], headers_val)
request_digest = hmac.new(self.key, request_digest, self.hashmod).hexdigest().lower()
headers['authorization'] = 'HMACDigest username="%s", realm="%s", snonce="%s", cnonce="%s", uri="%s", created="%s", response="%s", headers="%s"' % (
self.credentials[0],
self.challenge['realm'],
self.challenge['snonce'],
cnonce,
request_uri,
created,
request_digest,
keylist,
)
def response(self, response, content):
challenge = _parse_www_authenticate(response, 'www-authenticate').get('hmacdigest', {})
if challenge.get('reason') in ['integrity', 'stale']:
return True
return False
class WsseAuthentication(Authentication):
"""This is thinly tested and should not be relied upon.
At this time there isn't any third party server to test against.
Blogger and TypePad implemented this algorithm at one point
but Blogger has since switched to Basic over HTTPS and
TypePad has implemented it wrong, by never issuing a 401
challenge but instead requiring your client to telepathically know that
their endpoint is expecting WSSE profile="UsernameToken"."""
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header."""
headers['authorization'] = 'WSSE profile="UsernameToken"'
iso_now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
password_digest = _wsse_username_token(cnonce, iso_now, self.credentials[1])
headers['X-WSSE'] = 'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"' % (
self.credentials[0],
password_digest,
cnonce,
iso_now)
class GoogleLoginAuthentication(Authentication):
def __init__(self, credentials, host, request_uri, headers, response, content, http):
from urllib import urlencode
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
challenge = _parse_www_authenticate(response, 'www-authenticate')
service = challenge['googlelogin'].get('service', 'xapi')
# Bloggger actually returns the service in the challenge
# For the rest we guess based on the URI
if service == 'xapi' and request_uri.find("calendar") > 0:
service = "cl"
# No point in guessing Base or Spreadsheet
#elif request_uri.find("spreadsheets") > 0:
# service = "wise"
auth = dict(Email=credentials[0], Passwd=credentials[1], service=service, source=headers['user-agent'])
resp, content = self.http.request("https://www.google.com/accounts/ClientLogin", method="POST", body=urlencode(auth), headers={'Content-Type': 'application/x-www-form-urlencoded'})
lines = content.split('\n')
d = dict([tuple(line.split("=", 1)) for line in lines if line])
if resp.status == 403:
self.Auth = ""
else:
self.Auth = d['Auth']
def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header."""
headers['authorization'] = 'GoogleLogin Auth=' + self.Auth
AUTH_SCHEME_CLASSES = {
"basic": BasicAuthentication,
"wsse": WsseAuthentication,
"digest": DigestAuthentication,
"hmacdigest": HmacDigestAuthentication,
"googlelogin": GoogleLoginAuthentication
}
AUTH_SCHEME_ORDER = ["hmacdigest", "googlelogin", "digest", "wsse", "basic"]
class FileCache(object):
"""Uses a local directory as a store for cached files.
Not really safe to use if multiple threads or processes are going to
be running on the same cache.
"""
def __init__(self, cache, safe=safename): # use safe=lambda x: md5.new(x).hexdigest() for the old behavior
self.cache = cache
self.safe = safe
if not os.path.exists(cache):
os.makedirs(self.cache)
def get(self, key):
retval = None
cacheFullPath = os.path.join(self.cache, self.safe(key))
try:
f = file(cacheFullPath, "rb")
retval = f.read()
f.close()
except IOError:
pass
return retval
def set(self, key, value):
cacheFullPath = os.path.join(self.cache, self.safe(key))
f = file(cacheFullPath, "wb")
f.write(value)
f.close()
def delete(self, key):
cacheFullPath = os.path.join(self.cache, self.safe(key))
if os.path.exists(cacheFullPath):
os.remove(cacheFullPath)
class Credentials(object):
def __init__(self):
self.credentials = []
def add(self, name, password, domain=""):
self.credentials.append((domain.lower(), name, password))
def clear(self):
self.credentials = []
def iter(self, domain):
for (cdomain, name, password) in self.credentials:
if cdomain == "" or domain == cdomain:
yield (name, password)
class KeyCerts(Credentials):
"""Identical to Credentials except that
name/password are mapped to key/cert."""
pass
class ProxyInfo(object):
"""Collect information required to use a proxy."""
def __init__(self, proxy_type, proxy_host, proxy_port, proxy_rdns=None, proxy_user=None, proxy_pass=None):
"""The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
constants. For example:
p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, proxy_host='localhost', proxy_port=8000)
"""
self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns, self.proxy_user, self.proxy_pass = proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass
def astuple(self):
return (self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns,
self.proxy_user, self.proxy_pass)
def isgood(self):
return (self.proxy_host != None) and (self.proxy_port != None)
class HTTPConnectionWithTimeout(httplib.HTTPConnection):
"""
HTTPConnection subclass that supports timeouts
All timeouts are in seconds. If None is passed for timeout then
Python's default timeout for sockets will be used. See for example
the docs of socket.setdefaulttimeout():
http://docs.python.org/library/socket.html#socket.setdefaulttimeout
"""
def __init__(self, host, port=None, strict=None, timeout=None, proxy_info=None):
httplib.HTTPConnection.__init__(self, host, port, strict)
self.timeout = timeout
self.proxy_info = proxy_info
def connect(self):
"""Connect to the host and port specified in __init__."""
# Mostly verbatim from httplib.py.
if self.proxy_info and socks is None:
raise ProxiesUnavailableError(
'Proxy support missing but proxy use was requested!')
msg = "getaddrinfo returns an empty list"
for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
if self.proxy_info and self.proxy_info.isgood():
self.sock = socks.socksocket(af, socktype, proto)
self.sock.setproxy(*self.proxy_info.astuple())
else:
self.sock = socket.socket(af, socktype, proto)
self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
# Different from httplib: support timeouts.
if has_timeout(self.timeout):
self.sock.settimeout(self.timeout)
# End of difference from httplib.
if self.debuglevel > 0:
print "connect: (%s, %s)" % (self.host, self.port)
self.sock.connect(sa)
except socket.error, msg:
if self.debuglevel > 0:
print 'connect fail:', (self.host, self.port)
if self.sock:
self.sock.close()
self.sock = None
continue
break
if not self.sock:
raise socket.error, msg
class HTTPSConnectionWithTimeout(httplib.HTTPSConnection):
"""
This class allows communication via SSL.
All timeouts are in seconds. If None is passed for timeout then
Python's default timeout for sockets will be used. See for example
the docs of socket.setdefaulttimeout():
http://docs.python.org/library/socket.html#socket.setdefaulttimeout
"""
def __init__(self, host, port=None, key_file=None, cert_file=None,
strict=None, timeout=None, proxy_info=None,
ca_certs=None, disable_ssl_certificate_validation=False):
httplib.HTTPSConnection.__init__(self, host, port=port, key_file=key_file,
cert_file=cert_file, strict=strict)
self.timeout = timeout
self.proxy_info = proxy_info
if ca_certs is None:
ca_certs = CA_CERTS
self.ca_certs = ca_certs
self.disable_ssl_certificate_validation = \
disable_ssl_certificate_validation
# The following two methods were adapted from https_wrapper.py, released
# with the Google Appengine SDK at
# http://googleappengine.googlecode.com/svn-history/r136/trunk/python/google/appengine/tools/https_wrapper.py
# under the following license:
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def _GetValidHostsForCert(self, cert):
"""Returns a list of valid host globs for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
Returns:
list: A list of valid host globs.
"""
if 'subjectAltName' in cert:
return [x[1] for x in cert['subjectAltName']
if x[0].lower() == 'dns']
else:
return [x[0][1] for x in cert['subject']
if x[0][0].lower() == 'commonname']
def _ValidateCertificateHostname(self, cert, hostname):
"""Validates that a given hostname is valid for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
hostname: The hostname to test.
Returns:
bool: Whether or not the hostname is valid for this certificate.
"""
hosts = self._GetValidHostsForCert(cert)
for host in hosts:
host_re = host.replace('.', '\.').replace('*', '[^.]*')
if re.search('^%s$' % (host_re,), hostname, re.I):
return True
return False
def connect(self):
"Connect to a host on a given (SSL) port."
msg = "getaddrinfo returns an empty list"
for family, socktype, proto, canonname, sockaddr in socket.getaddrinfo(
self.host, self.port, 0, socket.SOCK_STREAM):
try:
if self.proxy_info and self.proxy_info.isgood():
sock = socks.socksocket(family, socktype, proto)
sock.setproxy(*self.proxy_info.astuple())
else:
sock = socket.socket(family, socktype, proto)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
if has_timeout(self.timeout):
sock.settimeout(self.timeout)
sock.connect((self.host, self.port))
self.sock =_ssl_wrap_socket(
sock, self.key_file, self.cert_file,
self.disable_ssl_certificate_validation, self.ca_certs)
if self.debuglevel > 0:
print "connect: (%s, %s)" % (self.host, self.port)
if not self.disable_ssl_certificate_validation:
cert = self.sock.getpeercert()
hostname = self.host.split(':', 0)[0]
if not self._ValidateCertificateHostname(cert, hostname):
raise CertificateHostnameMismatch(
'Server presented certificate that does not match '
'host %s: %s' % (hostname, cert), hostname, cert)
except ssl_SSLError, e:
if sock:
sock.close()
if self.sock:
self.sock.close()
self.sock = None
# Unfortunately the ssl module doesn't seem to provide any way
# to get at more detailed error information, in particular
# whether the error is due to certificate validation or
# something else (such as SSL protocol mismatch).
if e.errno == ssl.SSL_ERROR_SSL:
raise SSLHandshakeError(e)
else:
raise
except (socket.timeout, socket.gaierror):
raise
except socket.error, msg:
if self.debuglevel > 0:
print 'connect fail:', (self.host, self.port)
if self.sock:
self.sock.close()
self.sock = None
continue
break
if not self.sock:
raise socket.error, msg
SCHEME_TO_CONNECTION = {
'http': HTTPConnectionWithTimeout,
'https': HTTPSConnectionWithTimeout
}
# Use a different connection object for Google App Engine
try:
from google.appengine.api import apiproxy_stub_map
if apiproxy_stub_map.apiproxy.GetStub('urlfetch') is None:
raise ImportError # Bail out; we're not actually running on App Engine.
from google.appengine.api.urlfetch import fetch
from google.appengine.api.urlfetch import InvalidURLError
from google.appengine.api.urlfetch import DownloadError
from google.appengine.api.urlfetch import ResponseTooLargeError
from google.appengine.api.urlfetch import SSLCertificateError
class ResponseDict(dict):
"""Is a dictionary that also has a read() method, so
that it can pass itself off as an httlib.HTTPResponse()."""
def read(self):
pass
class AppEngineHttpConnection(object):
"""Emulates an httplib.HTTPConnection object, but actually uses the Google
App Engine urlfetch library. This allows the timeout to be properly used on
Google App Engine, and avoids using httplib, which on Google App Engine is
just another wrapper around urlfetch.
"""
def __init__(self, host, port=None, key_file=None, cert_file=None,
strict=None, timeout=None, proxy_info=None, ca_certs=None,
disable_certificate_validation=False):
self.host = host
self.port = port
self.timeout = timeout
if key_file or cert_file or proxy_info or ca_certs:
raise NotSupportedOnThisPlatform()
self.response = None
self.scheme = 'http'
self.validate_certificate = not disable_certificate_validation
self.sock = True
def request(self, method, url, body, headers):
# Calculate the absolute URI, which fetch requires
netloc = self.host
if self.port:
netloc = '%s:%s' % (self.host, self.port)
absolute_uri = '%s://%s%s' % (self.scheme, netloc, url)
try:
response = fetch(absolute_uri, payload=body, method=method,
headers=headers, allow_truncated=False, follow_redirects=False,
deadline=self.timeout,
validate_certificate=self.validate_certificate)
self.response = ResponseDict(response.headers)
self.response['status'] = str(response.status_code)
self.response.status = response.status_code
setattr(self.response, 'read', lambda : response.content)
# Make sure the exceptions raised match the exceptions expected.
except InvalidURLError:
raise socket.gaierror('')
except (DownloadError, ResponseTooLargeError, SSLCertificateError):
raise httplib.HTTPException()
def getresponse(self):
if self.response:
return self.response
else:
raise httplib.HTTPException()
def set_debuglevel(self, level):
pass
def connect(self):
pass
def close(self):
pass
class AppEngineHttpsConnection(AppEngineHttpConnection):
"""Same as AppEngineHttpConnection, but for HTTPS URIs."""
def __init__(self, host, port=None, key_file=None, cert_file=None,
strict=None, timeout=None, proxy_info=None):
AppEngineHttpConnection.__init__(self, host, port, key_file, cert_file,
strict, timeout, proxy_info)
self.scheme = 'https'
# Update the connection classes to use the Googel App Engine specific ones.
SCHEME_TO_CONNECTION = {
'http': AppEngineHttpConnection,
'https': AppEngineHttpsConnection
}
except ImportError:
pass
class Http(object):
"""An HTTP client that handles:
- all methods
- caching
- ETags
- compression,
- HTTPS
- Basic
- Digest
- WSSE
and more.
"""
def __init__(self, cache=None, timeout=None, proxy_info=None,
ca_certs=None, disable_ssl_certificate_validation=False):
"""
The value of proxy_info is a ProxyInfo instance.
If 'cache' is a string then it is used as a directory name for
a disk cache. Otherwise it must be an object that supports the
same interface as FileCache.
All timeouts are in seconds. If None is passed for timeout
then Python's default timeout for sockets will be used. See
for example the docs of socket.setdefaulttimeout():
http://docs.python.org/library/socket.html#socket.setdefaulttimeout
ca_certs is the path of a file containing root CA certificates for SSL
server certificate validation. By default, a CA cert file bundled with
httplib2 is used.
If disable_ssl_certificate_validation is true, SSL cert validation will
not be performed.
"""
self.proxy_info = proxy_info
self.ca_certs = ca_certs
self.disable_ssl_certificate_validation = \
disable_ssl_certificate_validation
# Map domain name to an httplib connection
self.connections = {}
# The location of the cache, for now a directory
# where cached responses are held.
if cache and isinstance(cache, basestring):
self.cache = FileCache(cache)
else:
self.cache = cache
# Name/password
self.credentials = Credentials()
# Key/cert
self.certificates = KeyCerts()
# authorization objects
self.authorizations = []
# If set to False then no redirects are followed, even safe ones.
self.follow_redirects = True
# Which HTTP methods do we apply optimistic concurrency to, i.e.
# which methods get an "if-match:" etag header added to them.
self.optimistic_concurrency_methods = ["PUT", "PATCH"]
# If 'follow_redirects' is True, and this is set to True then
# all redirecs are followed, including unsafe ones.
self.follow_all_redirects = False
self.ignore_etag = False
self.force_exception_to_status_code = False
self.timeout = timeout
def _auth_from_challenge(self, host, request_uri, headers, response, content):
"""A generator that creates Authorization objects
that can be applied to requests.
"""
challenges = _parse_www_authenticate(response, 'www-authenticate')
for cred in self.credentials.iter(host):
for scheme in AUTH_SCHEME_ORDER:
if challenges.has_key(scheme):
yield AUTH_SCHEME_CLASSES[scheme](cred, host, request_uri, headers, response, content, self)
def add_credentials(self, name, password, domain=""):
"""Add a name and password that will be used
any time a request requires authentication."""
self.credentials.add(name, password, domain)
def add_certificate(self, key, cert, domain):
"""Add a key and cert that will be used
any time a request requires authentication."""
self.certificates.add(key, cert, domain)
def clear_credentials(self):
"""Remove all the names and passwords
that are used for authentication"""
self.credentials.clear()
self.authorizations = []
def _conn_request(self, conn, request_uri, method, body, headers):
for i in range(2):
try:
if conn.sock is None:
conn.connect()
conn.request(method, request_uri, body, headers)
except socket.timeout:
raise
except socket.gaierror:
conn.close()
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
except ssl_SSLError:
conn.close()
raise
except socket.error, e:
err = 0
if hasattr(e, 'args'):
err = getattr(e, 'args')[0]
else:
err = e.errno
if err == errno.ECONNREFUSED: # Connection refused
raise
except httplib.HTTPException:
# Just because the server closed the connection doesn't apparently mean
# that the server didn't send a response.
if conn.sock is None:
if i == 0:
conn.close()
conn.connect()
continue
else:
conn.close()
raise
if i == 0:
conn.close()
conn.connect()
continue
try:
response = conn.getresponse()
except (socket.error, httplib.HTTPException):
if i == 0:
conn.close()
conn.connect()
continue
else:
raise
else:
content = ""
if method == "HEAD":
response.close()
else:
content = response.read()
response = Response(response)
if method != "HEAD":
content = _decompressContent(response, content)
break
return (response, content)
def _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey):
"""Do the actual request using the connection object
and also follow one level of redirects if necessary"""
auths = [(auth.depth(request_uri), auth) for auth in self.authorizations if auth.inscope(host, request_uri)]
auth = auths and sorted(auths)[0][1] or None
if auth:
auth.request(method, request_uri, headers, body)
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
if auth:
if auth.response(response, body):
auth.request(method, request_uri, headers, body)
(response, content) = self._conn_request(conn, request_uri, method, body, headers )
response._stale_digest = 1
if response.status == 401:
for authorization in self._auth_from_challenge(host, request_uri, headers, response, content):
authorization.request(method, request_uri, headers, body)
(response, content) = self._conn_request(conn, request_uri, method, body, headers, )
if response.status != 401:
self.authorizations.append(authorization)
authorization.response(response, body)
break
if (self.follow_all_redirects or (method in ["GET", "HEAD"]) or response.status == 303):
if self.follow_redirects and response.status in [300, 301, 302, 303, 307]:
# Pick out the location header and basically start from the beginning
# remembering first to strip the ETag header and decrement our 'depth'
if redirections:
if not response.has_key('location') and response.status != 300:
raise RedirectMissingLocation( _("Redirected but the response is missing a Location: header."), response, content)
# Fix-up relative redirects (which violate an RFC 2616 MUST)
if response.has_key('location'):
location = response['location']
(scheme, authority, path, query, fragment) = parse_uri(location)
if authority == None:
response['location'] = urlparse.urljoin(absolute_uri, location)
if response.status == 301 and method in ["GET", "HEAD"]:
response['-x-permanent-redirect-url'] = response['location']
if not response.has_key('content-location'):
response['content-location'] = absolute_uri
_updateCache(headers, response, content, self.cache, cachekey)
if headers.has_key('if-none-match'):
del headers['if-none-match']
if headers.has_key('if-modified-since'):
del headers['if-modified-since']
if response.has_key('location'):
location = response['location']
old_response = copy.deepcopy(response)
if not old_response.has_key('content-location'):
old_response['content-location'] = absolute_uri
redirect_method = method
if response.status in [302, 303]:
redirect_method = "GET"
body = None
(response, content) = self.request(location, redirect_method, body=body, headers = headers, redirections = redirections - 1)
response.previous = old_response
else:
raise RedirectLimit("Redirected more times than rediection_limit allows.", response, content)
elif response.status in [200, 203] and method in ["GET", "HEAD"]:
# Don't cache 206's since we aren't going to handle byte range requests
if not response.has_key('content-location'):
response['content-location'] = absolute_uri
_updateCache(headers, response, content, self.cache, cachekey)
return (response, content)
def _normalize_headers(self, headers):
return _normalize_headers(headers)
# Need to catch and rebrand some exceptions
# Then need to optionally turn all exceptions into status codes
# including all socket.* and httplib.* exceptions.
def request(self, uri, method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None):
""" Performs a single HTTP request.
The 'uri' is the URI of the HTTP resource and can begin
with either 'http' or 'https'. The value of 'uri' must be an absolute URI.
The 'method' is the HTTP method to perform, such as GET, POST, DELETE, etc.
There is no restriction on the methods allowed.
The 'body' is the entity body to be sent with the request. It is a string
object.
Any extra headers that are to be sent with the request should be provided in the
'headers' dictionary.
The maximum number of redirect to follow before raising an
exception is 'redirections. The default is 5.
The return value is a tuple of (response, content), the first
being and instance of the 'Response' class, the second being
a string that contains the response entity body.
"""
try:
if headers is None:
headers = {}
else:
headers = self._normalize_headers(headers)
if not headers.has_key('user-agent'):
headers['user-agent'] = "Python-httplib2/%s (gzip)" % __version__
uri = iri2uri(uri)
(scheme, authority, request_uri, defrag_uri) = urlnorm(uri)
domain_port = authority.split(":")[0:2]
if len(domain_port) == 2 and domain_port[1] == '443' and scheme == 'http':
scheme = 'https'
authority = domain_port[0]
conn_key = scheme+":"+authority
if conn_key in self.connections:
conn = self.connections[conn_key]
else:
if not connection_type:
connection_type = SCHEME_TO_CONNECTION[scheme]
certs = list(self.certificates.iter(authority))
if issubclass(connection_type, HTTPSConnectionWithTimeout):
if certs:
conn = self.connections[conn_key] = connection_type(
authority, key_file=certs[0][0],
cert_file=certs[0][1], timeout=self.timeout,
proxy_info=self.proxy_info,
ca_certs=self.ca_certs,
disable_ssl_certificate_validation=
self.disable_ssl_certificate_validation)
else:
conn = self.connections[conn_key] = connection_type(
authority, timeout=self.timeout,
proxy_info=self.proxy_info,
ca_certs=self.ca_certs,
disable_ssl_certificate_validation=
self.disable_ssl_certificate_validation)
else:
conn = self.connections[conn_key] = connection_type(
authority, timeout=self.timeout,
proxy_info=self.proxy_info)
conn.set_debuglevel(debuglevel)
if 'range' not in headers and 'accept-encoding' not in headers:
headers['accept-encoding'] = 'gzip, deflate'
info = email.Message.Message()
cached_value = None
if self.cache:
cachekey = defrag_uri
cached_value = self.cache.get(cachekey)
if cached_value:
# info = email.message_from_string(cached_value)
#
# Need to replace the line above with the kludge below
# to fix the non-existent bug not fixed in this
# bug report: http://mail.python.org/pipermail/python-bugs-list/2005-September/030289.html
try:
info, content = cached_value.split('\r\n\r\n', 1)
feedparser = email.FeedParser.FeedParser()
feedparser.feed(info)
info = feedparser.close()
feedparser._parse = None
except IndexError:
self.cache.delete(cachekey)
cachekey = None
cached_value = None
else:
cachekey = None
if method in self.optimistic_concurrency_methods and self.cache and info.has_key('etag') and not self.ignore_etag and 'if-match' not in headers:
# http://www.w3.org/1999/04/Editing/
headers['if-match'] = info['etag']
if method not in ["GET", "HEAD"] and self.cache and cachekey:
# RFC 2616 Section 13.10
self.cache.delete(cachekey)
# Check the vary header in the cache to see if this request
# matches what varies in the cache.
if method in ['GET', 'HEAD'] and 'vary' in info:
vary = info['vary']
vary_headers = vary.lower().replace(' ', '').split(',')
for header in vary_headers:
key = '-varied-%s' % header
value = info[key]
if headers.get(header, None) != value:
cached_value = None
break
if cached_value and method in ["GET", "HEAD"] and self.cache and 'range' not in headers:
if info.has_key('-x-permanent-redirect-url'):
# Should cached permanent redirects be counted in our redirection count? For now, yes.
if redirections <= 0:
raise RedirectLimit("Redirected more times than rediection_limit allows.", {}, "")
(response, new_content) = self.request(info['-x-permanent-redirect-url'], "GET", headers = headers, redirections = redirections - 1)
response.previous = Response(info)
response.previous.fromcache = True
else:
# Determine our course of action:
# Is the cached entry fresh or stale?
# Has the client requested a non-cached response?
#
# There seems to be three possible answers:
# 1. [FRESH] Return the cache entry w/o doing a GET
# 2. [STALE] Do the GET (but add in cache validators if available)
# 3. [TRANSPARENT] Do a GET w/o any cache validators (Cache-Control: no-cache) on the request
entry_disposition = _entry_disposition(info, headers)
if entry_disposition == "FRESH":
if not cached_value:
info['status'] = '504'
content = ""
response = Response(info)
if cached_value:
response.fromcache = True
return (response, content)
if entry_disposition == "STALE":
if info.has_key('etag') and not self.ignore_etag and not 'if-none-match' in headers:
headers['if-none-match'] = info['etag']
if info.has_key('last-modified') and not 'last-modified' in headers:
headers['if-modified-since'] = info['last-modified']
elif entry_disposition == "TRANSPARENT":
pass
(response, new_content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
if response.status == 304 and method == "GET":
# Rewrite the cache entry with the new end-to-end headers
# Take all headers that are in response
# and overwrite their values in info.
# unless they are hop-by-hop, or are listed in the connection header.
for key in _get_end2end_headers(response):
info[key] = response[key]
merged_response = Response(info)
if hasattr(response, "_stale_digest"):
merged_response._stale_digest = response._stale_digest
_updateCache(headers, merged_response, content, self.cache, cachekey)
response = merged_response
response.status = 200
response.fromcache = True
elif response.status == 200:
content = new_content
else:
self.cache.delete(cachekey)
content = new_content
else:
cc = _parse_cache_control(headers)
if cc.has_key('only-if-cached'):
info['status'] = '504'
response = Response(info)
content = ""
else:
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
except Exception, e:
if self.force_exception_to_status_code:
if isinstance(e, HttpLib2ErrorWithResponse):
response = e.response
content = e.content
response.status = 500
response.reason = str(e)
elif isinstance(e, socket.timeout):
content = "Request Timeout"
response = Response( {
"content-type": "text/plain",
"status": "408",
"content-length": len(content)
})
response.reason = "Request Timeout"
else:
content = str(e)
response = Response( {
"content-type": "text/plain",
"status": "400",
"content-length": len(content)
})
response.reason = "Bad Request"
else:
raise
return (response, content)
class Response(dict):
"""An object more like email.Message than httplib.HTTPResponse."""
"""Is this response from our local cache"""
fromcache = False
"""HTTP protocol version used by server. 10 for HTTP/1.0, 11 for HTTP/1.1. """
version = 11
"Status code returned by server. "
status = 200
"""Reason phrase returned by server."""
reason = "Ok"
previous = None
def __init__(self, info):
# info is either an email.Message or
# an httplib.HTTPResponse object.
if isinstance(info, httplib.HTTPResponse):
for key, value in info.getheaders():
self[key.lower()] = value
self.status = info.status
self['status'] = str(self.status)
self.reason = info.reason
self.version = info.version
elif isinstance(info, email.Message.Message):
for key, value in info.items():
self[key] = value
self.status = int(self['status'])
else:
for key, value in info.iteritems():
self[key] = value
self.status = int(self.get('status', self.status))
def __getattr__(self, name):
if name == 'dict':
return self
else:
raise AttributeError, name
| Python |
#!/usr/bin/env python
#
# Copyright (c) 2002, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ---
# Author: Chad Lester
# Design and style contributions by:
# Amit Patel, Bogdan Cocosel, Daniel Dulitz, Eric Tiedemann,
# Eric Veach, Laurence Gonsalves, Matthew Springer
# Code reorganized a bit by Craig Silverstein
"""This module is used to define and parse command line flags.
This module defines a *distributed* flag-definition policy: rather than
an application having to define all flags in or near main(), each python
module defines flags that are useful to it. When one python module
imports another, it gains access to the other's flags. (This is
implemented by having all modules share a common, global registry object
containing all the flag information.)
Flags are defined through the use of one of the DEFINE_xxx functions.
The specific function used determines how the flag is parsed, checked,
and optionally type-converted, when it's seen on the command line.
IMPLEMENTATION: DEFINE_* creates a 'Flag' object and registers it with a
'FlagValues' object (typically the global FlagValues FLAGS, defined
here). The 'FlagValues' object can scan the command line arguments and
pass flag arguments to the corresponding 'Flag' objects for
value-checking and type conversion. The converted flag values are
available as attributes of the 'FlagValues' object.
Code can access the flag through a FlagValues object, for instance
gflags.FLAGS.myflag. Typically, the __main__ module passes the command
line arguments to gflags.FLAGS for parsing.
At bottom, this module calls getopt(), so getopt functionality is
supported, including short- and long-style flags, and the use of -- to
terminate flags.
Methods defined by the flag module will throw 'FlagsError' exceptions.
The exception argument will be a human-readable string.
FLAG TYPES: This is a list of the DEFINE_*'s that you can do. All flags
take a name, default value, help-string, and optional 'short' name
(one-letter name). Some flags have other arguments, which are described
with the flag.
DEFINE_string: takes any input, and interprets it as a string.
DEFINE_bool or
DEFINE_boolean: typically does not take an argument: say --myflag to
set FLAGS.myflag to true, or --nomyflag to set
FLAGS.myflag to false. Alternately, you can say
--myflag=true or --myflag=t or --myflag=1 or
--myflag=false or --myflag=f or --myflag=0
DEFINE_float: takes an input and interprets it as a floating point
number. Takes optional args lower_bound and upper_bound;
if the number specified on the command line is out of
range, it will raise a FlagError.
DEFINE_integer: takes an input and interprets it as an integer. Takes
optional args lower_bound and upper_bound as for floats.
DEFINE_enum: takes a list of strings which represents legal values. If
the command-line value is not in this list, raise a flag
error. Otherwise, assign to FLAGS.flag as a string.
DEFINE_list: Takes a comma-separated list of strings on the commandline.
Stores them in a python list object.
DEFINE_spaceseplist: Takes a space-separated list of strings on the
commandline. Stores them in a python list object.
Example: --myspacesepflag "foo bar baz"
DEFINE_multistring: The same as DEFINE_string, except the flag can be
specified more than once on the commandline. The
result is a python list object (list of strings),
even if the flag is only on the command line once.
DEFINE_multi_int: The same as DEFINE_integer, except the flag can be
specified more than once on the commandline. The
result is a python list object (list of ints), even if
the flag is only on the command line once.
SPECIAL FLAGS: There are a few flags that have special meaning:
--help prints a list of all the flags in a human-readable fashion
--helpshort prints a list of all key flags (see below).
--helpxml prints a list of all flags, in XML format. DO NOT parse
the output of --help and --helpshort. Instead, parse
the output of --helpxml. For more info, see
"OUTPUT FOR --helpxml" below.
--flagfile=foo read flags from file foo.
--undefok=f1,f2 ignore unrecognized option errors for f1,f2.
For boolean flags, you should use --undefok=boolflag, and
--boolflag and --noboolflag will be accepted. Do not use
--undefok=noboolflag.
-- as in getopt(), terminates flag-processing
FLAGS VALIDATORS: If your program:
- requires flag X to be specified
- needs flag Y to match a regular expression
- or requires any more general constraint to be satisfied
then validators are for you!
Each validator represents a constraint over one flag, which is enforced
starting from the initial parsing of the flags and until the program
terminates.
Also, lower_bound and upper_bound for numerical flags are enforced using flag
validators.
Howto:
If you want to enforce a constraint over one flag, use
gflags.RegisterValidator(flag_name,
checker,
message='Flag validation failed',
flag_values=FLAGS)
After flag values are initially parsed, and after any change to the specified
flag, method checker(flag_value) will be executed. If constraint is not
satisfied, an IllegalFlagValue exception will be raised. See
RegisterValidator's docstring for a detailed explanation on how to construct
your own checker.
EXAMPLE USAGE:
FLAGS = gflags.FLAGS
gflags.DEFINE_integer('my_version', 0, 'Version number.')
gflags.DEFINE_string('filename', None, 'Input file name', short_name='f')
gflags.RegisterValidator('my_version',
lambda value: value % 2 == 0,
message='--my_version must be divisible by 2')
gflags.MarkFlagAsRequired('filename')
NOTE ON --flagfile:
Flags may be loaded from text files in addition to being specified on
the commandline.
Any flags you don't feel like typing, throw them in a file, one flag per
line, for instance:
--myflag=myvalue
--nomyboolean_flag
You then specify your file with the special flag '--flagfile=somefile'.
You CAN recursively nest flagfile= tokens OR use multiple files on the
command line. Lines beginning with a single hash '#' or a double slash
'//' are comments in your flagfile.
Any flagfile=<file> will be interpreted as having a relative path from
the current working directory rather than from the place the file was
included from:
myPythonScript.py --flagfile=config/somefile.cfg
If somefile.cfg includes further --flagfile= directives, these will be
referenced relative to the original CWD, not from the directory the
including flagfile was found in!
The caveat applies to people who are including a series of nested files
in a different dir than they are executing out of. Relative path names
are always from CWD, not from the directory of the parent include
flagfile. We do now support '~' expanded directory names.
Absolute path names ALWAYS work!
EXAMPLE USAGE:
FLAGS = gflags.FLAGS
# Flag names are globally defined! So in general, we need to be
# careful to pick names that are unlikely to be used by other libraries.
# If there is a conflict, we'll get an error at import time.
gflags.DEFINE_string('name', 'Mr. President', 'your name')
gflags.DEFINE_integer('age', None, 'your age in years', lower_bound=0)
gflags.DEFINE_boolean('debug', False, 'produces debugging output')
gflags.DEFINE_enum('gender', 'male', ['male', 'female'], 'your gender')
def main(argv):
try:
argv = FLAGS(argv) # parse flags
except gflags.FlagsError, e:
print '%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS)
sys.exit(1)
if FLAGS.debug: print 'non-flag arguments:', argv
print 'Happy Birthday', FLAGS.name
if FLAGS.age is not None:
print 'You are a %d year old %s' % (FLAGS.age, FLAGS.gender)
if __name__ == '__main__':
main(sys.argv)
KEY FLAGS:
As we already explained, each module gains access to all flags defined
by all the other modules it transitively imports. In the case of
non-trivial scripts, this means a lot of flags ... For documentation
purposes, it is good to identify the flags that are key (i.e., really
important) to a module. Clearly, the concept of "key flag" is a
subjective one. When trying to determine whether a flag is key to a
module or not, assume that you are trying to explain your module to a
potential user: which flags would you really like to mention first?
We'll describe shortly how to declare which flags are key to a module.
For the moment, assume we know the set of key flags for each module.
Then, if you use the app.py module, you can use the --helpshort flag to
print only the help for the flags that are key to the main module, in a
human-readable format.
NOTE: If you need to parse the flag help, do NOT use the output of
--help / --helpshort. That output is meant for human consumption, and
may be changed in the future. Instead, use --helpxml; flags that are
key for the main module are marked there with a <key>yes</key> element.
The set of key flags for a module M is composed of:
1. Flags defined by module M by calling a DEFINE_* function.
2. Flags that module M explictly declares as key by using the function
DECLARE_key_flag(<flag_name>)
3. Key flags of other modules that M specifies by using the function
ADOPT_module_key_flags(<other_module>)
This is a "bulk" declaration of key flags: each flag that is key for
<other_module> becomes key for the current module too.
Notice that if you do not use the functions described at points 2 and 3
above, then --helpshort prints information only about the flags defined
by the main module of our script. In many cases, this behavior is good
enough. But if you move part of the main module code (together with the
related flags) into a different module, then it is nice to use
DECLARE_key_flag / ADOPT_module_key_flags and make sure --helpshort
lists all relevant flags (otherwise, your code refactoring may confuse
your users).
Note: each of DECLARE_key_flag / ADOPT_module_key_flags has its own
pluses and minuses: DECLARE_key_flag is more targeted and may lead a
more focused --helpshort documentation. ADOPT_module_key_flags is good
for cases when an entire module is considered key to the current script.
Also, it does not require updates to client scripts when a new flag is
added to the module.
EXAMPLE USAGE 2 (WITH KEY FLAGS):
Consider an application that contains the following three files (two
auxiliary modules and a main module)
File libfoo.py:
import gflags
gflags.DEFINE_integer('num_replicas', 3, 'Number of replicas to start')
gflags.DEFINE_boolean('rpc2', True, 'Turn on the usage of RPC2.')
... some code ...
File libbar.py:
import gflags
gflags.DEFINE_string('bar_gfs_path', '/gfs/path',
'Path to the GFS files for libbar.')
gflags.DEFINE_string('email_for_bar_errors', 'bar-team@google.com',
'Email address for bug reports about module libbar.')
gflags.DEFINE_boolean('bar_risky_hack', False,
'Turn on an experimental and buggy optimization.')
... some code ...
File myscript.py:
import gflags
import libfoo
import libbar
gflags.DEFINE_integer('num_iterations', 0, 'Number of iterations.')
# Declare that all flags that are key for libfoo are
# key for this module too.
gflags.ADOPT_module_key_flags(libfoo)
# Declare that the flag --bar_gfs_path (defined in libbar) is key
# for this module.
gflags.DECLARE_key_flag('bar_gfs_path')
... some code ...
When myscript is invoked with the flag --helpshort, the resulted help
message lists information about all the key flags for myscript:
--num_iterations, --num_replicas, --rpc2, and --bar_gfs_path.
Of course, myscript uses all the flags declared by it (in this case,
just --num_replicas) or by any of the modules it transitively imports
(e.g., the modules libfoo, libbar). E.g., it can access the value of
FLAGS.bar_risky_hack, even if --bar_risky_hack is not declared as a key
flag for myscript.
OUTPUT FOR --helpxml:
The --helpxml flag generates output with the following structure:
<?xml version="1.0"?>
<AllFlags>
<program>PROGRAM_BASENAME</program>
<usage>MAIN_MODULE_DOCSTRING</usage>
(<flag>
[<key>yes</key>]
<file>DECLARING_MODULE</file>
<name>FLAG_NAME</name>
<meaning>FLAG_HELP_MESSAGE</meaning>
<default>DEFAULT_FLAG_VALUE</default>
<current>CURRENT_FLAG_VALUE</current>
<type>FLAG_TYPE</type>
[OPTIONAL_ELEMENTS]
</flag>)*
</AllFlags>
Notes:
1. The output is intentionally similar to the output generated by the
C++ command-line flag library. The few differences are due to the
Python flags that do not have a C++ equivalent (at least not yet),
e.g., DEFINE_list.
2. New XML elements may be added in the future.
3. DEFAULT_FLAG_VALUE is in serialized form, i.e., the string you can
pass for this flag on the command-line. E.g., for a flag defined
using DEFINE_list, this field may be foo,bar, not ['foo', 'bar'].
4. CURRENT_FLAG_VALUE is produced using str(). This means that the
string 'false' will be represented in the same way as the boolean
False. Using repr() would have removed this ambiguity and simplified
parsing, but would have broken the compatibility with the C++
command-line flags.
5. OPTIONAL_ELEMENTS describe elements relevant for certain kinds of
flags: lower_bound, upper_bound (for flags that specify bounds),
enum_value (for enum flags), list_separator (for flags that consist of
a list of values, separated by a special token).
6. We do not provide any example here: please use --helpxml instead.
This module requires at least python 2.2.1 to run.
"""
import cgi
import getopt
import os
import re
import string
import struct
import sys
# pylint: disable-msg=C6204
try:
import fcntl
except ImportError:
fcntl = None
try:
# Importing termios will fail on non-unix platforms.
import termios
except ImportError:
termios = None
import gflags_validators
# pylint: enable-msg=C6204
# Are we running under pychecker?
_RUNNING_PYCHECKER = 'pychecker.python' in sys.modules
def _GetCallingModuleObjectAndName():
"""Returns the module that's calling into this module.
We generally use this function to get the name of the module calling a
DEFINE_foo... function.
"""
# Walk down the stack to find the first globals dict that's not ours.
for depth in range(1, sys.getrecursionlimit()):
if not sys._getframe(depth).f_globals is globals():
globals_for_frame = sys._getframe(depth).f_globals
module, module_name = _GetModuleObjectAndName(globals_for_frame)
if module_name is not None:
return module, module_name
raise AssertionError("No module was found")
def _GetCallingModule():
"""Returns the name of the module that's calling into this module."""
return _GetCallingModuleObjectAndName()[1]
def _GetThisModuleObjectAndName():
"""Returns: (module object, module name) for this module."""
return _GetModuleObjectAndName(globals())
# module exceptions:
class FlagsError(Exception):
"""The base class for all flags errors."""
pass
class DuplicateFlag(FlagsError):
"""Raised if there is a flag naming conflict."""
pass
class CantOpenFlagFileError(FlagsError):
"""Raised if flagfile fails to open: doesn't exist, wrong permissions, etc."""
pass
class DuplicateFlagCannotPropagateNoneToSwig(DuplicateFlag):
"""Special case of DuplicateFlag -- SWIG flag value can't be set to None.
This can be raised when a duplicate flag is created. Even if allow_override is
True, we still abort if the new value is None, because it's currently
impossible to pass None default value back to SWIG. See FlagValues.SetDefault
for details.
"""
pass
class DuplicateFlagError(DuplicateFlag):
"""A DuplicateFlag whose message cites the conflicting definitions.
A DuplicateFlagError conveys more information than a DuplicateFlag,
namely the modules where the conflicting definitions occur. This
class was created to avoid breaking external modules which depend on
the existing DuplicateFlags interface.
"""
def __init__(self, flagname, flag_values, other_flag_values=None):
"""Create a DuplicateFlagError.
Args:
flagname: Name of the flag being redefined.
flag_values: FlagValues object containing the first definition of
flagname.
other_flag_values: If this argument is not None, it should be the
FlagValues object where the second definition of flagname occurs.
If it is None, we assume that we're being called when attempting
to create the flag a second time, and we use the module calling
this one as the source of the second definition.
"""
self.flagname = flagname
first_module = flag_values.FindModuleDefiningFlag(
flagname, default='<unknown>')
if other_flag_values is None:
second_module = _GetCallingModule()
else:
second_module = other_flag_values.FindModuleDefiningFlag(
flagname, default='<unknown>')
msg = "The flag '%s' is defined twice. First from %s, Second from %s" % (
self.flagname, first_module, second_module)
DuplicateFlag.__init__(self, msg)
class IllegalFlagValue(FlagsError):
"""The flag command line argument is illegal."""
pass
class UnrecognizedFlag(FlagsError):
"""Raised if a flag is unrecognized."""
pass
# An UnrecognizedFlagError conveys more information than an UnrecognizedFlag.
# Since there are external modules that create DuplicateFlags, the interface to
# DuplicateFlag shouldn't change. The flagvalue will be assigned the full value
# of the flag and its argument, if any, allowing handling of unrecognized flags
# in an exception handler.
# If flagvalue is the empty string, then this exception is an due to a
# reference to a flag that was not already defined.
class UnrecognizedFlagError(UnrecognizedFlag):
def __init__(self, flagname, flagvalue=''):
self.flagname = flagname
self.flagvalue = flagvalue
UnrecognizedFlag.__init__(
self, "Unknown command line flag '%s'" % flagname)
# Global variable used by expvar
_exported_flags = {}
_help_width = 80 # width of help output
def GetHelpWidth():
"""Returns: an integer, the width of help lines that is used in TextWrap."""
if (not sys.stdout.isatty()) or (termios is None) or (fcntl is None):
return _help_width
try:
data = fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, '1234')
columns = struct.unpack('hh', data)[1]
# Emacs mode returns 0.
# Here we assume that any value below 40 is unreasonable
if columns >= 40:
return columns
# Returning an int as default is fine, int(int) just return the int.
return int(os.getenv('COLUMNS', _help_width))
except (TypeError, IOError, struct.error):
return _help_width
def CutCommonSpacePrefix(text):
"""Removes a common space prefix from the lines of a multiline text.
If the first line does not start with a space, it is left as it is and
only in the remaining lines a common space prefix is being searched
for. That means the first line will stay untouched. This is especially
useful to turn doc strings into help texts. This is because some
people prefer to have the doc comment start already after the
apostrophe and then align the following lines while others have the
apostrophes on a separate line.
The function also drops trailing empty lines and ignores empty lines
following the initial content line while calculating the initial
common whitespace.
Args:
text: text to work on
Returns:
the resulting text
"""
text_lines = text.splitlines()
# Drop trailing empty lines
while text_lines and not text_lines[-1]:
text_lines = text_lines[:-1]
if text_lines:
# We got some content, is the first line starting with a space?
if text_lines[0] and text_lines[0][0].isspace():
text_first_line = []
else:
text_first_line = [text_lines.pop(0)]
# Calculate length of common leading whitespace (only over content lines)
common_prefix = os.path.commonprefix([line for line in text_lines if line])
space_prefix_len = len(common_prefix) - len(common_prefix.lstrip())
# If we have a common space prefix, drop it from all lines
if space_prefix_len:
for index in xrange(len(text_lines)):
if text_lines[index]:
text_lines[index] = text_lines[index][space_prefix_len:]
return '\n'.join(text_first_line + text_lines)
return ''
def TextWrap(text, length=None, indent='', firstline_indent=None, tabs=' '):
"""Wraps a given text to a maximum line length and returns it.
We turn lines that only contain whitespace into empty lines. We keep
new lines and tabs (e.g., we do not treat tabs as spaces).
Args:
text: text to wrap
length: maximum length of a line, includes indentation
if this is None then use GetHelpWidth()
indent: indent for all but first line
firstline_indent: indent for first line; if None, fall back to indent
tabs: replacement for tabs
Returns:
wrapped text
Raises:
FlagsError: if indent not shorter than length
FlagsError: if firstline_indent not shorter than length
"""
# Get defaults where callee used None
if length is None:
length = GetHelpWidth()
if indent is None:
indent = ''
if len(indent) >= length:
raise FlagsError('Indent must be shorter than length')
# In line we will be holding the current line which is to be started
# with indent (or firstline_indent if available) and then appended
# with words.
if firstline_indent is None:
firstline_indent = ''
line = indent
else:
line = firstline_indent
if len(firstline_indent) >= length:
raise FlagsError('First line indent must be shorter than length')
# If the callee does not care about tabs we simply convert them to
# spaces If callee wanted tabs to be single space then we do that
# already here.
if not tabs or tabs == ' ':
text = text.replace('\t', ' ')
else:
tabs_are_whitespace = not tabs.strip()
line_regex = re.compile('([ ]*)(\t*)([^ \t]+)', re.MULTILINE)
# Split the text into lines and the lines with the regex above. The
# resulting lines are collected in result[]. For each split we get the
# spaces, the tabs and the next non white space (e.g. next word).
result = []
for text_line in text.splitlines():
# Store result length so we can find out whether processing the next
# line gave any new content
old_result_len = len(result)
# Process next line with line_regex. For optimization we do an rstrip().
# - process tabs (changes either line or word, see below)
# - process word (first try to squeeze on line, then wrap or force wrap)
# Spaces found on the line are ignored, they get added while wrapping as
# needed.
for spaces, current_tabs, word in line_regex.findall(text_line.rstrip()):
# If tabs weren't converted to spaces, handle them now
if current_tabs:
# If the last thing we added was a space anyway then drop
# it. But let's not get rid of the indentation.
if (((result and line != indent) or
(not result and line != firstline_indent)) and line[-1] == ' '):
line = line[:-1]
# Add the tabs, if that means adding whitespace, just add it at
# the line, the rstrip() code while shorten the line down if
# necessary
if tabs_are_whitespace:
line += tabs * len(current_tabs)
else:
# if not all tab replacement is whitespace we prepend it to the word
word = tabs * len(current_tabs) + word
# Handle the case where word cannot be squeezed onto current last line
if len(line) + len(word) > length and len(indent) + len(word) <= length:
result.append(line.rstrip())
line = indent + word
word = ''
# No space left on line or can we append a space?
if len(line) + 1 >= length:
result.append(line.rstrip())
line = indent
else:
line += ' '
# Add word and shorten it up to allowed line length. Restart next
# line with indent and repeat, or add a space if we're done (word
# finished) This deals with words that cannot fit on one line
# (e.g. indent + word longer than allowed line length).
while len(line) + len(word) >= length:
line += word
result.append(line[:length])
word = line[length:]
line = indent
# Default case, simply append the word and a space
if word:
line += word + ' '
# End of input line. If we have content we finish the line. If the
# current line is just the indent but we had content in during this
# original line then we need to add an empty line.
if (result and line != indent) or (not result and line != firstline_indent):
result.append(line.rstrip())
elif len(result) == old_result_len:
result.append('')
line = indent
return '\n'.join(result)
def DocToHelp(doc):
"""Takes a __doc__ string and reformats it as help."""
# Get rid of starting and ending white space. Using lstrip() or even
# strip() could drop more than maximum of first line and right space
# of last line.
doc = doc.strip()
# Get rid of all empty lines
whitespace_only_line = re.compile('^[ \t]+$', re.M)
doc = whitespace_only_line.sub('', doc)
# Cut out common space at line beginnings
doc = CutCommonSpacePrefix(doc)
# Just like this module's comment, comments tend to be aligned somehow.
# In other words they all start with the same amount of white space
# 1) keep double new lines
# 2) keep ws after new lines if not empty line
# 3) all other new lines shall be changed to a space
# Solution: Match new lines between non white space and replace with space.
doc = re.sub('(?<=\S)\n(?=\S)', ' ', doc, re.M)
return doc
def _GetModuleObjectAndName(globals_dict):
"""Returns the module that defines a global environment, and its name.
Args:
globals_dict: A dictionary that should correspond to an environment
providing the values of the globals.
Returns:
A pair consisting of (1) module object and (2) module name (a
string). Returns (None, None) if the module could not be
identified.
"""
# The use of .items() (instead of .iteritems()) is NOT a mistake: if
# a parallel thread imports a module while we iterate over
# .iteritems() (not nice, but possible), we get a RuntimeError ...
# Hence, we use the slightly slower but safer .items().
for name, module in sys.modules.items():
if getattr(module, '__dict__', None) is globals_dict:
if name == '__main__':
# Pick a more informative name for the main module.
name = sys.argv[0]
return (module, name)
return (None, None)
def _GetMainModule():
"""Returns: string, name of the module from which execution started."""
# First, try to use the same logic used by _GetCallingModuleObjectAndName(),
# i.e., call _GetModuleObjectAndName(). For that we first need to
# find the dictionary that the main module uses to store the
# globals.
#
# That's (normally) the same dictionary object that the deepest
# (oldest) stack frame is using for globals.
deepest_frame = sys._getframe(0)
while deepest_frame.f_back is not None:
deepest_frame = deepest_frame.f_back
globals_for_main_module = deepest_frame.f_globals
main_module_name = _GetModuleObjectAndName(globals_for_main_module)[1]
# The above strategy fails in some cases (e.g., tools that compute
# code coverage by redefining, among other things, the main module).
# If so, just use sys.argv[0]. We can probably always do this, but
# it's safest to try to use the same logic as _GetCallingModuleObjectAndName()
if main_module_name is None:
main_module_name = sys.argv[0]
return main_module_name
class FlagValues:
"""Registry of 'Flag' objects.
A 'FlagValues' can then scan command line arguments, passing flag
arguments through to the 'Flag' objects that it owns. It also
provides easy access to the flag values. Typically only one
'FlagValues' object is needed by an application: gflags.FLAGS
This class is heavily overloaded:
'Flag' objects are registered via __setitem__:
FLAGS['longname'] = x # register a new flag
The .value attribute of the registered 'Flag' objects can be accessed
as attributes of this 'FlagValues' object, through __getattr__. Both
the long and short name of the original 'Flag' objects can be used to
access its value:
FLAGS.longname # parsed flag value
FLAGS.x # parsed flag value (short name)
Command line arguments are scanned and passed to the registered 'Flag'
objects through the __call__ method. Unparsed arguments, including
argv[0] (e.g. the program name) are returned.
argv = FLAGS(sys.argv) # scan command line arguments
The original registered Flag objects can be retrieved through the use
of the dictionary-like operator, __getitem__:
x = FLAGS['longname'] # access the registered Flag object
The str() operator of a 'FlagValues' object provides help for all of
the registered 'Flag' objects.
"""
def __init__(self):
# Since everything in this class is so heavily overloaded, the only
# way of defining and using fields is to access __dict__ directly.
# Dictionary: flag name (string) -> Flag object.
self.__dict__['__flags'] = {}
# Dictionary: module name (string) -> list of Flag objects that are defined
# by that module.
self.__dict__['__flags_by_module'] = {}
# Dictionary: module id (int) -> list of Flag objects that are defined by
# that module.
self.__dict__['__flags_by_module_id'] = {}
# Dictionary: module name (string) -> list of Flag objects that are
# key for that module.
self.__dict__['__key_flags_by_module'] = {}
# Set if we should use new style gnu_getopt rather than getopt when parsing
# the args. Only possible with Python 2.3+
self.UseGnuGetOpt(False)
def UseGnuGetOpt(self, use_gnu_getopt=True):
"""Use GNU-style scanning. Allows mixing of flag and non-flag arguments.
See http://docs.python.org/library/getopt.html#getopt.gnu_getopt
Args:
use_gnu_getopt: wether or not to use GNU style scanning.
"""
self.__dict__['__use_gnu_getopt'] = use_gnu_getopt
def IsGnuGetOpt(self):
return self.__dict__['__use_gnu_getopt']
def FlagDict(self):
return self.__dict__['__flags']
def FlagsByModuleDict(self):
"""Returns the dictionary of module_name -> list of defined flags.
Returns:
A dictionary. Its keys are module names (strings). Its values
are lists of Flag objects.
"""
return self.__dict__['__flags_by_module']
def FlagsByModuleIdDict(self):
"""Returns the dictionary of module_id -> list of defined flags.
Returns:
A dictionary. Its keys are module IDs (ints). Its values
are lists of Flag objects.
"""
return self.__dict__['__flags_by_module_id']
def KeyFlagsByModuleDict(self):
"""Returns the dictionary of module_name -> list of key flags.
Returns:
A dictionary. Its keys are module names (strings). Its values
are lists of Flag objects.
"""
return self.__dict__['__key_flags_by_module']
def _RegisterFlagByModule(self, module_name, flag):
"""Records the module that defines a specific flag.
We keep track of which flag is defined by which module so that we
can later sort the flags by module.
Args:
module_name: A string, the name of a Python module.
flag: A Flag object, a flag that is key to the module.
"""
flags_by_module = self.FlagsByModuleDict()
flags_by_module.setdefault(module_name, []).append(flag)
def _RegisterFlagByModuleId(self, module_id, flag):
"""Records the module that defines a specific flag.
Args:
module_id: An int, the ID of the Python module.
flag: A Flag object, a flag that is key to the module.
"""
flags_by_module_id = self.FlagsByModuleIdDict()
flags_by_module_id.setdefault(module_id, []).append(flag)
def _RegisterKeyFlagForModule(self, module_name, flag):
"""Specifies that a flag is a key flag for a module.
Args:
module_name: A string, the name of a Python module.
flag: A Flag object, a flag that is key to the module.
"""
key_flags_by_module = self.KeyFlagsByModuleDict()
# The list of key flags for the module named module_name.
key_flags = key_flags_by_module.setdefault(module_name, [])
# Add flag, but avoid duplicates.
if flag not in key_flags:
key_flags.append(flag)
def _GetFlagsDefinedByModule(self, module):
"""Returns the list of flags defined by a module.
Args:
module: A module object or a module name (a string).
Returns:
A new list of Flag objects. Caller may update this list as he
wishes: none of those changes will affect the internals of this
FlagValue object.
"""
if not isinstance(module, str):
module = module.__name__
return list(self.FlagsByModuleDict().get(module, []))
def _GetKeyFlagsForModule(self, module):
"""Returns the list of key flags for a module.
Args:
module: A module object or a module name (a string)
Returns:
A new list of Flag objects. Caller may update this list as he
wishes: none of those changes will affect the internals of this
FlagValue object.
"""
if not isinstance(module, str):
module = module.__name__
# Any flag is a key flag for the module that defined it. NOTE:
# key_flags is a fresh list: we can update it without affecting the
# internals of this FlagValues object.
key_flags = self._GetFlagsDefinedByModule(module)
# Take into account flags explicitly declared as key for a module.
for flag in self.KeyFlagsByModuleDict().get(module, []):
if flag not in key_flags:
key_flags.append(flag)
return key_flags
def FindModuleDefiningFlag(self, flagname, default=None):
"""Return the name of the module defining this flag, or default.
Args:
flagname: Name of the flag to lookup.
default: Value to return if flagname is not defined. Defaults
to None.
Returns:
The name of the module which registered the flag with this name.
If no such module exists (i.e. no flag with this name exists),
we return default.
"""
for module, flags in self.FlagsByModuleDict().iteritems():
for flag in flags:
if flag.name == flagname or flag.short_name == flagname:
return module
return default
def FindModuleIdDefiningFlag(self, flagname, default=None):
"""Return the ID of the module defining this flag, or default.
Args:
flagname: Name of the flag to lookup.
default: Value to return if flagname is not defined. Defaults
to None.
Returns:
The ID of the module which registered the flag with this name.
If no such module exists (i.e. no flag with this name exists),
we return default.
"""
for module_id, flags in self.FlagsByModuleIdDict().iteritems():
for flag in flags:
if flag.name == flagname or flag.short_name == flagname:
return module_id
return default
def AppendFlagValues(self, flag_values):
"""Appends flags registered in another FlagValues instance.
Args:
flag_values: registry to copy from
"""
for flag_name, flag in flag_values.FlagDict().iteritems():
# Each flags with shortname appears here twice (once under its
# normal name, and again with its short name). To prevent
# problems (DuplicateFlagError) with double flag registration, we
# perform a check to make sure that the entry we're looking at is
# for its normal name.
if flag_name == flag.name:
try:
self[flag_name] = flag
except DuplicateFlagError:
raise DuplicateFlagError(flag_name, self,
other_flag_values=flag_values)
def RemoveFlagValues(self, flag_values):
"""Remove flags that were previously appended from another FlagValues.
Args:
flag_values: registry containing flags to remove.
"""
for flag_name in flag_values.FlagDict():
self.__delattr__(flag_name)
def __setitem__(self, name, flag):
"""Registers a new flag variable."""
fl = self.FlagDict()
if not isinstance(flag, Flag):
raise IllegalFlagValue(flag)
if not isinstance(name, type("")):
raise FlagsError("Flag name must be a string")
if len(name) == 0:
raise FlagsError("Flag name cannot be empty")
# If running under pychecker, duplicate keys are likely to be
# defined. Disable check for duplicate keys when pycheck'ing.
if (name in fl and not flag.allow_override and
not fl[name].allow_override and not _RUNNING_PYCHECKER):
module, module_name = _GetCallingModuleObjectAndName()
if (self.FindModuleDefiningFlag(name) == module_name and
id(module) != self.FindModuleIdDefiningFlag(name)):
# If the flag has already been defined by a module with the same name,
# but a different ID, we can stop here because it indicates that the
# module is simply being imported a subsequent time.
return
raise DuplicateFlagError(name, self)
short_name = flag.short_name
if short_name is not None:
if (short_name in fl and not flag.allow_override and
not fl[short_name].allow_override and not _RUNNING_PYCHECKER):
raise DuplicateFlagError(short_name, self)
fl[short_name] = flag
fl[name] = flag
global _exported_flags
_exported_flags[name] = flag
def __getitem__(self, name):
"""Retrieves the Flag object for the flag --name."""
return self.FlagDict()[name]
def __getattr__(self, name):
"""Retrieves the 'value' attribute of the flag --name."""
fl = self.FlagDict()
if name not in fl:
raise AttributeError(name)
return fl[name].value
def __setattr__(self, name, value):
"""Sets the 'value' attribute of the flag --name."""
fl = self.FlagDict()
fl[name].value = value
self._AssertValidators(fl[name].validators)
return value
def _AssertAllValidators(self):
all_validators = set()
for flag in self.FlagDict().itervalues():
for validator in flag.validators:
all_validators.add(validator)
self._AssertValidators(all_validators)
def _AssertValidators(self, validators):
"""Assert if all validators in the list are satisfied.
Asserts validators in the order they were created.
Args:
validators: Iterable(gflags_validators.Validator), validators to be
verified
Raises:
AttributeError: if validators work with a non-existing flag.
IllegalFlagValue: if validation fails for at least one validator
"""
for validator in sorted(
validators, key=lambda validator: validator.insertion_index):
try:
validator.Verify(self)
except gflags_validators.Error, e:
message = validator.PrintFlagsWithValues(self)
raise IllegalFlagValue('%s: %s' % (message, str(e)))
def _FlagIsRegistered(self, flag_obj):
"""Checks whether a Flag object is registered under some name.
Note: this is non trivial: in addition to its normal name, a flag
may have a short name too. In self.FlagDict(), both the normal and
the short name are mapped to the same flag object. E.g., calling
only "del FLAGS.short_name" is not unregistering the corresponding
Flag object (it is still registered under the longer name).
Args:
flag_obj: A Flag object.
Returns:
A boolean: True iff flag_obj is registered under some name.
"""
flag_dict = self.FlagDict()
# Check whether flag_obj is registered under its long name.
name = flag_obj.name
if flag_dict.get(name, None) == flag_obj:
return True
# Check whether flag_obj is registered under its short name.
short_name = flag_obj.short_name
if (short_name is not None and
flag_dict.get(short_name, None) == flag_obj):
return True
# The flag cannot be registered under any other name, so we do not
# need to do a full search through the values of self.FlagDict().
return False
def __delattr__(self, flag_name):
"""Deletes a previously-defined flag from a flag object.
This method makes sure we can delete a flag by using
del flag_values_object.<flag_name>
E.g.,
gflags.DEFINE_integer('foo', 1, 'Integer flag.')
del gflags.FLAGS.foo
Args:
flag_name: A string, the name of the flag to be deleted.
Raises:
AttributeError: When there is no registered flag named flag_name.
"""
fl = self.FlagDict()
if flag_name not in fl:
raise AttributeError(flag_name)
flag_obj = fl[flag_name]
del fl[flag_name]
if not self._FlagIsRegistered(flag_obj):
# If the Flag object indicated by flag_name is no longer
# registered (please see the docstring of _FlagIsRegistered), then
# we delete the occurrences of the flag object in all our internal
# dictionaries.
self.__RemoveFlagFromDictByModule(self.FlagsByModuleDict(), flag_obj)
self.__RemoveFlagFromDictByModule(self.FlagsByModuleIdDict(), flag_obj)
self.__RemoveFlagFromDictByModule(self.KeyFlagsByModuleDict(), flag_obj)
def __RemoveFlagFromDictByModule(self, flags_by_module_dict, flag_obj):
"""Removes a flag object from a module -> list of flags dictionary.
Args:
flags_by_module_dict: A dictionary that maps module names to lists of
flags.
flag_obj: A flag object.
"""
for unused_module, flags_in_module in flags_by_module_dict.iteritems():
# while (as opposed to if) takes care of multiple occurrences of a
# flag in the list for the same module.
while flag_obj in flags_in_module:
flags_in_module.remove(flag_obj)
def SetDefault(self, name, value):
"""Changes the default value of the named flag object."""
fl = self.FlagDict()
if name not in fl:
raise AttributeError(name)
fl[name].SetDefault(value)
self._AssertValidators(fl[name].validators)
def __contains__(self, name):
"""Returns True if name is a value (flag) in the dict."""
return name in self.FlagDict()
has_key = __contains__ # a synonym for __contains__()
def __iter__(self):
return iter(self.FlagDict())
def __call__(self, argv):
"""Parses flags from argv; stores parsed flags into this FlagValues object.
All unparsed arguments are returned. Flags are parsed using the GNU
Program Argument Syntax Conventions, using getopt:
http://www.gnu.org/software/libc/manual/html_mono/libc.html#Getopt
Args:
argv: argument list. Can be of any type that may be converted to a list.
Returns:
The list of arguments not parsed as options, including argv[0]
Raises:
FlagsError: on any parsing error
"""
# Support any sequence type that can be converted to a list
argv = list(argv)
shortopts = ""
longopts = []
fl = self.FlagDict()
# This pre parses the argv list for --flagfile=<> options.
argv = argv[:1] + self.ReadFlagsFromFiles(argv[1:], force_gnu=False)
# Correct the argv to support the google style of passing boolean
# parameters. Boolean parameters may be passed by using --mybool,
# --nomybool, --mybool=(true|false|1|0). getopt does not support
# having options that may or may not have a parameter. We replace
# instances of the short form --mybool and --nomybool with their
# full forms: --mybool=(true|false).
original_argv = list(argv) # list() makes a copy
shortest_matches = None
for name, flag in fl.items():
if not flag.boolean:
continue
if shortest_matches is None:
# Determine the smallest allowable prefix for all flag names
shortest_matches = self.ShortestUniquePrefixes(fl)
no_name = 'no' + name
prefix = shortest_matches[name]
no_prefix = shortest_matches[no_name]
# Replace all occurrences of this boolean with extended forms
for arg_idx in range(1, len(argv)):
arg = argv[arg_idx]
if arg.find('=') >= 0: continue
if arg.startswith('--'+prefix) and ('--'+name).startswith(arg):
argv[arg_idx] = ('--%s=true' % name)
elif arg.startswith('--'+no_prefix) and ('--'+no_name).startswith(arg):
argv[arg_idx] = ('--%s=false' % name)
# Loop over all of the flags, building up the lists of short options
# and long options that will be passed to getopt. Short options are
# specified as a string of letters, each letter followed by a colon
# if it takes an argument. Long options are stored in an array of
# strings. Each string ends with an '=' if it takes an argument.
for name, flag in fl.items():
longopts.append(name + "=")
if len(name) == 1: # one-letter option: allow short flag type also
shortopts += name
if not flag.boolean:
shortopts += ":"
longopts.append('undefok=')
undefok_flags = []
# In case --undefok is specified, loop to pick up unrecognized
# options one by one.
unrecognized_opts = []
args = argv[1:]
while True:
try:
if self.__dict__['__use_gnu_getopt']:
optlist, unparsed_args = getopt.gnu_getopt(args, shortopts, longopts)
else:
optlist, unparsed_args = getopt.getopt(args, shortopts, longopts)
break
except getopt.GetoptError, e:
if not e.opt or e.opt in fl:
# Not an unrecognized option, re-raise the exception as a FlagsError
raise FlagsError(e)
# Remove offender from args and try again
for arg_index in range(len(args)):
if ((args[arg_index] == '--' + e.opt) or
(args[arg_index] == '-' + e.opt) or
(args[arg_index].startswith('--' + e.opt + '='))):
unrecognized_opts.append((e.opt, args[arg_index]))
args = args[0:arg_index] + args[arg_index+1:]
break
else:
# We should have found the option, so we don't expect to get
# here. We could assert, but raising the original exception
# might work better.
raise FlagsError(e)
for name, arg in optlist:
if name == '--undefok':
flag_names = arg.split(',')
undefok_flags.extend(flag_names)
# For boolean flags, if --undefok=boolflag is specified, then we should
# also accept --noboolflag, in addition to --boolflag.
# Since we don't know the type of the undefok'd flag, this will affect
# non-boolean flags as well.
# NOTE: You shouldn't use --undefok=noboolflag, because then we will
# accept --nonoboolflag here. We are choosing not to do the conversion
# from noboolflag -> boolflag because of the ambiguity that flag names
# can start with 'no'.
undefok_flags.extend('no' + name for name in flag_names)
continue
if name.startswith('--'):
# long option
name = name[2:]
short_option = 0
else:
# short option
name = name[1:]
short_option = 1
if name in fl:
flag = fl[name]
if flag.boolean and short_option: arg = 1
flag.Parse(arg)
# If there were unrecognized options, raise an exception unless
# the options were named via --undefok.
for opt, value in unrecognized_opts:
if opt not in undefok_flags:
raise UnrecognizedFlagError(opt, value)
if unparsed_args:
if self.__dict__['__use_gnu_getopt']:
# if using gnu_getopt just return the program name + remainder of argv.
ret_val = argv[:1] + unparsed_args
else:
# unparsed_args becomes the first non-flag detected by getopt to
# the end of argv. Because argv may have been modified above,
# return original_argv for this region.
ret_val = argv[:1] + original_argv[-len(unparsed_args):]
else:
ret_val = argv[:1]
self._AssertAllValidators()
return ret_val
def Reset(self):
"""Resets the values to the point before FLAGS(argv) was called."""
for f in self.FlagDict().values():
f.Unparse()
def RegisteredFlags(self):
"""Returns: a list of the names and short names of all registered flags."""
return list(self.FlagDict())
def FlagValuesDict(self):
"""Returns: a dictionary that maps flag names to flag values."""
flag_values = {}
for flag_name in self.RegisteredFlags():
flag = self.FlagDict()[flag_name]
flag_values[flag_name] = flag.value
return flag_values
def __str__(self):
"""Generates a help string for all known flags."""
return self.GetHelp()
def GetHelp(self, prefix=''):
"""Generates a help string for all known flags."""
helplist = []
flags_by_module = self.FlagsByModuleDict()
if flags_by_module:
modules = sorted(flags_by_module)
# Print the help for the main module first, if possible.
main_module = _GetMainModule()
if main_module in modules:
modules.remove(main_module)
modules = [main_module] + modules
for module in modules:
self.__RenderOurModuleFlags(module, helplist)
self.__RenderModuleFlags('gflags',
_SPECIAL_FLAGS.FlagDict().values(),
helplist)
else:
# Just print one long list of flags.
self.__RenderFlagList(
self.FlagDict().values() + _SPECIAL_FLAGS.FlagDict().values(),
helplist, prefix)
return '\n'.join(helplist)
def __RenderModuleFlags(self, module, flags, output_lines, prefix=""):
"""Generates a help string for a given module."""
if not isinstance(module, str):
module = module.__name__
output_lines.append('\n%s%s:' % (prefix, module))
self.__RenderFlagList(flags, output_lines, prefix + " ")
def __RenderOurModuleFlags(self, module, output_lines, prefix=""):
"""Generates a help string for a given module."""
flags = self._GetFlagsDefinedByModule(module)
if flags:
self.__RenderModuleFlags(module, flags, output_lines, prefix)
def __RenderOurModuleKeyFlags(self, module, output_lines, prefix=""):
"""Generates a help string for the key flags of a given module.
Args:
module: A module object or a module name (a string).
output_lines: A list of strings. The generated help message
lines will be appended to this list.
prefix: A string that is prepended to each generated help line.
"""
key_flags = self._GetKeyFlagsForModule(module)
if key_flags:
self.__RenderModuleFlags(module, key_flags, output_lines, prefix)
def ModuleHelp(self, module):
"""Describe the key flags of a module.
Args:
module: A module object or a module name (a string).
Returns:
string describing the key flags of a module.
"""
helplist = []
self.__RenderOurModuleKeyFlags(module, helplist)
return '\n'.join(helplist)
def MainModuleHelp(self):
"""Describe the key flags of the main module.
Returns:
string describing the key flags of a module.
"""
return self.ModuleHelp(_GetMainModule())
def __RenderFlagList(self, flaglist, output_lines, prefix=" "):
fl = self.FlagDict()
special_fl = _SPECIAL_FLAGS.FlagDict()
flaglist = [(flag.name, flag) for flag in flaglist]
flaglist.sort()
flagset = {}
for (name, flag) in flaglist:
# It's possible this flag got deleted or overridden since being
# registered in the per-module flaglist. Check now against the
# canonical source of current flag information, the FlagDict.
if fl.get(name, None) != flag and special_fl.get(name, None) != flag:
# a different flag is using this name now
continue
# only print help once
if flag in flagset: continue
flagset[flag] = 1
flaghelp = ""
if flag.short_name: flaghelp += "-%s," % flag.short_name
if flag.boolean:
flaghelp += "--[no]%s" % flag.name + ":"
else:
flaghelp += "--%s" % flag.name + ":"
flaghelp += " "
if flag.help:
flaghelp += flag.help
flaghelp = TextWrap(flaghelp, indent=prefix+" ",
firstline_indent=prefix)
if flag.default_as_str:
flaghelp += "\n"
flaghelp += TextWrap("(default: %s)" % flag.default_as_str,
indent=prefix+" ")
if flag.parser.syntactic_help:
flaghelp += "\n"
flaghelp += TextWrap("(%s)" % flag.parser.syntactic_help,
indent=prefix+" ")
output_lines.append(flaghelp)
def get(self, name, default):
"""Returns the value of a flag (if not None) or a default value.
Args:
name: A string, the name of a flag.
default: Default value to use if the flag value is None.
"""
value = self.__getattr__(name)
if value is not None: # Can't do if not value, b/c value might be '0' or ""
return value
else:
return default
def ShortestUniquePrefixes(self, fl):
"""Returns: dictionary; maps flag names to their shortest unique prefix."""
# Sort the list of flag names
sorted_flags = []
for name, flag in fl.items():
sorted_flags.append(name)
if flag.boolean:
sorted_flags.append('no%s' % name)
sorted_flags.sort()
# For each name in the sorted list, determine the shortest unique
# prefix by comparing itself to the next name and to the previous
# name (the latter check uses cached info from the previous loop).
shortest_matches = {}
prev_idx = 0
for flag_idx in range(len(sorted_flags)):
curr = sorted_flags[flag_idx]
if flag_idx == (len(sorted_flags) - 1):
next = None
else:
next = sorted_flags[flag_idx+1]
next_len = len(next)
for curr_idx in range(len(curr)):
if (next is None
or curr_idx >= next_len
or curr[curr_idx] != next[curr_idx]):
# curr longer than next or no more chars in common
shortest_matches[curr] = curr[:max(prev_idx, curr_idx) + 1]
prev_idx = curr_idx
break
else:
# curr shorter than (or equal to) next
shortest_matches[curr] = curr
prev_idx = curr_idx + 1 # next will need at least one more char
return shortest_matches
def __IsFlagFileDirective(self, flag_string):
"""Checks whether flag_string contain a --flagfile=<foo> directive."""
if isinstance(flag_string, type("")):
if flag_string.startswith('--flagfile='):
return 1
elif flag_string == '--flagfile':
return 1
elif flag_string.startswith('-flagfile='):
return 1
elif flag_string == '-flagfile':
return 1
else:
return 0
return 0
def ExtractFilename(self, flagfile_str):
"""Returns filename from a flagfile_str of form -[-]flagfile=filename.
The cases of --flagfile foo and -flagfile foo shouldn't be hitting
this function, as they are dealt with in the level above this
function.
"""
if flagfile_str.startswith('--flagfile='):
return os.path.expanduser((flagfile_str[(len('--flagfile=')):]).strip())
elif flagfile_str.startswith('-flagfile='):
return os.path.expanduser((flagfile_str[(len('-flagfile=')):]).strip())
else:
raise FlagsError('Hit illegal --flagfile type: %s' % flagfile_str)
def __GetFlagFileLines(self, filename, parsed_file_list):
"""Returns the useful (!=comments, etc) lines from a file with flags.
Args:
filename: A string, the name of the flag file.
parsed_file_list: A list of the names of the files we have
already read. MUTATED BY THIS FUNCTION.
Returns:
List of strings. See the note below.
NOTE(springer): This function checks for a nested --flagfile=<foo>
tag and handles the lower file recursively. It returns a list of
all the lines that _could_ contain command flags. This is
EVERYTHING except whitespace lines and comments (lines starting
with '#' or '//').
"""
line_list = [] # All line from flagfile.
flag_line_list = [] # Subset of lines w/o comments, blanks, flagfile= tags.
try:
file_obj = open(filename, 'r')
except IOError, e_msg:
raise CantOpenFlagFileError('ERROR:: Unable to open flagfile: %s' % e_msg)
line_list = file_obj.readlines()
file_obj.close()
parsed_file_list.append(filename)
# This is where we check each line in the file we just read.
for line in line_list:
if line.isspace():
pass
# Checks for comment (a line that starts with '#').
elif line.startswith('#') or line.startswith('//'):
pass
# Checks for a nested "--flagfile=<bar>" flag in the current file.
# If we find one, recursively parse down into that file.
elif self.__IsFlagFileDirective(line):
sub_filename = self.ExtractFilename(line)
# We do a little safety check for reparsing a file we've already done.
if not sub_filename in parsed_file_list:
included_flags = self.__GetFlagFileLines(sub_filename,
parsed_file_list)
flag_line_list.extend(included_flags)
else: # Case of hitting a circularly included file.
sys.stderr.write('Warning: Hit circular flagfile dependency: %s\n' %
(sub_filename,))
else:
# Any line that's not a comment or a nested flagfile should get
# copied into 2nd position. This leaves earlier arguments
# further back in the list, thus giving them higher priority.
flag_line_list.append(line.strip())
return flag_line_list
def ReadFlagsFromFiles(self, argv, force_gnu=True):
"""Processes command line args, but also allow args to be read from file.
Args:
argv: A list of strings, usually sys.argv[1:], which may contain one or
more flagfile directives of the form --flagfile="./filename".
Note that the name of the program (sys.argv[0]) should be omitted.
force_gnu: If False, --flagfile parsing obeys normal flag semantics.
If True, --flagfile parsing instead follows gnu_getopt semantics.
*** WARNING *** force_gnu=False may become the future default!
Returns:
A new list which has the original list combined with what we read
from any flagfile(s).
References: Global gflags.FLAG class instance.
This function should be called before the normal FLAGS(argv) call.
This function scans the input list for a flag that looks like:
--flagfile=<somefile>. Then it opens <somefile>, reads all valid key
and value pairs and inserts them into the input list between the
first item of the list and any subsequent items in the list.
Note that your application's flags are still defined the usual way
using gflags DEFINE_flag() type functions.
Notes (assuming we're getting a commandline of some sort as our input):
--> Flags from the command line argv _should_ always take precedence!
--> A further "--flagfile=<otherfile.cfg>" CAN be nested in a flagfile.
It will be processed after the parent flag file is done.
--> For duplicate flags, first one we hit should "win".
--> In a flagfile, a line beginning with # or // is a comment.
--> Entirely blank lines _should_ be ignored.
"""
parsed_file_list = []
rest_of_args = argv
new_argv = []
while rest_of_args:
current_arg = rest_of_args[0]
rest_of_args = rest_of_args[1:]
if self.__IsFlagFileDirective(current_arg):
# This handles the case of -(-)flagfile foo. In this case the
# next arg really is part of this one.
if current_arg == '--flagfile' or current_arg == '-flagfile':
if not rest_of_args:
raise IllegalFlagValue('--flagfile with no argument')
flag_filename = os.path.expanduser(rest_of_args[0])
rest_of_args = rest_of_args[1:]
else:
# This handles the case of (-)-flagfile=foo.
flag_filename = self.ExtractFilename(current_arg)
new_argv.extend(
self.__GetFlagFileLines(flag_filename, parsed_file_list))
else:
new_argv.append(current_arg)
# Stop parsing after '--', like getopt and gnu_getopt.
if current_arg == '--':
break
# Stop parsing after a non-flag, like getopt.
if not current_arg.startswith('-'):
if not force_gnu and not self.__dict__['__use_gnu_getopt']:
break
if rest_of_args:
new_argv.extend(rest_of_args)
return new_argv
def FlagsIntoString(self):
"""Returns a string with the flags assignments from this FlagValues object.
This function ignores flags whose value is None. Each flag
assignment is separated by a newline.
NOTE: MUST mirror the behavior of the C++ CommandlineFlagsIntoString
from http://code.google.com/p/google-gflags
"""
s = ''
for flag in self.FlagDict().values():
if flag.value is not None:
s += flag.Serialize() + '\n'
return s
def AppendFlagsIntoFile(self, filename):
"""Appends all flags assignments from this FlagInfo object to a file.
Output will be in the format of a flagfile.
NOTE: MUST mirror the behavior of the C++ AppendFlagsIntoFile
from http://code.google.com/p/google-gflags
"""
out_file = open(filename, 'a')
out_file.write(self.FlagsIntoString())
out_file.close()
def WriteHelpInXMLFormat(self, outfile=None):
"""Outputs flag documentation in XML format.
NOTE: We use element names that are consistent with those used by
the C++ command-line flag library, from
http://code.google.com/p/google-gflags
We also use a few new elements (e.g., <key>), but we do not
interfere / overlap with existing XML elements used by the C++
library. Please maintain this consistency.
Args:
outfile: File object we write to. Default None means sys.stdout.
"""
outfile = outfile or sys.stdout
outfile.write('<?xml version=\"1.0\"?>\n')
outfile.write('<AllFlags>\n')
indent = ' '
_WriteSimpleXMLElement(outfile, 'program', os.path.basename(sys.argv[0]),
indent)
usage_doc = sys.modules['__main__'].__doc__
if not usage_doc:
usage_doc = '\nUSAGE: %s [flags]\n' % sys.argv[0]
else:
usage_doc = usage_doc.replace('%s', sys.argv[0])
_WriteSimpleXMLElement(outfile, 'usage', usage_doc, indent)
# Get list of key flags for the main module.
key_flags = self._GetKeyFlagsForModule(_GetMainModule())
# Sort flags by declaring module name and next by flag name.
flags_by_module = self.FlagsByModuleDict()
all_module_names = list(flags_by_module.keys())
all_module_names.sort()
for module_name in all_module_names:
flag_list = [(f.name, f) for f in flags_by_module[module_name]]
flag_list.sort()
for unused_flag_name, flag in flag_list:
is_key = flag in key_flags
flag.WriteInfoInXMLFormat(outfile, module_name,
is_key=is_key, indent=indent)
outfile.write('</AllFlags>\n')
outfile.flush()
def AddValidator(self, validator):
"""Register new flags validator to be checked.
Args:
validator: gflags_validators.Validator
Raises:
AttributeError: if validators work with a non-existing flag.
"""
for flag_name in validator.GetFlagsNames():
flag = self.FlagDict()[flag_name]
flag.validators.append(validator)
# end of FlagValues definition
# The global FlagValues instance
FLAGS = FlagValues()
def _StrOrUnicode(value):
"""Converts value to a python string or, if necessary, unicode-string."""
try:
return str(value)
except UnicodeEncodeError:
return unicode(value)
def _MakeXMLSafe(s):
"""Escapes <, >, and & from s, and removes XML 1.0-illegal chars."""
s = cgi.escape(s) # Escape <, >, and &
# Remove characters that cannot appear in an XML 1.0 document
# (http://www.w3.org/TR/REC-xml/#charsets).
#
# NOTE: if there are problems with current solution, one may move to
# XML 1.1, which allows such chars, if they're entity-escaped (&#xHH;).
s = re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f]', '', s)
# Convert non-ascii characters to entities. Note: requires python >=2.3
s = s.encode('ascii', 'xmlcharrefreplace') # u'\xce\x88' -> 'uΈ'
return s
def _WriteSimpleXMLElement(outfile, name, value, indent):
"""Writes a simple XML element.
Args:
outfile: File object we write the XML element to.
name: A string, the name of XML element.
value: A Python object, whose string representation will be used
as the value of the XML element.
indent: A string, prepended to each line of generated output.
"""
value_str = _StrOrUnicode(value)
if isinstance(value, bool):
# Display boolean values as the C++ flag library does: no caps.
value_str = value_str.lower()
safe_value_str = _MakeXMLSafe(value_str)
outfile.write('%s<%s>%s</%s>\n' % (indent, name, safe_value_str, name))
class Flag:
"""Information about a command-line flag.
'Flag' objects define the following fields:
.name - the name for this flag
.default - the default value for this flag
.default_as_str - default value as repr'd string, e.g., "'true'" (or None)
.value - the most recent parsed value of this flag; set by Parse()
.help - a help string or None if no help is available
.short_name - the single letter alias for this flag (or None)
.boolean - if 'true', this flag does not accept arguments
.present - true if this flag was parsed from command line flags.
.parser - an ArgumentParser object
.serializer - an ArgumentSerializer object
.allow_override - the flag may be redefined without raising an error
The only public method of a 'Flag' object is Parse(), but it is
typically only called by a 'FlagValues' object. The Parse() method is
a thin wrapper around the 'ArgumentParser' Parse() method. The parsed
value is saved in .value, and the .present attribute is updated. If
this flag was already present, a FlagsError is raised.
Parse() is also called during __init__ to parse the default value and
initialize the .value attribute. This enables other python modules to
safely use flags even if the __main__ module neglects to parse the
command line arguments. The .present attribute is cleared after
__init__ parsing. If the default value is set to None, then the
__init__ parsing step is skipped and the .value attribute is
initialized to None.
Note: The default value is also presented to the user in the help
string, so it is important that it be a legal value for this flag.
"""
def __init__(self, parser, serializer, name, default, help_string,
short_name=None, boolean=0, allow_override=0):
self.name = name
if not help_string:
help_string = '(no help available)'
self.help = help_string
self.short_name = short_name
self.boolean = boolean
self.present = 0
self.parser = parser
self.serializer = serializer
self.allow_override = allow_override
self.value = None
self.validators = []
self.SetDefault(default)
def __hash__(self):
return hash(id(self))
def __eq__(self, other):
return self is other
def __lt__(self, other):
if isinstance(other, Flag):
return id(self) < id(other)
return NotImplemented
def __GetParsedValueAsString(self, value):
if value is None:
return None
if self.serializer:
return repr(self.serializer.Serialize(value))
if self.boolean:
if value:
return repr('true')
else:
return repr('false')
return repr(_StrOrUnicode(value))
def Parse(self, argument):
try:
self.value = self.parser.Parse(argument)
except ValueError, e: # recast ValueError as IllegalFlagValue
raise IllegalFlagValue("flag --%s=%s: %s" % (self.name, argument, e))
self.present += 1
def Unparse(self):
if self.default is None:
self.value = None
else:
self.Parse(self.default)
self.present = 0
def Serialize(self):
if self.value is None:
return ''
if self.boolean:
if self.value:
return "--%s" % self.name
else:
return "--no%s" % self.name
else:
if not self.serializer:
raise FlagsError("Serializer not present for flag %s" % self.name)
return "--%s=%s" % (self.name, self.serializer.Serialize(self.value))
def SetDefault(self, value):
"""Changes the default value (and current value too) for this Flag."""
# We can't allow a None override because it may end up not being
# passed to C++ code when we're overriding C++ flags. So we
# cowardly bail out until someone fixes the semantics of trying to
# pass None to a C++ flag. See swig_flags.Init() for details on
# this behavior.
# TODO(olexiy): Users can directly call this method, bypassing all flags
# validators (we don't have FlagValues here, so we can not check
# validators).
# The simplest solution I see is to make this method private.
# Another approach would be to store reference to the corresponding
# FlagValues with each flag, but this seems to be an overkill.
if value is None and self.allow_override:
raise DuplicateFlagCannotPropagateNoneToSwig(self.name)
self.default = value
self.Unparse()
self.default_as_str = self.__GetParsedValueAsString(self.value)
def Type(self):
"""Returns: a string that describes the type of this Flag."""
# NOTE: we use strings, and not the types.*Type constants because
# our flags can have more exotic types, e.g., 'comma separated list
# of strings', 'whitespace separated list of strings', etc.
return self.parser.Type()
def WriteInfoInXMLFormat(self, outfile, module_name, is_key=False, indent=''):
"""Writes common info about this flag, in XML format.
This is information that is relevant to all flags (e.g., name,
meaning, etc.). If you defined a flag that has some other pieces of
info, then please override _WriteCustomInfoInXMLFormat.
Please do NOT override this method.
Args:
outfile: File object we write to.
module_name: A string, the name of the module that defines this flag.
is_key: A boolean, True iff this flag is key for main module.
indent: A string that is prepended to each generated line.
"""
outfile.write(indent + '<flag>\n')
inner_indent = indent + ' '
if is_key:
_WriteSimpleXMLElement(outfile, 'key', 'yes', inner_indent)
_WriteSimpleXMLElement(outfile, 'file', module_name, inner_indent)
# Print flag features that are relevant for all flags.
_WriteSimpleXMLElement(outfile, 'name', self.name, inner_indent)
if self.short_name:
_WriteSimpleXMLElement(outfile, 'short_name', self.short_name,
inner_indent)
if self.help:
_WriteSimpleXMLElement(outfile, 'meaning', self.help, inner_indent)
# The default flag value can either be represented as a string like on the
# command line, or as a Python object. We serialize this value in the
# latter case in order to remain consistent.
if self.serializer and not isinstance(self.default, str):
default_serialized = self.serializer.Serialize(self.default)
else:
default_serialized = self.default
_WriteSimpleXMLElement(outfile, 'default', default_serialized, inner_indent)
_WriteSimpleXMLElement(outfile, 'current', self.value, inner_indent)
_WriteSimpleXMLElement(outfile, 'type', self.Type(), inner_indent)
# Print extra flag features this flag may have.
self._WriteCustomInfoInXMLFormat(outfile, inner_indent)
outfile.write(indent + '</flag>\n')
def _WriteCustomInfoInXMLFormat(self, outfile, indent):
"""Writes extra info about this flag, in XML format.
"Extra" means "not already printed by WriteInfoInXMLFormat above."
Args:
outfile: File object we write to.
indent: A string that is prepended to each generated line.
"""
# Usually, the parser knows the extra details about the flag, so
# we just forward the call to it.
self.parser.WriteCustomInfoInXMLFormat(outfile, indent)
# End of Flag definition
class _ArgumentParserCache(type):
"""Metaclass used to cache and share argument parsers among flags."""
_instances = {}
def __call__(mcs, *args, **kwargs):
"""Returns an instance of the argument parser cls.
This method overrides behavior of the __new__ methods in
all subclasses of ArgumentParser (inclusive). If an instance
for mcs with the same set of arguments exists, this instance is
returned, otherwise a new instance is created.
If any keyword arguments are defined, or the values in args
are not hashable, this method always returns a new instance of
cls.
Args:
args: Positional initializer arguments.
kwargs: Initializer keyword arguments.
Returns:
An instance of cls, shared or new.
"""
if kwargs:
return type.__call__(mcs, *args, **kwargs)
else:
instances = mcs._instances
key = (mcs,) + tuple(args)
try:
return instances[key]
except KeyError:
# No cache entry for key exists, create a new one.
return instances.setdefault(key, type.__call__(mcs, *args))
except TypeError:
# An object in args cannot be hashed, always return
# a new instance.
return type.__call__(mcs, *args)
class ArgumentParser(object):
"""Base class used to parse and convert arguments.
The Parse() method checks to make sure that the string argument is a
legal value and convert it to a native type. If the value cannot be
converted, it should throw a 'ValueError' exception with a human
readable explanation of why the value is illegal.
Subclasses should also define a syntactic_help string which may be
presented to the user to describe the form of the legal values.
Argument parser classes must be stateless, since instances are cached
and shared between flags. Initializer arguments are allowed, but all
member variables must be derived from initializer arguments only.
"""
__metaclass__ = _ArgumentParserCache
syntactic_help = ""
def Parse(self, argument):
"""Default implementation: always returns its argument unmodified."""
return argument
def Type(self):
return 'string'
def WriteCustomInfoInXMLFormat(self, outfile, indent):
pass
class ArgumentSerializer:
"""Base class for generating string representations of a flag value."""
def Serialize(self, value):
return _StrOrUnicode(value)
class ListSerializer(ArgumentSerializer):
def __init__(self, list_sep):
self.list_sep = list_sep
def Serialize(self, value):
return self.list_sep.join([_StrOrUnicode(x) for x in value])
# Flags validators
def RegisterValidator(flag_name,
checker,
message='Flag validation failed',
flag_values=FLAGS):
"""Adds a constraint, which will be enforced during program execution.
The constraint is validated when flags are initially parsed, and after each
change of the corresponding flag's value.
Args:
flag_name: string, name of the flag to be checked.
checker: method to validate the flag.
input - value of the corresponding flag (string, boolean, etc.
This value will be passed to checker by the library). See file's
docstring for examples.
output - Boolean.
Must return True if validator constraint is satisfied.
If constraint is not satisfied, it should either return False or
raise gflags_validators.Error(desired_error_message).
message: error text to be shown to the user if checker returns False.
If checker raises gflags_validators.Error, message from the raised
Error will be shown.
flag_values: FlagValues
Raises:
AttributeError: if flag_name is not registered as a valid flag name.
"""
flag_values.AddValidator(gflags_validators.SimpleValidator(flag_name,
checker,
message))
def MarkFlagAsRequired(flag_name, flag_values=FLAGS):
"""Ensure that flag is not None during program execution.
Registers a flag validator, which will follow usual validator
rules.
Args:
flag_name: string, name of the flag
flag_values: FlagValues
Raises:
AttributeError: if flag_name is not registered as a valid flag name.
"""
RegisterValidator(flag_name,
lambda value: value is not None,
message='Flag --%s must be specified.' % flag_name,
flag_values=flag_values)
def _RegisterBoundsValidatorIfNeeded(parser, name, flag_values):
"""Enforce lower and upper bounds for numeric flags.
Args:
parser: NumericParser (either FloatParser or IntegerParser). Provides lower
and upper bounds, and help text to display.
name: string, name of the flag
flag_values: FlagValues
"""
if parser.lower_bound is not None or parser.upper_bound is not None:
def Checker(value):
if value is not None and parser.IsOutsideBounds(value):
message = '%s is not %s' % (value, parser.syntactic_help)
raise gflags_validators.Error(message)
return True
RegisterValidator(name,
Checker,
flag_values=flag_values)
# The DEFINE functions are explained in mode details in the module doc string.
def DEFINE(parser, name, default, help, flag_values=FLAGS, serializer=None,
**args):
"""Registers a generic Flag object.
NOTE: in the docstrings of all DEFINE* functions, "registers" is short
for "creates a new flag and registers it".
Auxiliary function: clients should use the specialized DEFINE_<type>
function instead.
Args:
parser: ArgumentParser that is used to parse the flag arguments.
name: A string, the flag name.
default: The default value of the flag.
help: A help string.
flag_values: FlagValues object the flag will be registered with.
serializer: ArgumentSerializer that serializes the flag value.
args: Dictionary with extra keyword args that are passes to the
Flag __init__.
"""
DEFINE_flag(Flag(parser, serializer, name, default, help, **args),
flag_values)
def DEFINE_flag(flag, flag_values=FLAGS):
"""Registers a 'Flag' object with a 'FlagValues' object.
By default, the global FLAGS 'FlagValue' object is used.
Typical users will use one of the more specialized DEFINE_xxx
functions, such as DEFINE_string or DEFINE_integer. But developers
who need to create Flag objects themselves should use this function
to register their flags.
"""
# copying the reference to flag_values prevents pychecker warnings
fv = flag_values
fv[flag.name] = flag
# Tell flag_values who's defining the flag.
if isinstance(flag_values, FlagValues):
# Regarding the above isinstance test: some users pass funny
# values of flag_values (e.g., {}) in order to avoid the flag
# registration (in the past, there used to be a flag_values ==
# FLAGS test here) and redefine flags with the same name (e.g.,
# debug). To avoid breaking their code, we perform the
# registration only if flag_values is a real FlagValues object.
module, module_name = _GetCallingModuleObjectAndName()
flag_values._RegisterFlagByModule(module_name, flag)
flag_values._RegisterFlagByModuleId(id(module), flag)
def _InternalDeclareKeyFlags(flag_names,
flag_values=FLAGS, key_flag_values=None):
"""Declares a flag as key for the calling module.
Internal function. User code should call DECLARE_key_flag or
ADOPT_module_key_flags instead.
Args:
flag_names: A list of strings that are names of already-registered
Flag objects.
flag_values: A FlagValues object that the flags listed in
flag_names have registered with (the value of the flag_values
argument from the DEFINE_* calls that defined those flags).
This should almost never need to be overridden.
key_flag_values: A FlagValues object that (among possibly many
other things) keeps track of the key flags for each module.
Default None means "same as flag_values". This should almost
never need to be overridden.
Raises:
UnrecognizedFlagError: when we refer to a flag that was not
defined yet.
"""
key_flag_values = key_flag_values or flag_values
module = _GetCallingModule()
for flag_name in flag_names:
if flag_name not in flag_values:
raise UnrecognizedFlagError(flag_name)
flag = flag_values.FlagDict()[flag_name]
key_flag_values._RegisterKeyFlagForModule(module, flag)
def DECLARE_key_flag(flag_name, flag_values=FLAGS):
"""Declares one flag as key to the current module.
Key flags are flags that are deemed really important for a module.
They are important when listing help messages; e.g., if the
--helpshort command-line flag is used, then only the key flags of the
main module are listed (instead of all flags, as in the case of
--help).
Sample usage:
gflags.DECLARED_key_flag('flag_1')
Args:
flag_name: A string, the name of an already declared flag.
(Redeclaring flags as key, including flags implicitly key
because they were declared in this module, is a no-op.)
flag_values: A FlagValues object. This should almost never
need to be overridden.
"""
if flag_name in _SPECIAL_FLAGS:
# Take care of the special flags, e.g., --flagfile, --undefok.
# These flags are defined in _SPECIAL_FLAGS, and are treated
# specially during flag parsing, taking precedence over the
# user-defined flags.
_InternalDeclareKeyFlags([flag_name],
flag_values=_SPECIAL_FLAGS,
key_flag_values=flag_values)
return
_InternalDeclareKeyFlags([flag_name], flag_values=flag_values)
def ADOPT_module_key_flags(module, flag_values=FLAGS):
"""Declares that all flags key to a module are key to the current module.
Args:
module: A module object.
flag_values: A FlagValues object. This should almost never need
to be overridden.
Raises:
FlagsError: When given an argument that is a module name (a
string), instead of a module object.
"""
# NOTE(salcianu): an even better test would be if not
# isinstance(module, types.ModuleType) but I didn't want to import
# types for such a tiny use.
if isinstance(module, str):
raise FlagsError('Received module name %s; expected a module object.'
% module)
_InternalDeclareKeyFlags(
[f.name for f in flag_values._GetKeyFlagsForModule(module.__name__)],
flag_values=flag_values)
# If module is this flag module, take _SPECIAL_FLAGS into account.
if module == _GetThisModuleObjectAndName()[0]:
_InternalDeclareKeyFlags(
# As we associate flags with _GetCallingModuleObjectAndName(), the
# special flags defined in this module are incorrectly registered with
# a different module. So, we can't use _GetKeyFlagsForModule.
# Instead, we take all flags from _SPECIAL_FLAGS (a private
# FlagValues, where no other module should register flags).
[f.name for f in _SPECIAL_FLAGS.FlagDict().values()],
flag_values=_SPECIAL_FLAGS,
key_flag_values=flag_values)
#
# STRING FLAGS
#
def DEFINE_string(name, default, help, flag_values=FLAGS, **args):
"""Registers a flag whose value can be any string."""
parser = ArgumentParser()
serializer = ArgumentSerializer()
DEFINE(parser, name, default, help, flag_values, serializer, **args)
#
# BOOLEAN FLAGS
#
class BooleanParser(ArgumentParser):
"""Parser of boolean values."""
def Convert(self, argument):
"""Converts the argument to a boolean; raise ValueError on errors."""
if type(argument) == str:
if argument.lower() in ['true', 't', '1']:
return True
elif argument.lower() in ['false', 'f', '0']:
return False
bool_argument = bool(argument)
if argument == bool_argument:
# The argument is a valid boolean (True, False, 0, or 1), and not just
# something that always converts to bool (list, string, int, etc.).
return bool_argument
raise ValueError('Non-boolean argument to boolean flag', argument)
def Parse(self, argument):
val = self.Convert(argument)
return val
def Type(self):
return 'bool'
class BooleanFlag(Flag):
"""Basic boolean flag.
Boolean flags do not take any arguments, and their value is either
True (1) or False (0). The false value is specified on the command
line by prepending the word 'no' to either the long or the short flag
name.
For example, if a Boolean flag was created whose long name was
'update' and whose short name was 'x', then this flag could be
explicitly unset through either --noupdate or --nox.
"""
def __init__(self, name, default, help, short_name=None, **args):
p = BooleanParser()
Flag.__init__(self, p, None, name, default, help, short_name, 1, **args)
if not self.help: self.help = "a boolean value"
def DEFINE_boolean(name, default, help, flag_values=FLAGS, **args):
"""Registers a boolean flag.
Such a boolean flag does not take an argument. If a user wants to
specify a false value explicitly, the long option beginning with 'no'
must be used: i.e. --noflag
This flag will have a value of None, True or False. None is possible
if default=None and the user does not specify the flag on the command
line.
"""
DEFINE_flag(BooleanFlag(name, default, help, **args), flag_values)
# Match C++ API to unconfuse C++ people.
DEFINE_bool = DEFINE_boolean
class HelpFlag(BooleanFlag):
"""
HelpFlag is a special boolean flag that prints usage information and
raises a SystemExit exception if it is ever found in the command
line arguments. Note this is called with allow_override=1, so other
apps can define their own --help flag, replacing this one, if they want.
"""
def __init__(self):
BooleanFlag.__init__(self, "help", 0, "show this help",
short_name="?", allow_override=1)
def Parse(self, arg):
if arg:
doc = sys.modules["__main__"].__doc__
flags = str(FLAGS)
print doc or ("\nUSAGE: %s [flags]\n" % sys.argv[0])
if flags:
print "flags:"
print flags
sys.exit(1)
class HelpXMLFlag(BooleanFlag):
"""Similar to HelpFlag, but generates output in XML format."""
def __init__(self):
BooleanFlag.__init__(self, 'helpxml', False,
'like --help, but generates XML output',
allow_override=1)
def Parse(self, arg):
if arg:
FLAGS.WriteHelpInXMLFormat(sys.stdout)
sys.exit(1)
class HelpshortFlag(BooleanFlag):
"""
HelpshortFlag is a special boolean flag that prints usage
information for the "main" module, and rasies a SystemExit exception
if it is ever found in the command line arguments. Note this is
called with allow_override=1, so other apps can define their own
--helpshort flag, replacing this one, if they want.
"""
def __init__(self):
BooleanFlag.__init__(self, "helpshort", 0,
"show usage only for this module", allow_override=1)
def Parse(self, arg):
if arg:
doc = sys.modules["__main__"].__doc__
flags = FLAGS.MainModuleHelp()
print doc or ("\nUSAGE: %s [flags]\n" % sys.argv[0])
if flags:
print "flags:"
print flags
sys.exit(1)
#
# Numeric parser - base class for Integer and Float parsers
#
class NumericParser(ArgumentParser):
"""Parser of numeric values.
Parsed value may be bounded to a given upper and lower bound.
"""
def IsOutsideBounds(self, val):
return ((self.lower_bound is not None and val < self.lower_bound) or
(self.upper_bound is not None and val > self.upper_bound))
def Parse(self, argument):
val = self.Convert(argument)
if self.IsOutsideBounds(val):
raise ValueError("%s is not %s" % (val, self.syntactic_help))
return val
def WriteCustomInfoInXMLFormat(self, outfile, indent):
if self.lower_bound is not None:
_WriteSimpleXMLElement(outfile, 'lower_bound', self.lower_bound, indent)
if self.upper_bound is not None:
_WriteSimpleXMLElement(outfile, 'upper_bound', self.upper_bound, indent)
def Convert(self, argument):
"""Default implementation: always returns its argument unmodified."""
return argument
# End of Numeric Parser
#
# FLOAT FLAGS
#
class FloatParser(NumericParser):
"""Parser of floating point values.
Parsed value may be bounded to a given upper and lower bound.
"""
number_article = "a"
number_name = "number"
syntactic_help = " ".join((number_article, number_name))
def __init__(self, lower_bound=None, upper_bound=None):
super(FloatParser, self).__init__()
self.lower_bound = lower_bound
self.upper_bound = upper_bound
sh = self.syntactic_help
if lower_bound is not None and upper_bound is not None:
sh = ("%s in the range [%s, %s]" % (sh, lower_bound, upper_bound))
elif lower_bound == 0:
sh = "a non-negative %s" % self.number_name
elif upper_bound == 0:
sh = "a non-positive %s" % self.number_name
elif upper_bound is not None:
sh = "%s <= %s" % (self.number_name, upper_bound)
elif lower_bound is not None:
sh = "%s >= %s" % (self.number_name, lower_bound)
self.syntactic_help = sh
def Convert(self, argument):
"""Converts argument to a float; raises ValueError on errors."""
return float(argument)
def Type(self):
return 'float'
# End of FloatParser
def DEFINE_float(name, default, help, lower_bound=None, upper_bound=None,
flag_values=FLAGS, **args):
"""Registers a flag whose value must be a float.
If lower_bound or upper_bound are set, then this flag must be
within the given range.
"""
parser = FloatParser(lower_bound, upper_bound)
serializer = ArgumentSerializer()
DEFINE(parser, name, default, help, flag_values, serializer, **args)
_RegisterBoundsValidatorIfNeeded(parser, name, flag_values=flag_values)
#
# INTEGER FLAGS
#
class IntegerParser(NumericParser):
"""Parser of an integer value.
Parsed value may be bounded to a given upper and lower bound.
"""
number_article = "an"
number_name = "integer"
syntactic_help = " ".join((number_article, number_name))
def __init__(self, lower_bound=None, upper_bound=None):
super(IntegerParser, self).__init__()
self.lower_bound = lower_bound
self.upper_bound = upper_bound
sh = self.syntactic_help
if lower_bound is not None and upper_bound is not None:
sh = ("%s in the range [%s, %s]" % (sh, lower_bound, upper_bound))
elif lower_bound == 1:
sh = "a positive %s" % self.number_name
elif upper_bound == -1:
sh = "a negative %s" % self.number_name
elif lower_bound == 0:
sh = "a non-negative %s" % self.number_name
elif upper_bound == 0:
sh = "a non-positive %s" % self.number_name
elif upper_bound is not None:
sh = "%s <= %s" % (self.number_name, upper_bound)
elif lower_bound is not None:
sh = "%s >= %s" % (self.number_name, lower_bound)
self.syntactic_help = sh
def Convert(self, argument):
__pychecker__ = 'no-returnvalues'
if type(argument) == str:
base = 10
if len(argument) > 2 and argument[0] == "0" and argument[1] == "x":
base = 16
return int(argument, base)
else:
return int(argument)
def Type(self):
return 'int'
def DEFINE_integer(name, default, help, lower_bound=None, upper_bound=None,
flag_values=FLAGS, **args):
"""Registers a flag whose value must be an integer.
If lower_bound, or upper_bound are set, then this flag must be
within the given range.
"""
parser = IntegerParser(lower_bound, upper_bound)
serializer = ArgumentSerializer()
DEFINE(parser, name, default, help, flag_values, serializer, **args)
_RegisterBoundsValidatorIfNeeded(parser, name, flag_values=flag_values)
#
# ENUM FLAGS
#
class EnumParser(ArgumentParser):
"""Parser of a string enum value (a string value from a given set).
If enum_values (see below) is not specified, any string is allowed.
"""
def __init__(self, enum_values=None):
super(EnumParser, self).__init__()
self.enum_values = enum_values
def Parse(self, argument):
if self.enum_values and argument not in self.enum_values:
raise ValueError("value should be one of <%s>" %
"|".join(self.enum_values))
return argument
def Type(self):
return 'string enum'
class EnumFlag(Flag):
"""Basic enum flag; its value can be any string from list of enum_values."""
def __init__(self, name, default, help, enum_values=None,
short_name=None, **args):
enum_values = enum_values or []
p = EnumParser(enum_values)
g = ArgumentSerializer()
Flag.__init__(self, p, g, name, default, help, short_name, **args)
if not self.help: self.help = "an enum string"
self.help = "<%s>: %s" % ("|".join(enum_values), self.help)
def _WriteCustomInfoInXMLFormat(self, outfile, indent):
for enum_value in self.parser.enum_values:
_WriteSimpleXMLElement(outfile, 'enum_value', enum_value, indent)
def DEFINE_enum(name, default, enum_values, help, flag_values=FLAGS,
**args):
"""Registers a flag whose value can be any string from enum_values."""
DEFINE_flag(EnumFlag(name, default, help, enum_values, ** args),
flag_values)
#
# LIST FLAGS
#
class BaseListParser(ArgumentParser):
"""Base class for a parser of lists of strings.
To extend, inherit from this class; from the subclass __init__, call
BaseListParser.__init__(self, token, name)
where token is a character used to tokenize, and name is a description
of the separator.
"""
def __init__(self, token=None, name=None):
assert name
super(BaseListParser, self).__init__()
self._token = token
self._name = name
self.syntactic_help = "a %s separated list" % self._name
def Parse(self, argument):
if isinstance(argument, list):
return argument
elif argument == '':
return []
else:
return [s.strip() for s in argument.split(self._token)]
def Type(self):
return '%s separated list of strings' % self._name
class ListParser(BaseListParser):
"""Parser for a comma-separated list of strings."""
def __init__(self):
BaseListParser.__init__(self, ',', 'comma')
def WriteCustomInfoInXMLFormat(self, outfile, indent):
BaseListParser.WriteCustomInfoInXMLFormat(self, outfile, indent)
_WriteSimpleXMLElement(outfile, 'list_separator', repr(','), indent)
class WhitespaceSeparatedListParser(BaseListParser):
"""Parser for a whitespace-separated list of strings."""
def __init__(self):
BaseListParser.__init__(self, None, 'whitespace')
def WriteCustomInfoInXMLFormat(self, outfile, indent):
BaseListParser.WriteCustomInfoInXMLFormat(self, outfile, indent)
separators = list(string.whitespace)
separators.sort()
for ws_char in string.whitespace:
_WriteSimpleXMLElement(outfile, 'list_separator', repr(ws_char), indent)
def DEFINE_list(name, default, help, flag_values=FLAGS, **args):
"""Registers a flag whose value is a comma-separated list of strings."""
parser = ListParser()
serializer = ListSerializer(',')
DEFINE(parser, name, default, help, flag_values, serializer, **args)
def DEFINE_spaceseplist(name, default, help, flag_values=FLAGS, **args):
"""Registers a flag whose value is a whitespace-separated list of strings.
Any whitespace can be used as a separator.
"""
parser = WhitespaceSeparatedListParser()
serializer = ListSerializer(' ')
DEFINE(parser, name, default, help, flag_values, serializer, **args)
#
# MULTI FLAGS
#
class MultiFlag(Flag):
"""A flag that can appear multiple time on the command-line.
The value of such a flag is a list that contains the individual values
from all the appearances of that flag on the command-line.
See the __doc__ for Flag for most behavior of this class. Only
differences in behavior are described here:
* The default value may be either a single value or a list of values.
A single value is interpreted as the [value] singleton list.
* The value of the flag is always a list, even if the option was
only supplied once, and even if the default value is a single
value
"""
def __init__(self, *args, **kwargs):
Flag.__init__(self, *args, **kwargs)
self.help += ';\n repeat this option to specify a list of values'
def Parse(self, arguments):
"""Parses one or more arguments with the installed parser.
Args:
arguments: a single argument or a list of arguments (typically a
list of default values); a single argument is converted
internally into a list containing one item.
"""
if not isinstance(arguments, list):
# Default value may be a list of values. Most other arguments
# will not be, so convert them into a single-item list to make
# processing simpler below.
arguments = [arguments]
if self.present:
# keep a backup reference to list of previously supplied option values
values = self.value
else:
# "erase" the defaults with an empty list
values = []
for item in arguments:
# have Flag superclass parse argument, overwriting self.value reference
Flag.Parse(self, item) # also increments self.present
values.append(self.value)
# put list of option values back in the 'value' attribute
self.value = values
def Serialize(self):
if not self.serializer:
raise FlagsError("Serializer not present for flag %s" % self.name)
if self.value is None:
return ''
s = ''
multi_value = self.value
for self.value in multi_value:
if s: s += ' '
s += Flag.Serialize(self)
self.value = multi_value
return s
def Type(self):
return 'multi ' + self.parser.Type()
def DEFINE_multi(parser, serializer, name, default, help, flag_values=FLAGS,
**args):
"""Registers a generic MultiFlag that parses its args with a given parser.
Auxiliary function. Normal users should NOT use it directly.
Developers who need to create their own 'Parser' classes for options
which can appear multiple times can call this module function to
register their flags.
"""
DEFINE_flag(MultiFlag(parser, serializer, name, default, help, **args),
flag_values)
def DEFINE_multistring(name, default, help, flag_values=FLAGS, **args):
"""Registers a flag whose value can be a list of any strings.
Use the flag on the command line multiple times to place multiple
string values into the list. The 'default' may be a single string
(which will be converted into a single-element list) or a list of
strings.
"""
parser = ArgumentParser()
serializer = ArgumentSerializer()
DEFINE_multi(parser, serializer, name, default, help, flag_values, **args)
def DEFINE_multi_int(name, default, help, lower_bound=None, upper_bound=None,
flag_values=FLAGS, **args):
"""Registers a flag whose value can be a list of arbitrary integers.
Use the flag on the command line multiple times to place multiple
integer values into the list. The 'default' may be a single integer
(which will be converted into a single-element list) or a list of
integers.
"""
parser = IntegerParser(lower_bound, upper_bound)
serializer = ArgumentSerializer()
DEFINE_multi(parser, serializer, name, default, help, flag_values, **args)
def DEFINE_multi_float(name, default, help, lower_bound=None, upper_bound=None,
flag_values=FLAGS, **args):
"""Registers a flag whose value can be a list of arbitrary floats.
Use the flag on the command line multiple times to place multiple
float values into the list. The 'default' may be a single float
(which will be converted into a single-element list) or a list of
floats.
"""
parser = FloatParser(lower_bound, upper_bound)
serializer = ArgumentSerializer()
DEFINE_multi(parser, serializer, name, default, help, flag_values, **args)
# Now register the flags that we want to exist in all applications.
# These are all defined with allow_override=1, so user-apps can use
# these flagnames for their own purposes, if they want.
DEFINE_flag(HelpFlag())
DEFINE_flag(HelpshortFlag())
DEFINE_flag(HelpXMLFlag())
# Define special flags here so that help may be generated for them.
# NOTE: Please do NOT use _SPECIAL_FLAGS from outside this module.
_SPECIAL_FLAGS = FlagValues()
DEFINE_string(
'flagfile', "",
"Insert flag definitions from the given file into the command line.",
_SPECIAL_FLAGS)
DEFINE_string(
'undefok', "",
"comma-separated list of flag names that it is okay to specify "
"on the command line even if the program does not define a flag "
"with that name. IMPORTANT: flags in this list that have "
"arguments MUST use the --flag=value format.", _SPECIAL_FLAGS)
| Python |
#!/usr/bin/env python
#
# hanzim2dict
#
# Original version written by Michael Robinson (robinson@netrinsics.com)
# Version 0.0.2
# Copyright 2004
#
# 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.
#
# Usage: Run hanzim2dict in a directory containing the "zidianf.gb",
# "cidianf.gb", and "sanzidianf.gb" files from the Hanzi Master distribution
# (available at http://zakros.ucsd.edu/~arobert/hanzim.html). The output
# will be a StarDict dictionary in 2.4.2 format: hanzim.dict, hanzim.idx,
# and hanzim.ifo
#
# The dictionary and index files may be compressed as follows:
# $ gzip -9 hanzim.idx
# $ dictzip hanzim.dict
#
from string import split
from codecs import getdecoder, getencoder
from struct import pack
class Word:
def __init__(self, code, definition):
self.code = code
self.definition = [definition]
def add(self, definition):
self.definition.append(definition)
wordmap = {}
fromGB = getdecoder("GB2312")
toUTF = getencoder("utf_8")
file = open("zidianf.gb", "r")
lines = map(lambda x: split(x[:-1], '\t'), file.readlines())
for line in lines:
code = toUTF(fromGB(line[0])[0])[0]
pinyin = line[2]
definition = '<'+pinyin+'> '+line[3]+' ['+line[1]+']'
if wordmap.has_key(code):
wordmap[code].add(definition)
else:
wordmap[code] = Word(code, definition)
for filename in ("cidianf.gb", "sanzicidianf.gb"):
file = open(filename, "r")
lines = map(lambda x: split(x[:-1], '\t'), file.readlines())
for line in lines:
if len(line) < 2:
print len(line)
continue
code = toUTF(fromGB(line[0][:-2])[0])[0]
definition = line[1]+' ['+line[0][-1:]+']'
if wordmap.has_key(code):
wordmap[code].add(definition)
else:
wordmap[code] = Word(code, definition)
dict = open("hanzim.dict", "wb")
idx = open("hanzim.idx", "wb")
ifo = open("hanzim.ifo", "wb")
offset = 0
count = 0
keylen = 0
keys = list(wordmap.keys())
keys.sort()
for key in keys:
word = wordmap[key]
deftext = ""
multi = False
for d in word.definition:
if multi:
deftext += '\n'
deftext += d
multi = True
dict.write(deftext)
idx.write(key+'\0')
idx.write(pack("!I", offset))
idx.write(pack("!I", len(deftext)))
offset += len(deftext)
count += 1
keylen += len(key)
dict.close()
idx.close()
ifo.write("StarDict's dict ifo file\n")
ifo.write("version=2.4.2\n")
ifo.write("bookname=Hanzi Master 1.3\n")
ifo.write("wordcount="+str(count)+"\n")
ifo.write("idxfilesize="+str(keylen+(count*9))+"\n")
ifo.write("author=Adrian Robert\n")
ifo.write("email=arobert@cogsci.ucsd.edu\n")
ifo.write("website=http://zakros.ucsd.edu/~arobert/hanzim.html\n")
ifo.write("sametypesequence=m\n")
ifo.close()
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, os, string, re, glob
import libxml2dom
fencoding = 'utf-8'
whattoextract = u'康熙字典'
#def TextInNode(node):
# result = u''
# for child in node.childNodes:
# if child.nodeType == child.TEXT_NODE:
# result += child.nodeValue
# else:
# result += TextInNode(child)
# return result
filelist = glob.glob('*.htm')
filenum = len(filelist)
num = 0
errorfiles = []
for filename in filelist:
num += 1
print >> sys.stderr, filename, num, 'of', filenum
try:
fp = open(filename, 'r')
doc = libxml2dom.parseString(fp.read(), html=1)
fp.close()
style = doc.getElementsByTagName("style")[0].textContent
style = re.search(r'(?s)\s*\.(\S+)\s*{\s*display:\s*none', style)
displaynone = style.group(1)
tabpages = doc.getElementsByTagName("div")
tabpages = filter(lambda s: s.getAttribute("class") == "tab-page", tabpages)
for tabpage in tabpages:
found = False
for node in tabpage.childNodes:
if node.nodeType == node.ELEMENT_NODE and node.name == 'h2':
if node.textContent == whattoextract:
found = True
break
if found:
spans = tabpage.getElementsByTagName("span")
for span in spans:
if span.getAttribute("class") == "kszi":
character = span.textContent
paragraphs = tabpage.getElementsByTagName("p")
thisitem = character + u'\t'
for paragraph in paragraphs:
if paragraph.getAttribute("class") <> displaynone:
#print TextInNode(paragraph).encode(fencoding)
text = paragraph.textContent
#text = filter(lambda s: not s in u' \t\r\n', text)
text = re.sub(r'\s+', r' ', text)
thisitem += text + u'\\n'
print thisitem.encode(fencoding)
except:
print >> sys.stderr, 'error occured'
errorfiles += [filename]
continue
if errorfiles:
print >> sys.stderr, 'Error files:', '\n'.join(errorfiles)
| Python |
import sys, string
for line in sys.stdin.readlines():
words = string.split(line[:-1], '\t')
muci = words[1]
sheng = words[2]
deng = words[3]
hu = words[4]
yunbu = words[5]
diao = words[6]
fanqie= words[7]
she = words[8]
chars = words[9]
romazi= words[10]
beizhu= words[12]
pinyin= words[13]
psyun = words[22]
if beizhu == '':
print "%s\t%s %s%s%s%s%s%s %sQIE PINYIN%s PSYUN%s\\n%s" % (romazi, muci, sheng, yunbu, she, hu, deng, diao, fanqie, pinyin, psyun, chars)
else:
print "%s\t%s %s%s%s%s%s%s %sQIE PINYIN%s PSYUN%s\\n%s\\n%s" % (romazi, muci, sheng, yunbu, she, hu, deng, diao, fanqie, pinyin, psyun, chars, beizhu)
| Python |
# This tool convert KangXiZiDian djvu files to tiff files.
# Download djvu files: http://bbs.dartmouth.edu/~fangq/KangXi/KangXi.tar
# Character page info: http://wenq.org/unihan/Unihan.txt as kIRGKangXi field.
# Character seek position in Unihan.txt http://wenq.org/unihan/unihandata.txt
# DjVuLibre package provides the ddjvu tool.
# The 410 page is bad, but it should be blank page in fact. so just remove 410.tif
import os
if __name__ == "__main__":
os.system("mkdir tif")
pages = range(1, 1683+1)
for i in pages:
page = str(i)
print(page)
os.system("ddjvu -format=tiff -page="+ page + " -scale=100 -quality=150 KangXiZiDian.djvu"+ " tif/" + page + ".tif")
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gimpfu import *
import os
def prepare_image(image, visibleLayers, size, numColors = None):
"""prepare custom image
image - image object to change
size - size of the image in pixels
visibleLayers - a list of layers that must be visible
"""
for layer in image.layers:
if layer.name in visibleLayers:
layer.visible = True
else:
image.remove_layer(layer)
gimp.pdb.gimp_image_merge_visible_layers(image, CLIP_TO_IMAGE)
drawable=gimp.pdb.gimp_image_get_active_layer(image)
gimp.pdb.gimp_layer_scale_full(drawable, size, size, False, INTERPOLATION_CUBIC)
"""
image 670x670, all layers have the same dimensions
after applying gimp_image_scale_full functions with size=32,
image.width = 32, image.height = 32
layer.width = 27, layer.height = 31
gimp.pdb.gimp_image_scale_full(image, size, size, INTERPOLATION_CUBIC)
"""
#print 'width = {0}, height = {1}'.format(drawable.width, drawable.height)
#print 'width = {0}, height = {1}'.format(image.width, image.height)
if numColors != None:
gimp.pdb.gimp_image_convert_indexed(image, NO_DITHER, MAKE_PALETTE, numColors, False, False, "")
def save_image(image, dstFilePath):
dirPath = os.path.dirname(dstFilePath)
if not os.path.exists(dirPath):
os.makedirs(dirPath)
drawable=gimp.pdb.gimp_image_get_active_layer(image)
gimp.pdb.gimp_file_save(image, drawable, dstFilePath, dstFilePath)
gimp.delete(drawable)
gimp.delete(image)
def create_icon(origImage, visibleLayers, props):
"""visibleLayers - a list of layers that must be visible
props - tuple of image properties in format ((size, bpp), ...)
where:
size - size of the icon in pixels,
bpp - bits per pixel, None to leave by default
return value - new image
"""
iconImage = None
i = 0
for prop in props:
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, visibleLayers, prop[0], prop[1])
image.layers[0].name = 's{0}'.format(i)
if iconImage == None:
iconImage = image
else:
newLayer = gimp.pdb.gimp_layer_new_from_drawable(image.layers[0], iconImage)
gimp.pdb.gimp_image_add_layer(iconImage, newLayer, -1)
gimp.delete(image)
i += 1
return iconImage
def stardict_images(srcFilePath, rootDir):
if not rootDir:
# srcFilePath = rootDir + "/pixmaps/stardict.xcf"
if not srcFilePath.endswith("/pixmaps/stardict.xcf"):
print 'Unable to automatically detect StarDict root directory. Specify non-blank root directory parameter.'
return
dstDirPath = os.path.dirname(srcFilePath)
dstDirPath = os.path.dirname(dstDirPath)
else:
dstDirPath = rootDir
"""
print 'srcFilePath = {0}'.format(srcFilePath)
print 'rootDir = {0}'.format(rootDir)
print 'dstDirPath = {0}'.format(dstDirPath)
"""
dstStarDict_s128_FilePath=os.path.join(dstDirPath, "pixmaps/stardict_128.png")
dstStarDict_s32_FilePath=os.path.join(dstDirPath, "pixmaps/stardict_32.png")
dstStarDict_s16_FilePath=os.path.join(dstDirPath, "pixmaps/stardict_16.png")
dstStarDict_FilePath=os.path.join(dstDirPath, "pixmaps/stardict.png")
dstStarDictEditor_s128_FilePath=os.path.join(dstDirPath, "pixmaps/stardict-editor_128.png")
dstStarDictEditor_s32_FilePath=os.path.join(dstDirPath, "pixmaps/stardict-editor_32.png")
dstStarDictEditor_s16_FilePath=os.path.join(dstDirPath, "pixmaps/stardict-editor_16.png")
dstStarDictIconFilePath=os.path.join(dstDirPath, "pixmaps/stardict.ico")
dstStarDictEditorIconFilePath=os.path.join(dstDirPath, "pixmaps/stardict-editor.ico")
dstStarDictUninstIconFilePath=os.path.join(dstDirPath, "pixmaps/stardict-uninst.ico")
dstDockletNormalFilePath=os.path.join(dstDirPath, "src/pixmaps/docklet_normal.png")
dstDockletScanFilePath=os.path.join(dstDirPath, "src/pixmaps/docklet_scan.png")
dstDockletStopFilePath=os.path.join(dstDirPath, "src/pixmaps/docklet_stop.png")
dstDockletGPENormalFilePath=os.path.join(dstDirPath, "src/pixmaps/docklet_gpe_normal.png")
dstDockletGPEScanFilePath=os.path.join(dstDirPath, "src/pixmaps/docklet_gpe_scan.png")
dstDockletGPEStopFilePath=os.path.join(dstDirPath, "src/pixmaps/docklet_gpe_stop.png")
dstWordPickFilePath=os.path.join(dstDirPath, "src/win32/acrobat/win32/wordPick.bmp")
origImage=gimp.pdb.gimp_file_load(srcFilePath, srcFilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2"), 128)
save_image(image, dstStarDict_s128_FilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2"), 32)
save_image(image, dstStarDict_s32_FilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2"), 16)
save_image(image, dstStarDict_s16_FilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2"), 64)
save_image(image, dstStarDict_FilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2", "edit"), 128)
save_image(image, dstStarDictEditor_s128_FilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2", "edit"), 32)
save_image(image, dstStarDictEditor_s32_FilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2", "edit"), 16)
save_image(image, dstStarDictEditor_s16_FilePath)
image = create_icon(origImage, ("book1", "book2"),
((16, None), (32, None), (48, None), (16, 256), (32, 256), (48, 256), (256, None))
)
save_image(image, dstStarDictIconFilePath)
image = create_icon(origImage, ("book1", "book2", "edit"),
((16, None), (32, None), (48, None), (16, 256), (32, 256), (48, 256), (256, None))
)
save_image(image, dstStarDictEditorIconFilePath)
image = create_icon(origImage, ("book1", "book2", "cross"),
((16, None), (32, None), (48, None), (16, 256), (32, 256), (48, 256), (256, None))
)
save_image(image, dstStarDictUninstIconFilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2"), 32)
save_image(image, dstDockletNormalFilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2", "search"), 32)
save_image(image, dstDockletScanFilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2", "stop"), 32)
save_image(image, dstDockletStopFilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2"), 16)
save_image(image, dstDockletGPENormalFilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2", "search"), 16)
save_image(image, dstDockletGPEScanFilePath)
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2", "stop"), 16)
save_image(image, dstDockletGPEStopFilePath)
# See AVToolButtonNew function in PDF API Reference
# Recommended icon size is 18x18, but it looks too small...
image = gimp.pdb.gimp_image_duplicate(origImage)
prepare_image(image, ("book1", "book2"), 22)
gimp.set_background(192, 192, 192)
gimp.pdb.gimp_layer_flatten(image.layers[0])
save_image(image, dstWordPickFilePath)
register(
"stardict_images",
"Create images for StarDict",
"Create images for StarDict",
"StarDict team",
"GPL",
"Mar 2011",
"<Toolbox>/Tools/stardict images",
"",
[
(PF_FILE, "src_image", "Multilayer image used as source for all other images in StarDict, "
+ "normally that is pixmaps/stardict.xcf is StarDict source tree.", None),
(PF_DIRNAME, "stardict_dir", "Root directory of StarDict source tree. New images will be saved here.", None)
],
[],
stardict_images)
main()
| Python |
#!/usr/bin/python
# WinVNKey Hannom Database to Stardict dictionary source Conversion Tool
# coded by wesnoth@ustc on 070804
# http://winvnkey.sourceforge.net
import sys, os, string, types, pprint
infileencoding = 'utf-16-le'
outfileencoding = 'utf-8'
def showhelp():
print "Usage: %s filename" % sys.argv[0]
def ishantu(str):
if len(str) > 0 and ord(str[0]) > 0x2e80:
return True
else:
return False
def mysplit(line):
status = 0 # 0: normal, 1: quote
i = 0
line = line.lstrip()
linelen = len(line)
while i < linelen:
if status == 0 and line[i].isspace():
break
if line[i] == u'"':
status = 1 - status
i += 1
#print 'mysplit: i=%d, line=%s' % (i, `line`)
if i == 0:
return []
else:
line = [line[:i], line[i:].strip()]
if line[1] == u'':
return [line[0]]
else:
return line
if __name__ == '__main__':
if len(sys.argv) <> 2:
showhelp()
else:
fp = open(sys.argv[1], 'r')
print 'Reading file...'
lines = unicode(fp.read(), infileencoding).split(u'\n')
lineno = 0
hugedict = {}
print 'Generating Han-Viet dict...'
for line in lines:
lineno += 1
if line.endswith(u'\r'):
line = line[:-1]
if line.startswith(u'\ufeff'):
line = line[1:]
ind = line.find(u'#')
if ind >= 0:
line = line[:ind]
line = mysplit(line)
if len(line) == 0:
continue
elif len(line) == 1:
continue # ignore this incomplete line
if line[0].startswith(u'"') and line[0].endswith(u'"'):
line[0] = line[0][1:-1]
if line[0].startswith(u'U+') or line[0].startswith(u'u+'):
line[0] = unichr(int(line[0][2:], 16))
if not ishantu(line[0]):
continue # invalid Han character
#print 'error occurred on line %d: %s' % (lineno, `line`)
if line[1].startswith(u'"') and line[1].endswith(u'"'):
line[1] = line[1][1:-1]
line[1] = filter(None, map(string.strip, line[1].split(u',')))
#hugedict[line[0]] = hugedict.get(line[0], []) + line[1]
for item in line[1]:
if not hugedict.has_key(line[0]):
hugedict[line[0]] = [item]
elif not item in hugedict[line[0]]:
hugedict[line[0]] += [item]
#print lineno, `line`
#for hantu, quocngu in hugedict.iteritems():
# print hantu.encode('utf-8'), ':',
# for viettu in quocngu:
# print viettu.encode('utf-8'), ',',
# print
fp.close()
print 'Generating Viet-Han dict...'
dicthuge = {}
for hantu, quocngu in hugedict.iteritems():
for viettu in quocngu:
if not dicthuge.has_key(viettu):
dicthuge[viettu] = [hantu]
elif not hantu in dicthuge[viettu]:
dicthuge[viettu] += [hantu]
print 'Writing Han-Viet dict...'
gp = open('hanviet.txt', 'w')
for hantu, quocngu in hugedict.iteritems():
gp.write(hantu.encode('utf-8'))
gp.write('\t')
gp.write((u', '.join(quocngu)).encode('utf-8'))
gp.write('\n')
gp.close()
print 'Writing Viet-Han dict...'
gp = open('viethan.txt', 'w')
for quocngu,hantu in dicthuge.iteritems():
gp.write(quocngu.encode('utf-8'))
gp.write('\t')
gp.write((u' '.join(hantu)).encode('utf-8'))
gp.write('\n')
gp.close()
| Python |
#!/usr/bin/env python
#
# uyghur2dict
# By Abdisalam (anatilim@gmail.com), inspired by Michael Robinson's hanzim2dict converter.
#
# Original version, hanzim2dict, written by Michael Robinson (robinson@netrinsics.com)
# Version 0.0.2
# Copyright 2004
#
# 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.
#
# Usage: Run hanzim2dict in a directory containing the "zidianf.gb",
# "cidianf.gb", and "sanzidianf.gb" files from the Hanzi Master distribution
# (available at http://zakros.ucsd.edu/~arobert/hanzim.html). The output
# will be a StarDict dictionary in 2.4.2 format: hanzim.dict, hanzim.idx,
# and hanzim.ifo
#
# The dictionary and index files may be compressed as follows:
# $ gzip -9 hanzim.idx
# $ dictzip hanzim.dict
#
from string import split
from struct import pack
class Word:
def __init__(self, code, definition):
self.code = code
self.definition = [definition]
def add(self, definition):
self.definition.append(definition)
wordmap = {}
file = open("ChineseUyghurStarDict.txt", "r")
lines = map(lambda x: split(x[:-1], '\t\t'), file.readlines())
for line in lines:
code = line[0]
definition = line[1]
if wordmap.has_key(code):
wordmap[code].add(definition)
else:
wordmap[code] = Word(code, definition)
dict = open("Anatilim_Chinese_Uyghur.dict", "wb")
idx = open("Anatilim_Chinese_Uyghur.idx", "wb")
ifo = open("Anatilim_Chinese_Uyghur.ifo", "wb")
offset = 0
count = 0
keylen = 0
keys = list(wordmap.keys())
keys.sort()
for key in keys:
word = wordmap[key]
deftext = ""
for d in word.definition:
deftext=d
deftext += '\0'
dict.write(deftext)
idx.write(key+'\0')
idx.write(pack("!I", offset))
idx.write(pack("!I", len(deftext)))
offset += len(deftext)
count += 1
keylen += len(key)
dict.close()
idx.close()
ifo.write("StarDict's dict ifo file\n")
ifo.write("version=2.4.2\n")
ifo.write("bookname=Anatilim 《汉维词典》-- Anatilim Chinese Uyghur Dictionary\n")
ifo.write("wordcount="+str(count)+"\n")
ifo.write("idxfilesize="+str(keylen+(count*9))+"\n")
ifo.write("author=Abdisalam\n")
ifo.write("email=anatilim@gmail.com\n")
ifo.write("description=感谢新疆维吾尔自治区语委会、新疆青少年出版社为我们提供《汉维词典》的词库\n")
ifo.write("sametypesequence=m\n")
ifo.close() | Python |
#!/usr/bin/env python2
#
# converts XML JMDict to Stardict idx/dict format
# JMDict website: http://www.csse.monash.edu.au/~jwb/j_jmdict.html
#
# Date: 3rd July 2003
# Author: Alastair Tse <acnt2@cam.ac.uk>
# License: BSD (http://www.opensource.org/licenses/bsd-license.php)
#
# Usage: jm2stardict expects the file JMdict.gz in the current working
# directory and outputs to files jmdict-ja-en and jmdict-en-ja
#
# To compress the resulting files, use:
#
# gzip -9 jmdict-en-ja.idx
# gzip -9 jmdict-ja-en.idx
# dictzip jmdict-en-ja.dict
# dictzip jmdict-ja-en.dict
#
# note - dictzip is from www.dict.org
#
import xml.sax
from xml.sax.handler import *
import gzip
import struct, sys, string, codecs,os
def text(nodes):
label = ""
textnodes = filter(lambda x: x.nodeName == "#text", nodes)
for t in textnodes:
label += t.data
return label
def strcasecmp(a, b):
result = 0
# to ascii
#str_a = string.join(filter(lambda x: ord(x) < 128, a[0]), "").lower()
#str_b = string.join(filter(lambda x: ord(x) < 128, b[0]), "").lower()
#result = cmp(str_a, str_b)
# if result == 0:
result = cmp(a[0].lower() , b[0].lower())
return result
def merge_dup(list):
newlist = []
lastkey = ""
for x in list:
if x[0] == lastkey:
newlist[-1] = (newlist[-1][0], newlist[-1][1] + "\n" + x[1])
else:
newlist.append(x)
lastkey = x[0]
return newlist
class JMDictHandler(ContentHandler):
def __init__(self):
self.mapping = []
self.state = ""
self.buffer = ""
def startElement(self, name, attrs):
if name == "entry":
self.kanji = []
self.chars = []
self.gloss = []
self.state = ""
self.buffer = ""
elif name == "keb":
self.state = "keb"
elif name == "reb":
self.state = "reb"
elif name == "gloss" and not attrs:
self.state = "gloss"
elif name == "xref":
self.state = "xref"
def endElement(self, name):
if name == "entry":
self.mapping.append((self.kanji, self.chars, self.gloss))
elif name == "keb":
self.kanji.append(self.buffer)
elif name == "reb":
self.chars.append(self.buffer)
elif name == "gloss" and self.buffer:
self.gloss.append(self.buffer)
elif name == "xref":
self.gloss.append(self.buffer)
self.buffer = ""
self.state = ""
def characters(self, ch):
if self.state in ["keb", "reb", "gloss", "xref"]:
self.buffer = self.buffer + ch
def map_to_file(dictmap, filename):
dict = open(filename + ".dict","wb")
idx = open(filename + ".idx","wb")
offset = 0
idx.write("StarDict's idx file\nversion=2.1.0\n");
idx.write("bookname=" + filename + "\nauthor=Jim Breen\nemail=j.breen@csse.monash.edu.au\nwebsite=http://www.csse.monash.edu.au/~jwb/j_jmdict.html\ndescription=Convert to stardict by Alastair Tse <liquidx@gentoo.org>, http://www-lce.eng.cam.ac.uk/~acnt2/code/\ndate=2003.07.01\n")
idx.write("sametypesequence=m\n")
idx.write("BEGIN:\n")
idx.write(struct.pack("!I",len(dictmap)))
for k,v in dictmap:
k_utf8 = k.encode("utf-8")
v_utf8 = v.encode("utf-8")
idx.write(k_utf8 + "\0")
idx.write(struct.pack("!I",offset))
idx.write(struct.pack("!I",len(v_utf8)))
offset += len(v_utf8)
dict.write(v_utf8)
dict.close()
idx.close()
if __name__ == "__main__":
print "opening xml dict .."
f = gzip.open("JMdict.gz")
#f = open("jmdict_sample.xml")
print "parsing xml file .."
parser = xml.sax.make_parser()
handler = JMDictHandler()
parser.setContentHandler(handler)
parser.parse(f)
f.close()
print "creating dictionary .."
# create a japanese -> english mappings
jap_to_eng = []
for kanji,chars,gloss in handler.mapping:
for k in kanji:
key = k
value = string.join(chars + gloss, "\n")
jap_to_eng.append((key,value))
for c in chars:
key = c
value = string.join(kanji + gloss, "\n")
jap_to_eng.append((key,value))
eng_to_jap = []
for kanji,chars,gloss in handler.mapping:
for k in gloss:
key = k
value = string.join(kanji + chars, "\n")
eng_to_jap.append((key,value))
print "sorting dictionary .."
jap_to_eng.sort(strcasecmp)
eng_to_jap.sort(strcasecmp)
print "merging and pruning dups.."
jap_to_eng = merge_dup(jap_to_eng)
eng_to_jap = merge_dup(eng_to_jap)
print "writing to files.."
# create dict and idx file
map_to_file(jap_to_eng, "jmdict-ja-en")
map_to_file(eng_to_jap, "jmdict-en-ja")
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Script for decoding Lingea Dictionary (.trd) file
# Result is <header>\t<definition> file, convertable easily
# by stardict-editor from package stardict-tools into native
# Stardict dictionary (stardict.sf.net and www.stardict.org)
#
# Copyright (C) 2007 - Klokan Petr Přidal (www.klokan.cz)
#
# Based on script CobuildConv.rb by Nomad
# http://hp.vector.co.jp/authors/VA005784/cobuild/cobuildconv.html
#
# Version history:
# 0.4 (30.10.2007) Patch by Petr Dlouhy, optional HTML generation
# 0.3 (28.10.2007) Patch by Petr Dlouhy, cleanup, bugfix. More dictionaries.
# 0.2 (19.7.2007) Changes, documentation, first 100% dictionary
# 0.1 (20.5.2006) Initial version based on Nomad specs
#
# Supported dictionaries:
# - Lingea Německý Kapesní slovník
# - Lingea Anglický Kapesní slovník
# - Lingea 2002 series (theoretically)
#
# Modified by:
# - Petr Dlouhy (petr.dlouhy | email.cz)
# Generalization of data block rules, sampleFlag 0x04, sound out fix, data phrase prefix with comment (0x04)
# HTML output, debugging patch, options on command line
#
# <write your name here>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library 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.
# VERSION
VERSION = "0.4"
import getopt, sys
def usage():
print "Lingea Dictionary Decoder"
print "-------------------------"
print "Version: %s" % VERSION
print "Copyright (C) 2007 - Klokan Petr Pridal, Petr Dlouhy"
print
print "Usage: python lingea-trd-decoder.py DICTIONARY.trd > DICTIONARY.tab"
print "Result convertion by stardict-tools: /usr/lib/stardict-tools/tabfile"
print
print " -o <num> --out-style : Output style"
print " 0 no tags"
print " 1 \\n tags"
print " 2 html tags"
print " -h --help : Print this message"
print " -d --debug : Degub"
print " -r --debug-header : Degub - print headers"
print " -a --debug-all : Degub - print all records"
print " -l --debug-limit : Degub limit"
print
print "For HTML support in StarDict dictionary .ifo has to contain:"
print "sametypesequence=g"
print "!!! Change the .ifo file after generation by tabfile !!!"
print
try:
opts, args = getopt.getopt(sys.argv[1:], "hdo:ral:", ["help", "debug", "out-style=", "debug-header", "debug-all", "debug-limit="])
except getopt.GetoptError:
usage()
print "ERROR: Bad option"
sys.exit(2)
import locale
DEBUG = False
OUTSTYLE = 2
DEBUGHEADER = False
DEBUGALL = False
DEBUGLIMIT = 1
for o, a in opts:
if o in ("-d", "-debug"):
# DEBUGING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DEBUG = True
if o in ("-o", "--out-style"):
# output style
OUTSTYLE = locale.atoi(a)
if OUTSTYLE > 2:
usage()
print "ERROR: Output style not specified"
if o in ("-r", "--debug-header"):
# If DEBUG and DEBUGHEADER, then print just all header records
DEBUGHEADER = True
if o in ("-a", "--debug-all"):
# If DEBUG and DEBUGALL then print debug info for all records
DEBUGALL = True
if o in ("-h", "--help"):
usage()
sys.exit(0)
if o in ("-l", "--debug-limit"):
# Number of wrong records for printing to stop during debugging
DEBUGLIMIT = locale.atoi(a)
# FILENAME is a first parameter on the commandline now
if len(args) == 1:
FILENAME = args[0]
else:
usage()
print "ERROR: You have to specify .trd file to decode"
sys.exit(2)
from struct import *
import re
alpha = ['\x00', 'a','b','c','d','e','f','g','h','i',
'j','k','l','m','n','o','p','q','r','s',
't','u','v','w','x','y','z','#AL27#','#AL28#','#AL29#',
'#AL30#','#AL31#', ' ', '.', '<', '>', ',', ';', '-', '#AL39#',
'#GRAVE#', '#ACUTE#', '#CIRC#', '#TILDE#', '#UML#', '#AL45#', '#AL46#', '#CARON#', '#AL48#', '#CEDIL#',
'#AL50#', '#AL51#', '#GREEK#', '#AL53#', '#AL54#', '#AL55#', '#AL56#', '#AL57#', '#AL58#', '#SYMBOL#',
'#AL60#', '#UPCASE#', '#SPECIAL#', '#UNICODE#'] # 4 bytes after unicode
upcase = ['#UP0#','#UP1#','#UP2#','#UP3#','#UP4#','#UP5#','#UP6#','#UP7#','#UP8#','#UP9#',
'#UP10#','#UP11#','#UP12#','#UP13#','#UP14#','#UP15#','#UP16#','#UP17#','#UP18#','#UP19#',
'#UP20#','#UP21#','#UP22#','#UP23#','#UP24#','#UP25#','#UP26#','#UP27#','#UP28#','#UP29#',
'#UP30#','#UP31#','A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P','Q','R',
'S','T','U','V','W','X','Y','Z','#UP58#','#UP59#',
'#UP60#','#UP61#','#UP62#','#UP63#']
upcase_pron = ['#pr0#', '#pr1#','#pr2#','#pr3#','#pr4#','#pr5#','#pr6#','#pr7#','#pr8#','#pr9#',
'#pr10#', '#pr11#','#pr12#','#pr13#','#pr14#','#pr15#','#pr16#','#pr17#','#pr18#','#pr19#',
'#pr20#', '#pr21#','#pr22#','#pr23#','#pr24#','#pr25#','#pr26#','#pr27#','#pr28#','#pr29#',
'#pr30#', '#pr31#','ɑ','#pr33#','ʧ','ð','ə','ɜ','#pr38#','æ',
'ɪ', 'ɭ','#pr42#','ŋ','#pr44#','ɳ','ɔ','#pr47#','ɒ','ɽ',
'ʃ', 'θ','ʊ','ʌ','#pr54#','#pr55#','#pr56#','ʒ','#pr58#','#pr59#',
'#pr60#', '#pr61#','#pr62#','#pr63#']
symbol = ['#SY0#', '#SY1#','#SY2#','#SY3#','§','#SY5#','#SY6#','#SY7#','#SY8#','#SY9#',
'#SY10#', '#SY11#','#SY12#','#SY13#','#SY14#','™','#SY16#','#SY17#','¢','£',
'#SY20#', '#SY21#','#SY22#','#SY23#','©','#SY25#','#SY26#','#SY27#','®','°',
'#SY30#', '²','³','#SY33#','#SY34#','#SY35#','¹','#SY37#','#SY38#','#SY39#',
'½', '#SY41#','#SY42#','×','÷','#SY45#','#SY46#','#SY47#','#SY48#','#SY49#',
'#SY50#', '#SY51#','#SY52#','#SY53#','#SY54#','#SY55#','#SY56#','#SY57#','#SY58#','#SY59#',
'#SY60#', '#SY61#','#SY62#','#SY63#']
special = ['#SP0#', '!','"','#','$','%','&','\'','(',')',
'*', '+','#SP12#','#SP13#','#SP14#','/','0','1','2','3',
'4', '5','6','7','8','9',':',';','<','=',
'>', '?','@','[','\\',']','^','_','`','{',
'|', '}','~','#SP43#','#SP44#','#SP45#','#SP46#','#SP47#','#SP48#','#SP49#',
'#SP50#', '#SP51#','#SP52#','#SP53#','#SP54#','#SP55#','#SP56#','#SP57#','#SP58#','#SP59#',
'#SP60#', '#SP61#','#SP62#','#SP63#']
wordclass = ('#0#','n:','adj:','pron:','#4#','v:','adv:','prep:','#8#','#9#',
'intr:','phr:','#12#','#13#','#14#','#15#','#16#','#17#','#18#','#19#',
'#20#','#21#','#22#','#23#','#24#','#25#','#26#','#27#','#28#','#29#',
'#30#','#31#')
if OUTSTYLE == 0:
tag = {
'db':('' ,''), #Data begining
'rn':('' ,'\t'), #Record name
'va':('' ,' '), #Header variant
'wc':('(' ,')'), #WordClass
'pa':('' ,' '), #Header parts
'fo':('(' ,') '), #Header forms
'on':('(' ,')' ), #Header origin note
'pr':('[' ,']'), #Header pronunciation
'dv':('{' ,'} '), #Header dataVariant
'sa':('`' ,'`' ), #Data sample
'sw':('' ,''), #Data sample wordclass; is no printed by Lingea
'do':('`' ,'`' ), #Data origin note
'df':('' ,' '), #Data definition
'ps':('"' ,'" '), #Data phrase short form
'pg':('"' ,' = '), #Data phrase green
'pc':('`' ,'`'), #Data phrase comment; this comment is not printed by Lingea), but it seems useful
'p1':('"' ,' = '), #Data phrase 1
'p2':('' ,'" ' ), #Data phrase 2
'sp':('"' ,' = ' ),#Data simple phrase
'b1':('"' ,' = '), #Data phrase (block) 1
'b2':('" ' ,''), #Data phrase (block) 2
}
if OUTSTYLE == 1:
tag = {
'db':('•' ,''), #Data begining
'rn':('' ,'\t'), #Record name
'va':('' ,' '), #Header variant
'wc':('' ,'\\n'), #WordClass
'pa':('' ,':\\n'), #Header parts
'fo':('(' ,') '), #Header forms
'on':('(' ,')\\n' ), #Header origin note
'pr':('[' ,']\\n'), #Header pronunciation
'dv':('{' ,'} '), #Header dataVariant
'sa':(' ' ,'\\n' ), #Data sample
'sw':('' ,''), #Data sample wordclass; is not printed by Lingea
'do':(' ' ,' ' ), #Data origin note
'df':(' ' ,'\\n'), #Data definition
'ps':(' ' ,'\\n'), #Data phrase short form
'pg':(' ' ,' '), #Data phrase green
'pc':(' ' ,' '), #Data phrase comment; this comment is not printed by Lingea), but it seems useful
'p1':(' ' ,' '), #Data phrase 1
'p2':(' ' ,'\\n' ), #Data phrase 2
'sp':('' ,'\\n' ), #Data simple phrase
'b1':('"' ,' = '), #Data phrase (block) 1
'b2':('" ' ,''), #Data phrase (block) 2
}
if OUTSTYLE == 2:
tag = {
'db':('•' ,''), #Data begining
'rn':('' ,'\t'), #Record name
'va':('' ,' '), #Header variant
'wc':('<span size="larger" color="darkred" weight="bold">','</span>\\n'), #WordClass
'pa':('<span size="larger" color="darkred" weight="bold">',':</span>\\n'), #Header parts
'fo':('(' ,') '), #Header forms
'on':('<span color="blue">(' ,')</span>\\n' ), #Header origin note
'pr':('[' ,']\\n'), #Header pronunciation
'dv':('{' ,'} '), #Header dataVariant
'sa':(' <span color="darkred" weight="bold">' ,'</span>\\n' ), #Data sample
'sw':('' ,''), #Data sample wordclass; is not printed by Lingea
'do':(' <span color="darkred" weight="bold">' ,'</span> ' ), #Data origin note
'df':(' <span weight="bold">' ,'</span>\\n'), #Data definition
'ps':(' <span color="dimgray" weight="bold">' ,'</span>\\n'), #Data phrase short form
'pg':(' <span color="darkgreen" style="italic">' ,'</span> '), #Data phrase green
'pc':(' <span color="darkgreen" style="italic">' ,'</span> '), #Data phrase comment; this comment is not printed by Lingea), but it seems useful
'p1':(' <span color="dimgray" style="italic">' ,'</span> '), #Data phrase 1
'p2':(' ' ,'\\n' ), #Data phrase 2
'sp':('<span color="cyan">' ,'</span>\\n' ), #Data simple phrase
'b1':('"' ,' = '), #Data phrase (block) 1
'b2':('" ' ,''), #Data phrase (block) 2
}
# Print color debug functions
purple = lambda c: '\x1b[1;35m'+c+'\x1b[0m'
blue = lambda c: '\x1b[1;34m'+c+'\x1b[0m'
cyan = lambda c: '\x1b[36m'+c+'\x1b[0m'
gray = lambda c: '\x1b[1m'+c+'\x1b[0m'
def getRec(n):
"""Get data stream for record of given number"""
if n >= 0 and n < entryCount:
f.seek(index[n])
return f.read(index[n+1] - index[n])
else:
return ''
def decode_alpha( stream, nullstop=True):
"""Decode 6-bit encoding data stream from the begining untit first NULL"""
offset = 0
triple = 0
result = []
while triple < len( stream ):
if offset % 4 == 0:
c = stream[triple] >> 2
triple += 1
if offset % 4 == 1:
c = (stream[triple-1] & 3) << 4 | stream[triple] >> 4
triple += 1
if offset % 4 == 2:
c = (stream[triple-1] & 15) << 2 | (stream[triple] & 192) >> 6
triple += 1
if offset % 4 == 3:
c = stream[triple-1] & 63
if c == 0 and nullstop:
break
offset += 1
# TODO: ENCODE UNICODE 4 BYTE STREAM!!! and but it after #UNICODE# as unichr()
result.append(c)
return decode_alpha_postprocessing(result), triple - 1
def decode_alpha_postprocessing( input ):
"""Lowlevel alphabet decoding postprocessing, combines tuples into one character"""
result = ""
input.extend([0x00]*5)
# UPCASE, UPCASE_PRON, SYMBOL, SPECIAL
skip = False
for i in range(0,len(input)-1):
if skip:
skip = False
continue
bc = input[i]
c = alpha[bc]
bc1 = input[i+1]
c1 = alpha[bc1]
if bc < 40:
result += c
else:
if c == "#GRAVE#":
if c1 == 'a': result += 'à'
else: result += '#GRAVE%s#' % c1
elif c == "#UML#":
if c1 == 'o': result += 'ö'
elif c1 == 'u': result += 'ü'
elif c1 == 'a': result += 'ä'
elif c1 == ' ': result += 'Ä'
elif c1 == '#AL46#': result += 'Ö'
elif c1 == '#GREEK#': result += 'Ü'
else: result += '#UML%s#' % c1
elif c == "#ACUTE#":
if c1 == 'a': result += 'á'
elif c1 == 'e': result += 'é'
elif c1 == 'i': result += 'í'
elif c1 == 'o': result += 'ó'
elif c1 == 'u': result += 'ú'
elif c1 == 'y': result += 'ý'
elif c1 == ' ': result += 'Á'
elif c1 == '#GRAVE#': result += 'Í'
else: result += '#ACUTE%s#' % c1
elif c == "#CARON#":
if c1 == 'r': result += 'ř'
elif c1 == 'c': result += 'č'
elif c1 == 's': result += 'š'
elif c1 == 'z': result += 'ž'
elif c1 == 'e': result += 'ě'
elif c1 == 'd': result += 'ď'
elif c1 == 't': result += 'ť'
elif c1 == 'a': result += 'å'
elif c1 == 'u': result += 'ů'
elif c1 == 'n': result += 'ň'
elif c1 == '<': result += 'Č'
elif c1 == '#CEDIL#': result += 'Ř'
elif c1 == '#AL50#': result += 'Š'
elif c1 == '#AL57#': result += 'Ž'
else: result += '#CARON%s#' % c1
elif c == "#UPCASE#":
result += upcase[bc1]
elif c == "#SYMBOL#":
result += symbol[bc1]
elif c == "#AL51#":
if c1 == 's': result += 'ß'
elif c == "#AL48#":
result += "#AL48#%s" % c1
elif c == "#SPECIAL#":
result += special[bc1]
elif c == "#UNICODE#":
result += '#UNICODE%s#' % bc1
elif c == "#CIRC#":
if c1 == 'a': result += 'â'
else: result += '#CARON%s#' % c1
else:
result += '%sX%s#' % (c[:-1], bc1)
skip = True
return result
def pronunciation_encode(s):
"""Encode pronunciation upcase symbols into IPA symbols"""
for i in range(0, 64):
s = s.replace(upcase[i], upcase_pron[i])
return s
re_d = re.compile(r'<d(.*?)>')
re_w = re.compile(r'<w(.*?)>')
re_y = re.compile(r'<y(.*?)>')
re_c = re.compile(r'<c(.*?)>')
def decode_tag_postprocessing(input):
"""Decode and replace tags used in lingea dictionaries; decode internal tags"""
s = input
# General information in http://www.david-zbiral.cz/El-slovniky-plnaverze.htm#_Toc151656799
# TODO: Better output handling
if OUTSTYLE == 0:
# ?? <d...>
s = re_d.sub(r'(\1)',s)
# ?? <w...>
s = re_w.sub(r'(\1)',s)
# ?? <y...>
s = re_y.sub(r'(\1)',s)
# ?? <c...>
s = re_c.sub(r'(\1)',s)
# ...
if OUTSTYLE == 1:
# ?? <d...>
s = re_d.sub(r'(\1)',s)
# ?? <w...>
s = re_w.sub(r'(\1)',s)
# ?? <y...>
s = re_y.sub(r'(\1)',s)
# ?? <c...>
s = re_c.sub(r'(\1)',s)
# ...
if OUTSTYLE == 2:
# ?? <d...>
s = re_d.sub(r'<span size="small" color="blue">(\1)</span>',s)
# ?? <w...>
s = re_w.sub(r'<span size="small" color="blue" style="italic">\1</span>',s)
# ?? <y...>
s = re_y.sub(r'<span size="small" color="blue" style="italic">\1</span>',s)
# ?? <c...>
s = re_c.sub(r'<span size="small" color="blue" style="italic">\1</span>',s)
# ...
return s
def toBin( b ):
"""Prettify debug output format: hex(bin)dec"""
original = b
r = 0;
i = 1;
while b > 0:
if b & 0x01 != 0: r += i
i *= 10
b = b >> 1
return "0x%02X(%08d)%03d" % (original, r, original)
def out( comment = "", skip = False):
"""Read next byte or string (with skip=True) and output DEBUG info"""
global bs, pos
s, triple = decode_alpha(bs[pos:])
s = s.split('\x00')[0] # give me string until first NULL
if (comment.find('%') != -1):
if skip:
comment = comment % s
else:
comment = comment % bs[pos]
if DEBUG: print "%03d %s %s | %s | %03d" % (pos, toBin(bs[pos]),comment, s, (triple + pos))
if skip:
pos += triple + 1
return s.replace('`','') # Remove '`' character from words
else:
pos += 1
return bs[pos-1]
outInt = lambda c: out(c)
outStr = lambda c: out(c, True)
def decode(stream):
"""Decode byte stream of one record, return decoded string with formatting in utf"""
result = ""
global bs, pos
# stream - data byte stream for one record
bs = unpack("<%sB" % len(stream), stream)
# bs - list of bytes from stream
pos = 0
itemCount = outInt("ItemCount: %s") # Number of blocks in the record
mainFlag = outInt("MainFlag: %s")
# HEADER BLOCK
# ------------
if mainFlag & 0x01:
headerFlag = outInt("HeaderFlag: %s") # Blocks in header
if headerFlag & 0x01:
result += tag['rn'][0] + outStr("Header record name: %s").replace('_','') + tag['rn'][1] # Remove character '_' from index
if headerFlag & 0x02:
result += tag['va'][0] + outStr("Header variant: %s") + tag['va'][1]
if headerFlag & 0x04:
s = outInt("Header wordclass: %s")
if s < 32:
result += tag['wc'][0] + wordclass[s] + tag['wc'][1]
else:
raise "Header wordclass out of range in: %s" % result
if headerFlag & 0x08:
result += tag['pa'][0] + outStr("Header parts: %s") + tag['pa'][1]
if headerFlag & 0x10:
result += tag['fo'][0] + outStr("Header forms: %s") + tag['fo'][1]
if headerFlag & 0x20:
result += tag['on'][0] + outStr("Header origin note: %s") + tag['on'][1]
if headerFlag & 0x80:
result += tag['pr'][0] + pronunciation_encode(outStr("Header pronunciation: %s")) + tag['pr'][1]
# Header data block
if mainFlag & 0x02:
headerFlag = outInt("Header dataFlag: %s") # Blocks in header
if headerFlag & 0x02:
result += tag['dv'][0] + outStr("Header dataVariant: %s")+ tag['dv'][1]
# ??? Link elsewhere
pass
# SOUND DATA REFERENCE
if mainFlag & 0x80:
outInt("Sound reference byte #1: %s")
outInt("Sound reference byte #2: %s")
outInt("Sound reference byte #3: %s")
outInt("Sound reference byte #4: %s")
outInt("Sound reference byte #5: %s")
#out("Sound data reference (5 bytes)", 6)
# TODO: Test all mainFlags in header!!!!
#result += ': '
li = 0
#print just every first word class identifier
# TODO: this is not systematic (should be handled by output)
global lastWordClass
lastWordClass = 0
# DATA BLOCK(S)
# -------------
for i in range(0, itemCount):
item = tag['db'][0] + tag['db'][1]
ol = False
dataFlag = outInt("DataFlag: %s -----------------------------")
if dataFlag & 0x01: # small index
sampleFlag = outInt("Data sampleFlag: %s")
if sampleFlag & 0x01:
result += tag['sa'][0] + outStr("Data sample: %s") + tag['sa'][1]
if sampleFlag & 0x04:
s = outInt("Data wordclass: %s")
if s != lastWordClass:
if s < 32:
result += tag['wc'][0] + wordclass[s] + tag['wc'][1]
else:
raise "Header wordclass out of range in: %s" % result
lastWordClass = s
if sampleFlag & 0x08:
result += tag['sw'][0] + outStr("Data sample wordclass: %s") + tag['sw'][1]
if sampleFlag & 0x10:
outInt("Data sample Int: %s")
outInt("Data sample Int: %s")
outInt("Data sample Int: %s")
if sampleFlag & 0x20:
item += tag['do'][0] + outStr("Data origin note: %s") + tag['do'][1]
if sampleFlag & 0x80:
item += " "
result += tag['pr'][0] + pronunciation_encode(outStr("Data sample pronunciation: %s")) + tag['pr'][1]
if dataFlag & 0x02:
item += " "
subFlag = outInt("Data subFlag: %s")
if subFlag == 0x80:
outStr("Data sub prefix: %s")
# It seams that data sub prefix content is ignored and there is a generated number for the whole block instead.
li += 1
ol = True
if dataFlag & 0x04: # chart
pass # ???
if dataFlag & 0x08: # reference
item += tag['df'][0] + outStr("Data definition: %s") + tag['df'][1]
if dataFlag & 0x10:
pass # ???
if dataFlag & 0x20: # phrase
phraseFlag1 = outInt("Data phraseFlag1: %s")
if phraseFlag1 & 0x01:
item += tag['ps'][0] + outStr("Data phrase short form: %s") + tag['ps'][1]
if phraseFlag1 & 0x02:
phraseCount = outInt("Data phraseCount: %s")
for i in range(0, phraseCount):
phraseComment = outInt("Data phrase prefix")
if phraseComment & 0x04:
item += tag['pc'][0] + outStr("Data phrase comment: %s") + tag['pc'][1]
item += tag['p1'][0] + outStr("Data phrase 1: %s") + tag['p1'][1]
item += tag['p2'][0] + outStr("Data phrase 2: %s") + tag['p2'][1]
if phraseFlag1 & 0x04:
phraseCount = outInt("Data phraseCount: %s")
for i in range(0, phraseCount):
phraseComment = outInt("Data phrase prefix")
if phraseComment & 0x04:
item += tag['pc'][0] + outStr("Data phrase 1: %s") + tag['pc'][1]
item += tag['pg'][0] + outStr("Data phrase comment: %s") + tag['pg'][1]
item += tag['p2'][0] + outStr("Data phrase 2: %s") + tag['p2'][1]
if phraseFlag1 & 0x08:
phraseCount = outInt("Data simple phraseCount: %s")
for i in range(0, phraseCount):
item += " "
item += tag['sp'][0] + outStr("Data simple phrase: %s") + tag['sp'][1]
if phraseFlag1 & 0x40:
item += tag['ps'][0] + outStr("Data phrase short form: %s") + tag['ps'][1]
# TODO: be careful in changing the rules, to have back compatibility!
if dataFlag & 0x40: # reference, related language
#0x01 synonym ?
#0x02 antonym ?
pass
if dataFlag & 0x80: # Phrase block
flags = [
out("Data phrase block: %s"),
out("Data phrase block: %s"),
out("Data phrase block: %s"),
out("Data phrase block: %s"),
out("Data phrase block: %s"),
out("Data phrase block: %s"),
out("Data phrase block: %s"),
out("Data phrase block: %s")]
if flags == [0x80,0x80,0xF9,0xDF,0x9D,0x00,0x0B,0x01]:
result += "\\nphr: "
li = 1
ol = True
item += tag['b1'][0]+outStr("Data phrase 1: %s") + tag['b1'][1]
out("Data phrase block: %s")
out("Data phrase block: %s")
out("Data phrase block: %s")
out("Data phrase block: %s")
item += tag['ds'][0] + outStr("Data phrase 2: %s") + tag['ds'][1]
if flags == [0x80,0x80,0xF9,0xDF,0x9D,0x00,0x23,0x01]:
result += "\\nphr: "
li = 1
ol = True
item += tag['b1'][0]+outStr("Data phrase 1: %s") + tag['b1'][1]
out("Data phrase block: %s")
out("Data phrase block: %s")
out("Data phrase block: %s")
out("Data phrase block: %s")
out("Data phrase block: %s")
item += tag['ds'][0] + outStr("Data phrase 2: %s") + tag['ds'][1]
if ol:
result += "\\n%d. %s" % (li, item)
else:
result += item
ok = True
while pos < len(stream):
ok = (out() == 0x00) and ok
if ok:
result += '\n'
return decode_tag_postprocessing(result)
################################################################
# MAIN
################################################################
f = open(FILENAME,'rb')
# DECODE HEADER OF FILE
copyright = unpack("<64s",f.read(64))[0]
a = unpack("<16L",f.read(64))
entryCount = a[4]
indexBaseCount = a[6]
indexOffsetCount = a[7]
pos1 = a[8]
indexPos = a[9]
bodyPos = a[10]
smallIndex = (a[3] == 2052)
# DECODE INDEX STRUCTURE OF FILE
index = []
f.seek(indexPos)
bases = unpack("<%sL" % indexBaseCount, f.read(indexBaseCount * 4))
if smallIndex: # In small dictionaries every base is used 4-times
bases4 = []
for i in bases:
bases4.extend([i,i,i,i])
bases = bases4
for b in bases:
offsets = unpack("<64H", f.read(64*2))
for o in offsets:
if len(index) < indexOffsetCount:
#print "Index %s: %s + %s + %s * 4 = %s" % (len(index), bodyPos, b, o, toBin(bodyPos + b + o * 4))
index.append(bodyPos + b + o * 4)
# DECODE RECORDS
if DEBUG:
# PRINTOUT DEBUG OF FIRST <DEBUGLIMIT> WRONG RECORDS:
for i in range(1,entryCount):
if not DEBUGALL:
DEBUG = False
s = decode(getRec(i))
if DEBUGHEADER:
# print s.split('\t')[0]
print s
if DEBUGLIMIT > 0 and not s.endswith('\n'):
DEBUG = True
print "-"*80
print "%s) at address %s" % (i, toBin(index[i]))
print
s = decode(getRec(i))
print s
DEBUGLIMIT -= 1
DEBUG = True
else:
# DECODE EACH RECORD AND PRINT IT IN FORMAT FOR stardict-editor <term>\t<definition>
for i in range(1,entryCount):
s = decode(getRec(i))
if s.endswith('\n'):
print s,
else:
print s
print "!!! RECORD STRUCTURE DECODING ERROR !!!"
print "Please run this script in DEBUG mode and repair DATA BLOCK(S) section in function decode()"
print "If you succeed with whole dictionary send report (name of the dictionary and source code of script) to slovniky@googlegroups.com"
break
| Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.