repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
listlengths
1.02k
1.02k
labels
listlengths
1.02k
1.02k
attention_mask
listlengths
1.02k
1.02k
askin/GNazar
GNazar/gnazar.py
1
6314
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Licensed under GPL v2 # Copyright 2010, Aşkın Yollu <askin@askin.ws> # # 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. # # Please read the COPYING file. # import pygtk import gtk import gettext import pynotify import time import os import sys import locale import random import platform gtk.gdk.threads_init() #Translation stuff localedir = "/usr/share/gnazar/locale" gettext.bindtextdomain('gnazar', localedir) gettext.textdomain('gnazar') sharedirs = '/usr/share' _ = gettext.gettext class GNazar(): def __init__(self): # create a new Status Icon self.gnazar = gtk.StatusIcon() self.gnazar.set_from_file( '%s/icons/hicolor/22x22/apps/gnazar-deactive.png' % sharedirs) self.gnazar.set_tooltip( _("GNazar - You are completely demilitarized...")) self.gnazar.set_visible(True) self.status = False # create menu self.menu = gtk.Menu() self.gnazar.connect("popup_menu", self.show_menu) # connect _quit = gtk.ImageMenuItem(gtk.STOCK_QUIT) _quit.connect("activate", self.destroy) _about = gtk.ImageMenuItem(gtk.STOCK_ABOUT) _about.connect("activate", self.show_about) _protect = gtk.ImageMenuItem(gtk.STOCK_OK) _protect.connect("activate", self.protect) _protect.set_label(_("Protect")) _release = gtk.ImageMenuItem(gtk.STOCK_CANCEL) _release.set_label(_("Release")) _release.connect("activate", self.release) # add to menu self.menu.add(_protect) self.menu.add(_release) self.menu.add(_about) self.menu.add(_quit) self.menu.show_all() # notification pynotify.init(_("GNazar Application")) # init attack self.total_attack = 0 self.defated_attack = 0 self.running = True import thread thread.start_new_thread(self._notification, ()) def main(self): # gtk main gtk.main() ''' show popup menu ''' def show_menu(self, status_icon, button, activate_time): self.menu.popup(None, None, gtk.status_icon_position_menu, button, activate_time, status_icon) # random notification def _notification(self): while(self.running): time.sleep(random.randrange(3600, 18000)) #time.sleep(4) # testing self.notification() ''' show about ''' def show_about(self, widget): about = gtk.AboutDialog() about.set_program_name("GNazar") about.set_icon_from_file("%s/icons/hicolor/22x22/apps/gnazar.png" % sharedirs) about.set_version("0.1") about.set_copyright("(c) Aşkın Yollu") # FIXME: make it generic (mac, bsd, win etc..) dist_name = platform.dist()[0] about.set_comments(_("GNazar is a useful part of the %s" % dist_name)) about.set_website("http://www.askin.ws") about.set_logo(gtk.gdk.pixbuf_new_from_file( "%s/icons/hicolor/32x32/apps/gnazar.png" % sharedirs)) about.set_translator_credits(_("TRANSLATORS")) about.set_artists([_("THANKSFORICONS")]) about.run() about.destroy() # destroy callback def destroy(self, widget): self.gnazar.set_visible(False) self.running = False gtk.main_quit() # popup callback def protect(self, widget): if self.status == False: dialog = gtk.MessageDialog( parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK, message_format=_("GNazar is starting to protect your " "computer from harmful looks...") ) dialog.set_title(_("GNazar Application")) dialog.connect('response', self.dialog_destroyer) dialog.show() self.status = True self.gnazar.set_tooltip(_("GNazar - No harmful look allowed!")) self.gnazar.set_from_file("%s/icons/hicolor/22x22/apps/gnazar.png" % sharedirs) def release(self, widget): if self.status == True: dialog = gtk.MessageDialog( parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK, message_format=_("GNazar is stopping to protect your computer" " from harmful looks...") ) dialog.set_title(_("GNazar Application")) dialog.connect('response', self.dialog_destroyer) dialog.show() self.status = False self.gnazar.set_tooltip( _("GNazar - You are completely demilitarized...")) self.gnazar.set_from_file( "%s/icons/hicolor/22x22/apps/gnazar-deactive.png" % sharedirs) def notification(self): self.total_attack += 1 if self.status == True: self.defated_attack += 1 title = _("Nazar eliminated") body = _("Nazar Received and eliminated successfuly") icon = "gtk-apply" else: title = _("Nazar harmed") body = _("Nazar Received and it HARMED!") icon = "dialog-warning" self.gnazar.set_tooltip( _("GNazar - %s attacks received so far, %s" " are defated and %s are received...") % (self.total_attack, self.defated_attack, self.total_attack - self.defated_attack)) notify = pynotify.Notification(title, body, icon) notify.set_urgency(pynotify.URGENCY_NORMAL) notify.set_timeout(pynotify.EXPIRES_NEVER) notify.show() def dialog_destroyer(self, dialog, widget): dialog.destroy() def main(): si = GNazar() si.main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 14629, 373, 18, 199, 3, 1898, 7129, 12, 437, 130, 254, 75, 28871, 78, 1488, 393, 10836, 665, 813, 262, 32, 813, 262, 14, 3569, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 7754, 1586, 314, 9685, 570, 14, 199, 3, 199, 199, 646, 1134, 12275, 199, 646, 8116, 199, 646, 9796, 199, 646, 1134, 6814, 199, 646, 900, 199, 646, 747, 199, 646, 984, 199, 646, 5867, 199, 646, 2196, 199, 646, 4298, 199, 12275, 14, 24697, 14, 6962, 63, 826, 342, 199, 199, 3, 18483, 8292, 199, 5508, 694, 275, 3286, 2647, 15, 6251, 15, 784, 4651, 285, 15, 5508, 2, 199, 5152, 14, 3409, 505, 2261, 360, 784, 4651, 285, 297, 5867, 694, 9, 199, 5152, 14, 505, 2261, 360, 784, 4651, 285, 358, 199, 6251, 3220, 275, 1994, 2647, 15, 6251, 7, 199, 199, 63, 275, 9796, 14, 5152, 421, 199, 533, 27650, 4651, 285, 837, 272, 347, 636, 826, 721, 277, 304, 267, 327, 1218, 282, 892, 9795, 473, 388, 267, 291, 14, 784, 4651, 285, 275, 8116, 14, 3694, 8954, 342, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 504, 63, 493, 8, 288, 1543, 83, 15, 16471, 15, 5812, 2326, 15, 1081, 88, 1081, 15, 5181, 15, 784, 4651, 285, 13, 271, 2682, 14, 4524, 7, 450, 8663, 3220, 9, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 22972, 8, 288, 3824, 15306, 4651, 285, 446, 2047, 787, 14793, 477, 2664, 1051, 285, 1759, 1396, 2237, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 6604, 8, 549, 9, 267, 291, 14, 1205, 275, 756, 398, 327, 1218, 6269, 267, 291, 14, 4470, 275, 8116, 14, 5977, 342, 267, 291, 14, 784, 4651, 285, 14, 2242, 480, 16020, 63, 4470, 401, 291, 14, 2384, 63, 4470, 9, 398, 327, 4907, 267, 485, 10589, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 2328, 649, 9, 267, 485, 10589, 14, 2242, 480, 8222, 401, 291, 14, 7237, 9, 267, 485, 10254, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 1217, 1877, 9, 267, 485, 10254, 14, 2242, 480, 8222, 401, 291, 14, 2384, 63, 10254, 9, 267, 485, 18292, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 3593, 9, 267, 485, 18292, 14, 2242, 480, 8222, 401, 291, 14, 18292, 9, 267, 485, 18292, 14, 409, 63, 1302, 6115, 919, 5302, 2237, 267, 485, 3221, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 20707, 9, 267, 485, 3221, 14, 409, 63, 1302, 6115, 9625, 2237, 267, 485, 3221, 14, 2242, 480, 8222, 401, 291, 14, 3221, 9, 398, 327, 1050, 370, 6269, 267, 291, 14, 4470, 14, 525, 1547, 18292, 9, 267, 291, 14, 4470, 14, 525, 1547, 3221, 9, 267, 291, 14, 4470, 14, 525, 1547, 10254, 9, 267, 291, 14, 4470, 14, 525, 1547, 10589, 9, 267, 291, 14, 4470, 14, 2384, 63, 452, 342, 398, 327, 6955, 267, 1134, 6814, 14, 826, 6115, 15306, 4651, 285, 13515, 2237, 398, 327, 4205, 23326, 267, 291, 14, 2923, 63, 24171, 275, 378, 267, 291, 14, 318, 972, 63, 24171, 275, 378, 398, 291, 14, 5720, 275, 715, 398, 492, 2462, 267, 2462, 14, 928, 63, 1222, 63, 2671, 8, 277, 423, 6761, 12, 14515, 339, 347, 2446, 8, 277, 304, 267, 327, 8116, 2446, 267, 8116, 14, 973, 342, 339, 1449, 272, 2498, 22365, 6269, 272, 1449, 272, 347, 2498, 63, 4470, 8, 277, 12, 2004, 63, 4677, 12, 5528, 12, 15422, 63, 521, 304, 267, 291, 14, 4470, 14, 16020, 8, 403, 12, 488, 12, 8116, 14, 1205, 63, 4677, 63, 3124, 63, 4470, 12, 717, 5528, 12, 15422, 63, 521, 12, 2004, 63, 4677, 9, 339, 327, 2196, 6955, 272, 347, 485, 6761, 8, 277, 304, 267, 1830, 8, 277, 14, 5720, 304, 288, 900, 14, 4532, 8, 2355, 14, 20539, 8, 11035, 12, 6155, 1493, 430, 288, 327, 521, 14, 4532, 8, 20, 9, 327, 5343, 288, 291, 14, 6761, 342, 339, 1449, 272, 2498, 3595, 272, 1449, 272, 347, 2498, 63, 10254, 8, 277, 12, 3938, 304, 267, 3595, 275, 8116, 14, 18816, 5619, 342, 267, 3595, 14, 409, 63, 6815, 63, 354, 480, 15306, 4651, 285, 531, 267, 3595, 14, 409, 63, 4677, 63, 504, 63, 493, 3647, 83, 15, 16471, 15, 5812, 2326, 15, 1081, 88, 1081, 15, 5181, 15, 784, 4651, 285, 14, 4524, 2, 639, 450, 8663, 3220, 9, 267, 3595, 14, 409, 63, 1023, 480, 16, 14, 17, 531, 267, 3595, 14, 409, 63, 7307, 18353, 67, 9, 437, 130, 254, 75, 28871, 78, 1488, 393, 10836, 531, 267, 327, 7600, 26, 1852, 652, 7809, 334, 3088, 12, 330, 3893, 12, 4747, 5423, 703, 9, 267, 2917, 63, 354, 275, 4298, 14, 2686, 3430, 16, 61, 267, 3595, 14, 409, 63, 6223, 6115, 15306, 4651, 285, 365, 282, 2997, 1777, 402, 314, 450, 83, 2, 450, 2917, 63, 354, 430, 267, 3595, 14, 409, 63, 7360, 480, 1014, 921, 1544, 14, 813, 262, 14, 3569, 531, 267, 3595, 14, 409, 63, 9733, 8, 12275, 14, 24697, 14, 25740, 63, 1222, 63, 504, 63, 493, 8, 355, 2071, 83, 15, 16471, 15, 5812, 2326, 15, 708, 88, 708, 15, 5181, 15, 784, 4651, 285, 14, 4524, 2, 450, 8663, 3220, 430, 267, 3595, 14, 409, 63, 29346, 63, 22461, 6115, 26376, 19033, 2237, 267, 3595, 14, 409, 63, 11215, 83, 779, 14332, 2080, 15874, 51, 2707, 15903, 51, 13403, 267, 3595, 14, 1065, 342, 267, 3595, 14, 7237, 342, 339, 327, 11972, 3233, 272, 347, 11972, 8, 277, 12, 3938, 304, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 6604, 8, 797, 9, 267, 291, 14, 5720, 275, 756, 267, 8116 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 14629, 373, 18, 199, 3, 1898, 7129, 12, 437, 130, 254, 75, 28871, 78, 1488, 393, 10836, 665, 813, 262, 32, 813, 262, 14, 3569, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 7754, 1586, 314, 9685, 570, 14, 199, 3, 199, 199, 646, 1134, 12275, 199, 646, 8116, 199, 646, 9796, 199, 646, 1134, 6814, 199, 646, 900, 199, 646, 747, 199, 646, 984, 199, 646, 5867, 199, 646, 2196, 199, 646, 4298, 199, 12275, 14, 24697, 14, 6962, 63, 826, 342, 199, 199, 3, 18483, 8292, 199, 5508, 694, 275, 3286, 2647, 15, 6251, 15, 784, 4651, 285, 15, 5508, 2, 199, 5152, 14, 3409, 505, 2261, 360, 784, 4651, 285, 297, 5867, 694, 9, 199, 5152, 14, 505, 2261, 360, 784, 4651, 285, 358, 199, 6251, 3220, 275, 1994, 2647, 15, 6251, 7, 199, 199, 63, 275, 9796, 14, 5152, 421, 199, 533, 27650, 4651, 285, 837, 272, 347, 636, 826, 721, 277, 304, 267, 327, 1218, 282, 892, 9795, 473, 388, 267, 291, 14, 784, 4651, 285, 275, 8116, 14, 3694, 8954, 342, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 504, 63, 493, 8, 288, 1543, 83, 15, 16471, 15, 5812, 2326, 15, 1081, 88, 1081, 15, 5181, 15, 784, 4651, 285, 13, 271, 2682, 14, 4524, 7, 450, 8663, 3220, 9, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 22972, 8, 288, 3824, 15306, 4651, 285, 446, 2047, 787, 14793, 477, 2664, 1051, 285, 1759, 1396, 2237, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 6604, 8, 549, 9, 267, 291, 14, 1205, 275, 756, 398, 327, 1218, 6269, 267, 291, 14, 4470, 275, 8116, 14, 5977, 342, 267, 291, 14, 784, 4651, 285, 14, 2242, 480, 16020, 63, 4470, 401, 291, 14, 2384, 63, 4470, 9, 398, 327, 4907, 267, 485, 10589, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 2328, 649, 9, 267, 485, 10589, 14, 2242, 480, 8222, 401, 291, 14, 7237, 9, 267, 485, 10254, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 1217, 1877, 9, 267, 485, 10254, 14, 2242, 480, 8222, 401, 291, 14, 2384, 63, 10254, 9, 267, 485, 18292, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 3593, 9, 267, 485, 18292, 14, 2242, 480, 8222, 401, 291, 14, 18292, 9, 267, 485, 18292, 14, 409, 63, 1302, 6115, 919, 5302, 2237, 267, 485, 3221, 275, 8116, 14, 3491, 20973, 8, 12275, 14, 24838, 63, 20707, 9, 267, 485, 3221, 14, 409, 63, 1302, 6115, 9625, 2237, 267, 485, 3221, 14, 2242, 480, 8222, 401, 291, 14, 3221, 9, 398, 327, 1050, 370, 6269, 267, 291, 14, 4470, 14, 525, 1547, 18292, 9, 267, 291, 14, 4470, 14, 525, 1547, 3221, 9, 267, 291, 14, 4470, 14, 525, 1547, 10254, 9, 267, 291, 14, 4470, 14, 525, 1547, 10589, 9, 267, 291, 14, 4470, 14, 2384, 63, 452, 342, 398, 327, 6955, 267, 1134, 6814, 14, 826, 6115, 15306, 4651, 285, 13515, 2237, 398, 327, 4205, 23326, 267, 291, 14, 2923, 63, 24171, 275, 378, 267, 291, 14, 318, 972, 63, 24171, 275, 378, 398, 291, 14, 5720, 275, 715, 398, 492, 2462, 267, 2462, 14, 928, 63, 1222, 63, 2671, 8, 277, 423, 6761, 12, 14515, 339, 347, 2446, 8, 277, 304, 267, 327, 8116, 2446, 267, 8116, 14, 973, 342, 339, 1449, 272, 2498, 22365, 6269, 272, 1449, 272, 347, 2498, 63, 4470, 8, 277, 12, 2004, 63, 4677, 12, 5528, 12, 15422, 63, 521, 304, 267, 291, 14, 4470, 14, 16020, 8, 403, 12, 488, 12, 8116, 14, 1205, 63, 4677, 63, 3124, 63, 4470, 12, 717, 5528, 12, 15422, 63, 521, 12, 2004, 63, 4677, 9, 339, 327, 2196, 6955, 272, 347, 485, 6761, 8, 277, 304, 267, 1830, 8, 277, 14, 5720, 304, 288, 900, 14, 4532, 8, 2355, 14, 20539, 8, 11035, 12, 6155, 1493, 430, 288, 327, 521, 14, 4532, 8, 20, 9, 327, 5343, 288, 291, 14, 6761, 342, 339, 1449, 272, 2498, 3595, 272, 1449, 272, 347, 2498, 63, 10254, 8, 277, 12, 3938, 304, 267, 3595, 275, 8116, 14, 18816, 5619, 342, 267, 3595, 14, 409, 63, 6815, 63, 354, 480, 15306, 4651, 285, 531, 267, 3595, 14, 409, 63, 4677, 63, 504, 63, 493, 3647, 83, 15, 16471, 15, 5812, 2326, 15, 1081, 88, 1081, 15, 5181, 15, 784, 4651, 285, 14, 4524, 2, 639, 450, 8663, 3220, 9, 267, 3595, 14, 409, 63, 1023, 480, 16, 14, 17, 531, 267, 3595, 14, 409, 63, 7307, 18353, 67, 9, 437, 130, 254, 75, 28871, 78, 1488, 393, 10836, 531, 267, 327, 7600, 26, 1852, 652, 7809, 334, 3088, 12, 330, 3893, 12, 4747, 5423, 703, 9, 267, 2917, 63, 354, 275, 4298, 14, 2686, 3430, 16, 61, 267, 3595, 14, 409, 63, 6223, 6115, 15306, 4651, 285, 365, 282, 2997, 1777, 402, 314, 450, 83, 2, 450, 2917, 63, 354, 430, 267, 3595, 14, 409, 63, 7360, 480, 1014, 921, 1544, 14, 813, 262, 14, 3569, 531, 267, 3595, 14, 409, 63, 9733, 8, 12275, 14, 24697, 14, 25740, 63, 1222, 63, 504, 63, 493, 8, 355, 2071, 83, 15, 16471, 15, 5812, 2326, 15, 708, 88, 708, 15, 5181, 15, 784, 4651, 285, 14, 4524, 2, 450, 8663, 3220, 430, 267, 3595, 14, 409, 63, 29346, 63, 22461, 6115, 26376, 19033, 2237, 267, 3595, 14, 409, 63, 11215, 83, 779, 14332, 2080, 15874, 51, 2707, 15903, 51, 13403, 267, 3595, 14, 1065, 342, 267, 3595, 14, 7237, 342, 339, 327, 11972, 3233, 272, 347, 11972, 8, 277, 12, 3938, 304, 267, 291, 14, 784, 4651, 285, 14, 409, 63, 6604, 8, 797, 9, 267, 291, 14, 5720, 275, 756, 267, 8116, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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commands.py
147
1243
# 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. # to configure behavior, define $CQL_TEST_HOST to the destination address # for Thrift connections, and $CQL_TEST_PORT to the associated port. from .basecase import BaseTestCase, cqlsh class TestCqlshCommands(BaseTestCase): def setUp(self): pass def tearDown(self): pass def test_show(self): pass def test_describe(self): pass def test_exit(self): pass def test_help(self): pass
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 370, 7908, 5953, 12, 5627, 2672, 35, 2940, 63, 2864, 63, 5449, 370, 314, 5724, 2287, 199, 3, 367, 3868, 6501, 6947, 12, 436, 2672, 35, 2940, 63, 2864, 63, 3657, 370, 314, 4568, 1844, 14, 199, 199, 504, 1275, 1095, 2546, 492, 3523, 1746, 12, 286, 81, 23025, 199, 199, 533, 1379, 35, 81, 23025, 14680, 8, 20760, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 2384, 8, 277, 304, 267, 986, 339, 347, 511, 63, 11935, 8, 277, 304, 267, 986, 339, 347, 511, 63, 2224, 8, 277, 304, 267, 986, 339, 347, 511, 63, 3437, 8, 277, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 370, 7908, 5953, 12, 5627, 2672, 35, 2940, 63, 2864, 63, 5449, 370, 314, 5724, 2287, 199, 3, 367, 3868, 6501, 6947, 12, 436, 2672, 35, 2940, 63, 2864, 63, 3657, 370, 314, 4568, 1844, 14, 199, 199, 504, 1275, 1095, 2546, 492, 3523, 1746, 12, 286, 81, 23025, 199, 199, 533, 1379, 35, 81, 23025, 14680, 8, 20760, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 2384, 8, 277, 304, 267, 986, 339, 347, 511, 63, 11935, 8, 277, 304, 267, 986, 339, 347, 511, 63, 2224, 8, 277, 304, 267, 986, 339, 347, 511, 63, 3437, 8, 277, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
laurmurclar/mitmproxy
mitmproxy/tools/console/flowview.py
1
23737
import math import os import sys from functools import lru_cache from typing import Optional, Union # noqa import urwid from mitmproxy import contentviews from mitmproxy import exceptions from mitmproxy import export from mitmproxy import http from mitmproxy.net.http import Headers from mitmproxy.net.http import status_codes from mitmproxy.tools.console import common from mitmproxy.tools.console import flowdetailview from mitmproxy.tools.console import grideditor from mitmproxy.tools.console import searchable from mitmproxy.tools.console import signals from mitmproxy.tools.console import tabs class SearchError(Exception): pass def _mkhelp(): text = [] keys = [ ("A", "accept all intercepted flows"), ("a", "accept this intercepted flow"), ("b", "save request/response body"), ("C", "export flow to clipboard"), ("D", "duplicate flow"), ("d", "delete flow"), ("e", "edit request/response"), ("f", "load full body data"), ("m", "change body display mode for this entity\n(default mode can be changed in the options)"), (None, common.highlight_key("automatic", "a") + [("text", ": automatic detection")] ), (None, common.highlight_key("hex", "e") + [("text", ": Hex")] ), (None, common.highlight_key("html", "h") + [("text", ": HTML")] ), (None, common.highlight_key("image", "i") + [("text", ": Image")] ), (None, common.highlight_key("javascript", "j") + [("text", ": JavaScript")] ), (None, common.highlight_key("json", "s") + [("text", ": JSON")] ), (None, common.highlight_key("urlencoded", "u") + [("text", ": URL-encoded data")] ), (None, common.highlight_key("raw", "r") + [("text", ": raw data")] ), (None, common.highlight_key("xml", "x") + [("text", ": XML")] ), ("E", "export flow to file"), ("r", "replay request"), ("V", "revert changes to request"), ("v", "view body in external viewer"), ("w", "save all flows matching current view filter"), ("W", "save this flow"), ("x", "delete body"), ("z", "encode/decode a request/response"), ("tab", "next tab"), ("h, l", "previous tab, next tab"), ("space", "next flow"), ("|", "run script on this flow"), ("/", "search (case sensitive)"), ("n", "repeat search forward"), ("N", "repeat search backwards"), ] text.extend(common.format_keyvals(keys, key="key", val="text", indent=4)) return text help_context = _mkhelp() footer = [ ('heading_key', "?"), ":help ", ('heading_key', "q"), ":back ", ] class FlowViewHeader(urwid.WidgetWrap): def __init__(self, master: "mitmproxy.console.master.ConsoleMaster", f: http.HTTPFlow): self.master = master self.flow = f self._w = common.format_flow( f, False, extended=True, hostheader=self.master.options.showhost ) signals.flow_change.connect(self.sig_flow_change) def sig_flow_change(self, sender, flow): if flow == self.flow: self._w = common.format_flow( flow, False, extended=True, hostheader=self.master.options.showhost ) TAB_REQ = 0 TAB_RESP = 1 class FlowView(tabs.Tabs): highlight_color = "focusfield" def __init__(self, master, view, flow, tab_offset): self.master, self.view, self.flow = master, view, flow super().__init__( [ (self.tab_request, self.view_request), (self.tab_response, self.view_response), (self.tab_details, self.view_details), ], tab_offset ) self.show() self.last_displayed_body = None signals.flow_change.connect(self.sig_flow_change) def tab_request(self): if self.flow.intercepted and not self.flow.response: return "Request intercepted" else: return "Request" def tab_response(self): if self.flow.intercepted and self.flow.response: return "Response intercepted" else: return "Response" def tab_details(self): return "Detail" def view_request(self): return self.conn_text(self.flow.request) def view_response(self): return self.conn_text(self.flow.response) def view_details(self): return flowdetailview.flowdetails(self.view, self.flow) def sig_flow_change(self, sender, flow): if flow == self.flow: self.show() def content_view(self, viewmode, message): if message.raw_content is None: msg, body = "", [urwid.Text([("error", "[content missing]")])] return msg, body else: s = self.view.settings[self.flow] full = s.get((self.tab_offset, "fullcontents"), False) if full: limit = sys.maxsize else: limit = contentviews.VIEW_CUTOFF flow_modify_cache_invalidation = hash(( message.raw_content, message.headers.fields, getattr(message, "path", None), )) # we need to pass the message off-band because it's not hashable self._get_content_view_message = message return self._get_content_view(viewmode, limit, flow_modify_cache_invalidation) @lru_cache(maxsize=200) def _get_content_view(self, viewmode, max_lines, _): message = self._get_content_view_message self._get_content_view_message = None description, lines, error = contentviews.get_message_content_view( viewmode, message ) if error: signals.add_log(error, "error") # Give hint that you have to tab for the response. if description == "No content" and isinstance(message, http.HTTPRequest): description = "No request content (press tab to view response)" # If the users has a wide terminal, he gets fewer lines; this should not be an issue. chars_per_line = 80 max_chars = max_lines * chars_per_line total_chars = 0 text_objects = [] for line in lines: txt = [] for (style, text) in line: if total_chars + len(text) > max_chars: text = text[:max_chars - total_chars] txt.append((style, text)) total_chars += len(text) if total_chars == max_chars: break # round up to the next line. total_chars = int(math.ceil(total_chars / chars_per_line) * chars_per_line) text_objects.append(urwid.Text(txt)) if total_chars == max_chars: text_objects.append(urwid.Text([ ("highlight", "Stopped displaying data after %d lines. Press " % max_lines), ("key", "f"), ("highlight", " to load all data.") ])) break return description, text_objects def viewmode_get(self): override = self.view.settings[self.flow].get( (self.tab_offset, "prettyview"), None ) return self.master.options.default_contentview if override is None else override def conn_text(self, conn): if conn: txt = common.format_keyvals( [(h + ":", v) for (h, v) in conn.headers.items(multi=True)], key = "header", val = "text" ) viewmode = self.viewmode_get() msg, body = self.content_view(viewmode, conn) cols = [ urwid.Text( [ ("heading", msg), ] ), urwid.Text( [ " ", ('heading', "["), ('heading_key', "m"), ('heading', (":%s]" % viewmode)), ], align="right" ) ] title = urwid.AttrWrap(urwid.Columns(cols), "heading") txt.append(title) txt.extend(body) else: txt = [ urwid.Text(""), urwid.Text( [ ("highlight", "No response. Press "), ("key", "e"), ("highlight", " and edit any aspect to add one."), ] ) ] return searchable.Searchable(self.view, txt) def set_method_raw(self, m): if m: self.flow.request.method = m signals.flow_change.send(self, flow = self.flow) def edit_method(self, m): if m == "e": signals.status_prompt.send( prompt = "Method", text = self.flow.request.method, callback = self.set_method_raw ) else: for i in common.METHOD_OPTIONS: if i[1] == m: self.flow.request.method = i[0].upper() signals.flow_change.send(self, flow = self.flow) def set_url(self, url): request = self.flow.request try: request.url = str(url) except ValueError: return "Invalid URL." signals.flow_change.send(self, flow = self.flow) def set_resp_status_code(self, status_code): try: status_code = int(status_code) except ValueError: return None self.flow.response.status_code = status_code if status_code in status_codes.RESPONSES: self.flow.response.reason = status_codes.RESPONSES[status_code] signals.flow_change.send(self, flow = self.flow) def set_resp_reason(self, reason): self.flow.response.reason = reason signals.flow_change.send(self, flow = self.flow) def set_headers(self, fields, conn): conn.headers = Headers(fields) signals.flow_change.send(self, flow = self.flow) def set_query(self, lst, conn): conn.query = lst signals.flow_change.send(self, flow = self.flow) def set_path_components(self, lst, conn): conn.path_components = lst signals.flow_change.send(self, flow = self.flow) def set_form(self, lst, conn): conn.urlencoded_form = lst signals.flow_change.send(self, flow = self.flow) def edit_form(self, conn): self.master.view_grideditor( grideditor.URLEncodedFormEditor( self.master, conn.urlencoded_form.items(multi=True), self.set_form, conn ) ) def edit_form_confirm(self, key, conn): if key == "y": self.edit_form(conn) def set_cookies(self, lst, conn): conn.cookies = lst signals.flow_change.send(self, flow = self.flow) def set_setcookies(self, data, conn): conn.cookies = data signals.flow_change.send(self, flow = self.flow) def edit(self, part): if self.tab_offset == TAB_REQ: message = self.flow.request else: if not self.flow.response: self.flow.response = http.HTTPResponse.make(200, b"") message = self.flow.response self.flow.backup() if message == self.flow.request and part == "c": self.master.view_grideditor( grideditor.CookieEditor( self.master, message.cookies.items(multi=True), self.set_cookies, message ) ) if message == self.flow.response and part == "c": self.master.view_grideditor( grideditor.SetCookieEditor( self.master, message.cookies.items(multi=True), self.set_setcookies, message ) ) if part == "r": # Fix an issue caused by some editors when editing a # request/response body. Many editors make it hard to save a # file without a terminating newline on the last line. When # editing message bodies, this can cause problems. For now, I # just strip the newlines off the end of the body when we return # from an editor. c = self.master.spawn_editor(message.get_content(strict=False) or b"") message.content = c.rstrip(b"\n") elif part == "f": if not message.urlencoded_form and message.raw_content: signals.status_prompt_onekey.send( prompt = "Existing body is not a URL-encoded form. Clear and edit?", keys = [ ("yes", "y"), ("no", "n"), ], callback = self.edit_form_confirm, args = (message,) ) else: self.edit_form(message) elif part == "h": self.master.view_grideditor( grideditor.HeaderEditor( self.master, message.headers.fields, self.set_headers, message ) ) elif part == "p": p = message.path_components self.master.view_grideditor( grideditor.PathEditor( self.master, p, self.set_path_components, message ) ) elif part == "q": self.master.view_grideditor( grideditor.QueryEditor( self.master, message.query.items(multi=True), self.set_query, message ) ) elif part == "u": signals.status_prompt.send( prompt = "URL", text = message.url, callback = self.set_url ) elif part == "m" and message == self.flow.request: signals.status_prompt_onekey.send( prompt = "Method", keys = common.METHOD_OPTIONS, callback = self.edit_method ) elif part == "o": signals.status_prompt.send( prompt = "Code", text = str(message.status_code), callback = self.set_resp_status_code ) elif part == "m" and message == self.flow.response: signals.status_prompt.send( prompt = "Message", text = message.reason, callback = self.set_resp_reason ) signals.flow_change.send(self, flow = self.flow) def view_flow(self, flow): signals.pop_view_state.send(self) self.master.view_flow(flow, self.tab_offset) def _view_nextprev_flow(self, idx, flow): if not self.view.inbounds(idx): signals.status_message.send(message="No more flows") return self.view_flow(self.view[idx]) def view_next_flow(self, flow): return self._view_nextprev_flow(self.view.index(flow) + 1, flow) def view_prev_flow(self, flow): return self._view_nextprev_flow(self.view.index(flow) - 1, flow) def change_this_display_mode(self, t): view = contentviews.get_by_shortcut(t) if view: self.view.settings[self.flow][(self.tab_offset, "prettyview")] = view.name else: self.view.settings[self.flow][(self.tab_offset, "prettyview")] = None signals.flow_change.send(self, flow=self.flow) def keypress(self, size, key): conn = None # type: Optional[Union[http.HTTPRequest, http.HTTPResponse]] if self.tab_offset == TAB_REQ: conn = self.flow.request elif self.tab_offset == TAB_RESP: conn = self.flow.response key = super().keypress(size, key) # Special case: Space moves over to the next flow. # We need to catch that before applying common.shortcuts() if key == " ": self.view_next_flow(self.flow) return key = common.shortcuts(key) if key in ("up", "down", "page up", "page down"): # Pass scroll events to the wrapped widget self._w.keypress(size, key) elif key == "a": self.flow.resume() self.master.view.update(self.flow) elif key == "A": for f in self.view: if f.intercepted: f.resume() self.master.view.update(self.flow) elif key == "d": if self.flow.killable: self.flow.kill() self.view.remove(self.flow) if not self.view.focus.flow: self.master.view_flowlist() else: self.view_flow(self.view.focus.flow) elif key == "D": cp = self.flow.copy() self.master.view.add(cp) self.master.view.focus.flow = cp self.view_flow(cp) signals.status_message.send(message="Duplicated.") elif key == "p": self.view_prev_flow(self.flow) elif key == "r": try: self.master.replay_request(self.flow) except exceptions.ReplayException as e: signals.add_log("Replay error: %s" % e, "warn") signals.flow_change.send(self, flow = self.flow) elif key == "V": if self.flow.modified(): self.flow.revert() signals.flow_change.send(self, flow = self.flow) signals.status_message.send(message="Reverted.") else: signals.status_message.send(message="Flow not modified.") elif key == "W": signals.status_prompt_path.send( prompt = "Save this flow", callback = self.master.save_one_flow, args = (self.flow,) ) elif key == "|": signals.status_prompt_path.send( prompt = "Send flow to script", callback = self.master.run_script_once, args = (self.flow,) ) elif key == "e": if self.tab_offset == TAB_REQ: signals.status_prompt_onekey.send( prompt="Edit request", keys=( ("cookies", "c"), ("query", "q"), ("path", "p"), ("url", "u"), ("header", "h"), ("form", "f"), ("raw body", "r"), ("method", "m"), ), callback=self.edit ) elif self.tab_offset == TAB_RESP: signals.status_prompt_onekey.send( prompt="Edit response", keys=( ("cookies", "c"), ("code", "o"), ("message", "m"), ("header", "h"), ("raw body", "r"), ), callback=self.edit ) else: signals.status_message.send( message="Tab to the request or response", expire=1 ) elif key in set("bfgmxvzEC") and not conn: signals.status_message.send( message = "Tab to the request or response", expire = 1 ) return elif key == "b": if self.tab_offset == TAB_REQ: common.ask_save_body("q", self.flow) else: common.ask_save_body("s", self.flow) elif key == "f": self.view.settings[self.flow][(self.tab_offset, "fullcontents")] = True signals.flow_change.send(self, flow = self.flow) signals.status_message.send(message="Loading all body data...") elif key == "m": p = list(contentviews.view_prompts) p.insert(0, ("Clear", "C")) signals.status_prompt_onekey.send( self, prompt = "Display mode", keys = p, callback = self.change_this_display_mode ) elif key == "E": if self.tab_offset == TAB_REQ: scope = "q" else: scope = "s" signals.status_prompt_onekey.send( self, prompt = "Export to file", keys = [(e[0], e[1]) for e in export.EXPORTERS], callback = common.export_to_clip_or_file, args = (scope, self.flow, common.ask_save_path) ) elif key == "C": if self.tab_offset == TAB_REQ: scope = "q" else: scope = "s" signals.status_prompt_onekey.send( self, prompt = "Export to clipboard", keys = [(e[0], e[1]) for e in export.EXPORTERS], callback = common.export_to_clip_or_file, args = (scope, self.flow, common.copy_to_clipboard_or_prompt) ) elif key == "x": conn.content = None signals.flow_change.send(self, flow=self.flow) elif key == "v": if conn.raw_content: t = conn.headers.get("content-type") if "EDITOR" in os.environ or "PAGER" in os.environ: self.master.spawn_external_viewer(conn.get_content(strict=False), t) else: signals.status_message.send( message = "Error! Set $EDITOR or $PAGER." ) elif key == "z": self.flow.backup() e = conn.headers.get("content-encoding", "identity") if e != "identity": try: conn.decode() except ValueError: signals.status_message.send( message = "Could not decode - invalid data?" ) else: signals.status_prompt_onekey.send( prompt = "Select encoding: ", keys = ( ("gzip", "z"), ("deflate", "d"), ("brotli", "b"), ), callback = self.encode_callback, args = (conn,) ) signals.flow_change.send(self, flow = self.flow) else: # Key is not handled here. return key def encode_callback(self, key, conn): encoding_map = { "z": "gzip", "d": "deflate", "b": "br", } conn.encode(encoding_map[key]) signals.flow_change.send(self, flow = self.flow)
mit
[ 646, 3473, 199, 646, 747, 199, 646, 984, 199, 504, 9143, 492, 634, 6558, 63, 1637, 199, 504, 14090, 492, 4879, 12, 15961, 221, 327, 8151, 199, 199, 646, 7629, 19686, 199, 199, 504, 30714, 311, 293, 1702, 492, 1564, 4196, 199, 504, 30714, 311, 293, 1702, 492, 4967, 199, 504, 30714, 311, 293, 1702, 492, 4843, 199, 504, 30714, 311, 293, 1702, 492, 1455, 199, 504, 30714, 311, 293, 1702, 14, 846, 14, 1014, 492, 21391, 199, 504, 30714, 311, 293, 1702, 14, 846, 14, 1014, 492, 2004, 63, 6021, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 2863, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 6369, 5506, 1345, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 486, 2188, 27050, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 2754, 461, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 10166, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 12187, 421, 199, 533, 8730, 547, 8, 1726, 304, 272, 986, 421, 199, 318, 485, 3880, 3437, 837, 272, 1318, 275, 942, 272, 2883, 275, 359, 267, 1689, 33, 401, 298, 5694, 1006, 1640, 7203, 30708, 1288, 267, 1689, 65, 401, 298, 5694, 642, 1640, 7203, 6369, 1288, 267, 1689, 66, 401, 298, 2117, 1056, 15, 1310, 2396, 1288, 267, 1689, 35, 401, 298, 3790, 6369, 370, 11353, 3576, 1288, 267, 1689, 36, 401, 298, 11081, 6369, 1288, 267, 1689, 68, 401, 298, 1807, 6369, 1288, 267, 1689, 69, 401, 298, 3773, 1056, 15, 1310, 1288, 267, 1689, 70, 401, 298, 912, 2615, 2396, 666, 1288, 267, 1689, 77, 401, 298, 1461, 2396, 2929, 818, 367, 642, 4642, 60, 78, 8, 885, 818, 883, 506, 2896, 315, 314, 1511, 13185, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 23292, 401, 298, 65, 531, 435, 268, 10003, 505, 401, 7244, 4834, 15212, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 4097, 401, 298, 69, 531, 435, 268, 10003, 505, 401, 7244, 28333, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1360, 401, 298, 72, 531, 435, 268, 10003, 505, 401, 7244, 4163, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1569, 401, 298, 73, 531, 435, 268, 10003, 505, 401, 7244, 6047, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 9554, 401, 298, 74, 531, 435, 268, 10003, 505, 401, 7244, 15250, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1001, 401, 298, 83, 531, 435, 268, 10003, 505, 401, 7244, 4840, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 21886, 401, 298, 85, 531, 435, 268, 10003, 505, 401, 7244, 2851, 13, 8167, 666, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1773, 401, 298, 82, 531, 435, 268, 10003, 505, 401, 7244, 3066, 666, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1652, 401, 298, 88, 531, 435, 268, 10003, 505, 401, 7244, 4692, 11323, 268, 2318, 267, 1689, 37, 401, 298, 3790, 6369, 370, 570, 1288, 267, 1689, 82, 401, 298, 19540, 1056, 1288, 267, 1689, 54, 401, 298, 19092, 4493, 370, 1056, 1288, 267, 1689, 86, 401, 298, 1345, 2396, 315, 5957, 27354, 1288, 267, 1689, 87, 401, 298, 2117, 1006, 30708, 4877, 1453, 2455, 2457, 1288, 267, 1689, 55, 401, 298, 2117, 642, 6369, 1288, 267, 1689, 88, 401, 298, 1807, 2396, 1288, 267, 1689, 90, 401, 298, 2143, 15, 2708, 282, 1056, 15, 1310, 1288, 267, 1689, 2902, 401, 298, 2184, 5174, 1288, 267, 1689, 72, 12, 634, 401, 298, 6352, 5174, 12, 2163, 5174, 1288, 267, 1689, 2638, 401, 298, 2184, 6369, 1288, 267, 1689, 92, 401, 298, 1065, 2884, 641, 642, 6369, 1288, 267, 1689, 10665, 298, 1733, 334, 2546, 18423, 13185, 267, 1689, 78, 401, 298, 8755, 2754, 7568, 1288, 267, 1689, 46, 401, 298, 8755, 2754, 8552, 1288, 272, 1622, 272, 1318, 14, 2880, 8, 2330, 14, 908, 63, 498, 3643, 8, 1612, 12, 790, 628, 498, 401, 1139, 628, 505, 401, 4363, 29, 20, 430, 272, 372, 1318, 421, 199, 3437, 63, 1100, 275, 485, 3880, 3437, 342, 199, 199, 12781, 275, 359, 272, 661, 13983, 63, 498, 297, 23665, 1288, 7244, 3437, 3872, 272, 661, 13983, 63, 498, 297, 298, 81, 1288, 7244, 894, 3872, 199, 61, 421, 199, 533, 20823, 2768, 2567, 8, 300, 19686, 14, 3339, 15991, 304, 339, 347, 636, 826, 721, 277, 12, 5288, 26, 298, 1147, 311, 293, 1702, 14, 6614, 14, 4133, 14, 9270, 12288, 401, 289, 26, 1455, 14, 2856, 5060, 304, 267, 291, 14, 4133, 275, 5288, 267, 291, 14, 1659, 275, 289, 267, 291, 423, 87, 275, 2863, 14, 908, 63, 1659, 8, 288, 289, 12, 288, 756, 12, 288, 9243, 29, 549, 12, 288, 1591, 1291, 29, 277, 14, 4133, 14, 1419, 14, 2384, 1102, 267, 776, 267, 10166, 14, 1659, 63, 1461, 14, 2242, 8, 277, 14, 4093, 63, 1659, 63, 1461, 9, 339, 347, 5259, 63, 1659, 63, 1461, 8, 277, 12, 8904, 12, 6369, 304, 267, 340, 6369, 508, 291, 14, 1659, 26, 288, 291, 423, 87, 275, 2863, 14, 908, 63, 1659, 8, 355, 6369, 12, 355, 756, 12, 355, 9243, 29, 549, 12, 355, 1591, 1291, 29, 277, 14, 4133, 14, 1419, 14, 2384, 1102, 288, 776, 421, 199, 10129, 63, 14583, 275, 378, 199, 10129, 63, 11073, 275, 413, 421, 199, 533, 20823, 2768, 8, 8741, 14, 23085, 304, 272, 11850, 63, 2326, 275, 298, 12283, 698, 2, 339, 347, 636, 826, 721, 277, 12, 5288, 12, 2455, 12, 6369, 12, 5174, 63, 2743, 304, 267, 291, 14, 4133, 12, 291, 14, 1345, 12, 291, 14, 1659, 275, 5288, 12, 2455, 12, 6369, 267, 1613, 11027, 826, 721, 288, 359, 355, 334, 277, 14, 2902, 63, 1069, 12, 291, 14, 1345, 63, 1069, 395, 355, 334, 277, 14, 2902, 63, 1310, 12, 291, 14, 1345, 63, 1310, 395, 355 ]
[ 3473, 199, 646, 747, 199, 646, 984, 199, 504, 9143, 492, 634, 6558, 63, 1637, 199, 504, 14090, 492, 4879, 12, 15961, 221, 327, 8151, 199, 199, 646, 7629, 19686, 199, 199, 504, 30714, 311, 293, 1702, 492, 1564, 4196, 199, 504, 30714, 311, 293, 1702, 492, 4967, 199, 504, 30714, 311, 293, 1702, 492, 4843, 199, 504, 30714, 311, 293, 1702, 492, 1455, 199, 504, 30714, 311, 293, 1702, 14, 846, 14, 1014, 492, 21391, 199, 504, 30714, 311, 293, 1702, 14, 846, 14, 1014, 492, 2004, 63, 6021, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 2863, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 6369, 5506, 1345, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 486, 2188, 27050, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 2754, 461, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 10166, 199, 504, 30714, 311, 293, 1702, 14, 2537, 14, 6614, 492, 12187, 421, 199, 533, 8730, 547, 8, 1726, 304, 272, 986, 421, 199, 318, 485, 3880, 3437, 837, 272, 1318, 275, 942, 272, 2883, 275, 359, 267, 1689, 33, 401, 298, 5694, 1006, 1640, 7203, 30708, 1288, 267, 1689, 65, 401, 298, 5694, 642, 1640, 7203, 6369, 1288, 267, 1689, 66, 401, 298, 2117, 1056, 15, 1310, 2396, 1288, 267, 1689, 35, 401, 298, 3790, 6369, 370, 11353, 3576, 1288, 267, 1689, 36, 401, 298, 11081, 6369, 1288, 267, 1689, 68, 401, 298, 1807, 6369, 1288, 267, 1689, 69, 401, 298, 3773, 1056, 15, 1310, 1288, 267, 1689, 70, 401, 298, 912, 2615, 2396, 666, 1288, 267, 1689, 77, 401, 298, 1461, 2396, 2929, 818, 367, 642, 4642, 60, 78, 8, 885, 818, 883, 506, 2896, 315, 314, 1511, 13185, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 23292, 401, 298, 65, 531, 435, 268, 10003, 505, 401, 7244, 4834, 15212, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 4097, 401, 298, 69, 531, 435, 268, 10003, 505, 401, 7244, 28333, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1360, 401, 298, 72, 531, 435, 268, 10003, 505, 401, 7244, 4163, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1569, 401, 298, 73, 531, 435, 268, 10003, 505, 401, 7244, 6047, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 9554, 401, 298, 74, 531, 435, 268, 10003, 505, 401, 7244, 15250, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1001, 401, 298, 83, 531, 435, 268, 10003, 505, 401, 7244, 4840, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 21886, 401, 298, 85, 531, 435, 268, 10003, 505, 401, 7244, 2851, 13, 8167, 666, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1773, 401, 298, 82, 531, 435, 268, 10003, 505, 401, 7244, 3066, 666, 11323, 268, 2318, 267, 334, 403, 12, 268, 2863, 14, 14337, 63, 498, 480, 1652, 401, 298, 88, 531, 435, 268, 10003, 505, 401, 7244, 4692, 11323, 268, 2318, 267, 1689, 37, 401, 298, 3790, 6369, 370, 570, 1288, 267, 1689, 82, 401, 298, 19540, 1056, 1288, 267, 1689, 54, 401, 298, 19092, 4493, 370, 1056, 1288, 267, 1689, 86, 401, 298, 1345, 2396, 315, 5957, 27354, 1288, 267, 1689, 87, 401, 298, 2117, 1006, 30708, 4877, 1453, 2455, 2457, 1288, 267, 1689, 55, 401, 298, 2117, 642, 6369, 1288, 267, 1689, 88, 401, 298, 1807, 2396, 1288, 267, 1689, 90, 401, 298, 2143, 15, 2708, 282, 1056, 15, 1310, 1288, 267, 1689, 2902, 401, 298, 2184, 5174, 1288, 267, 1689, 72, 12, 634, 401, 298, 6352, 5174, 12, 2163, 5174, 1288, 267, 1689, 2638, 401, 298, 2184, 6369, 1288, 267, 1689, 92, 401, 298, 1065, 2884, 641, 642, 6369, 1288, 267, 1689, 10665, 298, 1733, 334, 2546, 18423, 13185, 267, 1689, 78, 401, 298, 8755, 2754, 7568, 1288, 267, 1689, 46, 401, 298, 8755, 2754, 8552, 1288, 272, 1622, 272, 1318, 14, 2880, 8, 2330, 14, 908, 63, 498, 3643, 8, 1612, 12, 790, 628, 498, 401, 1139, 628, 505, 401, 4363, 29, 20, 430, 272, 372, 1318, 421, 199, 3437, 63, 1100, 275, 485, 3880, 3437, 342, 199, 199, 12781, 275, 359, 272, 661, 13983, 63, 498, 297, 23665, 1288, 7244, 3437, 3872, 272, 661, 13983, 63, 498, 297, 298, 81, 1288, 7244, 894, 3872, 199, 61, 421, 199, 533, 20823, 2768, 2567, 8, 300, 19686, 14, 3339, 15991, 304, 339, 347, 636, 826, 721, 277, 12, 5288, 26, 298, 1147, 311, 293, 1702, 14, 6614, 14, 4133, 14, 9270, 12288, 401, 289, 26, 1455, 14, 2856, 5060, 304, 267, 291, 14, 4133, 275, 5288, 267, 291, 14, 1659, 275, 289, 267, 291, 423, 87, 275, 2863, 14, 908, 63, 1659, 8, 288, 289, 12, 288, 756, 12, 288, 9243, 29, 549, 12, 288, 1591, 1291, 29, 277, 14, 4133, 14, 1419, 14, 2384, 1102, 267, 776, 267, 10166, 14, 1659, 63, 1461, 14, 2242, 8, 277, 14, 4093, 63, 1659, 63, 1461, 9, 339, 347, 5259, 63, 1659, 63, 1461, 8, 277, 12, 8904, 12, 6369, 304, 267, 340, 6369, 508, 291, 14, 1659, 26, 288, 291, 423, 87, 275, 2863, 14, 908, 63, 1659, 8, 355, 6369, 12, 355, 756, 12, 355, 9243, 29, 549, 12, 355, 1591, 1291, 29, 277, 14, 4133, 14, 1419, 14, 2384, 1102, 288, 776, 421, 199, 10129, 63, 14583, 275, 378, 199, 10129, 63, 11073, 275, 413, 421, 199, 533, 20823, 2768, 8, 8741, 14, 23085, 304, 272, 11850, 63, 2326, 275, 298, 12283, 698, 2, 339, 347, 636, 826, 721, 277, 12, 5288, 12, 2455, 12, 6369, 12, 5174, 63, 2743, 304, 267, 291, 14, 4133, 12, 291, 14, 1345, 12, 291, 14, 1659, 275, 5288, 12, 2455, 12, 6369, 267, 1613, 11027, 826, 721, 288, 359, 355, 334, 277, 14, 2902, 63, 1069, 12, 291, 14, 1345, 63, 1069, 395, 355, 334, 277, 14, 2902, 63, 1310, 12, 291, 14, 1345, 63, 1310, 395, 355, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kuzmoyev/Google-Calendar-Simple-API
tests/test_attachment.py
1
3788
from unittest import TestCase from gcsa.attachment import Attachment from gcsa.serializers.attachment_serializer import AttachmentSerializer DOC_URL = 'https://docs.google.com/document/d/1uDvwcxOsXkzl2Bod0YIfrIQ5MqfBhnc1jusYdH1xCZo/edit?usp=sharing' class TestAttachment(TestCase): def test_create(self): attachment = Attachment('My doc', file_url=DOC_URL, mime_type="application/vnd.google-apps.document") self.assertEqual(attachment.title, 'My doc') with self.assertRaises(ValueError): Attachment('My doc', file_url=DOC_URL, mime_type="application/vnd.google-apps.something") class TestAttachmentSerializer(TestCase): def test_to_json(self): attachment = Attachment('My doc', file_url=DOC_URL, mime_type="application/vnd.google-apps.document") attachment_json = { 'title': 'My doc', 'fileUrl': DOC_URL, 'mimeType': "application/vnd.google-apps.document" } self.assertDictEqual(AttachmentSerializer.to_json(attachment), attachment_json) attachment = Attachment('My doc2', file_url=DOC_URL, mime_type="application/vnd.google-apps.drawing", icon_link="https://some_link.com", file_id='abc123') attachment_json = { 'title': 'My doc2', 'fileUrl': DOC_URL, 'mimeType': "application/vnd.google-apps.drawing", 'iconLink': "https://some_link.com", 'fileId': 'abc123' } serializer = AttachmentSerializer(attachment) self.assertDictEqual(serializer.get_json(), attachment_json) def test_to_object(self): attachment_json = { 'title': 'My doc', 'fileUrl': DOC_URL, 'mimeType': "application/vnd.google-apps.document" } attachment = AttachmentSerializer.to_object(attachment_json) self.assertEqual(attachment.title, 'My doc') self.assertEqual(attachment.file_url, DOC_URL) self.assertEqual(attachment.mime_type, "application/vnd.google-apps.document") self.assertIsNone(attachment.icon_link) self.assertIsNone(attachment.file_id) attachment_json = { 'title': 'My doc2', 'fileUrl': DOC_URL, 'mimeType': "application/vnd.google-apps.drawing", 'iconLink': "https://some_link.com", 'fileId': 'abc123' } serializer = AttachmentSerializer(attachment_json) attachment = serializer.get_object() self.assertEqual(attachment.title, 'My doc2') self.assertEqual(attachment.file_url, DOC_URL) self.assertEqual(attachment.mime_type, "application/vnd.google-apps.drawing") self.assertEqual(attachment.icon_link, "https://some_link.com") self.assertEqual(attachment.file_id, 'abc123') attachment_json_str = """{ "title": "My doc3", "fileUrl": "%s", "mimeType": "application/vnd.google-apps.drawing", "iconLink": "https://some_link.com", "fileId": "abc123" } """ % DOC_URL attachment = AttachmentSerializer.to_object(attachment_json_str) self.assertEqual(attachment.title, 'My doc3') self.assertEqual(attachment.file_url, DOC_URL) self.assertEqual(attachment.mime_type, "application/vnd.google-apps.drawing") self.assertEqual(attachment.icon_link, "https://some_link.com") self.assertEqual(attachment.file_id, 'abc123')
mit
[ 504, 2882, 492, 7640, 199, 199, 504, 486, 1259, 65, 14, 8905, 492, 21328, 434, 199, 504, 486, 1259, 65, 14, 12844, 14, 8905, 63, 8349, 492, 21328, 434, 7299, 199, 199, 16618, 63, 2632, 275, 283, 2859, 921, 4757, 14, 3098, 14, 957, 15, 3554, 15, 68, 15, 17, 18867, 19665, 11859, 24351, 56, 75, 90, 76, 18, 34, 364, 16, 57, 3917, 82, 23559, 21, 45, 31814, 34, 6164, 67, 17, 74, 527, 57, 68, 40, 17, 8163, 58, 79, 15, 3773, 31, 527, 80, 29, 29122, 7, 421, 199, 533, 1379, 22662, 8, 1746, 304, 339, 347, 511, 63, 981, 8, 277, 304, 267, 12193, 275, 21328, 434, 360, 5713, 1382, 297, 1816, 570, 63, 633, 29, 16618, 63, 2632, 12, 1816, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 531, 267, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 358, 398, 543, 291, 14, 1855, 8, 3393, 304, 288, 21328, 434, 360, 5713, 1382, 297, 2432, 570, 63, 633, 29, 16618, 63, 2632, 12, 2432, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 10297, 531, 421, 199, 533, 1379, 22662, 7299, 8, 1746, 304, 339, 347, 511, 63, 475, 63, 1001, 8, 277, 304, 267, 12193, 275, 21328, 434, 360, 5713, 1382, 297, 1816, 570, 63, 633, 29, 16618, 63, 2632, 12, 1816, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 531, 267, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 2, 267, 789, 267, 291, 14, 19512, 8, 22662, 7299, 14, 475, 63, 1001, 8, 8905, 395, 12193, 63, 1001, 9, 398, 12193, 275, 21328, 434, 360, 5713, 1382, 18, 297, 1816, 570, 63, 633, 29, 16618, 63, 2632, 12, 1816, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 1816, 7016, 63, 1073, 628, 2859, 921, 3972, 63, 1073, 14, 957, 401, 1816, 570, 63, 344, 534, 3175, 4288, 358, 267, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 18, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 288, 283, 4677, 3834, 356, 298, 2859, 921, 3972, 63, 1073, 14, 957, 401, 288, 283, 493, 1304, 356, 283, 3175, 4288, 7, 267, 789, 267, 9146, 275, 21328, 434, 7299, 8, 8905, 9, 267, 291, 14, 19512, 8, 8349, 14, 362, 63, 1001, 1062, 12193, 63, 1001, 9, 339, 347, 511, 63, 475, 63, 785, 8, 277, 304, 267, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 2, 267, 789, 267, 12193, 275, 21328, 434, 7299, 14, 475, 63, 785, 8, 8905, 63, 1001, 9, 398, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 358, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 633, 12, 3506, 35, 63, 2632, 9, 267, 291, 14, 629, 8, 8905, 14, 7626, 63, 466, 12, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 531, 267, 291, 14, 7702, 8, 8905, 14, 4677, 63, 1073, 9, 267, 291, 14, 7702, 8, 8905, 14, 493, 63, 344, 9, 398, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 18, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 288, 283, 4677, 3834, 356, 298, 2859, 921, 3972, 63, 1073, 14, 957, 401, 288, 283, 493, 1304, 356, 283, 3175, 4288, 7, 267, 789, 267, 9146, 275, 21328, 434, 7299, 8, 8905, 63, 1001, 9, 267, 12193, 275, 9146, 14, 362, 63, 785, 342, 398, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 18, 358, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 633, 12, 3506, 35, 63, 2632, 9, 267, 291, 14, 629, 8, 8905, 14, 7626, 63, 466, 12, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 531, 267, 291, 14, 629, 8, 8905, 14, 4677, 63, 1073, 12, 298, 2859, 921, 3972, 63, 1073, 14, 957, 531, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 344, 12, 283, 3175, 4288, 358, 398, 12193, 63, 1001, 63, 495, 275, 408, 91, 288, 298, 1213, 582, 298, 5713, 1382, 19, 401, 288, 298, 493, 6417, 582, 2071, 83, 401, 288, 298, 7626, 804, 582, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 288, 298, 4677, 3834, 582, 298, 2859, 921, 3972, 63, 1073, 14, 957, 401, 288, 298, 493, 1304, 582, 298, 3175, 4288, 2, 267, 789, 267, 408, 450, 3506, 35, 63, 2632, 267, 12193, 275, 21328, 434, 7299, 14, 475, 63, 785, 8, 8905, 63, 1001, 63, 495, 9, 398, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 19, 358, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 633, 12, 3506, 35, 63, 2632, 9, 267, 291, 14, 629, 8, 8905, 14, 7626, 63, 466, 12, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 531, 267, 291, 14, 629, 8, 8905, 14, 4677, 63, 1073, 12, 298, 2859, 921, 3972, 63, 1073, 14, 957, 531, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 344, 12, 283, 3175, 4288, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2882, 492, 7640, 199, 199, 504, 486, 1259, 65, 14, 8905, 492, 21328, 434, 199, 504, 486, 1259, 65, 14, 12844, 14, 8905, 63, 8349, 492, 21328, 434, 7299, 199, 199, 16618, 63, 2632, 275, 283, 2859, 921, 4757, 14, 3098, 14, 957, 15, 3554, 15, 68, 15, 17, 18867, 19665, 11859, 24351, 56, 75, 90, 76, 18, 34, 364, 16, 57, 3917, 82, 23559, 21, 45, 31814, 34, 6164, 67, 17, 74, 527, 57, 68, 40, 17, 8163, 58, 79, 15, 3773, 31, 527, 80, 29, 29122, 7, 421, 199, 533, 1379, 22662, 8, 1746, 304, 339, 347, 511, 63, 981, 8, 277, 304, 267, 12193, 275, 21328, 434, 360, 5713, 1382, 297, 1816, 570, 63, 633, 29, 16618, 63, 2632, 12, 1816, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 531, 267, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 358, 398, 543, 291, 14, 1855, 8, 3393, 304, 288, 21328, 434, 360, 5713, 1382, 297, 2432, 570, 63, 633, 29, 16618, 63, 2632, 12, 2432, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 10297, 531, 421, 199, 533, 1379, 22662, 7299, 8, 1746, 304, 339, 347, 511, 63, 475, 63, 1001, 8, 277, 304, 267, 12193, 275, 21328, 434, 360, 5713, 1382, 297, 1816, 570, 63, 633, 29, 16618, 63, 2632, 12, 1816, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 531, 267, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 2, 267, 789, 267, 291, 14, 19512, 8, 22662, 7299, 14, 475, 63, 1001, 8, 8905, 395, 12193, 63, 1001, 9, 398, 12193, 275, 21328, 434, 360, 5713, 1382, 18, 297, 1816, 570, 63, 633, 29, 16618, 63, 2632, 12, 1816, 6660, 63, 466, 628, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 1816, 7016, 63, 1073, 628, 2859, 921, 3972, 63, 1073, 14, 957, 401, 1816, 570, 63, 344, 534, 3175, 4288, 358, 267, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 18, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 288, 283, 4677, 3834, 356, 298, 2859, 921, 3972, 63, 1073, 14, 957, 401, 288, 283, 493, 1304, 356, 283, 3175, 4288, 7, 267, 789, 267, 9146, 275, 21328, 434, 7299, 8, 8905, 9, 267, 291, 14, 19512, 8, 8349, 14, 362, 63, 1001, 1062, 12193, 63, 1001, 9, 339, 347, 511, 63, 475, 63, 785, 8, 277, 304, 267, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 2, 267, 789, 267, 12193, 275, 21328, 434, 7299, 14, 475, 63, 785, 8, 8905, 63, 1001, 9, 398, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 358, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 633, 12, 3506, 35, 63, 2632, 9, 267, 291, 14, 629, 8, 8905, 14, 7626, 63, 466, 12, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 3554, 531, 267, 291, 14, 7702, 8, 8905, 14, 4677, 63, 1073, 9, 267, 291, 14, 7702, 8, 8905, 14, 493, 63, 344, 9, 398, 12193, 63, 1001, 275, 469, 288, 283, 1213, 356, 283, 5713, 1382, 18, 297, 288, 283, 493, 6417, 356, 3506, 35, 63, 2632, 12, 288, 283, 7626, 804, 356, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 288, 283, 4677, 3834, 356, 298, 2859, 921, 3972, 63, 1073, 14, 957, 401, 288, 283, 493, 1304, 356, 283, 3175, 4288, 7, 267, 789, 267, 9146, 275, 21328, 434, 7299, 8, 8905, 63, 1001, 9, 267, 12193, 275, 9146, 14, 362, 63, 785, 342, 398, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 18, 358, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 633, 12, 3506, 35, 63, 2632, 9, 267, 291, 14, 629, 8, 8905, 14, 7626, 63, 466, 12, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 531, 267, 291, 14, 629, 8, 8905, 14, 4677, 63, 1073, 12, 298, 2859, 921, 3972, 63, 1073, 14, 957, 531, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 344, 12, 283, 3175, 4288, 358, 398, 12193, 63, 1001, 63, 495, 275, 408, 91, 288, 298, 1213, 582, 298, 5713, 1382, 19, 401, 288, 298, 493, 6417, 582, 2071, 83, 401, 288, 298, 7626, 804, 582, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 401, 288, 298, 4677, 3834, 582, 298, 2859, 921, 3972, 63, 1073, 14, 957, 401, 288, 298, 493, 1304, 582, 298, 3175, 4288, 2, 267, 789, 267, 408, 450, 3506, 35, 63, 2632, 267, 12193, 275, 21328, 434, 7299, 14, 475, 63, 785, 8, 8905, 63, 1001, 63, 495, 9, 398, 291, 14, 629, 8, 8905, 14, 1213, 12, 283, 5713, 1382, 19, 358, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 633, 12, 3506, 35, 63, 2632, 9, 267, 291, 14, 629, 8, 8905, 14, 7626, 63, 466, 12, 298, 3578, 15, 26379, 14, 3098, 13, 5181, 14, 25195, 531, 267, 291, 14, 629, 8, 8905, 14, 4677, 63, 1073, 12, 298, 2859, 921, 3972, 63, 1073, 14, 957, 531, 267, 291, 14, 629, 8, 8905, 14, 493, 63, 344, 12, 283, 3175, 4288, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ghosteyezz/my-linux-kernel-study
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
11088
3246
# Core.py - Python extension for perf script, core functions # # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com> # # This software may be distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. from collections import defaultdict def autodict(): return defaultdict(autodict) flag_fields = autodict() symbolic_fields = autodict() def define_flag_field(event_name, field_name, delim): flag_fields[event_name][field_name]['delim'] = delim def define_flag_value(event_name, field_name, value, field_str): flag_fields[event_name][field_name]['values'][value] = field_str def define_symbolic_field(event_name, field_name): # nothing to do, really pass def define_symbolic_value(event_name, field_name, value, field_str): symbolic_fields[event_name][field_name]['values'][value] = field_str def flag_str(event_name, field_name, value): string = "" if flag_fields[event_name][field_name]: print_delim = 0 keys = flag_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string += flag_fields[event_name][field_name]['values'][idx] break if idx and (value & idx) == idx: if print_delim and flag_fields[event_name][field_name]['delim']: string += " " + flag_fields[event_name][field_name]['delim'] + " " string += flag_fields[event_name][field_name]['values'][idx] print_delim = 1 value &= ~idx return string def symbol_str(event_name, field_name, value): string = "" if symbolic_fields[event_name][field_name]: keys = symbolic_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string = symbolic_fields[event_name][field_name]['values'][idx] break if (value == idx): string = symbolic_fields[event_name][field_name]['values'][idx] break return string trace_flags = { 0x00: "NONE", \ 0x01: "IRQS_OFF", \ 0x02: "IRQS_NOSUPPORT", \ 0x04: "NEED_RESCHED", \ 0x08: "HARDIRQ", \ 0x10: "SOFTIRQ" } def trace_flag_str(value): string = "" print_delim = 0 keys = trace_flags.keys() for idx in keys: if not value and not idx: string += "NONE" break if idx and (value & idx) == idx: if print_delim: string += " | "; string += trace_flags[idx] print_delim = 1 value &= ~idx return string def taskState(state): states = { 0 : "R", 1 : "S", 2 : "D", 64: "DEAD" } if state not in states: return "Unknown" return states[state] class EventHeaders: def __init__(self, common_cpu, common_secs, common_nsecs, common_pid, common_comm): self.cpu = common_cpu self.secs = common_secs self.nsecs = common_nsecs self.pid = common_pid self.comm = common_comm def ts(self): return (self.secs * (10 ** 9)) + self.nsecs def ts_format(self): return "%d.%d" % (self.secs, int(self.nsecs / 1000))
gpl-2.0
[ 3, 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
radoondas/apachebeat
vendor/github.com/elastic/beats/topbeat/tests/system/test_filtering.py
6
4127
from topbeat import BaseTest """ Contains tests for filtering. """ class Test(BaseTest): def test_dropfields(self): """ Check drop_fields filtering action """ self.render_config_template( system_stats=False, process_stats=True, filesystem_stats=False, drop_fields=["proc"] ) topbeat = self.start_beat() self.wait_until( lambda: self.output_count(lambda x: x >= 1), max_timeout=15) topbeat.kill_and_wait() output = self.read_output( required_fields=["@timestamp", "type"], )[0] for key in [ "proc.cpu.start_time", "proc.cpu.total", "proc.cpu.total_p", "proc.cpu.user", "proc.cpu.system", "proc.name", "proc.state", "proc.pid", ]: assert key not in output def test_include_fields(self): """ Check include_fields filtering action """ self.render_config_template( system_stats=False, process_stats=True, filesystem_stats=False, include_fields=["proc.cpu", "proc.mem"] ) topbeat = self.start_beat() self.wait_until( lambda: self.output_count(lambda x: x >= 1), max_timeout=15) topbeat.kill_and_wait() output = self.read_output( required_fields=["@timestamp", "type"], )[0] print(output) for key in [ "proc.cpu.start_time", "proc.cpu.total", "proc.cpu.total_p", "proc.cpu.user", "proc.cpu.system", "proc.mem.size", "proc.mem.rss", "proc.mem.rss_p" ]: assert key in output for key in [ "proc.name", "proc.pid", ]: assert key not in output def test_multiple_actions(self): """ Check the result when configuring two actions: include_fields and drop_fields. """ self.render_config_template( system_stats=False, process_stats=True, filesystem_stats=False, include_fields=["proc"], drop_fields=["proc.mem"], ) topbeat = self.start_beat() self.wait_until( lambda: self.output_count(lambda x: x >= 1), max_timeout=15) topbeat.kill_and_wait() output = self.read_output( required_fields=["@timestamp", "type"], )[0] for key in [ "proc.cpu.start_time", "proc.cpu.total", "proc.cpu.total_p", "proc.cpu.user", "proc.cpu.system", "proc.name", "proc.pid", ]: assert key in output for key in [ "proc.mem.size", "proc.mem.rss", "proc.mem.rss_p" ]: assert key not in output def test_contradictory_multiple_actions(self): """ Check the behaviour of a contradictory multiple actions """ self.render_config_template( system_stats=False, process_stats=True, filesystem_stats=False, include_fields=["proc.mem.size", "proc.mem.rss_p"], drop_fields=["proc.mem.size", "proc.mem.rss_p"], ) topbeat = self.start_beat() self.wait_until( lambda: self.output_count(lambda x: x >= 1), max_timeout=15) topbeat.kill_and_wait() output = self.read_output( required_fields=["@timestamp", "type"], )[0] for key in [ "proc.mem.size", "proc.mem.rss", "proc.cpu.start_time", "proc.cpu.total", "proc.cpu.total_p", "proc.cpu.user", "proc.cpu.system", "proc.name", "proc.pid", "proc.mem.rss_p" ]: assert key not in output
apache-2.0
[ 504, 2746, 12522, 492, 3523, 774, 199, 199, 624, 199, 6906, 2295, 367, 14545, 14, 199, 624, 421, 199, 533, 1379, 8, 23170, 304, 272, 347, 511, 63, 4824, 955, 8, 277, 304, 267, 408, 267, 2670, 5978, 63, 955, 14545, 1595, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 5978, 63, 955, 6270, 4687, 937, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 398, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 929, 401, 288, 298, 4687, 14, 3150, 401, 267, 16246, 288, 702, 790, 440, 315, 1072, 339, 347, 511, 63, 2613, 63, 955, 8, 277, 304, 267, 408, 267, 2670, 2387, 63, 955, 14545, 1595, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 2387, 63, 955, 6270, 4687, 14, 3541, 401, 298, 4687, 14, 5286, 937, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 398, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 267, 870, 8, 1199, 9, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 5286, 14, 890, 401, 288, 298, 4687, 14, 5286, 14, 13614, 401, 288, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2, 267, 16246, 288, 702, 790, 315, 1072, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 3150, 401, 267, 16246, 288, 702, 790, 440, 315, 1072, 339, 347, 511, 63, 6048, 63, 3723, 8, 277, 304, 267, 408, 267, 2670, 314, 754, 1380, 1101, 4039, 2877, 5445, 26, 2387, 63, 955, 267, 436, 5978, 63, 955, 14, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 2387, 63, 955, 6270, 4687, 2255, 288, 5978, 63, 955, 6270, 4687, 14, 5286, 2255, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 398, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 3150, 401, 267, 16246, 288, 702, 790, 315, 1072, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 5286, 14, 890, 401, 288, 298, 4687, 14, 5286, 14, 13614, 401, 288, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2, 267, 16246, 288, 702, 790, 440, 315, 1072, 339, 347, 511, 63, 17926, 328, 1076, 63, 6048, 63, 3723, 8, 277, 304, 267, 408, 267, 2670, 314, 13942, 402, 282, 18782, 328, 1076, 3663, 5445, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 2387, 63, 955, 6270, 4687, 14, 5286, 14, 890, 401, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2255, 288, 5978, 63, 955, 6270, 4687, 14, 5286, 14, 890, 401, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2255, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 267, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 5286, 14, 890, 401, 288, 298, 4687, 14, 5286, 14, 13614, 401, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 3150, 401, 288, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2, 267, 16246, 288, 702, 790, 440, 315, 1072, 199, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2746, 12522, 492, 3523, 774, 199, 199, 624, 199, 6906, 2295, 367, 14545, 14, 199, 624, 421, 199, 533, 1379, 8, 23170, 304, 272, 347, 511, 63, 4824, 955, 8, 277, 304, 267, 408, 267, 2670, 5978, 63, 955, 14545, 1595, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 5978, 63, 955, 6270, 4687, 937, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 398, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 929, 401, 288, 298, 4687, 14, 3150, 401, 267, 16246, 288, 702, 790, 440, 315, 1072, 339, 347, 511, 63, 2613, 63, 955, 8, 277, 304, 267, 408, 267, 2670, 2387, 63, 955, 14545, 1595, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 2387, 63, 955, 6270, 4687, 14, 3541, 401, 298, 4687, 14, 5286, 937, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 398, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 267, 870, 8, 1199, 9, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 5286, 14, 890, 401, 288, 298, 4687, 14, 5286, 14, 13614, 401, 288, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2, 267, 16246, 288, 702, 790, 315, 1072, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 3150, 401, 267, 16246, 288, 702, 790, 440, 315, 1072, 339, 347, 511, 63, 6048, 63, 3723, 8, 277, 304, 267, 408, 267, 2670, 314, 754, 1380, 1101, 4039, 2877, 5445, 26, 2387, 63, 955, 267, 436, 5978, 63, 955, 14, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 2387, 63, 955, 6270, 4687, 2255, 288, 5978, 63, 955, 6270, 4687, 14, 5286, 2255, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 398, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 3150, 401, 267, 16246, 288, 702, 790, 315, 1072, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 5286, 14, 890, 401, 288, 298, 4687, 14, 5286, 14, 13614, 401, 288, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2, 267, 16246, 288, 702, 790, 440, 315, 1072, 339, 347, 511, 63, 17926, 328, 1076, 63, 6048, 63, 3723, 8, 277, 304, 267, 408, 267, 2670, 314, 13942, 402, 282, 18782, 328, 1076, 3663, 5445, 267, 408, 267, 291, 14, 3352, 63, 888, 63, 1160, 8, 288, 2656, 63, 3200, 29, 797, 12, 288, 2112, 63, 3200, 29, 549, 12, 288, 10036, 63, 3200, 29, 797, 12, 288, 2387, 63, 955, 6270, 4687, 14, 5286, 14, 890, 401, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2255, 288, 5978, 63, 955, 6270, 4687, 14, 5286, 14, 890, 401, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2255, 267, 776, 267, 2746, 12522, 275, 291, 14, 928, 63, 12522, 342, 267, 291, 14, 2573, 63, 8111, 8, 288, 2400, 26, 291, 14, 1199, 63, 835, 8, 2734, 671, 26, 671, 2356, 413, 395, 288, 1390, 63, 2593, 29, 1046, 9, 267, 2746, 12522, 14, 8997, 63, 460, 63, 2573, 342, 398, 1072, 275, 291, 14, 739, 63, 1199, 8, 288, 1415, 63, 955, 6270, 32, 3954, 401, 298, 466, 2255, 267, 29688, 16, 61, 398, 367, 790, 315, 359, 288, 298, 4687, 14, 5286, 14, 890, 401, 288, 298, 4687, 14, 5286, 14, 13614, 401, 288, 298, 4687, 14, 3541, 14, 928, 63, 521, 401, 288, 298, 4687, 14, 3541, 14, 2923, 401, 288, 298, 4687, 14, 3541, 14, 2923, 63, 80, 401, 288, 298, 4687, 14, 3541, 14, 751, 401, 288, 298, 4687, 14, 3541, 14, 2253, 401, 288, 298, 4687, 14, 354, 401, 288, 298, 4687, 14, 3150, 401, 288, 298, 4687, 14, 5286, 14, 13614, 63, 80, 2, 267, 16246, 288, 702, 790, 440, 315, 1072, 199,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1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
dgellis90/nipype
nipype/interfaces/slicer/filtering/extractskeleton.py
10
2303
# -*- coding: utf8 -*- """Autogenerated file - DO NOT EDIT If you spot a bug, please report it on the mailing list and/or change the generator.""" from nipype.interfaces.base import CommandLine, CommandLineInputSpec, SEMLikeCommandLine, TraitedSpec, File, Directory, traits, isdefined, InputMultiPath, OutputMultiPath import os class ExtractSkeletonInputSpec(CommandLineInputSpec): InputImageFileName = File(position=-2, desc="Input image", exists=True, argstr="%s") OutputImageFileName = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Skeleton of the input image", argstr="%s") type = traits.Enum("1D", "2D", desc="Type of skeleton to create", argstr="--type %s") dontPrune = traits.Bool(desc="Return the full skeleton, not just the maximal skeleton", argstr="--dontPrune ") numPoints = traits.Int(desc="Number of points used to represent the skeleton", argstr="--numPoints %d") pointsFile = traits.Str(desc="Name of the file to store the coordinates of the central (1D) skeleton points", argstr="--pointsFile %s") class ExtractSkeletonOutputSpec(TraitedSpec): OutputImageFileName = File(position=-1, desc="Skeleton of the input image", exists=True) class ExtractSkeleton(SEMLikeCommandLine): """title: Extract Skeleton category: Filtering description: Extract the skeleton of a binary object. The skeleton can be limited to being a 1D curve or allowed to be a full 2D manifold. The branches of the skeleton can be pruned so that only the maximal center skeleton is returned. version: 0.1.0.$Revision: 2104 $(alpha) documentation-url: http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.1/Modules/ExtractSkeleton contributor: Pierre Seroul (UNC), Martin Styner (UNC), Guido Gerig (UNC), Stephen Aylward (Kitware) acknowledgements: The original implementation of this method was provided by ETH Zurich, Image Analysis Laboratory of Profs Olaf Kuebler, Gabor Szekely and Guido Gerig. Martin Styner at UNC, Chapel Hill made enhancements. Wrapping for Slicer was provided by Pierre Seroul and Stephen Aylward at Kitware, Inc. """ input_spec = ExtractSkeletonInputSpec output_spec = ExtractSkeletonOutputSpec _cmd = "ExtractSkeleton " _outputs_filenames = {'OutputImageFileName': 'OutputImageFileName.nii'}
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 24, 1882, 199, 624, 23570, 16741, 570, 446, 3506, 2845, 24981, 199, 3917, 1265, 23226, 282, 6519, 12, 8749, 3622, 652, 641, 314, 30939, 769, 436, 15, 269, 1570, 314, 4306, 1041, 199, 199, 504, 302, 711, 514, 14, 7436, 14, 1095, 492, 5817, 3049, 12, 5817, 3049, 3205, 5307, 12, 5795, 1698, 7455, 16926, 12, 12643, 5703, 5307, 12, 3814, 12, 15191, 12, 19692, 12, 365, 4037, 12, 6924, 3947, 2042, 12, 7242, 3947, 2042, 199, 646, 747, 421, 199, 533, 12892, 51, 415, 17589, 3205, 5307, 8, 16926, 3205, 5307, 304, 272, 6924, 3491, 7733, 275, 3814, 8, 3124, 4022, 18, 12, 4328, 628, 3205, 1834, 401, 3495, 29, 549, 12, 22494, 5961, 83, 531, 272, 7242, 3491, 7733, 275, 19692, 14, 37, 1711, 8, 17668, 14, 10349, 12, 3814, 1062, 3421, 4022, 17, 12, 2631, 63, 1725, 29, 797, 12, 4328, 628, 51, 415, 17589, 402, 314, 1324, 1834, 401, 22494, 5961, 83, 531, 272, 730, 275, 19692, 14, 5081, 480, 17, 36, 401, 298, 18, 36, 401, 4328, 628, 804, 402, 30537, 370, 1218, 401, 22494, 28953, 466, 450, 83, 531, 272, 21542, 48, 14780, 275, 19692, 14, 10349, 8, 3257, 628, 1767, 314, 2615, 30537, 12, 440, 2951, 314, 1390, 7265, 30537, 401, 22494, 28953, 18671, 48, 14780, 6099, 272, 1967, 10225, 275, 19692, 14, 3241, 8, 3257, 628, 3259, 402, 4501, 1202, 370, 2954, 314, 30537, 401, 22494, 28953, 1507, 10225, 450, 68, 531, 272, 4501, 1173, 275, 19692, 14, 2848, 8, 3257, 628, 985, 402, 314, 570, 370, 3877, 314, 8983, 402, 314, 18796, 334, 17, 36, 9, 30537, 4501, 401, 22494, 28953, 3438, 1173, 450, 83, 531, 421, 199, 533, 12892, 51, 415, 17589, 2959, 5307, 8, 2437, 5703, 5307, 304, 272, 7242, 3491, 7733, 275, 3814, 8, 3124, 4022, 17, 12, 4328, 628, 51, 415, 17589, 402, 314, 1324, 1834, 401, 3495, 29, 549, 9, 421, 199, 533, 12892, 51, 415, 17589, 8, 899, 1698, 7455, 16926, 304, 272, 408, 1213, 26, 12892, 428, 415, 17589, 199, 199, 3710, 26, 9388, 316, 199, 199, 1802, 26, 12892, 314, 30537, 402, 282, 3366, 909, 14, 221, 710, 30537, 883, 506, 13988, 370, 3769, 282, 413, 36, 15318, 503, 4370, 370, 506, 282, 2615, 499, 36, 2169, 32294, 14, 221, 710, 17347, 402, 314, 30537, 883, 506, 29501, 379, 880, 626, 1454, 314, 1390, 7265, 8126, 30537, 365, 2138, 14, 199, 199, 1023, 26, 378, 14, 17, 14, 16, 14, 4, 12714, 26, 499, 6785, 7714, 4468, 9, 199, 199, 9970, 13, 633, 26, 1455, 921, 6797, 14, 83, 27975, 14, 1308, 15, 83, 27975, 26198, 15, 1080, 14, 8624, 15, 17763, 15, 20, 14, 17, 15, 17981, 15, 12147, 51, 415, 17589, 199, 199, 16833, 26, 510, 4446, 264, 428, 3478, 348, 334, 17192, 395, 603, 26788, 428, 369, 1372, 334, 17192, 395, 598, 1535, 79, 22261, 528, 334, 17192, 395, 17854, 17579, 437, 89, 76, 3079, 334, 14591, 1068, 9, 199, 199, 564, 23504, 1470, 26, 710, 3379, 4514, 402, 642, 1083, 1990, 2741, 701, 662, 2080, 3107, 300, 1158, 12, 6047, 21916, 16871, 31671, 402, 2165, 2319, 593, 416, 70, 1804, 310, 830, 82, 12, 598, 371, 269, 428, 806, 10204, 436, 598, 1535, 79, 22261, 528, 14, 221, 603, 26788, 428, 369, 1372, 737, 738, 6389, 12, 2799, 924, 76, 869, 778, 6326, 655, 14666, 1470, 14, 221, 644, 15521, 367, 428, 27975, 1990, 2741, 701, 510, 4446, 264, 428, 3478, 348, 436, 17854, 17579, 437, 89, 76, 3079, 737, 1804, 390, 1068, 12, 3277, 14, 199, 199, 624, 339, 1324, 63, 1650, 275, 12892, 51, 415, 17589, 3205, 5307, 272, 1072, 63, 1650, 275, 12892, 51, 415, 17589, 2959, 5307, 272, 485, 1760, 275, 298, 12147, 51, 415, 17589, 298, 272, 485, 4467, 63, 10309, 275, 791, 2959, 3491, 7733, 356, 283, 2959, 3491, 7733, 14, 78, 5908, 936, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 24, 1882, 199, 624, 23570, 16741, 570, 446, 3506, 2845, 24981, 199, 3917, 1265, 23226, 282, 6519, 12, 8749, 3622, 652, 641, 314, 30939, 769, 436, 15, 269, 1570, 314, 4306, 1041, 199, 199, 504, 302, 711, 514, 14, 7436, 14, 1095, 492, 5817, 3049, 12, 5817, 3049, 3205, 5307, 12, 5795, 1698, 7455, 16926, 12, 12643, 5703, 5307, 12, 3814, 12, 15191, 12, 19692, 12, 365, 4037, 12, 6924, 3947, 2042, 12, 7242, 3947, 2042, 199, 646, 747, 421, 199, 533, 12892, 51, 415, 17589, 3205, 5307, 8, 16926, 3205, 5307, 304, 272, 6924, 3491, 7733, 275, 3814, 8, 3124, 4022, 18, 12, 4328, 628, 3205, 1834, 401, 3495, 29, 549, 12, 22494, 5961, 83, 531, 272, 7242, 3491, 7733, 275, 19692, 14, 37, 1711, 8, 17668, 14, 10349, 12, 3814, 1062, 3421, 4022, 17, 12, 2631, 63, 1725, 29, 797, 12, 4328, 628, 51, 415, 17589, 402, 314, 1324, 1834, 401, 22494, 5961, 83, 531, 272, 730, 275, 19692, 14, 5081, 480, 17, 36, 401, 298, 18, 36, 401, 4328, 628, 804, 402, 30537, 370, 1218, 401, 22494, 28953, 466, 450, 83, 531, 272, 21542, 48, 14780, 275, 19692, 14, 10349, 8, 3257, 628, 1767, 314, 2615, 30537, 12, 440, 2951, 314, 1390, 7265, 30537, 401, 22494, 28953, 18671, 48, 14780, 6099, 272, 1967, 10225, 275, 19692, 14, 3241, 8, 3257, 628, 3259, 402, 4501, 1202, 370, 2954, 314, 30537, 401, 22494, 28953, 1507, 10225, 450, 68, 531, 272, 4501, 1173, 275, 19692, 14, 2848, 8, 3257, 628, 985, 402, 314, 570, 370, 3877, 314, 8983, 402, 314, 18796, 334, 17, 36, 9, 30537, 4501, 401, 22494, 28953, 3438, 1173, 450, 83, 531, 421, 199, 533, 12892, 51, 415, 17589, 2959, 5307, 8, 2437, 5703, 5307, 304, 272, 7242, 3491, 7733, 275, 3814, 8, 3124, 4022, 17, 12, 4328, 628, 51, 415, 17589, 402, 314, 1324, 1834, 401, 3495, 29, 549, 9, 421, 199, 533, 12892, 51, 415, 17589, 8, 899, 1698, 7455, 16926, 304, 272, 408, 1213, 26, 12892, 428, 415, 17589, 199, 199, 3710, 26, 9388, 316, 199, 199, 1802, 26, 12892, 314, 30537, 402, 282, 3366, 909, 14, 221, 710, 30537, 883, 506, 13988, 370, 3769, 282, 413, 36, 15318, 503, 4370, 370, 506, 282, 2615, 499, 36, 2169, 32294, 14, 221, 710, 17347, 402, 314, 30537, 883, 506, 29501, 379, 880, 626, 1454, 314, 1390, 7265, 8126, 30537, 365, 2138, 14, 199, 199, 1023, 26, 378, 14, 17, 14, 16, 14, 4, 12714, 26, 499, 6785, 7714, 4468, 9, 199, 199, 9970, 13, 633, 26, 1455, 921, 6797, 14, 83, 27975, 14, 1308, 15, 83, 27975, 26198, 15, 1080, 14, 8624, 15, 17763, 15, 20, 14, 17, 15, 17981, 15, 12147, 51, 415, 17589, 199, 199, 16833, 26, 510, 4446, 264, 428, 3478, 348, 334, 17192, 395, 603, 26788, 428, 369, 1372, 334, 17192, 395, 598, 1535, 79, 22261, 528, 334, 17192, 395, 17854, 17579, 437, 89, 76, 3079, 334, 14591, 1068, 9, 199, 199, 564, 23504, 1470, 26, 710, 3379, 4514, 402, 642, 1083, 1990, 2741, 701, 662, 2080, 3107, 300, 1158, 12, 6047, 21916, 16871, 31671, 402, 2165, 2319, 593, 416, 70, 1804, 310, 830, 82, 12, 598, 371, 269, 428, 806, 10204, 436, 598, 1535, 79, 22261, 528, 14, 221, 603, 26788, 428, 369, 1372, 737, 738, 6389, 12, 2799, 924, 76, 869, 778, 6326, 655, 14666, 1470, 14, 221, 644, 15521, 367, 428, 27975, 1990, 2741, 701, 510, 4446, 264, 428, 3478, 348, 436, 17854, 17579, 437, 89, 76, 3079, 737, 1804, 390, 1068, 12, 3277, 14, 199, 199, 624, 339, 1324, 63, 1650, 275, 12892, 51, 415, 17589, 3205, 5307, 272, 1072, 63, 1650, 275, 12892, 51, 415, 17589, 2959, 5307, 272, 485, 1760, 275, 298, 12147, 51, 415, 17589, 298, 272, 485, 4467, 63, 10309, 275, 791, 2959, 3491, 7733, 356, 283, 2959, 3491, 7733, 14, 78, 5908, 936, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
michaelpacer/networkx
networkx/algorithms/components/tests/test_semiconnected.py
64
1901
from itertools import chain import networkx as nx from nose.tools import * class TestIsSemiconnected(object): def test_undirected(self): assert_raises(nx.NetworkXNotImplemented, nx.is_semiconnected, nx.Graph()) assert_raises(nx.NetworkXNotImplemented, nx.is_semiconnected, nx.MultiGraph()) def test_empty(self): assert_raises(nx.NetworkXPointlessConcept, nx.is_semiconnected, nx.DiGraph()) assert_raises(nx.NetworkXPointlessConcept, nx.is_semiconnected, nx.MultiDiGraph()) def test_single_node_graph(self): G = nx.DiGraph() G.add_node(0) ok_(nx.is_semiconnected(G)) def test_path(self): G = nx.path_graph(100, create_using=nx.DiGraph()) ok_(nx.is_semiconnected(G)) G.add_edge(100, 99) ok_(not nx.is_semiconnected(G)) def test_cycle(self): G = nx.cycle_graph(100, create_using=nx.DiGraph()) ok_(nx.is_semiconnected(G)) G = nx.path_graph(100, create_using=nx.DiGraph()) G.add_edge(0, 99) ok_(nx.is_semiconnected(G)) def test_tree(self): G = nx.DiGraph() G.add_edges_from(chain.from_iterable([(i, 2 * i + 1), (i, 2 * i + 2)] for i in range(100))) ok_(not nx.is_semiconnected(G)) def test_dumbbell(self): G = nx.cycle_graph(100, create_using=nx.DiGraph()) G.add_edges_from((i + 100, (i + 1) % 100 + 100) for i in range(100)) ok_(not nx.is_semiconnected(G)) # G is disconnected. G.add_edge(100, 99) ok_(nx.is_semiconnected(G)) def test_alternating_path(self): G = nx.DiGraph(chain.from_iterable([(i, i - 1), (i, i + 1)] for i in range(0, 100, 2))) ok_(not nx.is_semiconnected(G))
bsd-3-clause
[ 504, 7975, 492, 6036, 199, 646, 24313, 465, 8484, 199, 504, 11354, 14, 2537, 492, 627, 199, 199, 533, 1379, 1831, 1513, 2664, 7113, 8, 785, 304, 339, 347, 511, 63, 324, 12080, 8, 277, 304, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 14278, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 4578, 1012, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 14278, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 3947, 4578, 1012, 339, 347, 511, 63, 1667, 8, 277, 304, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 23208, 1012, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 3947, 23208, 1012, 339, 347, 511, 63, 4780, 63, 932, 63, 2180, 8, 277, 304, 267, 598, 275, 8484, 14, 23208, 342, 267, 598, 14, 525, 63, 932, 8, 16, 9, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 515, 8, 277, 304, 267, 598, 275, 8484, 14, 515, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 267, 598, 14, 525, 63, 5173, 8, 1960, 12, 8806, 9, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 7612, 8, 277, 304, 267, 598, 275, 8484, 14, 7612, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 267, 598, 275, 8484, 14, 515, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 598, 14, 525, 63, 5173, 8, 16, 12, 8806, 9, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 2350, 8, 277, 304, 267, 598, 275, 8484, 14, 23208, 342, 267, 598, 14, 525, 63, 6929, 63, 504, 8, 4429, 14, 504, 63, 8147, 7694, 73, 12, 499, 627, 284, 435, 413, 395, 334, 73, 12, 499, 627, 284, 435, 499, 1874, 6163, 367, 284, 315, 1425, 8, 1960, 1724, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 27512, 2501, 1697, 8, 277, 304, 267, 598, 275, 8484, 14, 7612, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 598, 14, 525, 63, 6929, 63, 504, 1332, 73, 435, 2948, 12, 334, 73, 435, 413, 9, 450, 2948, 435, 2948, 9, 367, 284, 315, 1425, 8, 1960, 430, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 221, 327, 598, 365, 25602, 14, 267, 598, 14, 525, 63, 5173, 8, 1960, 12, 8806, 9, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 10280, 1958, 63, 515, 8, 277, 304, 267, 598, 275, 8484, 14, 23208, 8, 4429, 14, 504, 63, 8147, 7694, 73, 12, 284, 446, 413, 395, 334, 73, 12, 284, 435, 413, 1874, 5644, 367, 284, 315, 1425, 8, 16, 12, 2948, 12, 499, 1724, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7975, 492, 6036, 199, 646, 24313, 465, 8484, 199, 504, 11354, 14, 2537, 492, 627, 199, 199, 533, 1379, 1831, 1513, 2664, 7113, 8, 785, 304, 339, 347, 511, 63, 324, 12080, 8, 277, 304, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 14278, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 4578, 1012, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 14278, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 3947, 4578, 1012, 339, 347, 511, 63, 1667, 8, 277, 304, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 23208, 1012, 267, 702, 63, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 12, 8484, 14, 374, 63, 19290, 7113, 12, 1993, 8484, 14, 3947, 23208, 1012, 339, 347, 511, 63, 4780, 63, 932, 63, 2180, 8, 277, 304, 267, 598, 275, 8484, 14, 23208, 342, 267, 598, 14, 525, 63, 932, 8, 16, 9, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 515, 8, 277, 304, 267, 598, 275, 8484, 14, 515, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 267, 598, 14, 525, 63, 5173, 8, 1960, 12, 8806, 9, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 7612, 8, 277, 304, 267, 598, 275, 8484, 14, 7612, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 267, 598, 275, 8484, 14, 515, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 598, 14, 525, 63, 5173, 8, 16, 12, 8806, 9, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 2350, 8, 277, 304, 267, 598, 275, 8484, 14, 23208, 342, 267, 598, 14, 525, 63, 6929, 63, 504, 8, 4429, 14, 504, 63, 8147, 7694, 73, 12, 499, 627, 284, 435, 413, 395, 334, 73, 12, 499, 627, 284, 435, 499, 1874, 6163, 367, 284, 315, 1425, 8, 1960, 1724, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 27512, 2501, 1697, 8, 277, 304, 267, 598, 275, 8484, 14, 7612, 63, 2180, 8, 1960, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 598, 14, 525, 63, 6929, 63, 504, 1332, 73, 435, 2948, 12, 334, 73, 435, 413, 9, 450, 2948, 435, 2948, 9, 367, 284, 315, 1425, 8, 1960, 430, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 221, 327, 598, 365, 25602, 14, 267, 598, 14, 525, 63, 5173, 8, 1960, 12, 8806, 9, 267, 4112, 2531, 7343, 14, 374, 63, 19290, 7113, 8, 39, 430, 339, 347, 511, 63, 10280, 1958, 63, 515, 8, 277, 304, 267, 598, 275, 8484, 14, 23208, 8, 4429, 14, 504, 63, 8147, 7694, 73, 12, 284, 446, 413, 395, 334, 73, 12, 284, 435, 413, 1874, 5644, 367, 284, 315, 1425, 8, 16, 12, 2948, 12, 499, 1724, 267, 4112, 2531, 1397, 8484, 14, 374, 63, 19290, 7113, 8, 39, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
foss-transportationmodeling/rettina-server
flask/local/lib/python2.7/site-packages/jinja2/testsuite/inheritance.py
414
8248
# -*- coding: utf-8 -*- """ jinja2.testsuite.inheritance ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tests the template inheritance feature. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ import unittest from jinja2.testsuite import JinjaTestCase from jinja2 import Environment, DictLoader, TemplateError LAYOUTTEMPLATE = '''\ |{% block block1 %}block 1 from layout{% endblock %} |{% block block2 %}block 2 from layout{% endblock %} |{% block block3 %} {% block block4 %}nested block 4 from layout{% endblock %} {% endblock %}|''' LEVEL1TEMPLATE = '''\ {% extends "layout" %} {% block block1 %}block 1 from level1{% endblock %}''' LEVEL2TEMPLATE = '''\ {% extends "level1" %} {% block block2 %}{% block block5 %}nested block 5 from level2{% endblock %}{% endblock %}''' LEVEL3TEMPLATE = '''\ {% extends "level2" %} {% block block5 %}block 5 from level3{% endblock %} {% block block4 %}block 4 from level3{% endblock %} ''' LEVEL4TEMPLATE = '''\ {% extends "level3" %} {% block block3 %}block 3 from level4{% endblock %} ''' WORKINGTEMPLATE = '''\ {% extends "layout" %} {% block block1 %} {% if false %} {% block block2 %} this should workd {% endblock %} {% endif %} {% endblock %} ''' DOUBLEEXTENDS = '''\ {% extends "layout" %} {% extends "layout" %} {% block block1 %} {% if false %} {% block block2 %} this should workd {% endblock %} {% endif %} {% endblock %} ''' env = Environment(loader=DictLoader({ 'layout': LAYOUTTEMPLATE, 'level1': LEVEL1TEMPLATE, 'level2': LEVEL2TEMPLATE, 'level3': LEVEL3TEMPLATE, 'level4': LEVEL4TEMPLATE, 'working': WORKINGTEMPLATE, 'doublee': DOUBLEEXTENDS, }), trim_blocks=True) class InheritanceTestCase(JinjaTestCase): def test_layout(self): tmpl = env.get_template('layout') assert tmpl.render() == ('|block 1 from layout|block 2 from ' 'layout|nested block 4 from layout|') def test_level1(self): tmpl = env.get_template('level1') assert tmpl.render() == ('|block 1 from level1|block 2 from ' 'layout|nested block 4 from layout|') def test_level2(self): tmpl = env.get_template('level2') assert tmpl.render() == ('|block 1 from level1|nested block 5 from ' 'level2|nested block 4 from layout|') def test_level3(self): tmpl = env.get_template('level3') assert tmpl.render() == ('|block 1 from level1|block 5 from level3|' 'block 4 from level3|') def test_level4(sel): tmpl = env.get_template('level4') assert tmpl.render() == ('|block 1 from level1|block 5 from ' 'level3|block 3 from level4|') def test_super(self): env = Environment(loader=DictLoader({ 'a': '{% block intro %}INTRO{% endblock %}|' 'BEFORE|{% block data %}INNER{% endblock %}|AFTER', 'b': '{% extends "a" %}{% block data %}({{ ' 'super() }}){% endblock %}', 'c': '{% extends "b" %}{% block intro %}--{{ ' 'super() }}--{% endblock %}\n{% block data ' '%}[{{ super() }}]{% endblock %}' })) tmpl = env.get_template('c') assert tmpl.render() == '--INTRO--|BEFORE|[(INNER)]|AFTER' def test_working(self): tmpl = env.get_template('working') def test_reuse_blocks(self): tmpl = env.from_string('{{ self.foo() }}|{% block foo %}42' '{% endblock %}|{{ self.foo() }}') assert tmpl.render() == '42|42|42' def test_preserve_blocks(self): env = Environment(loader=DictLoader({ 'a': '{% if false %}{% block x %}A{% endblock %}{% endif %}{{ self.x() }}', 'b': '{% extends "a" %}{% block x %}B{{ super() }}{% endblock %}' })) tmpl = env.get_template('b') assert tmpl.render() == 'BA' def test_dynamic_inheritance(self): env = Environment(loader=DictLoader({ 'master1': 'MASTER1{% block x %}{% endblock %}', 'master2': 'MASTER2{% block x %}{% endblock %}', 'child': '{% extends master %}{% block x %}CHILD{% endblock %}' })) tmpl = env.get_template('child') for m in range(1, 3): assert tmpl.render(master='master%d' % m) == 'MASTER%dCHILD' % m def test_multi_inheritance(self): env = Environment(loader=DictLoader({ 'master1': 'MASTER1{% block x %}{% endblock %}', 'master2': 'MASTER2{% block x %}{% endblock %}', 'child': '''{% if master %}{% extends master %}{% else %}{% extends 'master1' %}{% endif %}{% block x %}CHILD{% endblock %}''' })) tmpl = env.get_template('child') assert tmpl.render(master='master2') == 'MASTER2CHILD' assert tmpl.render(master='master1') == 'MASTER1CHILD' assert tmpl.render() == 'MASTER1CHILD' def test_scoped_block(self): env = Environment(loader=DictLoader({ 'master.html': '{% for item in seq %}[{% block item scoped %}' '{% endblock %}]{% endfor %}' })) t = env.from_string('{% extends "master.html" %}{% block item %}' '{{ item }}{% endblock %}') assert t.render(seq=list(range(5))) == '[0][1][2][3][4]' def test_super_in_scoped_block(self): env = Environment(loader=DictLoader({ 'master.html': '{% for item in seq %}[{% block item scoped %}' '{{ item }}{% endblock %}]{% endfor %}' })) t = env.from_string('{% extends "master.html" %}{% block item %}' '{{ super() }}|{{ item * 2 }}{% endblock %}') assert t.render(seq=list(range(5))) == '[0|0][1|2][2|4][3|6][4|8]' def test_scoped_block_after_inheritance(self): env = Environment(loader=DictLoader({ 'layout.html': ''' {% block useless %}{% endblock %} ''', 'index.html': ''' {%- extends 'layout.html' %} {% from 'helpers.html' import foo with context %} {% block useless %} {% for x in [1, 2, 3] %} {% block testing scoped %} {{ foo(x) }} {% endblock %} {% endfor %} {% endblock %} ''', 'helpers.html': ''' {% macro foo(x) %}{{ the_foo + x }}{% endmacro %} ''' })) rv = env.get_template('index.html').render(the_foo=42).split() assert rv == ['43', '44', '45'] class BugFixTestCase(JinjaTestCase): def test_fixed_macro_scoping_bug(self): assert Environment(loader=DictLoader({ 'test.html': '''\ {% extends 'details.html' %} {% macro my_macro() %} my_macro {% endmacro %} {% block inner_box %} {{ my_macro() }} {% endblock %} ''', 'details.html': '''\ {% extends 'standard.html' %} {% macro my_macro() %} my_macro {% endmacro %} {% block content %} {% block outer_box %} outer_box {% block inner_box %} inner_box {% endblock %} {% endblock %} {% endblock %} ''', 'standard.html': ''' {% block content %}&nbsp;{% endblock %} ''' })).get_template("test.html").render().split() == [u'outer_box', u'my_macro'] def test_double_extends(self): """Ensures that a template with more than 1 {% extends ... %} usage raises a ``TemplateError``. """ try: tmpl = env.get_template('doublee') except Exception as e: assert isinstance(e, TemplateError) def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(InheritanceTestCase)) suite.addTest(unittest.makeSuite(BugFixTestCase)) return suite
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 14239, 14, 13136, 272, 18294, 22935, 339, 6496, 314, 1978, 15433, 3878, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 2882, 199, 199, 504, 10321, 18, 14, 14239, 492, 17300, 1746, 199, 199, 504, 10321, 18, 492, 9711, 12, 7448, 5455, 12, 5458, 547, 421, 199, 16897, 1877, 7433, 275, 18087, 199, 92, 3996, 1853, 1853, 17, 3674, 1457, 413, 687, 7054, 3996, 21525, 3674, 199, 92, 3996, 1853, 1853, 18, 3674, 1457, 499, 687, 7054, 3996, 21525, 3674, 199, 92, 3996, 1853, 1853, 19, 3674, 199, 3996, 1853, 1853, 20, 3674, 6376, 1853, 841, 687, 7054, 3996, 21525, 3674, 199, 3996, 21525, 3674, 92, 2344, 199, 199, 11817, 17, 7433, 275, 18087, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 1853, 1853, 17, 3674, 1457, 413, 687, 2166, 17, 3996, 21525, 3674, 2344, 199, 199, 11817, 18, 7433, 275, 18087, 199, 3996, 16879, 298, 1896, 17, 2, 3674, 199, 3996, 1853, 1853, 18, 12760, 1853, 1853, 21, 3674, 6376, 1853, 959, 687, 2166, 18, 3996, 199, 500, 1457, 12760, 21525, 3674, 2344, 199, 199, 11817, 19, 7433, 275, 18087, 199, 3996, 16879, 298, 1896, 18, 2, 3674, 199, 3996, 1853, 1853, 21, 3674, 1457, 959, 687, 2166, 19, 3996, 21525, 3674, 199, 3996, 1853, 1853, 20, 3674, 1457, 841, 687, 2166, 19, 3996, 21525, 3674, 199, 2344, 199, 199, 11817, 20, 7433, 275, 18087, 199, 3996, 16879, 298, 1896, 19, 2, 3674, 199, 3996, 1853, 1853, 19, 3674, 1457, 650, 687, 2166, 20, 3996, 21525, 3674, 199, 2344, 199, 199, 8406, 1206, 7433, 275, 18087, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 1853, 1853, 17, 3674, 523, 7749, 340, 3055, 3674, 272, 7749, 1853, 1853, 18, 3674, 489, 642, 1077, 1736, 68, 272, 7749, 21525, 3674, 523, 7749, 14454, 3674, 199, 3996, 21525, 3674, 199, 2344, 199, 199, 14989, 12770, 3177, 275, 18087, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 1853, 1853, 17, 3674, 523, 7749, 340, 3055, 3674, 272, 7749, 1853, 1853, 18, 3674, 489, 642, 1077, 1736, 68, 272, 7749, 21525, 3674, 523, 7749, 14454, 3674, 199, 3996, 21525, 3674, 199, 2344, 421, 199, 1813, 275, 9711, 8, 3422, 29, 2141, 5455, 2561, 272, 283, 4209, 356, 755, 491, 3448, 1877, 7433, 12, 272, 283, 1896, 17, 356, 755, 6124, 10429, 17, 7433, 12, 272, 283, 1896, 18, 356, 755, 6124, 10429, 18, 7433, 12, 272, 283, 1896, 19, 356, 755, 6124, 10429, 19, 7433, 12, 272, 283, 1896, 20, 356, 755, 6124, 10429, 20, 7433, 12, 272, 283, 9818, 356, 420, 29557, 43, 1206, 7433, 12, 272, 283, 3157, 69, 356, 420, 5681, 12770, 3177, 12, 199, 8688, 11639, 63, 4166, 29, 549, 9, 421, 199, 533, 27502, 554, 1746, 8, 42, 4135, 1746, 304, 339, 347, 511, 63, 4209, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 4209, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 7054, 92, 1457, 499, 687, 283, 639, 283, 4209, 92, 6376, 1853, 841, 687, 7054, 92, 358, 339, 347, 511, 63, 1896, 17, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 17, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 1457, 499, 687, 283, 639, 283, 4209, 92, 6376, 1853, 841, 687, 7054, 92, 358, 339, 347, 511, 63, 1896, 18, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 18, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 6376, 1853, 959, 687, 283, 639, 283, 1896, 18, 92, 6376, 1853, 841, 687, 7054, 92, 358, 339, 347, 511, 63, 1896, 19, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 19, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 1457, 959, 687, 2166, 19, 5227, 639, 283, 1457, 841, 687, 2166, 19, 92, 358, 339, 347, 511, 63, 1896, 20, 8, 5891, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 20, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 1457, 959, 687, 283, 639, 283, 1896, 19, 92, 1457, 650, 687, 2166, 20, 92, 358, 339, 347, 511, 63, 4792, 8, 277, 304, 267, 2589, 275, 9711, 8, 3422, 29, 2141, 5455, 2561, 288, 283, 65, 356, 12100, 1853, 13318, 3674, 2919, 1092, 3996, 21525, 3674, 5227, 326, 283, 31481, 92, 3996, 1853, 666, 3674, 31031, 3996, 21525, 3674, 92, 31883, 297, 288, 283, 66, 356, 12100, 16879, 298, 65, 2, 12760, 1853, 666, 3674, 2561, 91, 283, 326, 283, 4792, 342, 789, 1552, 3996, 21525, 21610, 288, 283, 67, 356, 12100, 16879, 298, 66, 2, 12760, 1853, 13318, 3674, 306, 3638, 283, 326, 283, 4792, 342, 3586, 306, 3996, 21525, 3674, 60, 78, 3996, 1853, 666, 283, 326, 1543, 22857, 3638, 1613, 342, 3586, 61, 3996, 21525, 25509, 267, 23451, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 67, 358, 267, 702, 9675, 14, 3352, 342, 508, 2850, 2919, 1092, 306, 92, 31481, 92, 7528, 31031, 1874, 92, 31883, 7, 339, 347, 511, 63, 9818, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 9818, 358, 339, 347, 511, 63, 15712, 63, 4166, 8, 277, 304, 267, 9675, 275, 2589, 14, 504, 63, 875, 18976, 291, 14, 1421, 342, 3586, 92, 3996, 1853, 3925, 3674, 2260, 7, 3044, 12100, 21525, 3674, 92, 3638, 291, 14, 1421, 342, 28404, 267, 702, 9675, 14, 3352, 342, 508, 283, 2260, 92, 2260, 92, 2260, 7, 339, 347, 511, 63, 17053, 63, 4166, 8, 277, 304, 267, 2589, 275, 9711, 8, 3422, 29, 2141, 5455, 2561, 288, 283, 65, 356, 12100, 340, 3055, 12760, 1853, 671, 3674, 33, 3996, 21525, 12760, 14454, 17337, 291, 14, 88, 342, 23688, 288, 283, 66, 356, 12100, 16879, 298, 65 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 14239, 14, 13136, 272, 18294, 22935, 339, 6496, 314, 1978, 15433, 3878, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 2882, 199, 199, 504, 10321, 18, 14, 14239, 492, 17300, 1746, 199, 199, 504, 10321, 18, 492, 9711, 12, 7448, 5455, 12, 5458, 547, 421, 199, 16897, 1877, 7433, 275, 18087, 199, 92, 3996, 1853, 1853, 17, 3674, 1457, 413, 687, 7054, 3996, 21525, 3674, 199, 92, 3996, 1853, 1853, 18, 3674, 1457, 499, 687, 7054, 3996, 21525, 3674, 199, 92, 3996, 1853, 1853, 19, 3674, 199, 3996, 1853, 1853, 20, 3674, 6376, 1853, 841, 687, 7054, 3996, 21525, 3674, 199, 3996, 21525, 3674, 92, 2344, 199, 199, 11817, 17, 7433, 275, 18087, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 1853, 1853, 17, 3674, 1457, 413, 687, 2166, 17, 3996, 21525, 3674, 2344, 199, 199, 11817, 18, 7433, 275, 18087, 199, 3996, 16879, 298, 1896, 17, 2, 3674, 199, 3996, 1853, 1853, 18, 12760, 1853, 1853, 21, 3674, 6376, 1853, 959, 687, 2166, 18, 3996, 199, 500, 1457, 12760, 21525, 3674, 2344, 199, 199, 11817, 19, 7433, 275, 18087, 199, 3996, 16879, 298, 1896, 18, 2, 3674, 199, 3996, 1853, 1853, 21, 3674, 1457, 959, 687, 2166, 19, 3996, 21525, 3674, 199, 3996, 1853, 1853, 20, 3674, 1457, 841, 687, 2166, 19, 3996, 21525, 3674, 199, 2344, 199, 199, 11817, 20, 7433, 275, 18087, 199, 3996, 16879, 298, 1896, 19, 2, 3674, 199, 3996, 1853, 1853, 19, 3674, 1457, 650, 687, 2166, 20, 3996, 21525, 3674, 199, 2344, 199, 199, 8406, 1206, 7433, 275, 18087, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 1853, 1853, 17, 3674, 523, 7749, 340, 3055, 3674, 272, 7749, 1853, 1853, 18, 3674, 489, 642, 1077, 1736, 68, 272, 7749, 21525, 3674, 523, 7749, 14454, 3674, 199, 3996, 21525, 3674, 199, 2344, 199, 199, 14989, 12770, 3177, 275, 18087, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 16879, 298, 4209, 2, 3674, 199, 3996, 1853, 1853, 17, 3674, 523, 7749, 340, 3055, 3674, 272, 7749, 1853, 1853, 18, 3674, 489, 642, 1077, 1736, 68, 272, 7749, 21525, 3674, 523, 7749, 14454, 3674, 199, 3996, 21525, 3674, 199, 2344, 421, 199, 1813, 275, 9711, 8, 3422, 29, 2141, 5455, 2561, 272, 283, 4209, 356, 755, 491, 3448, 1877, 7433, 12, 272, 283, 1896, 17, 356, 755, 6124, 10429, 17, 7433, 12, 272, 283, 1896, 18, 356, 755, 6124, 10429, 18, 7433, 12, 272, 283, 1896, 19, 356, 755, 6124, 10429, 19, 7433, 12, 272, 283, 1896, 20, 356, 755, 6124, 10429, 20, 7433, 12, 272, 283, 9818, 356, 420, 29557, 43, 1206, 7433, 12, 272, 283, 3157, 69, 356, 420, 5681, 12770, 3177, 12, 199, 8688, 11639, 63, 4166, 29, 549, 9, 421, 199, 533, 27502, 554, 1746, 8, 42, 4135, 1746, 304, 339, 347, 511, 63, 4209, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 4209, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 7054, 92, 1457, 499, 687, 283, 639, 283, 4209, 92, 6376, 1853, 841, 687, 7054, 92, 358, 339, 347, 511, 63, 1896, 17, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 17, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 1457, 499, 687, 283, 639, 283, 4209, 92, 6376, 1853, 841, 687, 7054, 92, 358, 339, 347, 511, 63, 1896, 18, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 18, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 6376, 1853, 959, 687, 283, 639, 283, 1896, 18, 92, 6376, 1853, 841, 687, 7054, 92, 358, 339, 347, 511, 63, 1896, 19, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 19, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 1457, 959, 687, 2166, 19, 5227, 639, 283, 1457, 841, 687, 2166, 19, 92, 358, 339, 347, 511, 63, 1896, 20, 8, 5891, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 1896, 20, 358, 267, 702, 9675, 14, 3352, 342, 508, 661, 92, 1457, 413, 687, 2166, 17, 92, 1457, 959, 687, 283, 639, 283, 1896, 19, 92, 1457, 650, 687, 2166, 20, 92, 358, 339, 347, 511, 63, 4792, 8, 277, 304, 267, 2589, 275, 9711, 8, 3422, 29, 2141, 5455, 2561, 288, 283, 65, 356, 12100, 1853, 13318, 3674, 2919, 1092, 3996, 21525, 3674, 5227, 326, 283, 31481, 92, 3996, 1853, 666, 3674, 31031, 3996, 21525, 3674, 92, 31883, 297, 288, 283, 66, 356, 12100, 16879, 298, 65, 2, 12760, 1853, 666, 3674, 2561, 91, 283, 326, 283, 4792, 342, 789, 1552, 3996, 21525, 21610, 288, 283, 67, 356, 12100, 16879, 298, 66, 2, 12760, 1853, 13318, 3674, 306, 3638, 283, 326, 283, 4792, 342, 3586, 306, 3996, 21525, 3674, 60, 78, 3996, 1853, 666, 283, 326, 1543, 22857, 3638, 1613, 342, 3586, 61, 3996, 21525, 25509, 267, 23451, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 67, 358, 267, 702, 9675, 14, 3352, 342, 508, 2850, 2919, 1092, 306, 92, 31481, 92, 7528, 31031, 1874, 92, 31883, 7, 339, 347, 511, 63, 9818, 8, 277, 304, 267, 9675, 275, 2589, 14, 362, 63, 1160, 360, 9818, 358, 339, 347, 511, 63, 15712, 63, 4166, 8, 277, 304, 267, 9675, 275, 2589, 14, 504, 63, 875, 18976, 291, 14, 1421, 342, 3586, 92, 3996, 1853, 3925, 3674, 2260, 7, 3044, 12100, 21525, 3674, 92, 3638, 291, 14, 1421, 342, 28404, 267, 702, 9675, 14, 3352, 342, 508, 283, 2260, 92, 2260, 92, 2260, 7, 339, 347, 511, 63, 17053, 63, 4166, 8, 277, 304, 267, 2589, 275, 9711, 8, 3422, 29, 2141, 5455, 2561, 288, 283, 65, 356, 12100, 340, 3055, 12760, 1853, 671, 3674, 33, 3996, 21525, 12760, 14454, 17337, 291, 14, 88, 342, 23688, 288, 283, 66, 356, 12100, 16879, 298, 65, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
goddardl/cortex
python/IECoreRI/__init__.py
7
1918
########################################################################## # # Copyright (c) 2007, Image Engine Design 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 Image Engine Design nor the names of any # other contributors to this software 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. # ########################################################################## from _IECoreRI import * from ExecuteProcedural import executeProcedural from MakeRibOp import MakeRibOp from TestCase import TestCase
bsd-3-clause
[ 26863, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 10219, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 258, 627, 11443, 314, 536, 402, 6047, 12580, 29410, 6590, 314, 1561, 402, 1263, 199, 3, 755, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 755, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 755, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 504, 485, 41, 13682, 6129, 492, 627, 199, 504, 17009, 919, 6867, 4889, 492, 5341, 919, 6867, 4889, 199, 504, 4155, 50, 1892, 4619, 492, 4155, 50, 1892, 4619, 199, 504, 7640, 492, 7640, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 199, 3, 221, 1898, 334, 67, 9, 10219, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 258, 627, 11443, 314, 536, 402, 6047, 12580, 29410, 6590, 314, 1561, 402, 1263, 199, 3, 755, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 755, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 755, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 504, 485, 41, 13682, 6129, 492, 627, 199, 504, 17009, 919, 6867, 4889, 492, 5341, 919, 6867, 4889, 199, 504, 4155, 50, 1892, 4619, 492, 4155, 50, 1892, 4619, 199, 504, 7640, 492, 7640, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cvium/Flexget
tests/test_api.py
2
7511
import json import os from mock import patch from flexget import __version__ from flexget.api import app, __version__ as __api_version__ from flexget.manager import Manager from flexget.utils.database import with_session from flexget.webserver import User from tests import FlexGetBase, MockManager @with_session def api_key(session=None): user = session.query(User).first() if not user: user = User(name='flexget', password='flexget') session.add(user) session.commit() return user.token def append_header(key, value, kwargs): if 'headers' not in kwargs: kwargs['headers'] = {} kwargs['headers'][key] = value class APITest(FlexGetBase): def __init__(self): self.client = app.test_client() FlexGetBase.__init__(self) def json_post(self, *args, **kwargs): append_header('Content-Type', 'application/json', kwargs) if kwargs.get('auth', True): append_header('Authorization', 'Token %s' % api_key(), kwargs) return self.client.post(*args, **kwargs) def json_put(self, *args, **kwargs): append_header('Content-Type', 'application/json', kwargs) if kwargs.get('auth', True): append_header('Authorization', 'Token %s' % api_key(), kwargs) return self.client.put(*args, **kwargs) def get(self, *args, **kwargs): if kwargs.get('auth', True): append_header('Authorization', 'Token %s' % api_key(), kwargs) return self.client.get(*args, **kwargs) def delete(self, *args, **kwargs): if kwargs.get('auth', True): append_header('Authorization', 'Token %s' % api_key(), kwargs) return self.client.delete(*args, **kwargs) class TestValidator(APITest): def test_invalid_payload(self): new_task = { 'name': 'new_task', 'config': { 'invalid_plugin': [{'title': 'entry 1'}], 'fake_plugin2': {'url': 'http://test/rss'} } } rsp = self.json_post('/tasks/', data=json.dumps(new_task)) assert rsp.status_code == 400 data = json.loads(rsp.data) assert data.get('code') == 400 assert data.get('message') == 'validation error' assert data.get('validation_errors') assert 'The keys' in data['validation_errors'][0]['message'] assert 'invalid_plugin' in data['validation_errors'][0]['message'] assert 'fake_plugin2' in data['validation_errors'][0]['message'] class TestServerAPI(APITest): __yaml__ = """ tasks: test: rss: url: http://test/rss mock: - title: entry 1 """ def test_pid(self): rsp = self.get('/server/pid/', headers={}) assert rsp.status_code == 200 assert json.loads(rsp.data) == {'pid': os.getpid()} @patch.object(MockManager, 'load_config') def test_reload(self, mocked_load_config): rsp = self.get('/server/reload/') assert rsp.status_code == 200 assert mocked_load_config.called @patch.object(Manager, 'shutdown') def test_shutdown(self, mocked_shutdown): self.get('/server/shutdown/') assert mocked_shutdown.called def test_get_config(self): rsp = self.get('/server/config/') assert rsp.status_code == 200 assert json.loads(rsp.data) == { 'tasks': { 'test': { 'mock': [{'title': 'entry 1'}], 'rss': {'url': 'http://test/rss'} } } } def test_version(self): rsp = self.get('/server/version/') assert rsp.status_code == 200 assert json.loads(rsp.data) == {'flexget_version': __version__, 'api_version': __api_version__} class TestTaskAPI(APITest): __yaml__ = """ tasks: test: rss: url: http://test/rss mock: - title: entry 1 """ def test_list_tasks(self): rsp = self.get('/tasks/') data = json.loads(rsp.data) assert data == { 'tasks': [ { 'name': 'test', 'config': { 'mock': [{'title': 'entry 1'}], 'rss': {'url': 'http://test/rss'} }, } ] } @patch.object(Manager, 'save_config') def test_add_task(self, mocked_save_config): new_task = { 'name': 'new_task', 'config': { 'mock': [{'title': 'entry 1'}], 'rss': {'url': 'http://test/rss'} } } rsp = self.json_post('/tasks/', data=json.dumps(new_task)) assert rsp.status_code == 201 assert mocked_save_config.called assert json.loads(rsp.data) == new_task assert self.manager.user_config['tasks']['new_task'] == new_task['config'] assert self.manager.config['tasks']['new_task'] == new_task['config'] def test_add_task_existing(self): new_task = { 'name': 'test', 'config': { 'mock': [{'title': 'entry 1'}] } } rsp = self.json_post('/tasks/', data=json.dumps(new_task)) assert rsp.status_code == 409 def test_get_task(self): rsp = self.get('/tasks/test/') data = json.loads(rsp.data) assert data == { 'name': 'test', 'config': { 'mock': [{'title': 'entry 1'}], 'rss': {'url': 'http://test/rss'} }, } @patch.object(Manager, 'save_config') def test_update_task(self, mocked_save_config): updated_task = { 'name': 'test', 'config': { 'mock': [{'title': 'entry 1'}], 'rss': {'url': 'http://newurl/rss'} } } rsp = self.json_put('/tasks/test/', data=json.dumps(updated_task)) assert rsp.status_code == 200 assert mocked_save_config.called assert json.loads(rsp.data) == updated_task assert self.manager.user_config['tasks']['test'] == updated_task['config'] assert self.manager.config['tasks']['test'] == updated_task['config'] @patch.object(Manager, 'save_config') def test_rename_task(self, mocked_save_config): updated_task = { 'name': 'new_test', 'config': { 'mock': [{'title': 'entry 1'}], 'rss': {'url': 'http://newurl/rss'} } } rsp = self.json_put('/tasks/test/', data=json.dumps(updated_task)) assert rsp.status_code == 201 assert mocked_save_config.called assert json.loads(rsp.data) == updated_task assert 'test' not in self.manager.user_config['tasks'] assert 'test' not in self.manager.config['tasks'] assert self.manager.user_config['tasks']['new_test'] == updated_task['config'] assert self.manager.config['tasks']['new_test'] == updated_task['config'] @patch.object(Manager, 'save_config') def test_delete_task(self, mocked_save_config): rsp = self.delete('/tasks/test/') assert rsp.status_code == 200 assert mocked_save_config.called assert 'test' not in self.manager.user_config['tasks'] assert 'test' not in self.manager.config['tasks'] # TODO: Finish tests
mit
[ 646, 2022, 199, 199, 646, 747, 199, 199, 504, 1683, 492, 3371, 199, 199, 504, 20758, 362, 492, 636, 1023, 363, 199, 504, 20758, 362, 14, 1246, 492, 1145, 12, 636, 1023, 363, 465, 636, 1246, 63, 1023, 363, 199, 504, 20758, 362, 14, 2609, 492, 13537, 199, 504, 20758, 362, 14, 1208, 14, 4659, 492, 543, 63, 1730, 199, 504, 20758, 362, 14, 29819, 492, 2876, 199, 504, 2295, 492, 481, 3113, 1002, 1563, 12, 4420, 2988, 421, 199, 32, 1045, 63, 1730, 199, 318, 2986, 63, 498, 8, 1730, 29, 403, 304, 272, 922, 275, 2351, 14, 1131, 8, 1899, 680, 2246, 342, 272, 340, 440, 922, 26, 267, 922, 275, 2876, 8, 354, 534, 14759, 362, 297, 2505, 534, 14759, 362, 358, 267, 2351, 14, 525, 8, 751, 9, 267, 2351, 14, 3543, 342, 339, 372, 922, 14, 1418, 421, 199, 318, 5666, 63, 1291, 8, 498, 12, 574, 12, 2074, 304, 272, 340, 283, 2139, 7, 440, 315, 2074, 26, 267, 2074, 459, 2139, 418, 275, 1052, 339, 2074, 459, 2139, 3488, 498, 61, 275, 574, 421, 199, 533, 10319, 649, 597, 8, 38, 3113, 1002, 1563, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1258, 275, 1145, 14, 396, 63, 1258, 342, 267, 481, 3113, 1002, 1563, 855, 826, 721, 277, 9, 339, 347, 2022, 63, 1932, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 5666, 63, 1291, 360, 2714, 13, 804, 297, 283, 3578, 15, 1001, 297, 2074, 9, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 267, 372, 291, 14, 1258, 14, 1932, 2031, 589, 12, 1011, 958, 9, 339, 347, 2022, 63, 524, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 5666, 63, 1291, 360, 2714, 13, 804, 297, 283, 3578, 15, 1001, 297, 2074, 9, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 267, 372, 291, 14, 1258, 14, 524, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 398, 372, 291, 14, 1258, 14, 362, 2031, 589, 12, 1011, 958, 9, 339, 347, 3145, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 398, 372, 291, 14, 1258, 14, 1807, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 1379, 8640, 8, 2642, 597, 304, 339, 347, 511, 63, 3197, 63, 4749, 8, 277, 304, 267, 892, 63, 1765, 275, 469, 288, 283, 354, 356, 283, 1222, 63, 1765, 297, 288, 283, 888, 356, 469, 355, 283, 3197, 63, 2718, 356, 9016, 1213, 356, 283, 2373, 413, 24371, 355, 283, 3183, 63, 2718, 18, 356, 791, 633, 356, 283, 1014, 921, 396, 15, 13614, 936, 288, 789, 267, 789, 398, 13684, 275, 291, 14, 1001, 63, 1932, 2336, 5054, 3678, 666, 29, 1001, 14, 4180, 8, 1222, 63, 1765, 430, 398, 702, 13684, 14, 1205, 63, 600, 508, 8290, 267, 666, 275, 2022, 14, 3640, 8, 15642, 14, 576, 9, 267, 702, 666, 14, 362, 360, 600, 358, 508, 8290, 267, 702, 666, 14, 362, 360, 1188, 358, 508, 283, 6136, 1125, 7, 267, 702, 666, 14, 362, 360, 6136, 63, 2550, 358, 267, 702, 283, 1918, 2883, 7, 315, 666, 459, 6136, 63, 2550, 3488, 16, 2733, 1188, 418, 267, 702, 283, 3197, 63, 2718, 7, 315, 666, 459, 6136, 63, 2550, 3488, 16, 2733, 1188, 418, 267, 702, 283, 3183, 63, 2718, 18, 7, 315, 666, 459, 6136, 63, 2550, 3488, 16, 2733, 1188, 418, 421, 199, 533, 1379, 3120, 3735, 8, 2642, 597, 304, 272, 636, 5963, 363, 275, 408, 267, 6527, 26, 881, 511, 26, 288, 32291, 26, 1598, 1166, 26, 1455, 921, 396, 15, 13614, 288, 1683, 26, 1598, 446, 2538, 26, 2397, 413, 267, 408, 339, 347, 511, 63, 3150, 8, 277, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 3150, 3678, 2323, 21146, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 2022, 14, 3640, 8, 15642, 14, 576, 9, 508, 791, 3150, 356, 747, 14, 17829, 12737, 339, 768, 2068, 14, 785, 8, 3346, 2988, 12, 283, 912, 63, 888, 358, 272, 347, 511, 63, 9233, 8, 277, 12, 16991, 63, 912, 63, 888, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 9233, 6217, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 16991, 63, 912, 63, 888, 14, 3527, 339, 768, 2068, 14, 785, 8, 2988, 12, 283, 8831, 358, 272, 347, 511, 63, 8831, 8, 277, 12, 16991, 63, 8831, 304, 267, 291, 14, 362, 2336, 1000, 15, 8831, 6217, 267, 702, 16991, 63, 8831, 14, 3527, 339, 347, 511, 63, 362, 63, 888, 8, 277, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 888, 6217, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 2022, 14, 3640, 8, 15642, 14, 576, 9, 508, 469, 288, 283, 5054, 356, 469, 355, 283, 396, 356, 469, 490, 283, 1805, 356, 9016, 1213, 356, 283, 2373, 413, 24371, 490, 283, 13614, 356, 791, 633, 356, 283, 1014, 921, 396, 15, 13614, 936, 355, 789, 288, 789, 267, 789, 339, 347, 511, 63, 1023, 8, 277, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 1023, 6217, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 2022, 14, 3640, 8, 15642, 14, 576, 9, 508, 791, 14759, 362, 63, 1023, 356, 636, 1023, 3108, 283, 1246, 63, 1023, 356, 636, 1246, 63, 1023, 363, 93, 421, 199, 533, 1379, 4476, 3735, 8, 2642, 597, 304, 272, 636, 5963, 363, 275, 408, 267, 6527, 26, 881, 511 ]
[ 2022, 199, 199, 646, 747, 199, 199, 504, 1683, 492, 3371, 199, 199, 504, 20758, 362, 492, 636, 1023, 363, 199, 504, 20758, 362, 14, 1246, 492, 1145, 12, 636, 1023, 363, 465, 636, 1246, 63, 1023, 363, 199, 504, 20758, 362, 14, 2609, 492, 13537, 199, 504, 20758, 362, 14, 1208, 14, 4659, 492, 543, 63, 1730, 199, 504, 20758, 362, 14, 29819, 492, 2876, 199, 504, 2295, 492, 481, 3113, 1002, 1563, 12, 4420, 2988, 421, 199, 32, 1045, 63, 1730, 199, 318, 2986, 63, 498, 8, 1730, 29, 403, 304, 272, 922, 275, 2351, 14, 1131, 8, 1899, 680, 2246, 342, 272, 340, 440, 922, 26, 267, 922, 275, 2876, 8, 354, 534, 14759, 362, 297, 2505, 534, 14759, 362, 358, 267, 2351, 14, 525, 8, 751, 9, 267, 2351, 14, 3543, 342, 339, 372, 922, 14, 1418, 421, 199, 318, 5666, 63, 1291, 8, 498, 12, 574, 12, 2074, 304, 272, 340, 283, 2139, 7, 440, 315, 2074, 26, 267, 2074, 459, 2139, 418, 275, 1052, 339, 2074, 459, 2139, 3488, 498, 61, 275, 574, 421, 199, 533, 10319, 649, 597, 8, 38, 3113, 1002, 1563, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1258, 275, 1145, 14, 396, 63, 1258, 342, 267, 481, 3113, 1002, 1563, 855, 826, 721, 277, 9, 339, 347, 2022, 63, 1932, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 5666, 63, 1291, 360, 2714, 13, 804, 297, 283, 3578, 15, 1001, 297, 2074, 9, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 267, 372, 291, 14, 1258, 14, 1932, 2031, 589, 12, 1011, 958, 9, 339, 347, 2022, 63, 524, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 5666, 63, 1291, 360, 2714, 13, 804, 297, 283, 3578, 15, 1001, 297, 2074, 9, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 267, 372, 291, 14, 1258, 14, 524, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 398, 372, 291, 14, 1258, 14, 362, 2031, 589, 12, 1011, 958, 9, 339, 347, 3145, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 362, 360, 1178, 297, 715, 304, 288, 5666, 63, 1291, 360, 11626, 297, 283, 3264, 450, 83, 7, 450, 2986, 63, 498, 1062, 2074, 9, 398, 372, 291, 14, 1258, 14, 1807, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 1379, 8640, 8, 2642, 597, 304, 339, 347, 511, 63, 3197, 63, 4749, 8, 277, 304, 267, 892, 63, 1765, 275, 469, 288, 283, 354, 356, 283, 1222, 63, 1765, 297, 288, 283, 888, 356, 469, 355, 283, 3197, 63, 2718, 356, 9016, 1213, 356, 283, 2373, 413, 24371, 355, 283, 3183, 63, 2718, 18, 356, 791, 633, 356, 283, 1014, 921, 396, 15, 13614, 936, 288, 789, 267, 789, 398, 13684, 275, 291, 14, 1001, 63, 1932, 2336, 5054, 3678, 666, 29, 1001, 14, 4180, 8, 1222, 63, 1765, 430, 398, 702, 13684, 14, 1205, 63, 600, 508, 8290, 267, 666, 275, 2022, 14, 3640, 8, 15642, 14, 576, 9, 267, 702, 666, 14, 362, 360, 600, 358, 508, 8290, 267, 702, 666, 14, 362, 360, 1188, 358, 508, 283, 6136, 1125, 7, 267, 702, 666, 14, 362, 360, 6136, 63, 2550, 358, 267, 702, 283, 1918, 2883, 7, 315, 666, 459, 6136, 63, 2550, 3488, 16, 2733, 1188, 418, 267, 702, 283, 3197, 63, 2718, 7, 315, 666, 459, 6136, 63, 2550, 3488, 16, 2733, 1188, 418, 267, 702, 283, 3183, 63, 2718, 18, 7, 315, 666, 459, 6136, 63, 2550, 3488, 16, 2733, 1188, 418, 421, 199, 533, 1379, 3120, 3735, 8, 2642, 597, 304, 272, 636, 5963, 363, 275, 408, 267, 6527, 26, 881, 511, 26, 288, 32291, 26, 1598, 1166, 26, 1455, 921, 396, 15, 13614, 288, 1683, 26, 1598, 446, 2538, 26, 2397, 413, 267, 408, 339, 347, 511, 63, 3150, 8, 277, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 3150, 3678, 2323, 21146, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 2022, 14, 3640, 8, 15642, 14, 576, 9, 508, 791, 3150, 356, 747, 14, 17829, 12737, 339, 768, 2068, 14, 785, 8, 3346, 2988, 12, 283, 912, 63, 888, 358, 272, 347, 511, 63, 9233, 8, 277, 12, 16991, 63, 912, 63, 888, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 9233, 6217, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 16991, 63, 912, 63, 888, 14, 3527, 339, 768, 2068, 14, 785, 8, 2988, 12, 283, 8831, 358, 272, 347, 511, 63, 8831, 8, 277, 12, 16991, 63, 8831, 304, 267, 291, 14, 362, 2336, 1000, 15, 8831, 6217, 267, 702, 16991, 63, 8831, 14, 3527, 339, 347, 511, 63, 362, 63, 888, 8, 277, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 888, 6217, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 2022, 14, 3640, 8, 15642, 14, 576, 9, 508, 469, 288, 283, 5054, 356, 469, 355, 283, 396, 356, 469, 490, 283, 1805, 356, 9016, 1213, 356, 283, 2373, 413, 24371, 490, 283, 13614, 356, 791, 633, 356, 283, 1014, 921, 396, 15, 13614, 936, 355, 789, 288, 789, 267, 789, 339, 347, 511, 63, 1023, 8, 277, 304, 267, 13684, 275, 291, 14, 362, 2336, 1000, 15, 1023, 6217, 267, 702, 13684, 14, 1205, 63, 600, 508, 1926, 267, 702, 2022, 14, 3640, 8, 15642, 14, 576, 9, 508, 791, 14759, 362, 63, 1023, 356, 636, 1023, 3108, 283, 1246, 63, 1023, 356, 636, 1246, 63, 1023, 363, 93, 421, 199, 533, 1379, 4476, 3735, 8, 2642, 597, 304, 272, 636, 5963, 363, 275, 408, 267, 6527, 26, 881, 511, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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_import, unicode_literals from future.builtins import chr, int, str try: from html.parser import HTMLParser, HTMLParseError from html.entities import name2codepoint except ImportError: # Python 2 from HTMLParser import HTMLParser, HTMLParseError from htmlentitydefs import name2codepoint import re SELF_CLOSING_TAGS = ['br', 'img'] NON_SELF_CLOSING_TAGS = ['script', 'iframe'] ABSOLUTE_URL_TAGS = {"img": "src", "a": "href", "iframe": "src"} def absolute_urls(html): """ Converts relative URLs into absolute URLs. Used for RSS feeds to provide more complete HTML for item descriptions, but could also be used as a general richtext filter. """ from bs4 import BeautifulSoup from mezzanine.core.request import current_request request = current_request() if request is not None: dom = BeautifulSoup(html, "html.parser") for tag, attr in ABSOLUTE_URL_TAGS.items(): for node in dom.findAll(tag): url = node.get(attr, "") if url: node[attr] = request.build_absolute_uri(url) html = str(dom) return html def decode_entities(html): """ Remove HTML entities from a string. Adapted from http://effbot.org/zone/re-sub.htm#unescape-html """ def decode(m): html = m.group(0) if html[:2] == "&#": try: if html[:3] == "&#x": return chr(int(html[3:-1], 16)) else: return chr(int(html[2:-1])) except ValueError: pass else: try: html = chr(name2codepoint[html[1:-1]]) except KeyError: pass return html return re.sub("&#?\w+;", decode, html.replace("&amp;", "&")) def thumbnails(html): """ Given a HTML string, converts paths in img tags to thumbnail paths, using Mezzanine's ``thumbnail`` template tag. Used as one of the default values in the ``RICHTEXT_FILTERS`` setting. """ from django.conf import settings from bs4 import BeautifulSoup from mezzanine.core.templatetags.mezzanine_tags import thumbnail # If MEDIA_URL isn't in the HTML string, there aren't any # images to replace, so bail early. if settings.MEDIA_URL.lower() not in html.lower(): return html dom = BeautifulSoup(html, "html.parser") for img in dom.findAll("img"): src = img.get("src", "") src_in_media = src.lower().startswith(settings.MEDIA_URL.lower()) width = img.get("width") height = img.get("height") if src_in_media and width and height: img["src"] = settings.MEDIA_URL + thumbnail(src, width, height) return str(dom) class TagCloser(HTMLParser): """ HTMLParser that closes open tags. Takes a HTML string as its first arg, and populate a ``html`` attribute on the parser with the original HTML arg and any required closing tags. """ def __init__(self, html): HTMLParser.__init__(self) self.html = html self.tags = [] try: self.feed(self.html) except HTMLParseError: pass else: self.html += "".join(["</%s>" % tag for tag in self.tags]) def handle_starttag(self, tag, attrs): if tag not in SELF_CLOSING_TAGS: self.tags.insert(0, tag) def handle_endtag(self, tag): try: self.tags.remove(tag) except ValueError: pass
gpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 504, 6466, 14, 10372, 492, 8678, 12, 1109, 12, 620, 199, 199, 893, 26, 272, 687, 3517, 14, 2087, 492, 24581, 12, 4163, 9123, 272, 687, 3517, 14, 8327, 492, 536, 18, 19300, 199, 2590, 3545, 26, 221, 327, 2018, 499, 272, 687, 24581, 492, 24581, 12, 4163, 9123, 272, 687, 30010, 552, 1701, 8710, 492, 536, 18, 19300, 199, 199, 646, 295, 421, 199, 899, 15965, 63, 10353, 12567, 63, 17626, 275, 788, 3289, 297, 283, 4060, 418, 199, 13887, 63, 899, 15965, 63, 10353, 12567, 63, 17626, 275, 788, 1579, 297, 283, 20052, 418, 199, 1217, 15096, 4586, 63, 2632, 63, 17626, 275, 2420, 4060, 582, 298, 2164, 401, 298, 65, 582, 298, 6399, 401, 298, 20052, 582, 298, 2164, 3570, 421, 199, 318, 3679, 63, 3603, 8, 1360, 304, 272, 408, 272, 19107, 3847, 10867, 1901, 3679, 10867, 14, 8051, 367, 30331, 22295, 370, 272, 5647, 1655, 4890, 4163, 367, 1242, 18714, 12, 1325, 4293, 2597, 272, 506, 1202, 465, 282, 8605, 30162, 505, 2457, 14, 272, 408, 339, 687, 9922, 20, 492, 17132, 272, 687, 562, 4348, 290, 1132, 14, 1018, 14, 1069, 492, 1453, 63, 1069, 339, 1056, 275, 1453, 63, 1069, 342, 272, 340, 1056, 365, 440, 488, 26, 267, 8266, 275, 17132, 8, 1360, 12, 298, 1360, 14, 2087, 531, 267, 367, 1947, 12, 1921, 315, 437, 11087, 2228, 4586, 63, 2632, 63, 17626, 14, 1744, 837, 288, 367, 1031, 315, 8266, 14, 32651, 8, 1450, 304, 355, 1166, 275, 1031, 14, 362, 8, 962, 12, 6899, 355, 340, 1166, 26, 490, 1031, 59, 962, 61, 275, 1056, 14, 1506, 63, 6116, 63, 2302, 8, 633, 9, 267, 3517, 275, 620, 8, 4556, 9, 272, 372, 3517, 421, 199, 318, 4849, 63, 8327, 8, 1360, 304, 272, 408, 272, 5852, 4163, 9045, 687, 282, 1059, 14, 272, 4431, 18309, 687, 1455, 921, 3609, 3018, 14, 1308, 15, 2619, 15, 264, 13, 954, 14, 15575, 3, 22726, 13, 1360, 272, 408, 272, 347, 4849, 8, 77, 304, 267, 3517, 275, 333, 14, 923, 8, 16, 9, 267, 340, 3517, 1491, 18, 61, 508, 27720, 582, 288, 862, 26, 355, 340, 3517, 1491, 19, 61, 508, 27720, 88, 582, 490, 372, 8678, 8, 442, 8, 1360, 59, 19, 6809, 17, 467, 3193, 430, 355, 587, 26, 490, 372, 8678, 8, 442, 8, 1360, 59, 18, 6809, 17, 2459, 288, 871, 1722, 26, 355, 986, 267, 587, 26, 288, 862, 26, 355, 3517, 275, 8678, 8, 354, 18, 19300, 59, 1360, 59, 17, 6809, 17, 3934, 288, 871, 4067, 26, 355, 986, 267, 372, 3517, 272, 372, 295, 14, 954, 480, 7997, 8995, 87, 11, 17259, 4849, 12, 3517, 14, 1814, 22077, 5282, 17259, 11746, 2237, 421, 199, 318, 10062, 83, 8, 1360, 304, 272, 408, 272, 9138, 282, 4163, 1059, 12, 15373, 3792, 315, 6050, 3762, 370, 10062, 272, 3792, 12, 1808, 3194, 4348, 290, 1132, 1159, 1124, 8311, 1040, 1978, 1947, 14, 8051, 465, 272, 1373, 402, 314, 849, 1338, 315, 314, 1124, 14673, 2148, 2472, 63, 9905, 51, 1040, 4260, 14, 272, 408, 272, 687, 1639, 14, 2190, 492, 2202, 272, 687, 9922, 20, 492, 17132, 272, 687, 562, 4348, 290, 1132, 14, 1018, 14, 1160, 2969, 14, 278, 4348, 290, 1132, 63, 2969, 492, 10062, 339, 327, 982, 31460, 63, 2632, 5712, 1133, 315, 314, 4163, 1059, 12, 2337, 10621, 1133, 1263, 272, 327, 5935, 370, 3350, 12, 880, 31571, 14670, 14, 272, 340, 2202, 14, 13669, 63, 2632, 14, 2325, 342, 440, 315, 3517, 14, 2325, 837, 267, 372, 3517, 339, 8266, 275, 17132, 8, 1360, 12, 298, 1360, 14, 2087, 531, 272, 367, 6050, 315, 8266, 14, 32651, 480, 4060, 2349, 267, 2928, 275, 6050, 14, 362, 480, 2164, 401, 6899, 267, 2928, 63, 262, 63, 4603, 275, 2928, 14, 2325, 1252, 2460, 8, 1751, 14, 13669, 63, 2632, 14, 2325, 1012, 267, 3462, 275, 6050, 14, 362, 480, 2063, 531, 267, 4569, 275, 6050, 14, 362, 480, 3333, 531, 267, 340, 2928, 63, 262, 63, 4603, 436, 3462, 436, 4569, 26, 288, 6050, 905, 2164, 937, 275, 2202, 14, 13669, 63, 2632, 435, 10062, 8, 2164, 12, 3462, 12, 4569, 9, 272, 372, 620, 8, 4556, 9, 421, 199, 533, 8053, 3337, 332, 8, 27375, 304, 272, 408, 272, 24581, 626, 27811, 1551, 3762, 14, 17415, 282, 4163, 1059, 465, 2399, 1642, 272, 1680, 12, 436, 13904, 282, 1124, 1360, 1040, 2225, 641, 314, 1798, 543, 314, 272, 3379, 4163, 1680, 436, 1263, 1415, 11261, 3762, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3517, 304, 267, 24581, 855, 826, 721, 277, 9, 267, 291, 14, 1360, 275, 3517, 267, 291, 14, 2969, 275, 942, 267, 862, 26, 288, 291, 14, 3871, 8, 277, 14, 1360, 9, 267, 871, 4163, 9123, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1360, 847, 10587, 904, 5234, 26191, 83, 4335, 450, 1947, 367, 1947, 315, 291, 14, 2969, 566, 339, 347, 2429, 63, 15234, 8, 277, 12, 1947, 12, 3290, 304, 267, 340, 1947, 440, 315, 428, 2901, 38, 63, 10353, 12567, 63, 17626, 26, 288, 291, 14, 2969, 14, 3176, 8, 16, 12, 1947, 9, 339, 347, 2429, 63, 25765, 8, 277, 12, 1947, 304, 267, 862, 26, 288, 291, 14, 2969, 14, 2168, 8, 1450, 9, 267, 871, 1722, 26, 288, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 504, 6466, 14, 10372, 492, 8678, 12, 1109, 12, 620, 199, 199, 893, 26, 272, 687, 3517, 14, 2087, 492, 24581, 12, 4163, 9123, 272, 687, 3517, 14, 8327, 492, 536, 18, 19300, 199, 2590, 3545, 26, 221, 327, 2018, 499, 272, 687, 24581, 492, 24581, 12, 4163, 9123, 272, 687, 30010, 552, 1701, 8710, 492, 536, 18, 19300, 199, 199, 646, 295, 421, 199, 899, 15965, 63, 10353, 12567, 63, 17626, 275, 788, 3289, 297, 283, 4060, 418, 199, 13887, 63, 899, 15965, 63, 10353, 12567, 63, 17626, 275, 788, 1579, 297, 283, 20052, 418, 199, 1217, 15096, 4586, 63, 2632, 63, 17626, 275, 2420, 4060, 582, 298, 2164, 401, 298, 65, 582, 298, 6399, 401, 298, 20052, 582, 298, 2164, 3570, 421, 199, 318, 3679, 63, 3603, 8, 1360, 304, 272, 408, 272, 19107, 3847, 10867, 1901, 3679, 10867, 14, 8051, 367, 30331, 22295, 370, 272, 5647, 1655, 4890, 4163, 367, 1242, 18714, 12, 1325, 4293, 2597, 272, 506, 1202, 465, 282, 8605, 30162, 505, 2457, 14, 272, 408, 339, 687, 9922, 20, 492, 17132, 272, 687, 562, 4348, 290, 1132, 14, 1018, 14, 1069, 492, 1453, 63, 1069, 339, 1056, 275, 1453, 63, 1069, 342, 272, 340, 1056, 365, 440, 488, 26, 267, 8266, 275, 17132, 8, 1360, 12, 298, 1360, 14, 2087, 531, 267, 367, 1947, 12, 1921, 315, 437, 11087, 2228, 4586, 63, 2632, 63, 17626, 14, 1744, 837, 288, 367, 1031, 315, 8266, 14, 32651, 8, 1450, 304, 355, 1166, 275, 1031, 14, 362, 8, 962, 12, 6899, 355, 340, 1166, 26, 490, 1031, 59, 962, 61, 275, 1056, 14, 1506, 63, 6116, 63, 2302, 8, 633, 9, 267, 3517, 275, 620, 8, 4556, 9, 272, 372, 3517, 421, 199, 318, 4849, 63, 8327, 8, 1360, 304, 272, 408, 272, 5852, 4163, 9045, 687, 282, 1059, 14, 272, 4431, 18309, 687, 1455, 921, 3609, 3018, 14, 1308, 15, 2619, 15, 264, 13, 954, 14, 15575, 3, 22726, 13, 1360, 272, 408, 272, 347, 4849, 8, 77, 304, 267, 3517, 275, 333, 14, 923, 8, 16, 9, 267, 340, 3517, 1491, 18, 61, 508, 27720, 582, 288, 862, 26, 355, 340, 3517, 1491, 19, 61, 508, 27720, 88, 582, 490, 372, 8678, 8, 442, 8, 1360, 59, 19, 6809, 17, 467, 3193, 430, 355, 587, 26, 490, 372, 8678, 8, 442, 8, 1360, 59, 18, 6809, 17, 2459, 288, 871, 1722, 26, 355, 986, 267, 587, 26, 288, 862, 26, 355, 3517, 275, 8678, 8, 354, 18, 19300, 59, 1360, 59, 17, 6809, 17, 3934, 288, 871, 4067, 26, 355, 986, 267, 372, 3517, 272, 372, 295, 14, 954, 480, 7997, 8995, 87, 11, 17259, 4849, 12, 3517, 14, 1814, 22077, 5282, 17259, 11746, 2237, 421, 199, 318, 10062, 83, 8, 1360, 304, 272, 408, 272, 9138, 282, 4163, 1059, 12, 15373, 3792, 315, 6050, 3762, 370, 10062, 272, 3792, 12, 1808, 3194, 4348, 290, 1132, 1159, 1124, 8311, 1040, 1978, 1947, 14, 8051, 465, 272, 1373, 402, 314, 849, 1338, 315, 314, 1124, 14673, 2148, 2472, 63, 9905, 51, 1040, 4260, 14, 272, 408, 272, 687, 1639, 14, 2190, 492, 2202, 272, 687, 9922, 20, 492, 17132, 272, 687, 562, 4348, 290, 1132, 14, 1018, 14, 1160, 2969, 14, 278, 4348, 290, 1132, 63, 2969, 492, 10062, 339, 327, 982, 31460, 63, 2632, 5712, 1133, 315, 314, 4163, 1059, 12, 2337, 10621, 1133, 1263, 272, 327, 5935, 370, 3350, 12, 880, 31571, 14670, 14, 272, 340, 2202, 14, 13669, 63, 2632, 14, 2325, 342, 440, 315, 3517, 14, 2325, 837, 267, 372, 3517, 339, 8266, 275, 17132, 8, 1360, 12, 298, 1360, 14, 2087, 531, 272, 367, 6050, 315, 8266, 14, 32651, 480, 4060, 2349, 267, 2928, 275, 6050, 14, 362, 480, 2164, 401, 6899, 267, 2928, 63, 262, 63, 4603, 275, 2928, 14, 2325, 1252, 2460, 8, 1751, 14, 13669, 63, 2632, 14, 2325, 1012, 267, 3462, 275, 6050, 14, 362, 480, 2063, 531, 267, 4569, 275, 6050, 14, 362, 480, 3333, 531, 267, 340, 2928, 63, 262, 63, 4603, 436, 3462, 436, 4569, 26, 288, 6050, 905, 2164, 937, 275, 2202, 14, 13669, 63, 2632, 435, 10062, 8, 2164, 12, 3462, 12, 4569, 9, 272, 372, 620, 8, 4556, 9, 421, 199, 533, 8053, 3337, 332, 8, 27375, 304, 272, 408, 272, 24581, 626, 27811, 1551, 3762, 14, 17415, 282, 4163, 1059, 465, 2399, 1642, 272, 1680, 12, 436, 13904, 282, 1124, 1360, 1040, 2225, 641, 314, 1798, 543, 314, 272, 3379, 4163, 1680, 436, 1263, 1415, 11261, 3762, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3517, 304, 267, 24581, 855, 826, 721, 277, 9, 267, 291, 14, 1360, 275, 3517, 267, 291, 14, 2969, 275, 942, 267, 862, 26, 288, 291, 14, 3871, 8, 277, 14, 1360, 9, 267, 871, 4163, 9123, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1360, 847, 10587, 904, 5234, 26191, 83, 4335, 450, 1947, 367, 1947, 315, 291, 14, 2969, 566, 339, 347, 2429, 63, 15234, 8, 277, 12, 1947, 12, 3290, 304, 267, 340, 1947, 440, 315, 428, 2901, 38, 63, 10353, 12567, 63, 17626, 26, 288, 291, 14, 2969, 14, 3176, 8, 16, 12, 1947, 9, 339, 347, 2429, 63, 25765, 8, 277, 12, 1947, 304, 267, 862, 26, 288, 291, 14, 2969, 14, 2168, 8, 1450, 9, 267, 871, 1722, 26, 288, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
egafford/sahara
sahara/plugins/cdh/health.py
2
5255
# Copyright (c) 2016 Mirantis 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 functools from oslo_log import log as logging import six from sahara.i18n import _ from sahara.service.health import health_check_base LOG = logging.getLogger(__name__) class HealthStatusProvider(object): def __init__(self, cluster, cloudera_tools): self.cluster = cluster self.cloudera_tools = cloudera_tools self._data = None self._cluster_services = None self._exception_store = None self.get_health_status() def get_cluster_services(self): return self._cluster_services def is_cloudera_active(self): if self._exception_store: raise health_check_base.RedHealthError(self._exception_store) return _("Cloudera Manager is Active") def get_cloudera_health(self): cu = self.cloudera_tools api = cu.get_api_client(self.cluster) return api.get_service_health_status(self.cluster.name) def get_important_services(self): # will be overridable in future cu = self.cloudera_tools return [ cu.HDFS_SERVICE_NAME, cu.YARN_SERVICE_NAME, cu.OOZIE_SERVICE_NAME ] def get_health_status(self, service=None): if self._data is not None: return self._data.get(service, []) if service else self._data self._data = {} self._cluster_services = [] try: # all data already grouped by services self._data = self.get_cloudera_health() self._cluster_services = self._data.keys() except Exception as e: msg = _("Can't get response from Cloudera " "Manager") LOG.exception(msg) self._exception_store = _( "%(problem)s, reason: %(reason)s") % { 'problem': msg, 'reason': six.text_type(e)} class ClouderaManagerHealthCheck(health_check_base.BasicHealthCheck): def __init__(self, cluster, provider): self.provider = provider super(ClouderaManagerHealthCheck, self).__init__(cluster) def get_health_check_name(self): return _("Cloudera Manager health check") def is_available(self): return (self.cluster.plugin_name == 'cdh' and self.cluster.hadoop_version >= '5.4.0') def check_health(self): return self.provider.is_cloudera_active() class ServiceHealthCheck(health_check_base.BasicHealthCheck): def __init__(self, cluster, provider, service): self.provider = provider self.service = service super(ServiceHealthCheck, self).__init__(cluster) def get_health_check_name(self): return _("CDH %s health check") % self.service def is_available(self): return (self.cluster.plugin_name == 'cdh' and self.cluster.hadoop_version >= '5.4.0') def check_health(self): important_services = self.provider.get_important_services() observed_data = self.provider.get_health_status(self.service) imp_map = {'BAD': 'red', 'CONCERNING': 'yellow', 'GOOD': 'green'} summary = observed_data['summary'] checks = observed_data.get('checks', []) failed_checks = [] for check in checks: if check['summary'] != 'GOOD': failed_checks.append('%(name)s - %(summary)s state' % { 'name': check['name'], 'summary': check['summary'] }) additional_info = None if failed_checks: additional_info = _( "The following checks did not pass: %s") % ",".join( failed_checks) if self.service in important_services: overall = imp_map.get(summary, 'red') else: overall = 'green' if summary != 'GOOD': overall = 'yellow' msg = _("Cloudera Manager has responded that service is in " "the %s state") % summary if additional_info: msg = _("%(problem)s. %(description)s") % { 'problem': msg, 'description': additional_info} if overall == 'red': raise health_check_base.RedHealthError(msg) elif overall == 'yellow': raise health_check_base.YellowHealthError(msg) return msg def get_health_checks(cluster, cloudera_utils): provider = HealthStatusProvider(cluster, cloudera_utils) checks = [functools.partial( ClouderaManagerHealthCheck, provider=provider)] for service in provider.get_cluster_services(): checks.append(functools.partial( ServiceHealthCheck, provider=provider, service=service)) return checks
apache-2.0
[ 3, 1898, 334, 67, 9, 7800, 603, 723, 4466, 83, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 9143, 199, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 646, 3816, 199, 199, 504, 2937, 27314, 14, 73, 1085, 78, 492, 485, 199, 504, 2937, 27314, 14, 1364, 14, 9665, 492, 13822, 63, 1074, 63, 1095, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 5311, 6130, 3694, 6663, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4350, 12, 2463, 3786, 345, 63, 2537, 304, 267, 291, 14, 4201, 275, 4350, 267, 291, 14, 1251, 3786, 345, 63, 2537, 275, 2463, 3786, 345, 63, 2537, 267, 291, 423, 576, 275, 488, 267, 291, 423, 4201, 63, 5950, 275, 488, 267, 291, 423, 1971, 63, 1617, 275, 488, 267, 291, 14, 362, 63, 9665, 63, 1205, 342, 339, 347, 664, 63, 4201, 63, 5950, 8, 277, 304, 267, 372, 291, 423, 4201, 63, 5950, 339, 347, 365, 63, 1251, 3786, 345, 63, 2682, 8, 277, 304, 267, 340, 291, 423, 1971, 63, 1617, 26, 288, 746, 13822, 63, 1074, 63, 1095, 14, 10858, 18850, 547, 8, 277, 423, 1971, 63, 1617, 9, 267, 372, 3824, 3337, 3786, 345, 13537, 365, 23241, 531, 339, 347, 664, 63, 1251, 3786, 345, 63, 9665, 8, 277, 304, 267, 30353, 275, 291, 14, 1251, 3786, 345, 63, 2537, 267, 2986, 275, 30353, 14, 362, 63, 1246, 63, 1258, 8, 277, 14, 4201, 9, 267, 372, 2986, 14, 362, 63, 1364, 63, 9665, 63, 1205, 8, 277, 14, 4201, 14, 354, 9, 339, 347, 664, 63, 19559, 63, 5950, 8, 277, 304, 267, 327, 911, 506, 1806, 1677, 461, 315, 6466, 267, 30353, 275, 291, 14, 1251, 3786, 345, 63, 2537, 267, 372, 359, 288, 30353, 14, 30165, 51, 63, 10486, 63, 2339, 12, 288, 30353, 14, 57, 26513, 63, 10486, 63, 2339, 12, 288, 30353, 14, 5757, 58, 4332, 63, 10486, 63, 2339, 267, 1622, 339, 347, 664, 63, 9665, 63, 1205, 8, 277, 12, 2435, 29, 403, 304, 267, 340, 291, 423, 576, 365, 440, 488, 26, 288, 372, 291, 423, 576, 14, 362, 8, 1364, 12, 3073, 340, 2435, 587, 291, 423, 576, 267, 291, 423, 576, 275, 1052, 267, 291, 423, 4201, 63, 5950, 275, 942, 267, 862, 26, 288, 327, 1006, 666, 2575, 16251, 701, 8500, 288, 291, 423, 576, 275, 291, 14, 362, 63, 1251, 3786, 345, 63, 9665, 342, 288, 291, 423, 4201, 63, 5950, 275, 291, 423, 576, 14, 1612, 342, 267, 871, 2186, 465, 325, 26, 288, 1499, 275, 3824, 6049, 1133, 664, 1177, 687, 5980, 3786, 345, 298, 490, 298, 2988, 531, 288, 5051, 14, 1971, 8, 1328, 9, 288, 291, 423, 1971, 63, 1617, 275, 12561, 355, 11792, 6462, 9, 83, 12, 4499, 26, 2818, 5764, 9, 83, 531, 450, 469, 355, 283, 6462, 356, 1499, 12, 283, 5764, 356, 3816, 14, 505, 63, 466, 8, 69, 6769, 421, 199, 533, 5980, 3786, 345, 2988, 18850, 1799, 8, 9665, 63, 1074, 63, 1095, 14, 6845, 18850, 1799, 304, 272, 347, 636, 826, 721, 277, 12, 4350, 12, 5022, 304, 267, 291, 14, 3780, 275, 5022, 267, 1613, 8, 3337, 3786, 345, 2988, 18850, 1799, 12, 291, 2843, 826, 721, 4201, 9, 339, 347, 664, 63, 9665, 63, 1074, 63, 354, 8, 277, 304, 267, 372, 3824, 3337, 3786, 345, 13537, 13822, 1104, 531, 339, 347, 365, 63, 4561, 8, 277, 304, 267, 372, 334, 277, 14, 4201, 14, 2718, 63, 354, 508, 283, 2866, 72, 7, 436, 355, 291, 14, 4201, 14, 15449, 63, 1023, 2356, 283, 21, 14, 20, 14, 16, 358, 339, 347, 1104, 63, 9665, 8, 277, 304, 267, 372, 291, 14, 3780, 14, 374, 63, 1251, 3786, 345, 63, 2682, 342, 421, 199, 533, 7591, 18850, 1799, 8, 9665, 63, 1074, 63, 1095, 14, 6845, 18850, 1799, 304, 272, 347, 636, 826, 721, 277, 12, 4350, 12, 5022, 12, 2435, 304, 267, 291, 14, 3780, 275, 5022, 267, 291, 14, 1364, 275, 2435, 267, 1613, 8, 3167, 18850, 1799, 12, 291, 2843, 826, 721, 4201, 9, 339, 347, 664, 63, 9665, 63, 1074, 63, 354, 8, 277, 304, 267, 372, 3824, 7695, 40, 450, 83, 13822, 1104, 531, 450, 291, 14, 1364, 339, 347, 365, 63, 4561, 8, 277, 304, 267, 372, 334, 277, 14, 4201, 14, 2718, 63, 354, 508, 283, 2866, 72, 7, 436, 355, 291, 14, 4201, 14, 15449, 63, 1023, 2356, 283, 21, 14, 20, 14, 16, 358, 339, 347, 1104, 63, 9665, 8, 277, 304, 267, 11012, 63, 5950, 275, 291, 14, 3780, 14, 362, 63, 19559, 63, 5950, 342, 267, 20802, 63, 576, 275, 291, 14, 3780, 14, 362, 63, 9665, 63, 1205, 8, 277, 14, 1364, 9, 267, 1742, 63, 1130, 275, 791, 9439, 356, 283, 581, 297, 283, 1864, 35, 540, 6024, 356, 283, 14514, 297, 283, 17316, 36, 356, 283, 7731, 936, 267, 6212, 275, 20802, 63, 576, 459, 4705, 418, 267, 5920, 275, 20802, 63, 576, 14, 362, 360, 8625, 297, 3073, 267, 3405, 63, 8625, 275, 942, 267, 367, 1104, 315, 5920, 26, 288, 340, 1104, 459, 4705, 418, 1137, 283, 17316, 36, 356, 355, 3405, 63, 8625, 14, 740, 24713, 354, 9, 83, 446, 2818, 4705, 9, 83, 1174, 7, 450, 469, 490, 283, 354, 356, 1104, 459, 354, 995, 283, 4705, 356, 1104, 459, 4705 ]
[ 1898, 334, 67, 9, 7800, 603, 723, 4466, 83, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 9143, 199, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 646, 3816, 199, 199, 504, 2937, 27314, 14, 73, 1085, 78, 492, 485, 199, 504, 2937, 27314, 14, 1364, 14, 9665, 492, 13822, 63, 1074, 63, 1095, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 5311, 6130, 3694, 6663, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4350, 12, 2463, 3786, 345, 63, 2537, 304, 267, 291, 14, 4201, 275, 4350, 267, 291, 14, 1251, 3786, 345, 63, 2537, 275, 2463, 3786, 345, 63, 2537, 267, 291, 423, 576, 275, 488, 267, 291, 423, 4201, 63, 5950, 275, 488, 267, 291, 423, 1971, 63, 1617, 275, 488, 267, 291, 14, 362, 63, 9665, 63, 1205, 342, 339, 347, 664, 63, 4201, 63, 5950, 8, 277, 304, 267, 372, 291, 423, 4201, 63, 5950, 339, 347, 365, 63, 1251, 3786, 345, 63, 2682, 8, 277, 304, 267, 340, 291, 423, 1971, 63, 1617, 26, 288, 746, 13822, 63, 1074, 63, 1095, 14, 10858, 18850, 547, 8, 277, 423, 1971, 63, 1617, 9, 267, 372, 3824, 3337, 3786, 345, 13537, 365, 23241, 531, 339, 347, 664, 63, 1251, 3786, 345, 63, 9665, 8, 277, 304, 267, 30353, 275, 291, 14, 1251, 3786, 345, 63, 2537, 267, 2986, 275, 30353, 14, 362, 63, 1246, 63, 1258, 8, 277, 14, 4201, 9, 267, 372, 2986, 14, 362, 63, 1364, 63, 9665, 63, 1205, 8, 277, 14, 4201, 14, 354, 9, 339, 347, 664, 63, 19559, 63, 5950, 8, 277, 304, 267, 327, 911, 506, 1806, 1677, 461, 315, 6466, 267, 30353, 275, 291, 14, 1251, 3786, 345, 63, 2537, 267, 372, 359, 288, 30353, 14, 30165, 51, 63, 10486, 63, 2339, 12, 288, 30353, 14, 57, 26513, 63, 10486, 63, 2339, 12, 288, 30353, 14, 5757, 58, 4332, 63, 10486, 63, 2339, 267, 1622, 339, 347, 664, 63, 9665, 63, 1205, 8, 277, 12, 2435, 29, 403, 304, 267, 340, 291, 423, 576, 365, 440, 488, 26, 288, 372, 291, 423, 576, 14, 362, 8, 1364, 12, 3073, 340, 2435, 587, 291, 423, 576, 267, 291, 423, 576, 275, 1052, 267, 291, 423, 4201, 63, 5950, 275, 942, 267, 862, 26, 288, 327, 1006, 666, 2575, 16251, 701, 8500, 288, 291, 423, 576, 275, 291, 14, 362, 63, 1251, 3786, 345, 63, 9665, 342, 288, 291, 423, 4201, 63, 5950, 275, 291, 423, 576, 14, 1612, 342, 267, 871, 2186, 465, 325, 26, 288, 1499, 275, 3824, 6049, 1133, 664, 1177, 687, 5980, 3786, 345, 298, 490, 298, 2988, 531, 288, 5051, 14, 1971, 8, 1328, 9, 288, 291, 423, 1971, 63, 1617, 275, 12561, 355, 11792, 6462, 9, 83, 12, 4499, 26, 2818, 5764, 9, 83, 531, 450, 469, 355, 283, 6462, 356, 1499, 12, 283, 5764, 356, 3816, 14, 505, 63, 466, 8, 69, 6769, 421, 199, 533, 5980, 3786, 345, 2988, 18850, 1799, 8, 9665, 63, 1074, 63, 1095, 14, 6845, 18850, 1799, 304, 272, 347, 636, 826, 721, 277, 12, 4350, 12, 5022, 304, 267, 291, 14, 3780, 275, 5022, 267, 1613, 8, 3337, 3786, 345, 2988, 18850, 1799, 12, 291, 2843, 826, 721, 4201, 9, 339, 347, 664, 63, 9665, 63, 1074, 63, 354, 8, 277, 304, 267, 372, 3824, 3337, 3786, 345, 13537, 13822, 1104, 531, 339, 347, 365, 63, 4561, 8, 277, 304, 267, 372, 334, 277, 14, 4201, 14, 2718, 63, 354, 508, 283, 2866, 72, 7, 436, 355, 291, 14, 4201, 14, 15449, 63, 1023, 2356, 283, 21, 14, 20, 14, 16, 358, 339, 347, 1104, 63, 9665, 8, 277, 304, 267, 372, 291, 14, 3780, 14, 374, 63, 1251, 3786, 345, 63, 2682, 342, 421, 199, 533, 7591, 18850, 1799, 8, 9665, 63, 1074, 63, 1095, 14, 6845, 18850, 1799, 304, 272, 347, 636, 826, 721, 277, 12, 4350, 12, 5022, 12, 2435, 304, 267, 291, 14, 3780, 275, 5022, 267, 291, 14, 1364, 275, 2435, 267, 1613, 8, 3167, 18850, 1799, 12, 291, 2843, 826, 721, 4201, 9, 339, 347, 664, 63, 9665, 63, 1074, 63, 354, 8, 277, 304, 267, 372, 3824, 7695, 40, 450, 83, 13822, 1104, 531, 450, 291, 14, 1364, 339, 347, 365, 63, 4561, 8, 277, 304, 267, 372, 334, 277, 14, 4201, 14, 2718, 63, 354, 508, 283, 2866, 72, 7, 436, 355, 291, 14, 4201, 14, 15449, 63, 1023, 2356, 283, 21, 14, 20, 14, 16, 358, 339, 347, 1104, 63, 9665, 8, 277, 304, 267, 11012, 63, 5950, 275, 291, 14, 3780, 14, 362, 63, 19559, 63, 5950, 342, 267, 20802, 63, 576, 275, 291, 14, 3780, 14, 362, 63, 9665, 63, 1205, 8, 277, 14, 1364, 9, 267, 1742, 63, 1130, 275, 791, 9439, 356, 283, 581, 297, 283, 1864, 35, 540, 6024, 356, 283, 14514, 297, 283, 17316, 36, 356, 283, 7731, 936, 267, 6212, 275, 20802, 63, 576, 459, 4705, 418, 267, 5920, 275, 20802, 63, 576, 14, 362, 360, 8625, 297, 3073, 267, 3405, 63, 8625, 275, 942, 267, 367, 1104, 315, 5920, 26, 288, 340, 1104, 459, 4705, 418, 1137, 283, 17316, 36, 356, 355, 3405, 63, 8625, 14, 740, 24713, 354, 9, 83, 446, 2818, 4705, 9, 83, 1174, 7, 450, 469, 490, 283, 354, 356, 1104, 459, 354, 995, 283, 4705, 356, 1104, 459, 4705, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
twitchyliquid64/misc-scripts
s3tool/boto-develop/tests/integration/s3/test_multidelete.py
25
6770
# -*- coding: utf-8 -*- # Copyright (c) 2011 Mitch Garnaat http://garnaat.org/ # All rights reserved. # # 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, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing 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 MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR 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. """ Some unit tests for the S3 MultiDelete """ import unittest import time from boto.s3.key import Key from boto.s3.deletemarker import DeleteMarker from boto.s3.prefix import Prefix from boto.s3.connection import S3Connection from boto.exception import S3ResponseError class S3MultiDeleteTest(unittest.TestCase): s3 = True def setUp(self): self.conn = S3Connection() self.bucket_name = 'multidelete-%d' % int(time.time()) self.bucket = self.conn.create_bucket(self.bucket_name) def tearDown(self): for key in self.bucket: key.delete() self.bucket.delete_keys(self.bucket.list_versions()) self.bucket.delete() def test_delete_nothing(self): result = self.bucket.delete_keys([]) self.assertEqual(len(result.deleted), 0) self.assertEqual(len(result.errors), 0) def test_delete_illegal(self): result = self.bucket.delete_keys([{"dict":"notallowed"}]) self.assertEqual(len(result.deleted), 0) self.assertEqual(len(result.errors), 1) def test_delete_mix(self): result = self.bucket.delete_keys(["king", ("mice", None), Key(name="regular"), Key(), Prefix(name="folder/"), DeleteMarker(name="deleted"), {"bad":"type"}]) self.assertEqual(len(result.deleted), 4) self.assertEqual(len(result.errors), 3) def test_delete_quietly(self): result = self.bucket.delete_keys(["king"], quiet=True) self.assertEqual(len(result.deleted), 0) self.assertEqual(len(result.errors), 0) def test_delete_must_escape(self): result = self.bucket.delete_keys([Key(name=">_<;")]) self.assertEqual(len(result.deleted), 1) self.assertEqual(len(result.errors), 0) def test_delete_unknown_version(self): no_ver = Key(name="no") no_ver.version_id = "version" result = self.bucket.delete_keys([no_ver]) self.assertEqual(len(result.deleted), 0) self.assertEqual(len(result.errors), 1) def test_delete_kanji(self): result = self.bucket.delete_keys([u"漢字", Key(name=u"日本語")]) self.assertEqual(len(result.deleted), 2) self.assertEqual(len(result.errors), 0) def test_delete_empty_by_list(self): result = self.bucket.delete_keys(self.bucket.list()) self.assertEqual(len(result.deleted), 0) self.assertEqual(len(result.errors), 0) def test_delete_kanji_by_list(self): for key_name in [u"漢字", u"日本語", u"テスト"]: key = self.bucket.new_key(key_name) key.set_contents_from_string('this is a test') result = self.bucket.delete_keys(self.bucket.list()) self.assertEqual(len(result.deleted), 3) self.assertEqual(len(result.errors), 0) def test_delete_with_prefixes(self): for key_name in ["a", "a/b", "b"]: key = self.bucket.new_key(key_name) key.set_contents_from_string('this is a test') # First delete all "files": "a" and "b" result = self.bucket.delete_keys(self.bucket.list(delimiter="/")) self.assertEqual(len(result.deleted), 2) # Using delimiter will cause 1 common prefix to be listed # which will be skipped as an error. self.assertEqual(len(result.errors), 1) self.assertEqual(result.errors[0].key, "a/") # Next delete any remaining objects: "a/b" result = self.bucket.delete_keys(self.bucket.list()) self.assertEqual(len(result.deleted), 1) self.assertEqual(len(result.errors), 0) self.assertEqual(result.deleted[0].key, "a/b") def test_delete_too_many_versions(self): # configure versioning first self.bucket.configure_versioning(True) # Add 1000 initial versions as DMs by deleting them :-) # Adding 1000 objects is painful otherwise... key_names = ['key-%03d' % i for i in range(0, 1000)] result = self.bucket.delete_keys(key_names) self.assertEqual(len(result.deleted) + len(result.errors), 1000) # delete them again to create 1000 more delete markers result = self.bucket.delete_keys(key_names) self.assertEqual(len(result.deleted) + len(result.errors), 1000) # Sometimes takes AWS sometime to settle time.sleep(10) # delete all versions to delete 2000 objects. # this tests the 1000 limit. result = self.bucket.delete_keys(self.bucket.list_versions()) self.assertEqual(len(result.deleted) + len(result.errors), 2000) def test_1(self): nkeys = 100 # create a bunch of keynames key_names = ['key-%03d' % i for i in range(0, nkeys)] # create the corresponding keys for key_name in key_names: key = self.bucket.new_key(key_name) key.set_contents_from_string('this is a test') # now count keys in bucket n = 0 for key in self.bucket: n += 1 self.assertEqual(n, nkeys) # now delete them all result = self.bucket.delete_keys(key_names) self.assertEqual(len(result.deleted), nkeys) self.assertEqual(len(result.errors), 0) time.sleep(5) # now count keys in bucket n = 0 for key in self.bucket: n += 1 self.assertEqual(n, 0)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 624, 199, 7700, 4137, 2295, 367, 314, 428, 19, 6879, 5392, 199, 624, 199, 199, 646, 2882, 199, 646, 900, 199, 504, 6055, 14, 83, 19, 14, 498, 492, 2606, 199, 504, 6055, 14, 83, 19, 14, 7346, 563, 1096, 281, 492, 8496, 12825, 199, 504, 6055, 14, 83, 19, 14, 1861, 492, 25110, 199, 504, 6055, 14, 83, 19, 14, 2105, 492, 428, 19, 3225, 199, 504, 6055, 14, 1971, 492, 428, 19, 19712, 199, 199, 533, 428, 19, 3947, 5392, 774, 8, 2796, 14, 1746, 304, 272, 308, 19, 275, 715, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1631, 275, 428, 19, 3225, 342, 267, 291, 14, 4623, 63, 354, 275, 283, 3029, 1807, 3295, 68, 7, 450, 1109, 8, 521, 14, 521, 1012, 267, 291, 14, 4623, 275, 291, 14, 1631, 14, 981, 63, 4623, 8, 277, 14, 4623, 63, 354, 9, 339, 347, 6766, 8, 277, 304, 267, 367, 790, 315, 291, 14, 4623, 26, 288, 790, 14, 1807, 342, 267, 291, 14, 4623, 14, 1807, 63, 1612, 8, 277, 14, 4623, 14, 513, 63, 6234, 1012, 267, 291, 14, 4623, 14, 1807, 342, 339, 347, 511, 63, 1807, 63, 16323, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 4157, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 23375, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 6641, 807, 5122, 1397, 6541, 3570, 566, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 413, 9, 339, 347, 511, 63, 1807, 63, 13979, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 5234, 17443, 401, 5101, 1689, 77, 1885, 401, 488, 395, 5101, 2606, 8, 354, 628, 7898, 1288, 5101, 2606, 1062, 5101, 25110, 8, 354, 628, 3741, 15, 1288, 5101, 8496, 12825, 8, 354, 628, 6062, 1288, 5101, 2420, 4087, 5122, 466, 3570, 566, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 841, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 650, 9, 339, 347, 511, 63, 1807, 63, 10243, 590, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 5234, 17443, 2255, 11971, 29, 549, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 7790, 63, 3765, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 1197, 8, 354, 628, 30, 27718, 27, 13403, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 413, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 5187, 63, 1023, 8, 277, 304, 267, 949, 63, 422, 275, 2606, 8, 354, 628, 889, 531, 267, 949, 63, 422, 14, 1023, 63, 344, 275, 298, 1023, 2, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 889, 63, 422, 566, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 413, 9, 339, 347, 511, 63, 1807, 63, 29305, 8047, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 85, 2, 163, 121, 96, 26032, 401, 2606, 8, 354, 29, 85, 2, 17243, 26304, 165, 104, 253, 13403, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 499, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 1667, 63, 991, 63, 513, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 8, 277, 14, 4623, 14, 513, 1012, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 29305, 8047, 63, 991, 63, 513, 8, 277, 304, 267, 367, 790, 63, 354, 315, 359, 85, 2, 163, 121, 96, 26032, 401, 399, 2, 17243, 26304, 165, 104, 253, 401, 399, 2, 5692, 229, 25111, 23869, 6229, 288, 790, 275, 291, 14, 4623, 14, 1222, 63, 498, 8, 498, 63, 354, 9, 288, 790, 14, 409, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 624, 199, 7700, 4137, 2295, 367, 314, 428, 19, 6879, 5392, 199, 624, 199, 199, 646, 2882, 199, 646, 900, 199, 504, 6055, 14, 83, 19, 14, 498, 492, 2606, 199, 504, 6055, 14, 83, 19, 14, 7346, 563, 1096, 281, 492, 8496, 12825, 199, 504, 6055, 14, 83, 19, 14, 1861, 492, 25110, 199, 504, 6055, 14, 83, 19, 14, 2105, 492, 428, 19, 3225, 199, 504, 6055, 14, 1971, 492, 428, 19, 19712, 199, 199, 533, 428, 19, 3947, 5392, 774, 8, 2796, 14, 1746, 304, 272, 308, 19, 275, 715, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1631, 275, 428, 19, 3225, 342, 267, 291, 14, 4623, 63, 354, 275, 283, 3029, 1807, 3295, 68, 7, 450, 1109, 8, 521, 14, 521, 1012, 267, 291, 14, 4623, 275, 291, 14, 1631, 14, 981, 63, 4623, 8, 277, 14, 4623, 63, 354, 9, 339, 347, 6766, 8, 277, 304, 267, 367, 790, 315, 291, 14, 4623, 26, 288, 790, 14, 1807, 342, 267, 291, 14, 4623, 14, 1807, 63, 1612, 8, 277, 14, 4623, 14, 513, 63, 6234, 1012, 267, 291, 14, 4623, 14, 1807, 342, 339, 347, 511, 63, 1807, 63, 16323, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 4157, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 23375, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 6641, 807, 5122, 1397, 6541, 3570, 566, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 413, 9, 339, 347, 511, 63, 1807, 63, 13979, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 5234, 17443, 401, 5101, 1689, 77, 1885, 401, 488, 395, 5101, 2606, 8, 354, 628, 7898, 1288, 5101, 2606, 1062, 5101, 25110, 8, 354, 628, 3741, 15, 1288, 5101, 8496, 12825, 8, 354, 628, 6062, 1288, 5101, 2420, 4087, 5122, 466, 3570, 566, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 841, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 650, 9, 339, 347, 511, 63, 1807, 63, 10243, 590, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 5234, 17443, 2255, 11971, 29, 549, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 7790, 63, 3765, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 1197, 8, 354, 628, 30, 27718, 27, 13403, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 413, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 5187, 63, 1023, 8, 277, 304, 267, 949, 63, 422, 275, 2606, 8, 354, 628, 889, 531, 267, 949, 63, 422, 14, 1023, 63, 344, 275, 298, 1023, 2, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 889, 63, 422, 566, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 413, 9, 339, 347, 511, 63, 1807, 63, 29305, 8047, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 779, 85, 2, 163, 121, 96, 26032, 401, 2606, 8, 354, 29, 85, 2, 17243, 26304, 165, 104, 253, 13403, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 499, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 1667, 63, 991, 63, 513, 8, 277, 304, 267, 754, 275, 291, 14, 4623, 14, 1807, 63, 1612, 8, 277, 14, 4623, 14, 513, 1012, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 6062, 395, 378, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 14, 2550, 395, 378, 9, 339, 347, 511, 63, 1807, 63, 29305, 8047, 63, 991, 63, 513, 8, 277, 304, 267, 367, 790, 63, 354, 315, 359, 85, 2, 163, 121, 96, 26032, 401, 399, 2, 17243, 26304, 165, 104, 253, 401, 399, 2, 5692, 229, 25111, 23869, 6229, 288, 790, 275, 291, 14, 4623, 14, 1222, 63, 498, 8, 498, 63, 354, 9, 288, 790, 14, 409, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ryfeus/lambda-packs
Tensorflow/source/tensorflow/contrib/nccl/python/ops/nccl_ops.py
9
8253
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # 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. # ============================================================================== """Ops for GPU collective operations implemented using NVIDIA nccl.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import threading from tensorflow.contrib.nccl.ops import gen_nccl_ops from tensorflow.contrib.util import loader from tensorflow.python.eager import context from tensorflow.python.framework import device from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.platform import resource_loader _nccl_ops_so = loader.load_op_library( resource_loader.get_path_to_datafile('_nccl_ops.so')) def all_sum(tensors): """Returns a list of tensors with the all-reduce sum across `tensors`. The computation is done with an all-reduce operation, so if only some of the returned tensors are evaluated then the computation will hang. Args: tensors: The input tensors across which to sum; must be assigned to GPU devices. Returns: List of tensors, each with the sum of the input tensors, where tensor i has the same device as `tensors[i]`. """ return _apply_all_reduce('sum', tensors) @ops.RegisterGradient('NcclAllReduce') def _all_sum_grad(op, grad): """The gradients for `all_sum`. Args: op: The `all_sum` `Operation` that we are differentiating. grad: Gradient with respect to the output of the `all_sum` op. Returns: The gradient with respect to the output of `all_sum`. Raises: LookupError: If `reduction` is not `sum`. """ if op.get_attr('reduction') != 'sum': raise LookupError('No gradient defined for NcclAllReduce except all_sum.') _check_device_assignment(grad) num_devices = op.get_attr('num_devices') shared_name = op.get_attr('shared_name') + '_grad' with ops.device(grad.device): return gen_nccl_ops.nccl_all_reduce( input=grad, reduction='sum', num_devices=num_devices, shared_name=shared_name) def all_prod(tensors): """Returns a list of tensors with the all-reduce product across `tensors`. The computation is done with an all-reduce operation, so if only some of the returned tensors are evaluated then the computation will hang. Args: tensors: The input tensors across which to multiply; must be assigned to GPU devices. Returns: List of tensors, each with the product of the input tensors, where tensor i has the same device as `tensors[i]`. """ return _apply_all_reduce('prod', tensors) def all_min(tensors): """Returns a list of tensors with the all-reduce min across `tensors`. The computation is done with an all-reduce operation, so if only some of the returned tensors are evaluated then the computation will hang. Args: tensors: The input tensors across which to reduce; must be assigned to GPU devices. Returns: List of tensors, each with the minimum of the input tensors, where tensor i has the same device as `tensors[i]`. """ return _apply_all_reduce('min', tensors) def all_max(tensors): """Returns a list of tensors with the all-reduce max across `tensors`. The computation is done with an all-reduce operation, so if only some of the returned tensors are evaluated then the computation will hang. Args: tensors: The input tensors across which to reduce; must be assigned to GPU devices. Returns: List of tensors, each with the maximum of the input tensors, where tensor i has the same device as `tensors[i]`. """ return _apply_all_reduce('max', tensors) def reduce_sum(tensors, dst_device): """Returns a tensor with the reduce sum across `tensors`. The computation is done with a reduce operation, so only one tensor is returned. Args: tensors: The input tensors across which to sum; must be assigned to GPU devices. dst_device: The device of the returned tensor. Returns: A tensor containing the sum of the input tensors, with the device of the tensor being `dst_device`. """ return _apply_reduce('sum', tensors, dst_device) def broadcast(src_tensor, dst_devices): """Returns a list of tensors on `dst_devices`, each with value `tensor`. The computation is done with a broadcast nccl operation, so if only some of the returned tensors and src_tensor are evaluated then the computation will hang. Args: src_tensor: The tensor to send; must be assigned to a GPU device. dst_devices: The GPU devices to receive the sent tensor. Returns: An `Operation` to send the `src_tensor`, and a list of tensors, each with the value of `src_tensor`, where the device of tensor i is `dst_devices[i]`. """ if not dst_devices: raise ValueError('Must pass >0 dst_devices to broadcast') _check_graph_mode() _check_device_assignment(src_tensor) shape = array_ops.shape(src_tensor, out_type=dtypes.int64) num_devices = len(dst_devices) + 1 shared_name = _get_shared_name() with ops.device(src_tensor.device): send = gen_nccl_ops.nccl_broadcast_send( input=src_tensor, num_devices=num_devices, shared_name=shared_name) recvs = [] for d in dst_devices: with ops.device(d): recvs.append( gen_nccl_ops.nccl_broadcast_recv( shape=shape, T=src_tensor.dtype, num_devices=num_devices, shared_name=shared_name)) return send, recvs def _apply_all_reduce(reduction, tensors): """Helper function for all_* functions.""" if not tensors: raise ValueError('Must pass >0 tensors to all reduce operations') _check_graph_mode() shared_name = _get_shared_name() res = [] for t in tensors: _check_device_assignment(t) with ops.device(t.device): res.append( gen_nccl_ops.nccl_all_reduce( input=t, reduction=reduction, num_devices=len(tensors), shared_name=shared_name)) return res def _apply_reduce(reduction, tensors, dst_device): """Helper function for reduce_* functions.""" if not tensors: raise ValueError('Must pass >0 tensors to reduce operations') if not dst_device: raise ValueError('Must pass dst_device to reduce operations') _check_graph_mode() try: recv_index = next(i for i, t in enumerate(tensors) if t.device == dst_device) except StopIteration: raise ValueError('One of the tensors must be assigned to dst_device') shared_name = _get_shared_name() sends = [] for t in tensors[:recv_index] + tensors[recv_index + 1:]: _check_device_assignment(t) with ops.device(t.device): sends.append( gen_nccl_ops.nccl_reduce_send( input=t, reduction=reduction, num_devices=len(tensors), shared_name=shared_name)) with ops.device(dst_device): recv = gen_nccl_ops.nccl_reduce_recv( input=tensors[recv_index], reduction=reduction, num_devices=len(tensors), shared_name=shared_name) return recv, sends _lock = threading.Lock() _shared_name_counter = 0 def _get_shared_name(): global _shared_name_counter with _lock: val = _shared_name_counter _shared_name_counter += 1 return 'c%s' % val def _check_device_assignment(tensor): if not device.canonical_name(tensor.device): raise ValueError('Device assignment required for nccl collective ops') def _check_graph_mode(): if context.in_eager_mode(): raise ValueError('Nccl ops are not supported in eager mode')
mit
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 16452, 367, 18613, 1048, 25982, 5331, 6366, 1808, 653, 5437, 13033, 12698, 429, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5796, 199, 199, 504, 3228, 14, 2828, 14, 7966, 429, 14, 1483, 492, 3805, 63, 7966, 429, 63, 1483, 199, 504, 3228, 14, 2828, 14, 1974, 492, 5077, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2243, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 199, 63, 7966, 429, 63, 1483, 63, 1152, 275, 5077, 14, 912, 63, 411, 63, 4342, 8, 272, 2073, 63, 3422, 14, 362, 63, 515, 63, 475, 63, 31423, 6412, 7966, 429, 63, 1483, 14, 1152, 1333, 421, 199, 318, 1006, 63, 1838, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 3089, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 3089, 27, 1471, 506, 7943, 489, 370, 18613, 7256, 14, 819, 1803, 26, 272, 3820, 402, 10519, 12, 1924, 543, 314, 3089, 402, 314, 1324, 10519, 12, 2382, 2345, 284, 965, 272, 314, 2011, 2243, 465, 658, 10206, 59, 73, 20336, 523, 408, 523, 372, 485, 4998, 63, 452, 63, 5270, 360, 1838, 297, 10519, 9, 421, 199, 32, 1483, 14, 24876, 360, 46, 67, 429, 2422, 21822, 358, 199, 318, 485, 452, 63, 1838, 63, 6017, 8, 411, 12, 7659, 304, 523, 408, 1918, 12661, 367, 658, 452, 63, 1838, 2313, 819, 3033, 26, 272, 1687, 26, 710, 658, 452, 63, 1838, 64, 658, 6044, 64, 626, 781, 787, 26796, 1958, 14, 272, 7659, 26, 19603, 543, 14021, 370, 314, 1072, 402, 314, 658, 452, 63, 1838, 64, 1687, 14, 819, 1803, 26, 272, 710, 6709, 543, 14021, 370, 314, 1072, 402, 658, 452, 63, 1838, 2313, 819, 6218, 26, 272, 19021, 26, 982, 658, 22508, 64, 365, 440, 658, 1838, 2313, 523, 408, 523, 340, 1687, 14, 362, 63, 962, 360, 22508, 358, 1137, 283, 1838, 356, 272, 746, 19021, 360, 1944, 6709, 3247, 367, 653, 67, 429, 2422, 21822, 871, 1006, 63, 1838, 2659, 819, 485, 1074, 63, 1782, 63, 10861, 8, 6017, 9, 523, 1967, 63, 6410, 275, 1687, 14, 362, 63, 962, 360, 1507, 63, 6410, 358, 523, 5709, 63, 354, 275, 1687, 14, 362, 63, 962, 360, 5555, 63, 354, 358, 435, 2513, 6017, 7, 819, 543, 4156, 14, 1782, 8, 6017, 14, 1782, 304, 272, 372, 3805, 63, 7966, 429, 63, 1483, 14, 7966, 429, 63, 452, 63, 5270, 8, 267, 1324, 29, 6017, 12, 267, 16773, 534, 1838, 297, 267, 1967, 63, 6410, 29, 1507, 63, 6410, 12, 267, 5709, 63, 354, 29, 5555, 63, 354, 9, 421, 199, 318, 1006, 63, 8788, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 3336, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 21699, 27, 1471, 506, 7943, 489, 370, 18613, 7256, 14, 819, 1803, 26, 272, 3820, 402, 10519, 12, 1924, 543, 314, 3336, 402, 314, 1324, 10519, 12, 2382, 2345, 284, 272, 965, 314, 2011, 2243, 465, 658, 10206, 59, 73, 20336, 523, 408, 523, 372, 485, 4998, 63, 452, 63, 5270, 360, 8788, 297, 10519, 9, 421, 199, 318, 1006, 63, 827, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 1748, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 7114, 27, 1471, 506, 7943, 489, 370, 18613, 7256, 14, 819, 1803, 26, 272, 3820, 402, 10519, 12, 1924, 543, 314, 7481, 402, 314, 1324, 10519, 12, 2382, 2345, 284, 272, 965, 314, 2011, 2243, 465, 658, 10206, 59, 73, 20336, 523, 408, 523, 372, 485, 4998, 63, 452, 63, 5270, 360, 827, 297, 10519, 9, 421, 199, 318, 1006, 63, 988, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 1390, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 7114, 27, 1471, 506, 7943, 489, 370, 18613, 7256, 14, 819, 1803, 26, 272, 3820, 402, 10519, 12, 1924, 543, 314, 5696, 402, 314, 1324, 10519, 12, 2382, 2345, 284, 272, 965, 314, 2011, 2243, 465 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 16452, 367, 18613, 1048, 25982, 5331, 6366, 1808, 653, 5437, 13033, 12698, 429, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5796, 199, 199, 504, 3228, 14, 2828, 14, 7966, 429, 14, 1483, 492, 3805, 63, 7966, 429, 63, 1483, 199, 504, 3228, 14, 2828, 14, 1974, 492, 5077, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2243, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 199, 63, 7966, 429, 63, 1483, 63, 1152, 275, 5077, 14, 912, 63, 411, 63, 4342, 8, 272, 2073, 63, 3422, 14, 362, 63, 515, 63, 475, 63, 31423, 6412, 7966, 429, 63, 1483, 14, 1152, 1333, 421, 199, 318, 1006, 63, 1838, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 3089, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 3089, 27, 1471, 506, 7943, 489, 370, 18613, 7256, 14, 819, 1803, 26, 272, 3820, 402, 10519, 12, 1924, 543, 314, 3089, 402, 314, 1324, 10519, 12, 2382, 2345, 284, 965, 272, 314, 2011, 2243, 465, 658, 10206, 59, 73, 20336, 523, 408, 523, 372, 485, 4998, 63, 452, 63, 5270, 360, 1838, 297, 10519, 9, 421, 199, 32, 1483, 14, 24876, 360, 46, 67, 429, 2422, 21822, 358, 199, 318, 485, 452, 63, 1838, 63, 6017, 8, 411, 12, 7659, 304, 523, 408, 1918, 12661, 367, 658, 452, 63, 1838, 2313, 819, 3033, 26, 272, 1687, 26, 710, 658, 452, 63, 1838, 64, 658, 6044, 64, 626, 781, 787, 26796, 1958, 14, 272, 7659, 26, 19603, 543, 14021, 370, 314, 1072, 402, 314, 658, 452, 63, 1838, 64, 1687, 14, 819, 1803, 26, 272, 710, 6709, 543, 14021, 370, 314, 1072, 402, 658, 452, 63, 1838, 2313, 819, 6218, 26, 272, 19021, 26, 982, 658, 22508, 64, 365, 440, 658, 1838, 2313, 523, 408, 523, 340, 1687, 14, 362, 63, 962, 360, 22508, 358, 1137, 283, 1838, 356, 272, 746, 19021, 360, 1944, 6709, 3247, 367, 653, 67, 429, 2422, 21822, 871, 1006, 63, 1838, 2659, 819, 485, 1074, 63, 1782, 63, 10861, 8, 6017, 9, 523, 1967, 63, 6410, 275, 1687, 14, 362, 63, 962, 360, 1507, 63, 6410, 358, 523, 5709, 63, 354, 275, 1687, 14, 362, 63, 962, 360, 5555, 63, 354, 358, 435, 2513, 6017, 7, 819, 543, 4156, 14, 1782, 8, 6017, 14, 1782, 304, 272, 372, 3805, 63, 7966, 429, 63, 1483, 14, 7966, 429, 63, 452, 63, 5270, 8, 267, 1324, 29, 6017, 12, 267, 16773, 534, 1838, 297, 267, 1967, 63, 6410, 29, 1507, 63, 6410, 12, 267, 5709, 63, 354, 29, 5555, 63, 354, 9, 421, 199, 318, 1006, 63, 8788, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 3336, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 21699, 27, 1471, 506, 7943, 489, 370, 18613, 7256, 14, 819, 1803, 26, 272, 3820, 402, 10519, 12, 1924, 543, 314, 3336, 402, 314, 1324, 10519, 12, 2382, 2345, 284, 272, 965, 314, 2011, 2243, 465, 658, 10206, 59, 73, 20336, 523, 408, 523, 372, 485, 4998, 63, 452, 63, 5270, 360, 8788, 297, 10519, 9, 421, 199, 318, 1006, 63, 827, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 1748, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 7114, 27, 1471, 506, 7943, 489, 370, 18613, 7256, 14, 819, 1803, 26, 272, 3820, 402, 10519, 12, 1924, 543, 314, 7481, 402, 314, 1324, 10519, 12, 2382, 2345, 284, 272, 965, 314, 2011, 2243, 465, 658, 10206, 59, 73, 20336, 523, 408, 523, 372, 485, 4998, 63, 452, 63, 5270, 360, 827, 297, 10519, 9, 421, 199, 318, 1006, 63, 988, 8, 10206, 304, 523, 408, 3407, 282, 769, 402, 10519, 543, 314, 1006, 13, 5270, 1390, 9371, 658, 10206, 2313, 819, 710, 14009, 365, 4224, 543, 376, 1006, 13, 5270, 3439, 12, 880, 340, 1454, 2005, 402, 314, 523, 2138, 10519, 787, 13006, 2066, 314, 14009, 911, 30084, 14, 819, 3033, 26, 272, 10519, 26, 710, 1324, 10519, 9371, 1314, 370, 7114, 27, 1471, 506, 7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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
makelove/OpenCV-Python-Tutorial
官方samples/feature_homography.py
6
2798
#!/usr/bin/env python ''' Feature homography ================== Example of using features2d framework for interactive video homography matching. ORB features and FLANN matcher are used. The actual tracking is implemented by PlaneTracker class in plane_tracker.py Inspired by http://www.youtube.com/watch?v=-ZNYoL8rzPY video: http://www.youtube.com/watch?v=FirtmYcC0Vc Usage ----- feature_homography.py [<video source>] Keys: SPACE - pause video Select a textured planar object to track by drawing a box with a mouse. ''' # Python 2/3 compatibility from __future__ import print_function import numpy as np import cv2 # local modules import video from video import presets import common from common import getsize, draw_keypoints from plane_tracker import PlaneTracker class App: def __init__(self, src): self.cap = video.create_capture(src, presets['book']) self.frame = None self.paused = False self.tracker = PlaneTracker() cv2.namedWindow('plane') self.rect_sel = common.RectSelector('plane', self.on_rect) def on_rect(self, rect): self.tracker.clear() self.tracker.add_target(self.frame, rect) def run(self): while True: playing = not self.paused and not self.rect_sel.dragging if playing or self.frame is None: ret, frame = self.cap.read() if not ret: break self.frame = frame.copy() w, h = getsize(self.frame) vis = np.zeros((h, w*2, 3), np.uint8) vis[:h,:w] = self.frame if len(self.tracker.targets) > 0: target = self.tracker.targets[0] vis[:,w:] = target.image draw_keypoints(vis[:,w:], target.keypoints) x0, y0, x1, y1 = target.rect cv2.rectangle(vis, (x0+w, y0), (x1+w, y1), (0, 255, 0), 2) if playing: tracked = self.tracker.track(self.frame) if len(tracked) > 0: tracked = tracked[0] cv2.polylines(vis, [np.int32(tracked.quad)], True, (255, 255, 255), 2) for (x0, y0), (x1, y1) in zip(np.int32(tracked.p0), np.int32(tracked.p1)): cv2.line(vis, (x0+w, y0), (x1, y1), (0, 255, 0)) draw_keypoints(vis, self.tracker.frame_points) self.rect_sel.draw(vis) cv2.imshow('plane', vis) ch = cv2.waitKey(1) if ch == ord(' '): self.paused = not self.paused if ch == 27: break if __name__ == '__main__': print(__doc__) import sys try: video_src = sys.argv[1] except: video_src = 0 App(video_src).run()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 5968, 2636, 573, 9773, 199, 1280, 389, 199, 199, 9846, 402, 1808, 4534, 18, 68, 10059, 367, 12777, 3991, 2636, 573, 9773, 4877, 14, 199, 726, 34, 4534, 436, 9821, 879, 46, 15990, 787, 1202, 14, 710, 3503, 15161, 365, 6366, 701, 199, 23363, 13652, 1021, 315, 16388, 63, 8877, 14, 647, 199, 199, 13962, 1038, 581, 701, 1455, 921, 1544, 14, 9788, 14, 957, 15, 6821, 31, 86, 4022, 58, 27437, 79, 44, 24, 30841, 4521, 199, 199, 3722, 26, 1455, 921, 1544, 14, 9788, 14, 957, 15, 6821, 31, 86, 29, 28692, 7574, 57, 67, 35, 16, 54, 67, 199, 199, 7692, 199, 9858, 199, 4445, 63, 526, 573, 9773, 14, 647, 24936, 3722, 1350, 19109, 199, 199, 6340, 26, 2043, 16796, 221, 446, 221, 16834, 3991, 199, 199, 5446, 282, 1318, 3297, 8683, 285, 909, 370, 4426, 701, 17455, 282, 5689, 543, 282, 12817, 14, 199, 2344, 199, 199, 3, 2018, 499, 15, 19, 7163, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 6277, 18, 199, 199, 3, 2257, 4621, 199, 646, 3991, 199, 504, 3991, 492, 876, 2193, 199, 646, 2863, 199, 504, 2863, 492, 664, 890, 12, 5954, 63, 498, 3438, 199, 504, 16388, 63, 8877, 492, 510, 24064, 13652, 421, 199, 533, 4693, 26, 272, 347, 636, 826, 721, 277, 12, 2928, 304, 267, 291, 14, 2874, 275, 3991, 14, 981, 63, 12685, 8, 2164, 12, 876, 2193, 459, 2706, 1105, 267, 291, 14, 1943, 275, 488, 267, 291, 14, 22478, 275, 756, 267, 291, 14, 8877, 275, 510, 24064, 13652, 342, 398, 6277, 18, 14, 4579, 4301, 360, 15365, 358, 267, 291, 14, 1201, 63, 5891, 275, 2863, 14, 8252, 11212, 360, 15365, 297, 291, 14, 265, 63, 1201, 9, 339, 347, 641, 63, 1201, 8, 277, 12, 8626, 304, 267, 291, 14, 8877, 14, 3584, 342, 267, 291, 14, 8877, 14, 525, 63, 1375, 8, 277, 14, 1943, 12, 8626, 9, 339, 347, 1255, 8, 277, 304, 267, 1830, 715, 26, 288, 25692, 275, 440, 291, 14, 22478, 436, 440, 291, 14, 1201, 63, 5891, 14, 14479, 1540, 288, 340, 25692, 503, 291, 14, 1943, 365, 488, 26, 355, 2203, 12, 2787, 275, 291, 14, 2874, 14, 739, 342, 355, 340, 440, 2203, 26, 490, 2059, 355, 291, 14, 1943, 275, 2787, 14, 1574, 342, 953, 336, 12, 394, 275, 664, 890, 8, 277, 14, 1943, 9, 288, 21370, 275, 980, 14, 4250, 1332, 72, 12, 336, 10, 18, 12, 650, 395, 980, 14, 1635, 24, 9, 288, 21370, 1491, 72, 12, 26, 87, 61, 275, 291, 14, 1943, 288, 340, 822, 8, 277, 14, 8877, 14, 4684, 9, 690, 378, 26, 355, 1347, 275, 291, 14, 8877, 14, 4684, 59, 16, 61, 355, 21370, 3981, 87, 2938, 275, 1347, 14, 1569, 355, 5954, 63, 498, 3438, 8, 5068, 3981, 87, 8429, 1347, 14, 498, 3438, 9, 355, 671, 16, 12, 612, 16, 12, 671, 17, 12, 612, 17, 275, 1347, 14, 1201, 355, 6277, 18, 14, 19954, 8, 5068, 12, 334, 88, 16, 11, 87, 12, 612, 16, 395, 334, 88, 17, 11, 87, 12, 612, 17, 395, 334, 16, 12, 5450, 12, 378, 395, 499, 9, 953, 340, 25692, 26, 355, 23268, 275, 291, 14, 8877, 14, 3885, 8, 277, 14, 1943, 9, 355, 340, 822, 8, 22586, 9, 690, 378, 26, 490, 23268, 275, 23268, 59, 16, 61, 490, 6277, 18, 14, 6023, 1278, 8, 5068, 12, 359, 1590, 14, 442, 708, 8, 22586, 14, 14567, 4360, 715, 12, 334, 2299, 12, 5450, 12, 5450, 395, 499, 9, 490, 367, 334, 88, 16, 12, 612, 16, 395, 334, 88, 17, 12, 612, 17, 9, 315, 3482, 8, 1590, 14, 442, 708, 8, 22586, 14, 80, 16, 395, 980, 14, 442, 708, 8, 22586, 14, 80, 17, 2298, 717, 6277, 18, 14, 604, 8, 5068, 12, 334, 88, 16, 11, 87, 12, 612, 16, 395, 334, 88, 17, 12, 612, 17, 395, 334, 16, 12, 5450, 12, 378, 430, 288, 5954, 63, 498, 3438, 8, 5068, 12, 291, 14, 8877, 14, 1943, 63, 3438, 9, 953, 291, 14, 1201, 63, 5891, 14, 5485, 8, 5068, 9, 288, 6277, 18, 14, 20413, 360, 15365, 297, 21370, 9, 288, 682, 275, 6277, 18, 14, 2573, 1197, 8, 17, 9, 288, 340, 682, 508, 6206, 360, 18927, 355, 291, 14, 22478, 275, 440, 291, 14, 22478, 288, 340, 682, 508, 8087, 26, 355, 2059, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 870, 3460, 1301, 3368, 339, 492, 984, 272, 862, 26, 267, 3991, 63, 2164, 275, 984, 14, 3020, 59, 17, 61, 272, 871, 26, 267, 3991, 63, 2164, 275, 378, 272, 4693, 8, 3722, 63, 2164, 680, 1065, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 5968, 2636, 573, 9773, 199, 1280, 389, 199, 199, 9846, 402, 1808, 4534, 18, 68, 10059, 367, 12777, 3991, 2636, 573, 9773, 4877, 14, 199, 726, 34, 4534, 436, 9821, 879, 46, 15990, 787, 1202, 14, 710, 3503, 15161, 365, 6366, 701, 199, 23363, 13652, 1021, 315, 16388, 63, 8877, 14, 647, 199, 199, 13962, 1038, 581, 701, 1455, 921, 1544, 14, 9788, 14, 957, 15, 6821, 31, 86, 4022, 58, 27437, 79, 44, 24, 30841, 4521, 199, 199, 3722, 26, 1455, 921, 1544, 14, 9788, 14, 957, 15, 6821, 31, 86, 29, 28692, 7574, 57, 67, 35, 16, 54, 67, 199, 199, 7692, 199, 9858, 199, 4445, 63, 526, 573, 9773, 14, 647, 24936, 3722, 1350, 19109, 199, 199, 6340, 26, 2043, 16796, 221, 446, 221, 16834, 3991, 199, 199, 5446, 282, 1318, 3297, 8683, 285, 909, 370, 4426, 701, 17455, 282, 5689, 543, 282, 12817, 14, 199, 2344, 199, 199, 3, 2018, 499, 15, 19, 7163, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 6277, 18, 199, 199, 3, 2257, 4621, 199, 646, 3991, 199, 504, 3991, 492, 876, 2193, 199, 646, 2863, 199, 504, 2863, 492, 664, 890, 12, 5954, 63, 498, 3438, 199, 504, 16388, 63, 8877, 492, 510, 24064, 13652, 421, 199, 533, 4693, 26, 272, 347, 636, 826, 721, 277, 12, 2928, 304, 267, 291, 14, 2874, 275, 3991, 14, 981, 63, 12685, 8, 2164, 12, 876, 2193, 459, 2706, 1105, 267, 291, 14, 1943, 275, 488, 267, 291, 14, 22478, 275, 756, 267, 291, 14, 8877, 275, 510, 24064, 13652, 342, 398, 6277, 18, 14, 4579, 4301, 360, 15365, 358, 267, 291, 14, 1201, 63, 5891, 275, 2863, 14, 8252, 11212, 360, 15365, 297, 291, 14, 265, 63, 1201, 9, 339, 347, 641, 63, 1201, 8, 277, 12, 8626, 304, 267, 291, 14, 8877, 14, 3584, 342, 267, 291, 14, 8877, 14, 525, 63, 1375, 8, 277, 14, 1943, 12, 8626, 9, 339, 347, 1255, 8, 277, 304, 267, 1830, 715, 26, 288, 25692, 275, 440, 291, 14, 22478, 436, 440, 291, 14, 1201, 63, 5891, 14, 14479, 1540, 288, 340, 25692, 503, 291, 14, 1943, 365, 488, 26, 355, 2203, 12, 2787, 275, 291, 14, 2874, 14, 739, 342, 355, 340, 440, 2203, 26, 490, 2059, 355, 291, 14, 1943, 275, 2787, 14, 1574, 342, 953, 336, 12, 394, 275, 664, 890, 8, 277, 14, 1943, 9, 288, 21370, 275, 980, 14, 4250, 1332, 72, 12, 336, 10, 18, 12, 650, 395, 980, 14, 1635, 24, 9, 288, 21370, 1491, 72, 12, 26, 87, 61, 275, 291, 14, 1943, 288, 340, 822, 8, 277, 14, 8877, 14, 4684, 9, 690, 378, 26, 355, 1347, 275, 291, 14, 8877, 14, 4684, 59, 16, 61, 355, 21370, 3981, 87, 2938, 275, 1347, 14, 1569, 355, 5954, 63, 498, 3438, 8, 5068, 3981, 87, 8429, 1347, 14, 498, 3438, 9, 355, 671, 16, 12, 612, 16, 12, 671, 17, 12, 612, 17, 275, 1347, 14, 1201, 355, 6277, 18, 14, 19954, 8, 5068, 12, 334, 88, 16, 11, 87, 12, 612, 16, 395, 334, 88, 17, 11, 87, 12, 612, 17, 395, 334, 16, 12, 5450, 12, 378, 395, 499, 9, 953, 340, 25692, 26, 355, 23268, 275, 291, 14, 8877, 14, 3885, 8, 277, 14, 1943, 9, 355, 340, 822, 8, 22586, 9, 690, 378, 26, 490, 23268, 275, 23268, 59, 16, 61, 490, 6277, 18, 14, 6023, 1278, 8, 5068, 12, 359, 1590, 14, 442, 708, 8, 22586, 14, 14567, 4360, 715, 12, 334, 2299, 12, 5450, 12, 5450, 395, 499, 9, 490, 367, 334, 88, 16, 12, 612, 16, 395, 334, 88, 17, 12, 612, 17, 9, 315, 3482, 8, 1590, 14, 442, 708, 8, 22586, 14, 80, 16, 395, 980, 14, 442, 708, 8, 22586, 14, 80, 17, 2298, 717, 6277, 18, 14, 604, 8, 5068, 12, 334, 88, 16, 11, 87, 12, 612, 16, 395, 334, 88, 17, 12, 612, 17, 395, 334, 16, 12, 5450, 12, 378, 430, 288, 5954, 63, 498, 3438, 8, 5068, 12, 291, 14, 8877, 14, 1943, 63, 3438, 9, 953, 291, 14, 1201, 63, 5891, 14, 5485, 8, 5068, 9, 288, 6277, 18, 14, 20413, 360, 15365, 297, 21370, 9, 288, 682, 275, 6277, 18, 14, 2573, 1197, 8, 17, 9, 288, 340, 682, 508, 6206, 360, 18927, 355, 291, 14, 22478, 275, 440, 291, 14, 22478, 288, 340, 682, 508, 8087, 26, 355, 2059, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 870, 3460, 1301, 3368, 339, 492, 984, 272, 862, 26, 267, 3991, 63, 2164, 275, 984, 14, 3020, 59, 17, 61, 272, 871, 26, 267, 3991, 63, 2164, 275, 378, 272, 4693, 8, 3722, 63, 2164, 680, 1065, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1,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ibble/Embedded-Systems-Assignment
EmbeddedSystems.Applications/EmbeddedSystems.Client/jsoncpp-src-0.6.0-rc2/scons-local-1.2.0/SCons/Tool/tlib.py
12
1761
"""SCons.Tool.tlib XXX """ # # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation # # 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. # __revision__ = "src/engine/SCons/Tool/tlib.py 3842 2008/12/20 22:59:52 scons" import SCons.Tool import SCons.Tool.bcc32 import SCons.Util def generate(env): SCons.Tool.bcc32.findIt('tlib', env) """Add Builders and construction variables for ar to an Environment.""" SCons.Tool.createStaticLibBuilder(env) env['AR'] = 'tlib' env['ARFLAGS'] = SCons.Util.CLVar('') env['ARCOM'] = '$AR $TARGET $ARFLAGS /a $SOURCES' env['LIBPREFIX'] = '' env['LIBSUFFIX'] = '.lib' def exists(env): return SCons.Tool.bcc32.findIt('tlib', env)
mit
[ 624, 18521, 14, 5157, 14, 84, 773, 199, 199, 13933, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 84, 773, 14, 647, 650, 18931, 9079, 15, 713, 15, 1165, 6928, 26, 1427, 26, 2528, 31551, 2, 199, 199, 646, 8218, 14, 5157, 199, 646, 8218, 14, 5157, 14, 21976, 708, 199, 646, 8218, 14, 9562, 199, 199, 318, 3550, 8, 1813, 304, 272, 8218, 14, 5157, 14, 21976, 708, 14, 1623, 7940, 360, 84, 773, 297, 2589, 9, 272, 408, 1123, 19286, 83, 436, 14538, 2860, 367, 601, 370, 376, 9711, 1041, 272, 8218, 14, 5157, 14, 981, 9278, 4728, 6437, 8, 1813, 9, 272, 2589, 459, 689, 418, 3515, 275, 283, 84, 773, 7, 272, 2589, 459, 689, 4831, 418, 258, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 689, 11265, 418, 755, 275, 4505, 689, 2672, 9268, 2672, 689, 4831, 1182, 65, 2672, 25744, 7, 272, 2589, 459, 5617, 6351, 418, 257, 275, 2125, 272, 2589, 459, 5617, 12273, 418, 257, 275, 1987, 773, 7, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 8218, 14, 5157, 14, 21976, 708, 14, 1623, 7940, 360, 84, 773, 297, 2589, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 18521, 14, 5157, 14, 84, 773, 199, 199, 13933, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 84, 773, 14, 647, 650, 18931, 9079, 15, 713, 15, 1165, 6928, 26, 1427, 26, 2528, 31551, 2, 199, 199, 646, 8218, 14, 5157, 199, 646, 8218, 14, 5157, 14, 21976, 708, 199, 646, 8218, 14, 9562, 199, 199, 318, 3550, 8, 1813, 304, 272, 8218, 14, 5157, 14, 21976, 708, 14, 1623, 7940, 360, 84, 773, 297, 2589, 9, 272, 408, 1123, 19286, 83, 436, 14538, 2860, 367, 601, 370, 376, 9711, 1041, 272, 8218, 14, 5157, 14, 981, 9278, 4728, 6437, 8, 1813, 9, 272, 2589, 459, 689, 418, 3515, 275, 283, 84, 773, 7, 272, 2589, 459, 689, 4831, 418, 258, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 689, 11265, 418, 755, 275, 4505, 689, 2672, 9268, 2672, 689, 4831, 1182, 65, 2672, 25744, 7, 272, 2589, 459, 5617, 6351, 418, 257, 275, 2125, 272, 2589, 459, 5617, 12273, 418, 257, 275, 1987, 773, 7, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 8218, 14, 5157, 14, 21976, 708, 14, 1623, 7940, 360, 84, 773, 297, 2589, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Azure/azure-sdk-for-python
sdk/network/azure-mgmt-network/azure/mgmt/network/v2020_04_01/operations/_web_application_firewall_policies_operations.py
1
20908
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class WebApplicationFirewallPoliciesOperations(object): """WebApplicationFirewallPoliciesOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~azure.mgmt.network.v2020_04_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ models = _models def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config def list( self, resource_group_name, # type: str **kwargs # type: Any ): # type: (...) -> Iterable["_models.WebApplicationFirewallPolicyListResult"] """Lists all of the protection policies within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebApplicationFirewallPolicyListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.network.v2020_04_01.models.WebApplicationFirewallPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebApplicationFirewallPolicyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-04-01" accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('WebApplicationFirewallPolicyListResult', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies'} # type: ignore def list_all( self, **kwargs # type: Any ): # type: (...) -> Iterable["_models.WebApplicationFirewallPolicyListResult"] """Gets all the WAF policies in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebApplicationFirewallPolicyListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.network.v2020_04_01.models.WebApplicationFirewallPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebApplicationFirewallPolicyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-04-01" accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.list_all.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('WebApplicationFirewallPolicyListResult', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged( get_next, extract_data ) list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies'} # type: ignore def get( self, resource_group_name, # type: str policy_name, # type: str **kwargs # type: Any ): # type: (...) -> "_models.WebApplicationFirewallPolicy" """Retrieve protection policy with specified name within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param policy_name: The name of the policy. :type policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: WebApplicationFirewallPolicy, or the result of cls(response) :rtype: ~azure.mgmt.network.v2020_04_01.models.WebApplicationFirewallPolicy :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebApplicationFirewallPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-04-01" accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'policyName': self._serialize.url("policy_name", policy_name, 'str', max_length=128, min_length=0), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('WebApplicationFirewallPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/{policyName}'} # type: ignore def create_or_update( self, resource_group_name, # type: str policy_name, # type: str parameters, # type: "_models.WebApplicationFirewallPolicy" **kwargs # type: Any ): # type: (...) -> "_models.WebApplicationFirewallPolicy" """Creates or update policy with specified rule set name within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param policy_name: The name of the policy. :type policy_name: str :param parameters: Policy to be created. :type parameters: ~azure.mgmt.network.v2020_04_01.models.WebApplicationFirewallPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: WebApplicationFirewallPolicy, or the result of cls(response) :rtype: ~azure.mgmt.network.v2020_04_01.models.WebApplicationFirewallPolicy :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebApplicationFirewallPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-04-01" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'policyName': self._serialize.url("policy_name", policy_name, 'str', max_length=128, min_length=0), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'WebApplicationFirewallPolicy') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('WebApplicationFirewallPolicy', pipeline_response) if response.status_code == 201: deserialized = self._deserialize('WebApplicationFirewallPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/{policyName}'} # type: ignore def _delete_initial( self, resource_group_name, # type: str policy_name, # type: str **kwargs # type: Any ): # type: (...) -> None cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-04-01" accept = "application/json" # Construct URL url = self._delete_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'policyName': self._serialize.url("policy_name", policy_name, 'str', max_length=128, min_length=0), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/{policyName}'} # type: ignore def begin_delete( self, resource_group_name, # type: str policy_name, # type: str **kwargs # type: Any ): # type: (...) -> LROPoller[None] """Deletes Policy. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param policy_name: The name of the policy. :type policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: Pass in True if you'd like the ARMPolling polling method, False for no polling, or your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, policy_name=policy_name, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'policyName': self._serialize.url("policy_name", policy_name, 'str', max_length=128, min_length=0), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/{policyName}'} # type: ignore
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 4190, 2556, 14, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 31904, 14, 199, 3, 24775, 199, 504, 14090, 492, 11511, 63, 8936, 1206, 199, 646, 3598, 199, 199, 504, 13601, 14, 1018, 14, 3924, 492, 6810, 27942, 12, 6183, 547, 12, 7337, 23839, 12, 28783, 12, 2341, 63, 705, 199, 504, 13601, 14, 1018, 14, 31691, 492, 7020, 16769, 199, 504, 13601, 14, 1018, 14, 7379, 492, 19090, 2364, 199, 504, 13601, 14, 1018, 14, 7379, 14, 5545, 492, 20730, 12, 6183, 199, 504, 13601, 14, 1018, 14, 17154, 492, 491, 26898, 12, 3091, 28588, 12, 8467, 2983, 3767, 199, 504, 13601, 14, 9752, 14, 1018, 14, 3924, 492, 27155, 547, 3484, 199, 504, 13601, 14, 9752, 14, 1018, 14, 17154, 14, 5362, 63, 17154, 492, 4160, 1658, 393, 2983, 199, 199, 504, 2508, 492, 1709, 465, 485, 992, 199, 199, 692, 11511, 63, 8936, 1206, 26, 272, 327, 4287, 26, 3507, 29, 8618, 13, 646, 12, 10335, 11330, 13, 12775, 272, 687, 14090, 492, 6184, 12, 16975, 12, 7448, 12, 8307, 12, 19937, 12, 4879, 12, 2434, 5894, 12, 15961, 339, 377, 275, 2434, 5894, 360, 52, 358, 272, 28793, 804, 275, 4879, 59, 16410, 9046, 17562, 2364, 59, 10441, 12, 6183, 467, 377, 12, 7448, 59, 495, 12, 6184, 2365, 6184, 2677, 199, 199, 533, 6001, 5039, 24260, 27079, 12929, 8, 785, 304, 272, 408, 5926, 5039, 24260, 27079, 12929, 5331, 14, 339, 2047, 1077, 440, 17321, 642, 1021, 5370, 14, 15345, 12, 1265, 1077, 1218, 282, 6810, 1256, 626, 272, 9034, 2335, 652, 367, 1265, 436, 6554, 397, 652, 465, 376, 2225, 14, 339, 520, 7725, 1709, 26, 24777, 370, 1402, 3992, 1202, 315, 642, 3439, 1572, 14, 272, 520, 466, 1709, 26, 6146, 9078, 14, 9752, 14, 1200, 14, 86, 13934, 63, 966, 63, 614, 14, 992, 272, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 909, 1402, 30237, 14, 272, 408, 339, 1709, 275, 485, 992, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 304, 267, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 267, 291, 423, 888, 275, 1101, 339, 347, 769, 8, 267, 291, 12, 267, 2073, 63, 923, 63, 354, 12, 221, 327, 730, 26, 620, 267, 1011, 958, 221, 327, 730, 26, 6184, 272, 3461, 267, 327, 730, 26, 30934, 1035, 19937, 18524, 992, 14, 5926, 5039, 24260, 4845, 27577, 937, 267, 408, 15116, 1006, 402, 314, 23977, 14118, 4453, 282, 2073, 1572, 14, 398, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 536, 402, 314, 2073, 1572, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 6691, 4550, 843, 26, 437, 3537, 730, 503, 805, 626, 911, 506, 3032, 314, 4125, 1177, 267, 520, 1107, 26, 1626, 6122, 2839, 1256, 402, 1902, 6001, 5039, 24260, 4845, 27577, 503, 314, 754, 402, 843, 8, 1310, 9, 267, 520, 4500, 26, 6146, 9078, 14, 1018, 14, 31691, 14, 2081, 16769, 19911, 9078, 14, 9752, 14, 1200, 14, 86, 13934, 63, 966, 63, 614, 14, 992, 14, 5926, 5039, 24260, 4845, 27577, 61, 267, 520, 3536, 26, 6146, 9078, 14, 1018, 14, 3924, 14, 16287, 547, 267, 408, 267, 843, 275, 2074, 14, 1935, 360, 1886, 297, 488, 9, 221, 327, 730, 26, 28793, 804, 18524, 992, 14, 5926, 5039, 24260, 4845, 27577, 937, 267, 1125, 63, 1130, 275, 469, 288, 13952, 26, 6810, 27942, 12, 7901, 26, 28783, 12, 21292, 26, 7337, 23839, 267, 789, 267, 1125, 63, 1130, 14, 873, 8, 958, 14, 1935, 360, 705, 63, 1130, 297, 17003, 267, 2986, 63, 1023, 275, 298, 13934, 13, 966, 13, 614, 2, 267, 4729, 275, 298, 3578, 15, 1001, 2, 398, 347, 9275, 63, 1069, 8, 2184, 63, 1073, 29, 403, 304, 288, 327, 9215, 2323, 288, 1406, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 288, 1406, 63, 3214, 459, 8422, 418, 275, 291, 423, 3549, 14, 1291, 480, 5694, 401, 4729, 12, 283, 495, 358, 953, 340, 440, 2163, 63, 1073, 26, 355, 327, 9215, 2851, 355, 1166, 275, 291, 14, 513, 14, 2343, 459, 633, 418, 221, 327, 730, 26, 3686, 355, 931, 63, 908, 63, 4958, 275, 469, 490, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 490, 283, 20505, 356, 291, 423, 3549, 14, 633, 480, 277, 423, 888, 14, 6645, 63, 344, 401, 291, 423, 888, 14, 6645, 63, 344, 12, 283, 495, 659, 355, 789, 355, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 355, 327, 9215, 2633, 355, 1827, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 355, 1827, 63, 3214, 459, 1246, 13, 1023, 418, 275, 291, 423, 3549, 14, 1131, 480, 1246, 63, 1023, 401, 2986, 63, 1023, 12, 283, 495, 358, 2234, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 9, 288, 587, 26, 355, 1166, 275, 2163, 63, 1073, 355, 1827, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 355, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 9, 288, 372, 1056, 398, 347, 5536, 63, 576, 8, 7379, 63, 1310, 304, 288, 13256, 275, 291, 423, 11143, 360, 5926, 5039, 24260, 4845, 27577, 297, 7679, 63, 1310, 9, 288, 769, 63, 1618, 63, 6086, 275, 13256, 14, 585, 288, 340, 843 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 4190, 2556, 14, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 31904, 14, 199, 3, 24775, 199, 504, 14090, 492, 11511, 63, 8936, 1206, 199, 646, 3598, 199, 199, 504, 13601, 14, 1018, 14, 3924, 492, 6810, 27942, 12, 6183, 547, 12, 7337, 23839, 12, 28783, 12, 2341, 63, 705, 199, 504, 13601, 14, 1018, 14, 31691, 492, 7020, 16769, 199, 504, 13601, 14, 1018, 14, 7379, 492, 19090, 2364, 199, 504, 13601, 14, 1018, 14, 7379, 14, 5545, 492, 20730, 12, 6183, 199, 504, 13601, 14, 1018, 14, 17154, 492, 491, 26898, 12, 3091, 28588, 12, 8467, 2983, 3767, 199, 504, 13601, 14, 9752, 14, 1018, 14, 3924, 492, 27155, 547, 3484, 199, 504, 13601, 14, 9752, 14, 1018, 14, 17154, 14, 5362, 63, 17154, 492, 4160, 1658, 393, 2983, 199, 199, 504, 2508, 492, 1709, 465, 485, 992, 199, 199, 692, 11511, 63, 8936, 1206, 26, 272, 327, 4287, 26, 3507, 29, 8618, 13, 646, 12, 10335, 11330, 13, 12775, 272, 687, 14090, 492, 6184, 12, 16975, 12, 7448, 12, 8307, 12, 19937, 12, 4879, 12, 2434, 5894, 12, 15961, 339, 377, 275, 2434, 5894, 360, 52, 358, 272, 28793, 804, 275, 4879, 59, 16410, 9046, 17562, 2364, 59, 10441, 12, 6183, 467, 377, 12, 7448, 59, 495, 12, 6184, 2365, 6184, 2677, 199, 199, 533, 6001, 5039, 24260, 27079, 12929, 8, 785, 304, 272, 408, 5926, 5039, 24260, 27079, 12929, 5331, 14, 339, 2047, 1077, 440, 17321, 642, 1021, 5370, 14, 15345, 12, 1265, 1077, 1218, 282, 6810, 1256, 626, 272, 9034, 2335, 652, 367, 1265, 436, 6554, 397, 652, 465, 376, 2225, 14, 339, 520, 7725, 1709, 26, 24777, 370, 1402, 3992, 1202, 315, 642, 3439, 1572, 14, 272, 520, 466, 1709, 26, 6146, 9078, 14, 9752, 14, 1200, 14, 86, 13934, 63, 966, 63, 614, 14, 992, 272, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 909, 1402, 30237, 14, 272, 408, 339, 1709, 275, 485, 992, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 304, 267, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 267, 291, 423, 888, 275, 1101, 339, 347, 769, 8, 267, 291, 12, 267, 2073, 63, 923, 63, 354, 12, 221, 327, 730, 26, 620, 267, 1011, 958, 221, 327, 730, 26, 6184, 272, 3461, 267, 327, 730, 26, 30934, 1035, 19937, 18524, 992, 14, 5926, 5039, 24260, 4845, 27577, 937, 267, 408, 15116, 1006, 402, 314, 23977, 14118, 4453, 282, 2073, 1572, 14, 398, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 536, 402, 314, 2073, 1572, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 6691, 4550, 843, 26, 437, 3537, 730, 503, 805, 626, 911, 506, 3032, 314, 4125, 1177, 267, 520, 1107, 26, 1626, 6122, 2839, 1256, 402, 1902, 6001, 5039, 24260, 4845, 27577, 503, 314, 754, 402, 843, 8, 1310, 9, 267, 520, 4500, 26, 6146, 9078, 14, 1018, 14, 31691, 14, 2081, 16769, 19911, 9078, 14, 9752, 14, 1200, 14, 86, 13934, 63, 966, 63, 614, 14, 992, 14, 5926, 5039, 24260, 4845, 27577, 61, 267, 520, 3536, 26, 6146, 9078, 14, 1018, 14, 3924, 14, 16287, 547, 267, 408, 267, 843, 275, 2074, 14, 1935, 360, 1886, 297, 488, 9, 221, 327, 730, 26, 28793, 804, 18524, 992, 14, 5926, 5039, 24260, 4845, 27577, 937, 267, 1125, 63, 1130, 275, 469, 288, 13952, 26, 6810, 27942, 12, 7901, 26, 28783, 12, 21292, 26, 7337, 23839, 267, 789, 267, 1125, 63, 1130, 14, 873, 8, 958, 14, 1935, 360, 705, 63, 1130, 297, 17003, 267, 2986, 63, 1023, 275, 298, 13934, 13, 966, 13, 614, 2, 267, 4729, 275, 298, 3578, 15, 1001, 2, 398, 347, 9275, 63, 1069, 8, 2184, 63, 1073, 29, 403, 304, 288, 327, 9215, 2323, 288, 1406, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 288, 1406, 63, 3214, 459, 8422, 418, 275, 291, 423, 3549, 14, 1291, 480, 5694, 401, 4729, 12, 283, 495, 358, 953, 340, 440, 2163, 63, 1073, 26, 355, 327, 9215, 2851, 355, 1166, 275, 291, 14, 513, 14, 2343, 459, 633, 418, 221, 327, 730, 26, 3686, 355, 931, 63, 908, 63, 4958, 275, 469, 490, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 490, 283, 20505, 356, 291, 423, 3549, 14, 633, 480, 277, 423, 888, 14, 6645, 63, 344, 401, 291, 423, 888, 14, 6645, 63, 344, 12, 283, 495, 659, 355, 789, 355, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 355, 327, 9215, 2633, 355, 1827, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 355, 1827, 63, 3214, 459, 1246, 13, 1023, 418, 275, 291, 423, 3549, 14, 1131, 480, 1246, 63, 1023, 401, 2986, 63, 1023, 12, 283, 495, 358, 2234, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 9, 288, 587, 26, 355, 1166, 275, 2163, 63, 1073, 355, 1827, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 355, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 9, 288, 372, 1056, 398, 347, 5536, 63, 576, 8, 7379, 63, 1310, 304, 288, 13256, 275, 291, 423, 11143, 360, 5926, 5039, 24260, 4845, 27577, 297, 7679, 63, 1310, 9, 288, 769, 63, 1618, 63, 6086, 275, 13256, 14, 585, 288, 340, 843, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
beckastar/django
django/contrib/auth/tests/test_forms.py
13
19785
from __future__ import unicode_literals import os import re from django import forms from django.contrib.auth import get_user_model from django.contrib.auth.models import User from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm, PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm, ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget) from django.contrib.auth.tests.utils import skipIfCustomUser from django.core import mail from django.forms.fields import Field, CharField from django.test import TestCase, override_settings from django.utils.encoding import force_text from django.utils._os import upath from django.utils import translation from django.utils.text import capfirst from django.utils.translation import ugettext as _ @skipIfCustomUser @override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class UserCreationFormTest(TestCase): fixtures = ['authtestdata.json'] def test_user_already_exists(self): data = { 'username': 'testclient', 'password1': 'test123', 'password2': 'test123', } form = UserCreationForm(data) self.assertFalse(form.is_valid()) self.assertEqual(form["username"].errors, [force_text(form.error_messages['duplicate_username'])]) def test_invalid_data(self): data = { 'username': 'jsmith!', 'password1': 'test123', 'password2': 'test123', } form = UserCreationForm(data) self.assertFalse(form.is_valid()) self.assertEqual(form["username"].errors, [force_text(form.fields['username'].error_messages['invalid'])]) def test_password_verification(self): # The verification password is incorrect. data = { 'username': 'jsmith', 'password1': 'test123', 'password2': 'test', } form = UserCreationForm(data) self.assertFalse(form.is_valid()) self.assertEqual(form["password2"].errors, [force_text(form.error_messages['password_mismatch'])]) def test_both_passwords(self): # One (or both) passwords weren't given data = {'username': 'jsmith'} form = UserCreationForm(data) required_error = [force_text(Field.default_error_messages['required'])] self.assertFalse(form.is_valid()) self.assertEqual(form['password1'].errors, required_error) self.assertEqual(form['password2'].errors, required_error) data['password2'] = 'test123' form = UserCreationForm(data) self.assertFalse(form.is_valid()) self.assertEqual(form['password1'].errors, required_error) self.assertEqual(form['password2'].errors, []) def test_success(self): # The success case. data = { 'username': 'jsmith@example.com', 'password1': 'test123', 'password2': 'test123', } form = UserCreationForm(data) self.assertTrue(form.is_valid()) u = form.save() self.assertEqual(repr(u), '<User: jsmith@example.com>') @skipIfCustomUser @override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AuthenticationFormTest(TestCase): fixtures = ['authtestdata.json'] def test_invalid_username(self): # The user submits an invalid username. data = { 'username': 'jsmith_does_not_exist', 'password': 'test123', } form = AuthenticationForm(None, data) self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), [force_text(form.error_messages['invalid_login'] % { 'username': User._meta.get_field('username').verbose_name })]) def test_inactive_user(self): # The user is inactive. data = { 'username': 'inactive', 'password': 'password', } form = AuthenticationForm(None, data) self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), [force_text(form.error_messages['inactive'])]) def test_inactive_user_i18n(self): with self.settings(USE_I18N=True), translation.override('pt-br', deactivate=True): # The user is inactive. data = { 'username': 'inactive', 'password': 'password', } form = AuthenticationForm(None, data) self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), [force_text(form.error_messages['inactive'])]) def test_custom_login_allowed_policy(self): # The user is inactive, but our custom form policy allows them to log in. data = { 'username': 'inactive', 'password': 'password', } class AuthenticationFormWithInactiveUsersOkay(AuthenticationForm): def confirm_login_allowed(self, user): pass form = AuthenticationFormWithInactiveUsersOkay(None, data) self.assertTrue(form.is_valid()) # If we want to disallow some logins according to custom logic, # we should raise a django.forms.ValidationError in the form. class PickyAuthenticationForm(AuthenticationForm): def confirm_login_allowed(self, user): if user.username == "inactive": raise forms.ValidationError(_("This user is disallowed.")) raise forms.ValidationError(_("Sorry, nobody's allowed in.")) form = PickyAuthenticationForm(None, data) self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), ['This user is disallowed.']) data = { 'username': 'testclient', 'password': 'password', } form = PickyAuthenticationForm(None, data) self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), ["Sorry, nobody's allowed in."]) def test_success(self): # The success case data = { 'username': 'testclient', 'password': 'password', } form = AuthenticationForm(None, data) self.assertTrue(form.is_valid()) self.assertEqual(form.non_field_errors(), []) def test_username_field_label(self): class CustomAuthenticationForm(AuthenticationForm): username = CharField(label="Name", max_length=75) form = CustomAuthenticationForm() self.assertEqual(form['username'].label, "Name") def test_username_field_label_not_set(self): class CustomAuthenticationForm(AuthenticationForm): username = CharField() form = CustomAuthenticationForm() UserModel = get_user_model() username_field = UserModel._meta.get_field(UserModel.USERNAME_FIELD) self.assertEqual(form.fields['username'].label, capfirst(username_field.verbose_name)) def test_username_field_label_empty_string(self): class CustomAuthenticationForm(AuthenticationForm): username = CharField(label='') form = CustomAuthenticationForm() self.assertEqual(form.fields['username'].label, "") @skipIfCustomUser @override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class SetPasswordFormTest(TestCase): fixtures = ['authtestdata.json'] def test_password_verification(self): # The two new passwords do not match. user = User.objects.get(username='testclient') data = { 'new_password1': 'abc123', 'new_password2': 'abc', } form = SetPasswordForm(user, data) self.assertFalse(form.is_valid()) self.assertEqual(form["new_password2"].errors, [force_text(form.error_messages['password_mismatch'])]) def test_success(self): user = User.objects.get(username='testclient') data = { 'new_password1': 'abc123', 'new_password2': 'abc123', } form = SetPasswordForm(user, data) self.assertTrue(form.is_valid()) @skipIfCustomUser @override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class PasswordChangeFormTest(TestCase): fixtures = ['authtestdata.json'] def test_incorrect_password(self): user = User.objects.get(username='testclient') data = { 'old_password': 'test', 'new_password1': 'abc123', 'new_password2': 'abc123', } form = PasswordChangeForm(user, data) self.assertFalse(form.is_valid()) self.assertEqual(form["old_password"].errors, [force_text(form.error_messages['password_incorrect'])]) def test_password_verification(self): # The two new passwords do not match. user = User.objects.get(username='testclient') data = { 'old_password': 'password', 'new_password1': 'abc123', 'new_password2': 'abc', } form = PasswordChangeForm(user, data) self.assertFalse(form.is_valid()) self.assertEqual(form["new_password2"].errors, [force_text(form.error_messages['password_mismatch'])]) def test_success(self): # The success case. user = User.objects.get(username='testclient') data = { 'old_password': 'password', 'new_password1': 'abc123', 'new_password2': 'abc123', } form = PasswordChangeForm(user, data) self.assertTrue(form.is_valid()) def test_field_order(self): # Regression test - check the order of fields: user = User.objects.get(username='testclient') self.assertEqual(list(PasswordChangeForm(user, {}).fields), ['old_password', 'new_password1', 'new_password2']) @skipIfCustomUser @override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class UserChangeFormTest(TestCase): fixtures = ['authtestdata.json'] def test_username_validity(self): user = User.objects.get(username='testclient') data = {'username': 'not valid'} form = UserChangeForm(data, instance=user) self.assertFalse(form.is_valid()) self.assertEqual(form['username'].errors, [force_text(form.fields['username'].error_messages['invalid'])]) def test_bug_14242(self): # A regression test, introduce by adding an optimization for the # UserChangeForm. class MyUserForm(UserChangeForm): def __init__(self, *args, **kwargs): super(MyUserForm, self).__init__(*args, **kwargs) self.fields['groups'].help_text = 'These groups give users different permissions' class Meta(UserChangeForm.Meta): fields = ('groups',) # Just check we can create it MyUserForm({}) def test_unsuable_password(self): user = User.objects.get(username='empty_password') user.set_unusable_password() user.save() form = UserChangeForm(instance=user) self.assertIn(_("No password set."), form.as_table()) def test_bug_17944_empty_password(self): user = User.objects.get(username='empty_password') form = UserChangeForm(instance=user) self.assertIn(_("No password set."), form.as_table()) def test_bug_17944_unmanageable_password(self): user = User.objects.get(username='unmanageable_password') form = UserChangeForm(instance=user) self.assertIn(_("Invalid password format or unknown hashing algorithm."), form.as_table()) def test_bug_17944_unknown_password_algorithm(self): user = User.objects.get(username='unknown_password') form = UserChangeForm(instance=user) self.assertIn(_("Invalid password format or unknown hashing algorithm."), form.as_table()) def test_bug_19133(self): "The change form does not return the password value" # Use the form to construct the POST data user = User.objects.get(username='testclient') form_for_data = UserChangeForm(instance=user) post_data = form_for_data.initial # The password field should be readonly, so anything # posted here should be ignored; the form will be # valid, and give back the 'initial' value for the # password field. post_data['password'] = 'new password' form = UserChangeForm(instance=user, data=post_data) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data['password'], 'sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161') def test_bug_19349_bound_password_field(self): user = User.objects.get(username='testclient') form = UserChangeForm(data={}, instance=user) # When rendering the bound password field, # ReadOnlyPasswordHashWidget needs the initial # value to render correctly self.assertEqual(form.initial['password'], form['password'].value()) @skipIfCustomUser @override_settings( PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',), TEMPLATE_DIRS=( os.path.join(os.path.dirname(upath(__file__)), 'templates'), ), USE_TZ=False, ) class PasswordResetFormTest(TestCase): fixtures = ['authtestdata.json'] def create_dummy_user(self): """ Create a user and return a tuple (user_object, username, email). """ username = 'jsmith' email = 'jsmith@example.com' user = User.objects.create_user(username, email, 'test123') return (user, username, email) def test_invalid_email(self): data = {'email': 'not valid'} form = PasswordResetForm(data) self.assertFalse(form.is_valid()) self.assertEqual(form['email'].errors, [_('Enter a valid email address.')]) def test_nonexistant_email(self): """ Test nonexistant email address. This should not fail because it would expose information about registered users. """ data = {'email': 'foo@bar.com'} form = PasswordResetForm(data) self.assertTrue(form.is_valid()) self.assertEqual(len(mail.outbox), 0) def test_cleaned_data(self): (user, username, email) = self.create_dummy_user() data = {'email': email} form = PasswordResetForm(data) self.assertTrue(form.is_valid()) form.save(domain_override='example.com') self.assertEqual(form.cleaned_data['email'], email) self.assertEqual(len(mail.outbox), 1) def test_custom_email_subject(self): data = {'email': 'testclient@example.com'} form = PasswordResetForm(data) self.assertTrue(form.is_valid()) # Since we're not providing a request object, we must provide a # domain_override to prevent the save operation from failing in the # potential case where contrib.sites is not installed. Refs #16412. form.save(domain_override='example.com') self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].subject, 'Custom password reset on example.com') def test_preserve_username_case(self): """ Preserve the case of the user name (before the @ in the email address) when creating a user (#5605). """ user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test') self.assertEqual(user.email, 'tesT@example.com') user = User.objects.create_user('forms_test3', 'tesT', 'test') self.assertEqual(user.email, 'tesT') def test_inactive_user(self): """ Test that inactive user cannot receive password reset email. """ (user, username, email) = self.create_dummy_user() user.is_active = False user.save() form = PasswordResetForm({'email': email}) self.assertTrue(form.is_valid()) form.save() self.assertEqual(len(mail.outbox), 0) def test_unusable_password(self): user = User.objects.create_user('testuser', 'test@example.com', 'test') data = {"email": "test@example.com"} form = PasswordResetForm(data) self.assertTrue(form.is_valid()) user.set_unusable_password() user.save() form = PasswordResetForm(data) # The form itself is valid, but no email is sent self.assertTrue(form.is_valid()) form.save() self.assertEqual(len(mail.outbox), 0) def test_save_plaintext_email(self): """ Test the PasswordResetForm.save() method with no html_email_template_name parameter passed in. Test to ensure original behavior is unchanged after the parameter was added. """ (user, username, email) = self.create_dummy_user() form = PasswordResetForm({"email": email}) self.assertTrue(form.is_valid()) form.save() self.assertEqual(len(mail.outbox), 1) message = mail.outbox[0].message() self.assertFalse(message.is_multipart()) self.assertEqual(message.get_content_type(), 'text/plain') self.assertEqual(message.get('subject'), 'Custom password reset on example.com') self.assertEqual(len(mail.outbox[0].alternatives), 0) self.assertEqual(message.get_all('to'), [email]) self.assertTrue(re.match(r'^http://example.com/reset/[\w+/-]', message.get_payload())) def test_save_html_email_template_name(self): """ Test the PasswordResetFOrm.save() method with html_email_template_name parameter specified. Test to ensure that a multipart email is sent with both text/plain and text/html parts. """ (user, username, email) = self.create_dummy_user() form = PasswordResetForm({"email": email}) self.assertTrue(form.is_valid()) form.save(html_email_template_name='registration/html_password_reset_email.html') self.assertEqual(len(mail.outbox), 1) self.assertEqual(len(mail.outbox[0].alternatives), 1) message = mail.outbox[0].message() self.assertEqual(message.get('subject'), 'Custom password reset on example.com') self.assertEqual(len(message.get_payload()), 2) self.assertTrue(message.is_multipart()) self.assertEqual(message.get_payload(0).get_content_type(), 'text/plain') self.assertEqual(message.get_payload(1).get_content_type(), 'text/html') self.assertEqual(message.get_all('to'), [email]) self.assertTrue(re.match(r'^http://example.com/reset/[\w/-]+', message.get_payload(0).get_payload())) self.assertTrue(re.match(r'^<html><a href="http://example.com/reset/[\w/-]+/">Link</a></html>$', message.get_payload(1).get_payload())) class ReadOnlyPasswordHashTest(TestCase): def test_bug_19349_render_with_none_value(self): # Rendering the widget with value set to None # mustn't raise an exception. widget = ReadOnlyPasswordHashWidget() html = widget.render(name='password', value=None, attrs={}) self.assertIn(_("No password set."), html) def test_readonly_field_has_changed(self): field = ReadOnlyPasswordHashField() self.assertFalse(field._has_changed('aaa', 'bbb'))
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 646, 295, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 334, 1899, 13921, 2821, 12, 15995, 2821, 12, 272, 13635, 32523, 12, 2494, 6139, 2821, 12, 2876, 32523, 12, 13635, 9637, 2821, 12, 272, 5574, 5903, 6139, 3476, 792, 12, 5574, 5903, 6139, 3476, 3339, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 12064, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 421, 199, 32, 15118, 31482, 199, 32, 4415, 63, 1751, 8, 4701, 63, 14226, 29, 797, 12, 21705, 5172, 63, 13533, 31700, 7782, 1176, 14, 2828, 14, 1178, 14, 31342, 14, 8461, 17, 27596, 16829, 199, 533, 2876, 13921, 2821, 774, 8, 1746, 304, 339, 15188, 275, 788, 1178, 18481, 14, 1001, 418, 339, 347, 511, 63, 751, 63, 14039, 63, 2444, 8, 277, 304, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 396, 1258, 297, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 905, 2473, 4140, 2550, 12, 586, 359, 3990, 63, 505, 8, 964, 14, 705, 63, 3431, 459, 11081, 63, 2473, 31161, 339, 347, 511, 63, 3197, 63, 576, 8, 277, 304, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 12389, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 905, 2473, 4140, 2550, 12, 586, 359, 3990, 63, 505, 8, 964, 14, 955, 459, 2473, 2278, 705, 63, 3431, 459, 3197, 31161, 339, 347, 511, 63, 2060, 63, 16257, 8, 277, 304, 267, 327, 710, 14786, 2505, 365, 8927, 14, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 297, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 905, 2060, 18, 4140, 2550, 12, 586, 359, 3990, 63, 505, 8, 964, 14, 705, 63, 3431, 459, 2060, 63, 20759, 31161, 339, 347, 511, 63, 10727, 63, 28608, 8, 277, 304, 267, 327, 7309, 334, 269, 3865, 9, 19572, 781, 828, 1133, 1627, 267, 666, 275, 791, 2473, 356, 283, 74, 3300, 448, 936, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 1415, 63, 705, 275, 359, 3990, 63, 505, 8, 792, 14, 885, 63, 705, 63, 3431, 459, 2427, 24437, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 459, 2060, 17, 2278, 2550, 12, 1415, 63, 705, 9, 267, 291, 14, 629, 8, 964, 459, 2060, 18, 2278, 2550, 12, 1415, 63, 705, 9, 398, 666, 459, 2060, 18, 418, 275, 283, 396, 4288, 7, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 459, 2060, 17, 2278, 2550, 12, 1415, 63, 705, 9, 267, 291, 14, 629, 8, 964, 459, 2060, 18, 2278, 2550, 12, 3073, 339, 347, 511, 63, 3742, 8, 277, 304, 267, 327, 710, 3182, 1930, 14, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 32, 2694, 14, 957, 297, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 1815, 8, 964, 14, 374, 63, 1078, 1012, 267, 399, 275, 1824, 14, 2117, 342, 267, 291, 14, 629, 8, 2722, 8, 85, 395, 2650, 1899, 26, 1335, 3300, 448, 32, 2694, 14, 957, 5971, 421, 199, 32, 15118, 31482, 199, 32, 4415, 63, 1751, 8, 4701, 63, 14226, 29, 797, 12, 21705, 5172, 63, 13533, 31700, 7782, 1176, 14, 2828, 14, 1178, 14, 31342, 14, 8461, 17, 27596, 16829, 199, 533, 15995, 2821, 774, 8, 1746, 304, 339, 15188, 275, 788, 1178, 18481, 14, 1001, 418, 339, 347, 511, 63, 3197, 63, 2473, 8, 277, 304, 267, 327, 710, 922, 11482, 83, 376, 3866, 3434, 14, 398, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 63, 9105, 63, 1397, 63, 4494, 297, 288, 283, 2060, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 15995, 2821, 8, 403, 12, 666, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 14, 2865, 63, 698, 63, 2550, 1062, 355, 359, 3990, 63, 505, 8, 964, 14, 705, 63, 3431, 459, 3197, 63, 2886, 418, 450, 469, 490, 283, 2473, 356, 2876, 423, 2024, 14, 362, 63, 698, 360, 2473, 1959, 3832, 63, 354, 355, 3828, 566, 339, 347, 511, 63, 16856, 63, 751, 8, 277, 304, 267, 327, 710, 922, 365, 21325, 14, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 16856, 297, 288, 283, 2060, 356, 283, 2060, 297, 267, 789, 267, 1824, 275, 15995, 2821, 8, 403, 12, 666, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 14, 2865, 63, 698, 63, 2550 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 646, 295, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 334, 1899, 13921, 2821, 12, 15995, 2821, 12, 272, 13635, 32523, 12, 2494, 6139, 2821, 12, 2876, 32523, 12, 13635, 9637, 2821, 12, 272, 5574, 5903, 6139, 3476, 792, 12, 5574, 5903, 6139, 3476, 3339, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 12064, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 421, 199, 32, 15118, 31482, 199, 32, 4415, 63, 1751, 8, 4701, 63, 14226, 29, 797, 12, 21705, 5172, 63, 13533, 31700, 7782, 1176, 14, 2828, 14, 1178, 14, 31342, 14, 8461, 17, 27596, 16829, 199, 533, 2876, 13921, 2821, 774, 8, 1746, 304, 339, 15188, 275, 788, 1178, 18481, 14, 1001, 418, 339, 347, 511, 63, 751, 63, 14039, 63, 2444, 8, 277, 304, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 396, 1258, 297, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 905, 2473, 4140, 2550, 12, 586, 359, 3990, 63, 505, 8, 964, 14, 705, 63, 3431, 459, 11081, 63, 2473, 31161, 339, 347, 511, 63, 3197, 63, 576, 8, 277, 304, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 12389, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 905, 2473, 4140, 2550, 12, 586, 359, 3990, 63, 505, 8, 964, 14, 955, 459, 2473, 2278, 705, 63, 3431, 459, 3197, 31161, 339, 347, 511, 63, 2060, 63, 16257, 8, 277, 304, 267, 327, 710, 14786, 2505, 365, 8927, 14, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 297, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 905, 2060, 18, 4140, 2550, 12, 586, 359, 3990, 63, 505, 8, 964, 14, 705, 63, 3431, 459, 2060, 63, 20759, 31161, 339, 347, 511, 63, 10727, 63, 28608, 8, 277, 304, 267, 327, 7309, 334, 269, 3865, 9, 19572, 781, 828, 1133, 1627, 267, 666, 275, 791, 2473, 356, 283, 74, 3300, 448, 936, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 1415, 63, 705, 275, 359, 3990, 63, 505, 8, 792, 14, 885, 63, 705, 63, 3431, 459, 2427, 24437, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 459, 2060, 17, 2278, 2550, 12, 1415, 63, 705, 9, 267, 291, 14, 629, 8, 964, 459, 2060, 18, 2278, 2550, 12, 1415, 63, 705, 9, 398, 666, 459, 2060, 18, 418, 275, 283, 396, 4288, 7, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 459, 2060, 17, 2278, 2550, 12, 1415, 63, 705, 9, 267, 291, 14, 629, 8, 964, 459, 2060, 18, 2278, 2550, 12, 3073, 339, 347, 511, 63, 3742, 8, 277, 304, 267, 327, 710, 3182, 1930, 14, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 32, 2694, 14, 957, 297, 288, 283, 2060, 17, 356, 283, 396, 4288, 297, 288, 283, 2060, 18, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 2876, 13921, 2821, 8, 576, 9, 267, 291, 14, 1815, 8, 964, 14, 374, 63, 1078, 1012, 267, 399, 275, 1824, 14, 2117, 342, 267, 291, 14, 629, 8, 2722, 8, 85, 395, 2650, 1899, 26, 1335, 3300, 448, 32, 2694, 14, 957, 5971, 421, 199, 32, 15118, 31482, 199, 32, 4415, 63, 1751, 8, 4701, 63, 14226, 29, 797, 12, 21705, 5172, 63, 13533, 31700, 7782, 1176, 14, 2828, 14, 1178, 14, 31342, 14, 8461, 17, 27596, 16829, 199, 533, 15995, 2821, 774, 8, 1746, 304, 339, 15188, 275, 788, 1178, 18481, 14, 1001, 418, 339, 347, 511, 63, 3197, 63, 2473, 8, 277, 304, 267, 327, 710, 922, 11482, 83, 376, 3866, 3434, 14, 398, 666, 275, 469, 288, 283, 2473, 356, 283, 74, 3300, 448, 63, 9105, 63, 1397, 63, 4494, 297, 288, 283, 2060, 356, 283, 396, 4288, 297, 267, 789, 267, 1824, 275, 15995, 2821, 8, 403, 12, 666, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 14, 2865, 63, 698, 63, 2550, 1062, 355, 359, 3990, 63, 505, 8, 964, 14, 705, 63, 3431, 459, 3197, 63, 2886, 418, 450, 469, 490, 283, 2473, 356, 2876, 423, 2024, 14, 362, 63, 698, 360, 2473, 1959, 3832, 63, 354, 355, 3828, 566, 339, 347, 511, 63, 16856, 63, 751, 8, 277, 304, 267, 327, 710, 922, 365, 21325, 14, 267, 666, 275, 469, 288, 283, 2473, 356, 283, 16856, 297, 288, 283, 2060, 356, 283, 2060, 297, 267, 789, 267, 1824, 275, 15995, 2821, 8, 403, 12, 666, 9, 267, 291, 14, 3334, 8, 964, 14, 374, 63, 1078, 1012, 267, 291, 14, 629, 8, 964, 14, 2865, 63, 698, 63, 2550, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
imbugs/stock-3
common/basic.py
2
2604
import datetime as dt import re # Progress calculation and printing class Progress(object): def __init__(self, maximum): self.maximum = maximum self.last_percent = 0 def show(self, current): percent = round(current/self.maximum * 100) if percent > self.last_percent: self.last_percent = percent print ("%d%% complete \r" % percent, end="") if percent == 100: print ("") class WriteStats(object): def __init__(self, statsfile): # Erase file f = open(statsfile, 'w') f.close() # Open to append self.f = open(statsfile, 'a') def append(self, analytics_obj, res_name, ma, pair): data = """\ ==== %s %s %s ==== Pair profitability: %.2f%% Biggest win: %.2f%% Biggest loss: %.2f%% Sum on won trades: %.2f Sum on lost trades: %.2f Number of wins: %d Number of losts: %d Max consecutive wins: %d Max consecutive losts: %d Max consecutive profit: %.2f%% Max consecutive loss: %.2f%% """ % ( res_name, ma, pair, analytics_obj.profit[ma][pair[0]][pair[1]], analytics_obj.biggest_win[ma][pair], analytics_obj.biggest_loss[ma][pair], analytics_obj.won_trades_sum[ma][pair], analytics_obj.lost_trades_sum[ma][pair], analytics_obj.won_trades_num[ma][pair], analytics_obj.lost_trades_num[ma][pair], analytics_obj.max_consecutive_wins[ma][pair], analytics_obj.max_consecutive_losts[ma][pair], analytics_obj.max_consecutive_profit[ma][pair], analytics_obj.max_consecutive_loss[ma][pair] ) self.f.write(data) def __del__(self): self.f.close() # Return current time timestamp def now(): return int(dt.datetime.now().strftime('%s')) # Return timestamp of datetime object def dt_timestamp(dt_obj): return int(dt_obj.strftime('%s')) # Return date object from timestamp def dt_date(timestamp): return dt.datetime.fromtimestamp(timestamp) # Function to convert resolution from word to seconds # Returns dict like { 5m: 300, ... } def resolutions_convert(res_string): resolutions_conf = {} regex = re.compile("(\d+)([mh])") for res in res_string.split(','): m = regex.match(res) amount = int(m.group(1)) # number suffix = m.group(2) # mins or hours if suffix == 'm': multiplier = 60 elif suffix == 'h': multiplier = 60*60 resolutions_conf[res] = amount * multiplier return resolutions_conf
gpl-3.0
[ 646, 2197, 465, 4487, 199, 646, 295, 199, 199, 3, 21211, 15232, 436, 16116, 199, 533, 21211, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5696, 304, 267, 291, 14, 11555, 275, 5696, 267, 291, 14, 2019, 63, 7045, 275, 378, 272, 347, 2498, 8, 277, 12, 1453, 304, 267, 8878, 275, 6168, 8, 1818, 15, 277, 14, 11555, 627, 2948, 9, 267, 340, 8878, 690, 291, 14, 2019, 63, 7045, 26, 288, 291, 14, 2019, 63, 7045, 275, 8878, 288, 870, 19426, 68, 8530, 4890, 971, 82, 2, 450, 8878, 12, 1284, 18413, 288, 340, 8878, 508, 2948, 26, 355, 870, 334, 7230, 199, 199, 533, 6990, 8257, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5020, 493, 304, 267, 327, 662, 8062, 570, 267, 289, 275, 1551, 8, 3200, 493, 12, 283, 87, 358, 267, 289, 14, 1600, 342, 398, 327, 3232, 370, 5666, 267, 291, 14, 70, 275, 1551, 8, 3200, 493, 12, 283, 65, 358, 339, 347, 5666, 8, 277, 12, 30159, 63, 1113, 12, 522, 63, 354, 12, 610, 12, 4092, 304, 267, 666, 275, 9638, 199, 532, 450, 83, 450, 83, 450, 83, 275, 5918, 199, 12882, 557, 329, 2902, 2012, 26, 198, 17229, 18, 70, 8530, 199, 7279, 3199, 4747, 26, 198, 198, 17229, 18, 70, 8530, 199, 7279, 3199, 5621, 26, 198, 198, 17229, 18, 70, 8530, 199, 6959, 641, 7859, 1468, 3424, 26, 198, 17229, 18, 70, 199, 6959, 641, 14669, 1468, 3424, 26, 198, 17229, 18, 70, 199, 3259, 402, 29431, 26, 198, 198, 5, 68, 199, 3259, 402, 560, 10329, 26, 198, 5, 68, 199, 4261, 23376, 29431, 26, 198, 5, 68, 199, 4261, 23376, 560, 10329, 26, 198, 5, 68, 199, 4261, 23376, 32630, 26, 198, 17229, 18, 70, 8530, 199, 4261, 23376, 5621, 26, 198, 17229, 18, 70, 8530, 199, 199, 624, 450, 334, 288, 522, 63, 354, 12, 610, 12, 4092, 12, 288, 30159, 63, 1113, 14, 496, 3269, 59, 391, 1527, 3852, 59, 16, 22235, 3852, 59, 17, 2365, 288, 30159, 63, 1113, 14, 5076, 3199, 63, 2676, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 5076, 3199, 63, 4358, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 87, 265, 63, 1239, 3424, 63, 1838, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 22031, 63, 1239, 3424, 63, 1838, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 87, 265, 63, 1239, 3424, 63, 1507, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 22031, 63, 1239, 3424, 63, 1507, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 2676, 83, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 320, 10329, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 496, 3269, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 4358, 59, 391, 1527, 3852, 61, 288, 776, 398, 291, 14, 70, 14, 952, 8, 576, 9, 339, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 70, 14, 1600, 342, 421, 199, 3, 1432, 1453, 900, 4913, 199, 318, 3063, 837, 272, 372, 1109, 8, 3583, 14, 2083, 14, 2131, 1252, 6205, 3508, 83, 1333, 199, 199, 3, 1432, 4913, 402, 2197, 909, 199, 318, 4487, 63, 3954, 8, 3583, 63, 1113, 304, 272, 372, 1109, 8, 3583, 63, 1113, 14, 6205, 3508, 83, 1333, 199, 199, 3, 1432, 1434, 909, 687, 4913, 199, 318, 4487, 63, 602, 8, 3954, 304, 272, 372, 4487, 14, 2083, 14, 18531, 8, 3954, 9, 199, 199, 3, 6801, 370, 3957, 12401, 687, 4349, 370, 4696, 199, 3, 1803, 1211, 2839, 469, 959, 77, 26, 9601, 12, 2263, 789, 199, 318, 17416, 8653, 63, 3916, 8, 470, 63, 875, 304, 272, 17416, 8653, 63, 2190, 275, 1052, 272, 5163, 275, 295, 14, 2014, 480, 2961, 68, 8771, 779, 17077, 566, 531, 339, 367, 522, 315, 522, 63, 875, 14, 1294, 25908, 267, 333, 275, 5163, 14, 1431, 8, 470, 9, 267, 5982, 275, 1109, 8, 77, 14, 923, 8, 17, 430, 327, 1329, 267, 4739, 275, 333, 14, 923, 8, 18, 9, 327, 1748, 83, 503, 10857, 267, 340, 4739, 508, 283, 77, 356, 288, 22215, 275, 5212, 267, 916, 4739, 508, 283, 72, 356, 288, 22215, 275, 5212, 10, 2259, 267, 17416, 8653, 63, 2190, 59, 470, 61, 275, 5982, 627, 22215, 339, 372, 17416, 8653, 63, 2190, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2197, 465, 4487, 199, 646, 295, 199, 199, 3, 21211, 15232, 436, 16116, 199, 533, 21211, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5696, 304, 267, 291, 14, 11555, 275, 5696, 267, 291, 14, 2019, 63, 7045, 275, 378, 272, 347, 2498, 8, 277, 12, 1453, 304, 267, 8878, 275, 6168, 8, 1818, 15, 277, 14, 11555, 627, 2948, 9, 267, 340, 8878, 690, 291, 14, 2019, 63, 7045, 26, 288, 291, 14, 2019, 63, 7045, 275, 8878, 288, 870, 19426, 68, 8530, 4890, 971, 82, 2, 450, 8878, 12, 1284, 18413, 288, 340, 8878, 508, 2948, 26, 355, 870, 334, 7230, 199, 199, 533, 6990, 8257, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5020, 493, 304, 267, 327, 662, 8062, 570, 267, 289, 275, 1551, 8, 3200, 493, 12, 283, 87, 358, 267, 289, 14, 1600, 342, 398, 327, 3232, 370, 5666, 267, 291, 14, 70, 275, 1551, 8, 3200, 493, 12, 283, 65, 358, 339, 347, 5666, 8, 277, 12, 30159, 63, 1113, 12, 522, 63, 354, 12, 610, 12, 4092, 304, 267, 666, 275, 9638, 199, 532, 450, 83, 450, 83, 450, 83, 275, 5918, 199, 12882, 557, 329, 2902, 2012, 26, 198, 17229, 18, 70, 8530, 199, 7279, 3199, 4747, 26, 198, 198, 17229, 18, 70, 8530, 199, 7279, 3199, 5621, 26, 198, 198, 17229, 18, 70, 8530, 199, 6959, 641, 7859, 1468, 3424, 26, 198, 17229, 18, 70, 199, 6959, 641, 14669, 1468, 3424, 26, 198, 17229, 18, 70, 199, 3259, 402, 29431, 26, 198, 198, 5, 68, 199, 3259, 402, 560, 10329, 26, 198, 5, 68, 199, 4261, 23376, 29431, 26, 198, 5, 68, 199, 4261, 23376, 560, 10329, 26, 198, 5, 68, 199, 4261, 23376, 32630, 26, 198, 17229, 18, 70, 8530, 199, 4261, 23376, 5621, 26, 198, 17229, 18, 70, 8530, 199, 199, 624, 450, 334, 288, 522, 63, 354, 12, 610, 12, 4092, 12, 288, 30159, 63, 1113, 14, 496, 3269, 59, 391, 1527, 3852, 59, 16, 22235, 3852, 59, 17, 2365, 288, 30159, 63, 1113, 14, 5076, 3199, 63, 2676, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 5076, 3199, 63, 4358, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 87, 265, 63, 1239, 3424, 63, 1838, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 22031, 63, 1239, 3424, 63, 1838, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 87, 265, 63, 1239, 3424, 63, 1507, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 22031, 63, 1239, 3424, 63, 1507, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 2676, 83, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 320, 10329, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 496, 3269, 59, 391, 1527, 3852, 467, 288, 30159, 63, 1113, 14, 988, 63, 388, 19068, 63, 4358, 59, 391, 1527, 3852, 61, 288, 776, 398, 291, 14, 70, 14, 952, 8, 576, 9, 339, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 70, 14, 1600, 342, 421, 199, 3, 1432, 1453, 900, 4913, 199, 318, 3063, 837, 272, 372, 1109, 8, 3583, 14, 2083, 14, 2131, 1252, 6205, 3508, 83, 1333, 199, 199, 3, 1432, 4913, 402, 2197, 909, 199, 318, 4487, 63, 3954, 8, 3583, 63, 1113, 304, 272, 372, 1109, 8, 3583, 63, 1113, 14, 6205, 3508, 83, 1333, 199, 199, 3, 1432, 1434, 909, 687, 4913, 199, 318, 4487, 63, 602, 8, 3954, 304, 272, 372, 4487, 14, 2083, 14, 18531, 8, 3954, 9, 199, 199, 3, 6801, 370, 3957, 12401, 687, 4349, 370, 4696, 199, 3, 1803, 1211, 2839, 469, 959, 77, 26, 9601, 12, 2263, 789, 199, 318, 17416, 8653, 63, 3916, 8, 470, 63, 875, 304, 272, 17416, 8653, 63, 2190, 275, 1052, 272, 5163, 275, 295, 14, 2014, 480, 2961, 68, 8771, 779, 17077, 566, 531, 339, 367, 522, 315, 522, 63, 875, 14, 1294, 25908, 267, 333, 275, 5163, 14, 1431, 8, 470, 9, 267, 5982, 275, 1109, 8, 77, 14, 923, 8, 17, 430, 327, 1329, 267, 4739, 275, 333, 14, 923, 8, 18, 9, 327, 1748, 83, 503, 10857, 267, 340, 4739, 508, 283, 77, 356, 288, 22215, 275, 5212, 267, 916, 4739, 508, 283, 72, 356, 288, 22215, 275, 5212, 10, 2259, 267, 17416, 8653, 63, 2190, 59, 470, 61, 275, 5982, 627, 22215, 339, 372, 17416, 8653, 63, 2190, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
abhinavsingh/proxy.py
examples/websocket_client.py
1
1465
# -*- coding: utf-8 -*- """ proxy.py ~~~~~~~~ ⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging. :copyright: (c) 2013-present by Abhinav Singh and contributors. :license: BSD, see LICENSE for more details. """ import time from proxy.http.websocket import WebsocketClient, WebsocketFrame, websocketOpcodes # globals client: WebsocketClient last_dispatch_time: float static_frame = memoryview(WebsocketFrame.text(b'hello')) num_echos = 10 def on_message(frame: WebsocketFrame) -> None: """WebsocketClient on_message callback.""" global client, num_echos, last_dispatch_time print('Received %r after %d millisec' % (frame.data, (time.time() - last_dispatch_time) * 1000)) assert(frame.data == b'hello' and frame.opcode == websocketOpcodes.TEXT_FRAME) if num_echos > 0: client.queue(static_frame) last_dispatch_time = time.time() num_echos -= 1 else: client.close() if __name__ == '__main__': # Constructor establishes socket connection client = WebsocketClient( b'echo.websocket.org', 80, b'/', on_message=on_message) # Perform handshake client.handshake() # Queue some data for client client.queue(static_frame) last_dispatch_time = time.time() # Start event loop client.run()
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 4566, 14, 647, 272, 221, 4919, 272, 22410, 249, 95, 159, 249, 95, 159, 249, 95, 22613, 12, 29684, 3463, 12, 7497, 1518, 16725, 12, 12213, 1640, 814, 4021, 461, 4566, 1654, 289, 679, 2972, 641, 272, 7220, 20391, 12, 13467, 1253, 13515, 16367, 12, 5343, 12, 10201, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 13, 1881, 701, 8351, 72, 262, 1214, 428, 316, 72, 436, 8417, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 900, 199, 504, 4566, 14, 1014, 14, 13508, 492, 2136, 10833, 3041, 12, 2136, 10833, 3160, 12, 24897, 4619, 6021, 421, 199, 3, 7992, 199, 1258, 26, 2136, 10833, 3041, 199, 2019, 63, 6052, 63, 521, 26, 2069, 199, 1986, 63, 1943, 275, 20228, 8, 6004, 10833, 3160, 14, 505, 8, 66, 7, 5006, 1333, 199, 1507, 63, 12736, 736, 275, 1616, 421, 199, 318, 641, 63, 1188, 8, 1943, 26, 2136, 10833, 3160, 9, 1035, 488, 26, 272, 408, 6004, 10833, 3041, 641, 63, 1188, 3233, 1041, 272, 2288, 1890, 12, 1967, 63, 12736, 736, 12, 2061, 63, 6052, 63, 521, 272, 870, 360, 9392, 450, 82, 2410, 450, 68, 15949, 3321, 7, 450, 881, 334, 1943, 14, 576, 12, 334, 521, 14, 521, 342, 446, 2061, 63, 6052, 63, 521, 9, 627, 5198, 430, 272, 702, 8, 1943, 14, 576, 508, 330, 7, 5006, 7, 436, 2787, 14, 14325, 508, 1779, 24897, 4619, 6021, 14, 3876, 63, 12683, 9, 272, 340, 1967, 63, 12736, 736, 690, 378, 26, 267, 1890, 14, 1825, 8, 1986, 63, 1943, 9, 267, 2061, 63, 6052, 63, 521, 275, 900, 14, 521, 342, 267, 1967, 63, 12736, 736, 4862, 413, 272, 587, 26, 267, 1890, 14, 1600, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 20297, 16873, 397, 2838, 1950, 272, 1890, 275, 2136, 10833, 3041, 8, 267, 330, 7, 7878, 14, 13508, 14, 1308, 297, 267, 5939, 12, 267, 330, 7, 3678, 267, 641, 63, 1188, 29, 265, 63, 1188, 9, 272, 327, 14795, 14305, 272, 1890, 14, 11913, 342, 272, 327, 10703, 2005, 666, 367, 1890, 272, 1890, 14, 1825, 8, 1986, 63, 1943, 9, 272, 2061, 63, 6052, 63, 521, 275, 900, 14, 521, 342, 272, 327, 7707, 1566, 4438, 272, 1890, 14, 1065, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 4566, 14, 647, 272, 221, 4919, 272, 22410, 249, 95, 159, 249, 95, 159, 249, 95, 22613, 12, 29684, 3463, 12, 7497, 1518, 16725, 12, 12213, 1640, 814, 4021, 461, 4566, 1654, 289, 679, 2972, 641, 272, 7220, 20391, 12, 13467, 1253, 13515, 16367, 12, 5343, 12, 10201, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 13, 1881, 701, 8351, 72, 262, 1214, 428, 316, 72, 436, 8417, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 900, 199, 504, 4566, 14, 1014, 14, 13508, 492, 2136, 10833, 3041, 12, 2136, 10833, 3160, 12, 24897, 4619, 6021, 421, 199, 3, 7992, 199, 1258, 26, 2136, 10833, 3041, 199, 2019, 63, 6052, 63, 521, 26, 2069, 199, 1986, 63, 1943, 275, 20228, 8, 6004, 10833, 3160, 14, 505, 8, 66, 7, 5006, 1333, 199, 1507, 63, 12736, 736, 275, 1616, 421, 199, 318, 641, 63, 1188, 8, 1943, 26, 2136, 10833, 3160, 9, 1035, 488, 26, 272, 408, 6004, 10833, 3041, 641, 63, 1188, 3233, 1041, 272, 2288, 1890, 12, 1967, 63, 12736, 736, 12, 2061, 63, 6052, 63, 521, 272, 870, 360, 9392, 450, 82, 2410, 450, 68, 15949, 3321, 7, 450, 881, 334, 1943, 14, 576, 12, 334, 521, 14, 521, 342, 446, 2061, 63, 6052, 63, 521, 9, 627, 5198, 430, 272, 702, 8, 1943, 14, 576, 508, 330, 7, 5006, 7, 436, 2787, 14, 14325, 508, 1779, 24897, 4619, 6021, 14, 3876, 63, 12683, 9, 272, 340, 1967, 63, 12736, 736, 690, 378, 26, 267, 1890, 14, 1825, 8, 1986, 63, 1943, 9, 267, 2061, 63, 6052, 63, 521, 275, 900, 14, 521, 342, 267, 1967, 63, 12736, 736, 4862, 413, 272, 587, 26, 267, 1890, 14, 1600, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 20297, 16873, 397, 2838, 1950, 272, 1890, 275, 2136, 10833, 3041, 8, 267, 330, 7, 7878, 14, 13508, 14, 1308, 297, 267, 5939, 12, 267, 330, 7, 3678, 267, 641, 63, 1188, 29, 265, 63, 1188, 9, 272, 327, 14795, 14305, 272, 1890, 14, 11913, 342, 272, 327, 10703, 2005, 666, 367, 1890, 272, 1890, 14, 1825, 8, 1986, 63, 1943, 9, 272, 2061, 63, 6052, 63, 521, 275, 900, 14, 521, 342, 272, 327, 7707, 1566, 4438, 272, 1890, 14, 1065, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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import Testing from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() # Quadric definition quadric = vtk.vtkQuadric() quadric.SetCoefficients([.5,1,.2,0,.1,0,0,.2,0,0]) sample = vtk.vtkSampleFunction() sample.SetSampleDimensions(30,30,30) sample.SetImplicitFunction(quadric) sample.Update() #sample Print sample.ComputeNormalsOff() # Extract cells that contains isosurface of interest conn = vtk.vtkConnectivityFilter() conn.SetInputConnection(sample.GetOutputPort()) conn.ScalarConnectivityOn() conn.SetScalarRange(0.6,0.6) conn.SetExtractionModeToCellSeededRegions() conn.AddSeed(105) # Create a surface contours = vtk.vtkContourFilter() contours.SetInputConnection(conn.GetOutputPort()) # contours SetInputConnection [sample GetOutputPort] contours.GenerateValues(5,0.0,1.2) contMapper = vtk.vtkDataSetMapper() # contMapper SetInputConnection [contours GetOutputPort] contMapper.SetInputConnection(conn.GetOutputPort()) contMapper.SetScalarRange(0.0,1.2) contActor = vtk.vtkActor() contActor.SetMapper(contMapper) # Create outline outline = vtk.vtkOutlineFilter() outline.SetInputConnection(sample.GetOutputPort()) outlineMapper = vtk.vtkPolyDataMapper() outlineMapper.SetInputConnection(outline.GetOutputPort()) outlineActor = vtk.vtkActor() outlineActor.SetMapper(outlineMapper) outlineActor.GetProperty().SetColor(0,0,0) # Graphics # create a window to render into ren1 = vtk.vtkRenderer() renWin = vtk.vtkRenderWindow() renWin.SetMultiSamples(0) renWin.AddRenderer(ren1) # create a renderer # interactiver renderer catches mouse events (optional) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) ren1.SetBackground(1,1,1) ren1.AddActor(contActor) ren1.AddActor(outlineActor) ren1.ResetCamera() ren1.GetActiveCamera().Zoom(1.4) iren.Initialize() # --- end of script --
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 25702, 6405, 199, 8156, 43, 63, 3998, 63, 5441, 275, 11144, 25702, 6405, 342, 199, 199, 3, 5843, 350, 1567, 5492, 199, 14567, 1567, 275, 11144, 14, 11919, 23053, 1567, 342, 199, 14567, 1567, 14, 1084, 967, 21069, 83, 779, 14, 21, 12, 17, 18485, 18, 12, 16, 18485, 17, 12, 16, 12, 16, 18485, 18, 12, 16, 12, 16, 566, 199, 3271, 275, 11144, 14, 11919, 8176, 3481, 342, 199, 3271, 14, 1084, 8176, 23370, 8, 1216, 12, 1216, 12, 1216, 9, 199, 3271, 14, 1084, 8499, 3137, 3481, 8, 14567, 1567, 9, 199, 3271, 14, 4152, 342, 199, 3, 3271, 9101, 199, 3271, 14, 8564, 6241, 83, 5195, 342, 199, 3, 12892, 10106, 626, 3509, 365, 736, 300, 1409, 402, 13518, 199, 1631, 275, 11144, 14, 11919, 714, 13498, 4131, 342, 199, 1631, 14, 32195, 8, 3271, 14, 30810, 1012, 199, 1631, 14, 13090, 714, 13498, 3314, 342, 199, 1631, 14, 1084, 13090, 4709, 8, 16, 14, 22, 12, 16, 14, 22, 9, 199, 1631, 14, 1084, 4942, 6156, 1385, 1378, 8108, 51, 4063, 10708, 83, 342, 199, 1631, 14, 1123, 19554, 8, 7320, 9, 199, 3, 2790, 282, 13195, 199, 17798, 83, 275, 11144, 14, 11919, 714, 10808, 4131, 342, 199, 17798, 83, 14, 32195, 8, 1631, 14, 30810, 1012, 199, 3, 221, 23176, 83, 2494, 3205, 3225, 359, 3271, 2372, 2959, 4313, 61, 199, 17798, 83, 14, 6864, 6550, 8, 21, 12, 16, 14, 16, 12, 17, 14, 18, 9, 199, 11096, 11880, 275, 11144, 14, 11919, 30720, 11880, 342, 199, 3, 221, 13770, 11880, 2494, 3205, 3225, 359, 17798, 83, 2372, 2959, 4313, 61, 199, 11096, 11880, 14, 32195, 8, 1631, 14, 30810, 1012, 199, 11096, 11880, 14, 1084, 13090, 4709, 8, 16, 14, 16, 12, 17, 14, 18, 9, 199, 11096, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 11096, 12258, 14, 1084, 11880, 8, 11096, 11880, 9, 199, 3, 2790, 17964, 199, 11550, 275, 11144, 14, 11919, 21432, 4131, 342, 199, 11550, 14, 32195, 8, 3271, 14, 30810, 1012, 199, 11550, 11880, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 11550, 11880, 14, 32195, 8, 11550, 14, 30810, 1012, 199, 11550, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 11550, 12258, 14, 1084, 11880, 8, 11550, 11880, 9, 199, 11550, 12258, 14, 22845, 1252, 1084, 4117, 8, 16, 12, 16, 12, 16, 9, 199, 3, 11513, 2932, 199, 3, 1218, 282, 4353, 370, 3795, 1901, 199, 828, 17, 275, 11144, 14, 11919, 11355, 342, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1084, 3947, 27665, 8, 16, 9, 199, 828, 8886, 14, 1123, 11355, 8, 828, 17, 9, 199, 3, 1218, 282, 11889, 199, 3, 315, 2967, 67, 280, 422, 11889, 8579, 397, 12817, 4474, 334, 4144, 9, 199, 73, 828, 275, 11144, 14, 11919, 9216, 4301, 607, 2967, 630, 342, 199, 73, 828, 14, 1084, 9216, 4301, 8, 828, 8886, 9, 199, 828, 17, 14, 1084, 14148, 8, 17, 12, 17, 12, 17, 9, 199, 828, 17, 14, 1123, 12258, 8, 11096, 12258, 9, 199, 828, 17, 14, 1123, 12258, 8, 11550, 12258, 9, 199, 828, 17, 14, 9637, 18425, 342, 199, 828, 17, 14, 1002, 7472, 18425, 1252, 26798, 8, 17, 14, 20, 9, 199, 73, 828, 14, 9345, 342, 199, 3, 10894, 1284, 402, 2884, 1553, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 25702, 6405, 199, 8156, 43, 63, 3998, 63, 5441, 275, 11144, 25702, 6405, 342, 199, 199, 3, 5843, 350, 1567, 5492, 199, 14567, 1567, 275, 11144, 14, 11919, 23053, 1567, 342, 199, 14567, 1567, 14, 1084, 967, 21069, 83, 779, 14, 21, 12, 17, 18485, 18, 12, 16, 18485, 17, 12, 16, 12, 16, 18485, 18, 12, 16, 12, 16, 566, 199, 3271, 275, 11144, 14, 11919, 8176, 3481, 342, 199, 3271, 14, 1084, 8176, 23370, 8, 1216, 12, 1216, 12, 1216, 9, 199, 3271, 14, 1084, 8499, 3137, 3481, 8, 14567, 1567, 9, 199, 3271, 14, 4152, 342, 199, 3, 3271, 9101, 199, 3271, 14, 8564, 6241, 83, 5195, 342, 199, 3, 12892, 10106, 626, 3509, 365, 736, 300, 1409, 402, 13518, 199, 1631, 275, 11144, 14, 11919, 714, 13498, 4131, 342, 199, 1631, 14, 32195, 8, 3271, 14, 30810, 1012, 199, 1631, 14, 13090, 714, 13498, 3314, 342, 199, 1631, 14, 1084, 13090, 4709, 8, 16, 14, 22, 12, 16, 14, 22, 9, 199, 1631, 14, 1084, 4942, 6156, 1385, 1378, 8108, 51, 4063, 10708, 83, 342, 199, 1631, 14, 1123, 19554, 8, 7320, 9, 199, 3, 2790, 282, 13195, 199, 17798, 83, 275, 11144, 14, 11919, 714, 10808, 4131, 342, 199, 17798, 83, 14, 32195, 8, 1631, 14, 30810, 1012, 199, 3, 221, 23176, 83, 2494, 3205, 3225, 359, 3271, 2372, 2959, 4313, 61, 199, 17798, 83, 14, 6864, 6550, 8, 21, 12, 16, 14, 16, 12, 17, 14, 18, 9, 199, 11096, 11880, 275, 11144, 14, 11919, 30720, 11880, 342, 199, 3, 221, 13770, 11880, 2494, 3205, 3225, 359, 17798, 83, 2372, 2959, 4313, 61, 199, 11096, 11880, 14, 32195, 8, 1631, 14, 30810, 1012, 199, 11096, 11880, 14, 1084, 13090, 4709, 8, 16, 14, 16, 12, 17, 14, 18, 9, 199, 11096, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 11096, 12258, 14, 1084, 11880, 8, 11096, 11880, 9, 199, 3, 2790, 17964, 199, 11550, 275, 11144, 14, 11919, 21432, 4131, 342, 199, 11550, 14, 32195, 8, 3271, 14, 30810, 1012, 199, 11550, 11880, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 11550, 11880, 14, 32195, 8, 11550, 14, 30810, 1012, 199, 11550, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 11550, 12258, 14, 1084, 11880, 8, 11550, 11880, 9, 199, 11550, 12258, 14, 22845, 1252, 1084, 4117, 8, 16, 12, 16, 12, 16, 9, 199, 3, 11513, 2932, 199, 3, 1218, 282, 4353, 370, 3795, 1901, 199, 828, 17, 275, 11144, 14, 11919, 11355, 342, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1084, 3947, 27665, 8, 16, 9, 199, 828, 8886, 14, 1123, 11355, 8, 828, 17, 9, 199, 3, 1218, 282, 11889, 199, 3, 315, 2967, 67, 280, 422, 11889, 8579, 397, 12817, 4474, 334, 4144, 9, 199, 73, 828, 275, 11144, 14, 11919, 9216, 4301, 607, 2967, 630, 342, 199, 73, 828, 14, 1084, 9216, 4301, 8, 828, 8886, 9, 199, 828, 17, 14, 1084, 14148, 8, 17, 12, 17, 12, 17, 9, 199, 828, 17, 14, 1123, 12258, 8, 11096, 12258, 9, 199, 828, 17, 14, 1123, 12258, 8, 11550, 12258, 9, 199, 828, 17, 14, 9637, 18425, 342, 199, 828, 17, 14, 1002, 7472, 18425, 1252, 26798, 8, 17, 14, 20, 9, 199, 73, 828, 14, 9345, 342, 199, 3, 10894, 1284, 402, 2884, 1553, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
zjj/trac_hack
contrib/sourceforge2trac.py
2
24160
""" Import a Sourceforge project's tracker items into a Trac database. Requires: Trac 0.11 from http://trac.edgewall.org/ Python 2.5 from http://www.python.org/ The Sourceforge tracker items can be exported from the 'Backup' page of the project admin section. Substitute XXXXX with project id: https://sourceforge.net/export/xml_export2.php?group_id=XXXXX Initial version for Trac 0.7 and old artiface SF export format is Copyright 2004, Mark Rowe <mrowe@bluewire.net.nz> Version for Trac 0.11 and SF XML2 export format, completely rewritten except TracDatabase class is Copyright 2010, anatoly techtonik <techtonik@php.net> HGID: 92fd15e8398c $Id$ Uses Trac 0.11 DB format version 21 SourceForge XML Export format identified by the header: <!DOCTYPE project_export SYSTEM "http://sourceforge.net/export/sf_project_export_0.2.dtd"> Works with all DB backends. Attachments are not downloaded, but inserted as links to SF tracker. Ticket Types, Priorities and Resolutions ---------------------------------------- Conversion kills default Trac ticket types: - defect 1 - enhancement 2 - task 3 and priorities: - blocker 1 - critical 2 - major 3 - minor 4 - trivial 5 and resolutions: - fixed 1 - invalid 2 - wontfix 3 - duplicate 4 - worksforme 5 Versions and Milestones ----------------------- Kills versions and milestones from existing Trac DB Mapping ------- tracker_name == ticket_type group_name == version category_name == component user nobody == anonymous Not implemented (feature:reason) -------------------------------- attachments:made as a comment with links to attachments stored on SF (type,id,filename,size,time,description,author,ipnr) ticket_custom:unknown (ticket,name,value) history:imported only for summary, priority. closed date and owner fields severities:no field in source data """ #: rename users from SF to Trac user_map = {"nobody":"anonymous"} complete_msg = """ Conversion complete. You may want to login into Trac to verify names for ticket owners. You may also want to rename ticket types and priorities to default. """ from xml.etree.ElementTree import ElementTree import time import sys import trac.env # --- utility class DBNotEmpty(Exception): def __str__(self): return "Will not modify database with existing tickets!" class FlatXML(object): """Flat XML is XML without element attributes. Also each element may contain other elements or text, but not both. This object mirrors XML structure into own properties for convenient access to tree elements, i.e. flat.trackers[2].groups[2].group_name Uses recursion. """ def __init__(self, el=None): """el is ElementTree element""" if el: self.merge(el) def merge(self, el): """merge supplied ElementTree element into current object""" for c in el: if len(c.getchildren()) == 0: if c.text != None and len(c.text.strip()) != 0: self.__setattr__(c.tag, c.text) else: self.__setattr__(c.tag, []) else: #if c.getchildren()[0].tag == c.tag[:-1]: # c is a set of elements self.__setattr__(c.tag, [FlatXML(x) for x in c.getchildren()]) def __str__(self): buf = "" for sub in self.__dict__: val = self.__dict__[sub] if type(val) != list: buf += "%s : %s\n" % (sub, val) else: for x in val: buf += "\n ".join(x.__str__().split("\n")) return buf def __repr__(self): buf = "" for sub in self.__dict__: val = self.__dict__[sub] if type(val) != list: buf += "<%s>%s</%s>\n" % (sub, val, sub) else: for x in val: buf += "\n ".join(x.__repr__().split("\n")) return buf # --- SF data model class Tracker(FlatXML): """ <trackers> <tracker> <url>http://sourceforge.net/?group_id=175454&#38;atid=873299</url> <tracker_id>873299</tracker_id> <name>Bugs</name> <description>Bug Tracking System</description> <is_public>All site users</is_public> <allow_anon>Yes</allow_anon> <email_updates>Send to goblinhack@gmail.com</email_updates> <due_period>2592000</due_period> <submit_instructions></submit_instructions> <browse_instructions></browse_instructions> <status_timeout>1209600</status_timeout> <due_period_initial>0</due_period_initial> <due_period_update>0</due_period_update> <reopen_on_comment>1</reopen_on_comment> <canned_responses> </canned_responses> <groups> <group> <id>632324</id> <group_name>v1.0 (example)</group_name> </group> </groups> <categories> <category> <id>885178</id> <category_name>Interface (example)</category_name> <auto_assignee>nobody</auto_assignee> </category> </categories> <resolutions> <resolution> <id>1</id> <name>Fixed</name> </resolution> <resolution> <id>2</id> <name>Invalid</name> </resolution> ... </resolutions> <statuses> <status> <id>1</id> <name>Open</name> </status> <status> <id>2</id> <name>Closed</name> </status> <status> <id>3</id> <name>Deleted</name> </status> <status> <id>4</id> <name>Pending</name> </status> </statuses> ... <tracker_items> <tracker_item> <url>http://sourceforge.net/support/tracker.php?aid=2471428</url> <id>2471428</id> <status_id>2</status_id> <category_id>100</category_id> <group_id>100</group_id> <resolution_id>100</resolution_id> <submitter>sbluen</submitter> <assignee>nobody</assignee> <closer>goblinhack</closer> <submit_date>1230400444</submit_date> <close_date>1231087612</close_date> <priority>5</priority> <summary>glitch with edge of level</summary> <details>The mini-laser that the future soldier carries is so powerful that it even lets me go outside the level. I stand at the top edge of the level and then shoot up, and then it gets me somewhere where I am not supposed to go.</details> <is_private>0</is_private> <followups> <followup> <id>2335316</id> <submitter>goblinhack</submitter> <date>1175610236</date> <details>Logged In: YES user_id=1577972 Originator: NO does this happen every game or just once? you could send me the saved file and I'll try and load it - old versions harldy ever work with newer versions - need to add some kind of warnings on that tx</details> </followup> ... </followups> <attachments> <attachment> <url>http://sourceforge.net/tracker/download.php?group_id=175454&#38;atid=873299&#38;file_id=289080&#38;aid=</url> <id>289080</id> <filename>your_most_recent_game.gz</filename> <description>my saved game</description> <filesize>112968</filesize> <filetype>application/x-gzip</filetype> <date>1218987770</date> <submitter>sbluen</submitter> </attachment> ... </attachments> <history_entries> <history_entry> <id>7304242</id> <field_name>IP</field_name> <old_value>Artifact Created: 76.173.48.148</old_value> <date>1230400444</date> <updator>sbluen</updator> </history_entry> ... </history_entries> </tracker_item> ... </tracker_items> ... </tracker> </trackers> """ def __init__(self, e): self.merge(e) class ExportedProjectData(object): """Project data container as Python object. """ def __init__(self, f): """Data parsing""" self.trackers = [] #: tracker properties and data self.groups = [] #: groups [] self.priorities = [] #: priorities used self.resolutions = [] #: resolutions (index, name) self.tickets = [] #: all tickets self.statuses = [] #: status (idx, name) self.used_resolutions = {} #: id:name self.used_categories = {} #: id:name # id '100' means no category self.used_categories['100'] = None self.users = {} #: id:name root = ElementTree().parse(f) self.users = dict([(FlatXML(u).userid, FlatXML(u).username) for u in root.find('referenced_users')]) for tracker in root.find('trackers'): tr = Tracker(tracker) self.trackers.append(tr) # groups-versions for grp in tr.groups: # group ids are tracker-specific even if names match g = (grp.id, grp.group_name) if g not in self.groups: self.groups.append(g) # resolutions for res in tr.resolutions: r = (res.id, res.name) if r not in self.resolutions: self.resolutions.append(r) # statuses self.statuses = [(s.id, s.name) for s in tr.statuses] # tickets for tck in tr.tracker_items: if type(tck) == str: print repr(tck) self.tickets.append(tck) if int(tck.priority) not in self.priorities: self.priorities.append(int(tck.priority)) res_id = getattr(tck, "resolution_id", None) if res_id is not None and res_id not in self.used_resolutions: for idx, name in self.resolutions: if idx == res_id: break self.used_resolutions[res_id] = dict(self.resolutions)[res_id] # used categories categories = dict(self.get_categories(tr, noowner=True)) if tck.category_id not in self.used_categories: self.used_categories[tck.category_id] = categories[tck.category_id] # sorting everything self.trackers.sort(key=lambda x:x.name) self.groups.sort() self.priorities.sort() def get_categories(self, tracker=None, noid=False, noowner=False): """ SF categories : Trac components (id, name, owner) tuples for specified tracker or all trackers if noid or noowner flags are set, specified tuple attribute is stripped """ trs = [tracker] if tracker is not None else self.trackers categories = [] for tr in trs: for cat in tr.categories: c = (cat.id, cat.category_name, cat.auto_assignee) if c not in categories: categories.append(c) #: sort by name if noid: categories.sort() else: categories.sort(key=lambda x:x[1]) if noowner: categories = [x[:2] for x in categories] if noid: categories = [x[1:] for x in categories] return categories class TracDatabase(object): def __init__(self, path): self.env = trac.env.Environment(path) self._db = self.env.get_db_cnx() self._db.autocommit = False self._db.cnx.ping() def db(self): return self._db def hasTickets(self): c = self.db().cursor() #c.execute("""DELETE FROM ticket""") c.execute('''SELECT count(*) FROM ticket''') return int(c.fetchall()[0][0]) > 0 def dbCheck(self): if self.hasTickets(): raise DBNotEmpty def setTypeList(self, s): """Remove all types, set them to `s`""" self.dbCheck() c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='ticket_type'""") for i, value in enumerate(s): c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", ("ticket_type", value, i)) self.db().commit() def setPriorityList(self, s): """Remove all priorities, set them to `s`""" self.dbCheck() c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='priority'""") for i, value in enumerate(s): c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", ("priority", value, i)) self.db().commit() def setResolutionList(self, t): """Remove all resolutions, set them to `t` (index, name)""" self.dbCheck() c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='resolution'""") for value, name in t: c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", ("resolution", name, value)) self.db().commit() def setComponentList(self, t): """Remove all components, set them to `t` (name, owner)""" self.dbCheck() c = self.db().cursor() c.execute("""DELETE FROM component""") for name, owner in t: c.execute("""INSERT INTO component (name, owner) VALUES (%s, %s)""", (name, owner)) self.db().commit() def setVersionList(self, v): """Remove all versions, set them to `v`""" self.dbCheck() c = self.db().cursor() c.execute("""DELETE FROM version""") for value in v: # time and description are also available c.execute("""INSERT INTO version (name) VALUES (%s)""", value) self.db().commit() def setMilestoneList(self, m): """Remove all milestones, set them to `m` (""" self.dbCheck() c = self.db().cursor() c.execute("""DELETE FROM milestone""") for value in m: # due, completed, description are also available c.execute("""INSERT INTO milestone (name) VALUES (%s)""", value) self.db().commit() def addTicket(self, type, time, changetime, component, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): """ ticket table db21.py format id integer PRIMARY KEY, type text, -- the nature of the ticket time integer, -- the time it was created changetime integer, component text, severity text, priority text, owner text, -- who is this ticket assigned to reporter text, cc text, -- email addresses to notify version text, -- milestone text, -- status text, resolution text, summary text, -- one-line summary description text, -- problem description (long) keywords text """ db = self.db() c = db.cursor() if status.lower() == 'open': if owner != '': status = 'assigned' else: status = 'new' c.execute("""INSERT INTO ticket (type, time, changetime, component, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (type, time, changetime, component, priority, owner, reporter, cc, version, milestone, status.lower(), resolution, summary, '%s' % description, keywords)) db.commit() return db.get_last_id(c, 'ticket') def addTicketComment(self, ticket, time, author, value): c = self.db().cursor() c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", (ticket, time, author, 'comment', '', '%s' % value)) self.db().commit() def addTicketChange(self, ticket, time, author, field, oldvalue, newvalue): c = self.db().cursor() c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", (ticket, time, author, field, oldvalue, newvalue)) self.db().commit() def importData(f, env, opt): project = ExportedProjectData(f) trackers = project.trackers db = TracDatabase(env) # Data conversion typeList = [x.name for x in trackers] print("%d trackers will be converted to the following ticket types:\n %s" \ % (len(trackers), typeList)) used_cat_names = set(project.used_categories.values()) #: make names unique, forget about competing owners (the last one wins) components = dict(project.get_categories(noid=True)).items() components.sort() components = [x for x in components if x[0] in used_cat_names] print "%d out of %d categories are used and will be converted to the following components:\n %s" \ % (len(components), len(project.get_categories()), components) print "..renaming component owners:" for i,c in enumerate(components): if c[1] in user_map: components[i] = (c[0], user_map[c[1]]) print " %s" % components print "%d groups which will be converted to the following versions:\n %s" \ % (len(project.groups), project.groups) print "%d resolutions found :\n %s" \ % (len(project.resolutions), project.resolutions) resolutions = [(k,project.used_resolutions[k]) for k in project.used_resolutions] resolutions.sort(key=lambda x:int(x[0])) print ".. only %d used will be imported:\n %s" \ % (len(resolutions), resolutions) print "Priorities used so far: %s" % project.priorities if not(raw_input("Continue [y/N]?").lower() == 'y'): sys.exit() # Data save db.setTypeList(typeList) db.setComponentList(components) db.setPriorityList(range(min(project.priorities), max(project.priorities))) db.setVersionList(set([x[1] for x in project.groups])) db.setResolutionList(resolutions) db.setMilestoneList([]) for tracker in project.trackers: # id 100 means no component selected component_lookup = dict(project.get_categories(noowner=True)+[("100", None)]) for t in tracker.tracker_items: i = db.addTicket(type=tracker.name, time=int(t.submit_date), changetime=int(t.submit_date), component=component_lookup[t.category_id], priority=t.priority, owner=t.assignee if t.assignee not in user_map else user_map[t.assignee], reporter=t.submitter if t.submitter not in user_map else user_map[t.submitter], cc=None, # 100 means no group selected version=dict(project.groups+[("100", None)])[t.group_id], milestone=None, status=dict(project.statuses)[t.status_id], resolution=dict(resolutions)[t.resolution_id] if hasattr(t, "resolution_id") else None, summary=t.summary, description=t.details, keywords='sf'+t.id) print 'Imported %s as #%d' % (t.id, i) if len(t.attachments): attmsg = "SourceForge attachments:\n" for a in t.attachments: attmsg = attmsg + " * [%s %s] (%s) - added by '%s' %s [[BR]] "\ % (a.url+t.id, a.filename, a.filesize+" bytes", user_map.get(a.submitter, a.submitter), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(a.date)))) attmsg = attmsg + "''%s ''\n" % (a.description or '') # empty description is as empty list db.addTicketComment(ticket=i, time=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(t.submit_date))), author=None, value=attmsg) print ' added information about %d attachments for #%d' % (len(t.attachments), i) for msg in t.followups: """ <followup> <id>3280792</id> <submitter>goblinhack</submitter> <date>1231087739</date> <details>done</details> </followup> """ db.addTicketComment(ticket=i, time=msg.date, author=msg.submitter, value=msg.details) if t.followups: print ' imported %d messages for #%d' % (len(t.followups), i) # Import history """ <history_entry> <id>4452195</id> <field_name>resolution_id</field_name> <old_value>100</old_value> <date>1176043865</date> <updator>goblinhack</updator> </history_entry> """ revision = t.__dict__.copy() # iterate the history in reverse order and update ticket revision from # current (last) to initial changes = 0 for h in sorted(t.history_entries, reverse=True): """ Processed fields (field - notes): IP - no target field, just skip summary priority close_date assigned_to Fields not processed (field: explanation): File Added - TODO resolution_id - need to update used_resolutions status_id artifact_group_id category_id group_id """ f = None if h.field_name in ("IP",): changes += 1 continue elif h.field_name in ("summary", "priority"): f = h.field_name oldvalue = h.old_value newvalue = revision.get(h.field_name, None) elif h.field_name == 'assigned_to': f = "owner" newvalue = revision['assignee'] if h.old_value == '100': # was not assigned revision['assignee'] = None oldvalue = None else: username = project.users[h.old_value] if username in user_map: username = user_map[username] revision['assignee'] = oldvalue = username elif h.field_name == 'close_date' and revision['close_date'] != 0: f = 'status' oldvalue = 'assigned' newvalue = 'closed' if f: changes += 1 db.addTicketChange(ticket=i, time=h.date, author=h.updator, field=f, oldvalue=oldvalue, newvalue=newvalue) if h.field_name != 'assigned_to': revision[h.field_name] = h.old_value if changes: print ' processed %d out of %d history items for #%d' % (changes, len(t.history_entries), i) def main(): import optparse p = optparse.OptionParser('usage: %prog xml_export.xml /path/to/trac/environment') opt, args = p.parse_args() if len(args) != 2: p.error("Incorrect number of arguments") try: importData(open(args[0]), args[1], opt) except DBNotEmpty, e: print 'Error:', e sys.exit(1) print complete_msg if __name__ == '__main__': main()
bsd-3-clause
[ 624, 199, 6295, 282, 5800, 16677, 2199, 1159, 15271, 2974, 1901, 282, 377, 6457, 3050, 14, 199, 199, 18153, 26, 2043, 377, 6457, 378, 14, 845, 687, 1455, 921, 23047, 14, 5173, 7567, 14, 1308, 15, 2043, 2018, 499, 14, 21, 687, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 288, 199, 1918, 5800, 16677, 15271, 2974, 883, 506, 16629, 687, 314, 283, 16559, 7, 2034, 199, 1618, 314, 2199, 4628, 3420, 14, 4804, 25585, 5787, 2483, 543, 2199, 1305, 26, 199, 2859, 921, 22943, 14, 846, 15, 3790, 15, 1652, 63, 3790, 18, 14, 8624, 31, 923, 63, 344, 29, 6873, 56, 421, 199, 5733, 1015, 367, 377, 6457, 378, 14, 23, 436, 2269, 601, 280, 1409, 29531, 4843, 1475, 365, 199, 7384, 8353, 12, 7173, 15231, 69, 665, 17335, 1129, 32, 6304, 11239, 14, 846, 14, 15291, 30, 199, 199, 3353, 367, 377, 6457, 378, 14, 845, 436, 29531, 4692, 18, 4843, 1475, 12, 14793, 28286, 199, 2590, 377, 6457, 7243, 1021, 365, 199, 7384, 7129, 12, 376, 292, 16242, 28222, 1860, 3258, 665, 15970, 1860, 3258, 32, 8624, 14, 846, 30, 199, 31442, 998, 26, 20140, 2592, 1046, 69, 24, 13944, 67, 199, 199, 4, 1304, 4, 421, 199, 21896, 377, 6457, 378, 14, 845, 6249, 1475, 1015, 7829, 199, 2980, 1858, 303, 4692, 20220, 1475, 15836, 701, 314, 1406, 26, 199, 11230, 16556, 2199, 63, 3790, 20859, 298, 1014, 921, 22943, 14, 846, 15, 3790, 15, 7646, 63, 1715, 63, 3790, 63, 16, 14, 18, 14, 15662, 1743, 199, 199, 25348, 543, 1006, 6249, 14745, 14, 21328, 1470, 787, 440, 13557, 12, 1325, 11788, 199, 305, 6220, 370, 29531, 15271, 14, 421, 199, 25813, 18851, 12, 8538, 269, 12107, 436, 3591, 393, 8653, 199, 32111, 199, 20403, 1022, 15350, 849, 377, 6457, 12052, 2943, 26, 199, 13, 347, 449, 420, 413, 199, 13, 655, 14666, 434, 499, 199, 13, 2120, 263, 650, 199, 199, 460, 6791, 12107, 26, 199, 13, 1853, 281, 221, 413, 199, 13, 19698, 499, 199, 13, 12160, 259, 650, 199, 13, 12612, 259, 841, 199, 13, 28586, 221, 959, 199, 199, 460, 17416, 8653, 26, 199, 13, 6317, 420, 413, 199, 13, 3866, 259, 499, 199, 13, 336, 1888, 970, 259, 650, 199, 13, 9250, 221, 841, 199, 13, 5419, 509, 278, 959, 421, 199, 21167, 436, 603, 24156, 199, 777, 12797, 199, 43, 15350, 5459, 436, 333, 24156, 687, 3411, 377, 6457, 6249, 421, 199, 7674, 199, 12797, 199, 8877, 63, 354, 508, 12052, 63, 466, 199, 923, 63, 354, 508, 1015, 199, 3710, 63, 354, 508, 3931, 199, 199, 751, 949, 2030, 508, 16535, 421, 199, 1763, 6366, 334, 4445, 26, 5764, 9, 199, 1444, 199, 15855, 26, 29519, 465, 282, 3721, 543, 6220, 370, 18912, 5489, 641, 29531, 288, 334, 466, 12, 344, 12, 1501, 12, 890, 12, 521, 12, 1802, 12, 2502, 12, 711, 7865, 9, 199, 9201, 63, 4229, 26, 5187, 334, 9201, 12, 354, 12, 585, 9, 199, 5570, 26, 17932, 1454, 367, 6212, 12, 7464, 14, 6876, 1434, 436, 5771, 1504, 199, 199, 261, 422, 12107, 26, 889, 901, 315, 1350, 666, 199, 624, 421, 199, 12573, 11441, 4390, 687, 29531, 370, 377, 6457, 199, 751, 63, 1130, 275, 2420, 889, 2030, 5122, 12628, 3570, 4388, 199, 4883, 63, 1328, 275, 408, 199, 20403, 4890, 14, 199, 199, 5556, 1443, 2934, 370, 4676, 1901, 377, 6457, 370, 4911, 1561, 367, 12052, 31867, 14, 2047, 1443, 199, 12344, 2934, 370, 11441, 12052, 2943, 436, 6791, 12107, 370, 849, 14, 199, 624, 199, 199, 504, 2748, 14, 9464, 14, 15325, 492, 13139, 199, 646, 900, 199, 646, 984, 199, 199, 646, 1468, 67, 14, 1813, 199, 199, 3, 10894, 11420, 199, 533, 6249, 1763, 4699, 8, 1726, 304, 272, 347, 636, 495, 721, 277, 304, 267, 372, 298, 20326, 440, 2811, 3050, 543, 3411, 12052, 83, 9539, 199, 199, 533, 19005, 4317, 8, 785, 304, 272, 408, 17271, 4692, 365, 4692, 1928, 1819, 3004, 14, 6121, 1924, 1819, 2126, 1443, 1395, 1163, 4008, 503, 1318, 12, 1325, 440, 3865, 14, 10817, 961, 909, 15216, 83, 4692, 5523, 1901, 5705, 4382, 367, 22700, 2126, 2879, 370, 3123, 4008, 12, 284, 14, 69, 14, 6829, 14, 3885, 1192, 59, 18, 1055, 2634, 59, 18, 1055, 923, 63, 354, 10817, 14911, 16189, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 579, 29, 403, 304, 267, 408, 352, 365, 13139, 1819, 624, 267, 340, 579, 26, 288, 291, 14, 5628, 8, 352, 9, 339, 347, 5389, 8, 277, 12, 579, 304, 267, 408, 5628, 6841, 13139, 1819, 1901, 1453, 909, 624, 267, 367, 286, 315, 579, 26, 288, 340, 822, 8, 67, 14, 362, 3223, 1012, 508, 378, 26, 355, 340, 286, 14, 505, 1137, 488, 436, 822, 8, 67, 14, 505, 14, 1913, 1012, 1137, 378, 26, 673, 291, 855, 10202, 721, 67, 14, 1450, 12, 286, 14, 505, 9, 355, 587, 26, 673, 291, 855, 10202, 721, 67, 14, 1450, 12, 3073, 288, 587, 26, 327, 692, 286, 14, 362, 3223, 3430, 16, 1055, 1450, 508, 286, 14, 1450, 4439, 17, 2189, 355, 327, 286, 365, 282, 663, 402, 4008, 355, 291, 855, 10202, 721, 67, 14, 1450, 12, 359, 17271, 4317, 8, 88, 9, 367, 671, 315, 286, 14, 362, 3223, 9383, 2378, 347, 636, 495, 721, 277, 304, 267, 4123, 275, 3087, 267, 367, 1007, 315, 291, 855, 807, 10651, 288, 1139, 275, 291, 855, 807, 12298, 954, 61, 288, 340, 730, 8, 637, 9, 1137, 769, 26, 355, 4123, 847, 2071, 83, 520, 450, 83, 60, 78, 2, 450, 334, 954, 12, 1139, 9, 288, 587, 26, 355, 367, 671, 315, 1139, 26, 15324, 4123, 847, 1867, 78, 221, 3680, 904, 8, 88, 855, 495, 31261, 1294, 4582, 78, 2237, 267, 372, 4123, 339, 347, 636, 2722, 721, 277, 304, 267, 4123, 275, 3087, 267, 367, 1007, 315, 291, 855, 807, 10651, 288, 1139, 275, 291, 855, 807, 12298, 954, 61, 288, 340, 730, 8, 637, 9, 1137, 769, 26, 355, 4123, 847, 23054, 83, 6598, 83, 26191, 83, 3072, 78, 2, 450, 334, 954, 12, 1139, 12, 1007, 9, 288, 587, 26, 355, 367, 671, 315, 1139 ]
[ 199, 6295, 282, 5800, 16677, 2199, 1159, 15271, 2974, 1901, 282, 377, 6457, 3050, 14, 199, 199, 18153, 26, 2043, 377, 6457, 378, 14, 845, 687, 1455, 921, 23047, 14, 5173, 7567, 14, 1308, 15, 2043, 2018, 499, 14, 21, 687, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 288, 199, 1918, 5800, 16677, 15271, 2974, 883, 506, 16629, 687, 314, 283, 16559, 7, 2034, 199, 1618, 314, 2199, 4628, 3420, 14, 4804, 25585, 5787, 2483, 543, 2199, 1305, 26, 199, 2859, 921, 22943, 14, 846, 15, 3790, 15, 1652, 63, 3790, 18, 14, 8624, 31, 923, 63, 344, 29, 6873, 56, 421, 199, 5733, 1015, 367, 377, 6457, 378, 14, 23, 436, 2269, 601, 280, 1409, 29531, 4843, 1475, 365, 199, 7384, 8353, 12, 7173, 15231, 69, 665, 17335, 1129, 32, 6304, 11239, 14, 846, 14, 15291, 30, 199, 199, 3353, 367, 377, 6457, 378, 14, 845, 436, 29531, 4692, 18, 4843, 1475, 12, 14793, 28286, 199, 2590, 377, 6457, 7243, 1021, 365, 199, 7384, 7129, 12, 376, 292, 16242, 28222, 1860, 3258, 665, 15970, 1860, 3258, 32, 8624, 14, 846, 30, 199, 31442, 998, 26, 20140, 2592, 1046, 69, 24, 13944, 67, 199, 199, 4, 1304, 4, 421, 199, 21896, 377, 6457, 378, 14, 845, 6249, 1475, 1015, 7829, 199, 2980, 1858, 303, 4692, 20220, 1475, 15836, 701, 314, 1406, 26, 199, 11230, 16556, 2199, 63, 3790, 20859, 298, 1014, 921, 22943, 14, 846, 15, 3790, 15, 7646, 63, 1715, 63, 3790, 63, 16, 14, 18, 14, 15662, 1743, 199, 199, 25348, 543, 1006, 6249, 14745, 14, 21328, 1470, 787, 440, 13557, 12, 1325, 11788, 199, 305, 6220, 370, 29531, 15271, 14, 421, 199, 25813, 18851, 12, 8538, 269, 12107, 436, 3591, 393, 8653, 199, 32111, 199, 20403, 1022, 15350, 849, 377, 6457, 12052, 2943, 26, 199, 13, 347, 449, 420, 413, 199, 13, 655, 14666, 434, 499, 199, 13, 2120, 263, 650, 199, 199, 460, 6791, 12107, 26, 199, 13, 1853, 281, 221, 413, 199, 13, 19698, 499, 199, 13, 12160, 259, 650, 199, 13, 12612, 259, 841, 199, 13, 28586, 221, 959, 199, 199, 460, 17416, 8653, 26, 199, 13, 6317, 420, 413, 199, 13, 3866, 259, 499, 199, 13, 336, 1888, 970, 259, 650, 199, 13, 9250, 221, 841, 199, 13, 5419, 509, 278, 959, 421, 199, 21167, 436, 603, 24156, 199, 777, 12797, 199, 43, 15350, 5459, 436, 333, 24156, 687, 3411, 377, 6457, 6249, 421, 199, 7674, 199, 12797, 199, 8877, 63, 354, 508, 12052, 63, 466, 199, 923, 63, 354, 508, 1015, 199, 3710, 63, 354, 508, 3931, 199, 199, 751, 949, 2030, 508, 16535, 421, 199, 1763, 6366, 334, 4445, 26, 5764, 9, 199, 1444, 199, 15855, 26, 29519, 465, 282, 3721, 543, 6220, 370, 18912, 5489, 641, 29531, 288, 334, 466, 12, 344, 12, 1501, 12, 890, 12, 521, 12, 1802, 12, 2502, 12, 711, 7865, 9, 199, 9201, 63, 4229, 26, 5187, 334, 9201, 12, 354, 12, 585, 9, 199, 5570, 26, 17932, 1454, 367, 6212, 12, 7464, 14, 6876, 1434, 436, 5771, 1504, 199, 199, 261, 422, 12107, 26, 889, 901, 315, 1350, 666, 199, 624, 421, 199, 12573, 11441, 4390, 687, 29531, 370, 377, 6457, 199, 751, 63, 1130, 275, 2420, 889, 2030, 5122, 12628, 3570, 4388, 199, 4883, 63, 1328, 275, 408, 199, 20403, 4890, 14, 199, 199, 5556, 1443, 2934, 370, 4676, 1901, 377, 6457, 370, 4911, 1561, 367, 12052, 31867, 14, 2047, 1443, 199, 12344, 2934, 370, 11441, 12052, 2943, 436, 6791, 12107, 370, 849, 14, 199, 624, 199, 199, 504, 2748, 14, 9464, 14, 15325, 492, 13139, 199, 646, 900, 199, 646, 984, 199, 199, 646, 1468, 67, 14, 1813, 199, 199, 3, 10894, 11420, 199, 533, 6249, 1763, 4699, 8, 1726, 304, 272, 347, 636, 495, 721, 277, 304, 267, 372, 298, 20326, 440, 2811, 3050, 543, 3411, 12052, 83, 9539, 199, 199, 533, 19005, 4317, 8, 785, 304, 272, 408, 17271, 4692, 365, 4692, 1928, 1819, 3004, 14, 6121, 1924, 1819, 2126, 1443, 1395, 1163, 4008, 503, 1318, 12, 1325, 440, 3865, 14, 10817, 961, 909, 15216, 83, 4692, 5523, 1901, 5705, 4382, 367, 22700, 2126, 2879, 370, 3123, 4008, 12, 284, 14, 69, 14, 6829, 14, 3885, 1192, 59, 18, 1055, 2634, 59, 18, 1055, 923, 63, 354, 10817, 14911, 16189, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 579, 29, 403, 304, 267, 408, 352, 365, 13139, 1819, 624, 267, 340, 579, 26, 288, 291, 14, 5628, 8, 352, 9, 339, 347, 5389, 8, 277, 12, 579, 304, 267, 408, 5628, 6841, 13139, 1819, 1901, 1453, 909, 624, 267, 367, 286, 315, 579, 26, 288, 340, 822, 8, 67, 14, 362, 3223, 1012, 508, 378, 26, 355, 340, 286, 14, 505, 1137, 488, 436, 822, 8, 67, 14, 505, 14, 1913, 1012, 1137, 378, 26, 673, 291, 855, 10202, 721, 67, 14, 1450, 12, 286, 14, 505, 9, 355, 587, 26, 673, 291, 855, 10202, 721, 67, 14, 1450, 12, 3073, 288, 587, 26, 327, 692, 286, 14, 362, 3223, 3430, 16, 1055, 1450, 508, 286, 14, 1450, 4439, 17, 2189, 355, 327, 286, 365, 282, 663, 402, 4008, 355, 291, 855, 10202, 721, 67, 14, 1450, 12, 359, 17271, 4317, 8, 88, 9, 367, 671, 315, 286, 14, 362, 3223, 9383, 2378, 347, 636, 495, 721, 277, 304, 267, 4123, 275, 3087, 267, 367, 1007, 315, 291, 855, 807, 10651, 288, 1139, 275, 291, 855, 807, 12298, 954, 61, 288, 340, 730, 8, 637, 9, 1137, 769, 26, 355, 4123, 847, 2071, 83, 520, 450, 83, 60, 78, 2, 450, 334, 954, 12, 1139, 9, 288, 587, 26, 355, 367, 671, 315, 1139, 26, 15324, 4123, 847, 1867, 78, 221, 3680, 904, 8, 88, 855, 495, 31261, 1294, 4582, 78, 2237, 267, 372, 4123, 339, 347, 636, 2722, 721, 277, 304, 267, 4123, 275, 3087, 267, 367, 1007, 315, 291, 855, 807, 10651, 288, 1139, 275, 291, 855, 807, 12298, 954, 61, 288, 340, 730, 8, 637, 9, 1137, 769, 26, 355, 4123, 847, 23054, 83, 6598, 83, 26191, 83, 3072, 78, 2, 450, 334, 954, 12, 1139, 12, 1007, 9, 288, 587, 26, 355, 367, 671, 315, 1139, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
InsomniaAOSP/platform_kernel_htc_m7
tools/perf/scripts/python/netdev-times.py
11271
15048
# Display a process of packets and processed time. # It helps us to investigate networking or network device. # # options # tx: show only tx chart # rx: show only rx chart # dev=: show only thing related to specified device # debug: work with debug mode. It shows buffer status. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * all_event_list = []; # insert all tracepoint event related with this script irq_dic = {}; # key is cpu and value is a list which stacks irqs # which raise NET_RX softirq net_rx_dic = {}; # key is cpu and value include time of NET_RX softirq-entry # and a list which stacks receive receive_hunk_list = []; # a list which include a sequence of receive events rx_skb_list = []; # received packet list for matching # skb_copy_datagram_iovec buffer_budget = 65536; # the budget of rx_skb_list, tx_queue_list and # tx_xmit_list of_count_rx_skb_list = 0; # overflow count tx_queue_list = []; # list of packets which pass through dev_queue_xmit of_count_tx_queue_list = 0; # overflow count tx_xmit_list = []; # list of packets which pass through dev_hard_start_xmit of_count_tx_xmit_list = 0; # overflow count tx_free_list = []; # list of packets which is freed # options show_tx = 0; show_rx = 0; dev = 0; # store a name of device specified by option "dev=" debug = 0; # indices of event_info tuple EINFO_IDX_NAME= 0 EINFO_IDX_CONTEXT=1 EINFO_IDX_CPU= 2 EINFO_IDX_TIME= 3 EINFO_IDX_PID= 4 EINFO_IDX_COMM= 5 # Calculate a time interval(msec) from src(nsec) to dst(nsec) def diff_msec(src, dst): return (dst - src) / 1000000.0 # Display a process of transmitting a packet def print_transmit(hunk): if dev != 0 and hunk['dev'].find(dev) < 0: return print "%7s %5d %6d.%06dsec %12.3fmsec %12.3fmsec" % \ (hunk['dev'], hunk['len'], nsecs_secs(hunk['queue_t']), nsecs_nsecs(hunk['queue_t'])/1000, diff_msec(hunk['queue_t'], hunk['xmit_t']), diff_msec(hunk['xmit_t'], hunk['free_t'])) # Format for displaying rx packet processing PF_IRQ_ENTRY= " irq_entry(+%.3fmsec irq=%d:%s)" PF_SOFT_ENTRY=" softirq_entry(+%.3fmsec)" PF_NAPI_POLL= " napi_poll_exit(+%.3fmsec %s)" PF_JOINT= " |" PF_WJOINT= " | |" PF_NET_RECV= " |---netif_receive_skb(+%.3fmsec skb=%x len=%d)" PF_NET_RX= " |---netif_rx(+%.3fmsec skb=%x)" PF_CPY_DGRAM= " | skb_copy_datagram_iovec(+%.3fmsec %d:%s)" PF_KFREE_SKB= " | kfree_skb(+%.3fmsec location=%x)" PF_CONS_SKB= " | consume_skb(+%.3fmsec)" # Display a process of received packets and interrputs associated with # a NET_RX softirq def print_receive(hunk): show_hunk = 0 irq_list = hunk['irq_list'] cpu = irq_list[0]['cpu'] base_t = irq_list[0]['irq_ent_t'] # check if this hunk should be showed if dev != 0: for i in range(len(irq_list)): if irq_list[i]['name'].find(dev) >= 0: show_hunk = 1 break else: show_hunk = 1 if show_hunk == 0: return print "%d.%06dsec cpu=%d" % \ (nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu) for i in range(len(irq_list)): print PF_IRQ_ENTRY % \ (diff_msec(base_t, irq_list[i]['irq_ent_t']), irq_list[i]['irq'], irq_list[i]['name']) print PF_JOINT irq_event_list = irq_list[i]['event_list'] for j in range(len(irq_event_list)): irq_event = irq_event_list[j] if irq_event['event'] == 'netif_rx': print PF_NET_RX % \ (diff_msec(base_t, irq_event['time']), irq_event['skbaddr']) print PF_JOINT print PF_SOFT_ENTRY % \ diff_msec(base_t, hunk['sirq_ent_t']) print PF_JOINT event_list = hunk['event_list'] for i in range(len(event_list)): event = event_list[i] if event['event_name'] == 'napi_poll': print PF_NAPI_POLL % \ (diff_msec(base_t, event['event_t']), event['dev']) if i == len(event_list) - 1: print "" else: print PF_JOINT else: print PF_NET_RECV % \ (diff_msec(base_t, event['event_t']), event['skbaddr'], event['len']) if 'comm' in event.keys(): print PF_WJOINT print PF_CPY_DGRAM % \ (diff_msec(base_t, event['comm_t']), event['pid'], event['comm']) elif 'handle' in event.keys(): print PF_WJOINT if event['handle'] == "kfree_skb": print PF_KFREE_SKB % \ (diff_msec(base_t, event['comm_t']), event['location']) elif event['handle'] == "consume_skb": print PF_CONS_SKB % \ diff_msec(base_t, event['comm_t']) print PF_JOINT def trace_begin(): global show_tx global show_rx global dev global debug for i in range(len(sys.argv)): if i == 0: continue arg = sys.argv[i] if arg == 'tx': show_tx = 1 elif arg =='rx': show_rx = 1 elif arg.find('dev=',0, 4) >= 0: dev = arg[4:] elif arg == 'debug': debug = 1 if show_tx == 0 and show_rx == 0: show_tx = 1 show_rx = 1 def trace_end(): # order all events in time all_event_list.sort(lambda a,b :cmp(a[EINFO_IDX_TIME], b[EINFO_IDX_TIME])) # process all events for i in range(len(all_event_list)): event_info = all_event_list[i] name = event_info[EINFO_IDX_NAME] if name == 'irq__softirq_exit': handle_irq_softirq_exit(event_info) elif name == 'irq__softirq_entry': handle_irq_softirq_entry(event_info) elif name == 'irq__softirq_raise': handle_irq_softirq_raise(event_info) elif name == 'irq__irq_handler_entry': handle_irq_handler_entry(event_info) elif name == 'irq__irq_handler_exit': handle_irq_handler_exit(event_info) elif name == 'napi__napi_poll': handle_napi_poll(event_info) elif name == 'net__netif_receive_skb': handle_netif_receive_skb(event_info) elif name == 'net__netif_rx': handle_netif_rx(event_info) elif name == 'skb__skb_copy_datagram_iovec': handle_skb_copy_datagram_iovec(event_info) elif name == 'net__net_dev_queue': handle_net_dev_queue(event_info) elif name == 'net__net_dev_xmit': handle_net_dev_xmit(event_info) elif name == 'skb__kfree_skb': handle_kfree_skb(event_info) elif name == 'skb__consume_skb': handle_consume_skb(event_info) # display receive hunks if show_rx: for i in range(len(receive_hunk_list)): print_receive(receive_hunk_list[i]) # display transmit hunks if show_tx: print " dev len Qdisc " \ " netdevice free" for i in range(len(tx_free_list)): print_transmit(tx_free_list[i]) if debug: print "debug buffer status" print "----------------------------" print "xmit Qdisc:remain:%d overflow:%d" % \ (len(tx_queue_list), of_count_tx_queue_list) print "xmit netdevice:remain:%d overflow:%d" % \ (len(tx_xmit_list), of_count_tx_xmit_list) print "receive:remain:%d overflow:%d" % \ (len(rx_skb_list), of_count_rx_skb_list) # called from perf, when it finds a correspoinding event def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, vec): if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX": return event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec) all_event_list.append(event_info) def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, vec): if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX": return event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec) all_event_list.append(event_info) def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, vec): if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX": return event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec) all_event_list.append(event_info) def irq__irq_handler_entry(name, context, cpu, sec, nsec, pid, comm, irq, irq_name): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, irq_name) all_event_list.append(event_info) def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, irq, ret): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret) all_event_list.append(event_info) def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, napi, dev_name): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, napi, dev_name) all_event_list.append(event_info) def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr, skblen, dev_name): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, skbaddr, skblen, dev_name) all_event_list.append(event_info) def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, skbaddr, skblen, dev_name): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, skbaddr, skblen, dev_name) all_event_list.append(event_info) def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm, skbaddr, skblen, dev_name): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, skbaddr, skblen, dev_name) all_event_list.append(event_info) def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm, skbaddr, skblen, rc, dev_name): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, skbaddr, skblen, rc ,dev_name) all_event_list.append(event_info) def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr, protocol, location): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, skbaddr, protocol, location) all_event_list.append(event_info) def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, skbaddr) all_event_list.append(event_info) def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm, skbaddr, skblen): event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, skbaddr, skblen) all_event_list.append(event_info) def handle_irq_handler_entry(event_info): (name, context, cpu, time, pid, comm, irq, irq_name) = event_info if cpu not in irq_dic.keys(): irq_dic[cpu] = [] irq_record = {'irq':irq, 'name':irq_name, 'cpu':cpu, 'irq_ent_t':time} irq_dic[cpu].append(irq_record) def handle_irq_handler_exit(event_info): (name, context, cpu, time, pid, comm, irq, ret) = event_info if cpu not in irq_dic.keys(): return irq_record = irq_dic[cpu].pop() if irq != irq_record['irq']: return irq_record.update({'irq_ext_t':time}) # if an irq doesn't include NET_RX softirq, drop. if 'event_list' in irq_record.keys(): irq_dic[cpu].append(irq_record) def handle_irq_softirq_raise(event_info): (name, context, cpu, time, pid, comm, vec) = event_info if cpu not in irq_dic.keys() \ or len(irq_dic[cpu]) == 0: return irq_record = irq_dic[cpu].pop() if 'event_list' in irq_record.keys(): irq_event_list = irq_record['event_list'] else: irq_event_list = [] irq_event_list.append({'time':time, 'event':'sirq_raise'}) irq_record.update({'event_list':irq_event_list}) irq_dic[cpu].append(irq_record) def handle_irq_softirq_entry(event_info): (name, context, cpu, time, pid, comm, vec) = event_info net_rx_dic[cpu] = {'sirq_ent_t':time, 'event_list':[]} def handle_irq_softirq_exit(event_info): (name, context, cpu, time, pid, comm, vec) = event_info irq_list = [] event_list = 0 if cpu in irq_dic.keys(): irq_list = irq_dic[cpu] del irq_dic[cpu] if cpu in net_rx_dic.keys(): sirq_ent_t = net_rx_dic[cpu]['sirq_ent_t'] event_list = net_rx_dic[cpu]['event_list'] del net_rx_dic[cpu] if irq_list == [] or event_list == 0: return rec_data = {'sirq_ent_t':sirq_ent_t, 'sirq_ext_t':time, 'irq_list':irq_list, 'event_list':event_list} # merge information realted to a NET_RX softirq receive_hunk_list.append(rec_data) def handle_napi_poll(event_info): (name, context, cpu, time, pid, comm, napi, dev_name) = event_info if cpu in net_rx_dic.keys(): event_list = net_rx_dic[cpu]['event_list'] rec_data = {'event_name':'napi_poll', 'dev':dev_name, 'event_t':time} event_list.append(rec_data) def handle_netif_rx(event_info): (name, context, cpu, time, pid, comm, skbaddr, skblen, dev_name) = event_info if cpu not in irq_dic.keys() \ or len(irq_dic[cpu]) == 0: return irq_record = irq_dic[cpu].pop() if 'event_list' in irq_record.keys(): irq_event_list = irq_record['event_list'] else: irq_event_list = [] irq_event_list.append({'time':time, 'event':'netif_rx', 'skbaddr':skbaddr, 'skblen':skblen, 'dev_name':dev_name}) irq_record.update({'event_list':irq_event_list}) irq_dic[cpu].append(irq_record) def handle_netif_receive_skb(event_info): global of_count_rx_skb_list (name, context, cpu, time, pid, comm, skbaddr, skblen, dev_name) = event_info if cpu in net_rx_dic.keys(): rec_data = {'event_name':'netif_receive_skb', 'event_t':time, 'skbaddr':skbaddr, 'len':skblen} event_list = net_rx_dic[cpu]['event_list'] event_list.append(rec_data) rx_skb_list.insert(0, rec_data) if len(rx_skb_list) > buffer_budget: rx_skb_list.pop() of_count_rx_skb_list += 1 def handle_net_dev_queue(event_info): global of_count_tx_queue_list (name, context, cpu, time, pid, comm, skbaddr, skblen, dev_name) = event_info skb = {'dev':dev_name, 'skbaddr':skbaddr, 'len':skblen, 'queue_t':time} tx_queue_list.insert(0, skb) if len(tx_queue_list) > buffer_budget: tx_queue_list.pop() of_count_tx_queue_list += 1 def handle_net_dev_xmit(event_info): global of_count_tx_xmit_list (name, context, cpu, time, pid, comm, skbaddr, skblen, rc, dev_name) = event_info if rc == 0: # NETDEV_TX_OK for i in range(len(tx_queue_list)): skb = tx_queue_list[i] if skb['skbaddr'] == skbaddr: skb['xmit_t'] = time tx_xmit_list.insert(0, skb) del tx_queue_list[i] if len(tx_xmit_list) > buffer_budget: tx_xmit_list.pop() of_count_tx_xmit_list += 1 return def handle_kfree_skb(event_info): (name, context, cpu, time, pid, comm, skbaddr, protocol, location) = event_info for i in range(len(tx_queue_list)): skb = tx_queue_list[i] if skb['skbaddr'] == skbaddr: del tx_queue_list[i] return for i in range(len(tx_xmit_list)): skb = tx_xmit_list[i] if skb['skbaddr'] == skbaddr: skb['free_t'] = time tx_free_list.append(skb) del tx_xmit_list[i] return for i in range(len(rx_skb_list)): rec_data = rx_skb_list[i] if rec_data['skbaddr'] == skbaddr: rec_data.update({'handle':"kfree_skb", 'comm':comm, 'pid':pid, 'comm_t':time}) del rx_skb_list[i] return def handle_consume_skb(event_info): (name, context, cpu, time, pid, comm, skbaddr) = event_info for i in range(len(tx_xmit_list)): skb = tx_xmit_list[i] if skb['skbaddr'] == skbaddr: skb['free_t'] = time tx_free_list.append(skb) del tx_xmit_list[i] return def handle_skb_copy_datagram_iovec(event_info): (name, context, cpu, time, pid, comm, skbaddr, skblen) = event_info for i in range(len(rx_skb_list)): rec_data = rx_skb_list[i] if skbaddr == rec_data['skbaddr']: rec_data.update({'handle':"skb_copy_datagram_iovec", 'comm':comm, 'pid':pid, 'comm_t':time}) del rx_skb_list[i] return
gpl-2.0
[ 3, 12175, 282, 2112, 402, 14593, 436, 7686, 900, 14, 199, 3, 2779, 22577, 2739, 370, 315, 27174, 323, 2784, 316, 503, 2784, 2243, 14, 199, 3, 199, 3, 1511, 199, 3, 4773, 26, 2498, 1454, 4773, 10943, 199, 3, 12951, 26, 2498, 1454, 12951, 10943, 199, 3, 4866, 29, 26, 2498, 1454, 8377, 4048, 370, 2013, 2243, 199, 3, 3105, 26, 1736, 543, 3105, 818, 14, 2779, 13703, 3335, 2004, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 452, 63, 1430, 63, 513, 275, 22750, 327, 5518, 1006, 3307, 1403, 1566, 4048, 543, 642, 2884, 199, 7277, 63, 5000, 275, 27978, 327, 790, 365, 5033, 436, 574, 365, 282, 769, 1314, 26733, 10476, 83, 1598, 327, 1314, 746, 18340, 63, 15361, 880, 15493, 199, 846, 63, 6872, 63, 5000, 275, 27978, 327, 790, 365, 5033, 436, 574, 2387, 900, 402, 18340, 63, 15361, 880, 15493, 13, 2373, 686, 327, 436, 282, 769, 1314, 26733, 9128, 199, 9391, 63, 17428, 63, 513, 275, 22750, 327, 282, 769, 1314, 2387, 282, 3414, 402, 9128, 4474, 199, 6872, 63, 6852, 63, 513, 275, 22750, 327, 3086, 3644, 769, 367, 4877, 686, 755, 327, 11448, 63, 1574, 63, 25443, 63, 30463, 199, 199, 2738, 63, 16501, 275, 25980, 27, 327, 314, 1032, 14080, 402, 12951, 63, 6852, 63, 513, 12, 4773, 63, 1825, 63, 513, 436, 686, 755, 327, 4773, 63, 14217, 63, 513, 199, 1618, 63, 835, 63, 6872, 63, 6852, 63, 513, 275, 378, 27, 327, 15784, 2338, 199, 199, 2347, 63, 1825, 63, 513, 275, 22750, 327, 769, 402, 14593, 1314, 986, 4012, 4866, 63, 1825, 63, 14217, 199, 1618, 63, 835, 63, 2347, 63, 1825, 63, 513, 275, 378, 27, 327, 15784, 2338, 199, 199, 2347, 63, 14217, 63, 513, 275, 22750, 221, 327, 769, 402, 14593, 1314, 986, 4012, 4866, 63, 8726, 63, 928, 63, 14217, 199, 1618, 63, 835, 63, 2347, 63, 14217, 63, 513, 275, 378, 27, 327, 15784, 2338, 199, 199, 2347, 63, 4624, 63, 513, 275, 22750, 221, 327, 769, 402, 14593, 1314, 365, 23694, 199, 199, 3, 1511, 199, 2384, 63, 2347, 275, 378, 27, 199, 2384, 63, 6872, 275, 378, 27, 199, 2374, 275, 378, 27, 327, 3877, 282, 536, 402, 2243, 2013, 701, 945, 298, 2374, 628, 199, 1757, 275, 378, 27, 199, 199, 3, 4918, 402, 1566, 63, 815, 2008, 199, 26556, 63, 20037, 63, 2339, 29, 257, 378, 199, 26556, 63, 20037, 63, 9059, 29, 17, 199, 26556, 63, 20037, 63, 11011, 29, 259, 499, 199, 26556, 63, 20037, 63, 4961, 29, 257, 650, 199, 26556, 63, 20037, 63, 16098, 29, 259, 841, 199, 26556, 63, 20037, 63, 5378, 29, 257, 959, 199, 199, 3, 12707, 282, 900, 6252, 8, 19764, 9, 687, 2928, 8, 78, 3321, 9, 370, 5042, 8, 78, 3321, 9, 199, 318, 3915, 63, 19764, 8, 2164, 12, 5042, 304, 199, 198, 1107, 334, 5119, 446, 2928, 9, 1182, 19492, 14, 16, 199, 199, 3, 12175, 282, 2112, 402, 27754, 1337, 282, 3644, 199, 318, 870, 63, 31399, 8, 17428, 304, 199, 198, 692, 4866, 1137, 378, 436, 19988, 459, 2374, 2278, 1623, 8, 2374, 9, 665, 378, 26, 507, 198, 1107, 199, 198, 1361, 2071, 23, 83, 450, 21, 68, 450, 22, 68, 4111, 1690, 68, 3321, 450, 713, 14, 19, 25154, 420, 450, 713, 14, 19, 25154, 2, 450, 971, 507, 198, 8, 17428, 459, 2374, 995, 19988, 459, 552, 995, 507, 198, 9618, 63, 4855, 8, 17428, 459, 1825, 63, 84, 3815, 507, 198, 9618, 63, 9618, 8, 17428, 459, 1825, 63, 84, 1105, 15, 5279, 12, 507, 198, 3028, 63, 19764, 8, 17428, 459, 1825, 63, 84, 995, 19988, 459, 14217, 63, 84, 3815, 507, 198, 3028, 63, 19764, 8, 17428, 459, 14217, 63, 84, 995, 19988, 459, 4624, 63, 84, 5156, 199, 199, 3, 9701, 367, 20589, 12951, 3644, 6661, 199, 10966, 63, 3927, 49, 63, 7285, 29, 298, 221, 10476, 63, 2373, 28643, 19, 25154, 10476, 2458, 68, 2689, 83, 2924, 199, 10966, 63, 26999, 63, 7285, 628, 221, 880, 15493, 63, 2373, 28643, 19, 25154, 2924, 199, 10966, 63, 46, 3735, 63, 16428, 29, 298, 221, 302, 1246, 63, 6843, 63, 2224, 28643, 19, 25154, 450, 83, 2924, 199, 10966, 63, 24931, 29, 258, 298, 260, 1204, 2, 199, 10966, 63, 55, 24931, 29, 259, 298, 260, 1204, 3322, 1204, 2, 199, 10966, 63, 7278, 63, 9481, 54, 29, 221, 298, 260, 1204, 2595, 20869, 63, 9391, 63, 6852, 28643, 19, 25154, 11448, 2458, 88, 822, 2458, 68, 2924, 199, 10966, 63, 7278, 63, 15361, 29, 259, 298, 260, 1204, 2595, 20869, 63, 6872, 28643, 19, 25154, 11448, 2458, 88, 2924, 199, 10966, 63, 2890, 57, 63, 25351, 29, 298, 260, 1204, 420, 11448, 63, 1574, 63, 25443, 63, 30463, 28643, 19, 25154, 450, 68, 2689, 83, 2924, 199, 10966, 63, 17706, 5271, 63, 8656, 34, 29, 298, 260, 1204, 420, 1022, 4624, 63, 6852, 28643, 19, 25154, 2909, 2458, 88, 2924, 199, 10966, 63, 1864, 51, 63, 8656, 34, 29, 221, 298, 260, 1204, 420, 9451, 63, 6852, 28643, 19, 25154, 2924, 199, 199, 3, 12175, 282, 2112, 402, 3086, 14593, 436, 1640, 82, 524, 83, 4568, 543, 199, 3, 282, 18340, 63, 15361, 880, 15493, 199, 318, 870, 63, 9391, 8, 17428, 304, 199, 198, 2384, 63, 17428, 275, 378, 199, 198, 7277, 63, 513, 275, 19988, 459, 7277, 63, 513, 418, 199, 198, 3541, 275, 10476, 63, 513, 59, 16, 2733, 3541, 418, 199, 198, 1095, 63, 84, 275, 10476, 63, 513, 59, 16, 2733, 7277, 63, 484, 63, 84, 418, 199, 198, 3, 1104, 340, 642, 19988, 1077, 506, 2498, 379, 199, 198, 692, 4866, 1137, 378, 26, 507, 198, 509, 284, 315, 1425, 8, 552, 8, 7277, 63, 513, 2298, 686, 198, 692, 10476, 63, 513 ]
[ 12175, 282, 2112, 402, 14593, 436, 7686, 900, 14, 199, 3, 2779, 22577, 2739, 370, 315, 27174, 323, 2784, 316, 503, 2784, 2243, 14, 199, 3, 199, 3, 1511, 199, 3, 4773, 26, 2498, 1454, 4773, 10943, 199, 3, 12951, 26, 2498, 1454, 12951, 10943, 199, 3, 4866, 29, 26, 2498, 1454, 8377, 4048, 370, 2013, 2243, 199, 3, 3105, 26, 1736, 543, 3105, 818, 14, 2779, 13703, 3335, 2004, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 452, 63, 1430, 63, 513, 275, 22750, 327, 5518, 1006, 3307, 1403, 1566, 4048, 543, 642, 2884, 199, 7277, 63, 5000, 275, 27978, 327, 790, 365, 5033, 436, 574, 365, 282, 769, 1314, 26733, 10476, 83, 1598, 327, 1314, 746, 18340, 63, 15361, 880, 15493, 199, 846, 63, 6872, 63, 5000, 275, 27978, 327, 790, 365, 5033, 436, 574, 2387, 900, 402, 18340, 63, 15361, 880, 15493, 13, 2373, 686, 327, 436, 282, 769, 1314, 26733, 9128, 199, 9391, 63, 17428, 63, 513, 275, 22750, 327, 282, 769, 1314, 2387, 282, 3414, 402, 9128, 4474, 199, 6872, 63, 6852, 63, 513, 275, 22750, 327, 3086, 3644, 769, 367, 4877, 686, 755, 327, 11448, 63, 1574, 63, 25443, 63, 30463, 199, 199, 2738, 63, 16501, 275, 25980, 27, 327, 314, 1032, 14080, 402, 12951, 63, 6852, 63, 513, 12, 4773, 63, 1825, 63, 513, 436, 686, 755, 327, 4773, 63, 14217, 63, 513, 199, 1618, 63, 835, 63, 6872, 63, 6852, 63, 513, 275, 378, 27, 327, 15784, 2338, 199, 199, 2347, 63, 1825, 63, 513, 275, 22750, 327, 769, 402, 14593, 1314, 986, 4012, 4866, 63, 1825, 63, 14217, 199, 1618, 63, 835, 63, 2347, 63, 1825, 63, 513, 275, 378, 27, 327, 15784, 2338, 199, 199, 2347, 63, 14217, 63, 513, 275, 22750, 221, 327, 769, 402, 14593, 1314, 986, 4012, 4866, 63, 8726, 63, 928, 63, 14217, 199, 1618, 63, 835, 63, 2347, 63, 14217, 63, 513, 275, 378, 27, 327, 15784, 2338, 199, 199, 2347, 63, 4624, 63, 513, 275, 22750, 221, 327, 769, 402, 14593, 1314, 365, 23694, 199, 199, 3, 1511, 199, 2384, 63, 2347, 275, 378, 27, 199, 2384, 63, 6872, 275, 378, 27, 199, 2374, 275, 378, 27, 327, 3877, 282, 536, 402, 2243, 2013, 701, 945, 298, 2374, 628, 199, 1757, 275, 378, 27, 199, 199, 3, 4918, 402, 1566, 63, 815, 2008, 199, 26556, 63, 20037, 63, 2339, 29, 257, 378, 199, 26556, 63, 20037, 63, 9059, 29, 17, 199, 26556, 63, 20037, 63, 11011, 29, 259, 499, 199, 26556, 63, 20037, 63, 4961, 29, 257, 650, 199, 26556, 63, 20037, 63, 16098, 29, 259, 841, 199, 26556, 63, 20037, 63, 5378, 29, 257, 959, 199, 199, 3, 12707, 282, 900, 6252, 8, 19764, 9, 687, 2928, 8, 78, 3321, 9, 370, 5042, 8, 78, 3321, 9, 199, 318, 3915, 63, 19764, 8, 2164, 12, 5042, 304, 199, 198, 1107, 334, 5119, 446, 2928, 9, 1182, 19492, 14, 16, 199, 199, 3, 12175, 282, 2112, 402, 27754, 1337, 282, 3644, 199, 318, 870, 63, 31399, 8, 17428, 304, 199, 198, 692, 4866, 1137, 378, 436, 19988, 459, 2374, 2278, 1623, 8, 2374, 9, 665, 378, 26, 507, 198, 1107, 199, 198, 1361, 2071, 23, 83, 450, 21, 68, 450, 22, 68, 4111, 1690, 68, 3321, 450, 713, 14, 19, 25154, 420, 450, 713, 14, 19, 25154, 2, 450, 971, 507, 198, 8, 17428, 459, 2374, 995, 19988, 459, 552, 995, 507, 198, 9618, 63, 4855, 8, 17428, 459, 1825, 63, 84, 3815, 507, 198, 9618, 63, 9618, 8, 17428, 459, 1825, 63, 84, 1105, 15, 5279, 12, 507, 198, 3028, 63, 19764, 8, 17428, 459, 1825, 63, 84, 995, 19988, 459, 14217, 63, 84, 3815, 507, 198, 3028, 63, 19764, 8, 17428, 459, 14217, 63, 84, 995, 19988, 459, 4624, 63, 84, 5156, 199, 199, 3, 9701, 367, 20589, 12951, 3644, 6661, 199, 10966, 63, 3927, 49, 63, 7285, 29, 298, 221, 10476, 63, 2373, 28643, 19, 25154, 10476, 2458, 68, 2689, 83, 2924, 199, 10966, 63, 26999, 63, 7285, 628, 221, 880, 15493, 63, 2373, 28643, 19, 25154, 2924, 199, 10966, 63, 46, 3735, 63, 16428, 29, 298, 221, 302, 1246, 63, 6843, 63, 2224, 28643, 19, 25154, 450, 83, 2924, 199, 10966, 63, 24931, 29, 258, 298, 260, 1204, 2, 199, 10966, 63, 55, 24931, 29, 259, 298, 260, 1204, 3322, 1204, 2, 199, 10966, 63, 7278, 63, 9481, 54, 29, 221, 298, 260, 1204, 2595, 20869, 63, 9391, 63, 6852, 28643, 19, 25154, 11448, 2458, 88, 822, 2458, 68, 2924, 199, 10966, 63, 7278, 63, 15361, 29, 259, 298, 260, 1204, 2595, 20869, 63, 6872, 28643, 19, 25154, 11448, 2458, 88, 2924, 199, 10966, 63, 2890, 57, 63, 25351, 29, 298, 260, 1204, 420, 11448, 63, 1574, 63, 25443, 63, 30463, 28643, 19, 25154, 450, 68, 2689, 83, 2924, 199, 10966, 63, 17706, 5271, 63, 8656, 34, 29, 298, 260, 1204, 420, 1022, 4624, 63, 6852, 28643, 19, 25154, 2909, 2458, 88, 2924, 199, 10966, 63, 1864, 51, 63, 8656, 34, 29, 221, 298, 260, 1204, 420, 9451, 63, 6852, 28643, 19, 25154, 2924, 199, 199, 3, 12175, 282, 2112, 402, 3086, 14593, 436, 1640, 82, 524, 83, 4568, 543, 199, 3, 282, 18340, 63, 15361, 880, 15493, 199, 318, 870, 63, 9391, 8, 17428, 304, 199, 198, 2384, 63, 17428, 275, 378, 199, 198, 7277, 63, 513, 275, 19988, 459, 7277, 63, 513, 418, 199, 198, 3541, 275, 10476, 63, 513, 59, 16, 2733, 3541, 418, 199, 198, 1095, 63, 84, 275, 10476, 63, 513, 59, 16, 2733, 7277, 63, 484, 63, 84, 418, 199, 198, 3, 1104, 340, 642, 19988, 1077, 506, 2498, 379, 199, 198, 692, 4866, 1137, 378, 26, 507, 198, 509, 284, 315, 1425, 8, 552, 8, 7277, 63, 513, 2298, 686, 198, 692, 10476, 63, 513, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sebalas/fake-useragent
fake_useragent/utils.py
1
2970
import os import re from . import settings try: # Python 2 from urllib import urlopen, quote_plus except ImportError: # Python 3 from urllib.request import urlopen from urllib.parse import quote_plus try: import json except ImportError: import simplejson as json def get(url, annex=None): if annex is not None: url = url % (quote_plus(annex), ) return urlopen(url).read() def get_browsers(): """ very very hardcoded/dirty re/split stuff, but no dependencies """ html = get(settings.BROWSERS_STATS_PAGE) html = html.decode('windows-1252') html = html.split('<table class="reference notranslate">')[1] html = html.split('</table>')[0] browsers = re.findall(r'\.asp">(.+?)<', html, re.UNICODE) for value, override in settings.OVERRIDES: browsers = [ value if browser == override else browser for browser in browsers ] browsers_statistics = re.findall( r'td\sclass="right">(.+?)\s', html, re.UNICODE ) # TODO: ensure encoding return list(zip(browsers, browsers_statistics)) def get_browser_versions(browser): """ very very hardcoded/dirty re/split stuff, but no dependencies """ html = get(settings.BROWSER_BASE_PAGE, browser) html = html.decode('iso-8859-1') html = html.split('<div id=\'liste\'>')[1] html = html.split('</div>')[0] browsers_iter = re.finditer(r'\.php\'>(.+?)</a', html, re.UNICODE) count = 0 browsers = [] for browser in browsers_iter: if 'more' in browser.group(1).lower(): continue # TODO: ensure encoding browsers.append(browser.group(1)) count += 1 if count == settings.BROWSERS_COUNT_LIMIT: break return browsers def load(): browsers_dict = {} randomize_dict = {} for item in get_browsers(): browser, percent = item browser_key = browser for replacement in settings.REPLACEMENTS: browser_key = browser_key.replace(replacement, '') browser_key = browser_key.lower() browsers_dict[browser_key] = get_browser_versions(browser) for counter in range(int(float(percent))): randomize_dict[str(len(randomize_dict))] = browser_key db = {} db['browsers'] = browsers_dict db['randomize'] = randomize_dict return db def write(data): data = json.dumps(data, ensure_ascii=False) # no codecs\with for python 2.5 f = open(settings.DB, 'w+') f.write(data) f.close() def read(): # no codecs\with for python 2.5 f = open(settings.DB, 'r') data = f.read() f.close() return json.loads(data) def exist(): return os.path.isfile(settings.DB) def rm(): if exist(): os.remove(settings.DB) def update(): if exist(): rm() write(load()) def load_cached(): if not exist(): update() return read()
apache-2.0
[ 646, 747, 199, 646, 295, 199, 199, 504, 1275, 492, 2202, 199, 199, 893, 26, 221, 327, 2018, 499, 272, 687, 4011, 492, 18279, 12, 6313, 63, 6666, 199, 2590, 3545, 26, 221, 327, 2018, 650, 272, 687, 4011, 14, 1069, 492, 18279, 272, 687, 4011, 14, 1122, 492, 6313, 63, 6666, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 421, 199, 318, 664, 8, 633, 12, 376, 14743, 29, 403, 304, 272, 340, 376, 14743, 365, 440, 488, 26, 267, 1166, 275, 1166, 450, 334, 3513, 63, 6666, 8, 1189, 476, 395, 776, 272, 372, 18279, 8, 633, 680, 739, 342, 421, 199, 318, 664, 63, 5750, 83, 837, 272, 408, 272, 7437, 7437, 7508, 15282, 15, 8799, 295, 15, 1294, 8292, 12, 1325, 949, 5124, 272, 408, 272, 3517, 275, 664, 8, 1751, 14, 31956, 3279, 51, 63, 19202, 63, 12898, 9, 272, 3517, 275, 3517, 14, 2708, 360, 8258, 13, 19364, 358, 272, 3517, 275, 3517, 14, 1294, 4827, 1224, 1021, 628, 4443, 440, 1320, 750, 1743, 5832, 17, 61, 272, 3517, 275, 3517, 14, 1294, 14264, 1224, 30, 5832, 16, 61, 339, 23776, 275, 295, 14, 6452, 8, 82, 1154, 14, 20222, 1743, 28149, 21528, 297, 3517, 12, 295, 14, 12819, 9, 339, 367, 574, 12, 4278, 315, 2202, 14, 30024, 998, 654, 26, 267, 23776, 275, 359, 288, 574, 340, 7042, 508, 4278, 587, 7042, 288, 367, 7042, 315, 23776, 267, 1622, 339, 23776, 63, 13724, 275, 295, 14, 6452, 8, 267, 519, 1133, 68, 60, 83, 533, 628, 1019, 1743, 28149, 2862, 83, 297, 3517, 12, 295, 14, 12819, 272, 776, 339, 327, 3254, 26, 4868, 2644, 339, 372, 769, 8, 3065, 8, 5750, 83, 12, 23776, 63, 13724, 430, 421, 199, 318, 664, 63, 5750, 63, 6234, 8, 5750, 304, 272, 408, 272, 7437, 7437, 7508, 15282, 15, 8799, 295, 15, 1294, 8292, 12, 1325, 949, 5124, 272, 408, 272, 3517, 275, 664, 8, 1751, 14, 31956, 3279, 63, 5825, 63, 12898, 12, 7042, 9, 272, 3517, 275, 3517, 14, 2708, 360, 4595, 13, 4830, 13, 17, 358, 272, 3517, 275, 3517, 14, 1294, 4827, 3015, 1305, 25641, 317, 1597, 3985, 30, 5832, 17, 61, 272, 3517, 275, 3517, 14, 1294, 14264, 3015, 30, 5832, 16, 61, 339, 23776, 63, 1661, 275, 295, 14, 19373, 8, 82, 1154, 14, 8624, 3985, 13661, 11198, 15939, 65, 297, 3517, 12, 295, 14, 12819, 9, 339, 2338, 275, 378, 339, 23776, 275, 942, 339, 367, 7042, 315, 23776, 63, 1661, 26, 267, 340, 283, 6878, 7, 315, 7042, 14, 923, 8, 17, 680, 2325, 837, 288, 1980, 398, 327, 3254, 26, 4868, 2644, 267, 23776, 14, 740, 8, 5750, 14, 923, 8, 17, 430, 267, 2338, 847, 413, 398, 340, 2338, 508, 2202, 14, 31956, 3279, 51, 63, 8760, 63, 13387, 26, 288, 2059, 339, 372, 23776, 421, 199, 318, 2248, 837, 272, 23776, 63, 807, 275, 1052, 272, 2196, 794, 63, 807, 275, 1052, 339, 367, 1242, 315, 664, 63, 5750, 83, 837, 267, 7042, 12, 8878, 275, 1242, 398, 7042, 63, 498, 275, 7042, 398, 367, 8343, 315, 2202, 14, 30583, 51, 26, 288, 7042, 63, 498, 275, 7042, 63, 498, 14, 1814, 8, 15895, 12, 4074, 398, 7042, 63, 498, 275, 7042, 63, 498, 14, 2325, 342, 398, 23776, 63, 807, 59, 5750, 63, 498, 61, 275, 664, 63, 5750, 63, 6234, 8, 5750, 9, 398, 367, 7055, 315, 1425, 8, 442, 8, 1609, 8, 7045, 15206, 288, 2196, 794, 63, 807, 59, 495, 8, 552, 8, 28610, 63, 807, 10524, 275, 7042, 63, 498, 339, 1592, 275, 1052, 272, 1592, 459, 5750, 83, 418, 275, 23776, 63, 807, 272, 1592, 459, 28610, 418, 275, 2196, 794, 63, 807, 339, 372, 1592, 421, 199, 318, 2218, 8, 576, 304, 272, 666, 275, 2022, 14, 4180, 8, 576, 12, 4868, 63, 4371, 29, 797, 9, 339, 327, 949, 6010, 60, 1045, 367, 2366, 499, 14, 21, 272, 289, 275, 1551, 8, 1751, 14, 2846, 12, 283, 87, 13854, 272, 289, 14, 952, 8, 576, 9, 272, 289, 14, 1600, 342, 421, 199, 318, 1586, 837, 272, 327, 949, 6010, 60, 1045, 367, 2366, 499, 14, 21, 272, 289, 275, 1551, 8, 1751, 14, 2846, 12, 283, 82, 358, 272, 666, 275, 289, 14, 739, 342, 272, 289, 14, 1600, 342, 339, 372, 2022, 14, 3640, 8, 576, 9, 421, 199, 318, 2187, 837, 272, 372, 747, 14, 515, 14, 6292, 8, 1751, 14, 2846, 9, 421, 199, 318, 14267, 837, 272, 340, 2187, 837, 267, 747, 14, 2168, 8, 1751, 14, 2846, 9, 421, 199, 318, 1678, 837, 272, 340, 2187, 837, 267, 14267, 342, 339, 2218, 8, 912, 1012, 421, 199, 318, 2248, 63, 5245, 837, 272, 340, 440, 2187, 837, 267, 1678, 342, 339, 372, 1586, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 646, 295, 199, 199, 504, 1275, 492, 2202, 199, 199, 893, 26, 221, 327, 2018, 499, 272, 687, 4011, 492, 18279, 12, 6313, 63, 6666, 199, 2590, 3545, 26, 221, 327, 2018, 650, 272, 687, 4011, 14, 1069, 492, 18279, 272, 687, 4011, 14, 1122, 492, 6313, 63, 6666, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 421, 199, 318, 664, 8, 633, 12, 376, 14743, 29, 403, 304, 272, 340, 376, 14743, 365, 440, 488, 26, 267, 1166, 275, 1166, 450, 334, 3513, 63, 6666, 8, 1189, 476, 395, 776, 272, 372, 18279, 8, 633, 680, 739, 342, 421, 199, 318, 664, 63, 5750, 83, 837, 272, 408, 272, 7437, 7437, 7508, 15282, 15, 8799, 295, 15, 1294, 8292, 12, 1325, 949, 5124, 272, 408, 272, 3517, 275, 664, 8, 1751, 14, 31956, 3279, 51, 63, 19202, 63, 12898, 9, 272, 3517, 275, 3517, 14, 2708, 360, 8258, 13, 19364, 358, 272, 3517, 275, 3517, 14, 1294, 4827, 1224, 1021, 628, 4443, 440, 1320, 750, 1743, 5832, 17, 61, 272, 3517, 275, 3517, 14, 1294, 14264, 1224, 30, 5832, 16, 61, 339, 23776, 275, 295, 14, 6452, 8, 82, 1154, 14, 20222, 1743, 28149, 21528, 297, 3517, 12, 295, 14, 12819, 9, 339, 367, 574, 12, 4278, 315, 2202, 14, 30024, 998, 654, 26, 267, 23776, 275, 359, 288, 574, 340, 7042, 508, 4278, 587, 7042, 288, 367, 7042, 315, 23776, 267, 1622, 339, 23776, 63, 13724, 275, 295, 14, 6452, 8, 267, 519, 1133, 68, 60, 83, 533, 628, 1019, 1743, 28149, 2862, 83, 297, 3517, 12, 295, 14, 12819, 272, 776, 339, 327, 3254, 26, 4868, 2644, 339, 372, 769, 8, 3065, 8, 5750, 83, 12, 23776, 63, 13724, 430, 421, 199, 318, 664, 63, 5750, 63, 6234, 8, 5750, 304, 272, 408, 272, 7437, 7437, 7508, 15282, 15, 8799, 295, 15, 1294, 8292, 12, 1325, 949, 5124, 272, 408, 272, 3517, 275, 664, 8, 1751, 14, 31956, 3279, 63, 5825, 63, 12898, 12, 7042, 9, 272, 3517, 275, 3517, 14, 2708, 360, 4595, 13, 4830, 13, 17, 358, 272, 3517, 275, 3517, 14, 1294, 4827, 3015, 1305, 25641, 317, 1597, 3985, 30, 5832, 17, 61, 272, 3517, 275, 3517, 14, 1294, 14264, 3015, 30, 5832, 16, 61, 339, 23776, 63, 1661, 275, 295, 14, 19373, 8, 82, 1154, 14, 8624, 3985, 13661, 11198, 15939, 65, 297, 3517, 12, 295, 14, 12819, 9, 339, 2338, 275, 378, 339, 23776, 275, 942, 339, 367, 7042, 315, 23776, 63, 1661, 26, 267, 340, 283, 6878, 7, 315, 7042, 14, 923, 8, 17, 680, 2325, 837, 288, 1980, 398, 327, 3254, 26, 4868, 2644, 267, 23776, 14, 740, 8, 5750, 14, 923, 8, 17, 430, 267, 2338, 847, 413, 398, 340, 2338, 508, 2202, 14, 31956, 3279, 51, 63, 8760, 63, 13387, 26, 288, 2059, 339, 372, 23776, 421, 199, 318, 2248, 837, 272, 23776, 63, 807, 275, 1052, 272, 2196, 794, 63, 807, 275, 1052, 339, 367, 1242, 315, 664, 63, 5750, 83, 837, 267, 7042, 12, 8878, 275, 1242, 398, 7042, 63, 498, 275, 7042, 398, 367, 8343, 315, 2202, 14, 30583, 51, 26, 288, 7042, 63, 498, 275, 7042, 63, 498, 14, 1814, 8, 15895, 12, 4074, 398, 7042, 63, 498, 275, 7042, 63, 498, 14, 2325, 342, 398, 23776, 63, 807, 59, 5750, 63, 498, 61, 275, 664, 63, 5750, 63, 6234, 8, 5750, 9, 398, 367, 7055, 315, 1425, 8, 442, 8, 1609, 8, 7045, 15206, 288, 2196, 794, 63, 807, 59, 495, 8, 552, 8, 28610, 63, 807, 10524, 275, 7042, 63, 498, 339, 1592, 275, 1052, 272, 1592, 459, 5750, 83, 418, 275, 23776, 63, 807, 272, 1592, 459, 28610, 418, 275, 2196, 794, 63, 807, 339, 372, 1592, 421, 199, 318, 2218, 8, 576, 304, 272, 666, 275, 2022, 14, 4180, 8, 576, 12, 4868, 63, 4371, 29, 797, 9, 339, 327, 949, 6010, 60, 1045, 367, 2366, 499, 14, 21, 272, 289, 275, 1551, 8, 1751, 14, 2846, 12, 283, 87, 13854, 272, 289, 14, 952, 8, 576, 9, 272, 289, 14, 1600, 342, 421, 199, 318, 1586, 837, 272, 327, 949, 6010, 60, 1045, 367, 2366, 499, 14, 21, 272, 289, 275, 1551, 8, 1751, 14, 2846, 12, 283, 82, 358, 272, 666, 275, 289, 14, 739, 342, 272, 289, 14, 1600, 342, 339, 372, 2022, 14, 3640, 8, 576, 9, 421, 199, 318, 2187, 837, 272, 372, 747, 14, 515, 14, 6292, 8, 1751, 14, 2846, 9, 421, 199, 318, 14267, 837, 272, 340, 2187, 837, 267, 747, 14, 2168, 8, 1751, 14, 2846, 9, 421, 199, 318, 1678, 837, 272, 340, 2187, 837, 267, 14267, 342, 339, 2218, 8, 912, 1012, 421, 199, 318, 2248, 63, 5245, 837, 272, 340, 440, 2187, 837, 267, 1678, 342, 339, 372, 1586, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Daeinar/norx-py
norx.py
1
7942
""" Python2 implementation of NORX. ------ :author: Philipp Jovanovic <philipp@jovanovic.io>, 2014-2015. :license: CC0, see LICENSE for more details. """ from struct import pack, unpack class NORX(object): def __init__(self, w=64, r=4, d=1, t=256): assert w in [32, 64] assert r >= 1 assert d >= 0 assert 10 * w >= t >= 0 self.NORX_W = w self.NORX_R = r self.NORX_D = d self.NORX_T = t self.NORX_N = w * 2 self.NORX_K = w * 4 self.NORX_B = w * 16 self.NORX_C = w * 6 self.RATE = self.NORX_B - self.NORX_C self.HEADER_TAG = 1 << 0 self.PAYLOAD_TAG = 1 << 1 self.TRAILER_TAG = 1 << 2 self.FINAL_TAG = 1 << 3 self.BRANCH_TAG = 1 << 4 self.MERGE_TAG = 1 << 5 self.BYTES_WORD = w / 8 self.BYTES_TAG = t / 8 self.WORDS_RATE = self.RATE / w self.BYTES_RATE = self.WORDS_RATE * self.BYTES_WORD if w == 32: self.R = (8, 11, 16, 31) self.U = (0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0x254F537A, 0x38531D48, 0x839C6E83, 0xF97A3AE5, 0x8C91D88C, 0x11EAFB59) self.M = 0xffffffff self.fmt = '<L' elif w == 64: self.R = (8, 19, 40, 63) self.U = (0x243F6A8885A308D3, 0x13198A2E03707344, 0xA4093822299F31D0, 0x082EFA98EC4E6C89, 0xAE8858DC339325A1, 0x670A134EE52D7FA6, 0xC4316D80CD967541, 0xD21DFBF8B630B762, 0x375A18D261E7F892, 0x343D1F187D92285B) self.M = 0xffffffffffffffff self.fmt = '<Q' def load(self, x): return unpack(self.fmt, x)[0] def store(self, x): return pack(self.fmt, x) def ROTR(self, a, r): return ((a >> r) | (a << (self.NORX_W - r))) & self.M def H(self, a, b): return ((a ^ b) ^ ((a & b) << 1)) & self.M def G(self, a, b, c, d): a = self.H(a, b) d = self.ROTR(a ^ d, self.R[0]) c = self.H(c, d) b = self.ROTR(b ^ c, self.R[1]) a = self.H(a, b) d = self.ROTR(a ^ d, self.R[2]) c = self.H(c, d) b = self.ROTR(b ^ c, self.R[3]) return a, b, c, d def F(self, S): # Column step S[0], S[4], S[8], S[12] = self.G(S[0], S[4], S[8], S[12]) S[1], S[5], S[9], S[13] = self.G(S[1], S[5], S[9], S[13]) S[2], S[6], S[10], S[14] = self.G(S[2], S[6], S[10], S[14]) S[3], S[7], S[11], S[15] = self.G(S[3], S[7], S[11], S[15]) # Diagonal step S[0], S[5], S[10], S[15] = self.G(S[0], S[5], S[10], S[15]) S[1], S[6], S[11], S[12] = self.G(S[1], S[6], S[11], S[12]) S[2], S[7], S[8], S[13] = self.G(S[2], S[7], S[8], S[13]) S[3], S[4], S[9], S[14] = self.G(S[3], S[4], S[9], S[14]) def permute(self, S): for i in xrange(self.NORX_R): self.F(S) def pad(self, x): y = bytearray(self.BYTES_RATE) y[:len(x)] = x y[len(x)] = 0x01 y[self.BYTES_RATE-1] |= 0x80 return y def init(self, S, n, k): b = self.BYTES_WORD K = [self.load(k[b*i:b*(i+1)]) for i in xrange(self.NORX_K / self.NORX_W)] N = [self.load(n[b*i:b*(i+1)]) for i in xrange(self.NORX_N / self.NORX_W)] U = self.U S[0], S[1], S[2], S[3] = U[0], N[0], N[1], U[1] S[4], S[5], S[6], S[7] = K[0], K[1], K[2], K[3] S[8], S[9], S[10], S[11] = U[2], U[3], U[4], U[5] S[12], S[13], S[14], S[15] = U[6], U[7], U[8], U[9] S[12] ^= self.NORX_W S[13] ^= self.NORX_R S[14] ^= self.NORX_D S[15] ^= self.NORX_T self.permute(S) def inject_tag(self, S, tag): S[15] ^= tag def process_header(self, S, x): return self.absorb_data(S, x, self.HEADER_TAG) def process_trailer(self, S, x): return self.absorb_data(S, x, self.TRAILER_TAG) def absorb_data(self, S, x, tag): inlen = len(x) if inlen > 0: i, n = 0, self.BYTES_RATE while inlen >= n: self.absorb_block(S, x[n*i:n*(i+1)], tag) inlen -= n i += 1 self.absorb_lastblock(S, x[n*i:n*i+inlen], tag) def absorb_block(self, S, x, tag): b = self.BYTES_WORD self.inject_tag(S, tag) self.permute(S) for i in xrange(self.WORDS_RATE): S[i] ^= self.load(x[b*i:b*(i+1)]) def absorb_lastblock(self, S, x, tag): y = self.pad(x) self.absorb_block(S, y, tag) def encrypt_data(self, S, x): c = bytearray() inlen = len(x) if inlen > 0: i, n = 0, self.BYTES_RATE while inlen >= n: c += self.encrypt_block(S, x[n*i:n*(i+1)]) inlen -= n i += 1 c += self.encrypt_lastblock(S, x[n*i:n*i+inlen]) return c def encrypt_block(self, S, x): c = bytearray() b = self.BYTES_WORD self.inject_tag(S, self.PAYLOAD_TAG) self.permute(S) for i in xrange(self.WORDS_RATE): S[i] ^= self.load(x[b*i:b*(i+1)]) c += self.store(S[i]) return c[:self.BYTES_RATE] def encrypt_lastblock(self, S, x): y = self.pad(x) c = self.encrypt_block(S, y) return c[:len(x)] def decrypt_data(self, S, x): m = bytearray() inlen = len(x) if inlen > 0: i, n = 0, self.BYTES_RATE while inlen >= n: m += self.decrypt_block(S, x[n*i:n*(i+1)]) inlen -= n i += 1 m += self.decrypt_lastblock(S, x[n*i:n*i+inlen]) return m def decrypt_block(self, S, x): m = bytearray() b = self.BYTES_WORD self.inject_tag(S, self.PAYLOAD_TAG) self.permute(S) for i in xrange(self.WORDS_RATE): c = self.load(x[b*i:b*(i+1)]) m += self.store(S[i] ^ c) S[i] = c return m[:self.BYTES_RATE] def decrypt_lastblock(self, S, x): m = bytearray() y = bytearray() b = self.BYTES_WORD self.inject_tag(S, self.PAYLOAD_TAG) self.permute(S) for i in xrange(self.WORDS_RATE): y += self.store(S[i]) y[:len(x)] = bytearray(x) y[len(x)] ^= 0x01 y[self.BYTES_RATE-1] ^= 0x80 for i in xrange(self.WORDS_RATE): c = self.load(y[b*i:b*(i+1)]) m += self.store(S[i] ^ c) S[i] = c return m[:len(x)] def generate_tag(self, S): t = bytearray() self.inject_tag(S, self.FINAL_TAG) self.permute(S) self.permute(S) for i in xrange(self.WORDS_RATE): t += self.store(S[i]) return t[:self.BYTES_TAG] def verify_tag(self, t0, t1): acc = 0 for i in xrange(self.BYTES_TAG): acc |= t0[i] ^ t1[i] return (((acc - 1) >> 8) & 1) - 1 def aead_encrypt(self, h, m, t, n, k): assert len(k) == self.NORX_K / 8 assert len(n) == self.NORX_N / 8 c = bytearray() S = [0] * 16 self.init(S, n, k) self.process_header(S, h) c += self.encrypt_data(S, m) self.process_trailer(S, t) c += self.generate_tag(S) return str(c) def aead_decrypt(self, h, c, t, n, k): assert len(k) == self.NORX_K / 8 assert len(n) == self.NORX_N / 8 assert len(c) >= self.BYTES_TAG m = bytearray() c = bytearray(c) S = [0] * 16 d = len(c)-self.BYTES_TAG c, t0 = c[:d], c[d:] self.init(S, n, k) self.process_header(S, h) m += self.decrypt_data(S, c) self.process_trailer(S, t) t1 = self.generate_tag(S) if self.verify_tag(t0, t1) != 0: m = '' return str(m)
cc0-1.0
[ 624, 2043, 2018, 18, 4514, 402, 653, 726, 56, 14, 2043, 21397, 8410, 520, 2502, 26, 11308, 1638, 802, 7135, 86, 8143, 31629, 665, 838, 1638, 802, 32, 743, 86, 8143, 31629, 14, 2308, 6244, 6927, 13, 7806, 14, 2043, 520, 1682, 26, 17586, 16, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 2702, 492, 1706, 12, 7787, 421, 199, 533, 653, 726, 56, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 336, 29, 772, 12, 519, 29, 20, 12, 366, 29, 17, 12, 307, 29, 3912, 304, 267, 702, 336, 315, 359, 708, 12, 5049, 61, 267, 702, 519, 2356, 413, 267, 702, 366, 2356, 378, 267, 702, 1616, 627, 336, 2356, 307, 2356, 378, 267, 291, 14, 46, 726, 56, 63, 55, 275, 336, 267, 291, 14, 46, 726, 56, 63, 50, 275, 519, 267, 291, 14, 46, 726, 56, 63, 36, 275, 366, 267, 291, 14, 46, 726, 56, 63, 52, 275, 307, 267, 291, 14, 46, 726, 56, 63, 46, 275, 336, 627, 499, 267, 291, 14, 46, 726, 56, 63, 43, 275, 336, 627, 841, 267, 291, 14, 46, 726, 56, 63, 34, 275, 336, 627, 3193, 267, 291, 14, 46, 726, 56, 63, 35, 275, 336, 627, 1227, 267, 291, 14, 16553, 275, 291, 14, 46, 726, 56, 63, 34, 446, 291, 14, 46, 726, 56, 63, 35, 267, 291, 14, 7311, 63, 6967, 275, 413, 5213, 378, 267, 291, 14, 24647, 63, 6967, 275, 413, 5213, 413, 267, 291, 14, 1766, 6593, 540, 63, 6967, 275, 413, 5213, 499, 267, 291, 14, 29270, 63, 6967, 275, 413, 5213, 650, 267, 291, 14, 24776, 63, 6967, 275, 413, 5213, 841, 267, 291, 14, 25619, 63, 6967, 275, 413, 5213, 959, 267, 291, 14, 20352, 63, 5172, 275, 336, 1182, 1695, 267, 291, 14, 20352, 63, 6967, 275, 307, 1182, 1695, 267, 291, 14, 19984, 63, 16553, 275, 291, 14, 16553, 1182, 336, 267, 291, 14, 20352, 63, 16553, 275, 291, 14, 19984, 63, 16553, 627, 291, 14, 20352, 63, 5172, 267, 340, 336, 508, 4337, 26, 288, 291, 14, 50, 275, 334, 24, 12, 4119, 12, 3193, 12, 7105, 9, 288, 291, 14, 53, 275, 334, 16, 88, 13440, 38, 22, 33, 1299, 12, 378, 88, 2426, 33, 12127, 36, 19, 12, 378, 88, 969, 10905, 33, 18, 37, 12, 378, 88, 18325, 1780, 10875, 12, 378, 88, 8306, 38, 24416, 33, 12, 1993, 378, 88, 13846, 2192, 36, 2006, 12, 378, 88, 29304, 35, 22, 37, 2658, 12, 378, 6287, 2576, 33, 19, 12500, 21, 12, 378, 88, 24, 35, 3328, 36, 1299, 35, 12, 378, 88, 845, 37, 5699, 34, 1427, 9, 288, 291, 14, 45, 275, 378, 21870, 288, 291, 14, 5045, 275, 2650, 44, 7, 267, 916, 336, 508, 5049, 26, 288, 291, 14, 50, 275, 334, 24, 12, 5851, 12, 6335, 12, 13668, 9, 288, 291, 14, 53, 275, 334, 16, 88, 13440, 38, 22, 33, 1299, 2426, 33, 12127, 36, 19, 12, 378, 88, 969, 10905, 33, 18, 37, 18325, 1780, 10875, 12, 378, 7471, 12443, 1703, 9485, 1020, 38, 2192, 36, 16, 12, 378, 88, 19171, 37, 2078, 2905, 4220, 20, 37, 22, 35, 1407, 12, 378, 7471, 37, 1299, 2010, 5196, 11870, 13288, 33, 17, 12, 1993, 378, 88, 21451, 33, 7582, 8699, 2528, 36, 23, 2078, 22, 12, 378, 8163, 2824, 975, 36, 1257, 7695, 25, 1822, 21278, 12, 378, 8313, 2025, 3888, 12659, 24, 34, 22, 1216, 34, 25569, 12, 378, 88, 9946, 33, 1085, 36, 15128, 37, 23, 38, 15765, 12, 378, 88, 14761, 36, 17, 38, 11775, 36, 23861, 2426, 34, 9, 288, 291, 14, 45, 275, 378, 3581, 15798, 12596, 288, 291, 14, 5045, 275, 2650, 49, 7, 339, 347, 2248, 8, 277, 12, 671, 304, 267, 372, 7787, 8, 277, 14, 5045, 12, 671, 2788, 16, 61, 339, 347, 3877, 8, 277, 12, 671, 304, 267, 372, 1706, 8, 277, 14, 5045, 12, 671, 9, 339, 347, 820, 1387, 50, 8, 277, 12, 282, 12, 519, 304, 267, 372, 3666, 65, 4331, 519, 9, 1204, 334, 65, 5213, 334, 277, 14, 46, 726, 56, 63, 55, 446, 519, 1724, 1253, 291, 14, 45, 339, 347, 869, 8, 277, 12, 282, 12, 330, 304, 267, 372, 3666, 65, 7167, 330, 9, 7167, 3666, 65, 1253, 330, 9, 5213, 413, 430, 1253, 291, 14, 45, 339, 347, 598, 8, 277, 12, 282, 12, 330, 12, 286, 12, 366, 304, 267, 282, 275, 291, 14, 40, 8, 65, 12, 330, 9, 267, 366, 275, 291, 14, 1092, 1766, 8, 65, 7167, 366, 12, 291, 14, 50, 59, 16, 566, 267, 286, 275, 291, 14, 40, 8, 67, 12, 366, 9, 267, 330, 275, 291, 14, 1092, 1766, 8, 66, 7167, 286, 12, 291, 14, 50, 59, 17, 566, 267, 282, 275, 291, 14, 40, 8, 65, 12, 330, 9, 267, 366, 275, 291, 14, 1092, 1766, 8, 65, 7167, 366, 12, 291, 14, 50, 59, 18, 566, 267, 286, 275, 291, 14, 40, 8, 67, 12, 366, 9, 267, 330, 275, 291, 14, 1092, 1766, 8, 66, 7167, 286, 12, 291, 14, 50, 59, 19, 566, 267, 372, 282, 12, 330, 12, 286, 12, 366, 339, 347, 481, 8, 277, 12, 428, 304, 267, 327, 4996, 3650, 267, 428, 59, 16, 467, 428, 59, 20, 467, 428, 59, 24, 467, 428, 59, 713, 61, 275, 291, 14, 39, 8, 51, 59, 16, 467, 428, 59, 20, 467, 428, 59, 24, 467, 428, 59, 713, 566, 267, 428, 59, 17, 467, 428, 59, 21, 467, 428, 59, 25, 467, 428, 59, 969, 61, 275, 291, 14, 39, 8, 51, 59, 17, 467, 428, 59, 21, 467, 428, 59, 25, 467, 428, 59, 969, 566, 267, 428, 59, 18, 467, 428, 59, 22, 467, 428, 59, 709, 467, 428, 59, 1079, 61, 275, 291, 14, 39, 8, 51, 59, 18, 467, 428, 59, 22, 467, 428, 59, 709, 467, 428, 59, 1079, 566, 267, 428, 59, 19, 467, 428, 59, 23, 467, 428, 59, 845, 467, 428, 59, 1046, 61, 275, 291, 14, 39, 8, 51, 59, 19, 467, 428, 59, 23, 467 ]
[ 2043, 2018, 18, 4514, 402, 653, 726, 56, 14, 2043, 21397, 8410, 520, 2502, 26, 11308, 1638, 802, 7135, 86, 8143, 31629, 665, 838, 1638, 802, 32, 743, 86, 8143, 31629, 14, 2308, 6244, 6927, 13, 7806, 14, 2043, 520, 1682, 26, 17586, 16, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 2702, 492, 1706, 12, 7787, 421, 199, 533, 653, 726, 56, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 336, 29, 772, 12, 519, 29, 20, 12, 366, 29, 17, 12, 307, 29, 3912, 304, 267, 702, 336, 315, 359, 708, 12, 5049, 61, 267, 702, 519, 2356, 413, 267, 702, 366, 2356, 378, 267, 702, 1616, 627, 336, 2356, 307, 2356, 378, 267, 291, 14, 46, 726, 56, 63, 55, 275, 336, 267, 291, 14, 46, 726, 56, 63, 50, 275, 519, 267, 291, 14, 46, 726, 56, 63, 36, 275, 366, 267, 291, 14, 46, 726, 56, 63, 52, 275, 307, 267, 291, 14, 46, 726, 56, 63, 46, 275, 336, 627, 499, 267, 291, 14, 46, 726, 56, 63, 43, 275, 336, 627, 841, 267, 291, 14, 46, 726, 56, 63, 34, 275, 336, 627, 3193, 267, 291, 14, 46, 726, 56, 63, 35, 275, 336, 627, 1227, 267, 291, 14, 16553, 275, 291, 14, 46, 726, 56, 63, 34, 446, 291, 14, 46, 726, 56, 63, 35, 267, 291, 14, 7311, 63, 6967, 275, 413, 5213, 378, 267, 291, 14, 24647, 63, 6967, 275, 413, 5213, 413, 267, 291, 14, 1766, 6593, 540, 63, 6967, 275, 413, 5213, 499, 267, 291, 14, 29270, 63, 6967, 275, 413, 5213, 650, 267, 291, 14, 24776, 63, 6967, 275, 413, 5213, 841, 267, 291, 14, 25619, 63, 6967, 275, 413, 5213, 959, 267, 291, 14, 20352, 63, 5172, 275, 336, 1182, 1695, 267, 291, 14, 20352, 63, 6967, 275, 307, 1182, 1695, 267, 291, 14, 19984, 63, 16553, 275, 291, 14, 16553, 1182, 336, 267, 291, 14, 20352, 63, 16553, 275, 291, 14, 19984, 63, 16553, 627, 291, 14, 20352, 63, 5172, 267, 340, 336, 508, 4337, 26, 288, 291, 14, 50, 275, 334, 24, 12, 4119, 12, 3193, 12, 7105, 9, 288, 291, 14, 53, 275, 334, 16, 88, 13440, 38, 22, 33, 1299, 12, 378, 88, 2426, 33, 12127, 36, 19, 12, 378, 88, 969, 10905, 33, 18, 37, 12, 378, 88, 18325, 1780, 10875, 12, 378, 88, 8306, 38, 24416, 33, 12, 1993, 378, 88, 13846, 2192, 36, 2006, 12, 378, 88, 29304, 35, 22, 37, 2658, 12, 378, 6287, 2576, 33, 19, 12500, 21, 12, 378, 88, 24, 35, 3328, 36, 1299, 35, 12, 378, 88, 845, 37, 5699, 34, 1427, 9, 288, 291, 14, 45, 275, 378, 21870, 288, 291, 14, 5045, 275, 2650, 44, 7, 267, 916, 336, 508, 5049, 26, 288, 291, 14, 50, 275, 334, 24, 12, 5851, 12, 6335, 12, 13668, 9, 288, 291, 14, 53, 275, 334, 16, 88, 13440, 38, 22, 33, 1299, 2426, 33, 12127, 36, 19, 12, 378, 88, 969, 10905, 33, 18, 37, 18325, 1780, 10875, 12, 378, 7471, 12443, 1703, 9485, 1020, 38, 2192, 36, 16, 12, 378, 88, 19171, 37, 2078, 2905, 4220, 20, 37, 22, 35, 1407, 12, 378, 7471, 37, 1299, 2010, 5196, 11870, 13288, 33, 17, 12, 1993, 378, 88, 21451, 33, 7582, 8699, 2528, 36, 23, 2078, 22, 12, 378, 8163, 2824, 975, 36, 1257, 7695, 25, 1822, 21278, 12, 378, 8313, 2025, 3888, 12659, 24, 34, 22, 1216, 34, 25569, 12, 378, 88, 9946, 33, 1085, 36, 15128, 37, 23, 38, 15765, 12, 378, 88, 14761, 36, 17, 38, 11775, 36, 23861, 2426, 34, 9, 288, 291, 14, 45, 275, 378, 3581, 15798, 12596, 288, 291, 14, 5045, 275, 2650, 49, 7, 339, 347, 2248, 8, 277, 12, 671, 304, 267, 372, 7787, 8, 277, 14, 5045, 12, 671, 2788, 16, 61, 339, 347, 3877, 8, 277, 12, 671, 304, 267, 372, 1706, 8, 277, 14, 5045, 12, 671, 9, 339, 347, 820, 1387, 50, 8, 277, 12, 282, 12, 519, 304, 267, 372, 3666, 65, 4331, 519, 9, 1204, 334, 65, 5213, 334, 277, 14, 46, 726, 56, 63, 55, 446, 519, 1724, 1253, 291, 14, 45, 339, 347, 869, 8, 277, 12, 282, 12, 330, 304, 267, 372, 3666, 65, 7167, 330, 9, 7167, 3666, 65, 1253, 330, 9, 5213, 413, 430, 1253, 291, 14, 45, 339, 347, 598, 8, 277, 12, 282, 12, 330, 12, 286, 12, 366, 304, 267, 282, 275, 291, 14, 40, 8, 65, 12, 330, 9, 267, 366, 275, 291, 14, 1092, 1766, 8, 65, 7167, 366, 12, 291, 14, 50, 59, 16, 566, 267, 286, 275, 291, 14, 40, 8, 67, 12, 366, 9, 267, 330, 275, 291, 14, 1092, 1766, 8, 66, 7167, 286, 12, 291, 14, 50, 59, 17, 566, 267, 282, 275, 291, 14, 40, 8, 65, 12, 330, 9, 267, 366, 275, 291, 14, 1092, 1766, 8, 65, 7167, 366, 12, 291, 14, 50, 59, 18, 566, 267, 286, 275, 291, 14, 40, 8, 67, 12, 366, 9, 267, 330, 275, 291, 14, 1092, 1766, 8, 66, 7167, 286, 12, 291, 14, 50, 59, 19, 566, 267, 372, 282, 12, 330, 12, 286, 12, 366, 339, 347, 481, 8, 277, 12, 428, 304, 267, 327, 4996, 3650, 267, 428, 59, 16, 467, 428, 59, 20, 467, 428, 59, 24, 467, 428, 59, 713, 61, 275, 291, 14, 39, 8, 51, 59, 16, 467, 428, 59, 20, 467, 428, 59, 24, 467, 428, 59, 713, 566, 267, 428, 59, 17, 467, 428, 59, 21, 467, 428, 59, 25, 467, 428, 59, 969, 61, 275, 291, 14, 39, 8, 51, 59, 17, 467, 428, 59, 21, 467, 428, 59, 25, 467, 428, 59, 969, 566, 267, 428, 59, 18, 467, 428, 59, 22, 467, 428, 59, 709, 467, 428, 59, 1079, 61, 275, 291, 14, 39, 8, 51, 59, 18, 467, 428, 59, 22, 467, 428, 59, 709, 467, 428, 59, 1079, 566, 267, 428, 59, 19, 467, 428, 59, 23, 467, 428, 59, 845, 467, 428, 59, 1046, 61, 275, 291, 14, 39, 8, 51, 59, 19, 467, 428, 59, 23, 467, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
EconForge/Smolyak
doc/sphinxext/docscrape_sphinx.py
62
7703
import re, inspect, textwrap, pydoc import sphinx from docscrape import NumpyDocString, FunctionDoc, ClassDoc class SphinxDocString(NumpyDocString): def __init__(self, docstring, config={}): self.use_plots = config.get('use_plots', False) NumpyDocString.__init__(self, docstring, config=config) # string conversion routines def _str_header(self, name, symbol='`'): return ['.. rubric:: ' + name, ''] def _str_field_list(self, name): return [':' + name + ':'] def _str_indent(self, doc, indent=4): out = [] for line in doc: out += [' '*indent + line] return out def _str_signature(self): return [''] if self['Signature']: return ['``%s``' % self['Signature']] + [''] else: return [''] def _str_summary(self): return self['Summary'] + [''] def _str_extended_summary(self): return self['Extended Summary'] + [''] def _str_param_list(self, name): out = [] if self[name]: out += self._str_field_list(name) out += [''] for param,param_type,desc in self[name]: out += self._str_indent(['**%s** : %s' % (param.strip(), param_type)]) out += [''] out += self._str_indent(desc,8) out += [''] return out @property def _obj(self): if hasattr(self, '_cls'): return self._cls elif hasattr(self, '_f'): return self._f return None def _str_member_list(self, name): """ Generate a member listing, autosummary:: table where possible, and a table where not. """ out = [] if self[name]: out += ['.. rubric:: %s' % name, ''] prefix = getattr(self, '_name', '') if prefix: prefix = '~%s.' % prefix autosum = [] others = [] for param, param_type, desc in self[name]: param = param.strip() if not self._obj or hasattr(self._obj, param): autosum += [" %s%s" % (prefix, param)] else: others.append((param, param_type, desc)) if autosum: out += ['.. autosummary::', ' :toctree:', ''] out += autosum if others: maxlen_0 = max([len(x[0]) for x in others]) maxlen_1 = max([len(x[1]) for x in others]) hdr = "="*maxlen_0 + " " + "="*maxlen_1 + " " + "="*10 fmt = '%%%ds %%%ds ' % (maxlen_0, maxlen_1) n_indent = maxlen_0 + maxlen_1 + 4 out += [hdr] for param, param_type, desc in others: out += [fmt % (param.strip(), param_type)] out += self._str_indent(desc, n_indent) out += [hdr] out += [''] return out def _str_section(self, name): out = [] if self[name]: out += self._str_header(name) out += [''] content = textwrap.dedent("\n".join(self[name])).split("\n") out += content out += [''] return out def _str_see_also(self, func_role): out = [] if self['See Also']: see_also = super(SphinxDocString, self)._str_see_also(func_role) out = ['.. seealso::', ''] out += self._str_indent(see_also[2:]) return out def _str_warnings(self): out = [] if self['Warnings']: out = ['.. warning::', ''] out += self._str_indent(self['Warnings']) return out def _str_index(self): idx = self['index'] out = [] if len(idx) == 0: return out out += ['.. index:: %s' % idx.get('default','')] for section, references in idx.iteritems(): if section == 'default': continue elif section == 'refguide': out += [' single: %s' % (', '.join(references))] else: out += [' %s: %s' % (section, ','.join(references))] return out def _str_references(self): out = [] if self['References']: out += self._str_header('References') if isinstance(self['References'], str): self['References'] = [self['References']] out.extend(self['References']) out += [''] # Latex collects all references to a separate bibliography, # so we need to insert links to it if sphinx.__version__ >= "0.6": out += ['.. only:: latex',''] else: out += ['.. latexonly::',''] items = [] for line in self['References']: m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I) if m: items.append(m.group(1)) out += [' ' + ", ".join(["[%s]_" % item for item in items]), ''] return out def _str_examples(self): examples_str = "\n".join(self['Examples']) if (self.use_plots and 'import matplotlib' in examples_str and 'plot::' not in examples_str): out = [] out += self._str_header('Examples') out += ['.. plot::', ''] out += self._str_indent(self['Examples']) out += [''] return out else: return self._str_section('Examples') def __str__(self, indent=0, func_role="obj"): out = [] out += self._str_signature() out += self._str_index() + [''] out += self._str_summary() out += self._str_extended_summary() for param_list in ('Parameters', 'Returns', 'Raises'): out += self._str_param_list(param_list) out += self._str_warnings() out += self._str_see_also(func_role) out += self._str_section('Notes') out += self._str_references() out += self._str_examples() for param_list in ('Attributes', 'Methods'): out += self._str_member_list(param_list) out = self._str_indent(out,indent) return '\n'.join(out) class SphinxFunctionDoc(SphinxDocString, FunctionDoc): def __init__(self, obj, doc=None, config={}): self.use_plots = config.get('use_plots', False) FunctionDoc.__init__(self, obj, doc=doc, config=config) class SphinxClassDoc(SphinxDocString, ClassDoc): def __init__(self, obj, doc=None, func_doc=None, config={}): self.use_plots = config.get('use_plots', False) ClassDoc.__init__(self, obj, doc=doc, func_doc=None, config=config) class SphinxObjDoc(SphinxDocString): def __init__(self, obj, doc=None, config={}): self._f = obj SphinxDocString.__init__(self, doc, config=config) def get_doc_object(obj, what=None, doc=None, config={}): if what is None: if inspect.isclass(obj): what = 'class' elif inspect.ismodule(obj): what = 'module' elif callable(obj): what = 'function' else: what = 'object' if what == 'class': return SphinxClassDoc(obj, func_doc=SphinxFunctionDoc, doc=doc, config=config) elif what in ('function', 'method'): return SphinxFunctionDoc(obj, doc=doc, config=config) else: if doc is None: doc = pydoc.getdoc(obj) return SphinxObjDoc(obj, doc, config=config)
mit
[ 646, 295, 12, 6485, 12, 13390, 12, 29164, 199, 646, 15882, 199, 504, 1382, 12865, 321, 492, 20535, 3768, 1558, 12, 6801, 3768, 12, 8089, 3768, 199, 199, 533, 10229, 3768, 1558, 8, 25218, 3768, 1558, 304, 272, 347, 636, 826, 721, 277, 12, 9214, 12, 1101, 16420, 267, 291, 14, 1180, 63, 13701, 275, 1101, 14, 362, 360, 1180, 63, 13701, 297, 756, 9, 267, 20535, 3768, 1558, 855, 826, 721, 277, 12, 9214, 12, 1101, 29, 888, 9, 339, 327, 1059, 8603, 14975, 272, 347, 485, 495, 63, 1291, 8, 277, 12, 536, 12, 5272, 534, 64, 735, 267, 372, 788, 703, 519, 17147, 447, 283, 435, 536, 12, 28696, 339, 347, 485, 495, 63, 698, 63, 513, 8, 277, 12, 536, 304, 267, 372, 359, 5242, 435, 536, 435, 7596, 418, 339, 347, 485, 495, 63, 3724, 8, 277, 12, 1382, 12, 4363, 29, 20, 304, 267, 734, 275, 942, 267, 367, 1004, 315, 1382, 26, 288, 734, 847, 788, 6438, 3724, 435, 1004, 61, 267, 372, 734, 339, 347, 485, 495, 63, 5233, 8, 277, 304, 267, 372, 24506, 267, 340, 291, 459, 10014, 2565, 288, 372, 788, 1040, 5, 83, 1040, 7, 450, 291, 459, 10014, 6538, 435, 24506, 267, 587, 26, 288, 372, 24506, 339, 347, 485, 495, 63, 4705, 8, 277, 304, 267, 372, 291, 459, 10407, 418, 435, 24506, 339, 347, 485, 495, 63, 10525, 63, 4705, 8, 277, 304, 267, 372, 291, 459, 14107, 22486, 418, 435, 24506, 339, 347, 485, 495, 63, 635, 63, 513, 8, 277, 12, 536, 304, 267, 734, 275, 942, 267, 340, 291, 59, 354, 2189, 288, 734, 847, 291, 423, 495, 63, 698, 63, 513, 8, 354, 9, 288, 734, 847, 24506, 288, 367, 1215, 12, 635, 63, 466, 12, 3257, 315, 291, 59, 354, 2189, 355, 734, 847, 291, 423, 495, 63, 3724, 2941, 538, 5, 83, 538, 520, 450, 83, 7, 450, 334, 635, 14, 1913, 1062, 12933, 1215, 63, 466, 3948, 355, 734, 847, 24506, 355, 734, 847, 291, 423, 495, 63, 3724, 8, 3257, 12, 24, 9, 355, 734, 847, 24506, 267, 372, 734, 339, 768, 1829, 272, 347, 485, 1113, 8, 277, 304, 267, 340, 2688, 8, 277, 12, 2513, 1886, 735, 288, 372, 291, 423, 1886, 267, 916, 2688, 8, 277, 12, 2513, 70, 735, 288, 372, 291, 423, 70, 267, 372, 488, 339, 347, 485, 495, 63, 1114, 63, 513, 8, 277, 12, 536, 304, 267, 408, 267, 7958, 282, 3653, 13778, 12, 26651, 29309, 447, 1817, 2382, 3962, 12, 267, 436, 282, 1817, 2382, 440, 14, 398, 408, 267, 734, 275, 942, 267, 340, 291, 59, 354, 2189, 288, 734, 847, 788, 703, 519, 17147, 447, 450, 83, 7, 450, 536, 12, 28696, 288, 2403, 275, 2519, 8, 277, 12, 2513, 354, 297, 4074, 953, 340, 2403, 26, 355, 2403, 275, 17352, 5, 83, 3530, 450, 2403, 953, 26651, 453, 275, 942, 288, 11789, 275, 942, 288, 367, 1215, 12, 1215, 63, 466, 12, 4328, 315, 291, 59, 354, 2189, 355, 1215, 275, 1215, 14, 1913, 342, 355, 340, 440, 291, 423, 1113, 503, 2688, 8, 277, 423, 1113, 12, 1215, 304, 490, 26651, 453, 847, 2097, 257, 450, 83, 5, 83, 2, 450, 334, 1861, 12, 1215, 1874, 355, 587, 26, 490, 11789, 14, 740, 1332, 635, 12, 1215, 63, 466, 12, 4328, 430, 953, 340, 26651, 453, 26, 355, 734, 847, 788, 703, 26651, 29309, 447, 297, 283, 257, 520, 475, 16970, 6536, 28696, 355, 734, 847, 26651, 453, 953, 340, 11789, 26, 355, 21037, 63, 16, 275, 1390, 779, 552, 8, 88, 59, 16, 566, 367, 671, 315, 11789, 566, 355, 21037, 63, 17, 275, 1390, 779, 552, 8, 88, 59, 17, 566, 367, 671, 315, 11789, 566, 355, 15260, 275, 22250, 10, 29078, 63, 16, 435, 298, 221, 298, 435, 22250, 10, 29078, 63, 17, 435, 298, 221, 298, 435, 22250, 10, 709, 355, 7104, 275, 1543, 8530, 795, 221, 450, 8530, 795, 221, 283, 450, 334, 29078, 63, 16, 12, 21037, 63, 17, 9, 355, 302, 63, 3724, 275, 21037, 63, 16, 435, 21037, 63, 17, 435, 841, 355, 734, 847, 359, 11244, 61, 355, 367, 1215, 12, 1215, 63, 466, 12, 4328, 315, 11789, 26, 490, 734, 847, 359, 5045, 450, 334, 635, 14, 1913, 1062, 1215, 63, 466, 1874, 490, 734, 847, 291, 423, 495, 63, 3724, 8, 3257, 12, 302, 63, 3724, 9, 355, 734, 847, 359, 11244, 61, 288, 734, 847, 24506, 267, 372, 734, 339, 347, 485, 495, 63, 2792, 8, 277, 12, 536, 304, 267, 734, 275, 942, 267, 340, 291, 59, 354, 2189, 288, 734, 847, 291, 423, 495, 63, 1291, 8, 354, 9, 288, 734, 847, 24506, 288, 1564, 275, 13390, 14, 14674, 4582, 78, 1674, 904, 8, 277, 59, 354, 2459, 14, 1294, 4582, 78, 531, 288, 734, 847, 1564, 288, 734, 847, 24506, 267, 372, 734, 339, 347, 485, 495, 63, 3239, 63, 12344, 8, 277, 12, 2562, 63, 3756, 304, 267, 734, 275, 942, 267, 340, 291, 459, 9295, 6121, 2565, 288, 1937, 63, 12344, 275, 1613, 8, 51, 7807, 3768, 1558, 12, 291, 10445, 495, 63, 3239, 63, 12344, 8, 1532, 63, 3756, 9, 288, 734, 275, 788, 703, 19352, 447, 297, 28696, 288, 734, 847, 291, 423, 495, 63, 3724, 8, 3239, 63, 12344, 59, 18, 5728, 267, 372, 734, 339, 347, 485, 495, 63, 5451, 8, 277, 304, 267, 734, 275, 942, 267, 340, 291, 459, 15921, 2565, 288, 734, 275, 788, 703, 5721, 447, 297, 28696, 288, 734, 847, 291, 423, 495, 63, 3724, 8, 277, 459, 15921, 1105, 267, 372, 734, 339, 347, 485, 495, 63, 1080, 8, 277, 304, 267, 4280, 275, 291, 459, 1080, 418, 267, 734, 275, 942, 267, 340, 822, 8, 2996, 9, 508, 378, 26, 288, 372, 734, 398, 734, 847, 788, 703, 1478, 447, 450, 83, 7, 450, 4280, 14, 362, 360, 885, 1673, 5440, 267, 367, 3420, 12, 6941, 315, 4280, 14, 4611, 837, 288, 340, 3420, 508, 283, 885, 356, 355, 1980, 288, 916, 3420, 508, 283, 1121, 17348, 356, 355, 734, 847, 788, 257, 2849, 26, 450, 83, 7, 450, 334 ]
[ 295, 12, 6485, 12, 13390, 12, 29164, 199, 646, 15882, 199, 504, 1382, 12865, 321, 492, 20535, 3768, 1558, 12, 6801, 3768, 12, 8089, 3768, 199, 199, 533, 10229, 3768, 1558, 8, 25218, 3768, 1558, 304, 272, 347, 636, 826, 721, 277, 12, 9214, 12, 1101, 16420, 267, 291, 14, 1180, 63, 13701, 275, 1101, 14, 362, 360, 1180, 63, 13701, 297, 756, 9, 267, 20535, 3768, 1558, 855, 826, 721, 277, 12, 9214, 12, 1101, 29, 888, 9, 339, 327, 1059, 8603, 14975, 272, 347, 485, 495, 63, 1291, 8, 277, 12, 536, 12, 5272, 534, 64, 735, 267, 372, 788, 703, 519, 17147, 447, 283, 435, 536, 12, 28696, 339, 347, 485, 495, 63, 698, 63, 513, 8, 277, 12, 536, 304, 267, 372, 359, 5242, 435, 536, 435, 7596, 418, 339, 347, 485, 495, 63, 3724, 8, 277, 12, 1382, 12, 4363, 29, 20, 304, 267, 734, 275, 942, 267, 367, 1004, 315, 1382, 26, 288, 734, 847, 788, 6438, 3724, 435, 1004, 61, 267, 372, 734, 339, 347, 485, 495, 63, 5233, 8, 277, 304, 267, 372, 24506, 267, 340, 291, 459, 10014, 2565, 288, 372, 788, 1040, 5, 83, 1040, 7, 450, 291, 459, 10014, 6538, 435, 24506, 267, 587, 26, 288, 372, 24506, 339, 347, 485, 495, 63, 4705, 8, 277, 304, 267, 372, 291, 459, 10407, 418, 435, 24506, 339, 347, 485, 495, 63, 10525, 63, 4705, 8, 277, 304, 267, 372, 291, 459, 14107, 22486, 418, 435, 24506, 339, 347, 485, 495, 63, 635, 63, 513, 8, 277, 12, 536, 304, 267, 734, 275, 942, 267, 340, 291, 59, 354, 2189, 288, 734, 847, 291, 423, 495, 63, 698, 63, 513, 8, 354, 9, 288, 734, 847, 24506, 288, 367, 1215, 12, 635, 63, 466, 12, 3257, 315, 291, 59, 354, 2189, 355, 734, 847, 291, 423, 495, 63, 3724, 2941, 538, 5, 83, 538, 520, 450, 83, 7, 450, 334, 635, 14, 1913, 1062, 12933, 1215, 63, 466, 3948, 355, 734, 847, 24506, 355, 734, 847, 291, 423, 495, 63, 3724, 8, 3257, 12, 24, 9, 355, 734, 847, 24506, 267, 372, 734, 339, 768, 1829, 272, 347, 485, 1113, 8, 277, 304, 267, 340, 2688, 8, 277, 12, 2513, 1886, 735, 288, 372, 291, 423, 1886, 267, 916, 2688, 8, 277, 12, 2513, 70, 735, 288, 372, 291, 423, 70, 267, 372, 488, 339, 347, 485, 495, 63, 1114, 63, 513, 8, 277, 12, 536, 304, 267, 408, 267, 7958, 282, 3653, 13778, 12, 26651, 29309, 447, 1817, 2382, 3962, 12, 267, 436, 282, 1817, 2382, 440, 14, 398, 408, 267, 734, 275, 942, 267, 340, 291, 59, 354, 2189, 288, 734, 847, 788, 703, 519, 17147, 447, 450, 83, 7, 450, 536, 12, 28696, 288, 2403, 275, 2519, 8, 277, 12, 2513, 354, 297, 4074, 953, 340, 2403, 26, 355, 2403, 275, 17352, 5, 83, 3530, 450, 2403, 953, 26651, 453, 275, 942, 288, 11789, 275, 942, 288, 367, 1215, 12, 1215, 63, 466, 12, 4328, 315, 291, 59, 354, 2189, 355, 1215, 275, 1215, 14, 1913, 342, 355, 340, 440, 291, 423, 1113, 503, 2688, 8, 277, 423, 1113, 12, 1215, 304, 490, 26651, 453, 847, 2097, 257, 450, 83, 5, 83, 2, 450, 334, 1861, 12, 1215, 1874, 355, 587, 26, 490, 11789, 14, 740, 1332, 635, 12, 1215, 63, 466, 12, 4328, 430, 953, 340, 26651, 453, 26, 355, 734, 847, 788, 703, 26651, 29309, 447, 297, 283, 257, 520, 475, 16970, 6536, 28696, 355, 734, 847, 26651, 453, 953, 340, 11789, 26, 355, 21037, 63, 16, 275, 1390, 779, 552, 8, 88, 59, 16, 566, 367, 671, 315, 11789, 566, 355, 21037, 63, 17, 275, 1390, 779, 552, 8, 88, 59, 17, 566, 367, 671, 315, 11789, 566, 355, 15260, 275, 22250, 10, 29078, 63, 16, 435, 298, 221, 298, 435, 22250, 10, 29078, 63, 17, 435, 298, 221, 298, 435, 22250, 10, 709, 355, 7104, 275, 1543, 8530, 795, 221, 450, 8530, 795, 221, 283, 450, 334, 29078, 63, 16, 12, 21037, 63, 17, 9, 355, 302, 63, 3724, 275, 21037, 63, 16, 435, 21037, 63, 17, 435, 841, 355, 734, 847, 359, 11244, 61, 355, 367, 1215, 12, 1215, 63, 466, 12, 4328, 315, 11789, 26, 490, 734, 847, 359, 5045, 450, 334, 635, 14, 1913, 1062, 1215, 63, 466, 1874, 490, 734, 847, 291, 423, 495, 63, 3724, 8, 3257, 12, 302, 63, 3724, 9, 355, 734, 847, 359, 11244, 61, 288, 734, 847, 24506, 267, 372, 734, 339, 347, 485, 495, 63, 2792, 8, 277, 12, 536, 304, 267, 734, 275, 942, 267, 340, 291, 59, 354, 2189, 288, 734, 847, 291, 423, 495, 63, 1291, 8, 354, 9, 288, 734, 847, 24506, 288, 1564, 275, 13390, 14, 14674, 4582, 78, 1674, 904, 8, 277, 59, 354, 2459, 14, 1294, 4582, 78, 531, 288, 734, 847, 1564, 288, 734, 847, 24506, 267, 372, 734, 339, 347, 485, 495, 63, 3239, 63, 12344, 8, 277, 12, 2562, 63, 3756, 304, 267, 734, 275, 942, 267, 340, 291, 459, 9295, 6121, 2565, 288, 1937, 63, 12344, 275, 1613, 8, 51, 7807, 3768, 1558, 12, 291, 10445, 495, 63, 3239, 63, 12344, 8, 1532, 63, 3756, 9, 288, 734, 275, 788, 703, 19352, 447, 297, 28696, 288, 734, 847, 291, 423, 495, 63, 3724, 8, 3239, 63, 12344, 59, 18, 5728, 267, 372, 734, 339, 347, 485, 495, 63, 5451, 8, 277, 304, 267, 734, 275, 942, 267, 340, 291, 459, 15921, 2565, 288, 734, 275, 788, 703, 5721, 447, 297, 28696, 288, 734, 847, 291, 423, 495, 63, 3724, 8, 277, 459, 15921, 1105, 267, 372, 734, 339, 347, 485, 495, 63, 1080, 8, 277, 304, 267, 4280, 275, 291, 459, 1080, 418, 267, 734, 275, 942, 267, 340, 822, 8, 2996, 9, 508, 378, 26, 288, 372, 734, 398, 734, 847, 788, 703, 1478, 447, 450, 83, 7, 450, 4280, 14, 362, 360, 885, 1673, 5440, 267, 367, 3420, 12, 6941, 315, 4280, 14, 4611, 837, 288, 340, 3420, 508, 283, 885, 356, 355, 1980, 288, 916, 3420, 508, 283, 1121, 17348, 356, 355, 734, 847, 788, 257, 2849, 26, 450, 83, 7, 450, 334, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
lanen/youtube-dl
youtube_dl/extractor/beeg.py
103
2066
from __future__ import unicode_literals import re from .common import InfoExtractor class BeegIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?beeg\.com/(?P<id>\d+)' _TEST = { 'url': 'http://beeg.com/5416503', 'md5': '1bff67111adb785c51d1b42959ec10e5', 'info_dict': { 'id': '5416503', 'ext': 'mp4', 'title': 'Sultry Striptease', 'description': 'md5:6db3c6177972822aaba18652ff59c773', 'categories': list, # NSFW 'thumbnail': 're:https?://.*\.jpg$', 'age_limit': 18, } } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') webpage = self._download_webpage(url, video_id) quality_arr = self._search_regex( r'(?s)var\s+qualityArr\s*=\s*{\s*(.+?)\s*}', webpage, 'quality formats') formats = [{ 'url': fmt[1], 'format_id': fmt[0], 'height': int(fmt[0][:-1]), } for fmt in re.findall(r"'([^']+)'\s*:\s*'([^']+)'", quality_arr)] self._sort_formats(formats) title = self._html_search_regex( r'<title>([^<]+)\s*-\s*beeg\.?</title>', webpage, 'title') description = self._html_search_regex( r'<meta name="description" content="([^"]*)"', webpage, 'description', fatal=False) thumbnail = self._html_search_regex( r'\'previewer.url\'\s*:\s*"([^"]*)"', webpage, 'thumbnail', fatal=False) categories_str = self._html_search_regex( r'<meta name="keywords" content="([^"]+)"', webpage, 'categories', fatal=False) categories = ( None if categories_str is None else categories_str.split(',')) return { 'id': video_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'categories': categories, 'formats': formats, 'age_limit': 18, }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 699, 1024, 71, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 19446, 71, 4537, 957, 9448, 48, 28, 344, 3072, 68, 29600, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 19446, 71, 14, 957, 15, 1477, 975, 15773, 297, 267, 283, 1064, 21, 356, 283, 17, 66, 556, 1822, 6673, 13741, 19312, 67, 2869, 68, 17, 66, 14372, 1427, 825, 709, 69, 21, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1477, 975, 15773, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 51, 427, 651, 19828, 266, 482, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 22, 697, 19, 67, 2976, 1138, 2576, 29736, 65, 20338, 1085, 25415, 556, 1427, 67, 18507, 297, 288, 283, 8906, 356, 769, 12, 221, 327, 9380, 19445, 288, 283, 8311, 356, 283, 264, 26, 2859, 32569, 8476, 4268, 288, 283, 474, 63, 3097, 356, 6155, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 11030, 63, 5250, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 10120, 83, 9, 1391, 60, 83, 11, 9161, 22011, 60, 83, 23440, 83, 10, 12911, 83, 5830, 11198, 2862, 83, 10, 7293, 9248, 12, 283, 9161, 6752, 358, 398, 6752, 275, 8910, 288, 283, 633, 356, 7104, 59, 17, 467, 288, 283, 908, 63, 344, 356, 7104, 59, 16, 467, 288, 283, 3333, 356, 1109, 8, 5045, 59, 16, 61, 4439, 17, 2522, 267, 789, 367, 7104, 315, 295, 14, 6452, 8, 82, 4507, 7059, 418, 8771, 1154, 83, 10, 3427, 83, 10223, 7059, 21899, 3171, 401, 11030, 63, 5250, 1874, 398, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 1213, 30, 31204, 18096, 83, 1837, 60, 83, 10, 19446, 71, 4537, 31, 1108, 1213, 4206, 9248, 12, 283, 1213, 358, 398, 1369, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 2024, 536, 628, 1802, 2, 1564, 24296, 25952, 297, 288, 9248, 12, 283, 1802, 297, 14294, 29, 797, 9, 267, 10062, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 1154, 7, 7780, 281, 14, 633, 24908, 83, 10, 3427, 83, 12469, 15710, 25952, 297, 288, 9248, 12, 283, 8311, 297, 14294, 29, 797, 9, 398, 9695, 63, 495, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 2024, 536, 628, 7511, 2, 1564, 32391, 297, 9248, 12, 283, 8906, 297, 14294, 29, 797, 9, 267, 9695, 275, 334, 288, 488, 340, 9695, 63, 495, 365, 488, 288, 587, 9695, 63, 495, 14, 1294, 5102, 1333, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 8906, 356, 9695, 12, 288, 283, 6321, 356, 6752, 12, 288, 283, 474, 63, 3097, 356, 6155, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 699, 1024, 71, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 19446, 71, 4537, 957, 9448, 48, 28, 344, 3072, 68, 29600, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 19446, 71, 14, 957, 15, 1477, 975, 15773, 297, 267, 283, 1064, 21, 356, 283, 17, 66, 556, 1822, 6673, 13741, 19312, 67, 2869, 68, 17, 66, 14372, 1427, 825, 709, 69, 21, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1477, 975, 15773, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 51, 427, 651, 19828, 266, 482, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 22, 697, 19, 67, 2976, 1138, 2576, 29736, 65, 20338, 1085, 25415, 556, 1427, 67, 18507, 297, 288, 283, 8906, 356, 769, 12, 221, 327, 9380, 19445, 288, 283, 8311, 356, 283, 264, 26, 2859, 32569, 8476, 4268, 288, 283, 474, 63, 3097, 356, 6155, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 11030, 63, 5250, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 10120, 83, 9, 1391, 60, 83, 11, 9161, 22011, 60, 83, 23440, 83, 10, 12911, 83, 5830, 11198, 2862, 83, 10, 7293, 9248, 12, 283, 9161, 6752, 358, 398, 6752, 275, 8910, 288, 283, 633, 356, 7104, 59, 17, 467, 288, 283, 908, 63, 344, 356, 7104, 59, 16, 467, 288, 283, 3333, 356, 1109, 8, 5045, 59, 16, 61, 4439, 17, 2522, 267, 789, 367, 7104, 315, 295, 14, 6452, 8, 82, 4507, 7059, 418, 8771, 1154, 83, 10, 3427, 83, 10223, 7059, 21899, 3171, 401, 11030, 63, 5250, 1874, 398, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 1213, 30, 31204, 18096, 83, 1837, 60, 83, 10, 19446, 71, 4537, 31, 1108, 1213, 4206, 9248, 12, 283, 1213, 358, 398, 1369, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 2024, 536, 628, 1802, 2, 1564, 24296, 25952, 297, 288, 9248, 12, 283, 1802, 297, 14294, 29, 797, 9, 267, 10062, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 1154, 7, 7780, 281, 14, 633, 24908, 83, 10, 3427, 83, 12469, 15710, 25952, 297, 288, 9248, 12, 283, 8311, 297, 14294, 29, 797, 9, 398, 9695, 63, 495, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 2024, 536, 628, 7511, 2, 1564, 32391, 297, 9248, 12, 283, 8906, 297, 14294, 29, 797, 9, 267, 9695, 275, 334, 288, 488, 340, 9695, 63, 495, 365, 488, 288, 587, 9695, 63, 495, 14, 1294, 5102, 1333, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 8906, 356, 9695, 12, 288, 283, 6321, 356, 6752, 12, 288, 283, 474, 63, 3097, 356, 6155, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
timfreund/pycontrol-shed
pycontrolshed/model.py
1
13233
# Copyright (C) 2011 Tim Freund and contributors. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from functools import wraps from pycontrol import pycontrol import logging import pycontrolshed import socket # In [1]: route_domains = bigip.Networking.RouteDomain.get_list() # In [2]: route_domains # Out[2]: [2220L] log = logging.getLogger('pycontrolshed.model') def partitioned(f): @wraps(f) def wrapper(self, *args, **kwargs): partition = kwargs.get('partition', None) if partition: orig_partition = self.bigip.Management.Partition.get_active_partition() self.bigip.active_partition = partition rc = f(self, *args, **kwargs) self.bigip.active_partition = orig_partition return rc else: return f(self, *args, **kwargs) return wrapper class NodeAssistant(object): def __init__(self, bigip): self.bigip = bigip def disable(self, nodes, partition=None): self.enable_disable_nodes(nodes, 'STATE_DISABLED', partition=partition) def enable(self, nodes, partition=None): self.enable_disable_nodes(nodes, 'STATE_ENABLED', partition=partition) @partitioned def enable_disable_nodes(self, nodes, target_state, partition=None): if isinstance(nodes, basestring): nodes = [nodes] targets = [] states = [] for node in nodes: targets.append(self.bigip.host_to_node(node)) states.append(target_state) self.bigip.LocalLB.NodeAddress.set_session_enabled_state(node_addresses=targets, states=states) return self.status(nodes) @partitioned def status(self, nodes, partition=None): if isinstance(nodes, basestring): nodes = [nodes] targets = [self.bigip.host_to_node(node) for node in nodes] statuses = self.bigip.LocalLB.NodeAddress.get_session_enabled_state(node_addresses=targets) rc = [] for node, status in zip(targets, statuses): rc.append({'node': node, 'fqdn': self.bigip.node_to_host(node), 'status': status}) return rc class VirtualAssistant(object): def __init__(self, bigip): self.bigip = bigip @partitioned def servers(self, partition=None): return self.bigip.LocalLB.VirtualServer.get_list() @partitioned def all_server_statistics(self, partition=None): return self.bigip.LocalLB.VirtualServer.get_all_statistics() @partitioned def addresses(self, partition=None): return self.bigip.LocalLB.VirtualAddress.get_list() @partitioned def all_address_statistics(self, partition=None): return self.bigip.LocalLB.VirtualAddress.get_all_statistics() class PoolAssistant(object): def __init__(self, bigip): self.bigip = bigip def create_type(self, type_name): return self.bigip.LocalLB.PoolMember.typefactory.create(type_name) @partitioned def pools(self, partition=None): return self.bigip.LocalLB.Pool.get_list() @partitioned def members(self, pools, partition=None): if isinstance(pools, basestring): pools = [pools] session_status_list = self.bigip.LocalLB.PoolMember.get_session_enabled_state(pools) monitor_status_list = self.bigip.LocalLB.PoolMember.get_monitor_status(pools) rc = {} for pool, sessions, monitors in zip(pools, session_status_list, monitor_status_list): members = [] for session, monitor in zip(sessions, monitors): members.append({'address': session.member.address, 'port': session.member.port, 'monitor': monitor, 'session': session}) rc[pool] = {'members': members} return rc @partitioned def multi_member_statistics(self, pools, members, partition=None): seq_members = [] ippd_seq_seq = self.create_type('Common.IPPortDefinitionSequenceSequence') ippd_seq_seq.item = seq_members empty_pools = [] if isinstance(members, list): pass elif isinstance(members, dict): mlist = [] for k in pools: if len(members[k]['members']) == 0: empty_pools.append(k) else: mlist.append(members[k]['members']) for ep in empty_pools: pools.remove(ep) members = mlist for member_list in members: seq_members.append(self.pool_members_to_ippd_seq(member_list)) stats = self.bigip.LocalLB.PoolMember.get_statistics(pool_names=pools, members=ippd_seq_seq) rc = {} for p, s in zip(pools, stats): s = self.collapse_member_statistics(s) rc[p] = s return rc @partitioned def member_statistics(self, pool, member, partition=None): # TODO refactor this to be a special case of multi_member_statistics pools = [pool] if isinstance(member, basestring): ipp_member = self.bigip.host_port_to_ipportdef(*member.split(':')) member = ipp_member ippd_seq_seq = self.create_type('Common.IPPortDefinitionSequenceSequence') ippd_seq = self.create_type('Common.IPPortDefinitionSequence') ippd_seq_seq.item = ippd_seq ippd_seq.item = member # this is kind of garbage too... see TODO above stats = self.bigip.LocalLB.PoolMember.get_statistics(pool_names=pools, members=ippd_seq_seq)[0].statistics[0] return stats def disable_member(self, pool_name, members, partition=None): return self.enable_disable_members(pool_name, members, 'STATE_DISABLED', partition=partition) def enable_member(self, pool_name, members, partition=None): return self.enable_disable_members(pool_name, members, 'STATE_ENABLED', partition=partition) @partitioned def enable_disable_members(self, pool_name, members, target_state, partition=None): pools = [pool_name] if isinstance(members, basestring) or members.__class__.__name__.count('IPPortDefinition'): members = [members] session_states = self.create_type('LocalLB.PoolMember.MemberSessionStateSequence') session_states.item = [] for member in members: if isinstance(member, basestring): ipp_member = self.bigip.host_port_to_ipportdef(*member.split(':')) member = ipp_member state = self.create_type('LocalLB.PoolMember.MemberSessionState') state.member = member state.session_state = target_state session_states.item.append(state) self.bigip.LocalLB.PoolMember.set_session_enabled_state(pool_names=pools, session_states=[session_states]) return self.members(pools, partition=partition) def pool_members_to_ippd_seq(self, members): ippd_seq = self.create_type('Common.IPPortDefinitionSequence') ippd_members = [] ippd_seq.item = ippd_members for member in members: address = None port = None if isinstance(member, dict): address = member['address'] port = member['port'] elif isinstance(member, basestring): address, port = member.split(':') else: raise Exception("Unknown member type") ippd_members.append(self.bigip.host_port_to_ipportdef(address, port)) return ippd_seq def collapse_member_statistics(self, pool_stats): stats = {} # LocalLB.PoolMember.MemberStatisticEntry for mse in pool_stats.statistics: member_id = "%s:%d" % (mse.member.address, mse.member.port) stats[member_id] = {} for stat in mse.statistics: stats[member_id][stat.type] = {'high': stat.value.high, 'low': stat.value.low} return stats class PyCtrlShedBIGIP(pycontrol.BIGIP): def __init__(self, *args, **kwargs): pycontrol.BIGIP.__init__(self, *args, **kwargs) self.nodes = NodeAssistant(self) self.pools = PoolAssistant(self) self.virtual = VirtualAssistant(self) self._active_partition = None @property def active_partition(self): if self._active_partition: return self._active_partition self._active_partition = str(self.Management.Partition.get_active_partition()) return self._active_partition @active_partition.setter def active_partition(self, partition): self.Management.Partition.set_active_partition(partition) self._active_partition = partition self._route_domains = self.Networking.RouteDomain.get_list() def host_port_to_ipportdef(self, host, port): ipp = self.LocalLB.PoolMember.typefactory.create('Common.IPPortDefinition') ipp.address = self.host_to_node(host) ipp.port = int(port) return ipp def host_to_node(self, host): # If someone provides us with a route domain, we're going to trust # that they know what route domain to use. if host.count('%'): host, route_domain = host.split('%', 1) return "%s%%%s" % (socket.gethostbyname(host), route_domain) node = socket.gethostbyname(host) if (len(self.route_domains) == 1) and self.route_domains[0] != 0: node += "%%%d" % self.route_domains[0] return node def node_to_ip(self, node): if node.count('%'): return node.split('%')[0] return node def node_to_host(self, node): return socket.getfqdn(self.node_to_ip(node)) @property def route_domains(self): if hasattr(self, '_route_domains'): return self._route_domains self._route_domains = self.Networking.RouteDomain.get_list() return self._route_domains @property def partitions(self): partitions = [] for partition in self.Management.Partition.get_partition_list(): partitions.append({ 'name': partition['partition_name'], 'description': partition["description"] }) return partitions class Environment(object): def __init__(self, name, hosts=[], wsdls=None, username=None): self.name = name self.hosts = hosts self.bigips = {} self.username = username self.wsdls = wsdls if self.wsdls is None: self.wsdls = [ 'LocalLB.NodeAddress', 'LocalLB.Pool', 'LocalLB.PoolMember', 'LocalLB.Rule', 'LocalLB.VirtualAddress', 'LocalLB.VirtualServer', 'Management.Partition', 'Networking.RouteDomain', 'System.Failover', ] for host in self.hosts: self.connect_to_bigip(host) def __setattr__(self, name, value): if name in ['hosts', 'wsdls']: if isinstance(value, str) or isinstance(value, unicode): object.__setattr__(self, name, [host.strip() for host in value.split(',')]) else: object.__setattr__(self, name, value) else: object.__setattr__(self, name, value) def configure(self, config): for k, v in config.items(self.name): setattr(self, k, v) @property def all_bigip_connections(self): return [self.bigips[bigip] for bigip in self.bigips] @property def active_bigip_connection(self): for host in self.hosts: bigip = self.connect_to_bigip(host) if bigip.System.Failover.get_failover_state() == 'FAILOVER_STATE_ACTIVE': return bigip raise Exception('No active BIGIP devices were found in this environment (%s)' % self.name) def connect_to_bigip(self, host, wsdls=None, force_reconnect=False): if not(wsdls): wsdls = self.wsdls if not hasattr(self, 'password'): log.debug('No password has been set, attempting to retrive via keychain capabilities') password = pycontrolshed.get_password(self.name, self.username) if password: log.debug('Password retrived from the keychain') self.password = password else: log.error('No password is available') if host not in self.bigips or force_reconnect: self.bigips[host] = PyCtrlShedBIGIP(host, self.username, self.password, fromurl=True, wsdls=wsdls) return self.bigips[host]
gpl-2.0
[ 3, 1898, 334, 35, 9, 7760, 26244, 481, 264, 725, 436, 8417, 14, 199, 3, 199, 3, 961, 2032, 1443, 506, 1202, 436, 1854, 7182, 370, 314, 2895, 402, 314, 199, 3, 1664, 1696, 1684, 844, 1015, 499, 503, 1263, 2945, 1015, 14, 199, 199, 504, 9143, 492, 14018, 199, 504, 1134, 2785, 492, 1134, 2785, 199, 646, 2050, 199, 646, 1134, 13658, 19985, 199, 646, 2838, 199, 199, 3, 1010, 359, 17, 2189, 7475, 63, 9756, 275, 27281, 14, 27801, 14, 7161, 7705, 14, 362, 63, 513, 342, 199, 3, 1010, 359, 18, 2189, 7475, 63, 9756, 199, 3, 6219, 59, 18, 2189, 359, 1081, 1165, 44, 61, 199, 199, 793, 275, 2050, 14, 5572, 360, 647, 13658, 19985, 14, 1238, 358, 199, 199, 318, 27105, 8, 70, 304, 272, 768, 13582, 8, 70, 9, 272, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 6484, 275, 2074, 14, 362, 360, 5312, 297, 488, 9, 267, 340, 6484, 26, 288, 2306, 63, 5312, 275, 291, 14, 17833, 14, 14552, 14, 13068, 14, 362, 63, 2682, 63, 5312, 342, 288, 291, 14, 17833, 14, 2682, 63, 5312, 275, 6484, 288, 4819, 275, 289, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 288, 291, 14, 17833, 14, 2682, 63, 5312, 275, 2306, 63, 5312, 288, 372, 4819, 267, 587, 26, 288, 372, 289, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 272, 372, 4975, 421, 199, 533, 5013, 24486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 27281, 304, 267, 291, 14, 17833, 275, 27281, 339, 347, 3507, 8, 277, 12, 3380, 12, 6484, 29, 403, 304, 267, 291, 14, 4296, 63, 5993, 63, 2415, 8, 2415, 12, 283, 6689, 63, 16205, 297, 6484, 29, 5312, 9, 339, 347, 4756, 8, 277, 12, 3380, 12, 6484, 29, 403, 304, 267, 291, 14, 4296, 63, 5993, 63, 2415, 8, 2415, 12, 283, 6689, 63, 15704, 297, 6484, 29, 5312, 9, 339, 768, 5312, 379, 272, 347, 4756, 63, 5993, 63, 2415, 8, 277, 12, 3380, 12, 1347, 63, 929, 12, 6484, 29, 403, 304, 267, 340, 1228, 8, 2415, 12, 7116, 304, 288, 3380, 275, 359, 2415, 61, 398, 4545, 275, 942, 267, 6363, 275, 942, 267, 367, 1031, 315, 3380, 26, 288, 4545, 14, 740, 8, 277, 14, 17833, 14, 1102, 63, 475, 63, 932, 8, 932, 430, 288, 6363, 14, 740, 8, 1375, 63, 929, 9, 398, 291, 14, 17833, 14, 24273, 14, 1716, 1476, 14, 409, 63, 1730, 63, 3827, 63, 929, 8, 932, 63, 7423, 29, 4684, 12, 6684, 6363, 29, 4981, 9, 267, 372, 291, 14, 1205, 8, 2415, 9, 339, 768, 5312, 379, 272, 347, 2004, 8, 277, 12, 3380, 12, 6484, 29, 403, 304, 267, 340, 1228, 8, 2415, 12, 7116, 304, 288, 3380, 275, 359, 2415, 61, 398, 4545, 275, 359, 277, 14, 17833, 14, 1102, 63, 475, 63, 932, 8, 932, 9, 367, 1031, 315, 3380, 61, 267, 24498, 275, 291, 14, 17833, 14, 24273, 14, 1716, 1476, 14, 362, 63, 1730, 63, 3827, 63, 929, 8, 932, 63, 7423, 29, 4684, 9, 398, 4819, 275, 942, 267, 367, 1031, 12, 2004, 315, 3482, 8, 4684, 12, 24498, 304, 288, 4819, 14, 740, 3252, 932, 356, 1031, 12, 2432, 283, 18364, 356, 291, 14, 17833, 14, 932, 63, 475, 63, 1102, 8, 932, 395, 2432, 283, 1205, 356, 2004, 1552, 267, 372, 4819, 421, 199, 533, 13311, 24486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 27281, 304, 267, 291, 14, 17833, 275, 27281, 339, 768, 5312, 379, 272, 347, 8037, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 3120, 14, 362, 63, 513, 342, 339, 768, 5312, 379, 272, 347, 1006, 63, 1000, 63, 13724, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 3120, 14, 362, 63, 452, 63, 13724, 342, 339, 768, 5312, 379, 272, 347, 7149, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 1476, 14, 362, 63, 513, 342, 339, 768, 5312, 379, 272, 347, 1006, 63, 1562, 63, 13724, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 1476, 14, 362, 63, 452, 63, 13724, 342, 421, 199, 533, 15553, 24486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 27281, 304, 267, 291, 14, 17833, 275, 27281, 339, 347, 1218, 63, 466, 8, 277, 12, 730, 63, 354, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 5453, 7021, 14, 466, 3702, 14, 981, 8, 466, 63, 354, 9, 339, 768, 5312, 379, 272, 347, 20092, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 5453, 14, 362, 63, 513, 342, 339, 768, 5312, 379, 272, 347, 7556, 8, 277, 12, 20092, 12, 6484, 29, 403, 304, 267, 340, 1228, 8, 12406, 12, 7116, 304, 288, 20092, 275, 359, 12406, 61, 398, 2351, 63, 1205, 63, 513, 275, 291, 14, 17833, 14, 24273, 14, 5453, 7021, 14, 362, 63, 1730, 63, 3827, 63, 929, 8, 12406, 9, 267, 8372, 63, 1205, 63, 513, 275, 291, 14, 17833, 14, 24273, 14, 5453, 7021, 14, 362, 63, 7157, 63, 1205, 8, 12406, 9, 398, 4819, 275, 1052, 267, 367, 4203, 12, 12184, 12, 26862, 315, 3482, 8, 12406, 12, 2351, 63, 1205, 63, 513, 12, 8372, 63, 1205, 63, 513, 304, 288, 7556, 275, 942, 288, 367, 2351, 12, 8372, 315, 3482, 8, 11676, 12, 26862, 304, 355, 7556, 14, 740, 3252, 1562, 356, 2351, 14, 1114, 14, 1562, 12, 1816, 283, 719, 356, 2351, 14, 1114, 14, 719, 12, 1816, 283, 7157, 356, 8372, 12, 1816, 283, 1730, 356, 2351, 1552, 953, 4819, 59, 2293, 61, 275, 791, 6334, 356, 7556, 93, 267, 372, 4819, 339, 768, 5312, 379, 272, 347, 3510, 63, 1114, 63, 13724, 8, 277, 12, 20092, 12, 7556, 12, 6484, 29, 403, 304, 267, 5412, 63, 6334, 275, 942, 267, 284, 802, 68, 63, 3610, 63, 3610, 275, 291, 14, 981, 63, 466, 360, 7844, 14, 1772, 4313, 10701, 5826, 5826 ]
[ 1898, 334, 35, 9, 7760, 26244, 481, 264, 725, 436, 8417, 14, 199, 3, 199, 3, 961, 2032, 1443, 506, 1202, 436, 1854, 7182, 370, 314, 2895, 402, 314, 199, 3, 1664, 1696, 1684, 844, 1015, 499, 503, 1263, 2945, 1015, 14, 199, 199, 504, 9143, 492, 14018, 199, 504, 1134, 2785, 492, 1134, 2785, 199, 646, 2050, 199, 646, 1134, 13658, 19985, 199, 646, 2838, 199, 199, 3, 1010, 359, 17, 2189, 7475, 63, 9756, 275, 27281, 14, 27801, 14, 7161, 7705, 14, 362, 63, 513, 342, 199, 3, 1010, 359, 18, 2189, 7475, 63, 9756, 199, 3, 6219, 59, 18, 2189, 359, 1081, 1165, 44, 61, 199, 199, 793, 275, 2050, 14, 5572, 360, 647, 13658, 19985, 14, 1238, 358, 199, 199, 318, 27105, 8, 70, 304, 272, 768, 13582, 8, 70, 9, 272, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 6484, 275, 2074, 14, 362, 360, 5312, 297, 488, 9, 267, 340, 6484, 26, 288, 2306, 63, 5312, 275, 291, 14, 17833, 14, 14552, 14, 13068, 14, 362, 63, 2682, 63, 5312, 342, 288, 291, 14, 17833, 14, 2682, 63, 5312, 275, 6484, 288, 4819, 275, 289, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 288, 291, 14, 17833, 14, 2682, 63, 5312, 275, 2306, 63, 5312, 288, 372, 4819, 267, 587, 26, 288, 372, 289, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 272, 372, 4975, 421, 199, 533, 5013, 24486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 27281, 304, 267, 291, 14, 17833, 275, 27281, 339, 347, 3507, 8, 277, 12, 3380, 12, 6484, 29, 403, 304, 267, 291, 14, 4296, 63, 5993, 63, 2415, 8, 2415, 12, 283, 6689, 63, 16205, 297, 6484, 29, 5312, 9, 339, 347, 4756, 8, 277, 12, 3380, 12, 6484, 29, 403, 304, 267, 291, 14, 4296, 63, 5993, 63, 2415, 8, 2415, 12, 283, 6689, 63, 15704, 297, 6484, 29, 5312, 9, 339, 768, 5312, 379, 272, 347, 4756, 63, 5993, 63, 2415, 8, 277, 12, 3380, 12, 1347, 63, 929, 12, 6484, 29, 403, 304, 267, 340, 1228, 8, 2415, 12, 7116, 304, 288, 3380, 275, 359, 2415, 61, 398, 4545, 275, 942, 267, 6363, 275, 942, 267, 367, 1031, 315, 3380, 26, 288, 4545, 14, 740, 8, 277, 14, 17833, 14, 1102, 63, 475, 63, 932, 8, 932, 430, 288, 6363, 14, 740, 8, 1375, 63, 929, 9, 398, 291, 14, 17833, 14, 24273, 14, 1716, 1476, 14, 409, 63, 1730, 63, 3827, 63, 929, 8, 932, 63, 7423, 29, 4684, 12, 6684, 6363, 29, 4981, 9, 267, 372, 291, 14, 1205, 8, 2415, 9, 339, 768, 5312, 379, 272, 347, 2004, 8, 277, 12, 3380, 12, 6484, 29, 403, 304, 267, 340, 1228, 8, 2415, 12, 7116, 304, 288, 3380, 275, 359, 2415, 61, 398, 4545, 275, 359, 277, 14, 17833, 14, 1102, 63, 475, 63, 932, 8, 932, 9, 367, 1031, 315, 3380, 61, 267, 24498, 275, 291, 14, 17833, 14, 24273, 14, 1716, 1476, 14, 362, 63, 1730, 63, 3827, 63, 929, 8, 932, 63, 7423, 29, 4684, 9, 398, 4819, 275, 942, 267, 367, 1031, 12, 2004, 315, 3482, 8, 4684, 12, 24498, 304, 288, 4819, 14, 740, 3252, 932, 356, 1031, 12, 2432, 283, 18364, 356, 291, 14, 17833, 14, 932, 63, 475, 63, 1102, 8, 932, 395, 2432, 283, 1205, 356, 2004, 1552, 267, 372, 4819, 421, 199, 533, 13311, 24486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 27281, 304, 267, 291, 14, 17833, 275, 27281, 339, 768, 5312, 379, 272, 347, 8037, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 3120, 14, 362, 63, 513, 342, 339, 768, 5312, 379, 272, 347, 1006, 63, 1000, 63, 13724, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 3120, 14, 362, 63, 452, 63, 13724, 342, 339, 768, 5312, 379, 272, 347, 7149, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 1476, 14, 362, 63, 513, 342, 339, 768, 5312, 379, 272, 347, 1006, 63, 1562, 63, 13724, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 8735, 1476, 14, 362, 63, 452, 63, 13724, 342, 421, 199, 533, 15553, 24486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 27281, 304, 267, 291, 14, 17833, 275, 27281, 339, 347, 1218, 63, 466, 8, 277, 12, 730, 63, 354, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 5453, 7021, 14, 466, 3702, 14, 981, 8, 466, 63, 354, 9, 339, 768, 5312, 379, 272, 347, 20092, 8, 277, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 17833, 14, 24273, 14, 5453, 14, 362, 63, 513, 342, 339, 768, 5312, 379, 272, 347, 7556, 8, 277, 12, 20092, 12, 6484, 29, 403, 304, 267, 340, 1228, 8, 12406, 12, 7116, 304, 288, 20092, 275, 359, 12406, 61, 398, 2351, 63, 1205, 63, 513, 275, 291, 14, 17833, 14, 24273, 14, 5453, 7021, 14, 362, 63, 1730, 63, 3827, 63, 929, 8, 12406, 9, 267, 8372, 63, 1205, 63, 513, 275, 291, 14, 17833, 14, 24273, 14, 5453, 7021, 14, 362, 63, 7157, 63, 1205, 8, 12406, 9, 398, 4819, 275, 1052, 267, 367, 4203, 12, 12184, 12, 26862, 315, 3482, 8, 12406, 12, 2351, 63, 1205, 63, 513, 12, 8372, 63, 1205, 63, 513, 304, 288, 7556, 275, 942, 288, 367, 2351, 12, 8372, 315, 3482, 8, 11676, 12, 26862, 304, 355, 7556, 14, 740, 3252, 1562, 356, 2351, 14, 1114, 14, 1562, 12, 1816, 283, 719, 356, 2351, 14, 1114, 14, 719, 12, 1816, 283, 7157, 356, 8372, 12, 1816, 283, 1730, 356, 2351, 1552, 953, 4819, 59, 2293, 61, 275, 791, 6334, 356, 7556, 93, 267, 372, 4819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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
CarbonWolf/aff4
scons-local-1.2.0/SCons/Tool/cvf.py
12
2393
"""engine.SCons.Tool.cvf Tool-specific initialization for the Compaq Visual Fortran compiler. """ # # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation # # 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. # __revision__ = "src/engine/SCons/Tool/cvf.py 3842 2008/12/20 22:59:52 scons" import fortran compilers = ['f90'] def generate(env): """Add Builders and construction variables for compaq visual fortran to an Environment.""" fortran.generate(env) env['FORTRAN'] = 'f90' env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.windows} /object:${TARGET.windows}' env['FORTRANPPCOM'] = '$FORTRAN $FORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.windows} /object:${TARGET.windows}' env['SHFORTRANCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.windows} /object:${TARGET.windows}' env['SHFORTRANPPCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.windows} /object:${TARGET.windows}' env['OBJSUFFIX'] = '.obj' env['FORTRANMODDIR'] = '${TARGET.dir}' env['FORTRANMODDIRPREFIX'] = '/module:' env['FORTRANMODDIRSUFFIX'] = '' def exists(env): return env.Detect(compilers)
gpl-3.0
[ 624, 3908, 14, 18521, 14, 5157, 14, 5107, 70, 199, 199, 5157, 13, 6100, 11097, 367, 314, 3599, 30030, 14702, 19998, 6365, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 5107, 70, 14, 647, 650, 18931, 9079, 15, 713, 15, 1165, 6928, 26, 1427, 26, 2528, 31551, 2, 199, 199, 646, 289, 14522, 199, 199, 32593, 275, 788, 70, 2710, 418, 199, 199, 318, 3550, 8, 1813, 304, 272, 408, 1123, 19286, 83, 436, 14538, 2860, 367, 1013, 30030, 13104, 289, 14522, 370, 376, 9711, 1041, 339, 289, 14522, 14, 4208, 8, 1813, 9, 339, 2589, 459, 2707, 17433, 418, 263, 275, 283, 70, 2710, 7, 272, 2589, 459, 2707, 17433, 11265, 418, 258, 275, 4505, 2707, 17433, 2672, 2707, 17433, 4831, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 2707, 17433, 7701, 11265, 418, 257, 275, 4505, 2707, 17433, 2672, 2707, 17433, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 3234, 2707, 17433, 11265, 418, 257, 275, 4505, 3234, 2707, 17433, 2672, 3234, 2707, 17433, 4831, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 3234, 2707, 17433, 7701, 11265, 418, 275, 4505, 3234, 2707, 17433, 2672, 3234, 2707, 17433, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 15862, 12273, 418, 420, 275, 1987, 1113, 7, 272, 2589, 459, 2707, 17433, 8816, 3022, 418, 275, 20044, 9268, 14, 694, 6834, 272, 2589, 459, 2707, 17433, 8816, 3022, 6351, 418, 275, 1994, 578, 4881, 272, 2589, 459, 2707, 17433, 8816, 3022, 12273, 418, 275, 2125, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 2589, 14, 20064, 8, 32593, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3908, 14, 18521, 14, 5157, 14, 5107, 70, 199, 199, 5157, 13, 6100, 11097, 367, 314, 3599, 30030, 14702, 19998, 6365, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 5107, 70, 14, 647, 650, 18931, 9079, 15, 713, 15, 1165, 6928, 26, 1427, 26, 2528, 31551, 2, 199, 199, 646, 289, 14522, 199, 199, 32593, 275, 788, 70, 2710, 418, 199, 199, 318, 3550, 8, 1813, 304, 272, 408, 1123, 19286, 83, 436, 14538, 2860, 367, 1013, 30030, 13104, 289, 14522, 370, 376, 9711, 1041, 339, 289, 14522, 14, 4208, 8, 1813, 9, 339, 2589, 459, 2707, 17433, 418, 263, 275, 283, 70, 2710, 7, 272, 2589, 459, 2707, 17433, 11265, 418, 258, 275, 4505, 2707, 17433, 2672, 2707, 17433, 4831, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 2707, 17433, 7701, 11265, 418, 257, 275, 4505, 2707, 17433, 2672, 2707, 17433, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 3234, 2707, 17433, 11265, 418, 257, 275, 4505, 3234, 2707, 17433, 2672, 3234, 2707, 17433, 4831, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 3234, 2707, 17433, 7701, 11265, 418, 275, 4505, 3234, 2707, 17433, 2672, 3234, 2707, 17433, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 2707, 17433, 8816, 3719, 2672, 63, 2707, 17433, 568, 14804, 1182, 2014, 63, 2118, 10839, 25744, 14, 8258, 93, 1182, 785, 26, 10545, 9268, 14, 8258, 6834, 272, 2589, 459, 15862, 12273, 418, 420, 275, 1987, 1113, 7, 272, 2589, 459, 2707, 17433, 8816, 3022, 418, 275, 20044, 9268, 14, 694, 6834, 272, 2589, 459, 2707, 17433, 8816, 3022, 6351, 418, 275, 1994, 578, 4881, 272, 2589, 459, 2707, 17433, 8816, 3022, 12273, 418, 275, 2125, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 2589, 14, 20064, 8, 32593, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tntnatbry/tensorflow
tensorflow/user_ops/ackermann_test.py
148
1394
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # 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. # ============================================================================== """Tests for custom user ops.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os.path import tensorflow as tf class AckermannTest(tf.test.TestCase): def testBasic(self): library_filename = os.path.join(tf.resource_loader.get_data_files_path(), 'ackermann_op.so') ackermann = tf.load_op_library(library_filename) self.assertEqual(len(ackermann.OP_LIST.op), 1) self.assertEqual(ackermann.OP_LIST.op[0].name, 'Ackermann') with self.test_session(): self.assertEqual(ackermann.ackermann().eval(), b'A(m, 0) == A(m-1, 1)') if __name__ == '__main__': tf.test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 3537, 922, 4156, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 14, 515, 199, 199, 646, 3228, 465, 2833, 421, 199, 533, 437, 22043, 20059, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 511, 6845, 8, 277, 304, 272, 3555, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 3249, 14, 1927, 63, 3422, 14, 362, 63, 576, 63, 1725, 63, 515, 1062, 2511, 283, 564, 281, 20059, 63, 411, 14, 1152, 358, 272, 19807, 281, 20059, 275, 2833, 14, 912, 63, 411, 63, 4342, 8, 4342, 63, 1501, 9, 339, 291, 14, 629, 8, 552, 8, 564, 281, 20059, 14, 1938, 63, 4924, 14, 411, 395, 413, 9, 272, 291, 14, 629, 8, 564, 281, 20059, 14, 1938, 63, 4924, 14, 411, 59, 16, 1055, 354, 12, 283, 9940, 281, 20059, 358, 339, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 629, 8, 564, 281, 20059, 14, 564, 281, 20059, 1252, 2579, 1062, 330, 7, 33, 8, 77, 12, 378, 9, 508, 437, 8, 77, 13, 17, 12, 413, 5942, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 3537, 922, 4156, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 14, 515, 199, 199, 646, 3228, 465, 2833, 421, 199, 533, 437, 22043, 20059, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 511, 6845, 8, 277, 304, 272, 3555, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 3249, 14, 1927, 63, 3422, 14, 362, 63, 576, 63, 1725, 63, 515, 1062, 2511, 283, 564, 281, 20059, 63, 411, 14, 1152, 358, 272, 19807, 281, 20059, 275, 2833, 14, 912, 63, 411, 63, 4342, 8, 4342, 63, 1501, 9, 339, 291, 14, 629, 8, 552, 8, 564, 281, 20059, 14, 1938, 63, 4924, 14, 411, 395, 413, 9, 272, 291, 14, 629, 8, 564, 281, 20059, 14, 1938, 63, 4924, 14, 411, 59, 16, 1055, 354, 12, 283, 9940, 281, 20059, 358, 339, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 629, 8, 564, 281, 20059, 14, 564, 281, 20059, 1252, 2579, 1062, 330, 7, 33, 8, 77, 12, 378, 9, 508, 437, 8, 77, 13, 17, 12, 413, 5942, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
pombredanne/algos-urv
django/utils/version.py
13
1403
import django import os.path import re def get_svn_revision(path=None): """ Returns the SVN revision in the form SVN-XXXX, where XXXX is the revision number. Returns SVN-unknown if anything goes wrong, such as an unexpected format of internal SVN files. If path is provided, it should be a directory whose SVN info you want to inspect. If it's not provided, this will use the root django/ package directory. """ rev = None if path is None: path = django.__path__[0] entries_path = '%s/.svn/entries' % path try: entries = open(entries_path, 'r').read() except IOError: pass else: # Versions >= 7 of the entries file are flat text. The first line is # the version number. The next set of digits after 'dir' is the revision. if re.match('(\d+)', entries): rev_match = re.search('\d+\s+dir\s+(\d+)', entries) if rev_match: rev = rev_match.groups()[0] # Older XML versions of the file specify revision as an attribute of # the first entries node. else: from xml.dom import minidom dom = minidom.parse(entries_path) rev = dom.getElementsByTagName('entry')[0].getAttribute('revision') if rev: return u'SVN-%s' % rev return u'SVN-unknown'
bsd-3-clause
[ 646, 1639, 202, 199, 646, 747, 14, 515, 202, 199, 646, 295, 2999, 199, 318, 664, 63, 6836, 63, 5792, 8, 515, 29, 403, 304, 1128, 408, 1128, 1803, 314, 24639, 6974, 315, 314, 1824, 24639, 13, 6873, 12, 1128, 2382, 5787, 56, 365, 314, 6974, 1329, 14, 2958, 1803, 24639, 13, 5187, 340, 7003, 13538, 6835, 12, 4066, 465, 376, 10537, 1128, 1475, 402, 5007, 24639, 1584, 14, 2958, 982, 931, 365, 2741, 12, 652, 1077, 506, 282, 2082, 7447, 24639, 2256, 1265, 2934, 370, 1128, 6485, 14, 982, 652, 1159, 440, 2741, 12, 642, 911, 675, 314, 1738, 1639, 15, 2559, 1128, 2082, 14, 1128, 408, 1128, 6822, 275, 488, 1128, 340, 931, 365, 488, 26, 1039, 931, 275, 1639, 855, 515, 12298, 16, 61, 1128, 4811, 63, 515, 275, 1543, 83, 8083, 6836, 15, 3189, 7, 450, 931, 2958, 862, 26, 1039, 4811, 275, 1551, 8, 3189, 63, 515, 12, 283, 82, 1959, 739, 342, 1128, 871, 5925, 26, 1039, 986, 1128, 587, 26, 1039, 327, 5444, 1356, 2356, 1520, 402, 314, 4811, 570, 787, 6829, 1318, 14, 221, 710, 1642, 1004, 365, 1039, 327, 314, 1015, 1329, 14, 710, 2163, 663, 402, 7576, 2410, 283, 694, 7, 365, 314, 6974, 14, 1039, 340, 295, 14, 1431, 360, 2961, 68, 14705, 4811, 304, 1675, 6822, 63, 1431, 275, 295, 14, 1733, 2258, 68, 7896, 83, 11, 694, 60, 83, 20900, 68, 14705, 4811, 9, 1675, 340, 6822, 63, 1431, 26, 2628, 6822, 275, 6822, 63, 1431, 14, 2634, 3430, 16, 61, 1039, 327, 593, 76, 424, 4692, 5459, 402, 314, 570, 4165, 6974, 465, 376, 2225, 402, 1039, 327, 314, 1642, 4811, 1031, 14, 1039, 587, 26, 1675, 687, 2748, 14, 4556, 492, 19165, 1675, 8266, 275, 19165, 14, 1122, 8, 3189, 63, 515, 9, 1675, 6822, 275, 8266, 14, 15045, 360, 2373, 5832, 16, 1055, 12956, 360, 5792, 358, 2958, 340, 6822, 26, 1039, 372, 399, 7, 31222, 3295, 83, 7, 450, 6822, 1128, 372, 399, 7, 31222, 13, 5187, 7, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 202, 199, 646, 747, 14, 515, 202, 199, 646, 295, 2999, 199, 318, 664, 63, 6836, 63, 5792, 8, 515, 29, 403, 304, 1128, 408, 1128, 1803, 314, 24639, 6974, 315, 314, 1824, 24639, 13, 6873, 12, 1128, 2382, 5787, 56, 365, 314, 6974, 1329, 14, 2958, 1803, 24639, 13, 5187, 340, 7003, 13538, 6835, 12, 4066, 465, 376, 10537, 1128, 1475, 402, 5007, 24639, 1584, 14, 2958, 982, 931, 365, 2741, 12, 652, 1077, 506, 282, 2082, 7447, 24639, 2256, 1265, 2934, 370, 1128, 6485, 14, 982, 652, 1159, 440, 2741, 12, 642, 911, 675, 314, 1738, 1639, 15, 2559, 1128, 2082, 14, 1128, 408, 1128, 6822, 275, 488, 1128, 340, 931, 365, 488, 26, 1039, 931, 275, 1639, 855, 515, 12298, 16, 61, 1128, 4811, 63, 515, 275, 1543, 83, 8083, 6836, 15, 3189, 7, 450, 931, 2958, 862, 26, 1039, 4811, 275, 1551, 8, 3189, 63, 515, 12, 283, 82, 1959, 739, 342, 1128, 871, 5925, 26, 1039, 986, 1128, 587, 26, 1039, 327, 5444, 1356, 2356, 1520, 402, 314, 4811, 570, 787, 6829, 1318, 14, 221, 710, 1642, 1004, 365, 1039, 327, 314, 1015, 1329, 14, 710, 2163, 663, 402, 7576, 2410, 283, 694, 7, 365, 314, 6974, 14, 1039, 340, 295, 14, 1431, 360, 2961, 68, 14705, 4811, 304, 1675, 6822, 63, 1431, 275, 295, 14, 1733, 2258, 68, 7896, 83, 11, 694, 60, 83, 20900, 68, 14705, 4811, 9, 1675, 340, 6822, 63, 1431, 26, 2628, 6822, 275, 6822, 63, 1431, 14, 2634, 3430, 16, 61, 1039, 327, 593, 76, 424, 4692, 5459, 402, 314, 570, 4165, 6974, 465, 376, 2225, 402, 1039, 327, 314, 1642, 4811, 1031, 14, 1039, 587, 26, 1675, 687, 2748, 14, 4556, 492, 19165, 1675, 8266, 275, 19165, 14, 1122, 8, 3189, 63, 515, 9, 1675, 6822, 275, 8266, 14, 15045, 360, 2373, 5832, 16, 1055, 12956, 360, 5792, 358, 2958, 340, 6822, 26, 1039, 372, 399, 7, 31222, 3295, 83, 7, 450, 6822, 1128, 372, 399, 7, 31222, 13, 5187, 7, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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, 0, 0, 0, 0, 0 ]
vanaf/mirrormanager-rfremix
mirrorlist-server/test/server_tester.py
3
2120
#!/usr/bin/python # # Copyright (c) 2007-2013 Dell, Inc. # by Matt Domsch <Matt_Domsch@dell.com> # Licensed under the MIT/X11 license import socket, os import cPickle as pickle from string import zfill, atoi from datetime import datetime socketfile = '/var/run/mirrormanager/mirrorlist_server.sock' pid = os.getpid() connectTime = None def do_mirrorlist(d): try: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) start = datetime.utcnow() s.connect(socketfile) end = datetime.utcnow() except: raise global connectTime connectTime = (end - start) p = pickle.dumps(d) size = len(p) #print "writing size %s to server" % size s.sendall(zfill('%s' % size, 10)) # write the pickle #print "writing the pickle" s.sendall(p) s.shutdown(socket.SHUT_WR) del p #print "reading result pickle size back" readlen = 0 resultsize = '' while readlen < 10: resultsize += s.recv(10 - readlen) readlen = len(resultsize) resultsize = atoi(resultsize) #print "reading %s bytes of the results list" % resultsize readlen = 0 p = '' while readlen < resultsize: p += s.recv(resultsize - readlen) readlen = len(p) s.shutdown(socket.SHUT_RD) results = pickle.loads(p) del p return results # This takes 0.120-0.126 seconds, so should be done before any requests import random while True: client_ip = "%s.%s.%s.%s" % (random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255)) d = {'repo':'fedora-18', 'arch':'i386', 'metalink':False} for k, v in d.iteritems(): try: d[k] = unicode(v, 'utf8', 'replace') except: pass client_ip = u"%s.%s.%s.%s" % (random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255)) d['client_ip'] = client_ip start = datetime.utcnow() result = do_mirrorlist(d) end = datetime.utcnow() print "[%s] connect: %s total: %s" % (pid, connectTime, (end-start))
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 10219, 13, 6965, 577, 1697, 12, 3277, 14, 199, 3, 221, 701, 31653, 577, 676, 15820, 665, 45, 6796, 63, 20106, 15820, 32, 271, 914, 14, 957, 30, 199, 3, 3909, 1334, 314, 10697, 15, 56, 845, 4190, 199, 199, 646, 2838, 12, 747, 199, 646, 17572, 465, 5927, 199, 504, 1059, 492, 1315, 4498, 12, 282, 475, 73, 199, 504, 2197, 492, 2197, 199, 199, 3450, 493, 275, 1994, 1391, 15, 1065, 15, 12324, 2609, 15, 12324, 513, 63, 1000, 14, 5096, 7, 199, 199, 3150, 275, 747, 14, 17829, 342, 199, 2242, 1366, 275, 488, 199, 199, 318, 886, 63, 12324, 513, 8, 68, 304, 272, 862, 26, 267, 308, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 19584, 12, 2838, 14, 9469, 63, 9484, 9, 267, 1343, 275, 2197, 14, 10779, 342, 267, 308, 14, 2242, 8, 3450, 493, 9, 267, 1284, 275, 2197, 14, 10779, 342, 272, 871, 26, 267, 746, 339, 2288, 4907, 1366, 272, 4907, 1366, 275, 334, 500, 446, 1343, 9, 272, 299, 275, 5927, 14, 4180, 8, 68, 9, 272, 1568, 275, 822, 8, 80, 9, 272, 327, 1361, 298, 14827, 1568, 450, 83, 370, 1654, 2, 450, 1568, 272, 308, 14, 22695, 8, 26626, 3508, 83, 7, 450, 1568, 12, 1616, 430, 339, 327, 2218, 314, 5927, 272, 327, 1361, 298, 14827, 314, 5927, 2, 272, 308, 14, 22695, 8, 80, 9, 272, 308, 14, 8831, 8, 3450, 14, 24340, 63, 6524, 9, 272, 2150, 299, 339, 327, 1361, 298, 19332, 754, 5927, 1568, 1771, 2, 272, 1586, 552, 275, 378, 272, 754, 890, 275, 2125, 272, 1830, 1586, 552, 665, 1616, 26, 267, 754, 890, 847, 308, 14, 7637, 8, 709, 446, 1586, 552, 9, 267, 1586, 552, 275, 822, 8, 1099, 890, 9, 272, 754, 890, 275, 282, 475, 73, 8, 1099, 890, 9, 2286, 327, 1361, 298, 19332, 450, 83, 2783, 402, 314, 2058, 769, 2, 450, 754, 890, 272, 1586, 552, 275, 378, 272, 299, 275, 2125, 272, 1830, 1586, 552, 665, 754, 890, 26, 267, 299, 847, 308, 14, 7637, 8, 1099, 890, 446, 1586, 552, 9, 267, 1586, 552, 275, 822, 8, 80, 9, 5493, 308, 14, 8831, 8, 3450, 14, 24340, 63, 15543, 9, 272, 2058, 275, 5927, 14, 3640, 8, 80, 9, 272, 2150, 299, 339, 372, 2058, 421, 199, 3, 961, 6181, 378, 14, 6708, 13, 16, 14, 7957, 4696, 12, 880, 1077, 506, 4224, 2544, 1263, 4145, 199, 646, 2196, 199, 199, 6710, 715, 26, 272, 1890, 63, 711, 275, 2071, 83, 4111, 83, 4111, 83, 4111, 83, 2, 450, 334, 2355, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 430, 339, 366, 275, 791, 3417, 5242, 28803, 13, 1085, 297, 268, 283, 1047, 5242, 73, 8040, 297, 268, 283, 22420, 2292, 356, 797, 93, 339, 367, 1022, 12, 373, 315, 366, 14, 4611, 837, 267, 862, 26, 288, 366, 59, 75, 61, 275, 2649, 8, 86, 12, 283, 1624, 24, 297, 283, 1814, 358, 267, 871, 26, 288, 986, 339, 1890, 63, 711, 275, 399, 6808, 83, 4111, 83, 4111, 83, 4111, 83, 2, 450, 334, 2355, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 430, 272, 366, 459, 1258, 63, 711, 418, 275, 1890, 63, 711, 339, 1343, 275, 2197, 14, 10779, 342, 272, 754, 275, 886, 63, 12324, 513, 8, 68, 9, 272, 1284, 275, 2197, 14, 10779, 342, 272, 870, 26503, 83, 61, 257, 4907, 26, 450, 83, 221, 3141, 26, 450, 83, 2, 450, 334, 3150, 12, 4907, 1366, 12, 334, 500, 13, 928, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 10219, 13, 6965, 577, 1697, 12, 3277, 14, 199, 3, 221, 701, 31653, 577, 676, 15820, 665, 45, 6796, 63, 20106, 15820, 32, 271, 914, 14, 957, 30, 199, 3, 3909, 1334, 314, 10697, 15, 56, 845, 4190, 199, 199, 646, 2838, 12, 747, 199, 646, 17572, 465, 5927, 199, 504, 1059, 492, 1315, 4498, 12, 282, 475, 73, 199, 504, 2197, 492, 2197, 199, 199, 3450, 493, 275, 1994, 1391, 15, 1065, 15, 12324, 2609, 15, 12324, 513, 63, 1000, 14, 5096, 7, 199, 199, 3150, 275, 747, 14, 17829, 342, 199, 2242, 1366, 275, 488, 199, 199, 318, 886, 63, 12324, 513, 8, 68, 304, 272, 862, 26, 267, 308, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 19584, 12, 2838, 14, 9469, 63, 9484, 9, 267, 1343, 275, 2197, 14, 10779, 342, 267, 308, 14, 2242, 8, 3450, 493, 9, 267, 1284, 275, 2197, 14, 10779, 342, 272, 871, 26, 267, 746, 339, 2288, 4907, 1366, 272, 4907, 1366, 275, 334, 500, 446, 1343, 9, 272, 299, 275, 5927, 14, 4180, 8, 68, 9, 272, 1568, 275, 822, 8, 80, 9, 272, 327, 1361, 298, 14827, 1568, 450, 83, 370, 1654, 2, 450, 1568, 272, 308, 14, 22695, 8, 26626, 3508, 83, 7, 450, 1568, 12, 1616, 430, 339, 327, 2218, 314, 5927, 272, 327, 1361, 298, 14827, 314, 5927, 2, 272, 308, 14, 22695, 8, 80, 9, 272, 308, 14, 8831, 8, 3450, 14, 24340, 63, 6524, 9, 272, 2150, 299, 339, 327, 1361, 298, 19332, 754, 5927, 1568, 1771, 2, 272, 1586, 552, 275, 378, 272, 754, 890, 275, 2125, 272, 1830, 1586, 552, 665, 1616, 26, 267, 754, 890, 847, 308, 14, 7637, 8, 709, 446, 1586, 552, 9, 267, 1586, 552, 275, 822, 8, 1099, 890, 9, 272, 754, 890, 275, 282, 475, 73, 8, 1099, 890, 9, 2286, 327, 1361, 298, 19332, 450, 83, 2783, 402, 314, 2058, 769, 2, 450, 754, 890, 272, 1586, 552, 275, 378, 272, 299, 275, 2125, 272, 1830, 1586, 552, 665, 754, 890, 26, 267, 299, 847, 308, 14, 7637, 8, 1099, 890, 446, 1586, 552, 9, 267, 1586, 552, 275, 822, 8, 80, 9, 5493, 308, 14, 8831, 8, 3450, 14, 24340, 63, 15543, 9, 272, 2058, 275, 5927, 14, 3640, 8, 80, 9, 272, 2150, 299, 339, 372, 2058, 421, 199, 3, 961, 6181, 378, 14, 6708, 13, 16, 14, 7957, 4696, 12, 880, 1077, 506, 4224, 2544, 1263, 4145, 199, 646, 2196, 199, 199, 6710, 715, 26, 272, 1890, 63, 711, 275, 2071, 83, 4111, 83, 4111, 83, 4111, 83, 2, 450, 334, 2355, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 430, 339, 366, 275, 791, 3417, 5242, 28803, 13, 1085, 297, 268, 283, 1047, 5242, 73, 8040, 297, 268, 283, 22420, 2292, 356, 797, 93, 339, 367, 1022, 12, 373, 315, 366, 14, 4611, 837, 267, 862, 26, 288, 366, 59, 75, 61, 275, 2649, 8, 86, 12, 283, 1624, 24, 297, 283, 1814, 358, 267, 871, 26, 288, 986, 339, 1890, 63, 711, 275, 399, 6808, 83, 4111, 83, 4111, 83, 4111, 83, 2, 450, 334, 2355, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 395, 2196, 14, 8393, 8, 16, 12, 2299, 430, 272, 366, 459, 1258, 63, 711, 418, 275, 1890, 63, 711, 339, 1343, 275, 2197, 14, 10779, 342, 272, 754, 275, 886, 63, 12324, 513, 8, 68, 9, 272, 1284, 275, 2197, 14, 10779, 342, 272, 870, 26503, 83, 61, 257, 4907, 26, 450, 83, 221, 3141, 26, 450, 83, 2, 450, 334, 3150, 12, 4907, 1366, 12, 334, 500, 13, 928, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1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i-Menu
build/lib.linux-x86_64-2.7/django/db/migrations/questioner.py
119
7690
from __future__ import print_function, unicode_literals import importlib import os import sys from django.apps import apps from django.db.models.fields import NOT_PROVIDED from django.utils import datetime_safe, six, timezone from django.utils.six.moves import input from .loader import MIGRATIONS_MODULE_NAME class MigrationQuestioner(object): """ Gives the autodetector responses to questions it might have. This base class has a built-in noninteractive mode, but the interactive subclass is what the command-line arguments will use. """ def __init__(self, defaults=None, specified_apps=None, dry_run=None): self.defaults = defaults or {} self.specified_apps = specified_apps or set() self.dry_run = dry_run def ask_initial(self, app_label): "Should we create an initial migration for the app?" # If it was specified on the command line, definitely true if app_label in self.specified_apps: return True # Otherwise, we look to see if it has a migrations module # without any Python files in it, apart from __init__.py. # Apps from the new app template will have these; the python # file check will ensure we skip South ones. try: app_config = apps.get_app_config(app_label) except LookupError: # It's a fake app. return self.defaults.get("ask_initial", False) migrations_import_path = "%s.%s" % (app_config.name, MIGRATIONS_MODULE_NAME) try: migrations_module = importlib.import_module(migrations_import_path) except ImportError: return self.defaults.get("ask_initial", False) else: if hasattr(migrations_module, "__file__"): filenames = os.listdir(os.path.dirname(migrations_module.__file__)) elif hasattr(migrations_module, "__path__"): if len(migrations_module.__path__) > 1: return False filenames = os.listdir(list(migrations_module.__path__)[0]) return not any(x.endswith(".py") for x in filenames if x != "__init__.py") def ask_not_null_addition(self, field_name, model_name): "Adding a NOT NULL field to a model" # None means quit return None def ask_not_null_alteration(self, field_name, model_name): "Changing a NULL field to NOT NULL" # None means quit return None def ask_rename(self, model_name, old_name, new_name, field_instance): "Was this field really renamed?" return self.defaults.get("ask_rename", False) def ask_rename_model(self, old_model_state, new_model_state): "Was this model really renamed?" return self.defaults.get("ask_rename_model", False) def ask_merge(self, app_label): "Do you really want to merge these migrations?" return self.defaults.get("ask_merge", False) class InteractiveMigrationQuestioner(MigrationQuestioner): def _boolean_input(self, question, default=None): result = input("%s " % question) if not result and default is not None: return default while len(result) < 1 or result[0].lower() not in "yn": result = input("Please answer yes or no: ") return result[0].lower() == "y" def _choice_input(self, question, choices): print(question) for i, choice in enumerate(choices): print(" %s) %s" % (i + 1, choice)) result = input("Select an option: ") while True: try: value = int(result) if 0 < value <= len(choices): return value except ValueError: pass result = input("Please select a valid option: ") def _ask_default(self): print("Please enter the default value now, as valid Python") print("The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now()") while True: if six.PY3: # Six does not correctly abstract over the fact that # py3 input returns a unicode string, while py2 raw_input # returns a bytestring. code = input(">>> ") else: code = input(">>> ").decode(sys.stdin.encoding) if not code: print("Please enter some code, or 'exit' (with no quotes) to exit.") elif code == "exit": sys.exit(1) else: try: return eval(code, {}, {"datetime": datetime_safe, "timezone": timezone}) except (SyntaxError, NameError) as e: print("Invalid input: %s" % e) def ask_not_null_addition(self, field_name, model_name): "Adding a NOT NULL field to a model" if not self.dry_run: choice = self._choice_input( "You are trying to add a non-nullable field '%s' to %s without a default; " "we can't do that (the database needs something to populate existing rows).\n" "Please select a fix:" % (field_name, model_name), [ "Provide a one-off default now (will be set on all existing rows)", "Quit, and let me add a default in models.py", ] ) if choice == 2: sys.exit(3) else: return self._ask_default() return None def ask_not_null_alteration(self, field_name, model_name): "Changing a NULL field to NOT NULL" if not self.dry_run: choice = self._choice_input( "You are trying to change the nullable field '%s' on %s to non-nullable " "without a default; we can't do that (the database needs something to " "populate existing rows).\n" "Please select a fix:" % (field_name, model_name), [ "Provide a one-off default now (will be set on all existing rows)", ("Ignore for now, and let me handle existing rows with NULL myself " "(e.g. adding a RunPython or RunSQL operation in the new migration " "file before the AlterField operation)"), "Quit, and let me add a default in models.py", ] ) if choice == 2: return NOT_PROVIDED elif choice == 3: sys.exit(3) else: return self._ask_default() return None def ask_rename(self, model_name, old_name, new_name, field_instance): "Was this field really renamed?" msg = "Did you rename %s.%s to %s.%s (a %s)? [y/N]" return self._boolean_input(msg % (model_name, old_name, model_name, new_name, field_instance.__class__.__name__), False) def ask_rename_model(self, old_model_state, new_model_state): "Was this model really renamed?" msg = "Did you rename the %s.%s model to %s? [y/N]" return self._boolean_input(msg % (old_model_state.app_label, old_model_state.name, new_model_state.name), False) def ask_merge(self, app_label): return self._boolean_input( "\nMerging will only work if the operations printed above do not conflict\n" + "with each other (working on different fields or models)\n" + "Do you want to merge these migration branches? [y/N]", False, )
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 646, 14802, 199, 646, 747, 199, 646, 984, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 2845, 63, 21403, 1149, 199, 504, 1639, 14, 1208, 492, 2197, 63, 3489, 12, 3816, 12, 7137, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1324, 199, 199, 504, 1275, 3422, 492, 603, 1277, 50, 12969, 63, 10001, 63, 2339, 421, 199, 533, 12090, 16778, 281, 8, 785, 304, 272, 408, 272, 598, 7602, 314, 28537, 9119, 9320, 370, 23071, 652, 5594, 1172, 14, 272, 961, 1300, 1021, 965, 282, 6137, 13, 262, 2222, 13543, 818, 12, 1325, 314, 272, 12777, 5516, 365, 4052, 314, 1414, 13, 604, 2368, 911, 675, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4243, 29, 403, 12, 2013, 63, 5181, 29, 403, 12, 9951, 63, 1065, 29, 403, 304, 267, 291, 14, 4322, 275, 4243, 503, 1052, 267, 291, 14, 10085, 63, 5181, 275, 2013, 63, 5181, 503, 663, 342, 267, 291, 14, 10481, 63, 1065, 275, 9951, 63, 1065, 339, 347, 7198, 63, 2747, 8, 277, 12, 1145, 63, 1302, 304, 267, 298, 11408, 781, 1218, 376, 2536, 8367, 367, 314, 1145, 13472, 267, 327, 982, 652, 1990, 2013, 641, 314, 1414, 1004, 12, 28088, 590, 2549, 267, 340, 1145, 63, 1302, 315, 291, 14, 10085, 63, 5181, 26, 288, 372, 715, 267, 327, 6630, 12, 781, 3648, 370, 1937, 340, 652, 965, 282, 6180, 859, 267, 327, 1928, 1263, 2018, 1584, 315, 652, 12, 29430, 687, 636, 826, 4343, 647, 14, 267, 327, 4693, 83, 687, 314, 892, 1145, 1978, 911, 1172, 3520, 27, 314, 2366, 267, 327, 570, 1104, 911, 4868, 781, 3372, 23150, 7869, 14, 267, 862, 26, 288, 1145, 63, 888, 275, 8686, 14, 362, 63, 571, 63, 888, 8, 571, 63, 1302, 9, 267, 871, 19021, 26, 260, 327, 2779, 1159, 282, 4026, 1145, 14, 288, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 2747, 401, 756, 9, 267, 6180, 63, 646, 63, 515, 275, 2071, 83, 4111, 83, 2, 450, 334, 571, 63, 888, 14, 354, 12, 603, 1277, 50, 12969, 63, 10001, 63, 2339, 9, 267, 862, 26, 288, 6180, 63, 578, 275, 14802, 14, 646, 63, 578, 8, 7685, 63, 646, 63, 515, 9, 267, 871, 3545, 26, 288, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 2747, 401, 756, 9, 267, 587, 26, 288, 340, 2688, 8, 7685, 63, 578, 12, 4396, 493, 363, 2349, 355, 6203, 275, 747, 14, 7374, 8, 736, 14, 515, 14, 3475, 8, 7685, 63, 578, 855, 493, 8964, 288, 916, 2688, 8, 7685, 63, 578, 12, 4396, 515, 363, 2349, 355, 340, 822, 8, 7685, 63, 578, 855, 515, 3368, 690, 413, 26, 490, 372, 756, 355, 6203, 275, 747, 14, 7374, 8, 513, 8, 7685, 63, 578, 855, 515, 363, 2788, 16, 566, 288, 372, 440, 1263, 8, 88, 14, 4130, 9520, 647, 531, 367, 671, 315, 6203, 340, 671, 1137, 4396, 826, 4343, 647, 531, 339, 347, 7198, 63, 1397, 63, 2307, 63, 26799, 8, 277, 12, 901, 63, 354, 12, 1402, 63, 354, 304, 267, 298, 20897, 282, 2845, 5962, 901, 370, 282, 1402, 2, 267, 327, 488, 4910, 17242, 267, 372, 488, 339, 347, 7198, 63, 1397, 63, 2307, 63, 279, 5388, 8, 277, 12, 901, 63, 354, 12, 1402, 63, 354, 304, 267, 298, 1049, 8544, 282, 5962, 901, 370, 2845, 5962, 2, 267, 327, 488, 4910, 17242, 267, 372, 488, 339, 347, 7198, 63, 8165, 8, 277, 12, 1402, 63, 354, 12, 2269, 63, 354, 12, 892, 63, 354, 12, 901, 63, 842, 304, 267, 298, 55, 305, 642, 901, 7710, 17864, 13472, 267, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 8165, 401, 756, 9, 339, 347, 7198, 63, 8165, 63, 1238, 8, 277, 12, 2269, 63, 1238, 63, 929, 12, 892, 63, 1238, 63, 929, 304, 267, 298, 55, 305, 642, 1402, 7710, 17864, 13472, 267, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 8165, 63, 1238, 401, 756, 9, 339, 347, 7198, 63, 5628, 8, 277, 12, 1145, 63, 1302, 304, 267, 298, 2585, 1265, 7710, 2934, 370, 5389, 3520, 6180, 13472, 267, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 5628, 401, 756, 9, 421, 199, 533, 1010, 7502, 9816, 16778, 281, 8, 9816, 16778, 281, 304, 339, 347, 485, 4871, 63, 1210, 8, 277, 12, 7894, 12, 849, 29, 403, 304, 267, 754, 275, 1324, 3647, 83, 298, 450, 7894, 9, 267, 340, 440, 754, 436, 849, 365, 440, 488, 26, 288, 372, 849, 267, 1830, 822, 8, 1099, 9, 665, 413, 503, 754, 59, 16, 1055, 2325, 342, 440, 315, 298, 1236, 582, 288, 754, 275, 1324, 480, 8254, 6385, 9456, 503, 949, 26, 6099, 267, 372, 754, 59, 16, 1055, 2325, 342, 508, 298, 89, 2, 339, 347, 485, 5095, 63, 1210, 8, 277, 12, 7894, 12, 3415, 304, 267, 870, 8, 4790, 9, 267, 367, 284, 12, 7141, 315, 3874, 8, 4577, 304, 288, 870, 480, 450, 83, 9, 450, 83, 2, 450, 334, 73, 435, 413, 12, 7141, 430, 267, 754, 275, 1324, 480, 5446, 376, 945, 26, 6099, 267, 1830, 715, 26, 288, 862, 26, 355, 574, 275, 1109, 8, 1099, 9, 355, 340, 378, 665, 574, 2695, 822, 8, 4577, 304, 490, 372, 574, 288, 871, 1722, 26, 355, 986, 288, 754, 275, 1324, 480, 8254, 3504, 282, 1686, 945, 26, 6099, 339, 347, 485, 813, 63, 885, 8, 277, 304, 267, 870, 480, 8254, 9509, 314, 849, 574, 3063, 12, 465, 1686, 2018, 531, 267, 870, 480, 1918, 2197, 436, 1639, 14, 1208, 14, 7145, 4621, 787, 2808, 12, 880, 1265, 883, 886, 325, 14, 71, 14, 7137, 14, 2131, 16060, 267, 1830, 715, 26, 288, 340, 3816, 14, 4521, 19, 26, 355, 327, 428, 1148, 1630, 440, 6657, 9006, 1806, 314, 10572, 626, 355, 327, 1134, 19, 1324, 2529, 282, 2649, 1059, 12, 1830, 1134, 18, 3066, 63, 1210, 355, 327, 2529, 282, 23888, 14, 355, 1233, 275, 1324, 480, 6071, 6099, 288, 587 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 646, 14802, 199, 646, 747, 199, 646, 984, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 2845, 63, 21403, 1149, 199, 504, 1639, 14, 1208, 492, 2197, 63, 3489, 12, 3816, 12, 7137, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1324, 199, 199, 504, 1275, 3422, 492, 603, 1277, 50, 12969, 63, 10001, 63, 2339, 421, 199, 533, 12090, 16778, 281, 8, 785, 304, 272, 408, 272, 598, 7602, 314, 28537, 9119, 9320, 370, 23071, 652, 5594, 1172, 14, 272, 961, 1300, 1021, 965, 282, 6137, 13, 262, 2222, 13543, 818, 12, 1325, 314, 272, 12777, 5516, 365, 4052, 314, 1414, 13, 604, 2368, 911, 675, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4243, 29, 403, 12, 2013, 63, 5181, 29, 403, 12, 9951, 63, 1065, 29, 403, 304, 267, 291, 14, 4322, 275, 4243, 503, 1052, 267, 291, 14, 10085, 63, 5181, 275, 2013, 63, 5181, 503, 663, 342, 267, 291, 14, 10481, 63, 1065, 275, 9951, 63, 1065, 339, 347, 7198, 63, 2747, 8, 277, 12, 1145, 63, 1302, 304, 267, 298, 11408, 781, 1218, 376, 2536, 8367, 367, 314, 1145, 13472, 267, 327, 982, 652, 1990, 2013, 641, 314, 1414, 1004, 12, 28088, 590, 2549, 267, 340, 1145, 63, 1302, 315, 291, 14, 10085, 63, 5181, 26, 288, 372, 715, 267, 327, 6630, 12, 781, 3648, 370, 1937, 340, 652, 965, 282, 6180, 859, 267, 327, 1928, 1263, 2018, 1584, 315, 652, 12, 29430, 687, 636, 826, 4343, 647, 14, 267, 327, 4693, 83, 687, 314, 892, 1145, 1978, 911, 1172, 3520, 27, 314, 2366, 267, 327, 570, 1104, 911, 4868, 781, 3372, 23150, 7869, 14, 267, 862, 26, 288, 1145, 63, 888, 275, 8686, 14, 362, 63, 571, 63, 888, 8, 571, 63, 1302, 9, 267, 871, 19021, 26, 260, 327, 2779, 1159, 282, 4026, 1145, 14, 288, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 2747, 401, 756, 9, 267, 6180, 63, 646, 63, 515, 275, 2071, 83, 4111, 83, 2, 450, 334, 571, 63, 888, 14, 354, 12, 603, 1277, 50, 12969, 63, 10001, 63, 2339, 9, 267, 862, 26, 288, 6180, 63, 578, 275, 14802, 14, 646, 63, 578, 8, 7685, 63, 646, 63, 515, 9, 267, 871, 3545, 26, 288, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 2747, 401, 756, 9, 267, 587, 26, 288, 340, 2688, 8, 7685, 63, 578, 12, 4396, 493, 363, 2349, 355, 6203, 275, 747, 14, 7374, 8, 736, 14, 515, 14, 3475, 8, 7685, 63, 578, 855, 493, 8964, 288, 916, 2688, 8, 7685, 63, 578, 12, 4396, 515, 363, 2349, 355, 340, 822, 8, 7685, 63, 578, 855, 515, 3368, 690, 413, 26, 490, 372, 756, 355, 6203, 275, 747, 14, 7374, 8, 513, 8, 7685, 63, 578, 855, 515, 363, 2788, 16, 566, 288, 372, 440, 1263, 8, 88, 14, 4130, 9520, 647, 531, 367, 671, 315, 6203, 340, 671, 1137, 4396, 826, 4343, 647, 531, 339, 347, 7198, 63, 1397, 63, 2307, 63, 26799, 8, 277, 12, 901, 63, 354, 12, 1402, 63, 354, 304, 267, 298, 20897, 282, 2845, 5962, 901, 370, 282, 1402, 2, 267, 327, 488, 4910, 17242, 267, 372, 488, 339, 347, 7198, 63, 1397, 63, 2307, 63, 279, 5388, 8, 277, 12, 901, 63, 354, 12, 1402, 63, 354, 304, 267, 298, 1049, 8544, 282, 5962, 901, 370, 2845, 5962, 2, 267, 327, 488, 4910, 17242, 267, 372, 488, 339, 347, 7198, 63, 8165, 8, 277, 12, 1402, 63, 354, 12, 2269, 63, 354, 12, 892, 63, 354, 12, 901, 63, 842, 304, 267, 298, 55, 305, 642, 901, 7710, 17864, 13472, 267, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 8165, 401, 756, 9, 339, 347, 7198, 63, 8165, 63, 1238, 8, 277, 12, 2269, 63, 1238, 63, 929, 12, 892, 63, 1238, 63, 929, 304, 267, 298, 55, 305, 642, 1402, 7710, 17864, 13472, 267, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 8165, 63, 1238, 401, 756, 9, 339, 347, 7198, 63, 5628, 8, 277, 12, 1145, 63, 1302, 304, 267, 298, 2585, 1265, 7710, 2934, 370, 5389, 3520, 6180, 13472, 267, 372, 291, 14, 4322, 14, 362, 480, 813, 63, 5628, 401, 756, 9, 421, 199, 533, 1010, 7502, 9816, 16778, 281, 8, 9816, 16778, 281, 304, 339, 347, 485, 4871, 63, 1210, 8, 277, 12, 7894, 12, 849, 29, 403, 304, 267, 754, 275, 1324, 3647, 83, 298, 450, 7894, 9, 267, 340, 440, 754, 436, 849, 365, 440, 488, 26, 288, 372, 849, 267, 1830, 822, 8, 1099, 9, 665, 413, 503, 754, 59, 16, 1055, 2325, 342, 440, 315, 298, 1236, 582, 288, 754, 275, 1324, 480, 8254, 6385, 9456, 503, 949, 26, 6099, 267, 372, 754, 59, 16, 1055, 2325, 342, 508, 298, 89, 2, 339, 347, 485, 5095, 63, 1210, 8, 277, 12, 7894, 12, 3415, 304, 267, 870, 8, 4790, 9, 267, 367, 284, 12, 7141, 315, 3874, 8, 4577, 304, 288, 870, 480, 450, 83, 9, 450, 83, 2, 450, 334, 73, 435, 413, 12, 7141, 430, 267, 754, 275, 1324, 480, 5446, 376, 945, 26, 6099, 267, 1830, 715, 26, 288, 862, 26, 355, 574, 275, 1109, 8, 1099, 9, 355, 340, 378, 665, 574, 2695, 822, 8, 4577, 304, 490, 372, 574, 288, 871, 1722, 26, 355, 986, 288, 754, 275, 1324, 480, 8254, 3504, 282, 1686, 945, 26, 6099, 339, 347, 485, 813, 63, 885, 8, 277, 304, 267, 870, 480, 8254, 9509, 314, 849, 574, 3063, 12, 465, 1686, 2018, 531, 267, 870, 480, 1918, 2197, 436, 1639, 14, 1208, 14, 7145, 4621, 787, 2808, 12, 880, 1265, 883, 886, 325, 14, 71, 14, 7137, 14, 2131, 16060, 267, 1830, 715, 26, 288, 340, 3816, 14, 4521, 19, 26, 355, 327, 428, 1148, 1630, 440, 6657, 9006, 1806, 314, 10572, 626, 355, 327, 1134, 19, 1324, 2529, 282, 2649, 1059, 12, 1830, 1134, 18, 3066, 63, 1210, 355, 327, 2529, 282, 23888, 14, 355, 1233, 275, 1324, 480, 6071, 6099, 288, 587, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
GorK-ChO/selenium
py/conftest.py
7
7314
# Licensed to the Software Freedom Conservancy (SFC) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The SFC 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. import os import socket import subprocess import sys import time import pytest from _pytest.skipping import MarkEvaluator from selenium import webdriver from selenium.webdriver import DesiredCapabilities from test.selenium.webdriver.common.webserver import SimpleWebServer from test.selenium.webdriver.common.network import get_lan_ip if sys.version_info[0] == 3: from urllib.request import urlopen else: from urllib import urlopen drivers = ( 'BlackBerry', 'Chrome', 'Edge', 'Firefox', 'Ie', 'Marionette', 'Remote', 'Safari', 'WebKitGTK', ) def pytest_addoption(parser): parser.addoption('--driver', action='append', choices=drivers, dest='drivers', metavar='DRIVER', help='driver to run tests against ({})'.format(', '.join(drivers))) parser.addoption('--browser-binary', action='store', dest='binary', help='location of the browser binary') parser.addoption('--driver-binary', action='store', dest='executable', help='location of the service executable binary') parser.addoption('--browser-args', action='store', dest='args', help='arguments to start the browser with') def pytest_ignore_collect(path, config): _drivers = set(drivers).difference(config.getoption('drivers') or drivers) parts = path.dirname.split(os.path.sep) return len([d for d in _drivers if d.lower() in parts]) > 0 driver_instance = None @pytest.fixture(scope='function') def driver(request): kwargs = {} try: driver_class = request.param except AttributeError: raise Exception('This test requires a --driver to be specified.') # conditionally mark tests as expected to fail based on driver request.node._evalxfail = request.node._evalxfail or MarkEvaluator( request.node, 'xfail_{0}'.format(driver_class.lower())) if request.node._evalxfail.istrue(): def fin(): global driver_instance if driver_instance is not None: driver_instance.quit() driver_instance = None request.addfinalizer(fin) # skip driver instantiation if xfail(run=False) if not request.config.getoption('runxfail'): if request.node._evalxfail.istrue(): if request.node._evalxfail.get('run') is False: yield return driver_path = request.config.option.executable options = None global driver_instance if driver_instance is None: if driver_class == 'BlackBerry': kwargs.update({'device_password': 'password'}) if driver_class == 'Firefox': kwargs.update({'capabilities': {'marionette': False}}) options = get_options(driver_class, request.config) if driver_class == 'Marionette': driver_class = 'Firefox' options = get_options(driver_class, request.config) if driver_class == 'Remote': capabilities = DesiredCapabilities.FIREFOX.copy() capabilities['marionette'] = False kwargs.update({'desired_capabilities': capabilities}) options = get_options('Firefox', request.config) if driver_class == 'WebKitGTK': options = get_options(driver_class, request.config) if driver_path is not None: kwargs['executable_path'] = driver_path if options is not None: kwargs['options'] = options driver_instance = getattr(webdriver, driver_class)(**kwargs) yield driver_instance if MarkEvaluator(request.node, 'no_driver_after_test').istrue(): driver_instance = None def get_options(driver_class, config): browser_path = config.option.binary browser_args = config.option.args options = None if browser_path or browser_args: options = getattr(webdriver, '{}Options'.format(driver_class))() if driver_class == 'WebKitGTK': options.overlay_scrollbars_enabled = False if browser_path is not None: options.binary_location = browser_path if browser_args is not None: for arg in browser_args.split(): options.add_argument(arg) return options @pytest.fixture(scope='session', autouse=True) def stop_driver(request): def fin(): global driver_instance if driver_instance is not None: driver_instance.quit() driver_instance = None request.addfinalizer(fin) def pytest_exception_interact(node, call, report): if report.failed: global driver_instance if driver_instance is not None: driver_instance.quit() driver_instance = None @pytest.fixture def pages(driver, webserver): class Pages(object): def url(self, name): return webserver.where_is(name) def load(self, name): driver.get(self.url(name)) return Pages() @pytest.fixture(autouse=True, scope='session') def server(request): drivers = request.config.getoption('drivers') if drivers is None or 'Remote' not in drivers: yield None return _host = 'localhost' _port = 4444 _path = '../buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar' def wait_for_server(url, timeout): start = time.time() while time.time() - start < timeout: try: urlopen(url) return 1 except IOError: time.sleep(0.2) return 0 _socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) url = 'http://{}:{}/wd/hub'.format(_host, _port) try: _socket.connect((_host, _port)) print('The remote driver server is already running or something else' 'is using port {}, continuing...'.format(_port)) except Exception: print('Starting the Selenium server') process = subprocess.Popen(['java', '-jar', _path]) print('Selenium server running as process: {}'.format(process.pid)) assert wait_for_server(url, 10), 'Timed out waiting for Selenium server at {}'.format(url) print('Selenium server is ready') yield process process.terminate() process.wait() print('Selenium server has been terminated') @pytest.fixture(autouse=True, scope='session') def webserver(): webserver = SimpleWebServer(host=get_lan_ip()) webserver.start() yield webserver webserver.stop()
apache-2.0
[ 3, 3909, 370, 314, 2290, 481, 3798, 676, 1448, 7297, 9844, 334, 51, 4161, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 428, 4161, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 199, 646, 4613, 199, 504, 485, 4462, 14, 27713, 492, 7173, 10006, 16530, 199, 199, 504, 19481, 492, 28094, 199, 504, 19481, 14, 17946, 492, 1487, 5381, 17006, 199, 504, 511, 14, 15041, 14, 17946, 14, 2330, 14, 29819, 492, 5870, 5926, 3120, 199, 504, 511, 14, 15041, 14, 17946, 14, 2330, 14, 1200, 492, 664, 63, 1502, 63, 711, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 26, 272, 687, 4011, 14, 1069, 492, 18279, 199, 2836, 26, 272, 687, 4011, 492, 18279, 199, 199, 13337, 275, 334, 272, 283, 23405, 24947, 651, 297, 272, 283, 18083, 297, 272, 283, 12886, 297, 272, 283, 27983, 297, 272, 283, 14485, 297, 272, 283, 45, 759, 368, 14586, 297, 272, 283, 6713, 297, 272, 283, 51, 2756, 759, 297, 272, 283, 21666, 8391, 43, 297, 199, 9, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 1798, 14, 525, 1422, 4517, 3090, 297, 1595, 534, 740, 297, 3415, 29, 13337, 12, 2053, 534, 13337, 297, 2151, 8214, 534, 23401, 297, 2151, 1720, 534, 3090, 370, 1255, 2295, 6169, 11459, 25885, 908, 5102, 1987, 904, 8, 13337, 1724, 272, 1798, 14, 525, 1422, 4517, 5750, 13, 3008, 297, 1595, 534, 1617, 297, 2053, 534, 3008, 297, 2151, 1720, 534, 1985, 402, 314, 7042, 3366, 358, 272, 1798, 14, 525, 1422, 4517, 3090, 13, 3008, 297, 1595, 534, 1617, 297, 2053, 534, 5904, 297, 2151, 1720, 534, 1985, 402, 314, 2435, 7286, 3366, 358, 272, 1798, 14, 525, 1422, 4517, 5750, 13, 589, 297, 1595, 534, 1617, 297, 2053, 534, 589, 297, 2151, 1720, 534, 4958, 370, 1343, 314, 7042, 543, 358, 421, 199, 318, 4613, 63, 4247, 63, 7112, 8, 515, 12, 1101, 304, 272, 485, 13337, 275, 663, 8, 13337, 680, 9196, 8, 888, 14, 362, 1422, 360, 13337, 358, 503, 19016, 9, 272, 4184, 275, 931, 14, 3475, 14, 1294, 8, 736, 14, 515, 14, 4127, 9, 272, 372, 822, 779, 68, 367, 366, 315, 485, 13337, 340, 366, 14, 2325, 342, 315, 4184, 566, 690, 378, 421, 199, 3090, 63, 842, 275, 488, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 1593, 358, 199, 318, 5253, 8, 1069, 304, 272, 2074, 275, 1052, 339, 862, 26, 267, 5253, 63, 533, 275, 1056, 14, 635, 272, 871, 4281, 26, 267, 746, 2186, 360, 2765, 511, 5074, 282, 1553, 3090, 370, 506, 2013, 2659, 339, 327, 5558, 1183, 2216, 2295, 465, 1420, 370, 2449, 4079, 641, 5253, 272, 1056, 14, 932, 423, 2579, 22557, 275, 1056, 14, 932, 423, 2579, 22557, 503, 7173, 10006, 16530, 8, 267, 1056, 14, 932, 12, 283, 22557, 7348, 16, 5285, 908, 8, 3090, 63, 533, 14, 2325, 4059, 272, 340, 1056, 14, 932, 423, 2579, 22557, 14, 631, 431, 837, 267, 347, 2583, 837, 288, 2288, 5253, 63, 842, 288, 340, 5253, 63, 842, 365, 440, 488, 26, 355, 5253, 63, 842, 14, 10589, 342, 288, 5253, 63, 842, 275, 488, 267, 1056, 14, 525, 30092, 8, 2408, 9, 339, 327, 3372, 5253, 26621, 340, 671, 1633, 8, 1065, 29, 797, 9, 272, 340, 440, 1056, 14, 888, 14, 362, 1422, 360, 1065, 22557, 735, 267, 340, 1056, 14, 932, 423, 2579, 22557, 14, 631, 431, 837, 288, 340, 1056, 14, 932, 423, 2579, 22557, 14, 362, 360, 1065, 358, 365, 756, 26, 355, 1995, 355, 372, 339, 5253, 63, 515, 275, 1056, 14, 888, 14, 1422, 14, 5904, 272, 1511, 275, 488, 339, 2288, 5253, 63, 842, 272, 340, 5253, 63, 842, 365, 488, 26, 267, 340, 5253, 63, 533, 508, 283, 23405, 24947, 651, 356, 288, 2074, 14, 873, 3252, 1782, 63, 2060, 356, 283, 2060, 3071, 267, 340, 5253, 63, 533, 508, 283, 27983, 356, 288, 2074, 14, 873, 3252, 10732, 356, 791, 77, 759, 368, 14586, 356, 756, 19575, 288, 1511, 275, 664, 63, 1419, 8, 3090, 63, 533, 12, 1056, 14, 888, 9, 267, 340, 5253, 63, 533, 508, 283, 45, 759, 368, 14586, 356, 288, 5253, 63, 533, 275, 283, 27983, 7, 288, 1511, 275, 664, 63, 1419, 8, 3090, 63, 533, 12, 1056, 14, 888, 9, 267, 340, 5253, 63, 533, 508, 283, 6713, 356, 288, 14918, 275, 1487, 5381, 17006, 14, 1976, 907, 3230, 56, 14, 1574, 342, 288, 14918, 459, 77, 759, 368, 14586, 418, 275, 756, 288, 2074, 14, 873, 3252, 16035, 63, 10732, 356, 14918, 1552, 288, 1511, 275, 664, 63, 1419, 360, 27983, 297, 1056, 14, 888, 9, 267, 340, 5253, 63, 533, 508, 283, 21666, 8391, 43, 356, 288, 1511, 275, 664, 63, 1419, 8, 3090, 63, 533, 12, 1056, 14, 888, 9, 267, 340, 5253, 63, 515, 365, 440, 488, 26, 288, 2074, 459, 5904, 63, 515, 418, 275, 5253, 63, 515, 267, 340, 1511, 365, 440, 488, 26, 288, 2074, 459, 1419, 418, 275, 1511, 267, 5253, 63, 842, 275, 2519, 8, 17946, 12, 5253, 63, 533, 9, 3682, 958, 9, 272, 1995 ]
[ 3909, 370, 314, 2290, 481, 3798, 676, 1448, 7297, 9844, 334, 51, 4161, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 428, 4161, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 199, 646, 4613, 199, 504, 485, 4462, 14, 27713, 492, 7173, 10006, 16530, 199, 199, 504, 19481, 492, 28094, 199, 504, 19481, 14, 17946, 492, 1487, 5381, 17006, 199, 504, 511, 14, 15041, 14, 17946, 14, 2330, 14, 29819, 492, 5870, 5926, 3120, 199, 504, 511, 14, 15041, 14, 17946, 14, 2330, 14, 1200, 492, 664, 63, 1502, 63, 711, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 26, 272, 687, 4011, 14, 1069, 492, 18279, 199, 2836, 26, 272, 687, 4011, 492, 18279, 199, 199, 13337, 275, 334, 272, 283, 23405, 24947, 651, 297, 272, 283, 18083, 297, 272, 283, 12886, 297, 272, 283, 27983, 297, 272, 283, 14485, 297, 272, 283, 45, 759, 368, 14586, 297, 272, 283, 6713, 297, 272, 283, 51, 2756, 759, 297, 272, 283, 21666, 8391, 43, 297, 199, 9, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 1798, 14, 525, 1422, 4517, 3090, 297, 1595, 534, 740, 297, 3415, 29, 13337, 12, 2053, 534, 13337, 297, 2151, 8214, 534, 23401, 297, 2151, 1720, 534, 3090, 370, 1255, 2295, 6169, 11459, 25885, 908, 5102, 1987, 904, 8, 13337, 1724, 272, 1798, 14, 525, 1422, 4517, 5750, 13, 3008, 297, 1595, 534, 1617, 297, 2053, 534, 3008, 297, 2151, 1720, 534, 1985, 402, 314, 7042, 3366, 358, 272, 1798, 14, 525, 1422, 4517, 3090, 13, 3008, 297, 1595, 534, 1617, 297, 2053, 534, 5904, 297, 2151, 1720, 534, 1985, 402, 314, 2435, 7286, 3366, 358, 272, 1798, 14, 525, 1422, 4517, 5750, 13, 589, 297, 1595, 534, 1617, 297, 2053, 534, 589, 297, 2151, 1720, 534, 4958, 370, 1343, 314, 7042, 543, 358, 421, 199, 318, 4613, 63, 4247, 63, 7112, 8, 515, 12, 1101, 304, 272, 485, 13337, 275, 663, 8, 13337, 680, 9196, 8, 888, 14, 362, 1422, 360, 13337, 358, 503, 19016, 9, 272, 4184, 275, 931, 14, 3475, 14, 1294, 8, 736, 14, 515, 14, 4127, 9, 272, 372, 822, 779, 68, 367, 366, 315, 485, 13337, 340, 366, 14, 2325, 342, 315, 4184, 566, 690, 378, 421, 199, 3090, 63, 842, 275, 488, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 1593, 358, 199, 318, 5253, 8, 1069, 304, 272, 2074, 275, 1052, 339, 862, 26, 267, 5253, 63, 533, 275, 1056, 14, 635, 272, 871, 4281, 26, 267, 746, 2186, 360, 2765, 511, 5074, 282, 1553, 3090, 370, 506, 2013, 2659, 339, 327, 5558, 1183, 2216, 2295, 465, 1420, 370, 2449, 4079, 641, 5253, 272, 1056, 14, 932, 423, 2579, 22557, 275, 1056, 14, 932, 423, 2579, 22557, 503, 7173, 10006, 16530, 8, 267, 1056, 14, 932, 12, 283, 22557, 7348, 16, 5285, 908, 8, 3090, 63, 533, 14, 2325, 4059, 272, 340, 1056, 14, 932, 423, 2579, 22557, 14, 631, 431, 837, 267, 347, 2583, 837, 288, 2288, 5253, 63, 842, 288, 340, 5253, 63, 842, 365, 440, 488, 26, 355, 5253, 63, 842, 14, 10589, 342, 288, 5253, 63, 842, 275, 488, 267, 1056, 14, 525, 30092, 8, 2408, 9, 339, 327, 3372, 5253, 26621, 340, 671, 1633, 8, 1065, 29, 797, 9, 272, 340, 440, 1056, 14, 888, 14, 362, 1422, 360, 1065, 22557, 735, 267, 340, 1056, 14, 932, 423, 2579, 22557, 14, 631, 431, 837, 288, 340, 1056, 14, 932, 423, 2579, 22557, 14, 362, 360, 1065, 358, 365, 756, 26, 355, 1995, 355, 372, 339, 5253, 63, 515, 275, 1056, 14, 888, 14, 1422, 14, 5904, 272, 1511, 275, 488, 339, 2288, 5253, 63, 842, 272, 340, 5253, 63, 842, 365, 488, 26, 267, 340, 5253, 63, 533, 508, 283, 23405, 24947, 651, 356, 288, 2074, 14, 873, 3252, 1782, 63, 2060, 356, 283, 2060, 3071, 267, 340, 5253, 63, 533, 508, 283, 27983, 356, 288, 2074, 14, 873, 3252, 10732, 356, 791, 77, 759, 368, 14586, 356, 756, 19575, 288, 1511, 275, 664, 63, 1419, 8, 3090, 63, 533, 12, 1056, 14, 888, 9, 267, 340, 5253, 63, 533, 508, 283, 45, 759, 368, 14586, 356, 288, 5253, 63, 533, 275, 283, 27983, 7, 288, 1511, 275, 664, 63, 1419, 8, 3090, 63, 533, 12, 1056, 14, 888, 9, 267, 340, 5253, 63, 533, 508, 283, 6713, 356, 288, 14918, 275, 1487, 5381, 17006, 14, 1976, 907, 3230, 56, 14, 1574, 342, 288, 14918, 459, 77, 759, 368, 14586, 418, 275, 756, 288, 2074, 14, 873, 3252, 16035, 63, 10732, 356, 14918, 1552, 288, 1511, 275, 664, 63, 1419, 360, 27983, 297, 1056, 14, 888, 9, 267, 340, 5253, 63, 533, 508, 283, 21666, 8391, 43, 356, 288, 1511, 275, 664, 63, 1419, 8, 3090, 63, 533, 12, 1056, 14, 888, 9, 267, 340, 5253, 63, 515, 365, 440, 488, 26, 288, 2074, 459, 5904, 63, 515, 418, 275, 5253, 63, 515, 267, 340, 1511, 365, 440, 488, 26, 288, 2074, 459, 1419, 418, 275, 1511, 267, 5253, 63, 842, 275, 2519, 8, 17946, 12, 5253, 63, 533, 9, 3682, 958, 9, 272, 1995, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
joergkappes/opengm
src/interfaces/python/examples/python_visitor_gui.py
14
1377
""" Usage: python_visitor_gui.py This script shows how one can implement visitors in pure python and inject them into OpenGM solver. ( not all OpenGM solvers support this kind of code injection ) """ import opengm import numpy import matplotlib from matplotlib import pyplot as plt shape=[100,100] numLabels=10 unaries=numpy.random.rand(shape[0], shape[1],numLabels) potts=opengm.PottsFunction([numLabels,numLabels],0.0,0.4) gm=opengm.grid2d2Order(unaries=unaries,regularizer=potts) inf=opengm.inference.BeliefPropagation(gm,parameter=opengm.InfParam(damping=0.5)) class PyCallback(object): def __init__(self,shape,numLabels): self.shape=shape self.numLabels=numLabels self.cmap = matplotlib.colors.ListedColormap ( numpy.random.rand ( self.numLabels,3)) matplotlib.interactive(True) def begin(self,inference): print "begin of inference" def end(self,inference): print "end of inference" def visit(self,inference): gm=inference.gm() labelVector=inference.arg() print "energy ",gm.evaluate(labelVector) labelVector=labelVector.reshape(self.shape) plt.imshow(labelVector*255.0, cmap=self.cmap,interpolation="nearest") plt.draw() callback=PyCallback(shape,numLabels) visitor=inf.pythonVisitor(callback,visitNth=1) inf.infer(visitor) argmin=inf.arg()
mit
[ 624, 199, 7692, 26, 2366, 63, 19863, 63, 5885, 14, 647, 259, 199, 199, 2765, 2884, 13703, 4212, 1373, 883, 5669, 5684, 1384, 199, 262, 15111, 2366, 436, 16182, 3062, 1901, 3232, 22636, 10196, 14, 199, 8, 440, 1006, 3232, 22636, 10196, 83, 2291, 642, 4928, 402, 5591, 1233, 315, 8923, 776, 199, 624, 199, 199, 646, 1551, 13844, 199, 646, 2680, 199, 646, 8027, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 421, 199, 1392, 1524, 1960, 12, 1960, 61, 199, 1507, 14016, 29, 709, 199, 324, 3433, 29, 4714, 14, 2355, 14, 3759, 8, 1392, 59, 16, 467, 2215, 59, 17, 467, 1507, 14016, 9, 199, 14173, 1086, 29, 1490, 13844, 14, 48, 357, 1086, 3481, 779, 1507, 14016, 12, 1507, 14016, 467, 16, 14, 16, 12, 16, 14, 20, 9, 199, 13844, 29, 1490, 13844, 14, 3825, 18, 68, 18, 4738, 8, 324, 3433, 29, 324, 3433, 12, 14044, 29, 14173, 1086, 9, 199, 4904, 29, 1490, 13844, 14, 20580, 14, 3655, 317, 2829, 11376, 8, 13844, 12, 5329, 29, 1490, 13844, 14, 17354, 4098, 8, 31218, 316, 29, 16, 14, 21, 430, 199, 199, 533, 1611, 2806, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1392, 12, 1507, 14016, 304, 267, 291, 14, 1392, 29, 1392, 267, 291, 14, 1507, 14016, 29, 1507, 14016, 267, 291, 14, 16513, 275, 8027, 14, 7120, 14, 44, 4957, 4117, 1130, 334, 2680, 14, 2355, 14, 3759, 334, 291, 14, 1507, 14016, 12, 19, 430, 267, 8027, 14, 13543, 8, 549, 9, 272, 347, 5386, 8, 277, 12, 20580, 304, 267, 870, 298, 5037, 402, 17353, 2, 272, 347, 1284, 8, 277, 12, 20580, 304, 267, 870, 298, 500, 402, 17353, 2, 272, 347, 5684, 8, 277, 12, 20580, 304, 267, 25561, 29, 20580, 14, 13844, 342, 267, 1768, 3646, 29, 20580, 14, 1273, 342, 267, 870, 298, 8443, 221, 3872, 13844, 14, 7383, 8, 1302, 3646, 9, 267, 1768, 3646, 29, 1302, 3646, 14, 5217, 8, 277, 14, 1392, 9, 267, 4488, 14, 20413, 8, 1302, 3646, 10, 2299, 14, 16, 12, 14920, 29, 277, 14, 16513, 12, 21080, 628, 16615, 531, 4960, 4488, 14, 5485, 342, 421, 199, 3058, 29, 2713, 2806, 8, 1392, 12, 1507, 14016, 9, 199, 19863, 29, 4904, 14, 1548, 18324, 8, 3058, 12, 5427, 46, 273, 29, 17, 9, 199, 199, 4904, 14, 14578, 8, 19863, 9, 199, 26488, 29, 4904, 14, 1273, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 7692, 26, 2366, 63, 19863, 63, 5885, 14, 647, 259, 199, 199, 2765, 2884, 13703, 4212, 1373, 883, 5669, 5684, 1384, 199, 262, 15111, 2366, 436, 16182, 3062, 1901, 3232, 22636, 10196, 14, 199, 8, 440, 1006, 3232, 22636, 10196, 83, 2291, 642, 4928, 402, 5591, 1233, 315, 8923, 776, 199, 624, 199, 199, 646, 1551, 13844, 199, 646, 2680, 199, 646, 8027, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 421, 199, 1392, 1524, 1960, 12, 1960, 61, 199, 1507, 14016, 29, 709, 199, 324, 3433, 29, 4714, 14, 2355, 14, 3759, 8, 1392, 59, 16, 467, 2215, 59, 17, 467, 1507, 14016, 9, 199, 14173, 1086, 29, 1490, 13844, 14, 48, 357, 1086, 3481, 779, 1507, 14016, 12, 1507, 14016, 467, 16, 14, 16, 12, 16, 14, 20, 9, 199, 13844, 29, 1490, 13844, 14, 3825, 18, 68, 18, 4738, 8, 324, 3433, 29, 324, 3433, 12, 14044, 29, 14173, 1086, 9, 199, 4904, 29, 1490, 13844, 14, 20580, 14, 3655, 317, 2829, 11376, 8, 13844, 12, 5329, 29, 1490, 13844, 14, 17354, 4098, 8, 31218, 316, 29, 16, 14, 21, 430, 199, 199, 533, 1611, 2806, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1392, 12, 1507, 14016, 304, 267, 291, 14, 1392, 29, 1392, 267, 291, 14, 1507, 14016, 29, 1507, 14016, 267, 291, 14, 16513, 275, 8027, 14, 7120, 14, 44, 4957, 4117, 1130, 334, 2680, 14, 2355, 14, 3759, 334, 291, 14, 1507, 14016, 12, 19, 430, 267, 8027, 14, 13543, 8, 549, 9, 272, 347, 5386, 8, 277, 12, 20580, 304, 267, 870, 298, 5037, 402, 17353, 2, 272, 347, 1284, 8, 277, 12, 20580, 304, 267, 870, 298, 500, 402, 17353, 2, 272, 347, 5684, 8, 277, 12, 20580, 304, 267, 25561, 29, 20580, 14, 13844, 342, 267, 1768, 3646, 29, 20580, 14, 1273, 342, 267, 870, 298, 8443, 221, 3872, 13844, 14, 7383, 8, 1302, 3646, 9, 267, 1768, 3646, 29, 1302, 3646, 14, 5217, 8, 277, 14, 1392, 9, 267, 4488, 14, 20413, 8, 1302, 3646, 10, 2299, 14, 16, 12, 14920, 29, 277, 14, 16513, 12, 21080, 628, 16615, 531, 4960, 4488, 14, 5485, 342, 421, 199, 3058, 29, 2713, 2806, 8, 1392, 12, 1507, 14016, 9, 199, 19863, 29, 4904, 14, 1548, 18324, 8, 3058, 12, 5427, 46, 273, 29, 17, 9, 199, 199, 4904, 14, 14578, 8, 19863, 9, 199, 26488, 29, 4904, 14, 1273, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chriskuehl/pre-commit-1
tests/commands/run_test.py
4
15170
# -*- coding: UTF-8 -*- from __future__ import unicode_literals import functools import io import os import os.path import subprocess import sys import mock import pytest from pre_commit.commands.install_uninstall import install from pre_commit.commands.run import _get_skips from pre_commit.commands.run import _has_unmerged_paths from pre_commit.commands.run import get_changed_files from pre_commit.commands.run import run from pre_commit.ordereddict import OrderedDict from pre_commit.output import sys_stdout_write_wrapper from pre_commit.runner import Runner from pre_commit.util import cmd_output from pre_commit.util import cwd from testing.auto_namedtuple import auto_namedtuple from testing.fixtures import add_config_to_repo from testing.fixtures import make_consuming_repo @pytest.yield_fixture def repo_with_passing_hook(tmpdir_factory): git_path = make_consuming_repo(tmpdir_factory, 'script_hooks_repo') with cwd(git_path): yield git_path @pytest.yield_fixture def repo_with_failing_hook(tmpdir_factory): git_path = make_consuming_repo(tmpdir_factory, 'failing_hook_repo') with cwd(git_path): yield git_path def stage_a_file(): cmd_output('touch', 'foo.py') cmd_output('git', 'add', 'foo.py') def get_write_mock_output(write_mock): return b''.join(call[0][0] for call in write_mock.write.call_args_list) def _get_opts( all_files=False, files=(), color=False, verbose=False, hook=None, no_stash=False, origin='', source='', allow_unstaged_config=False, ): # These are mutually exclusive assert not (all_files and files) return auto_namedtuple( all_files=all_files, files=files, color=color, verbose=verbose, hook=hook, no_stash=no_stash, origin=origin, source=source, allow_unstaged_config=allow_unstaged_config, ) def _do_run(repo, args, environ={}): runner = Runner(repo) write_mock = mock.Mock() write_fn = functools.partial(sys_stdout_write_wrapper, stream=write_mock) ret = run(runner, args, write=write_fn, environ=environ) printed = get_write_mock_output(write_mock) return ret, printed def _test_run(repo, options, expected_outputs, expected_ret, stage): if stage: stage_a_file() args = _get_opts(**options) ret, printed = _do_run(repo, args) assert ret == expected_ret, (ret, expected_ret, printed) for expected_output_part in expected_outputs: assert expected_output_part in printed def test_run_all_hooks_failing( repo_with_failing_hook, mock_out_store_directory ): _test_run( repo_with_failing_hook, {}, ( b'Failing hook', b'Failed', b'hookid: failing_hook', b'Fail\nfoo.py\n', ), 1, True, ) def test_arbitrary_bytes_hook(tmpdir_factory, mock_out_store_directory): git_path = make_consuming_repo(tmpdir_factory, 'arbitrary_bytes_repo') with cwd(git_path): _test_run(git_path, {}, (b'\xe2\x98\x83\xb2\n',), 1, True) @pytest.mark.parametrize( ('options', 'outputs', 'expected_ret', 'stage'), ( ({}, (b'Bash hook', b'Passed'), 0, True), ({'verbose': True}, (b'foo.py\nHello World',), 0, True), ({'hook': 'bash_hook'}, (b'Bash hook', b'Passed'), 0, True), ({'hook': 'nope'}, (b'No hook with id `nope`',), 1, True), ( {'all_files': True, 'verbose': True}, (b'foo.py',), 0, True, ), ( {'files': ('foo.py',), 'verbose': True}, (b'foo.py',), 0, True, ), ({}, (b'Bash hook', b'(no files to check)', b'Skipped'), 0, False), ) ) def test_run( repo_with_passing_hook, options, outputs, expected_ret, stage, mock_out_store_directory, ): _test_run(repo_with_passing_hook, options, outputs, expected_ret, stage) @pytest.mark.parametrize( ('origin', 'source', 'expect_failure'), ( ('master', 'master', False), ('master', '', True), ('', 'master', True), ) ) def test_origin_source_error_msg( repo_with_passing_hook, origin, source, expect_failure, mock_out_store_directory, ): args = _get_opts(origin=origin, source=source) ret, printed = _do_run(repo_with_passing_hook, args) warning_msg = b'Specify both --origin and --source.' if expect_failure: assert ret == 1 assert warning_msg in printed else: assert ret == 0 assert warning_msg not in printed @pytest.mark.parametrize( ('no_stash', 'all_files', 'expect_stash'), ( (True, True, False), (True, False, False), (False, True, False), (False, False, True), ), ) def test_no_stash( repo_with_passing_hook, no_stash, all_files, expect_stash, mock_out_store_directory, ): stage_a_file() # Make unstaged changes with open('foo.py', 'w') as foo_file: foo_file.write('import os\n') args = _get_opts(no_stash=no_stash, all_files=all_files) ret, printed = _do_run(repo_with_passing_hook, args) assert ret == 0 warning_msg = b'[WARNING] Unstaged files detected.' if expect_stash: assert warning_msg in printed else: assert warning_msg not in printed @pytest.mark.parametrize(('output', 'expected'), (('some', True), ('', False))) def test_has_unmerged_paths(output, expected): mock_runner = mock.Mock() mock_runner.cmd_runner.run.return_value = (1, output, '') assert _has_unmerged_paths(mock_runner) is expected def test_merge_conflict(in_merge_conflict, mock_out_store_directory): ret, printed = _do_run(in_merge_conflict, _get_opts()) assert ret == 1 assert b'Unmerged files. Resolve before committing.' in printed def test_merge_conflict_modified(in_merge_conflict, mock_out_store_directory): # Touch another file so we have unstaged non-conflicting things assert os.path.exists('dummy') with open('dummy', 'w') as dummy_file: dummy_file.write('bar\nbaz\n') ret, printed = _do_run(in_merge_conflict, _get_opts()) assert ret == 1 assert b'Unmerged files. Resolve before committing.' in printed def test_merge_conflict_resolved(in_merge_conflict, mock_out_store_directory): cmd_output('git', 'add', '.') ret, printed = _do_run(in_merge_conflict, _get_opts()) for msg in ( b'Checking merge-conflict files only.', b'Bash hook', b'Passed', ): assert msg in printed @pytest.mark.parametrize( ('environ', 'expected_output'), ( ({}, set([])), ({'SKIP': ''}, set([])), ({'SKIP': ','}, set([])), ({'SKIP': ',foo'}, set(['foo'])), ({'SKIP': 'foo'}, set(['foo'])), ({'SKIP': 'foo,bar'}, set(['foo', 'bar'])), ({'SKIP': ' foo , bar'}, set(['foo', 'bar'])), ), ) def test_get_skips(environ, expected_output): ret = _get_skips(environ) assert ret == expected_output def test_skip_hook(repo_with_passing_hook, mock_out_store_directory): ret, printed = _do_run( repo_with_passing_hook, _get_opts(), {'SKIP': 'bash_hook'}, ) for msg in (b'Bash hook', b'Skipped'): assert msg in printed def test_hook_id_not_in_non_verbose_output( repo_with_passing_hook, mock_out_store_directory ): ret, printed = _do_run(repo_with_passing_hook, _get_opts(verbose=False)) assert b'[bash_hook]' not in printed def test_hook_id_in_verbose_output( repo_with_passing_hook, mock_out_store_directory, ): ret, printed = _do_run(repo_with_passing_hook, _get_opts(verbose=True)) assert b'[bash_hook] Bash hook' in printed def test_multiple_hooks_same_id( repo_with_passing_hook, mock_out_store_directory, ): with cwd(repo_with_passing_hook): # Add bash hook on there again with io.open('.pre-commit-config.yaml', 'a+') as config_file: config_file.write(' - id: bash_hook\n') cmd_output('git', 'add', '.pre-commit-config.yaml') stage_a_file() ret, output = _do_run(repo_with_passing_hook, _get_opts()) assert ret == 0 assert output.count(b'Bash hook') == 2 def test_non_ascii_hook_id( repo_with_passing_hook, mock_out_store_directory, tmpdir_factory, ): with cwd(repo_with_passing_hook): install(Runner(repo_with_passing_hook)) # Don't want to write to home directory env = dict(os.environ, PRE_COMMIT_HOME=tmpdir_factory.get()) _, stdout, _ = cmd_output( sys.executable, '-m', 'pre_commit.main', 'run', '☃', env=env, retcode=None, ) assert 'UnicodeDecodeError' not in stdout # Doesn't actually happen, but a reasonable assertion assert 'UnicodeEncodeError' not in stdout def test_stdout_write_bug_py26( repo_with_failing_hook, mock_out_store_directory, tmpdir_factory, ): with cwd(repo_with_failing_hook): # Add bash hook on there again with io.open( '.pre-commit-config.yaml', 'a+', encoding='UTF-8', ) as config_file: config_file.write(' args: ["☃"]\n') cmd_output('git', 'add', '.pre-commit-config.yaml') stage_a_file() install(Runner(repo_with_failing_hook)) # Don't want to write to home directory env = dict(os.environ, PRE_COMMIT_HOME=tmpdir_factory.get()) # Have to use subprocess because pytest monkeypatches sys.stdout _, stdout, _ = cmd_output( 'git', 'commit', '-m', 'Commit!', # git commit puts pre-commit to stderr stderr=subprocess.STDOUT, env=env, retcode=None, ) assert 'UnicodeEncodeError' not in stdout # Doesn't actually happen, but a reasonable assertion assert 'UnicodeDecodeError' not in stdout def test_get_changed_files(): files = get_changed_files( '78c682a1d13ba20e7cb735313b9314a74365cd3a', '3387edbb1288a580b37fe25225aa0b856b18ad1a', ) assert files == ['CHANGELOG.md', 'setup.py'] def test_lots_of_files(mock_out_store_directory, tmpdir_factory): # windows xargs seems to have a bug, here's a regression test for # our workaround git_path = make_consuming_repo(tmpdir_factory, 'python_hooks_repo') with cwd(git_path): # Override files so we run against them with io.open('.pre-commit-config.yaml', 'a+') as config_file: config_file.write(' files: ""\n') # Write a crap ton of files for i in range(400): filename = '{0}{1}'.format('a' * 100, i) open(filename, 'w').close() cmd_output('bash', '-c', 'git add .') install(Runner(git_path)) # Don't want to write to home directory env = dict(os.environ, PRE_COMMIT_HOME=tmpdir_factory.get()) cmd_output( 'git', 'commit', '-m', 'Commit!', # git commit puts pre-commit to stderr stderr=subprocess.STDOUT, env=env, ) def test_local_hook_passes( repo_with_passing_hook, mock_out_store_directory, ): config = OrderedDict(( ('repo', 'local'), ('hooks', (OrderedDict(( ('id', 'pylint'), ('name', 'PyLint'), ('entry', 'python -m pylint.__main__'), ('language', 'system'), ('files', r'\.py$'), )), OrderedDict(( ('id', 'do_not_commit'), ('name', 'Block if "DO NOT COMMIT" is found'), ('entry', 'DO NOT COMMIT'), ('language', 'pcre'), ('files', '^(.*)$'), )))) )) add_config_to_repo(repo_with_passing_hook, config) with io.open('dummy.py', 'w') as staged_file: staged_file.write('"""TODO: something"""\n') cmd_output('git', 'add', 'dummy.py') _test_run( repo_with_passing_hook, options={}, expected_outputs=[b''], expected_ret=0, stage=False ) def test_local_hook_fails( repo_with_passing_hook, mock_out_store_directory, ): config = OrderedDict(( ('repo', 'local'), ('hooks', [OrderedDict(( ('id', 'no-todo'), ('name', 'No TODO'), ('entry', 'grep -iI todo'), ('expected_return_value', 1), ('language', 'system'), ('files', ''), ))]) )) add_config_to_repo(repo_with_passing_hook, config) with io.open('dummy.py', 'w') as staged_file: staged_file.write('"""TODO: something"""\n') cmd_output('git', 'add', 'dummy.py') _test_run( repo_with_passing_hook, options={}, expected_outputs=[b''], expected_ret=1, stage=False ) def test_allow_unstaged_config_option( repo_with_passing_hook, mock_out_store_directory, ): with cwd(repo_with_passing_hook): with io.open('.pre-commit-config.yaml', 'a+') as config_file: # writing a newline should be relatively harmless to get a change config_file.write('\n') args = _get_opts(allow_unstaged_config=True) ret, printed = _do_run(repo_with_passing_hook, args) assert b'You have an unstaged config file' in printed assert b'have specified the --allow-unstaged-config option.' in printed assert ret == 0 def modify_config(path): with cwd(path): with io.open('.pre-commit-config.yaml', 'a+') as config_file: # writing a newline should be relatively harmless to get a change config_file.write('\n') def test_no_allow_unstaged_config_option( repo_with_passing_hook, mock_out_store_directory, ): modify_config(repo_with_passing_hook) args = _get_opts(allow_unstaged_config=False) ret, printed = _do_run(repo_with_passing_hook, args) assert b'Your .pre-commit-config.yaml is unstaged.' in printed assert ret == 1 def test_no_stash_suppresses_allow_unstaged_config_option( repo_with_passing_hook, mock_out_store_directory, ): modify_config(repo_with_passing_hook) args = _get_opts(allow_unstaged_config=False, no_stash=True) ret, printed = _do_run(repo_with_passing_hook, args) assert b'Your .pre-commit-config.yaml is unstaged.' not in printed def test_all_files_suppresses_allow_unstaged_config_option( repo_with_passing_hook, mock_out_store_directory, ): modify_config(repo_with_passing_hook) args = _get_opts(all_files=True) ret, printed = _do_run(repo_with_passing_hook, args) assert b'Your .pre-commit-config.yaml is unstaged.' not in printed def test_files_suppresses_allow_unstaged_config_option( repo_with_passing_hook, mock_out_store_directory, ): modify_config(repo_with_passing_hook) args = _get_opts(files=['.pre-commit-config.yaml']) ret, printed = _do_run(repo_with_passing_hook, args) assert b'Your .pre-commit-config.yaml is unstaged.' not in printed
mit
[ 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 9143, 199, 646, 5890, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 646, 984, 199, 199, 646, 1683, 199, 646, 4613, 199, 199, 504, 876, 63, 3543, 14, 4405, 14, 3174, 63, 19502, 492, 3907, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 485, 362, 63, 2759, 83, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 485, 1989, 63, 324, 15269, 63, 3771, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 664, 63, 2489, 63, 1725, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 1255, 199, 504, 876, 63, 3543, 14, 8235, 807, 492, 8773, 199, 504, 876, 63, 3543, 14, 1199, 492, 984, 63, 2703, 63, 952, 63, 5029, 199, 504, 876, 63, 3543, 14, 5933, 492, 3378, 1372, 199, 504, 876, 63, 3543, 14, 1974, 492, 2088, 63, 1199, 199, 504, 876, 63, 3543, 14, 1974, 492, 8288, 199, 504, 5343, 14, 2495, 63, 18921, 492, 2599, 63, 18921, 199, 504, 5343, 14, 8769, 492, 1050, 63, 888, 63, 475, 63, 3417, 199, 504, 5343, 14, 8769, 492, 1852, 63, 388, 26745, 63, 3417, 421, 199, 32, 4462, 14, 11481, 63, 5997, 199, 318, 3831, 63, 1045, 63, 29436, 63, 3664, 8, 8616, 63, 3702, 304, 272, 6135, 63, 515, 275, 1852, 63, 388, 26745, 63, 3417, 8, 8616, 63, 3702, 12, 283, 1579, 63, 7922, 63, 3417, 358, 272, 543, 8288, 8, 3187, 63, 515, 304, 267, 1995, 6135, 63, 515, 421, 199, 32, 4462, 14, 11481, 63, 5997, 199, 318, 3831, 63, 1045, 63, 25299, 63, 3664, 8, 8616, 63, 3702, 304, 272, 6135, 63, 515, 275, 1852, 63, 388, 26745, 63, 3417, 8, 8616, 63, 3702, 12, 283, 25299, 63, 3664, 63, 3417, 358, 272, 543, 8288, 8, 3187, 63, 515, 304, 267, 1995, 6135, 63, 515, 421, 199, 318, 9546, 63, 65, 63, 493, 837, 272, 2088, 63, 1199, 360, 12376, 297, 283, 1421, 14, 647, 358, 272, 2088, 63, 1199, 360, 3187, 297, 283, 525, 297, 283, 1421, 14, 647, 358, 421, 199, 318, 664, 63, 952, 63, 1805, 63, 1199, 8, 952, 63, 1805, 304, 272, 372, 330, 17067, 904, 8, 1250, 59, 16, 1527, 16, 61, 367, 1240, 315, 2218, 63, 1805, 14, 952, 14, 1250, 63, 589, 63, 513, 9, 421, 199, 318, 485, 362, 63, 3291, 8, 267, 1006, 63, 1725, 29, 797, 12, 267, 1584, 16729, 267, 3164, 29, 797, 12, 267, 3376, 29, 797, 12, 267, 5759, 29, 403, 12, 267, 949, 63, 27145, 29, 797, 12, 267, 6330, 4581, 267, 1350, 4581, 267, 2040, 63, 324, 270, 6028, 63, 888, 29, 797, 12, 199, 304, 272, 327, 5723, 787, 16108, 13914, 272, 702, 440, 334, 452, 63, 1725, 436, 1584, 9, 272, 372, 2599, 63, 18921, 8, 267, 1006, 63, 1725, 29, 452, 63, 1725, 12, 267, 1584, 29, 1725, 12, 267, 3164, 29, 2326, 12, 267, 3376, 29, 3832, 12, 267, 5759, 29, 3664, 12, 267, 949, 63, 27145, 29, 889, 63, 27145, 12, 267, 6330, 29, 6493, 12, 267, 1350, 29, 1365, 12, 267, 2040, 63, 324, 270, 6028, 63, 888, 29, 3306, 63, 324, 270, 6028, 63, 888, 12, 272, 776, 421, 199, 318, 485, 1117, 63, 1065, 8, 3417, 12, 1249, 12, 6160, 16420, 272, 7876, 275, 3378, 1372, 8, 3417, 9, 272, 2218, 63, 1805, 275, 1683, 14, 3346, 342, 272, 2218, 63, 2324, 275, 9143, 14, 6672, 8, 1274, 63, 2703, 63, 952, 63, 5029, 12, 2547, 29, 952, 63, 1805, 9, 272, 2203, 275, 1255, 8, 5933, 12, 1249, 12, 2218, 29, 952, 63, 2324, 12, 6160, 29, 2314, 9, 272, 12487, 275, 664, 63, 952, 63, 1805, 63, 1199, 8, 952, 63, 1805, 9, 272, 372, 2203, 12, 12487, 421, 199, 318, 485, 396, 63, 1065, 8, 3417, 12, 1511, 12, 1420, 63, 4467, 12, 1420, 63, 3292, 12, 9546, 304, 272, 340, 9546, 26, 267, 9546, 63, 65, 63, 493, 342, 272, 1249, 275, 485, 362, 63, 3291, 3682, 1419, 9, 272, 2203, 12, 12487, 275, 485, 1117, 63, 1065, 8, 3417, 12, 1249, 9, 272, 702, 2203, 508, 1420, 63, 3292, 12, 334, 3292, 12, 1420, 63, 3292, 12, 12487, 9, 272, 367, 1420, 63, 1199, 63, 2064, 315, 1420, 63, 4467, 26, 267, 702, 1420, 63, 1199, 63, 2064, 315, 12487, 421, 199, 318, 511, 63, 1065, 63, 452, 63, 7922, 63, 25299, 8, 267, 3831, 63, 1045, 63, 25299, 63, 3664, 12, 1683, 63, 548, 63, 1617, 63, 3619, 199, 304, 272, 485, 396, 63, 1065, 8, 267, 3831, 63, 1045, 63, 25299, 63, 3664, 12, 267, 5479, 267, 334, 288, 330, 7, 4874, 316, 5759, 297, 288, 330, 7, 4276, 297, 288, 330, 7, 3664, 344, 26, 18648, 63, 3664, 297, 288, 330, 7, 4874, 60, 78, 1421, 14, 647, 60, 78, 297, 267, 2318, 267, 413, 12, 267, 715, 12, 272, 776, 421, 199, 318, 511, 63, 285, 8734, 63, 2394, 63, 3664, 8, 8616, 63, 3702, 12, 1683, 63, 548, 63, 1617, 63, 3619, 304, 272, 6135, 63, 515, 275, 1852, 63, 388, 26745, 63, 3417, 8, 8616, 63, 3702, 12, 283, 285, 8734, 63, 2394, 63, 3417, 358, 272, 543, 8288, 8, 3187, 63, 515, 304, 267, 485, 396, 63, 1065, 8, 3187, 63, 515, 12, 5479, 334, 66, 1154, 1845, 18, 60, 88, 2905, 60, 88, 2658, 60, 1774, 18, 60, 78, 5529, 413, 12, 715, 9, 421, 199, 32, 4462, 14, 1657, 14, 10396, 8, 272, 661, 1419, 297, 283, 4467, 297, 283, 2062, 63, 3292, 297, 283, 8614, 659, 272, 334, 267, 11459, 1386, 334, 66, 7, 34, 1119, 5759, 297, 330, 7, 48, 2744, 659, 378, 12, 715, 395, 267, 26227, 3832, 356, 715, 1386, 334, 66, 7, 1421, 14, 647, 60, 78, 6257, 13064, 5529, 378, 12, 715, 395, 267, 26227, 3664, 356, 283, 16408, 63, 3664, 2267, 334, 66, 7, 34, 1119, 5759, 297, 330, 7, 48, 2744, 659, 378, 12, 715, 395, 267, 26227, 3664, 356, 283, 889, 321, 2267, 334, 66, 7, 1944, 5759 ]
[ 1882, 2803, 26, 9094, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 9143, 199, 646, 5890, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 646, 984, 199, 199, 646, 1683, 199, 646, 4613, 199, 199, 504, 876, 63, 3543, 14, 4405, 14, 3174, 63, 19502, 492, 3907, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 485, 362, 63, 2759, 83, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 485, 1989, 63, 324, 15269, 63, 3771, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 664, 63, 2489, 63, 1725, 199, 504, 876, 63, 3543, 14, 4405, 14, 1065, 492, 1255, 199, 504, 876, 63, 3543, 14, 8235, 807, 492, 8773, 199, 504, 876, 63, 3543, 14, 1199, 492, 984, 63, 2703, 63, 952, 63, 5029, 199, 504, 876, 63, 3543, 14, 5933, 492, 3378, 1372, 199, 504, 876, 63, 3543, 14, 1974, 492, 2088, 63, 1199, 199, 504, 876, 63, 3543, 14, 1974, 492, 8288, 199, 504, 5343, 14, 2495, 63, 18921, 492, 2599, 63, 18921, 199, 504, 5343, 14, 8769, 492, 1050, 63, 888, 63, 475, 63, 3417, 199, 504, 5343, 14, 8769, 492, 1852, 63, 388, 26745, 63, 3417, 421, 199, 32, 4462, 14, 11481, 63, 5997, 199, 318, 3831, 63, 1045, 63, 29436, 63, 3664, 8, 8616, 63, 3702, 304, 272, 6135, 63, 515, 275, 1852, 63, 388, 26745, 63, 3417, 8, 8616, 63, 3702, 12, 283, 1579, 63, 7922, 63, 3417, 358, 272, 543, 8288, 8, 3187, 63, 515, 304, 267, 1995, 6135, 63, 515, 421, 199, 32, 4462, 14, 11481, 63, 5997, 199, 318, 3831, 63, 1045, 63, 25299, 63, 3664, 8, 8616, 63, 3702, 304, 272, 6135, 63, 515, 275, 1852, 63, 388, 26745, 63, 3417, 8, 8616, 63, 3702, 12, 283, 25299, 63, 3664, 63, 3417, 358, 272, 543, 8288, 8, 3187, 63, 515, 304, 267, 1995, 6135, 63, 515, 421, 199, 318, 9546, 63, 65, 63, 493, 837, 272, 2088, 63, 1199, 360, 12376, 297, 283, 1421, 14, 647, 358, 272, 2088, 63, 1199, 360, 3187, 297, 283, 525, 297, 283, 1421, 14, 647, 358, 421, 199, 318, 664, 63, 952, 63, 1805, 63, 1199, 8, 952, 63, 1805, 304, 272, 372, 330, 17067, 904, 8, 1250, 59, 16, 1527, 16, 61, 367, 1240, 315, 2218, 63, 1805, 14, 952, 14, 1250, 63, 589, 63, 513, 9, 421, 199, 318, 485, 362, 63, 3291, 8, 267, 1006, 63, 1725, 29, 797, 12, 267, 1584, 16729, 267, 3164, 29, 797, 12, 267, 3376, 29, 797, 12, 267, 5759, 29, 403, 12, 267, 949, 63, 27145, 29, 797, 12, 267, 6330, 4581, 267, 1350, 4581, 267, 2040, 63, 324, 270, 6028, 63, 888, 29, 797, 12, 199, 304, 272, 327, 5723, 787, 16108, 13914, 272, 702, 440, 334, 452, 63, 1725, 436, 1584, 9, 272, 372, 2599, 63, 18921, 8, 267, 1006, 63, 1725, 29, 452, 63, 1725, 12, 267, 1584, 29, 1725, 12, 267, 3164, 29, 2326, 12, 267, 3376, 29, 3832, 12, 267, 5759, 29, 3664, 12, 267, 949, 63, 27145, 29, 889, 63, 27145, 12, 267, 6330, 29, 6493, 12, 267, 1350, 29, 1365, 12, 267, 2040, 63, 324, 270, 6028, 63, 888, 29, 3306, 63, 324, 270, 6028, 63, 888, 12, 272, 776, 421, 199, 318, 485, 1117, 63, 1065, 8, 3417, 12, 1249, 12, 6160, 16420, 272, 7876, 275, 3378, 1372, 8, 3417, 9, 272, 2218, 63, 1805, 275, 1683, 14, 3346, 342, 272, 2218, 63, 2324, 275, 9143, 14, 6672, 8, 1274, 63, 2703, 63, 952, 63, 5029, 12, 2547, 29, 952, 63, 1805, 9, 272, 2203, 275, 1255, 8, 5933, 12, 1249, 12, 2218, 29, 952, 63, 2324, 12, 6160, 29, 2314, 9, 272, 12487, 275, 664, 63, 952, 63, 1805, 63, 1199, 8, 952, 63, 1805, 9, 272, 372, 2203, 12, 12487, 421, 199, 318, 485, 396, 63, 1065, 8, 3417, 12, 1511, 12, 1420, 63, 4467, 12, 1420, 63, 3292, 12, 9546, 304, 272, 340, 9546, 26, 267, 9546, 63, 65, 63, 493, 342, 272, 1249, 275, 485, 362, 63, 3291, 3682, 1419, 9, 272, 2203, 12, 12487, 275, 485, 1117, 63, 1065, 8, 3417, 12, 1249, 9, 272, 702, 2203, 508, 1420, 63, 3292, 12, 334, 3292, 12, 1420, 63, 3292, 12, 12487, 9, 272, 367, 1420, 63, 1199, 63, 2064, 315, 1420, 63, 4467, 26, 267, 702, 1420, 63, 1199, 63, 2064, 315, 12487, 421, 199, 318, 511, 63, 1065, 63, 452, 63, 7922, 63, 25299, 8, 267, 3831, 63, 1045, 63, 25299, 63, 3664, 12, 1683, 63, 548, 63, 1617, 63, 3619, 199, 304, 272, 485, 396, 63, 1065, 8, 267, 3831, 63, 1045, 63, 25299, 63, 3664, 12, 267, 5479, 267, 334, 288, 330, 7, 4874, 316, 5759, 297, 288, 330, 7, 4276, 297, 288, 330, 7, 3664, 344, 26, 18648, 63, 3664, 297, 288, 330, 7, 4874, 60, 78, 1421, 14, 647, 60, 78, 297, 267, 2318, 267, 413, 12, 267, 715, 12, 272, 776, 421, 199, 318, 511, 63, 285, 8734, 63, 2394, 63, 3664, 8, 8616, 63, 3702, 12, 1683, 63, 548, 63, 1617, 63, 3619, 304, 272, 6135, 63, 515, 275, 1852, 63, 388, 26745, 63, 3417, 8, 8616, 63, 3702, 12, 283, 285, 8734, 63, 2394, 63, 3417, 358, 272, 543, 8288, 8, 3187, 63, 515, 304, 267, 485, 396, 63, 1065, 8, 3187, 63, 515, 12, 5479, 334, 66, 1154, 1845, 18, 60, 88, 2905, 60, 88, 2658, 60, 1774, 18, 60, 78, 5529, 413, 12, 715, 9, 421, 199, 32, 4462, 14, 1657, 14, 10396, 8, 272, 661, 1419, 297, 283, 4467, 297, 283, 2062, 63, 3292, 297, 283, 8614, 659, 272, 334, 267, 11459, 1386, 334, 66, 7, 34, 1119, 5759, 297, 330, 7, 48, 2744, 659, 378, 12, 715, 395, 267, 26227, 3832, 356, 715, 1386, 334, 66, 7, 1421, 14, 647, 60, 78, 6257, 13064, 5529, 378, 12, 715, 395, 267, 26227, 3664, 356, 283, 16408, 63, 3664, 2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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
debugger22/sympy
sympy/concrete/summations.py
7
24851
from __future__ import print_function, division from sympy.concrete.expr_with_limits import AddWithLimits from sympy.concrete.expr_with_intlimits import ExprWithIntLimits from sympy.core.function import Derivative from sympy.core.relational import Eq from sympy.core.singleton import S from sympy.core.symbol import Dummy, Wild from sympy.core.add import Add from sympy.concrete.gosper import gosper_sum from sympy.functions.elementary.piecewise import Piecewise from sympy.polys import apart, PolynomialError from sympy.solvers import solve from sympy.core.compatibility import range from sympy.tensor.indexed import Idx class Sum(AddWithLimits, ExprWithIntLimits): r"""Represents unevaluated summation. ``Sum`` represents a finite or infinite series, with the first argument being the general form of terms in the series, and the second argument being ``(dummy_variable, start, end)``, with ``dummy_variable`` taking all integer values from ``start`` through ``end``. In accordance with long-standing mathematical convention, the end term is included in the summation. Finite sums =========== For finite sums (and sums with symbolic limits assumed to be finite) we follow the summation convention described by Karr [1], especially definition 3 of section 1.4. The sum: .. math:: \sum_{m \leq i < n} f(i) has *the obvious meaning* for `m < n`, namely: .. math:: \sum_{m \leq i < n} f(i) = f(m) + f(m+1) + \ldots + f(n-2) + f(n-1) with the upper limit value `f(n)` excluded. The sum over an empty set is zero if and only if `m = n`: .. math:: \sum_{m \leq i < n} f(i) = 0 \quad \mathrm{for} \quad m = n Finally, for all other sums over empty sets we assume the following definition: .. math:: \sum_{m \leq i < n} f(i) = - \sum_{n \leq i < m} f(i) \quad \mathrm{for} \quad m > n It is important to note that Karr defines all sums with the upper limit being exclusive. This is in contrast to the usual mathematical notation, but does not affect the summation convention. Indeed we have: .. math:: \sum_{m \leq i < n} f(i) = \sum_{i = m}^{n - 1} f(i) where the difference in notation is intentional to emphasize the meaning, with limits typeset on the top being inclusive. Examples ======== >>> from sympy.abc import i, k, m, n, x >>> from sympy import Sum, factorial, oo, IndexedBase, Function >>> Sum(k, (k, 1, m)) Sum(k, (k, 1, m)) >>> Sum(k, (k, 1, m)).doit() m**2/2 + m/2 >>> Sum(k**2, (k, 1, m)) Sum(k**2, (k, 1, m)) >>> Sum(k**2, (k, 1, m)).doit() m**3/3 + m**2/2 + m/6 >>> Sum(x**k, (k, 0, oo)) Sum(x**k, (k, 0, oo)) >>> Sum(x**k, (k, 0, oo)).doit() Piecewise((1/(-x + 1), Abs(x) < 1), (Sum(x**k, (k, 0, oo)), True)) >>> Sum(x**k/factorial(k), (k, 0, oo)).doit() exp(x) Here are examples to do summation with symbolic indices. You can use either Function of IndexedBase classes: >>> f = Function('f') >>> Sum(f(n), (n, 0, 3)).doit() f(0) + f(1) + f(2) + f(3) >>> Sum(f(n), (n, 0, oo)).doit() Sum(f(n), (n, 0, oo)) >>> f = IndexedBase('f') >>> Sum(f[n]**2, (n, 0, 3)).doit() f[0]**2 + f[1]**2 + f[2]**2 + f[3]**2 An example showing that the symbolic result of a summation is still valid for seemingly nonsensical values of the limits. Then the Karr convention allows us to give a perfectly valid interpretation to those sums by interchanging the limits according to the above rules: >>> S = Sum(i, (i, 1, n)).doit() >>> S n**2/2 + n/2 >>> S.subs(n, -4) 6 >>> Sum(i, (i, 1, -4)).doit() 6 >>> Sum(-i, (i, -3, 0)).doit() 6 An explicit example of the Karr summation convention: >>> S1 = Sum(i**2, (i, m, m+n-1)).doit() >>> S1 m**2*n + m*n**2 - m*n + n**3/3 - n**2/2 + n/6 >>> S2 = Sum(i**2, (i, m+n, m-1)).doit() >>> S2 -m**2*n - m*n**2 + m*n - n**3/3 + n**2/2 - n/6 >>> S1 + S2 0 >>> S3 = Sum(i, (i, m, m-1)).doit() >>> S3 0 See Also ======== summation Product, product References ========== .. [1] Michael Karr, "Summation in Finite Terms", Journal of the ACM, Volume 28 Issue 2, April 1981, Pages 305-350 http://dl.acm.org/citation.cfm?doid=322248.322255 .. [2] http://en.wikipedia.org/wiki/Summation#Capital-sigma_notation .. [3] http://en.wikipedia.org/wiki/Empty_sum """ __slots__ = ['is_commutative'] def __new__(cls, function, *symbols, **assumptions): obj = AddWithLimits.__new__(cls, function, *symbols, **assumptions) if not hasattr(obj, 'limits'): return obj if any(len(l) != 3 or None in l for l in obj.limits): raise ValueError('Sum requires values for lower and upper bounds.') return obj def _eval_is_zero(self): # a Sum is only zero if its function is zero or if all terms # cancel out. This only answers whether the summand is zero; if # not then None is returned since we don't analyze whether all # terms cancel out. if self.function.is_zero: return True def doit(self, **hints): if hints.get('deep', True): f = self.function.doit(**hints) else: f = self.function if self.function.is_Matrix: return self.expand().doit() for n, limit in enumerate(self.limits): i, a, b = limit dif = b - a if dif.is_integer and (dif < 0) == True: a, b = b + 1, a - 1 f = -f if isinstance(i, Idx): i = i.label newf = eval_sum(f, (i, a, b)) if newf is None: if f == self.function: return self else: return self.func(f, *self.limits[n:]) f = newf if hints.get('deep', True): # eval_sum could return partially unevaluated # result with Piecewise. In this case we won't # doit() recursively. if not isinstance(f, Piecewise): return f.doit(**hints) return f def _eval_derivative(self, x): """ Differentiate wrt x as long as x is not in the free symbols of any of the upper or lower limits. Sum(a*b*x, (x, 1, a)) can be differentiated wrt x or b but not `a` since the value of the sum is discontinuous in `a`. In a case involving a limit variable, the unevaluated derivative is returned. """ # diff already confirmed that x is in the free symbols of self, but we # don't want to differentiate wrt any free symbol in the upper or lower # limits # XXX remove this test for free_symbols when the default _eval_derivative is in if x not in self.free_symbols: return S.Zero # get limits and the function f, limits = self.function, list(self.limits) limit = limits.pop(-1) if limits: # f is the argument to a Sum f = self.func(f, *limits) if len(limit) == 3: _, a, b = limit if x in a.free_symbols or x in b.free_symbols: return None df = Derivative(f, x, evaluate=True) rv = self.func(df, limit) if limit[0] not in df.free_symbols: rv = rv.doit() return rv else: return NotImplementedError('Lower and upper bound expected.') def _eval_difference_delta(self, n, step): k, _, upper = self.args[-1] new_upper = upper.subs(n, n + step) if len(self.args) == 2: f = self.args[0] else: f = self.func(*self.args[:-1]) if upper + 1 == new_upper: return Sum(f, (k, upper + 1, new_upper)).doit() else: return Sum(f, (k, upper + 1, new_upper)) def _eval_simplify(self, ratio, measure): from sympy.simplify.simplify import sum_simplify return sum_simplify(self) def _eval_summation(self, f, x): return None def euler_maclaurin(self, m=0, n=0, eps=0, eval_integral=True): """ Return an Euler-Maclaurin approximation of self, where m is the number of leading terms to sum directly and n is the number of terms in the tail. With m = n = 0, this is simply the corresponding integral plus a first-order endpoint correction. Returns (s, e) where s is the Euler-Maclaurin approximation and e is the estimated error (taken to be the magnitude of the first omitted term in the tail): >>> from sympy.abc import k, a, b >>> from sympy import Sum >>> Sum(1/k, (k, 2, 5)).doit().evalf() 1.28333333333333 >>> s, e = Sum(1/k, (k, 2, 5)).euler_maclaurin() >>> s -log(2) + 7/20 + log(5) >>> from sympy import sstr >>> print(sstr((s.evalf(), e.evalf()), full_prec=True)) (1.26629073187415, 0.0175000000000000) The endpoints may be symbolic: >>> s, e = Sum(1/k, (k, a, b)).euler_maclaurin() >>> s -log(a) + log(b) + 1/(2*b) + 1/(2*a) >>> e Abs(1/(12*b**2) - 1/(12*a**2)) If the function is a polynomial of degree at most 2n+1, the Euler-Maclaurin formula becomes exact (and e = 0 is returned): >>> Sum(k, (k, 2, b)).euler_maclaurin() (b**2/2 + b/2 - 1, 0) >>> Sum(k, (k, 2, b)).doit() b**2/2 + b/2 - 1 With a nonzero eps specified, the summation is ended as soon as the remainder term is less than the epsilon. """ from sympy.functions import bernoulli, factorial from sympy.integrals import Integral m = int(m) n = int(n) f = self.function if len(self.limits) != 1: raise ValueError("More than 1 limit") i, a, b = self.limits[0] if (a > b) == True: if a - b == 1: return S.Zero,S.Zero a, b = b + 1, a - 1 f = -f s = S.Zero if m: if b.is_Integer and a.is_Integer: m = min(m, b - a + 1) if not eps or f.is_polynomial(i): for k in range(m): s += f.subs(i, a + k) else: term = f.subs(i, a) if term: test = abs(term.evalf(3)) < eps if test == True: return s, abs(term) elif not (test == False): # a symbolic Relational class, can't go further return term, S.Zero s += term for k in range(1, m): term = f.subs(i, a + k) if abs(term.evalf(3)) < eps and term != 0: return s, abs(term) s += term if b - a + 1 == m: return s, S.Zero a += m x = Dummy('x') I = Integral(f.subs(i, x), (x, a, b)) if eval_integral: I = I.doit() s += I def fpoint(expr): if b is S.Infinity: return expr.subs(i, a), 0 return expr.subs(i, a), expr.subs(i, b) fa, fb = fpoint(f) iterm = (fa + fb)/2 g = f.diff(i) for k in range(1, n + 2): ga, gb = fpoint(g) term = bernoulli(2*k)/factorial(2*k)*(gb - ga) if (eps and term and abs(term.evalf(3)) < eps) or (k > n): break s += term g = g.diff(i, 2, simplify=False) return s + iterm, abs(term) def reverse_order(self, *indices): """ Reverse the order of a limit in a Sum. Usage ===== ``reverse_order(self, *indices)`` reverses some limits in the expression ``self`` which can be either a ``Sum`` or a ``Product``. The selectors in the argument ``indices`` specify some indices whose limits get reversed. These selectors are either variable names or numerical indices counted starting from the inner-most limit tuple. Examples ======== >>> from sympy import Sum >>> from sympy.abc import x, y, a, b, c, d >>> Sum(x, (x, 0, 3)).reverse_order(x) Sum(-x, (x, 4, -1)) >>> Sum(x*y, (x, 1, 5), (y, 0, 6)).reverse_order(x, y) Sum(x*y, (x, 6, 0), (y, 7, -1)) >>> Sum(x, (x, a, b)).reverse_order(x) Sum(-x, (x, b + 1, a - 1)) >>> Sum(x, (x, a, b)).reverse_order(0) Sum(-x, (x, b + 1, a - 1)) While one should prefer variable names when specifying which limits to reverse, the index counting notation comes in handy in case there are several symbols with the same name. >>> S = Sum(x**2, (x, a, b), (x, c, d)) >>> S Sum(x**2, (x, a, b), (x, c, d)) >>> S0 = S.reverse_order(0) >>> S0 Sum(-x**2, (x, b + 1, a - 1), (x, c, d)) >>> S1 = S0.reverse_order(1) >>> S1 Sum(x**2, (x, b + 1, a - 1), (x, d + 1, c - 1)) Of course we can mix both notations: >>> Sum(x*y, (x, a, b), (y, 2, 5)).reverse_order(x, 1) Sum(x*y, (x, b + 1, a - 1), (y, 6, 1)) >>> Sum(x*y, (x, a, b), (y, 2, 5)).reverse_order(y, x) Sum(x*y, (x, b + 1, a - 1), (y, 6, 1)) See Also ======== index, reorder_limit, reorder References ========== .. [1] Michael Karr, "Summation in Finite Terms", Journal of the ACM, Volume 28 Issue 2, April 1981, Pages 305-350 http://dl.acm.org/citation.cfm?doid=322248.322255 """ l_indices = list(indices) for i, indx in enumerate(l_indices): if not isinstance(indx, int): l_indices[i] = self.index(indx) e = 1 limits = [] for i, limit in enumerate(self.limits): l = limit if i in l_indices: e = -e l = (limit[0], limit[2] + 1, limit[1] - 1) limits.append(l) return Sum(e * self.function, *limits) def summation(f, *symbols, **kwargs): r""" Compute the summation of f with respect to symbols. The notation for symbols is similar to the notation used in Integral. summation(f, (i, a, b)) computes the sum of f with respect to i from a to b, i.e., :: b ____ \ ` summation(f, (i, a, b)) = ) f /___, i = a If it cannot compute the sum, it returns an unevaluated Sum object. Repeated sums can be computed by introducing additional symbols tuples:: >>> from sympy import summation, oo, symbols, log >>> i, n, m = symbols('i n m', integer=True) >>> summation(2*i - 1, (i, 1, n)) n**2 >>> summation(1/2**i, (i, 0, oo)) 2 >>> summation(1/log(n)**n, (n, 2, oo)) Sum(log(n)**(-n), (n, 2, oo)) >>> summation(i, (i, 0, n), (n, 0, m)) m**3/6 + m**2/2 + m/3 >>> from sympy.abc import x >>> from sympy import factorial >>> summation(x**n/factorial(n), (n, 0, oo)) exp(x) See Also ======== Sum Product, product """ return Sum(f, *symbols, **kwargs).doit(deep=False) def telescopic_direct(L, R, n, limits): """Returns the direct summation of the terms of a telescopic sum L is the term with lower index R is the term with higher index n difference between the indexes of L and R For example: >>> from sympy.concrete.summations import telescopic_direct >>> from sympy.abc import k, a, b >>> telescopic_direct(1/k, -1/(k+2), 2, (k, a, b)) -1/(b + 2) - 1/(b + 1) + 1/(a + 1) + 1/a """ (i, a, b) = limits s = 0 for m in range(n): s += L.subs(i, a + m) + R.subs(i, b - m) return s def telescopic(L, R, limits): '''Tries to perform the summation using the telescopic property return None if not possible ''' (i, a, b) = limits if L.is_Add or R.is_Add: return None # We want to solve(L.subs(i, i + m) + R, m) # First we try a simple match since this does things that # solve doesn't do, e.g. solve(f(k+m)-f(k), m) fails k = Wild("k") sol = (-R).match(L.subs(i, i + k)) s = None if sol and k in sol: s = sol[k] if not (s.is_Integer and L.subs(i, i + s) == -R): # sometimes match fail(f(x+2).match(-f(x+k))->{k: -2 - 2x})) s = None # But there are things that match doesn't do that solve # can do, e.g. determine that 1/(x + m) = 1/(1 - x) when m = 1 if s is None: m = Dummy('m') try: sol = solve(L.subs(i, i + m) + R, m) or [] except NotImplementedError: return None sol = [si for si in sol if si.is_Integer and (L.subs(i, i + si) + R).expand().is_zero] if len(sol) != 1: return None s = sol[0] if s < 0: return telescopic_direct(R, L, abs(s), (i, a, b)) elif s > 0: return telescopic_direct(L, R, s, (i, a, b)) def eval_sum(f, limits): from sympy.concrete.delta import deltasummation, _has_simple_delta from sympy.functions import KroneckerDelta (i, a, b) = limits if f is S.Zero: return S.Zero if i not in f.free_symbols: return f*(b - a + 1) if a == b: return f.subs(i, a) if isinstance(f, Piecewise): if not any(i in arg.args[1].free_symbols for arg in f.args): # Piecewise conditions do not depend on the dummy summation variable, # therefore we can fold: Sum(Piecewise((e, c), ...), limits) # --> Piecewise((Sum(e, limits), c), ...) newargs = [] for arg in f.args: newexpr = eval_sum(arg.expr, limits) if newexpr is None: return None newargs.append((newexpr, arg.cond)) return f.func(*newargs) if f.has(KroneckerDelta) and _has_simple_delta(f, limits[0]): return deltasummation(f, limits) dif = b - a definite = dif.is_Integer # Doing it directly may be faster if there are very few terms. if definite and (dif < 100): return eval_sum_direct(f, (i, a, b)) if isinstance(f, Piecewise): return None # Try to do it symbolically. Even when the number of terms is known, # this can save time when b-a is big. # We should try to transform to partial fractions value = eval_sum_symbolic(f.expand(), (i, a, b)) if value is not None: return value # Do it directly if definite: return eval_sum_direct(f, (i, a, b)) def eval_sum_direct(expr, limits): from sympy.core import Add (i, a, b) = limits dif = b - a return Add(*[expr.subs(i, a + j) for j in range(dif + 1)]) def eval_sum_symbolic(f, limits): from sympy.functions import harmonic, bernoulli f_orig = f (i, a, b) = limits if not f.has(i): return f*(b - a + 1) # Linearity if f.is_Mul: L, R = f.as_two_terms() if not L.has(i): sR = eval_sum_symbolic(R, (i, a, b)) if sR: return L*sR if not R.has(i): sL = eval_sum_symbolic(L, (i, a, b)) if sL: return R*sL try: f = apart(f, i) # see if it becomes an Add except PolynomialError: pass if f.is_Add: L, R = f.as_two_terms() lrsum = telescopic(L, R, (i, a, b)) if lrsum: return lrsum lsum = eval_sum_symbolic(L, (i, a, b)) rsum = eval_sum_symbolic(R, (i, a, b)) if None not in (lsum, rsum): r = lsum + rsum if not r is S.NaN: return r # Polynomial terms with Faulhaber's formula n = Wild('n') result = f.match(i**n) if result is not None: n = result[n] if n.is_Integer: if n >= 0: if (b is S.Infinity and not a is S.NegativeInfinity) or \ (a is S.NegativeInfinity and not b is S.Infinity): return S.Infinity return ((bernoulli(n + 1, b + 1) - bernoulli(n + 1, a))/(n + 1)).expand() elif a.is_Integer and a >= 1: if n == -1: return harmonic(b) - harmonic(a - 1) else: return harmonic(b, abs(n)) - harmonic(a - 1, abs(n)) if not (a.has(S.Infinity, S.NegativeInfinity) or b.has(S.Infinity, S.NegativeInfinity)): # Geometric terms c1 = Wild('c1', exclude=[i]) c2 = Wild('c2', exclude=[i]) c3 = Wild('c3', exclude=[i]) e = f.match(c1**(c2*i + c3)) if e is not None: p = (c1**c3).subs(e) q = (c1**c2).subs(e) r = p*(q**a - q**(b + 1))/(1 - q) l = p*(b - a + 1) return Piecewise((l, Eq(q, S.One)), (r, True)) r = gosper_sum(f, (i, a, b)) if not r in (None, S.NaN): return r return eval_sum_hyper(f_orig, (i, a, b)) def _eval_sum_hyper(f, i, a): """ Returns (res, cond). Sums from a to oo. """ from sympy.functions import hyper from sympy.simplify import hyperexpand, hypersimp, fraction, simplify from sympy.polys.polytools import Poly, factor if a != 0: return _eval_sum_hyper(f.subs(i, i + a), i, 0) if f.subs(i, 0) == 0: if simplify(f.subs(i, Dummy('i', integer=True, positive=True))) == 0: return S(0), True return _eval_sum_hyper(f.subs(i, i + 1), i, 0) hs = hypersimp(f, i) if hs is None: return None numer, denom = fraction(factor(hs)) top, topl = numer.as_coeff_mul(i) bot, botl = denom.as_coeff_mul(i) ab = [top, bot] factors = [topl, botl] params = [[], []] for k in range(2): for fac in factors[k]: mul = 1 if fac.is_Pow: mul = fac.exp fac = fac.base if not mul.is_Integer: return None p = Poly(fac, i) if p.degree() != 1: return None m, n = p.all_coeffs() ab[k] *= m**mul params[k] += [n/m]*mul # Add "1" to numerator parameters, to account for implicit n! in # hypergeometric series. ap = params[0] + [1] bq = params[1] x = ab[0]/ab[1] h = hyper(ap, bq, x) return f.subs(i, 0)*hyperexpand(h), h.convergence_statement def eval_sum_hyper(f, i_a_b): from sympy.logic.boolalg import And i, a, b = i_a_b if (b - a).is_Integer: # We are never going to do better than doing the sum in the obvious way return None old_sum = Sum(f, (i, a, b)) if b != S.Infinity: if a == S.NegativeInfinity: res = _eval_sum_hyper(f.subs(i, -i), i, -b) if res is not None: return Piecewise(res, (old_sum, True)) else: res1 = _eval_sum_hyper(f, i, a) res2 = _eval_sum_hyper(f, i, b + 1) if res1 is None or res2 is None: return None (res1, cond1), (res2, cond2) = res1, res2 cond = And(cond1, cond2) if cond == False: return None return Piecewise((res1 - res2, cond), (old_sum, True)) if a == S.NegativeInfinity: res1 = _eval_sum_hyper(f.subs(i, -i), i, 1) res2 = _eval_sum_hyper(f, i, 0) if res1 is None or res2 is None: return None res1, cond1 = res1 res2, cond2 = res2 cond = And(cond1, cond2) if cond == False: return None return Piecewise((res1 + res2, cond), (old_sum, True)) # Now b == oo, a != -oo res = _eval_sum_hyper(f, i, a) if res is not None: r, c = res if c == False: if r.is_number: f = f.subs(i, Dummy('i', integer=True, positive=True) + a) if f.is_positive or f.is_zero: return S.Infinity elif f.is_negative: return S.NegativeInfinity return None return Piecewise(res, (old_sum, True))
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 13455, 14, 3684, 63, 1045, 63, 9368, 492, 2654, 3007, 24480, 199, 504, 5840, 14, 13455, 14, 3684, 63, 1045, 63, 442, 9368, 492, 14754, 3007, 3241, 24480, 199, 504, 5840, 14, 1018, 14, 1593, 492, 18674, 27418, 199, 504, 5840, 14, 1018, 14, 5690, 279, 492, 21779, 199, 504, 5840, 14, 1018, 14, 24675, 492, 428, 199, 504, 5840, 14, 1018, 14, 5155, 492, 9762, 12, 644, 668, 199, 504, 5840, 14, 1018, 14, 525, 492, 2654, 199, 504, 5840, 14, 13455, 14, 71, 736, 529, 492, 486, 736, 529, 63, 1838, 199, 504, 5840, 14, 5777, 14, 2108, 695, 14, 20082, 2605, 492, 31362, 199, 504, 5840, 14, 15743, 492, 29430, 12, 8467, 8887, 547, 199, 504, 5840, 14, 11263, 83, 492, 14241, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 504, 5840, 14, 3128, 14, 16821, 492, 473, 8373, 421, 199, 533, 12094, 8, 1123, 3007, 24480, 12, 14754, 3007, 3241, 24480, 304, 272, 519, 624, 18089, 625, 2579, 23130, 3089, 1615, 14, 339, 1124, 6959, 1040, 8469, 282, 21837, 503, 15258, 6779, 12, 543, 314, 1642, 1423, 272, 3769, 314, 8605, 1824, 402, 2895, 315, 314, 6779, 12, 436, 314, 3499, 1423, 272, 3769, 15475, 5869, 63, 1975, 12, 1343, 12, 1284, 28616, 543, 1124, 5869, 63, 1975, 1040, 16466, 272, 1006, 3000, 1338, 687, 1124, 928, 1040, 4012, 1124, 500, 4345, 1010, 1066, 1577, 554, 543, 272, 1846, 13, 18126, 610, 28491, 16129, 12, 314, 1284, 6707, 365, 5120, 315, 314, 272, 3089, 1615, 14, 339, 11711, 1175, 27690, 272, 275, 17575, 339, 2104, 21837, 27690, 334, 460, 27690, 543, 13673, 10976, 10826, 370, 506, 21837, 9, 781, 272, 2035, 314, 3089, 1615, 16129, 11736, 701, 1804, 5250, 359, 17, 467, 24002, 272, 5492, 650, 402, 3420, 413, 14, 20, 14, 710, 3089, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 339, 965, 627, 1589, 25259, 11150, 10, 367, 658, 77, 665, 302, 3559, 536, 590, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 289, 8, 77, 9, 435, 289, 8, 77, 11, 17, 9, 435, 971, 1447, 16673, 435, 289, 8, 78, 13, 18, 9, 435, 289, 8, 78, 13, 17, 9, 339, 543, 314, 7008, 2304, 574, 658, 70, 8, 78, 12544, 8789, 14, 710, 3089, 1806, 376, 2701, 663, 365, 272, 4697, 340, 436, 1454, 340, 658, 77, 275, 302, 8340, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 378, 221, 971, 14567, 971, 3442, 5682, 91, 509, 93, 971, 14567, 221, 333, 275, 302, 339, 19177, 12, 367, 1006, 1163, 27690, 1806, 2701, 5951, 781, 5534, 314, 2569, 272, 5492, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 446, 971, 1838, 7348, 78, 971, 274, 81, 284, 665, 333, 93, 289, 8, 73, 9, 221, 971, 14567, 971, 3442, 5682, 91, 509, 93, 971, 14567, 221, 333, 690, 302, 339, 2779, 365, 11012, 370, 5317, 626, 1804, 5250, 7890, 1006, 27690, 543, 314, 7008, 272, 2304, 3769, 13914, 14, 961, 365, 315, 30347, 370, 314, 20195, 610, 28491, 15843, 12, 272, 1325, 1630, 440, 12787, 314, 3089, 1615, 16129, 14, 1010, 271, 379, 781, 1172, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 971, 1838, 7348, 73, 275, 333, 93, 11683, 78, 446, 413, 93, 289, 8, 73, 9, 339, 2382, 314, 8865, 315, 15843, 365, 25343, 279, 370, 9052, 1989, 794, 314, 11150, 12, 272, 543, 10976, 730, 409, 641, 314, 2746, 3769, 20728, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 14, 3175, 492, 284, 12, 1022, 12, 333, 12, 302, 12, 671, 272, 1306, 687, 5840, 492, 12094, 12, 32618, 12, 16390, 12, 26437, 1563, 12, 6801, 272, 1306, 12094, 8, 75, 12, 334, 75, 12, 413, 12, 333, 430, 272, 12094, 8, 75, 12, 334, 75, 12, 413, 12, 333, 430, 272, 1306, 12094, 8, 75, 12, 334, 75, 12, 413, 12, 333, 4992, 19014, 342, 272, 333, 538, 18, 15, 18, 435, 333, 15, 18, 272, 1306, 12094, 8, 75, 538, 18, 12, 334, 75, 12, 413, 12, 333, 430, 272, 12094, 8, 75, 538, 18, 12, 334, 75, 12, 413, 12, 333, 430, 272, 1306, 12094, 8, 75, 538, 18, 12, 334, 75, 12, 413, 12, 333, 4992, 19014, 342, 272, 333, 538, 19, 15, 19, 435, 333, 538, 18, 15, 18, 435, 333, 15, 22, 272, 1306, 12094, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 430, 272, 12094, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 430, 272, 1306, 12094, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 4992, 19014, 342, 272, 31362, 1332, 17, 15, 2801, 88, 435, 413, 395, 20319, 8, 88, 9, 665, 413, 395, 334, 6959, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 1826, 715, 430, 272, 1306, 12094, 8, 88, 538, 75, 15, 28165, 8, 75, 395, 334, 75, 12, 378, 12, 16390, 4992, 19014, 342, 272, 1437, 8, 88, 9, 339, 11842, 787, 7251, 370, 886, 3089, 1615, 543, 13673, 4918, 14, 221, 2047, 272, 883, 675, 1902, 6801, 402, 26437, 1563, 3992, 26, 339, 1306, 289, 275, 6801, 360, 70, 358, 272, 1306, 12094, 8, 70, 8, 78, 395, 334, 78, 12, 378, 12, 650, 4992, 19014, 342, 272, 289, 8, 16, 9, 435, 289, 8, 17, 9, 435, 289, 8, 18, 9, 435, 289, 8, 19, 9, 272, 1306, 12094, 8, 70, 8, 78, 395, 334, 78, 12, 378, 12, 16390, 4992, 19014, 342, 272, 12094, 8, 70, 8, 78, 395, 334, 78, 12, 378, 12, 16390, 430, 272, 1306, 289, 275, 26437, 1563, 360, 70, 358, 272, 1306, 12094, 8, 70, 59, 78, 24186, 18, 12, 334, 78, 12 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 13455, 14, 3684, 63, 1045, 63, 9368, 492, 2654, 3007, 24480, 199, 504, 5840, 14, 13455, 14, 3684, 63, 1045, 63, 442, 9368, 492, 14754, 3007, 3241, 24480, 199, 504, 5840, 14, 1018, 14, 1593, 492, 18674, 27418, 199, 504, 5840, 14, 1018, 14, 5690, 279, 492, 21779, 199, 504, 5840, 14, 1018, 14, 24675, 492, 428, 199, 504, 5840, 14, 1018, 14, 5155, 492, 9762, 12, 644, 668, 199, 504, 5840, 14, 1018, 14, 525, 492, 2654, 199, 504, 5840, 14, 13455, 14, 71, 736, 529, 492, 486, 736, 529, 63, 1838, 199, 504, 5840, 14, 5777, 14, 2108, 695, 14, 20082, 2605, 492, 31362, 199, 504, 5840, 14, 15743, 492, 29430, 12, 8467, 8887, 547, 199, 504, 5840, 14, 11263, 83, 492, 14241, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 504, 5840, 14, 3128, 14, 16821, 492, 473, 8373, 421, 199, 533, 12094, 8, 1123, 3007, 24480, 12, 14754, 3007, 3241, 24480, 304, 272, 519, 624, 18089, 625, 2579, 23130, 3089, 1615, 14, 339, 1124, 6959, 1040, 8469, 282, 21837, 503, 15258, 6779, 12, 543, 314, 1642, 1423, 272, 3769, 314, 8605, 1824, 402, 2895, 315, 314, 6779, 12, 436, 314, 3499, 1423, 272, 3769, 15475, 5869, 63, 1975, 12, 1343, 12, 1284, 28616, 543, 1124, 5869, 63, 1975, 1040, 16466, 272, 1006, 3000, 1338, 687, 1124, 928, 1040, 4012, 1124, 500, 4345, 1010, 1066, 1577, 554, 543, 272, 1846, 13, 18126, 610, 28491, 16129, 12, 314, 1284, 6707, 365, 5120, 315, 314, 272, 3089, 1615, 14, 339, 11711, 1175, 27690, 272, 275, 17575, 339, 2104, 21837, 27690, 334, 460, 27690, 543, 13673, 10976, 10826, 370, 506, 21837, 9, 781, 272, 2035, 314, 3089, 1615, 16129, 11736, 701, 1804, 5250, 359, 17, 467, 24002, 272, 5492, 650, 402, 3420, 413, 14, 20, 14, 710, 3089, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 339, 965, 627, 1589, 25259, 11150, 10, 367, 658, 77, 665, 302, 3559, 536, 590, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 289, 8, 77, 9, 435, 289, 8, 77, 11, 17, 9, 435, 971, 1447, 16673, 435, 289, 8, 78, 13, 18, 9, 435, 289, 8, 78, 13, 17, 9, 339, 543, 314, 7008, 2304, 574, 658, 70, 8, 78, 12544, 8789, 14, 710, 3089, 1806, 376, 2701, 663, 365, 272, 4697, 340, 436, 1454, 340, 658, 77, 275, 302, 8340, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 378, 221, 971, 14567, 971, 3442, 5682, 91, 509, 93, 971, 14567, 221, 333, 275, 302, 339, 19177, 12, 367, 1006, 1163, 27690, 1806, 2701, 5951, 781, 5534, 314, 2569, 272, 5492, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 446, 971, 1838, 7348, 78, 971, 274, 81, 284, 665, 333, 93, 289, 8, 73, 9, 221, 971, 14567, 971, 3442, 5682, 91, 509, 93, 971, 14567, 221, 333, 690, 302, 339, 2779, 365, 11012, 370, 5317, 626, 1804, 5250, 7890, 1006, 27690, 543, 314, 7008, 272, 2304, 3769, 13914, 14, 961, 365, 315, 30347, 370, 314, 20195, 610, 28491, 15843, 12, 272, 1325, 1630, 440, 12787, 314, 3089, 1615, 16129, 14, 1010, 271, 379, 781, 1172, 26, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 77, 971, 274, 81, 284, 665, 302, 93, 289, 8, 73, 9, 275, 971, 1838, 7348, 73, 275, 333, 93, 11683, 78, 446, 413, 93, 289, 8, 73, 9, 339, 2382, 314, 8865, 315, 15843, 365, 25343, 279, 370, 9052, 1989, 794, 314, 11150, 12, 272, 543, 10976, 730, 409, 641, 314, 2746, 3769, 20728, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 14, 3175, 492, 284, 12, 1022, 12, 333, 12, 302, 12, 671, 272, 1306, 687, 5840, 492, 12094, 12, 32618, 12, 16390, 12, 26437, 1563, 12, 6801, 272, 1306, 12094, 8, 75, 12, 334, 75, 12, 413, 12, 333, 430, 272, 12094, 8, 75, 12, 334, 75, 12, 413, 12, 333, 430, 272, 1306, 12094, 8, 75, 12, 334, 75, 12, 413, 12, 333, 4992, 19014, 342, 272, 333, 538, 18, 15, 18, 435, 333, 15, 18, 272, 1306, 12094, 8, 75, 538, 18, 12, 334, 75, 12, 413, 12, 333, 430, 272, 12094, 8, 75, 538, 18, 12, 334, 75, 12, 413, 12, 333, 430, 272, 1306, 12094, 8, 75, 538, 18, 12, 334, 75, 12, 413, 12, 333, 4992, 19014, 342, 272, 333, 538, 19, 15, 19, 435, 333, 538, 18, 15, 18, 435, 333, 15, 22, 272, 1306, 12094, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 430, 272, 12094, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 430, 272, 1306, 12094, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 4992, 19014, 342, 272, 31362, 1332, 17, 15, 2801, 88, 435, 413, 395, 20319, 8, 88, 9, 665, 413, 395, 334, 6959, 8, 88, 538, 75, 12, 334, 75, 12, 378, 12, 16390, 1826, 715, 430, 272, 1306, 12094, 8, 88, 538, 75, 15, 28165, 8, 75, 395, 334, 75, 12, 378, 12, 16390, 4992, 19014, 342, 272, 1437, 8, 88, 9, 339, 11842, 787, 7251, 370, 886, 3089, 1615, 543, 13673, 4918, 14, 221, 2047, 272, 883, 675, 1902, 6801, 402, 26437, 1563, 3992, 26, 339, 1306, 289, 275, 6801, 360, 70, 358, 272, 1306, 12094, 8, 70, 8, 78, 395, 334, 78, 12, 378, 12, 650, 4992, 19014, 342, 272, 289, 8, 16, 9, 435, 289, 8, 17, 9, 435, 289, 8, 18, 9, 435, 289, 8, 19, 9, 272, 1306, 12094, 8, 70, 8, 78, 395, 334, 78, 12, 378, 12, 16390, 4992, 19014, 342, 272, 12094, 8, 70, 8, 78, 395, 334, 78, 12, 378, 12, 16390, 430, 272, 1306, 289, 275, 26437, 1563, 360, 70, 358, 272, 1306, 12094, 8, 70, 59, 78, 24186, 18, 12, 334, 78, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Theshadow4all/ShadowCoin
test/functional/nulldummy.py
11
6540
#!/usr/bin/env python3 # Copyright (c) 2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test NULLDUMMY softfork. Connect to a single node. Generate 2 blocks (save the coinbases for later). Generate 427 more blocks. [Policy/Consensus] Check that NULLDUMMY compliant transactions are accepted in the 430th block. [Policy] Check that non-NULLDUMMY transactions are rejected before activation. [Consensus] Check that the new NULLDUMMY rules are not enforced on the 431st block. [Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block. """ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * from test_framework.mininode import CTransaction, NetworkThread from test_framework.blocktools import create_coinbase, create_block, add_witness_commitment from test_framework.script import CScript from io import BytesIO import time NULLDUMMY_ERROR = "64: non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)" VB_TOP_BITS = 0x20000000 def trueDummy(tx): scriptSig = CScript(tx.vin[0].scriptSig) newscript = [] for i in scriptSig: if (len(newscript) == 0): assert(len(i) == 0) newscript.append(b'\x51') else: newscript.append(i) tx.vin[0].scriptSig = CScript(newscript) tx.rehash() class NULLDUMMYTest(BitcoinTestFramework): def __init__(self): super().__init__() self.num_nodes = 1 self.setup_clean_chain = True self.extra_args = [['-whitelist=127.0.0.1', '-walletprematurewitness']] def run_test(self): self.address = self.nodes[0].getnewaddress() self.ms_address = self.nodes[0].addmultisigaddress(1,[self.address]) self.wit_address = self.nodes[0].addwitnessaddress(self.address) self.wit_ms_address = self.nodes[0].addwitnessaddress(self.ms_address) NetworkThread().start() # Start up network handling in another thread self.coinbase_blocks = self.nodes[0].generate(2) # Block 2 coinbase_txid = [] for i in self.coinbase_blocks: coinbase_txid.append(self.nodes[0].getblock(i)['tx'][0]) self.nodes[0].generate(427) # Block 429 self.lastblockhash = self.nodes[0].getbestblockhash() self.tip = int("0x" + self.lastblockhash, 0) self.lastblockheight = 429 self.lastblocktime = int(time.time()) + 429 self.log.info("Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [430]") test1txs = [self.create_transaction(self.nodes[0], coinbase_txid[0], self.ms_address, 49)] txid1 = self.nodes[0].sendrawtransaction(bytes_to_hex_str(test1txs[0].serialize_with_witness()), True) test1txs.append(self.create_transaction(self.nodes[0], txid1, self.ms_address, 48)) txid2 = self.nodes[0].sendrawtransaction(bytes_to_hex_str(test1txs[1].serialize_with_witness()), True) test1txs.append(self.create_transaction(self.nodes[0], coinbase_txid[1], self.wit_ms_address, 49)) txid3 = self.nodes[0].sendrawtransaction(bytes_to_hex_str(test1txs[2].serialize_with_witness()), True) self.block_submit(self.nodes[0], test1txs, False, True) self.log.info("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation") test2tx = self.create_transaction(self.nodes[0], txid2, self.ms_address, 47) trueDummy(test2tx) assert_raises_jsonrpc(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, bytes_to_hex_str(test2tx.serialize_with_witness()), True) self.log.info("Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [431]") self.block_submit(self.nodes[0], [test2tx], False, True) self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation") test4tx = self.create_transaction(self.nodes[0], test2tx.hash, self.address, 46) test6txs=[CTransaction(test4tx)] trueDummy(test4tx) assert_raises_jsonrpc(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, bytes_to_hex_str(test4tx.serialize_with_witness()), True) self.block_submit(self.nodes[0], [test4tx]) self.log.info("Test 5: Non-NULLDUMMY P2WSH multisig transaction invalid after activation") test5tx = self.create_transaction(self.nodes[0], txid3, self.wit_address, 48) test6txs.append(CTransaction(test5tx)) test5tx.wit.vtxinwit[0].scriptWitness.stack[0] = b'\x01' assert_raises_jsonrpc(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, bytes_to_hex_str(test5tx.serialize_with_witness()), True) self.block_submit(self.nodes[0], [test5tx], True) self.log.info("Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [432]") for i in test6txs: self.nodes[0].sendrawtransaction(bytes_to_hex_str(i.serialize_with_witness()), True) self.block_submit(self.nodes[0], test6txs, True, True, VB_TOP_BITS) def create_transaction(self, node, txid, to_address, amount): inputs = [{ "txid" : txid, "vout" : 0}] outputs = { to_address : amount } rawtx = node.createrawtransaction(inputs, outputs) signresult = node.signrawtransaction(rawtx) tx = CTransaction() f = BytesIO(hex_str_to_bytes(signresult['hex'])) tx.deserialize(f) return tx def block_submit(self, node, txs, witness = False, accept = False, version=4): block = create_block(self.tip, create_coinbase(self.lastblockheight + 1), self.lastblocktime + 1) block.nVersion = version for tx in txs: tx.rehash() block.vtx.append(tx) block.hashMerkleRoot = block.calc_merkle_root() witness and add_witness_commitment(block) block.rehash() block.solve() node.submitblock(bytes_to_hex_str(block.serialize(True))) if (accept): assert_equal(node.getbestblockhash(), block.hash) self.tip = block.sha256 self.lastblockhash = block.hash self.lastblocktime += 1 self.lastblockheight += 1 else: assert_equal(node.getbestblockhash(), self.lastblockhash) if __name__ == '__main__': NULLDUMMYTest().main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 7800, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 624, 774, 5962, 26778, 11620, 11796, 14, 199, 199, 8631, 370, 282, 2849, 1031, 14, 199, 6864, 499, 5664, 334, 2117, 314, 21914, 12087, 367, 2945, 680, 199, 6864, 841, 1465, 1655, 5664, 14, 199, 59, 4845, 15, 714, 31664, 61, 2670, 626, 5962, 26778, 1013, 22676, 15809, 787, 10226, 315, 314, 841, 1216, 273, 1853, 14, 199, 59, 4845, 61, 2670, 626, 2222, 13, 8084, 26778, 15809, 787, 18935, 2544, 10361, 14, 199, 59, 714, 31664, 61, 2670, 626, 314, 892, 5962, 26778, 4713, 787, 440, 30163, 641, 314, 841, 2192, 270, 1853, 14, 199, 59, 4845, 15, 714, 31664, 61, 2670, 626, 314, 892, 5962, 26778, 4713, 787, 30163, 641, 314, 841, 708, 977, 1853, 14, 199, 624, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 627, 199, 504, 511, 63, 4857, 14, 827, 15993, 492, 445, 10161, 12, 7220, 4436, 199, 504, 511, 63, 4857, 14, 1457, 2537, 492, 1218, 63, 30488, 12, 1218, 63, 1457, 12, 1050, 63, 22179, 63, 3543, 434, 199, 504, 511, 63, 4857, 14, 1579, 492, 24682, 199, 504, 5890, 492, 11808, 199, 646, 900, 199, 199, 8084, 26778, 63, 3170, 275, 298, 772, 26, 2222, 13, 19900, 13, 1579, 13, 4712, 13, 4173, 334, 11324, 17654, 8203, 1311, 1277, 1423, 1471, 506, 4697, 2924, 199, 27966, 63, 11422, 63, 14662, 275, 378, 88, 18, 9084, 199, 199, 318, 2549, 11324, 8, 2347, 304, 272, 2884, 11575, 275, 24682, 8, 2347, 14, 11908, 59, 16, 1055, 1579, 11575, 9, 272, 892, 1579, 275, 942, 272, 367, 284, 315, 2884, 11575, 26, 267, 340, 334, 552, 8, 1222, 1579, 9, 508, 378, 304, 288, 702, 8, 552, 8, 73, 9, 508, 378, 9, 288, 892, 1579, 14, 740, 8, 66, 1154, 88, 2869, 358, 267, 587, 26, 288, 892, 1579, 14, 740, 8, 73, 9, 272, 4773, 14, 11908, 59, 16, 1055, 1579, 11575, 275, 24682, 8, 1222, 1579, 9, 272, 4773, 14, 264, 2227, 342, 199, 199, 533, 5962, 26778, 774, 8, 4734, 9061, 26203, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 11027, 826, 4533, 267, 291, 14, 1507, 63, 2415, 275, 413, 267, 291, 14, 2758, 63, 3118, 63, 4429, 275, 715, 267, 291, 14, 2911, 63, 589, 275, 11194, 13, 14189, 29, 4195, 14, 16, 14, 16, 14, 17, 297, 2475, 13892, 657, 19925, 22179, 6538, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 291, 14, 1562, 275, 291, 14, 2415, 59, 16, 1055, 21102, 342, 267, 291, 14, 706, 63, 1562, 275, 291, 14, 2415, 59, 16, 1055, 525, 3029, 4093, 1562, 8, 17, 14343, 277, 14, 1562, 566, 267, 291, 14, 2503, 63, 1562, 275, 291, 14, 2415, 59, 16, 1055, 525, 22179, 1562, 8, 277, 14, 1562, 9, 267, 291, 14, 2503, 63, 706, 63, 1562, 275, 291, 14, 2415, 59, 16, 1055, 525, 22179, 1562, 8, 277, 14, 706, 63, 1562, 9, 398, 7220, 4436, 1252, 928, 342, 327, 7707, 1536, 2784, 7252, 315, 4573, 2462, 267, 291, 14, 30488, 63, 4166, 275, 291, 14, 2415, 59, 16, 1055, 4208, 8, 18, 9, 327, 8651, 499, 267, 21914, 1095, 63, 14113, 275, 942, 267, 367, 284, 315, 291, 14, 30488, 63, 4166, 26, 288, 21914, 1095, 63, 14113, 14, 740, 8, 277, 14, 2415, 59, 16, 1055, 17785, 8, 73, 11820, 2347, 3488, 16, 566, 267, 291, 14, 2415, 59, 16, 1055, 4208, 8, 27358, 9, 327, 8651, 17640, 267, 291, 14, 2019, 25848, 275, 291, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 342, 267, 291, 14, 8996, 275, 1109, 480, 16, 88, 2, 435, 291, 14, 2019, 25848, 12, 378, 9, 267, 291, 14, 2019, 1457, 3333, 275, 17640, 267, 291, 14, 2019, 1457, 521, 275, 1109, 8, 521, 14, 521, 1012, 435, 17640, 398, 291, 14, 793, 14, 815, 480, 774, 413, 26, 5962, 26778, 1013, 22676, 1300, 15809, 1077, 506, 10226, 370, 30330, 436, 1748, 379, 2544, 10361, 359, 25473, 12523, 267, 511, 17, 21863, 275, 359, 277, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 21914, 1095, 63, 14113, 59, 16, 467, 291, 14, 706, 63, 1562, 12, 12260, 1874, 267, 22083, 17, 275, 291, 14, 2415, 59, 16, 1055, 2254, 16900, 8, 2394, 63, 475, 63, 4097, 63, 495, 8, 396, 17, 21863, 59, 16, 1055, 3549, 63, 1045, 63, 22179, 4000, 715, 9, 267, 511, 17, 21863, 14, 740, 8, 277, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 22083, 17, 12, 291, 14, 706, 63, 1562, 12, 9615, 430, 267, 22083, 18, 275, 291, 14, 2415, 59, 16, 1055, 2254, 16900, 8, 2394, 63, 475, 63, 4097, 63, 495, 8, 396, 17, 21863, 59, 17, 1055, 3549, 63, 1045, 63, 22179, 4000, 715, 9, 267, 511, 17, 21863, 14, 740, 8, 277, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 21914, 1095, 63, 14113, 59, 17, 467, 291, 14, 2503, 63, 706, 63, 1562, 12, 12260, 430, 267, 22083, 19, 275, 291, 14, 2415, 59, 16, 1055, 2254, 16900, 8, 2394, 63, 475, 63, 4097, 63, 495, 8, 396, 17, 21863, 59, 18, 1055, 3549, 63, 1045, 63, 22179, 4000, 715, 9, 267, 291, 14, 1457, 63, 7275, 8, 277, 14, 2415, 59, 16, 467, 511, 17, 21863, 12, 756, 12, 715, 9, 398, 291, 14, 793, 14, 815, 480, 774, 499, 26, 10172, 13, 8084, 26778, 1300, 3510, 4093, 6008, 1077, 440, 506, 10226, 370, 30330, 2544, 10361, 531, 267, 511, 18, 2347, 275, 291, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 22083, 18, 12, 291, 14, 706, 63, 1562, 12, 10954, 9, 267, 2549, 11324, 8, 396, 18, 2347, 9, 267, 702, 63, 3536, 63, 31395, 2801, 1479, 12, 5962, 26778, 63, 3170, 12, 291, 14, 2415 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 7800, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 624, 774, 5962, 26778, 11620, 11796, 14, 199, 199, 8631, 370, 282, 2849, 1031, 14, 199, 6864, 499, 5664, 334, 2117, 314, 21914, 12087, 367, 2945, 680, 199, 6864, 841, 1465, 1655, 5664, 14, 199, 59, 4845, 15, 714, 31664, 61, 2670, 626, 5962, 26778, 1013, 22676, 15809, 787, 10226, 315, 314, 841, 1216, 273, 1853, 14, 199, 59, 4845, 61, 2670, 626, 2222, 13, 8084, 26778, 15809, 787, 18935, 2544, 10361, 14, 199, 59, 714, 31664, 61, 2670, 626, 314, 892, 5962, 26778, 4713, 787, 440, 30163, 641, 314, 841, 2192, 270, 1853, 14, 199, 59, 4845, 15, 714, 31664, 61, 2670, 626, 314, 892, 5962, 26778, 4713, 787, 30163, 641, 314, 841, 708, 977, 1853, 14, 199, 624, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 627, 199, 504, 511, 63, 4857, 14, 827, 15993, 492, 445, 10161, 12, 7220, 4436, 199, 504, 511, 63, 4857, 14, 1457, 2537, 492, 1218, 63, 30488, 12, 1218, 63, 1457, 12, 1050, 63, 22179, 63, 3543, 434, 199, 504, 511, 63, 4857, 14, 1579, 492, 24682, 199, 504, 5890, 492, 11808, 199, 646, 900, 199, 199, 8084, 26778, 63, 3170, 275, 298, 772, 26, 2222, 13, 19900, 13, 1579, 13, 4712, 13, 4173, 334, 11324, 17654, 8203, 1311, 1277, 1423, 1471, 506, 4697, 2924, 199, 27966, 63, 11422, 63, 14662, 275, 378, 88, 18, 9084, 199, 199, 318, 2549, 11324, 8, 2347, 304, 272, 2884, 11575, 275, 24682, 8, 2347, 14, 11908, 59, 16, 1055, 1579, 11575, 9, 272, 892, 1579, 275, 942, 272, 367, 284, 315, 2884, 11575, 26, 267, 340, 334, 552, 8, 1222, 1579, 9, 508, 378, 304, 288, 702, 8, 552, 8, 73, 9, 508, 378, 9, 288, 892, 1579, 14, 740, 8, 66, 1154, 88, 2869, 358, 267, 587, 26, 288, 892, 1579, 14, 740, 8, 73, 9, 272, 4773, 14, 11908, 59, 16, 1055, 1579, 11575, 275, 24682, 8, 1222, 1579, 9, 272, 4773, 14, 264, 2227, 342, 199, 199, 533, 5962, 26778, 774, 8, 4734, 9061, 26203, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 11027, 826, 4533, 267, 291, 14, 1507, 63, 2415, 275, 413, 267, 291, 14, 2758, 63, 3118, 63, 4429, 275, 715, 267, 291, 14, 2911, 63, 589, 275, 11194, 13, 14189, 29, 4195, 14, 16, 14, 16, 14, 17, 297, 2475, 13892, 657, 19925, 22179, 6538, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 291, 14, 1562, 275, 291, 14, 2415, 59, 16, 1055, 21102, 342, 267, 291, 14, 706, 63, 1562, 275, 291, 14, 2415, 59, 16, 1055, 525, 3029, 4093, 1562, 8, 17, 14343, 277, 14, 1562, 566, 267, 291, 14, 2503, 63, 1562, 275, 291, 14, 2415, 59, 16, 1055, 525, 22179, 1562, 8, 277, 14, 1562, 9, 267, 291, 14, 2503, 63, 706, 63, 1562, 275, 291, 14, 2415, 59, 16, 1055, 525, 22179, 1562, 8, 277, 14, 706, 63, 1562, 9, 398, 7220, 4436, 1252, 928, 342, 327, 7707, 1536, 2784, 7252, 315, 4573, 2462, 267, 291, 14, 30488, 63, 4166, 275, 291, 14, 2415, 59, 16, 1055, 4208, 8, 18, 9, 327, 8651, 499, 267, 21914, 1095, 63, 14113, 275, 942, 267, 367, 284, 315, 291, 14, 30488, 63, 4166, 26, 288, 21914, 1095, 63, 14113, 14, 740, 8, 277, 14, 2415, 59, 16, 1055, 17785, 8, 73, 11820, 2347, 3488, 16, 566, 267, 291, 14, 2415, 59, 16, 1055, 4208, 8, 27358, 9, 327, 8651, 17640, 267, 291, 14, 2019, 25848, 275, 291, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 342, 267, 291, 14, 8996, 275, 1109, 480, 16, 88, 2, 435, 291, 14, 2019, 25848, 12, 378, 9, 267, 291, 14, 2019, 1457, 3333, 275, 17640, 267, 291, 14, 2019, 1457, 521, 275, 1109, 8, 521, 14, 521, 1012, 435, 17640, 398, 291, 14, 793, 14, 815, 480, 774, 413, 26, 5962, 26778, 1013, 22676, 1300, 15809, 1077, 506, 10226, 370, 30330, 436, 1748, 379, 2544, 10361, 359, 25473, 12523, 267, 511, 17, 21863, 275, 359, 277, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 21914, 1095, 63, 14113, 59, 16, 467, 291, 14, 706, 63, 1562, 12, 12260, 1874, 267, 22083, 17, 275, 291, 14, 2415, 59, 16, 1055, 2254, 16900, 8, 2394, 63, 475, 63, 4097, 63, 495, 8, 396, 17, 21863, 59, 16, 1055, 3549, 63, 1045, 63, 22179, 4000, 715, 9, 267, 511, 17, 21863, 14, 740, 8, 277, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 22083, 17, 12, 291, 14, 706, 63, 1562, 12, 9615, 430, 267, 22083, 18, 275, 291, 14, 2415, 59, 16, 1055, 2254, 16900, 8, 2394, 63, 475, 63, 4097, 63, 495, 8, 396, 17, 21863, 59, 17, 1055, 3549, 63, 1045, 63, 22179, 4000, 715, 9, 267, 511, 17, 21863, 14, 740, 8, 277, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 21914, 1095, 63, 14113, 59, 17, 467, 291, 14, 2503, 63, 706, 63, 1562, 12, 12260, 430, 267, 22083, 19, 275, 291, 14, 2415, 59, 16, 1055, 2254, 16900, 8, 2394, 63, 475, 63, 4097, 63, 495, 8, 396, 17, 21863, 59, 18, 1055, 3549, 63, 1045, 63, 22179, 4000, 715, 9, 267, 291, 14, 1457, 63, 7275, 8, 277, 14, 2415, 59, 16, 467, 511, 17, 21863, 12, 756, 12, 715, 9, 398, 291, 14, 793, 14, 815, 480, 774, 499, 26, 10172, 13, 8084, 26778, 1300, 3510, 4093, 6008, 1077, 440, 506, 10226, 370, 30330, 2544, 10361, 531, 267, 511, 18, 2347, 275, 291, 14, 981, 63, 5945, 8, 277, 14, 2415, 59, 16, 467, 22083, 18, 12, 291, 14, 706, 63, 1562, 12, 10954, 9, 267, 2549, 11324, 8, 396, 18, 2347, 9, 267, 702, 63, 3536, 63, 31395, 2801, 1479, 12, 5962, 26778, 63, 3170, 12, 291, 14, 2415, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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errors Provides exceptions used by the Distutils modules. Note that Distutils modules may raise standard exceptions; in particular, SystemExit is usually raised for errors that are obviously the end-user's fault (eg. bad command-line arguments). This module is safe to use in "from ... import *" mode; it only exports symbols whose names start with "Distutils" and end with "Error".""" __revision__ = "$Id$" class DistutilsError(Exception): """The root of all Distutils evil.""" class DistutilsModuleError(DistutilsError): """Unable to load an expected module, or to find an expected class within some module (in particular, command modules and classes).""" class DistutilsClassError(DistutilsError): """Some command class (or possibly distribution class, if anyone feels a need to subclass Distribution) is found not to be holding up its end of the bargain, ie. implementing some part of the "command "interface.""" class DistutilsGetoptError(DistutilsError): """The option table provided to 'fancy_getopt()' is bogus.""" class DistutilsArgError(DistutilsError): """Raised by fancy_getopt in response to getopt.error -- ie. an error in the command line usage.""" class DistutilsFileError(DistutilsError): """Any problems in the filesystem: expected file not found, etc. Typically this is for problems that we detect before IOError or OSError could be raised.""" class DistutilsOptionError(DistutilsError): """Syntactic/semantic errors in command options, such as use of mutually conflicting options, or inconsistent options, badly-spelled values, etc. No distinction is made between option values originating in the setup script, the command line, config files, or what-have-you -- but if we *know* something originated in the setup script, we'll raise DistutilsSetupError instead.""" class DistutilsSetupError(DistutilsError): """For errors that can be definitely blamed on the setup script, such as invalid keyword arguments to 'setup()'.""" class DistutilsPlatformError(DistutilsError): """We don't know how to do something on the current platform (but we do know how to do it on some platform) -- eg. trying to compile C files on a platform not supported by a CCompiler subclass.""" class DistutilsExecError(DistutilsError): """Any problems executing an external program (such as the C compiler, when compiling C files).""" class DistutilsInternalError(DistutilsError): """Internal inconsistencies or impossibilities (obviously, this should never be seen if the code is working!).""" class DistutilsTemplateError(DistutilsError): """Syntax error in a file list template.""" class DistutilsByteCompileError(DistutilsError): """Byte compile error.""" # Exception classes used by the CCompiler implementation classes class CCompilerError(Exception): """Some compile/link operation failed.""" class PreprocessError(CCompilerError): """Failure to preprocess one or more C/C++ files.""" class CompileError(CCompilerError): """Failure to compile one or more C/C++ source files.""" class LibError(CCompilerError): """Failure to create a static library from one or more C/C++ object files.""" class LinkError(CCompilerError): """Failure to link one or more C/C++ object files into an executable or shared library file.""" class UnknownFileError(CCompilerError): """Attempt to process an unknown file type."""
gpl-3.0
[ 624, 13350, 14, 2550, 2999, 199, 17473, 4967, 1202, 701, 314, 12577, 4621, 14, 221, 3390, 626, 12577, 202, 199, 3112, 1443, 746, 4465, 4967, 27, 315, 6770, 12, 14838, 365, 202, 199, 25118, 4915, 367, 2552, 626, 787, 25259, 590, 314, 1284, 13, 751, 1159, 16898, 202, 199, 8, 5902, 14, 4875, 1414, 13, 604, 2368, 680, 2999, 199, 2765, 859, 365, 5048, 370, 675, 315, 298, 504, 2263, 492, 14390, 818, 27, 652, 1454, 22609, 202, 199, 7450, 7447, 1561, 1343, 543, 298, 12012, 1208, 2, 436, 1284, 543, 298, 547, 2, 1041, 2999, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 2999, 199, 533, 12577, 547, 8, 1726, 304, 1128, 408, 1918, 1738, 402, 1006, 12577, 8145, 382, 1041, 2999, 199, 533, 12577, 12232, 8, 12012, 1208, 547, 304, 1128, 408, 6005, 370, 2248, 376, 1420, 859, 12, 503, 370, 2342, 376, 1420, 1021, 1128, 4453, 2005, 859, 334, 262, 6770, 12, 1414, 4621, 436, 3992, 10477, 2999, 199, 533, 12577, 2543, 547, 8, 12012, 1208, 547, 304, 1128, 408, 7700, 1414, 1021, 334, 269, 12570, 4084, 1021, 12, 340, 29165, 1128, 1964, 18099, 282, 1929, 370, 5516, 11839, 9, 365, 1911, 440, 370, 506, 17573, 1128, 1536, 2399, 1284, 402, 314, 330, 1273, 1581, 12, 13446, 14, 18234, 2005, 1777, 402, 314, 1128, 298, 1531, 298, 3266, 1041, 2999, 199, 533, 12577, 1002, 29368, 8, 12012, 1208, 547, 304, 1128, 408, 1918, 945, 1817, 2741, 370, 283, 25352, 63, 18907, 11716, 365, 23703, 1041, 2999, 199, 533, 12577, 6373, 547, 8, 12012, 1208, 547, 304, 1128, 408, 16894, 701, 27571, 63, 18907, 315, 1177, 370, 12733, 14, 705, 1553, 13446, 14, 376, 1128, 1125, 315, 314, 1414, 1004, 4503, 1041, 2999, 199, 533, 12577, 25212, 8, 12012, 1208, 547, 304, 1128, 408, 9874, 8826, 315, 314, 10036, 26, 1420, 570, 440, 1911, 12, 5423, 14, 1128, 26914, 642, 365, 367, 8826, 626, 781, 9696, 2544, 5925, 503, 1128, 6440, 4293, 506, 4915, 1041, 2999, 199, 533, 31484, 8, 12012, 1208, 547, 304, 1128, 408, 4323, 343, 27296, 15, 261, 23127, 2552, 315, 1414, 1511, 12, 4066, 465, 675, 402, 1128, 16108, 28204, 1511, 12, 503, 27253, 1511, 12, 1128, 4875, 590, 13, 12325, 76, 1146, 1338, 12, 5423, 14, 221, 3091, 2917, 262, 414, 365, 6326, 3382, 945, 1128, 1338, 6330, 1958, 315, 314, 3272, 2884, 12, 314, 1414, 1004, 12, 1101, 1128, 1584, 12, 503, 4052, 13, 7804, 13, 13297, 1553, 1325, 340, 781, 627, 14996, 10, 6020, 6330, 972, 315, 1128, 314, 3272, 2884, 12, 781, 7171, 746, 12577, 30221, 3140, 1041, 2999, 199, 533, 12577, 30221, 8, 12012, 1208, 547, 304, 1128, 408, 1858, 2552, 626, 883, 506, 28088, 590, 6826, 313, 68, 641, 314, 3272, 2884, 12, 1128, 4066, 465, 3866, 4252, 2368, 370, 283, 2758, 11716, 1041, 2999, 199, 533, 12577, 10397, 547, 8, 12012, 1208, 547, 304, 1128, 408, 6004, 2793, 1133, 5715, 4212, 370, 886, 6020, 641, 314, 1453, 4298, 334, 7911, 1128, 781, 886, 5715, 4212, 370, 886, 652, 641, 2005, 4298, 9, 1553, 11837, 14, 9936, 370, 6555, 1128, 445, 1584, 641, 282, 4298, 440, 3748, 701, 282, 445, 9131, 5516, 1041, 2999, 199, 533, 12577, 4858, 547, 8, 12012, 1208, 547, 304, 1128, 408, 9874, 8826, 14043, 376, 5957, 2240, 334, 10180, 465, 314, 445, 1128, 6365, 12, 1380, 1013, 5662, 445, 1584, 10477, 2999, 199, 533, 12577, 8405, 547, 8, 12012, 1208, 547, 304, 1128, 408, 8405, 315, 388, 2316, 724, 2578, 503, 1742, 736, 23422, 334, 2873, 2971, 590, 12, 642, 1128, 1077, 7078, 506, 6775, 340, 314, 1233, 365, 6449, 1, 10477, 2999, 199, 533, 12577, 4231, 547, 8, 12012, 1208, 547, 304, 1128, 408, 16626, 1125, 315, 282, 570, 769, 1978, 1041, 2999, 199, 533, 12577, 4861, 12626, 547, 8, 12012, 1208, 547, 304, 1128, 408, 4861, 6555, 1125, 1041, 2999, 199, 3, 2186, 3992, 1202, 701, 314, 445, 9131, 4514, 3992, 202, 199, 533, 445, 9131, 547, 8, 1726, 304, 1128, 408, 7700, 6555, 15, 1073, 3439, 3405, 1041, 2999, 199, 533, 5543, 1412, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 23351, 1373, 503, 1655, 445, 15, 35, 4176, 1584, 1041, 2999, 199, 533, 24562, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 6555, 1373, 503, 1655, 445, 15, 35, 4176, 1350, 1584, 1041, 2999, 199, 533, 8003, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 1218, 282, 2955, 3555, 687, 1373, 503, 1655, 445, 15, 35, 4176, 909, 1128, 1584, 1041, 2999, 199, 533, 10967, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 2142, 1373, 503, 1655, 445, 15, 35, 4176, 909, 1584, 1901, 376, 7286, 1128, 503, 5709, 3555, 570, 1041, 2999, 199, 533, 14831, 25212, 8, 30926, 547, 304, 1128, 408, 23272, 370, 2112, 376, 5809, 570, 730, 1041, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 13350, 14, 2550, 2999, 199, 17473, 4967, 1202, 701, 314, 12577, 4621, 14, 221, 3390, 626, 12577, 202, 199, 3112, 1443, 746, 4465, 4967, 27, 315, 6770, 12, 14838, 365, 202, 199, 25118, 4915, 367, 2552, 626, 787, 25259, 590, 314, 1284, 13, 751, 1159, 16898, 202, 199, 8, 5902, 14, 4875, 1414, 13, 604, 2368, 680, 2999, 199, 2765, 859, 365, 5048, 370, 675, 315, 298, 504, 2263, 492, 14390, 818, 27, 652, 1454, 22609, 202, 199, 7450, 7447, 1561, 1343, 543, 298, 12012, 1208, 2, 436, 1284, 543, 298, 547, 2, 1041, 2999, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 2999, 199, 533, 12577, 547, 8, 1726, 304, 1128, 408, 1918, 1738, 402, 1006, 12577, 8145, 382, 1041, 2999, 199, 533, 12577, 12232, 8, 12012, 1208, 547, 304, 1128, 408, 6005, 370, 2248, 376, 1420, 859, 12, 503, 370, 2342, 376, 1420, 1021, 1128, 4453, 2005, 859, 334, 262, 6770, 12, 1414, 4621, 436, 3992, 10477, 2999, 199, 533, 12577, 2543, 547, 8, 12012, 1208, 547, 304, 1128, 408, 7700, 1414, 1021, 334, 269, 12570, 4084, 1021, 12, 340, 29165, 1128, 1964, 18099, 282, 1929, 370, 5516, 11839, 9, 365, 1911, 440, 370, 506, 17573, 1128, 1536, 2399, 1284, 402, 314, 330, 1273, 1581, 12, 13446, 14, 18234, 2005, 1777, 402, 314, 1128, 298, 1531, 298, 3266, 1041, 2999, 199, 533, 12577, 1002, 29368, 8, 12012, 1208, 547, 304, 1128, 408, 1918, 945, 1817, 2741, 370, 283, 25352, 63, 18907, 11716, 365, 23703, 1041, 2999, 199, 533, 12577, 6373, 547, 8, 12012, 1208, 547, 304, 1128, 408, 16894, 701, 27571, 63, 18907, 315, 1177, 370, 12733, 14, 705, 1553, 13446, 14, 376, 1128, 1125, 315, 314, 1414, 1004, 4503, 1041, 2999, 199, 533, 12577, 25212, 8, 12012, 1208, 547, 304, 1128, 408, 9874, 8826, 315, 314, 10036, 26, 1420, 570, 440, 1911, 12, 5423, 14, 1128, 26914, 642, 365, 367, 8826, 626, 781, 9696, 2544, 5925, 503, 1128, 6440, 4293, 506, 4915, 1041, 2999, 199, 533, 31484, 8, 12012, 1208, 547, 304, 1128, 408, 4323, 343, 27296, 15, 261, 23127, 2552, 315, 1414, 1511, 12, 4066, 465, 675, 402, 1128, 16108, 28204, 1511, 12, 503, 27253, 1511, 12, 1128, 4875, 590, 13, 12325, 76, 1146, 1338, 12, 5423, 14, 221, 3091, 2917, 262, 414, 365, 6326, 3382, 945, 1128, 1338, 6330, 1958, 315, 314, 3272, 2884, 12, 314, 1414, 1004, 12, 1101, 1128, 1584, 12, 503, 4052, 13, 7804, 13, 13297, 1553, 1325, 340, 781, 627, 14996, 10, 6020, 6330, 972, 315, 1128, 314, 3272, 2884, 12, 781, 7171, 746, 12577, 30221, 3140, 1041, 2999, 199, 533, 12577, 30221, 8, 12012, 1208, 547, 304, 1128, 408, 1858, 2552, 626, 883, 506, 28088, 590, 6826, 313, 68, 641, 314, 3272, 2884, 12, 1128, 4066, 465, 3866, 4252, 2368, 370, 283, 2758, 11716, 1041, 2999, 199, 533, 12577, 10397, 547, 8, 12012, 1208, 547, 304, 1128, 408, 6004, 2793, 1133, 5715, 4212, 370, 886, 6020, 641, 314, 1453, 4298, 334, 7911, 1128, 781, 886, 5715, 4212, 370, 886, 652, 641, 2005, 4298, 9, 1553, 11837, 14, 9936, 370, 6555, 1128, 445, 1584, 641, 282, 4298, 440, 3748, 701, 282, 445, 9131, 5516, 1041, 2999, 199, 533, 12577, 4858, 547, 8, 12012, 1208, 547, 304, 1128, 408, 9874, 8826, 14043, 376, 5957, 2240, 334, 10180, 465, 314, 445, 1128, 6365, 12, 1380, 1013, 5662, 445, 1584, 10477, 2999, 199, 533, 12577, 8405, 547, 8, 12012, 1208, 547, 304, 1128, 408, 8405, 315, 388, 2316, 724, 2578, 503, 1742, 736, 23422, 334, 2873, 2971, 590, 12, 642, 1128, 1077, 7078, 506, 6775, 340, 314, 1233, 365, 6449, 1, 10477, 2999, 199, 533, 12577, 4231, 547, 8, 12012, 1208, 547, 304, 1128, 408, 16626, 1125, 315, 282, 570, 769, 1978, 1041, 2999, 199, 533, 12577, 4861, 12626, 547, 8, 12012, 1208, 547, 304, 1128, 408, 4861, 6555, 1125, 1041, 2999, 199, 3, 2186, 3992, 1202, 701, 314, 445, 9131, 4514, 3992, 202, 199, 533, 445, 9131, 547, 8, 1726, 304, 1128, 408, 7700, 6555, 15, 1073, 3439, 3405, 1041, 2999, 199, 533, 5543, 1412, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 23351, 1373, 503, 1655, 445, 15, 35, 4176, 1584, 1041, 2999, 199, 533, 24562, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 6555, 1373, 503, 1655, 445, 15, 35, 4176, 1350, 1584, 1041, 2999, 199, 533, 8003, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 1218, 282, 2955, 3555, 687, 1373, 503, 1655, 445, 15, 35, 4176, 909, 1128, 1584, 1041, 2999, 199, 533, 10967, 547, 8, 30926, 547, 304, 1128, 408, 6782, 370, 2142, 1373, 503, 1655, 445, 15, 35, 4176, 909, 1584, 1901, 376, 7286, 1128, 503, 5709, 3555, 570, 1041, 2999, 199, 533, 14831, 25212, 8, 30926, 547, 304, 1128, 408, 23272, 370, 2112, 376, 5809, 570, 730, 1041, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
airodactyl/qutebrowser
tests/helpers/messagemock.py
4
2576
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # # qutebrowser 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 3 of the License, or # (at your option) any later version. # # qutebrowser 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. """pytest helper to monkeypatch the message module.""" import logging import attr import pytest from qutebrowser.utils import usertypes, message @attr.s class Message: """Information about a shown message.""" level = attr.ib() text = attr.ib() class MessageMock: """Helper object for message_mock. Attributes: Message: A object representing a message. messages: A list of Message objects. """ def __init__(self): self.messages = [] def _record_message(self, level, text): log_levels = { usertypes.MessageLevel.error: logging.ERROR, usertypes.MessageLevel.info: logging.INFO, usertypes.MessageLevel.warning: logging.WARNING, } log_level = log_levels[level] logging.getLogger('messagemock').log(log_level, text) self.messages.append(Message(level, text)) def getmsg(self, level=None): """Get the only message in self.messages. Raises ValueError if there are multiple or no messages. Args: level: The message level to check against, or None. """ assert len(self.messages) == 1 msg = self.messages[0] if level is not None: assert msg.level == level return msg def patch(self): """Start recording messages.""" message.global_bridge.show_message.connect(self._record_message) message.global_bridge._connected = True def unpatch(self): """Stop recording messages.""" message.global_bridge.show_message.disconnect(self._record_message) @pytest.fixture def message_mock(): """Fixture to get a MessageMock.""" mmock = MessageMock() mmock.patch() yield mmock mmock.unpatch()
gpl-3.0
[ 3, 6695, 26, 18133, 29, 1548, 570, 2991, 29, 1624, 13, 24, 23014, 29, 20, 5584, 29, 20, 10844, 26, 199, 199, 3, 1898, 6927, 13, 12682, 11040, 269, 5653, 699, 6558, 72, 262, 334, 1918, 27154, 9, 665, 1198, 32, 392, 31127, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2173, 31127, 14, 199, 3, 199, 3, 2173, 31127, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2173, 31127, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2173, 31127, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 4462, 5922, 370, 17309, 314, 1245, 859, 1041, 199, 199, 646, 2050, 199, 199, 646, 1921, 199, 646, 4613, 199, 199, 504, 2173, 31127, 14, 1208, 492, 922, 1313, 12, 1245, 421, 199, 32, 962, 14, 83, 199, 533, 6430, 26, 339, 408, 4935, 3595, 282, 9164, 1245, 1041, 339, 2166, 275, 1921, 14, 1892, 342, 272, 1318, 275, 1921, 14, 1892, 342, 421, 199, 533, 6430, 3346, 26, 339, 408, 4433, 909, 367, 1245, 63, 1805, 14, 339, 9382, 26, 267, 6430, 26, 437, 909, 6144, 282, 1245, 14, 267, 3788, 26, 437, 769, 402, 6430, 2251, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3431, 275, 942, 339, 347, 485, 3059, 63, 1188, 8, 277, 12, 2166, 12, 1318, 304, 267, 943, 63, 11402, 275, 469, 288, 922, 1313, 14, 2209, 4670, 14, 705, 26, 2050, 14, 3170, 12, 288, 922, 1313, 14, 2209, 4670, 14, 815, 26, 2050, 14, 4531, 12, 288, 922, 1313, 14, 2209, 4670, 14, 3764, 26, 2050, 14, 9171, 12, 267, 789, 267, 943, 63, 1896, 275, 943, 63, 11402, 59, 1896, 61, 398, 2050, 14, 5572, 360, 1188, 1805, 1959, 793, 8, 793, 63, 1896, 12, 1318, 9, 267, 291, 14, 3431, 14, 740, 8, 2209, 8, 1896, 12, 1318, 430, 339, 347, 664, 1328, 8, 277, 12, 2166, 29, 403, 304, 267, 408, 1002, 314, 1454, 1245, 315, 291, 14, 3431, 14, 398, 6218, 1722, 340, 2337, 787, 3663, 503, 949, 3788, 14, 398, 3033, 26, 288, 2166, 26, 710, 1245, 2166, 370, 1104, 6169, 12, 503, 488, 14, 267, 408, 267, 702, 822, 8, 277, 14, 3431, 9, 508, 413, 267, 1499, 275, 291, 14, 3431, 59, 16, 61, 267, 340, 2166, 365, 440, 488, 26, 288, 702, 1499, 14, 1896, 508, 2166, 267, 372, 1499, 339, 347, 3371, 8, 277, 304, 267, 408, 3162, 20952, 3788, 1041, 267, 1245, 14, 2966, 63, 9528, 14, 2384, 63, 1188, 14, 2242, 8, 277, 423, 3059, 63, 1188, 9, 267, 1245, 14, 2966, 63, 9528, 423, 7113, 275, 715, 339, 347, 625, 2068, 8, 277, 304, 267, 408, 6293, 20952, 3788, 1041, 267, 1245, 14, 2966, 63, 9528, 14, 2384, 63, 1188, 14, 10673, 8, 277, 423, 3059, 63, 1188, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 1245, 63, 1805, 837, 272, 408, 12812, 370, 664, 282, 6430, 3346, 1041, 272, 333, 1805, 275, 6430, 3346, 342, 272, 333, 1805, 14, 2068, 342, 272, 1995, 333, 1805, 272, 333, 1805, 14, 324, 2068, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6695, 26, 18133, 29, 1548, 570, 2991, 29, 1624, 13, 24, 23014, 29, 20, 5584, 29, 20, 10844, 26, 199, 199, 3, 1898, 6927, 13, 12682, 11040, 269, 5653, 699, 6558, 72, 262, 334, 1918, 27154, 9, 665, 1198, 32, 392, 31127, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2173, 31127, 14, 199, 3, 199, 3, 2173, 31127, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2173, 31127, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2173, 31127, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 4462, 5922, 370, 17309, 314, 1245, 859, 1041, 199, 199, 646, 2050, 199, 199, 646, 1921, 199, 646, 4613, 199, 199, 504, 2173, 31127, 14, 1208, 492, 922, 1313, 12, 1245, 421, 199, 32, 962, 14, 83, 199, 533, 6430, 26, 339, 408, 4935, 3595, 282, 9164, 1245, 1041, 339, 2166, 275, 1921, 14, 1892, 342, 272, 1318, 275, 1921, 14, 1892, 342, 421, 199, 533, 6430, 3346, 26, 339, 408, 4433, 909, 367, 1245, 63, 1805, 14, 339, 9382, 26, 267, 6430, 26, 437, 909, 6144, 282, 1245, 14, 267, 3788, 26, 437, 769, 402, 6430, 2251, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3431, 275, 942, 339, 347, 485, 3059, 63, 1188, 8, 277, 12, 2166, 12, 1318, 304, 267, 943, 63, 11402, 275, 469, 288, 922, 1313, 14, 2209, 4670, 14, 705, 26, 2050, 14, 3170, 12, 288, 922, 1313, 14, 2209, 4670, 14, 815, 26, 2050, 14, 4531, 12, 288, 922, 1313, 14, 2209, 4670, 14, 3764, 26, 2050, 14, 9171, 12, 267, 789, 267, 943, 63, 1896, 275, 943, 63, 11402, 59, 1896, 61, 398, 2050, 14, 5572, 360, 1188, 1805, 1959, 793, 8, 793, 63, 1896, 12, 1318, 9, 267, 291, 14, 3431, 14, 740, 8, 2209, 8, 1896, 12, 1318, 430, 339, 347, 664, 1328, 8, 277, 12, 2166, 29, 403, 304, 267, 408, 1002, 314, 1454, 1245, 315, 291, 14, 3431, 14, 398, 6218, 1722, 340, 2337, 787, 3663, 503, 949, 3788, 14, 398, 3033, 26, 288, 2166, 26, 710, 1245, 2166, 370, 1104, 6169, 12, 503, 488, 14, 267, 408, 267, 702, 822, 8, 277, 14, 3431, 9, 508, 413, 267, 1499, 275, 291, 14, 3431, 59, 16, 61, 267, 340, 2166, 365, 440, 488, 26, 288, 702, 1499, 14, 1896, 508, 2166, 267, 372, 1499, 339, 347, 3371, 8, 277, 304, 267, 408, 3162, 20952, 3788, 1041, 267, 1245, 14, 2966, 63, 9528, 14, 2384, 63, 1188, 14, 2242, 8, 277, 423, 3059, 63, 1188, 9, 267, 1245, 14, 2966, 63, 9528, 423, 7113, 275, 715, 339, 347, 625, 2068, 8, 277, 304, 267, 408, 6293, 20952, 3788, 1041, 267, 1245, 14, 2966, 63, 9528, 14, 2384, 63, 1188, 14, 10673, 8, 277, 423, 3059, 63, 1188, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 1245, 63, 1805, 837, 272, 408, 12812, 370, 664, 282, 6430, 3346, 1041, 272, 333, 1805, 275, 6430, 3346, 342, 272, 333, 1805, 14, 2068, 342, 272, 1995, 333, 1805, 272, 333, 1805, 14, 324, 2068, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ehirt/odoo
addons/l10n_be/wizard/__init__.py
438
1145
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import l10n_be_partner_vat_listing import l10n_be_vat_intra import l10n_be_account_vat_declaration # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 634, 709, 78, 63, 1235, 63, 3899, 63, 16305, 63, 16115, 199, 646, 634, 709, 78, 63, 1235, 63, 16305, 63, 442, 345, 199, 646, 634, 709, 78, 63, 1235, 63, 2048, 63, 16305, 63, 15477, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 634, 709, 78, 63, 1235, 63, 3899, 63, 16305, 63, 16115, 199, 646, 634, 709, 78, 63, 1235, 63, 16305, 63, 442, 345, 199, 646, 634, 709, 78, 63, 1235, 63, 2048, 63, 16305, 63, 15477, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wonder-sk/inasafe
safe/impact_functions/earthquake/itb_earthquake_fatality_model/impact_function.py
2
14889
# coding=utf-8 """InaSAFE Disaster risk tool by Australian Aid - ITB Earthquake Impact Function on Population. Contact : ole.moller.nielsen@gmail.com .. note:: 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. """ __author__ = 'lucernae' __date__ = '24/03/15' import numpy import logging from safe.common.utilities import OrderedDict from safe.impact_functions.base import ImpactFunction from safe.impact_functions.earthquake.itb_earthquake_fatality_model\ .metadata_definitions import ITBFatalityMetadata from safe.impact_functions.core import ( evacuated_population_needs, population_rounding_full, population_rounding) from safe.storage.raster import Raster from safe.common.utilities import ( format_int, humanize_class, create_classes, create_label, get_thousand_separator) from safe.common.tables import Table, TableRow from safe.common.exceptions import InaSAFEError from safe.utilities.i18n import tr from safe.gui.tools.minimum_needs.needs_profile import add_needs_parameters, \ get_needs_provenance_value, filter_needs_parameters LOGGER = logging.getLogger('InaSAFE') class ITBFatalityFunction(ImpactFunction): # noinspection PyUnresolvedReferences """Indonesian Earthquake Fatality Model. This model was developed by Institut Teknologi Bandung (ITB) and implemented by Dr. Hadi Ghasemi, Geoscience Australia. Reference: Indonesian Earthquake Building-Damage and Fatality Models and Post Disaster Survey Guidelines Development, Bali, 27-28 February 2012, 54pp. Algorithm: In this study, the same functional form as Allen (2009) is adopted to express fatality rate as a function of intensity (see Eq. 10 in the report). The Matlab built-in function (fminsearch) for Nelder-Mead algorithm was used to estimate the model parameters. The objective function (L2G norm) that is minimised during the optimisation is the same as the one used by Jaiswal et al. (2010). The coefficients used in the indonesian model are x=0.62275231, y=8.03314466, zeta=2.15 Allen, T. I., Wald, D. J., Earle, P. S., Marano, K. D., Hotovec, A. J., Lin, K., and Hearne, M., 2009. An Atlas of ShakeMaps and population exposure catalog for earthquake loss modeling, Bull. Earthq. Eng. 7, 701-718. Jaiswal, K., and Wald, D., 2010. An empirical model for global earthquake fatality estimation, Earthq. Spectra 26, 1017-1037. Caveats and limitations: The current model is the result of the above mentioned workshop and reflects the best available information. However, the current model has a number of issues listed below and is expected to evolve further over time. 1 - The model is based on limited number of observed fatality rates during 4 past fatal events. 2 - The model clearly over-predicts the fatality rates at intensities higher than VIII. 3 - The model only estimates the expected fatality rate for a given intensity level; however the associated uncertainty for the proposed model is not addressed. 4 - There are few known mistakes in developing the current model: - rounding MMI values to the nearest 0.5, - Implementing Finite-Fault models of candidate events, and - consistency between selected GMPEs with those in use by BMKG. These issues will be addressed by ITB team in the final report. Note: Because of these caveats, decisions should not be made solely on the information presented here and should always be verified by ground truthing and other reliable information sources. """ _metadata = ITBFatalityMetadata() def __init__(self): super(ITBFatalityFunction, self).__init__() # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) self.hardcoded_parameters = OrderedDict([ ('x', 0.62275231), ('y', 8.03314466), # Model coefficients # Rates of people displaced for each MMI level ('displacement_rate', { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 1.0, 7: 1.0, 8: 1.0, 9: 1.0, 10: 1.0 }), ('mmi_range', range(2, 10)), ('step', 0.5), ('calculate_displaced_people', True) ]) def fatality_rate(self, mmi): """ITB method to compute fatality rate. :param mmi: """ # As per email discussion with Ole, Trevor, Hadi, mmi < 4 will have # a fatality rate of 0 - Tim if mmi < 4: return 0 x = self.hardcoded_parameters['x'] y = self.hardcoded_parameters['y'] # noinspection PyUnresolvedReferences return numpy.power(10.0, x * mmi - y) def run(self, layers=None): """Indonesian Earthquake Fatality Model. Input: :param layers: List of layers expected to contain, hazard: Raster layer of MMI ground shaking exposure: Raster layer of population count """ self.validate() self.prepare(layers) displacement_rate = self.hardcoded_parameters['displacement_rate'] # Extract input layers intensity = self.hazard population = self.exposure # Extract data grids hazard = intensity.get_data() # Ground Shaking exposure = population.get_data(scaling=True) # Population Density # Calculate people affected by each MMI level # FIXME (Ole): this range is 2-9. Should 10 be included? mmi_range = self.hardcoded_parameters['mmi_range'] number_of_exposed = {} number_of_displaced = {} number_of_fatalities = {} # Calculate fatality rates for observed Intensity values (hazard # based on ITB power model mask = numpy.zeros(hazard.shape) for mmi in mmi_range: # Identify cells where MMI is in class i and # count people affected by this shake level mmi_matches = numpy.where( (hazard > mmi - self.hardcoded_parameters['step']) * ( hazard <= mmi + self.hardcoded_parameters['step']), exposure, 0) # Calculate expected number of fatalities per level fatality_rate = self.fatality_rate(mmi) fatalities = fatality_rate * mmi_matches # Calculate expected number of displaced people per level try: displacements = displacement_rate[mmi] * mmi_matches except KeyError, e: msg = 'mmi = %i, mmi_matches = %s, Error msg: %s' % ( mmi, str(mmi_matches), str(e)) # noinspection PyExceptionInherit raise InaSAFEError(msg) # Adjust displaced people to disregard fatalities. # Set to zero if there are more fatalities than displaced. displacements = numpy.where( displacements > fatalities, displacements - fatalities, 0) # Sum up numbers for map mask += displacements # Displaced # Generate text with result for this study # This is what is used in the real time system exposure table number_of_exposed[mmi] = numpy.nansum(mmi_matches.flat) number_of_displaced[mmi] = numpy.nansum(displacements.flat) # noinspection PyUnresolvedReferences number_of_fatalities[mmi] = numpy.nansum(fatalities.flat) # Total statistics total_population, rounding = population_rounding_full( numpy.nansum(exposure.flat)) # Compute number of fatalities total_fatalities = population_rounding(numpy.nansum( number_of_fatalities.values())) # As per email discussion with Ole, Trevor, Hadi, total fatalities < 50 # will be rounded down to 0 - Tim if total_fatalities < 50: total_fatalities = 0 # Compute number of people displaced due to building collapse total_displaced = population_rounding( numpy.nansum(number_of_displaced.values())) # Generate impact report table_body = [self.question] # Add total fatality estimate s = format_int(total_fatalities) table_body.append(TableRow([tr('Number of fatalities'), s], header=True)) if self.hardcoded_parameters['calculate_displaced_people']: # Add total estimate of people displaced s = format_int(total_displaced) table_body.append(TableRow([tr('Number of people displaced'), s], header=True)) else: total_displaced = 0 # Add estimate of total population in area s = format_int(int(total_population)) table_body.append(TableRow([tr('Total number of people'), s], header=True)) minimum_needs = [ parameter.serialize() for parameter in filter_needs_parameters(self.parameters['minimum needs']) ] # Generate impact report for the pdf map table_body = [ self.question, TableRow( [tr('Fatalities'), '%s' % format_int(total_fatalities)], header=True), TableRow( [tr('People displaced'), '%s' % format_int(total_displaced)], header=True), TableRow(tr('Map shows the estimation of displaced population'))] total_needs = evacuated_population_needs( total_displaced, minimum_needs) for frequency, needs in total_needs.items(): table_body.append(TableRow( [ tr('Needs should be provided %s' % frequency), tr('Total') ], header=True)) for resource in needs: table_body.append(TableRow([ tr(resource['table name']), format_int(resource['amount'])])) table_body.append(TableRow(tr('Provenance'), header=True)) table_body.append(TableRow(get_needs_provenance_value( self.parameters))) table_body.append(TableRow(tr('Action Checklist:'), header=True)) if total_fatalities > 0: table_body.append(tr('Are there enough victim identification ' 'units available for %s people?') % format_int(total_fatalities)) if total_displaced > 0: table_body.append(tr('Are there enough shelters and relief items ' 'available for %s people?') % format_int(total_displaced)) table_body.append(TableRow(tr('If yes, where are they located and ' 'how will we distribute them?'))) table_body.append(TableRow(tr('If no, where can we obtain ' 'additional relief items from and ' 'how will we transport them?'))) # Extend impact report for on-screen display table_body.extend([TableRow(tr('Notes'), header=True), tr('Total population: %s') % format_int( total_population), tr('People are considered to be displaced if ' 'they experience and survive a shake level' 'of more than 5 on the MMI scale '), tr('The fatality calculation assumes that ' 'no fatalities occur for shake levels below 4 ' 'and fatality counts of less than 50 are ' 'disregarded.'), tr('All values are rounded up to the nearest ' 'integer in order to avoid representing human ' 'lives as fractions.')]) table_body.append(TableRow(tr('Notes'), header=True)) table_body.append( tr('Fatality model is from Institut Teknologi Bandung 2012.')) table_body.append( tr('Population numbers rounded up to the nearest %s.') % rounding) # Result impact_summary = Table(table_body).toNewlineFreeString() impact_table = impact_summary # Create style colours = ['#EEFFEE', '#FFFF7F', '#E15500', '#E4001B', '#730000'] classes = create_classes(mask.flat[:], len(colours)) interval_classes = humanize_class(classes) style_classes = [] for i in xrange(len(interval_classes)): style_class = dict() style_class['label'] = create_label(interval_classes[i]) style_class['quantity'] = classes[i] if i == 0: transparency = 100 else: transparency = 30 style_class['transparency'] = transparency style_class['colour'] = colours[i] style_classes.append(style_class) style_info = dict(target_field=None, style_classes=style_classes, style_type='rasterStyle') # For printing map purpose map_title = tr('Earthquake impact to population') legend_notes = tr('Thousand separator is represented by %s' % get_thousand_separator()) legend_units = tr('(people per cell)') legend_title = tr('Population Count') # Create raster object and return raster = Raster( mask, projection=population.get_projection(), geotransform=population.get_geotransform(), keywords={ 'impact_summary': impact_summary, 'total_population': total_population, 'total_fatalities': total_fatalities, 'fatalities_per_mmi': number_of_fatalities, 'exposed_per_mmi': number_of_exposed, 'displaced_per_mmi': number_of_displaced, 'impact_table': impact_table, 'map_title': map_title, 'legend_notes': legend_notes, 'legend_units': legend_units, 'legend_title': legend_title, 'total_needs': total_needs}, name=tr('Estimated displaced population per cell'), style_info=style_info) self._impact = raster return raster
gpl-3.0
[ 3, 2803, 29, 1624, 13, 24, 199, 624, 607, 65, 27657, 5289, 2311, 22633, 4744, 701, 437, 11409, 25861, 437, 344, 446, 473, 20098, 662, 19677, 392, 1728, 199, 8499, 2442, 6801, 641, 13244, 5332, 14, 199, 199, 14499, 520, 312, 274, 14, 16924, 1435, 14, 8445, 352, 2464, 32, 6799, 14, 957, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1362, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1362, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 1362, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 29918, 281, 3540, 69, 7, 199, 363, 602, 363, 275, 283, 1194, 15, 1644, 15, 1046, 7, 199, 199, 646, 2680, 199, 646, 2050, 199, 199, 504, 5048, 14, 2330, 14, 16355, 492, 8773, 199, 504, 5048, 14, 31822, 63, 5777, 14, 1095, 492, 8362, 2442, 3481, 199, 504, 5048, 14, 31822, 63, 5777, 14, 2210, 273, 392, 1728, 14, 390, 66, 63, 2210, 273, 392, 1728, 63, 23156, 6712, 63, 1238, 60, 272, 1275, 2343, 63, 15388, 492, 473, 52, 12659, 292, 6712, 5142, 199, 504, 5048, 14, 31822, 63, 5777, 14, 1018, 492, 334, 272, 8145, 645, 23130, 63, 16003, 63, 10065, 12, 272, 16423, 63, 15326, 63, 2861, 12, 272, 16423, 63, 15326, 9, 199, 504, 5048, 14, 3494, 14, 20876, 492, 820, 2311, 199, 504, 5048, 14, 2330, 14, 16355, 492, 334, 272, 1475, 63, 442, 12, 272, 11779, 794, 63, 533, 12, 272, 1218, 63, 2888, 12, 272, 1218, 63, 1302, 12, 272, 664, 63, 273, 1785, 460, 63, 9896, 9, 199, 504, 5048, 14, 2330, 14, 5987, 492, 6957, 12, 6957, 5810, 199, 504, 5048, 14, 2330, 14, 3924, 492, 1010, 65, 27657, 547, 199, 504, 5048, 14, 16355, 14, 73, 1085, 78, 492, 5651, 199, 504, 5048, 14, 5885, 14, 2537, 14, 10700, 63, 10065, 14, 10065, 63, 2913, 492, 1050, 63, 10065, 63, 3214, 12, 971, 272, 664, 63, 10065, 63, 496, 1856, 554, 63, 585, 12, 2457, 63, 10065, 63, 3214, 199, 199, 10186, 275, 2050, 14, 5572, 360, 607, 65, 27657, 358, 421, 199, 533, 473, 52, 12659, 292, 6712, 3481, 8, 8499, 2442, 3481, 304, 272, 327, 30870, 1611, 1358, 13697, 15242, 272, 408, 607, 4456, 6214, 662, 19677, 392, 1728, 481, 292, 6712, 5822, 14, 339, 961, 1402, 1990, 477, 27813, 701, 1010, 6329, 337, 377, 5711, 889, 793, 73, 27709, 10335, 334, 649, 34, 9, 436, 272, 6366, 701, 577, 82, 14, 869, 65, 328, 598, 72, 482, 2664, 12, 8875, 9907, 4894, 437, 22306, 14, 2378, 10944, 26, 339, 473, 977, 368, 6214, 662, 19677, 392, 1728, 6516, 316, 13, 25014, 960, 436, 481, 292, 6712, 29941, 436, 272, 7711, 5289, 2311, 29013, 15423, 1278, 15290, 12, 272, 699, 10874, 12, 8087, 13, 1651, 21141, 26709, 6029, 12, 13470, 802, 14, 2378, 23823, 26, 339, 1010, 642, 25932, 12, 314, 2011, 22380, 1824, 465, 4580, 552, 334, 8664, 9, 365, 1503, 411, 471, 272, 370, 4056, 289, 292, 6712, 6634, 465, 282, 805, 402, 28873, 334, 3239, 21779, 14, 1616, 315, 314, 272, 3622, 680, 710, 18619, 5561, 6137, 13, 262, 805, 334, 70, 827, 1733, 9, 367, 221, 653, 352, 424, 13, 1352, 350, 272, 5563, 1990, 1202, 370, 14497, 314, 1402, 2633, 14, 710, 20632, 272, 805, 334, 44, 18, 39, 6316, 9, 626, 365, 18790, 9096, 5309, 314, 1687, 280, 1292, 425, 365, 314, 272, 2011, 465, 314, 1373, 1202, 701, 1603, 65, 374, 20877, 10844, 741, 14, 334, 6542, 680, 339, 710, 12343, 1202, 315, 314, 315, 4456, 6214, 1402, 787, 272, 671, 29, 16, 14, 30603, 2194, 11921, 12, 612, 29, 24, 14, 8762, 9862, 1272, 12, 1315, 1841, 29, 18, 14, 1046, 339, 4580, 552, 12, 377, 14, 473, 2020, 644, 27075, 12, 577, 14, 1603, 2020, 662, 285, 274, 12, 510, 14, 428, 2020, 16794, 8143, 12, 1804, 14, 577, 2020, 869, 3459, 6046, 12, 437, 14, 1603, 2020, 272, 29730, 12, 1804, 2020, 436, 869, 2210, 685, 12, 603, 2020, 8937, 14, 1626, 2854, 12536, 402, 5244, 1728, 24995, 436, 16423, 272, 30105, 10594, 367, 8413, 273, 392, 1728, 5621, 1402, 316, 12, 699, 979, 14, 662, 19677, 81, 14, 18960, 14, 1520, 12, 272, 1520, 614, 13, 26948, 14, 339, 1603, 65, 374, 20877, 12, 1804, 2020, 436, 644, 27075, 12, 577, 2020, 7129, 14, 1626, 9052, 73, 8825, 1402, 367, 2288, 8413, 273, 392, 1728, 272, 289, 292, 6712, 27156, 12, 662, 19677, 81, 14, 428, 1764, 345, 7875, 12, 413, 9570, 13, 709, 1401, 14, 2378, 445, 811, 1956, 436, 4204, 26, 339, 710, 1453, 1402, 365, 314, 754, 402, 314, 3432, 26239, 1736, 10568, 436, 272, 16806, 83, 314, 5526, 2808, 2556, 14, 9738, 12, 314, 1453, 1402, 272, 965, 282, 1329, 402, 10876, 10532, 5084, 436, 365, 1420, 370, 8145, 3344, 9848, 272, 1806, 900, 14, 339, 413, 446, 710, 1402, 365, 4079, 641, 13988, 1329, 402, 20802, 289, 292, 6712, 267, 24434, 5309, 841, 13541, 14294, 4474, 14, 272, 499, 446, 710, 1402, 5436, 590, 1806, 13, 6892, 83, 314, 289, 292, 6712, 24434, 737, 267, 315, 724, 338, 1417, 10948, 2419, 812, 30807, 14, 272, 650, 446, 710, 1402, 1454, 23505, 314, 1420, 289, 292, 6712, 6634, 367, 282, 1627, 267, 28873, 2166, 27, 13432, 314, 4568, 30043, 369, 367, 314, 14075, 267, 1402, 365, 440, 1050, 5111, 14, 272, 841, 446, 6006, 787, 9284, 6040, 27572, 4364, 315, 477, 3419, 4073, 314, 1453, 1402, 26, 267, 446, 18100, 603, 10709, 1338, 370, 314, 17173, 378, 14, 21, 12, 267, 446, 22467, 316, 11711, 1175, 13, 16665, 1709, 402, 7627, 4474, 12, 436, 267, 446, 17754, 3382, 4895, 598, 45, 1510, 83, 543, 5204, 315, 675, 701, 699, 45, 14634, 14, 881, 5723, 10876, 911, 506, 1050, 5111, 701, 473, 20098, 8099, 315, 314, 4242, 3622, 14, 339, 3390, 26, 13821, 402, 3520, 286, 811, 1956, 12, 12985, 1356, 1077, 440, 506, 6326, 30869, 590, 641, 272, 314, 2556, 26568, 2348, 436, 1077, 3544, 506 ]
[ 2803, 29, 1624, 13, 24, 199, 624, 607, 65, 27657, 5289, 2311, 22633, 4744, 701, 437, 11409, 25861, 437, 344, 446, 473, 20098, 662, 19677, 392, 1728, 199, 8499, 2442, 6801, 641, 13244, 5332, 14, 199, 199, 14499, 520, 312, 274, 14, 16924, 1435, 14, 8445, 352, 2464, 32, 6799, 14, 957, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1362, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1362, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 1362, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 29918, 281, 3540, 69, 7, 199, 363, 602, 363, 275, 283, 1194, 15, 1644, 15, 1046, 7, 199, 199, 646, 2680, 199, 646, 2050, 199, 199, 504, 5048, 14, 2330, 14, 16355, 492, 8773, 199, 504, 5048, 14, 31822, 63, 5777, 14, 1095, 492, 8362, 2442, 3481, 199, 504, 5048, 14, 31822, 63, 5777, 14, 2210, 273, 392, 1728, 14, 390, 66, 63, 2210, 273, 392, 1728, 63, 23156, 6712, 63, 1238, 60, 272, 1275, 2343, 63, 15388, 492, 473, 52, 12659, 292, 6712, 5142, 199, 504, 5048, 14, 31822, 63, 5777, 14, 1018, 492, 334, 272, 8145, 645, 23130, 63, 16003, 63, 10065, 12, 272, 16423, 63, 15326, 63, 2861, 12, 272, 16423, 63, 15326, 9, 199, 504, 5048, 14, 3494, 14, 20876, 492, 820, 2311, 199, 504, 5048, 14, 2330, 14, 16355, 492, 334, 272, 1475, 63, 442, 12, 272, 11779, 794, 63, 533, 12, 272, 1218, 63, 2888, 12, 272, 1218, 63, 1302, 12, 272, 664, 63, 273, 1785, 460, 63, 9896, 9, 199, 504, 5048, 14, 2330, 14, 5987, 492, 6957, 12, 6957, 5810, 199, 504, 5048, 14, 2330, 14, 3924, 492, 1010, 65, 27657, 547, 199, 504, 5048, 14, 16355, 14, 73, 1085, 78, 492, 5651, 199, 504, 5048, 14, 5885, 14, 2537, 14, 10700, 63, 10065, 14, 10065, 63, 2913, 492, 1050, 63, 10065, 63, 3214, 12, 971, 272, 664, 63, 10065, 63, 496, 1856, 554, 63, 585, 12, 2457, 63, 10065, 63, 3214, 199, 199, 10186, 275, 2050, 14, 5572, 360, 607, 65, 27657, 358, 421, 199, 533, 473, 52, 12659, 292, 6712, 3481, 8, 8499, 2442, 3481, 304, 272, 327, 30870, 1611, 1358, 13697, 15242, 272, 408, 607, 4456, 6214, 662, 19677, 392, 1728, 481, 292, 6712, 5822, 14, 339, 961, 1402, 1990, 477, 27813, 701, 1010, 6329, 337, 377, 5711, 889, 793, 73, 27709, 10335, 334, 649, 34, 9, 436, 272, 6366, 701, 577, 82, 14, 869, 65, 328, 598, 72, 482, 2664, 12, 8875, 9907, 4894, 437, 22306, 14, 2378, 10944, 26, 339, 473, 977, 368, 6214, 662, 19677, 392, 1728, 6516, 316, 13, 25014, 960, 436, 481, 292, 6712, 29941, 436, 272, 7711, 5289, 2311, 29013, 15423, 1278, 15290, 12, 272, 699, 10874, 12, 8087, 13, 1651, 21141, 26709, 6029, 12, 13470, 802, 14, 2378, 23823, 26, 339, 1010, 642, 25932, 12, 314, 2011, 22380, 1824, 465, 4580, 552, 334, 8664, 9, 365, 1503, 411, 471, 272, 370, 4056, 289, 292, 6712, 6634, 465, 282, 805, 402, 28873, 334, 3239, 21779, 14, 1616, 315, 314, 272, 3622, 680, 710, 18619, 5561, 6137, 13, 262, 805, 334, 70, 827, 1733, 9, 367, 221, 653, 352, 424, 13, 1352, 350, 272, 5563, 1990, 1202, 370, 14497, 314, 1402, 2633, 14, 710, 20632, 272, 805, 334, 44, 18, 39, 6316, 9, 626, 365, 18790, 9096, 5309, 314, 1687, 280, 1292, 425, 365, 314, 272, 2011, 465, 314, 1373, 1202, 701, 1603, 65, 374, 20877, 10844, 741, 14, 334, 6542, 680, 339, 710, 12343, 1202, 315, 314, 315, 4456, 6214, 1402, 787, 272, 671, 29, 16, 14, 30603, 2194, 11921, 12, 612, 29, 24, 14, 8762, 9862, 1272, 12, 1315, 1841, 29, 18, 14, 1046, 339, 4580, 552, 12, 377, 14, 473, 2020, 644, 27075, 12, 577, 14, 1603, 2020, 662, 285, 274, 12, 510, 14, 428, 2020, 16794, 8143, 12, 1804, 14, 577, 2020, 869, 3459, 6046, 12, 437, 14, 1603, 2020, 272, 29730, 12, 1804, 2020, 436, 869, 2210, 685, 12, 603, 2020, 8937, 14, 1626, 2854, 12536, 402, 5244, 1728, 24995, 436, 16423, 272, 30105, 10594, 367, 8413, 273, 392, 1728, 5621, 1402, 316, 12, 699, 979, 14, 662, 19677, 81, 14, 18960, 14, 1520, 12, 272, 1520, 614, 13, 26948, 14, 339, 1603, 65, 374, 20877, 12, 1804, 2020, 436, 644, 27075, 12, 577, 2020, 7129, 14, 1626, 9052, 73, 8825, 1402, 367, 2288, 8413, 273, 392, 1728, 272, 289, 292, 6712, 27156, 12, 662, 19677, 81, 14, 428, 1764, 345, 7875, 12, 413, 9570, 13, 709, 1401, 14, 2378, 445, 811, 1956, 436, 4204, 26, 339, 710, 1453, 1402, 365, 314, 754, 402, 314, 3432, 26239, 1736, 10568, 436, 272, 16806, 83, 314, 5526, 2808, 2556, 14, 9738, 12, 314, 1453, 1402, 272, 965, 282, 1329, 402, 10876, 10532, 5084, 436, 365, 1420, 370, 8145, 3344, 9848, 272, 1806, 900, 14, 339, 413, 446, 710, 1402, 365, 4079, 641, 13988, 1329, 402, 20802, 289, 292, 6712, 267, 24434, 5309, 841, 13541, 14294, 4474, 14, 272, 499, 446, 710, 1402, 5436, 590, 1806, 13, 6892, 83, 314, 289, 292, 6712, 24434, 737, 267, 315, 724, 338, 1417, 10948, 2419, 812, 30807, 14, 272, 650, 446, 710, 1402, 1454, 23505, 314, 1420, 289, 292, 6712, 6634, 367, 282, 1627, 267, 28873, 2166, 27, 13432, 314, 4568, 30043, 369, 367, 314, 14075, 267, 1402, 365, 440, 1050, 5111, 14, 272, 841, 446, 6006, 787, 9284, 6040, 27572, 4364, 315, 477, 3419, 4073, 314, 1453, 1402, 26, 267, 446, 18100, 603, 10709, 1338, 370, 314, 17173, 378, 14, 21, 12, 267, 446, 22467, 316, 11711, 1175, 13, 16665, 1709, 402, 7627, 4474, 12, 436, 267, 446, 17754, 3382, 4895, 598, 45, 1510, 83, 543, 5204, 315, 675, 701, 699, 45, 14634, 14, 881, 5723, 10876, 911, 506, 1050, 5111, 701, 473, 20098, 8099, 315, 314, 4242, 3622, 14, 339, 3390, 26, 13821, 402, 3520, 286, 811, 1956, 12, 12985, 1356, 1077, 440, 506, 6326, 30869, 590, 641, 272, 314, 2556, 26568, 2348, 436, 1077, 3544, 506, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ChristineLaMuse/mozillians
vendor-local/lib/python/celery/backends/base.py
14
15413
# -*- coding: utf-8 -*- """celery.backends.base""" from __future__ import absolute_import import time import sys from datetime import timedelta from kombu import serialization from .. import states from ..datastructures import LRUCache from ..exceptions import TimeoutError, TaskRevokedError from ..utils import timeutils from ..utils.encoding import bytes_to_str, ensure_bytes, from_utf8 from ..utils.serialization import (get_pickled_exception, get_pickleable_exception, create_exception_cls) EXCEPTION_ABLE_CODECS = frozenset(["pickle", "yaml"]) is_py3k = sys.version_info >= (3, 0) def unpickle_backend(cls, args, kwargs): """Returns an unpickled backend.""" return cls(*args, **kwargs) class BaseBackend(object): """Base backend class.""" READY_STATES = states.READY_STATES UNREADY_STATES = states.UNREADY_STATES EXCEPTION_STATES = states.EXCEPTION_STATES TimeoutError = TimeoutError #: Time to sleep between polling each individual item #: in `ResultSet.iterate`. as opposed to the `interval` #: argument which is for each pass. subpolling_interval = None #: If true the backend must implement :meth:`get_many`. supports_native_join = False def __init__(self, *args, **kwargs): from ..app import app_or_default self.app = app_or_default(kwargs.get("app")) self.serializer = kwargs.get("serializer", self.app.conf.CELERY_RESULT_SERIALIZER) (self.content_type, self.content_encoding, self.encoder) = serialization.registry._encoders[self.serializer] def encode(self, data): _, _, payload = serialization.encode(data, serializer=self.serializer) return payload def decode(self, payload): payload = is_py3k and payload or str(payload) return serialization.decode(payload, content_type=self.content_type, content_encoding=self.content_encoding) def prepare_expires(self, value, type=None): if value is None: value = self.app.conf.CELERY_TASK_RESULT_EXPIRES if isinstance(value, timedelta): value = timeutils.timedelta_seconds(value) if value is not None and type: return type(value) return value def encode_result(self, result, status): if status in self.EXCEPTION_STATES and isinstance(result, Exception): return self.prepare_exception(result) else: return self.prepare_value(result) def store_result(self, task_id, result, status, traceback=None): """Store the result and status of a task.""" raise NotImplementedError( "store_result is not supported by this backend.") def mark_as_started(self, task_id, **meta): """Mark a task as started""" return self.store_result(task_id, meta, status=states.STARTED) def mark_as_done(self, task_id, result): """Mark task as successfully executed.""" return self.store_result(task_id, result, status=states.SUCCESS) def mark_as_failure(self, task_id, exc, traceback=None): """Mark task as executed with failure. Stores the execption.""" return self.store_result(task_id, exc, status=states.FAILURE, traceback=traceback) def mark_as_retry(self, task_id, exc, traceback=None): """Mark task as being retries. Stores the current exception (if any).""" return self.store_result(task_id, exc, status=states.RETRY, traceback=traceback) def mark_as_revoked(self, task_id): return self.store_result(task_id, TaskRevokedError(), status=states.REVOKED, traceback=None) def prepare_exception(self, exc): """Prepare exception for serialization.""" if self.serializer in EXCEPTION_ABLE_CODECS: return get_pickleable_exception(exc) return {"exc_type": type(exc).__name__, "exc_message": str(exc)} def exception_to_python(self, exc): """Convert serialized exception to Python exception.""" if self.serializer in EXCEPTION_ABLE_CODECS: return get_pickled_exception(exc) return create_exception_cls(from_utf8(exc["exc_type"]), sys.modules[__name__]) def prepare_value(self, result): """Prepare value for storage.""" return result def forget(self, task_id): raise NotImplementedError("%s does not implement forget." % ( self.__class__)) def wait_for(self, task_id, timeout=None, propagate=True, interval=0.5): """Wait for task and return its result. If the task raises an exception, this exception will be re-raised by :func:`wait_for`. If `timeout` is not :const:`None`, this raises the :class:`celery.exceptions.TimeoutError` exception if the operation takes longer than `timeout` seconds. """ time_elapsed = 0.0 while True: status = self.get_status(task_id) if status == states.SUCCESS: return self.get_result(task_id) elif status in states.PROPAGATE_STATES: result = self.get_result(task_id) if propagate: raise result return result # avoid hammering the CPU checking status. time.sleep(interval) time_elapsed += interval if timeout and time_elapsed >= timeout: raise TimeoutError("The operation timed out.") def cleanup(self): """Backend cleanup. Is run by :class:`celery.task.DeleteExpiredTaskMetaTask`.""" pass def process_cleanup(self): """Cleanup actions to do at the end of a task worker process.""" pass def get_status(self, task_id): """Get the status of a task.""" raise NotImplementedError( "get_status is not supported by this backend.") def get_result(self, task_id): """Get the result of a task.""" raise NotImplementedError( "get_result is not supported by this backend.") def get_traceback(self, task_id): """Get the traceback for a failed task.""" raise NotImplementedError( "get_traceback is not supported by this backend.") def save_taskset(self, taskset_id, result): """Store the result and status of a task.""" raise NotImplementedError( "save_taskset is not supported by this backend.") def restore_taskset(self, taskset_id, cache=True): """Get the result of a taskset.""" raise NotImplementedError( "restore_taskset is not supported by this backend.") def delete_taskset(self, taskset_id): raise NotImplementedError( "delete_taskset is not supported by this backend.") def reload_task_result(self, task_id): """Reload task result, even if it has been previously fetched.""" raise NotImplementedError( "reload_task_result is not supported by this backend.") def reload_taskset_result(self, task_id): """Reload taskset result, even if it has been previously fetched.""" raise NotImplementedError( "reload_taskset_result is not supported by this backend.") def on_chord_part_return(self, task, propagate=False): pass def on_chord_apply(self, setid, body, result=None, **kwargs): from ..registry import tasks kwargs["result"] = [r.task_id for r in result] tasks["celery.chord_unlock"].apply_async((setid, body, ), kwargs, countdown=1) def __reduce__(self, args=(), kwargs={}): return (unpickle_backend, (self.__class__, args, kwargs)) class BaseDictBackend(BaseBackend): def __init__(self, *args, **kwargs): super(BaseDictBackend, self).__init__(*args, **kwargs) self._cache = LRUCache(limit=kwargs.get("max_cached_results") or self.app.conf.CELERY_MAX_CACHED_RESULTS) def store_result(self, task_id, result, status, traceback=None, **kwargs): """Store task result and status.""" result = self.encode_result(result, status) return self._store_result(task_id, result, status, traceback, **kwargs) def forget(self, task_id): self._cache.pop(task_id, None) self._forget(task_id) def _forget(self, task_id): raise NotImplementedError("%s does not implement forget." % ( self.__class__)) def get_status(self, task_id): """Get the status of a task.""" return self.get_task_meta(task_id)["status"] def get_traceback(self, task_id): """Get the traceback for a failed task.""" return self.get_task_meta(task_id).get("traceback") def get_result(self, task_id): """Get the result of a task.""" meta = self.get_task_meta(task_id) if meta["status"] in self.EXCEPTION_STATES: return self.exception_to_python(meta["result"]) else: return meta["result"] def get_task_meta(self, task_id, cache=True): if cache: try: return self._cache[task_id] except KeyError: pass meta = self._get_task_meta_for(task_id) if cache and meta.get("status") == states.SUCCESS: self._cache[task_id] = meta return meta def reload_task_result(self, task_id): self._cache[task_id] = self.get_task_meta(task_id, cache=False) def reload_taskset_result(self, taskset_id): self._cache[taskset_id] = self.get_taskset_meta(taskset_id, cache=False) def get_taskset_meta(self, taskset_id, cache=True): if cache: try: return self._cache[taskset_id] except KeyError: pass meta = self._restore_taskset(taskset_id) if cache and meta is not None: self._cache[taskset_id] = meta return meta def restore_taskset(self, taskset_id, cache=True): """Get the result for a taskset.""" meta = self.get_taskset_meta(taskset_id, cache=cache) if meta: return meta["result"] def save_taskset(self, taskset_id, result): """Store the result of an executed taskset.""" return self._save_taskset(taskset_id, result) def delete_taskset(self, taskset_id): self._cache.pop(taskset_id, None) return self._delete_taskset(taskset_id) class KeyValueStoreBackend(BaseDictBackend): task_keyprefix = ensure_bytes("celery-task-meta-") taskset_keyprefix = ensure_bytes("celery-taskset-meta-") chord_keyprefix = ensure_bytes("chord-unlock-") def get(self, key): raise NotImplementedError("Must implement the get method.") def mget(self, keys): raise NotImplementedError("Does not support get_many") def set(self, key, value): raise NotImplementedError("Must implement the set method.") def delete(self, key): raise NotImplementedError("Must implement the delete method") def get_key_for_task(self, task_id): """Get the cache key for a task by id.""" return self.task_keyprefix + ensure_bytes(task_id) def get_key_for_taskset(self, taskset_id): """Get the cache key for a taskset by id.""" return self.taskset_keyprefix + ensure_bytes(taskset_id) def get_key_for_chord(self, taskset_id): """Get the cache key for the chord waiting on taskset with given id.""" return self.chord_keyprefix + ensure_bytes(taskset_id) def _strip_prefix(self, key): """Takes bytes, emits string.""" for prefix in self.task_keyprefix, self.taskset_keyprefix: if key.startswith(prefix): return bytes_to_str(key[len(prefix):]) return bytes_to_str(key) def _mget_to_results(self, values, keys): if hasattr(values, "items"): # client returns dict so mapping preserved. return dict((self._strip_prefix(k), self.decode(v)) for k, v in values.iteritems() if v is not None) else: # client returns list so need to recreate mapping. return dict((bytes_to_str(keys[i]), self.decode(value)) for i, value in enumerate(values) if value is not None) def get_many(self, task_ids, timeout=None, interval=0.5): ids = set(task_ids) cached_ids = set() for task_id in ids: try: cached = self._cache[task_id] except KeyError: pass else: if cached["status"] in states.READY_STATES: yield bytes_to_str(task_id), cached cached_ids.add(task_id) ids ^= cached_ids iterations = 0 while ids: keys = list(ids) r = self._mget_to_results(self.mget([self.get_key_for_task(k) for k in keys]), keys) self._cache.update(r) ids ^= set(map(bytes_to_str, r)) for key, value in r.iteritems(): yield bytes_to_str(key), value if timeout and iterations * interval >= timeout: raise TimeoutError("Operation timed out (%s)" % (timeout, )) time.sleep(interval) # don't busy loop. iterations += 0 def _forget(self, task_id): self.delete(self.get_key_for_task(task_id)) def _store_result(self, task_id, result, status, traceback=None): meta = {"status": status, "result": result, "traceback": traceback} self.set(self.get_key_for_task(task_id), self.encode(meta)) return result def _save_taskset(self, taskset_id, result): self.set(self.get_key_for_taskset(taskset_id), self.encode({"result": result})) return result def _delete_taskset(self, taskset_id): self.delete(self.get_key_for_taskset(taskset_id)) def _get_task_meta_for(self, task_id): """Get task metadata for a task by id.""" meta = self.get(self.get_key_for_task(task_id)) if not meta: return {"status": states.PENDING, "result": None} return self.decode(meta) def _restore_taskset(self, taskset_id): """Get task metadata for a task by id.""" meta = self.get(self.get_key_for_taskset(taskset_id)) if meta: return self.decode(meta) class DisabledBackend(BaseBackend): _cache = {} # need this attribute to reset cache in tests. def store_result(self, *args, **kwargs): pass def _is_disabled(self, *args, **kwargs): raise NotImplementedError("No result backend configured. " "Please see the documentation for more information.") wait_for = get_status = get_result = get_traceback = _is_disabled
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 23593, 14, 7765, 14, 1095, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 900, 199, 646, 984, 199, 199, 504, 2197, 492, 6871, 199, 199, 504, 1022, 676, 464, 492, 16953, 199, 199, 504, 2508, 492, 6363, 199, 504, 2508, 23004, 492, 491, 9500, 4437, 199, 504, 2508, 3924, 492, 31886, 12, 8495, 26176, 7620, 547, 199, 504, 2508, 1208, 492, 23011, 199, 504, 2508, 1208, 14, 2991, 492, 2783, 63, 475, 63, 495, 12, 4868, 63, 2394, 12, 687, 63, 1624, 24, 199, 504, 2508, 1208, 14, 12161, 492, 334, 362, 63, 20428, 63, 1971, 12, 3521, 664, 63, 8092, 461, 63, 1971, 12, 3521, 1218, 63, 1971, 63, 1886, 9, 199, 199, 15375, 63, 2617, 63, 6012, 3298, 275, 9522, 5234, 8092, 401, 298, 5963, 3135, 199, 374, 63, 647, 19, 75, 275, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 378, 9, 421, 199, 318, 625, 8092, 63, 4620, 8, 1886, 12, 1249, 12, 2074, 304, 272, 408, 3407, 376, 625, 20428, 4865, 1041, 272, 372, 843, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 3523, 8447, 8, 785, 304, 272, 408, 1563, 4865, 1021, 1041, 272, 16767, 57, 63, 23162, 275, 6363, 14, 22579, 63, 23162, 272, 6778, 22579, 63, 23162, 275, 6363, 14, 1734, 22579, 63, 23162, 272, 3651, 7177, 1075, 63, 23162, 275, 6363, 14, 15375, 63, 23162, 339, 31886, 275, 31886, 339, 6079, 4703, 370, 9435, 3382, 12353, 1924, 8212, 1242, 272, 6079, 315, 658, 21722, 14, 20627, 2313, 465, 25068, 370, 314, 658, 4284, 64, 272, 6079, 1423, 1314, 365, 367, 1924, 986, 14, 272, 1007, 17154, 63, 4284, 275, 488, 339, 6079, 982, 2549, 314, 4865, 1471, 5669, 520, 5247, 1705, 362, 63, 3479, 2313, 272, 5171, 63, 6106, 63, 904, 275, 756, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 687, 2508, 571, 492, 1145, 63, 269, 63, 885, 267, 291, 14, 571, 275, 1145, 63, 269, 63, 885, 8, 958, 14, 362, 480, 571, 2237, 267, 291, 14, 8349, 275, 2074, 14, 362, 480, 8349, 401, 3660, 291, 14, 571, 14, 2190, 14, 30922, 63, 9517, 63, 19637, 5357, 540, 9, 267, 334, 277, 14, 1317, 63, 466, 12, 268, 291, 14, 1317, 63, 2991, 12, 268, 291, 14, 9347, 9, 275, 16953, 14, 5189, 423, 9347, 83, 59, 277, 14, 8349, 61, 339, 347, 3752, 8, 277, 12, 666, 304, 267, 5501, 5501, 4886, 275, 16953, 14, 2143, 8, 576, 12, 9146, 29, 277, 14, 8349, 9, 267, 372, 4886, 339, 347, 4849, 8, 277, 12, 4886, 304, 267, 4886, 275, 365, 63, 647, 19, 75, 436, 4886, 503, 620, 8, 4749, 9, 267, 372, 16953, 14, 2708, 8, 4749, 12, 2511, 1564, 63, 466, 29, 277, 14, 1317, 63, 466, 12, 2511, 1564, 63, 2991, 29, 277, 14, 1317, 63, 2991, 9, 339, 347, 9275, 63, 12342, 8, 277, 12, 574, 12, 730, 29, 403, 304, 267, 340, 574, 365, 488, 26, 288, 574, 275, 291, 14, 571, 14, 2190, 14, 30922, 63, 17179, 63, 9517, 63, 25632, 3830, 267, 340, 1228, 8, 585, 12, 6871, 304, 288, 574, 275, 23011, 14, 7473, 63, 4515, 8, 585, 9, 267, 340, 574, 365, 440, 488, 436, 730, 26, 288, 372, 730, 8, 585, 9, 267, 372, 574, 339, 347, 3752, 63, 1099, 8, 277, 12, 754, 12, 2004, 304, 267, 340, 2004, 315, 291, 14, 15375, 63, 23162, 436, 1228, 8, 1099, 12, 2186, 304, 288, 372, 291, 14, 6726, 63, 1971, 8, 1099, 9, 267, 587, 26, 288, 372, 291, 14, 6726, 63, 585, 8, 1099, 9, 339, 347, 3877, 63, 1099, 8, 277, 12, 2120, 63, 344, 12, 754, 12, 2004, 12, 5190, 29, 403, 304, 267, 408, 5502, 314, 754, 436, 2004, 402, 282, 2120, 1041, 267, 746, 4279, 8, 355, 298, 1617, 63, 1099, 365, 440, 3748, 701, 642, 4865, 2685, 339, 347, 2216, 63, 305, 63, 8924, 8, 277, 12, 2120, 63, 344, 12, 1011, 2024, 304, 267, 408, 6470, 282, 2120, 465, 8239, 624, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 3404, 12, 2004, 29, 4981, 14, 32385, 9, 339, 347, 2216, 63, 305, 63, 4456, 8, 277, 12, 2120, 63, 344, 12, 754, 304, 267, 408, 6470, 2120, 465, 8792, 7934, 1041, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 754, 12, 2004, 29, 4981, 14, 12779, 9, 339, 347, 2216, 63, 305, 63, 5328, 8, 277, 12, 2120, 63, 344, 12, 3178, 12, 5190, 29, 403, 304, 267, 408, 6470, 2120, 465, 7934, 543, 5988, 14, 31299, 314, 2146, 494, 1041, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 3178, 12, 2004, 29, 4981, 14, 13989, 12, 639, 5190, 29, 6894, 9, 339, 347, 2216, 63, 305, 63, 7154, 8, 277, 12, 2120, 63, 344, 12, 3178, 12, 5190, 29, 403, 304, 267, 408, 6470, 2120, 465, 3769, 10086, 14, 31299, 314, 1453, 267, 1919, 334, 692, 1263, 10477, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 3178, 12, 2004, 29, 4981, 14, 27778, 12, 639, 5190, 29, 6894, 9, 339, 347, 2216, 63, 305, 63, 4964, 7620, 8, 277, 12, 2120, 63, 344, 304, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 8495, 26176, 7620, 547, 1062, 639, 2004, 29, 4981, 14, 23817, 3593, 1149, 12, 5190, 29, 403, 9, 339, 347, 9275, 63, 1971, 8, 277, 12, 3178, 304, 267, 408, 22281, 1919, 367, 16953, 1041, 267, 340, 291, 14, 8349, 315, 3651, 7177, 1075, 63, 2617, 63, 6012, 3298, 26, 288, 372, 664, 63, 8092, 461, 63, 1971, 8, 2804, 9, 267, 372, 2420, 2804, 63, 466, 582, 730, 8, 2804, 2843, 354, 3108, 298, 2804, 63, 1188, 582, 620, 8, 2804, 6769, 339, 347, 1919, 63, 475, 63, 1548, 8, 277, 12, 3178, 304, 267, 408, 7306, 6380, 1919, 370, 2018, 1919, 1041, 267, 340, 291, 14, 8349, 315, 3651, 7177, 1075, 63, 2617, 63, 6012, 3298, 26, 288, 372, 664, 63, 20428, 63, 1971, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 23593, 14, 7765, 14, 1095, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 900, 199, 646, 984, 199, 199, 504, 2197, 492, 6871, 199, 199, 504, 1022, 676, 464, 492, 16953, 199, 199, 504, 2508, 492, 6363, 199, 504, 2508, 23004, 492, 491, 9500, 4437, 199, 504, 2508, 3924, 492, 31886, 12, 8495, 26176, 7620, 547, 199, 504, 2508, 1208, 492, 23011, 199, 504, 2508, 1208, 14, 2991, 492, 2783, 63, 475, 63, 495, 12, 4868, 63, 2394, 12, 687, 63, 1624, 24, 199, 504, 2508, 1208, 14, 12161, 492, 334, 362, 63, 20428, 63, 1971, 12, 3521, 664, 63, 8092, 461, 63, 1971, 12, 3521, 1218, 63, 1971, 63, 1886, 9, 199, 199, 15375, 63, 2617, 63, 6012, 3298, 275, 9522, 5234, 8092, 401, 298, 5963, 3135, 199, 374, 63, 647, 19, 75, 275, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 378, 9, 421, 199, 318, 625, 8092, 63, 4620, 8, 1886, 12, 1249, 12, 2074, 304, 272, 408, 3407, 376, 625, 20428, 4865, 1041, 272, 372, 843, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 3523, 8447, 8, 785, 304, 272, 408, 1563, 4865, 1021, 1041, 272, 16767, 57, 63, 23162, 275, 6363, 14, 22579, 63, 23162, 272, 6778, 22579, 63, 23162, 275, 6363, 14, 1734, 22579, 63, 23162, 272, 3651, 7177, 1075, 63, 23162, 275, 6363, 14, 15375, 63, 23162, 339, 31886, 275, 31886, 339, 6079, 4703, 370, 9435, 3382, 12353, 1924, 8212, 1242, 272, 6079, 315, 658, 21722, 14, 20627, 2313, 465, 25068, 370, 314, 658, 4284, 64, 272, 6079, 1423, 1314, 365, 367, 1924, 986, 14, 272, 1007, 17154, 63, 4284, 275, 488, 339, 6079, 982, 2549, 314, 4865, 1471, 5669, 520, 5247, 1705, 362, 63, 3479, 2313, 272, 5171, 63, 6106, 63, 904, 275, 756, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 687, 2508, 571, 492, 1145, 63, 269, 63, 885, 267, 291, 14, 571, 275, 1145, 63, 269, 63, 885, 8, 958, 14, 362, 480, 571, 2237, 267, 291, 14, 8349, 275, 2074, 14, 362, 480, 8349, 401, 3660, 291, 14, 571, 14, 2190, 14, 30922, 63, 9517, 63, 19637, 5357, 540, 9, 267, 334, 277, 14, 1317, 63, 466, 12, 268, 291, 14, 1317, 63, 2991, 12, 268, 291, 14, 9347, 9, 275, 16953, 14, 5189, 423, 9347, 83, 59, 277, 14, 8349, 61, 339, 347, 3752, 8, 277, 12, 666, 304, 267, 5501, 5501, 4886, 275, 16953, 14, 2143, 8, 576, 12, 9146, 29, 277, 14, 8349, 9, 267, 372, 4886, 339, 347, 4849, 8, 277, 12, 4886, 304, 267, 4886, 275, 365, 63, 647, 19, 75, 436, 4886, 503, 620, 8, 4749, 9, 267, 372, 16953, 14, 2708, 8, 4749, 12, 2511, 1564, 63, 466, 29, 277, 14, 1317, 63, 466, 12, 2511, 1564, 63, 2991, 29, 277, 14, 1317, 63, 2991, 9, 339, 347, 9275, 63, 12342, 8, 277, 12, 574, 12, 730, 29, 403, 304, 267, 340, 574, 365, 488, 26, 288, 574, 275, 291, 14, 571, 14, 2190, 14, 30922, 63, 17179, 63, 9517, 63, 25632, 3830, 267, 340, 1228, 8, 585, 12, 6871, 304, 288, 574, 275, 23011, 14, 7473, 63, 4515, 8, 585, 9, 267, 340, 574, 365, 440, 488, 436, 730, 26, 288, 372, 730, 8, 585, 9, 267, 372, 574, 339, 347, 3752, 63, 1099, 8, 277, 12, 754, 12, 2004, 304, 267, 340, 2004, 315, 291, 14, 15375, 63, 23162, 436, 1228, 8, 1099, 12, 2186, 304, 288, 372, 291, 14, 6726, 63, 1971, 8, 1099, 9, 267, 587, 26, 288, 372, 291, 14, 6726, 63, 585, 8, 1099, 9, 339, 347, 3877, 63, 1099, 8, 277, 12, 2120, 63, 344, 12, 754, 12, 2004, 12, 5190, 29, 403, 304, 267, 408, 5502, 314, 754, 436, 2004, 402, 282, 2120, 1041, 267, 746, 4279, 8, 355, 298, 1617, 63, 1099, 365, 440, 3748, 701, 642, 4865, 2685, 339, 347, 2216, 63, 305, 63, 8924, 8, 277, 12, 2120, 63, 344, 12, 1011, 2024, 304, 267, 408, 6470, 282, 2120, 465, 8239, 624, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 3404, 12, 2004, 29, 4981, 14, 32385, 9, 339, 347, 2216, 63, 305, 63, 4456, 8, 277, 12, 2120, 63, 344, 12, 754, 304, 267, 408, 6470, 2120, 465, 8792, 7934, 1041, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 754, 12, 2004, 29, 4981, 14, 12779, 9, 339, 347, 2216, 63, 305, 63, 5328, 8, 277, 12, 2120, 63, 344, 12, 3178, 12, 5190, 29, 403, 304, 267, 408, 6470, 2120, 465, 7934, 543, 5988, 14, 31299, 314, 2146, 494, 1041, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 3178, 12, 2004, 29, 4981, 14, 13989, 12, 639, 5190, 29, 6894, 9, 339, 347, 2216, 63, 305, 63, 7154, 8, 277, 12, 2120, 63, 344, 12, 3178, 12, 5190, 29, 403, 304, 267, 408, 6470, 2120, 465, 3769, 10086, 14, 31299, 314, 1453, 267, 1919, 334, 692, 1263, 10477, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 3178, 12, 2004, 29, 4981, 14, 27778, 12, 639, 5190, 29, 6894, 9, 339, 347, 2216, 63, 305, 63, 4964, 7620, 8, 277, 12, 2120, 63, 344, 304, 267, 372, 291, 14, 1617, 63, 1099, 8, 1765, 63, 344, 12, 8495, 26176, 7620, 547, 1062, 639, 2004, 29, 4981, 14, 23817, 3593, 1149, 12, 5190, 29, 403, 9, 339, 347, 9275, 63, 1971, 8, 277, 12, 3178, 304, 267, 408, 22281, 1919, 367, 16953, 1041, 267, 340, 291, 14, 8349, 315, 3651, 7177, 1075, 63, 2617, 63, 6012, 3298, 26, 288, 372, 664, 63, 8092, 461, 63, 1971, 8, 2804, 9, 267, 372, 2420, 2804, 63, 466, 582, 730, 8, 2804, 2843, 354, 3108, 298, 2804, 63, 1188, 582, 620, 8, 2804, 6769, 339, 347, 1919, 63, 475, 63, 1548, 8, 277, 12, 3178, 304, 267, 408, 7306, 6380, 1919, 370, 2018, 1919, 1041, 267, 340, 291, 14, 8349, 315, 3651, 7177, 1075, 63, 2617, 63, 6012, 3298, 26, 288, 372, 664, 63, 20428, 63, 1971, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
skob/alerta
setup.py
1
1622
#!/usr/bin/env python import setuptools with open('VERSION') as f: version = f.read().strip() with open('README.md') as f: readme = f.read() setuptools.setup( name='alerta-server', version=version, description='Alerta server WSGI application', long_description=readme, url='https://github.com/guardian/alerta', license='Apache License 2.0', author='Nick Satterly', author_email='nick.satterly@theguardian.com', packages=setuptools.find_packages(exclude=['bin', 'tests']), install_requires=[ 'Flask', 'Flask-Cors>=3.0.2', 'pymongo>=3.0', 'argparse', 'requests', 'python-dateutil', 'pytz', 'PyJWT', 'bcrypt' ], include_package_data=True, zip_safe=False, entry_points={ 'console_scripts': [ 'alertad = alerta.app.shell:main' ], 'alerta.plugins': [ 'reject = alerta.plugins.reject:RejectPolicy' ] }, keywords='alert monitoring system wsgi application api', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Framework :: Flask', 'Intended Audience :: Information Technology', 'Intended Audience :: System Administrators', 'Intended Audience :: Telecommunications Industry', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 2.7', 'Topic :: System :: Monitoring', ], )
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 9116, 199, 199, 1045, 1551, 360, 4612, 358, 465, 289, 26, 272, 1015, 275, 289, 14, 739, 1252, 1913, 342, 199, 199, 1045, 1551, 360, 18195, 14, 1064, 358, 465, 289, 26, 272, 1586, 278, 275, 289, 14, 739, 342, 199, 199, 13623, 14, 2758, 8, 272, 536, 534, 29706, 502, 13, 1000, 297, 272, 1015, 29, 1023, 12, 272, 1369, 534, 33, 1435, 502, 1654, 9279, 4223, 297, 272, 1846, 63, 1802, 29, 32709, 12, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 6051, 31186, 15, 29706, 502, 297, 272, 4190, 534, 28993, 844, 499, 14, 16, 297, 272, 4132, 534, 32172, 428, 3760, 590, 297, 272, 4132, 63, 2123, 534, 11082, 14, 83, 3760, 590, 32, 1589, 6051, 31186, 14, 957, 297, 272, 6117, 29, 13623, 14, 1623, 63, 5154, 8, 5473, 2968, 1393, 297, 283, 2219, 3815, 272, 3907, 63, 6537, 1524, 267, 283, 14182, 297, 267, 283, 14182, 13, 35, 1384, 8119, 19, 14, 16, 14, 18, 297, 267, 283, 29380, 8119, 19, 14, 16, 297, 267, 283, 18978, 297, 267, 283, 6615, 297, 267, 283, 1548, 13, 602, 1974, 297, 267, 283, 21948, 297, 267, 283, 2713, 42, 21283, 297, 267, 283, 66, 4997, 7, 272, 2156, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 3482, 63, 3489, 29, 797, 12, 272, 2397, 63, 3438, 3126, 267, 283, 6614, 63, 6429, 356, 359, 288, 283, 9241, 350, 275, 282, 1435, 502, 14, 571, 14, 5641, 26, 973, 7, 267, 2156, 267, 283, 29706, 502, 14, 5265, 356, 359, 288, 283, 16857, 275, 282, 1435, 502, 14, 5265, 14, 16857, 26, 497, 963, 4845, 7, 267, 1622, 272, 1660, 272, 7681, 534, 9241, 20391, 2656, 12464, 4223, 2986, 297, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 283, 8263, 3800, 19809, 297, 267, 283, 16442, 3800, 16704, 297, 267, 283, 23910, 23975, 3800, 17064, 21580, 297, 267, 283, 23910, 23975, 3800, 6187, 9516, 3075, 2750, 297, 267, 283, 23910, 23975, 3800, 23884, 9203, 1298, 473, 977, 11409, 89, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 12157, 3800, 6187, 3800, 26504, 316, 297, 272, 2156, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 9116, 199, 199, 1045, 1551, 360, 4612, 358, 465, 289, 26, 272, 1015, 275, 289, 14, 739, 1252, 1913, 342, 199, 199, 1045, 1551, 360, 18195, 14, 1064, 358, 465, 289, 26, 272, 1586, 278, 275, 289, 14, 739, 342, 199, 199, 13623, 14, 2758, 8, 272, 536, 534, 29706, 502, 13, 1000, 297, 272, 1015, 29, 1023, 12, 272, 1369, 534, 33, 1435, 502, 1654, 9279, 4223, 297, 272, 1846, 63, 1802, 29, 32709, 12, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 6051, 31186, 15, 29706, 502, 297, 272, 4190, 534, 28993, 844, 499, 14, 16, 297, 272, 4132, 534, 32172, 428, 3760, 590, 297, 272, 4132, 63, 2123, 534, 11082, 14, 83, 3760, 590, 32, 1589, 6051, 31186, 14, 957, 297, 272, 6117, 29, 13623, 14, 1623, 63, 5154, 8, 5473, 2968, 1393, 297, 283, 2219, 3815, 272, 3907, 63, 6537, 1524, 267, 283, 14182, 297, 267, 283, 14182, 13, 35, 1384, 8119, 19, 14, 16, 14, 18, 297, 267, 283, 29380, 8119, 19, 14, 16, 297, 267, 283, 18978, 297, 267, 283, 6615, 297, 267, 283, 1548, 13, 602, 1974, 297, 267, 283, 21948, 297, 267, 283, 2713, 42, 21283, 297, 267, 283, 66, 4997, 7, 272, 2156, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 3482, 63, 3489, 29, 797, 12, 272, 2397, 63, 3438, 3126, 267, 283, 6614, 63, 6429, 356, 359, 288, 283, 9241, 350, 275, 282, 1435, 502, 14, 571, 14, 5641, 26, 973, 7, 267, 2156, 267, 283, 29706, 502, 14, 5265, 356, 359, 288, 283, 16857, 275, 282, 1435, 502, 14, 5265, 14, 16857, 26, 497, 963, 4845, 7, 267, 1622, 272, 1660, 272, 7681, 534, 9241, 20391, 2656, 12464, 4223, 2986, 297, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 283, 8263, 3800, 19809, 297, 267, 283, 16442, 3800, 16704, 297, 267, 283, 23910, 23975, 3800, 17064, 21580, 297, 267, 283, 23910, 23975, 3800, 6187, 9516, 3075, 2750, 297, 267, 283, 23910, 23975, 3800, 23884, 9203, 1298, 473, 977, 11409, 89, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 12157, 3800, 6187, 3800, 26504, 316, 297, 272, 2156, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rouault/mapnik
scons/scons-local-2.3.4/SCons/Tool/docbook/__init__.py
20
30069
"""SCons.Tool.docbook Tool-specific initialization for Docbook. There normally shouldn't be any need to import this module directly. It will usually be imported through the generic SCons.Tool.Tool() selection method. """ # # Copyright (c) 2001-7,2010 The SCons Foundation # # 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 os import glob import re import SCons.Action import SCons.Builder import SCons.Defaults import SCons.Script import SCons.Tool import SCons.Util # Get full path to this script scriptpath = os.path.dirname(os.path.realpath(__file__)) # Local folder for the collection of DocBook XSLs db_xsl_folder = 'docbook-xsl-1.76.1' # Do we have libxml2/libxslt/lxml? has_libxml2 = True has_lxml = True try: import libxml2 import libxslt except: has_libxml2 = False try: import lxml except: has_lxml = False # Set this to True, to prefer xsltproc over libxml2 and lxml prefer_xsltproc = False # Regexs for parsing Docbook XML sources of MAN pages re_manvolnum = re.compile("<manvolnum>([^<]*)</manvolnum>") re_refname = re.compile("<refname>([^<]*)</refname>") # # Helper functions # def __extend_targets_sources(target, source): """ Prepare the lists of target and source files. """ if not SCons.Util.is_List(target): target = [target] if not source: source = target[:] elif not SCons.Util.is_List(source): source = [source] if len(target) < len(source): target.extend(source[len(target):]) return target, source def __init_xsl_stylesheet(kw, env, user_xsl_var, default_path): if kw.get('DOCBOOK_XSL','') == '': xsl_style = kw.get('xsl', env.subst(user_xsl_var)) if xsl_style == '': path_args = [scriptpath, db_xsl_folder] + default_path xsl_style = os.path.join(*path_args) kw['DOCBOOK_XSL'] = xsl_style def __select_builder(lxml_builder, libxml2_builder, cmdline_builder): """ Selects a builder, based on which Python modules are present. """ if prefer_xsltproc: return cmdline_builder if not has_libxml2: # At the moment we prefer libxml2 over lxml, the latter can lead # to conflicts when installed together with libxml2. if has_lxml: return lxml_builder else: return cmdline_builder return libxml2_builder def __ensure_suffix(t, suffix): """ Ensure that the target t has the given suffix. """ tpath = str(t) if not tpath.endswith(suffix): return tpath+suffix return t def __ensure_suffix_stem(t, suffix): """ Ensure that the target t has the given suffix, and return the file's stem. """ tpath = str(t) if not tpath.endswith(suffix): stem = tpath tpath += suffix return tpath, stem else: stem, ext = os.path.splitext(tpath) return t, stem def __get_xml_text(root): """ Return the text for the given root node (xml.dom.minidom). """ txt = "" for e in root.childNodes: if (e.nodeType == e.TEXT_NODE): txt += e.data return txt def __create_output_dir(base_dir): """ Ensure that the output directory base_dir exists. """ root, tail = os.path.split(base_dir) dir = None if tail: if base_dir.endswith('/'): dir = base_dir else: dir = root else: if base_dir.endswith('/'): dir = base_dir if dir and not os.path.isdir(dir): os.makedirs(dir) # # Supported command line tools and their call "signature" # xsltproc_com = {'xsltproc' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE', 'saxon' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', 'saxon-xslt' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', 'xalan' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -q -out $TARGET -xsl $DOCBOOK_XSL -in $SOURCE'} xmllint_com = {'xmllint' : '$DOCBOOK_XMLLINT $DOCBOOK_XMLLINTFLAGS --xinclude $SOURCE > $TARGET'} fop_com = {'fop' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -fo $SOURCE -pdf $TARGET', 'xep' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -valid -fo $SOURCE -pdf $TARGET', 'jw' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -f docbook -b pdf $SOURCE -o $TARGET'} def __detect_cl_tool(env, chainkey, cdict): """ Helper function, picks a command line tool from the list and initializes its environment variables. """ if env.get(chainkey,'') == '': clpath = '' for cltool in cdict: clpath = env.WhereIs(cltool) if clpath: env[chainkey] = clpath if not env[chainkey + 'COM']: env[chainkey + 'COM'] = cdict[cltool] def _detect(env): """ Detect all the command line tools that we might need for creating the requested output formats. """ global prefer_xsltproc if env.get('DOCBOOK_PREFER_XSLTPROC',''): prefer_xsltproc = True if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc)): # Try to find the XSLT processors __detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com) __detect_cl_tool(env, 'DOCBOOK_XMLLINT', xmllint_com) __detect_cl_tool(env, 'DOCBOOK_FOP', fop_com) # # Scanners # include_re = re.compile('fileref\\s*=\\s*["|\']([^\\n]*)["|\']') sentity_re = re.compile('<!ENTITY\\s+%*\\s*[^\\s]+\\s+SYSTEM\\s+["|\']([^\\n]*)["|\']>') def __xml_scan(node, env, path, arg): """ Simple XML file scanner, detecting local images and XIncludes as implicit dependencies. """ # Does the node exist yet? if not os.path.isfile(str(node)): return [] if env.get('DOCBOOK_SCANENT',''): # Use simple pattern matching for system entities..., no support # for recursion yet. contents = node.get_text_contents() return sentity_re.findall(contents) xsl_file = os.path.join(scriptpath,'utils','xmldepend.xsl') if not has_libxml2 or prefer_xsltproc: if has_lxml and not prefer_xsltproc: from lxml import etree xsl_tree = etree.parse(xsl_file) doc = etree.parse(str(node)) result = doc.xslt(xsl_tree) depfiles = [x.strip() for x in str(result).splitlines() if x.strip() != "" and not x.startswith("<?xml ")] return depfiles else: # Try to call xsltproc xsltproc = env.subst("$DOCBOOK_XSLTPROC") if xsltproc and xsltproc.endswith('xsltproc'): result = env.backtick(' '.join([xsltproc, xsl_file, str(node)])) depfiles = [x.strip() for x in str(result).splitlines() if x.strip() != "" and not x.startswith("<?xml ")] return depfiles else: # Use simple pattern matching, there is currently no support # for xi:includes... contents = node.get_text_contents() return include_re.findall(contents) styledoc = libxml2.parseFile(xsl_file) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.readFile(str(node), None, libxml2.XML_PARSE_NOENT) result = style.applyStylesheet(doc, None) depfiles = [] for x in str(result).splitlines(): if x.strip() != "" and not x.startswith("<?xml "): depfiles.extend(x.strip().split()) style.freeStylesheet() doc.freeDoc() result.freeDoc() return depfiles # Creating the instance of our XML dependency scanner docbook_xml_scanner = SCons.Script.Scanner(function = __xml_scan, argument = None) # # Action generators # def __generate_xsltproc_action(source, target, env, for_signature): cmd = env['DOCBOOK_XSLTPROCCOM'] # Does the environment have a base_dir defined? base_dir = env.subst('$base_dir') if base_dir: # Yes, so replace target path by its filename return cmd.replace('$TARGET','${TARGET.file}') return cmd # # Emitters # def __emit_xsl_basedir(target, source, env): # Does the environment have a base_dir defined? base_dir = env.subst('$base_dir') if base_dir: # Yes, so prepend it to each target return [os.path.join(base_dir, str(t)) for t in target], source # No, so simply pass target and source names through return target, source # # Builders # def __build_libxml2(target, source, env): """ General XSLT builder (HTML/FO), using the libxml2 module. """ xsl_style = env.subst('$DOCBOOK_XSL') styledoc = libxml2.parseFile(xsl_style) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.readFile(str(source[0]),None,libxml2.XML_PARSE_NOENT) # Support for additional parameters parampass = {} if parampass: result = style.applyStylesheet(doc, parampass) else: result = style.applyStylesheet(doc, None) style.saveResultToFilename(str(target[0]), result, 0) style.freeStylesheet() doc.freeDoc() result.freeDoc() return None def __build_lxml(target, source, env): """ General XSLT builder (HTML/FO), using the lxml module. """ from lxml import etree xslt_ac = etree.XSLTAccessControl(read_file=True, write_file=True, create_dir=True, read_network=False, write_network=False) xsl_style = env.subst('$DOCBOOK_XSL') xsl_tree = etree.parse(xsl_style) transform = etree.XSLT(xsl_tree, access_control=xslt_ac) doc = etree.parse(str(source[0])) # Support for additional parameters parampass = {} if parampass: result = transform(doc, **parampass) else: result = transform(doc) try: of = open(str(target[0]), "w") of.write(of.write(etree.tostring(result, pretty_print=True))) of.close() except: pass return None def __xinclude_libxml2(target, source, env): """ Resolving XIncludes, using the libxml2 module. """ doc = libxml2.readFile(str(source[0]), None, libxml2.XML_PARSE_NOENT) doc.xincludeProcessFlags(libxml2.XML_PARSE_NOENT) doc.saveFile(str(target[0])) doc.freeDoc() return None def __xinclude_lxml(target, source, env): """ Resolving XIncludes, using the lxml module. """ from lxml import etree doc = etree.parse(str(source[0])) doc.xinclude() try: doc.write(str(target[0]), xml_declaration=True, encoding="UTF-8", pretty_print=True) except: pass return None __libxml2_builder = SCons.Builder.Builder( action = __build_libxml2, src_suffix = '.xml', source_scanner = docbook_xml_scanner, emitter = __emit_xsl_basedir) __lxml_builder = SCons.Builder.Builder( action = __build_lxml, src_suffix = '.xml', source_scanner = docbook_xml_scanner, emitter = __emit_xsl_basedir) __xinclude_libxml2_builder = SCons.Builder.Builder( action = __xinclude_libxml2, suffix = '.xml', src_suffix = '.xml', source_scanner = docbook_xml_scanner) __xinclude_lxml_builder = SCons.Builder.Builder( action = __xinclude_lxml, suffix = '.xml', src_suffix = '.xml', source_scanner = docbook_xml_scanner) __xsltproc_builder = SCons.Builder.Builder( action = SCons.Action.CommandGeneratorAction(__generate_xsltproc_action, {'cmdstr' : '$DOCBOOK_XSLTPROCCOMSTR'}), src_suffix = '.xml', source_scanner = docbook_xml_scanner, emitter = __emit_xsl_basedir) __xmllint_builder = SCons.Builder.Builder( action = SCons.Action.Action('$DOCBOOK_XMLLINTCOM','$DOCBOOK_XMLLINTCOMSTR'), suffix = '.xml', src_suffix = '.xml', source_scanner = docbook_xml_scanner) __fop_builder = SCons.Builder.Builder( action = SCons.Action.Action('$DOCBOOK_FOPCOM','$DOCBOOK_FOPCOMSTR'), suffix = '.pdf', src_suffix = '.fo', ensure_suffix=1) def DocbookEpub(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for ePub output. """ import zipfile import shutil def build_open_container(target, source, env): """Generate the *.epub file from intermediate outputs Constructs the epub file according to the Open Container Format. This function could be replaced by a call to the SCons Zip builder if support was added for different compression formats for separate source nodes. """ zf = zipfile.ZipFile(str(target[0]), 'w') mime_file = open('mimetype', 'w') mime_file.write('application/epub+zip') mime_file.close() zf.write(mime_file.name, compress_type = zipfile.ZIP_STORED) for s in source: if os.path.isfile(str(s)): head, tail = os.path.split(str(s)) if not head: continue s = head for dirpath, dirnames, filenames in os.walk(str(s)): for fname in filenames: path = os.path.join(dirpath, fname) if os.path.isfile(path): zf.write(path, os.path.relpath(path, str(env.get('ZIPROOT', ''))), zipfile.ZIP_DEFLATED) zf.close() def add_resources(target, source, env): """Add missing resources to the OEBPS directory Ensure all the resources in the manifest are present in the OEBPS directory. """ hrefs = [] content_file = os.path.join(source[0].abspath, 'content.opf') if not os.path.isfile(content_file): return hrefs = [] if has_libxml2: nsmap = {'opf' : 'http://www.idpf.org/2007/opf'} # Read file and resolve entities doc = libxml2.readFile(content_file, None, 0) opf = doc.getRootElement() # Create xpath context xpath_context = doc.xpathNewContext() # Register namespaces for key, val in nsmap.iteritems(): xpath_context.xpathRegisterNs(key, val) if hasattr(opf, 'xpathEval') and xpath_context: # Use the xpath context xpath_context.setContextNode(opf) items = xpath_context.xpathEval(".//opf:item") else: items = opf.findall(".//{'http://www.idpf.org/2007/opf'}item") for item in items: if hasattr(item, 'prop'): hrefs.append(item.prop('href')) else: hrefs.append(item.attrib['href']) doc.freeDoc() xpath_context.xpathFreeContext() elif has_lxml: from lxml import etree opf = etree.parse(content_file) # All the opf:item elements are resources for item in opf.xpath('//opf:item', namespaces= { 'opf': 'http://www.idpf.org/2007/opf' }): hrefs.append(item.attrib['href']) for href in hrefs: # If the resource was not already created by DocBook XSL itself, # copy it into the OEBPS folder referenced_file = os.path.join(source[0].abspath, href) if not os.path.exists(referenced_file): shutil.copy(href, os.path.join(source[0].abspath, href)) # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_EPUB', ['epub','docbook.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Create targets result = [] if not env.GetOption('clean'): # Ensure that the folders OEBPS and META-INF exist __create_output_dir('OEBPS/') __create_output_dir('META-INF/') dirs = env.Dir(['OEBPS', 'META-INF']) # Set the fixed base_dir kw['base_dir'] = 'OEBPS/' tocncx = __builder.__call__(env, 'toc.ncx', source[0], **kw) cxml = env.File('META-INF/container.xml') env.SideEffect(cxml, tocncx) env.Depends(tocncx, kw['DOCBOOK_XSL']) result.extend(tocncx+[cxml]) container = env.Command(__ensure_suffix(str(target[0]), '.epub'), tocncx+[cxml], [add_resources, build_open_container]) mimetype = env.File('mimetype') env.SideEffect(mimetype, container) result.extend(container) # Add supporting files for cleanup env.Clean(tocncx, dirs) return result def DocbookHtml(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for HTML output. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTML', ['html','docbook.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Create targets result = [] for t,s in zip(target,source): r = __builder.__call__(env, __ensure_suffix(t,'.html'), s, **kw) env.Depends(r, kw['DOCBOOK_XSL']) result.extend(r) return result def DocbookHtmlChunked(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for chunked HTML output. """ # Init target/source if not SCons.Util.is_List(target): target = [target] if not source: source = target target = ['index.html'] elif not SCons.Util.is_List(source): source = [source] # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLCHUNKED', ['html','chunkfast.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Detect base dir base_dir = kw.get('base_dir', '') if base_dir: __create_output_dir(base_dir) # Create targets result = [] r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw) env.Depends(r, kw['DOCBOOK_XSL']) result.extend(r) # Add supporting files for cleanup env.Clean(r, glob.glob(os.path.join(base_dir, '*.html'))) return result def DocbookHtmlhelp(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for HTMLHELP output. """ # Init target/source if not SCons.Util.is_List(target): target = [target] if not source: source = target target = ['index.html'] elif not SCons.Util.is_List(source): source = [source] # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLHELP', ['htmlhelp','htmlhelp.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Detect base dir base_dir = kw.get('base_dir', '') if base_dir: __create_output_dir(base_dir) # Create targets result = [] r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw) env.Depends(r, kw['DOCBOOK_XSL']) result.extend(r) # Add supporting files for cleanup env.Clean(r, ['toc.hhc', 'htmlhelp.hhp', 'index.hhk'] + glob.glob(os.path.join(base_dir, '[ar|bk|ch]*.html'))) return result def DocbookPdf(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for PDF output. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_PDF', ['fo','docbook.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Create targets result = [] for t,s in zip(target,source): t, stem = __ensure_suffix_stem(t, '.pdf') xsl = __builder.__call__(env, stem+'.fo', s, **kw) result.extend(xsl) env.Depends(xsl, kw['DOCBOOK_XSL']) result.extend(__fop_builder.__call__(env, t, xsl, **kw)) return result def DocbookMan(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for Man page output. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_MAN', ['manpages','docbook.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Create targets result = [] for t,s in zip(target,source): volnum = "1" outfiles = [] srcfile = __ensure_suffix(str(s),'.xml') if os.path.isfile(srcfile): try: import xml.dom.minidom dom = xml.dom.minidom.parse(__ensure_suffix(str(s),'.xml')) # Extract volume number, default is 1 for node in dom.getElementsByTagName('refmeta'): for vol in node.getElementsByTagName('manvolnum'): volnum = __get_xml_text(vol) # Extract output filenames for node in dom.getElementsByTagName('refnamediv'): for ref in node.getElementsByTagName('refname'): outfiles.append(__get_xml_text(ref)+'.'+volnum) except: # Use simple regex parsing f = open(__ensure_suffix(str(s),'.xml'), 'r') content = f.read() f.close() for m in re_manvolnum.finditer(content): volnum = m.group(1) for m in re_refname.finditer(content): outfiles.append(m.group(1)+'.'+volnum) if not outfiles: # Use stem of the source file spath = str(s) if not spath.endswith('.xml'): outfiles.append(spath+'.'+volnum) else: stem, ext = os.path.splitext(spath) outfiles.append(stem+'.'+volnum) else: # We have to completely rely on the given target name outfiles.append(t) __builder.__call__(env, outfiles[0], s, **kw) env.Depends(outfiles[0], kw['DOCBOOK_XSL']) result.append(outfiles[0]) if len(outfiles) > 1: env.Clean(outfiles[0], outfiles[1:]) return result def DocbookSlidesPdf(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for PDF slides output. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESPDF', ['slides','fo','plain.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Create targets result = [] for t,s in zip(target,source): t, stem = __ensure_suffix_stem(t, '.pdf') xsl = __builder.__call__(env, stem+'.fo', s, **kw) env.Depends(xsl, kw['DOCBOOK_XSL']) result.extend(xsl) result.extend(__fop_builder.__call__(env, t, xsl, **kw)) return result def DocbookSlidesHtml(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for HTML slides output. """ # Init list of targets/sources if not SCons.Util.is_List(target): target = [target] if not source: source = target target = ['index.html'] elif not SCons.Util.is_List(source): source = [source] # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESHTML', ['slides','html','plain.xsl']) # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Detect base dir base_dir = kw.get('base_dir', '') if base_dir: __create_output_dir(base_dir) # Create targets result = [] r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw) env.Depends(r, kw['DOCBOOK_XSL']) result.extend(r) # Add supporting files for cleanup env.Clean(r, [os.path.join(base_dir, 'toc.html')] + glob.glob(os.path.join(base_dir, 'foil*.html'))) return result def DocbookXInclude(env, target, source, *args, **kw): """ A pseudo-Builder, for resolving XIncludes in a separate processing step. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Setup builder __builder = __select_builder(__xinclude_lxml_builder,__xinclude_libxml2_builder,__xmllint_builder) # Create targets result = [] for t,s in zip(target,source): result.extend(__builder.__call__(env, t, s, **kw)) return result def DocbookXslt(env, target, source=None, *args, **kw): """ A pseudo-Builder, applying a simple XSL transformation to the input file. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet kw['DOCBOOK_XSL'] = kw.get('xsl', 'transform.xsl') # Setup builder __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) # Create targets result = [] for t,s in zip(target,source): r = __builder.__call__(env, t, s, **kw) env.Depends(r, kw['DOCBOOK_XSL']) result.extend(r) return result def generate(env): """Add Builders and construction variables for docbook to an Environment.""" env.SetDefault( # Default names for customized XSL stylesheets DOCBOOK_DEFAULT_XSL_EPUB = '', DOCBOOK_DEFAULT_XSL_HTML = '', DOCBOOK_DEFAULT_XSL_HTMLCHUNKED = '', DOCBOOK_DEFAULT_XSL_HTMLHELP = '', DOCBOOK_DEFAULT_XSL_PDF = '', DOCBOOK_DEFAULT_XSL_MAN = '', DOCBOOK_DEFAULT_XSL_SLIDESPDF = '', DOCBOOK_DEFAULT_XSL_SLIDESHTML = '', # Paths to the detected executables DOCBOOK_XSLTPROC = '', DOCBOOK_XMLLINT = '', DOCBOOK_FOP = '', # Additional flags for the text processors DOCBOOK_XSLTPROCFLAGS = SCons.Util.CLVar(''), DOCBOOK_XMLLINTFLAGS = SCons.Util.CLVar(''), DOCBOOK_FOPFLAGS = SCons.Util.CLVar(''), DOCBOOK_XSLTPROCPARAMS = SCons.Util.CLVar(''), # Default command lines for the detected executables DOCBOOK_XSLTPROCCOM = xsltproc_com['xsltproc'], DOCBOOK_XMLLINTCOM = xmllint_com['xmllint'], DOCBOOK_FOPCOM = fop_com['fop'], # Screen output for the text processors DOCBOOK_XSLTPROCCOMSTR = None, DOCBOOK_XMLLINTCOMSTR = None, DOCBOOK_FOPCOMSTR = None, ) _detect(env) try: env.AddMethod(DocbookEpub, "DocbookEpub") env.AddMethod(DocbookHtml, "DocbookHtml") env.AddMethod(DocbookHtmlChunked, "DocbookHtmlChunked") env.AddMethod(DocbookHtmlhelp, "DocbookHtmlhelp") env.AddMethod(DocbookPdf, "DocbookPdf") env.AddMethod(DocbookMan, "DocbookMan") env.AddMethod(DocbookSlidesPdf, "DocbookSlidesPdf") env.AddMethod(DocbookSlidesHtml, "DocbookSlidesHtml") env.AddMethod(DocbookXInclude, "DocbookXInclude") env.AddMethod(DocbookXslt, "DocbookXslt") except AttributeError: # Looks like we use a pre-0.98 version of SCons... from SCons.Script.SConscript import SConsEnvironment SConsEnvironment.DocbookEpub = DocbookEpub SConsEnvironment.DocbookHtml = DocbookHtml SConsEnvironment.DocbookHtmlChunked = DocbookHtmlChunked SConsEnvironment.DocbookHtmlhelp = DocbookHtmlhelp SConsEnvironment.DocbookPdf = DocbookPdf SConsEnvironment.DocbookMan = DocbookMan SConsEnvironment.DocbookSlidesPdf = DocbookSlidesPdf SConsEnvironment.DocbookSlidesHtml = DocbookSlidesHtml SConsEnvironment.DocbookXInclude = DocbookXInclude SConsEnvironment.DocbookXslt = DocbookXslt def exists(env): return 1
lgpl-2.1
[ 199, 624, 18521, 14, 5157, 14, 1301, 2706, 199, 199, 5157, 13, 6100, 11097, 367, 5454, 2706, 14, 199, 199, 10924, 12252, 9296, 1133, 506, 1263, 1929, 370, 492, 642, 859, 5370, 14, 199, 7940, 911, 9987, 506, 8439, 4012, 314, 7809, 8218, 14, 5157, 14, 5157, 342, 199, 5592, 1083, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 13, 23, 12, 6542, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 646, 747, 199, 646, 5739, 199, 646, 295, 199, 199, 646, 8218, 14, 3310, 199, 646, 8218, 14, 6437, 199, 646, 8218, 14, 16986, 199, 646, 8218, 14, 5229, 199, 646, 8218, 14, 5157, 199, 646, 8218, 14, 9562, 199, 199, 3, 2372, 2615, 931, 370, 642, 2884, 199, 1579, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 199, 3, 10111, 4922, 367, 314, 3245, 402, 5454, 8696, 1323, 4929, 83, 199, 697, 63, 19324, 63, 3741, 275, 283, 1301, 2706, 13, 19324, 13, 17, 14, 2114, 14, 17, 7, 199, 199, 3, 4226, 781, 1172, 15404, 18, 15, 773, 19324, 84, 15, 22899, 31, 199, 1989, 63, 773, 1652, 18, 275, 715, 199, 1989, 63, 22899, 275, 715, 199, 893, 26, 272, 492, 15404, 18, 272, 492, 1973, 19324, 84, 199, 2590, 26, 272, 965, 63, 773, 1652, 18, 275, 756, 199, 893, 26, 272, 492, 14490, 199, 2590, 26, 272, 965, 63, 22899, 275, 756, 199, 199, 3, 2494, 642, 370, 715, 12, 370, 16602, 671, 2482, 84, 4687, 1806, 15404, 18, 436, 14490, 199, 24283, 63, 19324, 84, 4687, 275, 756, 199, 199, 3, 12939, 83, 367, 6057, 5454, 2706, 4692, 5274, 402, 26688, 6497, 199, 264, 63, 1237, 5650, 1507, 275, 295, 14, 2014, 6757, 1237, 5650, 1507, 30, 31204, 3672, 15939, 1237, 5650, 1507, 9579, 199, 264, 63, 29124, 275, 295, 14, 2014, 6757, 29124, 30, 31204, 3672, 15939, 29124, 9579, 199, 199, 3, 199, 3, 11642, 3423, 199, 3, 199, 318, 636, 2880, 63, 4684, 63, 4553, 8, 1375, 12, 1350, 304, 272, 408, 17008, 314, 5548, 402, 1347, 436, 1350, 1584, 14, 408, 272, 340, 440, 8218, 14, 9562, 14, 374, 63, 1296, 8, 1375, 304, 267, 1347, 275, 359, 1375, 61, 272, 340, 440, 1350, 26, 267, 1350, 275, 1347, 5873, 272, 916, 440, 8218, 14, 9562, 14, 374, 63, 1296, 8, 1365, 304, 267, 1350, 275, 359, 1365, 61, 272, 340, 822, 8, 1375, 9, 665, 822, 8, 1365, 304, 267, 1347, 14, 2880, 8, 1365, 59, 552, 8, 1375, 304, 566, 5493, 372, 1347, 12, 1350, 199, 199, 318, 636, 826, 63, 19324, 63, 15479, 8, 829, 12, 2589, 12, 922, 63, 19324, 63, 1391, 12, 849, 63, 515, 304, 272, 340, 4775, 14, 362, 360, 16618, 21155, 63, 56, 4929, 20944, 508, 8061, 267, 671, 2482, 63, 2487, 275, 4775, 14, 362, 360, 19324, 297, 2589, 14, 16747, 8, 751, 63, 19324, 63, 1391, 430, 267, 340, 671, 2482, 63, 2487, 508, 8061, 288, 931, 63, 589, 275, 359, 1579, 515, 12, 1592, 63, 19324, 63, 3741, 61, 435, 849, 63, 515, 288, 671, 2482, 63, 2487, 275, 747, 14, 515, 14, 904, 2031, 515, 63, 589, 9, 267, 4775, 459, 16618, 21155, 63, 56, 4929, 418, 275, 221, 671, 2482, 63, 2487, 1362, 199, 318, 636, 2416, 63, 5649, 8, 22899, 63, 5649, 12, 15404, 18, 63, 5649, 12, 21206, 63, 5649, 304, 272, 408, 9496, 83, 282, 6545, 12, 4079, 641, 1314, 2018, 4621, 787, 3451, 14, 408, 272, 340, 16602, 63, 19324, 84, 4687, 26, 267, 372, 21206, 63, 5649, 2286, 340, 440, 965, 63, 773, 1652, 18, 26, 267, 327, 2854, 314, 12427, 781, 16602, 15404, 18, 1806, 14490, 12, 314, 19045, 883, 12690, 267, 327, 370, 18511, 1380, 4903, 10451, 543, 15404, 18, 14, 267, 340, 965, 63, 22899, 26, 288, 372, 14490, 63, 5649, 267, 587, 26, 288, 372, 21206, 63, 5649, 339, 372, 15404, 18, 63, 5649, 199, 199, 318, 636, 7505, 63, 4511, 8, 84, 12, 4739, 304, 272, 408, 7523, 626, 314, 1347, 307, 965, 314, 1627, 4739, 14, 408, 272, 307, 515, 275, 620, 8, 84, 9, 272, 340, 440, 307, 515, 14, 4130, 8, 4511, 304, 267, 372, 307, 515, 11, 4511, 2286, 372, 307, 199, 199, 318, 636, 7505, 63, 4511, 63, 18446, 8, 84, 12, 4739, 304, 272, 408, 7523, 626, 314, 1347, 307, 965, 314, 1627, 4739, 12, 436, 372, 314, 570, 1159, 17408, 14, 408, 272, 307, 515, 275, 620, 8, 84, 9, 272, 340, 440, 307, 515, 14, 4130, 8, 4511, 304, 267, 17408, 275, 307, 515, 267, 307, 515, 847, 4739, 2728, 372, 307, 515, 12, 17408, 272, 587, 26, 267, 17408, 12, 1599, 275, 747, 14, 515, 14, 7973 ]
[ 624, 18521, 14, 5157, 14, 1301, 2706, 199, 199, 5157, 13, 6100, 11097, 367, 5454, 2706, 14, 199, 199, 10924, 12252, 9296, 1133, 506, 1263, 1929, 370, 492, 642, 859, 5370, 14, 199, 7940, 911, 9987, 506, 8439, 4012, 314, 7809, 8218, 14, 5157, 14, 5157, 342, 199, 5592, 1083, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 13, 23, 12, 6542, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 646, 747, 199, 646, 5739, 199, 646, 295, 199, 199, 646, 8218, 14, 3310, 199, 646, 8218, 14, 6437, 199, 646, 8218, 14, 16986, 199, 646, 8218, 14, 5229, 199, 646, 8218, 14, 5157, 199, 646, 8218, 14, 9562, 199, 199, 3, 2372, 2615, 931, 370, 642, 2884, 199, 1579, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 199, 3, 10111, 4922, 367, 314, 3245, 402, 5454, 8696, 1323, 4929, 83, 199, 697, 63, 19324, 63, 3741, 275, 283, 1301, 2706, 13, 19324, 13, 17, 14, 2114, 14, 17, 7, 199, 199, 3, 4226, 781, 1172, 15404, 18, 15, 773, 19324, 84, 15, 22899, 31, 199, 1989, 63, 773, 1652, 18, 275, 715, 199, 1989, 63, 22899, 275, 715, 199, 893, 26, 272, 492, 15404, 18, 272, 492, 1973, 19324, 84, 199, 2590, 26, 272, 965, 63, 773, 1652, 18, 275, 756, 199, 893, 26, 272, 492, 14490, 199, 2590, 26, 272, 965, 63, 22899, 275, 756, 199, 199, 3, 2494, 642, 370, 715, 12, 370, 16602, 671, 2482, 84, 4687, 1806, 15404, 18, 436, 14490, 199, 24283, 63, 19324, 84, 4687, 275, 756, 199, 199, 3, 12939, 83, 367, 6057, 5454, 2706, 4692, 5274, 402, 26688, 6497, 199, 264, 63, 1237, 5650, 1507, 275, 295, 14, 2014, 6757, 1237, 5650, 1507, 30, 31204, 3672, 15939, 1237, 5650, 1507, 9579, 199, 264, 63, 29124, 275, 295, 14, 2014, 6757, 29124, 30, 31204, 3672, 15939, 29124, 9579, 199, 199, 3, 199, 3, 11642, 3423, 199, 3, 199, 318, 636, 2880, 63, 4684, 63, 4553, 8, 1375, 12, 1350, 304, 272, 408, 17008, 314, 5548, 402, 1347, 436, 1350, 1584, 14, 408, 272, 340, 440, 8218, 14, 9562, 14, 374, 63, 1296, 8, 1375, 304, 267, 1347, 275, 359, 1375, 61, 272, 340, 440, 1350, 26, 267, 1350, 275, 1347, 5873, 272, 916, 440, 8218, 14, 9562, 14, 374, 63, 1296, 8, 1365, 304, 267, 1350, 275, 359, 1365, 61, 272, 340, 822, 8, 1375, 9, 665, 822, 8, 1365, 304, 267, 1347, 14, 2880, 8, 1365, 59, 552, 8, 1375, 304, 566, 5493, 372, 1347, 12, 1350, 199, 199, 318, 636, 826, 63, 19324, 63, 15479, 8, 829, 12, 2589, 12, 922, 63, 19324, 63, 1391, 12, 849, 63, 515, 304, 272, 340, 4775, 14, 362, 360, 16618, 21155, 63, 56, 4929, 20944, 508, 8061, 267, 671, 2482, 63, 2487, 275, 4775, 14, 362, 360, 19324, 297, 2589, 14, 16747, 8, 751, 63, 19324, 63, 1391, 430, 267, 340, 671, 2482, 63, 2487, 508, 8061, 288, 931, 63, 589, 275, 359, 1579, 515, 12, 1592, 63, 19324, 63, 3741, 61, 435, 849, 63, 515, 288, 671, 2482, 63, 2487, 275, 747, 14, 515, 14, 904, 2031, 515, 63, 589, 9, 267, 4775, 459, 16618, 21155, 63, 56, 4929, 418, 275, 221, 671, 2482, 63, 2487, 1362, 199, 318, 636, 2416, 63, 5649, 8, 22899, 63, 5649, 12, 15404, 18, 63, 5649, 12, 21206, 63, 5649, 304, 272, 408, 9496, 83, 282, 6545, 12, 4079, 641, 1314, 2018, 4621, 787, 3451, 14, 408, 272, 340, 16602, 63, 19324, 84, 4687, 26, 267, 372, 21206, 63, 5649, 2286, 340, 440, 965, 63, 773, 1652, 18, 26, 267, 327, 2854, 314, 12427, 781, 16602, 15404, 18, 1806, 14490, 12, 314, 19045, 883, 12690, 267, 327, 370, 18511, 1380, 4903, 10451, 543, 15404, 18, 14, 267, 340, 965, 63, 22899, 26, 288, 372, 14490, 63, 5649, 267, 587, 26, 288, 372, 21206, 63, 5649, 339, 372, 15404, 18, 63, 5649, 199, 199, 318, 636, 7505, 63, 4511, 8, 84, 12, 4739, 304, 272, 408, 7523, 626, 314, 1347, 307, 965, 314, 1627, 4739, 14, 408, 272, 307, 515, 275, 620, 8, 84, 9, 272, 340, 440, 307, 515, 14, 4130, 8, 4511, 304, 267, 372, 307, 515, 11, 4511, 2286, 372, 307, 199, 199, 318, 636, 7505, 63, 4511, 63, 18446, 8, 84, 12, 4739, 304, 272, 408, 7523, 626, 314, 1347, 307, 965, 314, 1627, 4739, 12, 436, 372, 314, 570, 1159, 17408, 14, 408, 272, 307, 515, 275, 620, 8, 84, 9, 272, 340, 440, 307, 515, 14, 4130, 8, 4511, 304, 267, 17408, 275, 307, 515, 267, 307, 515, 847, 4739, 2728, 372, 307, 515, 12, 17408, 272, 587, 26, 267, 17408, 12, 1599, 275, 747, 14, 515, 14, 7973, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nttcom/eclcli
eclcli/api/auth_plugin.py
3
3732
# 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. # """Authentication Plugin Library""" import logging from oslo_config import cfg from six.moves.urllib import parse as urlparse from keystoneclient.auth.identity.generic import password as ksc_password from keystoneclient.auth import token_endpoint LOG = logging.getLogger(__name__) class TokenEndpoint(token_endpoint.Token): """Auth plugin to handle traditional token/endpoint usage Implements the methods required to handle token authentication with a user-specified token and service endpoint; no Identity calls are made for re-scoping, service catalog lookups or the like. The purpose of this plugin is to get rid of the special-case paths in the code to handle this authentication format. Its primary use is for bootstrapping the Keystone database. """ def __init__(self, url, token, **kwargs): """A plugin for static authentication with an existing token :param string url: Service endpoint :param string token: Existing token """ super(TokenEndpoint, self).__init__(endpoint=url, token=token) def get_auth_ref(self, session, **kwargs): # Stub this method for compatibility return None @classmethod def get_options(self): options = super(TokenEndpoint, self).get_options() options.extend([ # Maintain name 'url' for compatibility cfg.StrOpt('url', help='Specific service endpoint to use'), cfg.StrOpt('token', secret=True, help='Authentication token to use'), ]) return options class OSCGenericPassword(ksc_password.Password): """Auth plugin hack to work around broken Keystone configurations The default Keystone configuration uses http://localhost:xxxx in admin_endpoint and public_endpoint and are returned in the links.href attribute by the version routes. Deployments that do not set these are unusable with newer keystoneclient version discovery. """ def create_plugin(self, session, version, url, raw_status=None): """Handle default Keystone endpoint configuration Build the actual API endpoint from the scheme, host and port of the original auth URL and the rest from the returned version URL. """ ver_u = urlparse.urlparse(url) # Only hack this if it is the default setting if ver_u.netloc.startswith('localhost'): auth_u = urlparse.urlparse(self.auth_url) # from original auth_url: scheme, netloc # from api_url: path, query (basically, the rest) url = urlparse.urlunparse(( auth_u.scheme, auth_u.netloc, ver_u.path, ver_u.params, ver_u.query, ver_u.fragment, )) LOG.debug('Version URL updated: %s', url) return super(OSCGenericPassword, self).create_plugin( session=session, version=version, url=url, raw_status=raw_status, )
apache-2.0
[ 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 257, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 257, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 263, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 257, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 257, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 257, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 10348, 11349, 11243, 624, 199, 199, 646, 2050, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 465, 7097, 199, 199, 504, 19395, 1258, 14, 1178, 14, 5582, 14, 6767, 492, 2505, 465, 1022, 551, 63, 2060, 199, 504, 19395, 1258, 14, 1178, 492, 1526, 63, 6520, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 8767, 11442, 8, 1418, 63, 6520, 14, 3264, 304, 272, 408, 2817, 3589, 370, 2429, 1468, 2603, 1526, 15, 6520, 4503, 339, 24664, 314, 3102, 1415, 370, 2429, 1526, 6299, 272, 543, 282, 922, 13, 10085, 1526, 436, 2435, 6037, 27, 949, 22034, 4882, 272, 787, 6326, 367, 295, 13, 20845, 4073, 12, 2435, 10594, 16807, 503, 314, 2839, 14, 339, 710, 12016, 402, 642, 3589, 365, 370, 664, 16146, 402, 314, 4539, 13, 2546, 3792, 272, 315, 314, 1233, 370, 2429, 642, 6299, 1475, 14, 22940, 5062, 675, 272, 365, 367, 8498, 14183, 3637, 314, 2606, 8361, 3050, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1166, 12, 1526, 12, 1011, 958, 304, 267, 408, 33, 3589, 367, 2955, 6299, 543, 376, 3411, 1526, 398, 520, 635, 1059, 1166, 26, 7591, 6037, 267, 520, 635, 1059, 1526, 26, 1316, 26958, 1526, 267, 408, 267, 1613, 8, 3264, 11442, 12, 291, 2843, 826, 721, 6520, 29, 633, 12, 4490, 1526, 29, 1418, 9, 339, 347, 664, 63, 1178, 63, 1121, 8, 277, 12, 2351, 12, 1011, 958, 304, 267, 327, 23429, 642, 1083, 367, 7163, 267, 372, 488, 339, 768, 3744, 272, 347, 664, 63, 1419, 8, 277, 304, 267, 1511, 275, 1613, 8, 3264, 11442, 12, 291, 680, 362, 63, 1419, 342, 398, 1511, 14, 2880, 779, 288, 327, 16593, 8368, 536, 283, 633, 7, 367, 7163, 288, 4810, 14, 19340, 360, 633, 297, 2432, 1720, 534, 16786, 2435, 6037, 370, 675, 659, 288, 4810, 14, 19340, 360, 1418, 297, 2432, 7565, 29, 549, 12, 2432, 1720, 534, 10348, 1526, 370, 675, 659, 267, 4794, 398, 372, 1511, 421, 199, 533, 4403, 35, 9417, 6139, 8, 75, 551, 63, 2060, 14, 6139, 304, 272, 408, 2817, 3589, 11176, 370, 1736, 6818, 10529, 2606, 8361, 13422, 339, 710, 849, 2606, 8361, 2897, 4440, 1455, 921, 5967, 26, 5336, 315, 272, 4628, 63, 6520, 436, 4575, 63, 6520, 436, 787, 2138, 315, 314, 6220, 14, 6399, 272, 2225, 701, 314, 1015, 15777, 14, 221, 21588, 3374, 1470, 626, 886, 440, 663, 3520, 272, 787, 625, 14418, 543, 15666, 19395, 1258, 1015, 13172, 14, 339, 408, 339, 347, 1218, 63, 2718, 8, 277, 12, 2351, 12, 1015, 12, 1166, 12, 3066, 63, 1205, 29, 403, 304, 267, 408, 5940, 849, 2606, 8361, 6037, 2897, 398, 6516, 314, 3503, 3261, 6037, 687, 314, 5687, 12, 1591, 436, 1844, 402, 314, 267, 3379, 1790, 2851, 436, 314, 4618, 687, 314, 2138, 1015, 2851, 14, 267, 408, 398, 809, 63, 85, 275, 7097, 14, 10290, 8, 633, 9, 398, 327, 5972, 11176, 642, 340, 652, 365, 314, 849, 4260, 267, 340, 809, 63, 85, 14, 12652, 14, 2460, 360, 5967, 735, 288, 1790, 63, 85, 275, 7097, 14, 10290, 8, 277, 14, 1178, 63, 633, 9, 288, 327, 687, 3379, 1790, 63, 633, 26, 5687, 12, 10154, 288, 327, 687, 2986, 63, 633, 26, 931, 12, 1827, 334, 4316, 1183, 12, 314, 4618, 9, 288, 1166, 275, 7097, 14, 633, 18185, 1332, 355, 1790, 63, 85, 14, 5512, 12, 355, 1790, 63, 85, 14, 12652, 12, 355, 809, 63, 85, 14, 515, 12, 355, 809, 63, 85, 14, 1162, 12, 355, 809, 63, 85, 14, 1131, 12, 355, 809, 63, 85, 14, 7677, 12, 288, 5082, 288, 5051, 14, 1757, 360, 3353, 2851, 4588, 26, 450, 83, 297, 1166, 9, 398, 372, 1613, 8, 31799, 9417, 6139, 12, 291, 680, 981, 63, 2718, 8, 288, 2351, 29, 1730, 12, 288, 1015, 29, 1023, 12, 288, 1166, 29, 633, 12, 288, 3066, 63, 1205, 29, 1773, 63, 1205, 12, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 257, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 257, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 263, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 257, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 257, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 257, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 10348, 11349, 11243, 624, 199, 199, 646, 2050, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 465, 7097, 199, 199, 504, 19395, 1258, 14, 1178, 14, 5582, 14, 6767, 492, 2505, 465, 1022, 551, 63, 2060, 199, 504, 19395, 1258, 14, 1178, 492, 1526, 63, 6520, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 8767, 11442, 8, 1418, 63, 6520, 14, 3264, 304, 272, 408, 2817, 3589, 370, 2429, 1468, 2603, 1526, 15, 6520, 4503, 339, 24664, 314, 3102, 1415, 370, 2429, 1526, 6299, 272, 543, 282, 922, 13, 10085, 1526, 436, 2435, 6037, 27, 949, 22034, 4882, 272, 787, 6326, 367, 295, 13, 20845, 4073, 12, 2435, 10594, 16807, 503, 314, 2839, 14, 339, 710, 12016, 402, 642, 3589, 365, 370, 664, 16146, 402, 314, 4539, 13, 2546, 3792, 272, 315, 314, 1233, 370, 2429, 642, 6299, 1475, 14, 22940, 5062, 675, 272, 365, 367, 8498, 14183, 3637, 314, 2606, 8361, 3050, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1166, 12, 1526, 12, 1011, 958, 304, 267, 408, 33, 3589, 367, 2955, 6299, 543, 376, 3411, 1526, 398, 520, 635, 1059, 1166, 26, 7591, 6037, 267, 520, 635, 1059, 1526, 26, 1316, 26958, 1526, 267, 408, 267, 1613, 8, 3264, 11442, 12, 291, 2843, 826, 721, 6520, 29, 633, 12, 4490, 1526, 29, 1418, 9, 339, 347, 664, 63, 1178, 63, 1121, 8, 277, 12, 2351, 12, 1011, 958, 304, 267, 327, 23429, 642, 1083, 367, 7163, 267, 372, 488, 339, 768, 3744, 272, 347, 664, 63, 1419, 8, 277, 304, 267, 1511, 275, 1613, 8, 3264, 11442, 12, 291, 680, 362, 63, 1419, 342, 398, 1511, 14, 2880, 779, 288, 327, 16593, 8368, 536, 283, 633, 7, 367, 7163, 288, 4810, 14, 19340, 360, 633, 297, 2432, 1720, 534, 16786, 2435, 6037, 370, 675, 659, 288, 4810, 14, 19340, 360, 1418, 297, 2432, 7565, 29, 549, 12, 2432, 1720, 534, 10348, 1526, 370, 675, 659, 267, 4794, 398, 372, 1511, 421, 199, 533, 4403, 35, 9417, 6139, 8, 75, 551, 63, 2060, 14, 6139, 304, 272, 408, 2817, 3589, 11176, 370, 1736, 6818, 10529, 2606, 8361, 13422, 339, 710, 849, 2606, 8361, 2897, 4440, 1455, 921, 5967, 26, 5336, 315, 272, 4628, 63, 6520, 436, 4575, 63, 6520, 436, 787, 2138, 315, 314, 6220, 14, 6399, 272, 2225, 701, 314, 1015, 15777, 14, 221, 21588, 3374, 1470, 626, 886, 440, 663, 3520, 272, 787, 625, 14418, 543, 15666, 19395, 1258, 1015, 13172, 14, 339, 408, 339, 347, 1218, 63, 2718, 8, 277, 12, 2351, 12, 1015, 12, 1166, 12, 3066, 63, 1205, 29, 403, 304, 267, 408, 5940, 849, 2606, 8361, 6037, 2897, 398, 6516, 314, 3503, 3261, 6037, 687, 314, 5687, 12, 1591, 436, 1844, 402, 314, 267, 3379, 1790, 2851, 436, 314, 4618, 687, 314, 2138, 1015, 2851, 14, 267, 408, 398, 809, 63, 85, 275, 7097, 14, 10290, 8, 633, 9, 398, 327, 5972, 11176, 642, 340, 652, 365, 314, 849, 4260, 267, 340, 809, 63, 85, 14, 12652, 14, 2460, 360, 5967, 735, 288, 1790, 63, 85, 275, 7097, 14, 10290, 8, 277, 14, 1178, 63, 633, 9, 288, 327, 687, 3379, 1790, 63, 633, 26, 5687, 12, 10154, 288, 327, 687, 2986, 63, 633, 26, 931, 12, 1827, 334, 4316, 1183, 12, 314, 4618, 9, 288, 1166, 275, 7097, 14, 633, 18185, 1332, 355, 1790, 63, 85, 14, 5512, 12, 355, 1790, 63, 85, 14, 12652, 12, 355, 809, 63, 85, 14, 515, 12, 355, 809, 63, 85, 14, 1162, 12, 355, 809, 63, 85, 14, 1131, 12, 355, 809, 63, 85, 14, 7677, 12, 288, 5082, 288, 5051, 14, 1757, 360, 3353, 2851, 4588, 26, 450, 83, 297, 1166, 9, 398, 372, 1613, 8, 31799, 9417, 6139, 12, 291, 680, 981, 63, 2718, 8, 288, 2351, 29, 1730, 12, 288, 1015, 29, 1023, 12, 288, 1166, 29, 633, 12, 288, 3066, 63, 1205, 29, 1773, 63, 1205, 12, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Scratchcat1/AATC
flask_app/Flask_Test_App.py
1
5816
from flask import Flask, flash, redirect, render_template, request, session, abort import random,os,ast,prettytable from flask_app import forms import AATC_Server_002 as AATC_Server import HedaBot COMMANDS = HedaBot.CreateCommandDictionary() COMMANDS["AddFlight"][2]["Type"] = lambda x: HedaBot.SplitWaypoints(x,":") COMMANDS["AddFlight"][2]["Query"] = COMMANDS["AddFlight"][2]["Query"].replace("returns","colons") app = Flask(__name__) app.config.from_object('flask_app.config') @app.route("/") def home(): ## session["UserID"] = random.randint(0,1000) return render_template("base.html",user = {"Username":session.get("UserID"), "UserID":session.get("UserID")},Commands = COMMANDS) @app.route("/help") def help_page(): return render_template("help.html",name = session.get("UserID"),user = {"Username":session.get("UserID"), "UserID":session.get("UserID")}) @app.route("/base") def base(): return render_template("base.html",user = {"Username":session.get("UserID"), "UserID":session.get("UserID")}) @app.route("/quote") def quote(): quotes = ObtainQuote(3) return render_template("quote.html", quotes = quotes,user = {"Username":session.get("UserID"), "UserID":session.get("UserID")}) @app.route("/login", methods=['GET', 'POST']) def login(): form = forms.LoginForm() if form.validate_on_submit(): print("Loggin in ...") if form.Username.data == form.Password.data: session["UserID"] = form.Username.data else: session["UserID"] = -1 return render_template("LoginForm.html",title = "Login",form = form,user = {"Username":session.get("UserID"), "UserID":session.get("UserID")}) @app.route("/dyno", methods=['GET', 'POST']) def dyno(): items = [{"name":"Username"},{"name":"Password"}] fields = [{"name":"Username","form":forms.wtforms.StringField('Username', validators=[forms.DataRequired()])}, {"name":"Password","form":forms.wtforms.StringField('Password', validators=[forms.DataRequired()])}] #form = forms.DynoForm(fields = items) form = forms.update_form(fields) print(form.__dict__) if form.validate_on_submit(): print("Loggin in ...") print(form.fields.data) if form.Username.data == form.Password.data: session["UserID"] = form.Username.data else: session["UserID"] = -1 #print(form.fields.__dict__) return render_template("DynamicForm.html",title = "Login",form = form,user = {"Username":session.get("UserID"), "UserID":session.get("UserID")},fields = fields) @app.route("/command/<string:command>",methods=['GET', 'POST']) def Dynamic_Form(command): if command not in COMMANDS: return "FAILURE COMMAND DOES NOT EXIST" Fields = Generate_Fields(command) form = forms.update_form(Fields) if form.validate_on_submit(): packet = Evaluate_Form(command,form) WebConnection = AATC_Server.WebConnection(session.get("UserID",-1)) Sucess,Message,Data = WebConnection.Main(packet) if command == "Login": session["UserID"] = Data Data = [] rendered = RenderResults(Sucess,Message,Data) print(rendered) return render_template("DynamicForm2.html",title = "Output",form = form,user = {"Username":session.get("UserID"), "UserID":session.get("UserID")},fields = Fields ,Commands = COMMANDS, OUTPUT = True, rendered_result = rendered) return render_template("DynamicForm2.html",title = "command",form = form,user = {"Username":session.get("UserID"), "UserID":session.get("UserID")},fields = Fields,Commands = COMMANDS) def Generate_Fields(command): Queries = COMMANDS[command] Fields = [] for x in range(1,len(Queries)+1): query_name = Queries[x]["Query"] field = {"name":query_name ,"form":forms.wtforms.StringField(query_name, validators=[forms.DataRequired()])} Fields.append(field) return Fields def Evaluate_Form(command,form): Queries = COMMANDS[command] Arguments = [] for x in range(1,len(Queries)+1): Arguments.append( Queries[x]["Type"](form.__dict__[Queries[x]["Query"]].data)) packet = (command,Arguments) return packet def RenderResults(Sucess,Message,Data = None): render = "" render += "Sucess >>"+str(Sucess)+"\n" render += "Message >>"+str(Message) +"\n" if Data not in [None,[]]: try: Columns = ast.literal_eval(Message) Table = prettytable.PrettyTable(Columns) for row in Data: Table.add_row(row) render += str(Table) except Exception as e: render += "Error creating asthetic table"+str(e) +"\n" for row in Data: render += str(row)+"\n" render += "" rendered = render.split("\n") return rendered ##def ObtainQuote(number = 1): ## with open(os.path.join(os.path.abspath(os.path.join(os.getcwd(), os.pardir)),"SkyrimDialogue.txt"),"r") as f: ## for i,line in enumerate(f): ## pass ## ## responses = [] ## for f in range(number): ## lineNum = random.randint(0,i+1) ## with open(os.path.join(os.path.abspath(os.path.join(os.getcwd(), os.pardir)),"SkyrimDialogue.txt"),"r") as f: ## for x in range(lineNum): ## line = f.readline() ## responses.append( line.rstrip().split("\t")[-1:][0]) ## return responses def main_app(app): app.secret_key = "abcewhfuhiwuhef" app.run(host = "0.0.0.0") if __name__ == "__main__": main_app(app)
gpl-3.0
[ 504, 7209, 492, 16704, 12, 14775, 12, 4660, 12, 3795, 63, 1160, 12, 1056, 12, 2351, 12, 12004, 202, 199, 646, 2196, 12, 736, 12, 1810, 12, 9118, 1224, 202, 199, 504, 7209, 63, 571, 492, 4513, 2999, 199, 646, 437, 24355, 63, 3120, 63, 7432, 465, 437, 24355, 63, 3120, 202, 199, 646, 869, 379, 65, 14026, 202, 199, 28442, 275, 869, 379, 65, 14026, 14, 2499, 3110, 11728, 342, 202, 199, 28442, 905, 1123, 38, 4040, 9210, 18, 7541, 804, 937, 275, 2400, 671, 26, 869, 379, 65, 14026, 14, 8862, 25544, 3438, 8, 88, 12, 582, 531, 202, 199, 28442, 905, 1123, 38, 4040, 9210, 18, 7541, 3227, 937, 275, 11293, 20033, 905, 1123, 38, 4040, 9210, 18, 7541, 3227, 4140, 1814, 480, 5808, 2266, 761, 4654, 531, 2999, 199, 571, 275, 16704, 3460, 354, 3368, 202, 199, 571, 14, 888, 14, 504, 63, 785, 360, 15720, 63, 571, 14, 888, 358, 10060, 1223, 8065, 199, 32, 571, 14, 4449, 19031, 202, 199, 318, 5629, 837, 202, 199, 309, 259, 2351, 905, 28659, 937, 275, 2196, 14, 8393, 8, 16, 12, 5279, 9, 1128, 372, 3795, 63, 1160, 480, 1095, 14, 1360, 401, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 14680, 275, 11293, 20033, 9, 2999, 199, 32, 571, 14, 4449, 4769, 3437, 531, 202, 199, 318, 1720, 63, 1606, 837, 1128, 372, 3795, 63, 1160, 480, 3437, 14, 1360, 401, 354, 275, 2351, 14, 362, 480, 28659, 1288, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 2999, 199, 32, 571, 14, 4449, 4769, 1095, 531, 202, 199, 318, 1300, 837, 1128, 372, 3795, 63, 1160, 480, 1095, 14, 1360, 401, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 2999, 199, 32, 571, 14, 4449, 4769, 3513, 531, 202, 199, 318, 6313, 837, 1128, 9344, 275, 17985, 877, 12838, 8, 19, 9, 1128, 372, 3795, 63, 1160, 480, 3513, 14, 1360, 401, 9344, 275, 9344, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 8065, 199, 32, 571, 14, 4449, 4769, 2886, 401, 3102, 2968, 2970, 297, 283, 4030, 1105, 202, 199, 318, 4676, 837, 1128, 1824, 275, 4513, 14, 8880, 2821, 342, 11787, 340, 1824, 14, 3502, 63, 265, 63, 7275, 837, 1039, 870, 480, 2445, 903, 315, 2263, 531, 1039, 340, 1824, 14, 13355, 14, 576, 508, 1824, 14, 6139, 14, 576, 26, 1675, 2351, 905, 28659, 937, 275, 1824, 14, 13355, 14, 576, 1039, 587, 26, 1675, 2351, 905, 28659, 937, 275, 446, 17, 1128, 372, 3795, 63, 1160, 480, 8880, 2821, 14, 1360, 401, 1213, 275, 298, 8880, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 8065, 199, 32, 571, 14, 4449, 4769, 8161, 889, 401, 3102, 2968, 2970, 297, 283, 4030, 1105, 202, 199, 318, 13119, 889, 837, 1128, 2974, 275, 16870, 354, 5122, 13355, 6018, 6641, 354, 5122, 6139, 3570, 61, 2958, 1504, 275, 16870, 354, 5122, 13355, 2266, 964, 582, 3351, 14, 9115, 3351, 14, 14912, 360, 13355, 297, 14370, 1524, 3351, 14, 1451, 8030, 9383, 1386, 23284, 2420, 354, 5122, 6139, 2266, 964, 582, 3351, 14, 9115, 3351, 14, 14912, 360, 6139, 297, 14370, 1524, 3351, 14, 1451, 8030, 9383, 11049, 1128, 327, 964, 275, 4513, 14, 36, 89, 889, 2821, 8, 955, 275, 2974, 9, 1128, 1824, 275, 4513, 14, 873, 63, 964, 8, 955, 9, 1128, 870, 8, 964, 855, 807, 3368, 8428, 11787, 340, 1824, 14, 3502, 63, 265, 63, 7275, 837, 1039, 870, 480, 2445, 903, 315, 2263, 531, 1039, 870, 8, 964, 14, 955, 14, 576, 9, 1039, 340, 1824, 14, 13355, 14, 576, 508, 1824, 14, 6139, 14, 576, 26, 1675, 2351, 905, 28659, 937, 275, 1824, 14, 13355, 14, 576, 1039, 587, 26, 1675, 2351, 905, 28659, 937, 275, 446, 17, 2958, 327, 1361, 8, 964, 14, 955, 855, 807, 3368, 1128, 372, 3795, 63, 1160, 480, 14451, 2821, 14, 1360, 401, 1213, 275, 298, 8880, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 955, 275, 1504, 9, 8065, 199, 32, 571, 14, 4449, 4769, 1531, 8316, 875, 26, 1531, 7166, 2474, 2968, 2970, 297, 283, 4030, 1105, 202, 199, 318, 21907, 63, 2821, 8, 1531, 304, 1128, 340, 1414, 440, 315, 11293, 20033, 26, 1039, 372, 298, 13989, 25965, 3506, 654, 2845, 22968, 2, 2958, 16424, 275, 7958, 63, 7304, 8, 1531, 9, 1128, 1824, 275, 4513, 14, 873, 63, 964, 8, 7304, 9, 2958, 340, 1824, 14, 3502, 63, 265, 63, 7275, 837, 1039, 3644, 275, 27450, 63, 2821, 8, 1531, 12, 964, 9, 1039, 6001, 3225, 275, 437, 24355, 63, 3120, 14, 5926, 3225, 8, 1730, 14, 362, 480, 28659, 401, 13, 17, 430, 1039, 428, 85, 670, 12, 2209, 12, 1451, 275, 6001, 3225, 14, 6756, 8, 6253, 9, 4341, 340, 1414, 508, 298, 8880, 582, 1675, 2351, 905, 28659, 937, 275, 3918, 1675, 3918, 275, 942, 4341, 8018, 275, 17769, 6579, 8, 27032, 670, 12, 2209, 12, 1451, 9, 1039, 870, 8, 16841, 9, 4341, 372, 3795, 63, 1160, 480, 14451, 2821, 18, 14, 1360, 401, 1213, 275, 298, 2959, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 955, 275, 16424, 2360, 14680, 275, 11293, 20033, 12, 18746, 275, 715, 12, 8018, 63, 1099, 275, 8018, 9, 2958, 372, 3795, 63, 1160, 480, 14451, 2821, 18, 14, 1360, 401, 1213, 275, 298, 1531, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 955, 275, 16424, 12, 14680, 275, 11293, 20033, 9, 10060, 10060, 8065, 199, 318, 7958, 63, 7304, 8, 1531 ]
[ 7209, 492, 16704, 12, 14775, 12, 4660, 12, 3795, 63, 1160, 12, 1056, 12, 2351, 12, 12004, 202, 199, 646, 2196, 12, 736, 12, 1810, 12, 9118, 1224, 202, 199, 504, 7209, 63, 571, 492, 4513, 2999, 199, 646, 437, 24355, 63, 3120, 63, 7432, 465, 437, 24355, 63, 3120, 202, 199, 646, 869, 379, 65, 14026, 202, 199, 28442, 275, 869, 379, 65, 14026, 14, 2499, 3110, 11728, 342, 202, 199, 28442, 905, 1123, 38, 4040, 9210, 18, 7541, 804, 937, 275, 2400, 671, 26, 869, 379, 65, 14026, 14, 8862, 25544, 3438, 8, 88, 12, 582, 531, 202, 199, 28442, 905, 1123, 38, 4040, 9210, 18, 7541, 3227, 937, 275, 11293, 20033, 905, 1123, 38, 4040, 9210, 18, 7541, 3227, 4140, 1814, 480, 5808, 2266, 761, 4654, 531, 2999, 199, 571, 275, 16704, 3460, 354, 3368, 202, 199, 571, 14, 888, 14, 504, 63, 785, 360, 15720, 63, 571, 14, 888, 358, 10060, 1223, 8065, 199, 32, 571, 14, 4449, 19031, 202, 199, 318, 5629, 837, 202, 199, 309, 259, 2351, 905, 28659, 937, 275, 2196, 14, 8393, 8, 16, 12, 5279, 9, 1128, 372, 3795, 63, 1160, 480, 1095, 14, 1360, 401, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 14680, 275, 11293, 20033, 9, 2999, 199, 32, 571, 14, 4449, 4769, 3437, 531, 202, 199, 318, 1720, 63, 1606, 837, 1128, 372, 3795, 63, 1160, 480, 3437, 14, 1360, 401, 354, 275, 2351, 14, 362, 480, 28659, 1288, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 2999, 199, 32, 571, 14, 4449, 4769, 1095, 531, 202, 199, 318, 1300, 837, 1128, 372, 3795, 63, 1160, 480, 1095, 14, 1360, 401, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 2999, 199, 32, 571, 14, 4449, 4769, 3513, 531, 202, 199, 318, 6313, 837, 1128, 9344, 275, 17985, 877, 12838, 8, 19, 9, 1128, 372, 3795, 63, 1160, 480, 3513, 14, 1360, 401, 9344, 275, 9344, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 8065, 199, 32, 571, 14, 4449, 4769, 2886, 401, 3102, 2968, 2970, 297, 283, 4030, 1105, 202, 199, 318, 4676, 837, 1128, 1824, 275, 4513, 14, 8880, 2821, 342, 11787, 340, 1824, 14, 3502, 63, 265, 63, 7275, 837, 1039, 870, 480, 2445, 903, 315, 2263, 531, 1039, 340, 1824, 14, 13355, 14, 576, 508, 1824, 14, 6139, 14, 576, 26, 1675, 2351, 905, 28659, 937, 275, 1824, 14, 13355, 14, 576, 1039, 587, 26, 1675, 2351, 905, 28659, 937, 275, 446, 17, 1128, 372, 3795, 63, 1160, 480, 8880, 2821, 14, 1360, 401, 1213, 275, 298, 8880, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 531, 1552, 8065, 199, 32, 571, 14, 4449, 4769, 8161, 889, 401, 3102, 2968, 2970, 297, 283, 4030, 1105, 202, 199, 318, 13119, 889, 837, 1128, 2974, 275, 16870, 354, 5122, 13355, 6018, 6641, 354, 5122, 6139, 3570, 61, 2958, 1504, 275, 16870, 354, 5122, 13355, 2266, 964, 582, 3351, 14, 9115, 3351, 14, 14912, 360, 13355, 297, 14370, 1524, 3351, 14, 1451, 8030, 9383, 1386, 23284, 2420, 354, 5122, 6139, 2266, 964, 582, 3351, 14, 9115, 3351, 14, 14912, 360, 6139, 297, 14370, 1524, 3351, 14, 1451, 8030, 9383, 11049, 1128, 327, 964, 275, 4513, 14, 36, 89, 889, 2821, 8, 955, 275, 2974, 9, 1128, 1824, 275, 4513, 14, 873, 63, 964, 8, 955, 9, 1128, 870, 8, 964, 855, 807, 3368, 8428, 11787, 340, 1824, 14, 3502, 63, 265, 63, 7275, 837, 1039, 870, 480, 2445, 903, 315, 2263, 531, 1039, 870, 8, 964, 14, 955, 14, 576, 9, 1039, 340, 1824, 14, 13355, 14, 576, 508, 1824, 14, 6139, 14, 576, 26, 1675, 2351, 905, 28659, 937, 275, 1824, 14, 13355, 14, 576, 1039, 587, 26, 1675, 2351, 905, 28659, 937, 275, 446, 17, 2958, 327, 1361, 8, 964, 14, 955, 855, 807, 3368, 1128, 372, 3795, 63, 1160, 480, 14451, 2821, 14, 1360, 401, 1213, 275, 298, 8880, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 955, 275, 1504, 9, 8065, 199, 32, 571, 14, 4449, 4769, 1531, 8316, 875, 26, 1531, 7166, 2474, 2968, 2970, 297, 283, 4030, 1105, 202, 199, 318, 21907, 63, 2821, 8, 1531, 304, 1128, 340, 1414, 440, 315, 11293, 20033, 26, 1039, 372, 298, 13989, 25965, 3506, 654, 2845, 22968, 2, 2958, 16424, 275, 7958, 63, 7304, 8, 1531, 9, 1128, 1824, 275, 4513, 14, 873, 63, 964, 8, 7304, 9, 2958, 340, 1824, 14, 3502, 63, 265, 63, 7275, 837, 1039, 3644, 275, 27450, 63, 2821, 8, 1531, 12, 964, 9, 1039, 6001, 3225, 275, 437, 24355, 63, 3120, 14, 5926, 3225, 8, 1730, 14, 362, 480, 28659, 401, 13, 17, 430, 1039, 428, 85, 670, 12, 2209, 12, 1451, 275, 6001, 3225, 14, 6756, 8, 6253, 9, 4341, 340, 1414, 508, 298, 8880, 582, 1675, 2351, 905, 28659, 937, 275, 3918, 1675, 3918, 275, 942, 4341, 8018, 275, 17769, 6579, 8, 27032, 670, 12, 2209, 12, 1451, 9, 1039, 870, 8, 16841, 9, 4341, 372, 3795, 63, 1160, 480, 14451, 2821, 18, 14, 1360, 401, 1213, 275, 298, 2959, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 955, 275, 16424, 2360, 14680, 275, 11293, 20033, 12, 18746, 275, 715, 12, 8018, 63, 1099, 275, 8018, 9, 2958, 372, 3795, 63, 1160, 480, 14451, 2821, 18, 14, 1360, 401, 1213, 275, 298, 1531, 401, 964, 275, 1824, 12, 751, 275, 2420, 13355, 582, 1730, 14, 362, 480, 28659, 1288, 298, 28659, 582, 1730, 14, 362, 480, 28659, 25988, 955, 275, 16424, 12, 14680, 275, 11293, 20033, 9, 10060, 10060, 8065, 199, 318, 7958, 63, 7304, 8, 1531, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ragupta-git/ImcSdk
imcsdk/mometa/comm/CommSnmp.py
1
8759
"""This module contains the general information for CommSnmp ManagedObject.""" from ...imcmo import ManagedObject from ...imccoremeta import MoPropertyMeta, MoMeta from ...imcmeta import VersionMeta class CommSnmpConsts: ADMIN_STATE_DISABLED = "disabled" ADMIN_STATE_ENABLED = "enabled" COM2_SEC_NONE = "None" COM2_SEC_DISABLED = "disabled" COM2_SEC_FULL = "full" COM2_SEC_LIMITED = "limited" PROTO_ALL = "all" PROTO_NONE = "none" PROTO_TCP = "tcp" PROTO_UDP = "udp" class CommSnmp(ManagedObject): """This is CommSnmp class.""" consts = CommSnmpConsts() naming_props = set([]) mo_meta = { "classic": MoMeta("CommSnmp", "commSnmp", "snmp-svc", VersionMeta.Version151f, "InputOutput", 0xfff, [], ["admin", "read-only", "user"], [u'commSvcEp'], [u'commSnmpTrap', u'commSnmpUser'], ["Get", "Set"]), "modular": MoMeta("CommSnmp", "commSnmp", "snmp-svc", VersionMeta.Version2013e, "InputOutput", 0xfff, [], ["admin", "read-only", "user"], [u'commSvcEp'], [u'commSnmpTrap', u'commSnmpUser'], ["Get", "Set"]) } prop_meta = { "classic": { "admin_state": MoPropertyMeta("admin_state", "adminState", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x2, None, None, None, ["Disabled", "Enabled", "disabled", "enabled"], []), "com2_sec": MoPropertyMeta("com2_sec", "com2Sec", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x4, None, None, None, ["None", "disabled", "full", "limited"], []), "community": MoPropertyMeta("community", "community", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x8, None, None, r"""[!#$%\(\)\*\+,\-\./:<=\[\]\^_\{\}~a-zA-Z0-9]{0,18}""", [], []), "dn": MoPropertyMeta("dn", "dn", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x10, 0, 255, None, [], []), "engine_id_key": MoPropertyMeta("engine_id_key", "engineIdKey", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x20, 0, 27, r"""[^#!&]{0,27}""", [], []), "port": MoPropertyMeta("port", "port", "uint", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x40, None, None, None, [], ["1-65535"]), "rn": MoPropertyMeta("rn", "rn", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x80, 0, 255, None, [], []), "status": MoPropertyMeta("status", "status", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x100, None, None, None, ["", "created", "deleted", "modified", "removed"], []), "sys_contact": MoPropertyMeta("sys_contact", "sysContact", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x200, 0, 64, None, [], []), "sys_location": MoPropertyMeta("sys_location", "sysLocation", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x400, 0, 64, None, [], []), "trap_community": MoPropertyMeta("trap_community", "trapCommunity", "string", VersionMeta.Version151f, MoPropertyMeta.READ_WRITE, 0x800, None, None, r"""[!#$%\(\)\*\+,\-\./:<=\[\]\^_\{\}~a-zA-Z0-9]{0,18}""", [], []), "child_action": MoPropertyMeta("child_action", "childAction", "string", VersionMeta.Version151f, MoPropertyMeta.INTERNAL, None, None, None, None, [], []), "descr": MoPropertyMeta("descr", "descr", "string", VersionMeta.Version151f, MoPropertyMeta.READ_ONLY, None, None, None, r"""[ !#$%&\(\)\*\+,\-\./:;\?@\[\]_\{\|\}~a-zA-Z0-9]{0,256}""", [], []), "engine_id": MoPropertyMeta("engine_id", "engineId", "string", VersionMeta.Version209c, MoPropertyMeta.READ_ONLY, None, 0, 255, None, [], []), "name": MoPropertyMeta("name", "name", "string", VersionMeta.Version151f, MoPropertyMeta.READ_ONLY, None, None, None, r"""[\-\.:_a-zA-Z0-9]{0,16}""", [], []), "proto": MoPropertyMeta("proto", "proto", "string", VersionMeta.Version151f, MoPropertyMeta.READ_ONLY, None, None, None, None, ["all", "none", "tcp", "udp"], []), }, "modular": { "admin_state": MoPropertyMeta("admin_state", "adminState", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x2, None, None, None, ["Disabled", "Enabled", "disabled", "enabled"], []), "com2_sec": MoPropertyMeta("com2_sec", "com2Sec", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x4, None, None, None, ["None", "disabled", "full", "limited"], []), "community": MoPropertyMeta("community", "community", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x8, None, None, r"""[!#$%\(\)\*\+,\-\./:<=\[\]\^_\{\}~a-zA-Z0-9]{0,18}""", [], []), "dn": MoPropertyMeta("dn", "dn", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x10, 0, 255, None, [], []), "engine_id_key": MoPropertyMeta("engine_id_key", "engineIdKey", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x20, 0, 27, r"""[^#!&]{0,27}""", [], []), "port": MoPropertyMeta("port", "port", "uint", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x40, None, None, None, [], ["1-65535"]), "rn": MoPropertyMeta("rn", "rn", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x80, 0, 255, None, [], []), "status": MoPropertyMeta("status", "status", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x100, None, None, None, ["", "created", "deleted", "modified", "removed"], []), "sys_contact": MoPropertyMeta("sys_contact", "sysContact", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x200, 0, 64, None, [], []), "sys_location": MoPropertyMeta("sys_location", "sysLocation", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x400, 0, 64, None, [], []), "trap_community": MoPropertyMeta("trap_community", "trapCommunity", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_WRITE, 0x800, None, None, r"""[!#$%\(\)\*\+,\-\./:<=\[\]\^_\{\}~a-zA-Z0-9]{0,18}""", [], []), "child_action": MoPropertyMeta("child_action", "childAction", "string", VersionMeta.Version2013e, MoPropertyMeta.INTERNAL, None, None, None, None, [], []), "descr": MoPropertyMeta("descr", "descr", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_ONLY, None, None, None, r"""[ !#$%&\(\)\*\+,\-\./:;\?@\[\]_\{\|\}~a-zA-Z0-9]{0,256}""", [], []), "engine_id": MoPropertyMeta("engine_id", "engineId", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_ONLY, None, 0, 255, None, [], []), "name": MoPropertyMeta("name", "name", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_ONLY, None, None, None, r"""[\-\.:_a-zA-Z0-9]{0,16}""", [], []), "proto": MoPropertyMeta("proto", "proto", "string", VersionMeta.Version2013e, MoPropertyMeta.READ_ONLY, None, None, None, None, ["all", "none", "tcp", "udp"], []), }, } prop_map = { "classic": { "adminState": "admin_state", "com2Sec": "com2_sec", "community": "community", "dn": "dn", "engineIdKey": "engine_id_key", "port": "port", "rn": "rn", "status": "status", "sysContact": "sys_contact", "sysLocation": "sys_location", "trapCommunity": "trap_community", "childAction": "child_action", "descr": "descr", "engineId": "engine_id", "name": "name", "proto": "proto", }, "modular": { "adminState": "admin_state", "com2Sec": "com2_sec", "community": "community", "dn": "dn", "engineIdKey": "engine_id_key", "port": "port", "rn": "rn", "status": "status", "sysContact": "sys_contact", "sysLocation": "sys_location", "trapCommunity": "trap_community", "childAction": "child_action", "descr": "descr", "engineId": "engine_id", "name": "name", "proto": "proto", }, } def __init__(self, parent_mo_or_dn, **kwargs): self._dirty_mask = 0 self.admin_state = None self.com2_sec = None self.community = None self.engine_id_key = None self.port = None self.status = None self.sys_contact = None self.sys_location = None self.trap_community = None self.child_action = None self.descr = None self.engine_id = None self.name = None self.proto = None ManagedObject.__init__(self, "CommSnmp", parent_mo_or_dn, **kwargs)
apache-2.0
[ 624, 2765, 859, 3509, 314, 8605, 2556, 367, 7046, 20821, 311, 4688, 6028, 1692, 1041, 199, 199, 504, 2263, 1017, 67, 573, 492, 4688, 6028, 1692, 199, 504, 2263, 1017, 67, 1018, 2024, 492, 3930, 3697, 3396, 12, 3930, 3396, 199, 504, 2263, 1017, 67, 2024, 492, 3394, 3396, 421, 199, 533, 7046, 20821, 311, 6361, 83, 26, 272, 29948, 63, 6689, 63, 16205, 275, 298, 7011, 2, 272, 29948, 63, 6689, 63, 15704, 275, 298, 3827, 2, 272, 18877, 18, 63, 15048, 63, 9185, 275, 298, 403, 2, 272, 18877, 18, 63, 15048, 63, 16205, 275, 298, 7011, 2, 272, 18877, 18, 63, 15048, 63, 14742, 275, 298, 2861, 2, 272, 18877, 18, 63, 15048, 63, 13387, 1149, 275, 298, 14136, 2, 272, 3611, 2566, 63, 1761, 275, 298, 452, 2, 272, 3611, 2566, 63, 9185, 275, 298, 3592, 2, 272, 3611, 2566, 63, 9735, 275, 298, 8815, 2, 272, 3611, 2566, 63, 17457, 275, 298, 15036, 2, 421, 199, 533, 7046, 20821, 311, 8, 22625, 1692, 304, 272, 408, 2765, 365, 7046, 20821, 311, 1021, 1041, 339, 950, 83, 275, 7046, 20821, 311, 6361, 83, 342, 272, 19720, 63, 6750, 275, 663, 4157, 339, 1303, 63, 2024, 275, 469, 267, 298, 25140, 582, 3930, 3396, 480, 5150, 20821, 311, 401, 298, 1404, 20821, 311, 401, 298, 15523, 13, 10599, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 298, 3205, 2959, 401, 378, 3581, 70, 12, 990, 2097, 2113, 401, 298, 739, 13, 2118, 401, 298, 751, 2255, 359, 85, 7, 1404, 51, 6737, 14057, 995, 359, 85, 7, 1404, 20821, 311, 52, 1330, 297, 399, 7, 1404, 20821, 311, 1899, 995, 2097, 1002, 401, 298, 1084, 10252, 267, 298, 1494, 2238, 582, 3930, 3396, 480, 5150, 20821, 311, 401, 298, 1404, 20821, 311, 401, 298, 15523, 13, 10599, 401, 3394, 3396, 14, 3353, 6965, 69, 12, 298, 3205, 2959, 401, 378, 3581, 70, 12, 990, 2097, 2113, 401, 298, 739, 13, 2118, 401, 298, 751, 2255, 359, 85, 7, 1404, 51, 6737, 14057, 995, 359, 85, 7, 1404, 20821, 311, 52, 1330, 297, 399, 7, 1404, 20821, 311, 1899, 995, 2097, 1002, 401, 298, 1084, 3135, 272, 789, 2378, 5931, 63, 2024, 275, 469, 398, 298, 25140, 582, 469, 288, 298, 2113, 63, 929, 582, 3930, 3697, 3396, 480, 2113, 63, 929, 401, 298, 2113, 2223, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 18, 12, 488, 12, 488, 12, 488, 12, 2097, 15049, 401, 298, 6589, 401, 298, 7011, 401, 298, 3827, 2255, 14431, 7205, 298, 957, 18, 63, 3321, 582, 3930, 3697, 3396, 480, 957, 18, 63, 3321, 401, 298, 957, 18, 4933, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 20, 12, 488, 12, 488, 12, 488, 12, 2097, 403, 401, 298, 7011, 401, 298, 2861, 401, 298, 14136, 2255, 14431, 7205, 298, 9387, 582, 3930, 3697, 3396, 480, 9387, 401, 298, 9387, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 24, 12, 488, 12, 488, 12, 519, 624, 59, 1, 3, 22074, 29323, 2862, 7590, 11, 4202, 2696, 13186, 16875, 9529, 7023, 7272, 62, 18005, 12911, 93, 94, 65, 13, 6353, 13, 58, 16, 13, 25, 8194, 16, 12, 1085, 93, 7208, 990, 14431, 7205, 298, 4272, 582, 3930, 3697, 3396, 480, 4272, 401, 298, 4272, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 709, 12, 378, 12, 5450, 12, 488, 12, 990, 14431, 7205, 298, 3908, 63, 344, 63, 498, 582, 3930, 3697, 3396, 480, 3908, 63, 344, 63, 498, 401, 298, 3908, 1304, 1197, 401, 298, 875, 401, 3394, 3396, 14, 3353, 6965, 69, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1165, 12, 378, 12, 8087, 12, 519, 624, 4735, 3168, 6, 8194, 16, 12, 1465, 93, 7208, 990, 14431, 7205, 298, 719, 582, 3930, 3697, 3396, 480, 719, 401, 298, 719, 401, 298, 1635, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 2167, 12, 488, 12, 488, 12, 488, 12, 990, 2097, 17, 13, 26439, 10252, 7205, 298, 11641, 582, 3930, 3697, 3396, 480, 11641, 401, 298, 11641, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1257, 12, 378, 12, 5450, 12, 488, 12, 990, 14431, 7205, 298, 1205, 582, 3930, 3697, 3396, 480, 1205, 401, 298, 1205, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1960, 12, 488, 12, 488, 12, 488, 12, 359, 5151, 298, 3966, 401, 298, 6062, 401, 298, 5540, 401, 298, 10649, 2255, 14431, 7205, 298, 1274, 63, 7811, 582, 3930, 3697, 3396, 480, 1274, 63, 7811, 401, 298, 1274, 14499, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1840, 12, 378, 12, 5049, 12, 488, 12, 990, 14431, 7205, 298, 1274, 63, 1985, 582, 3930, 3697, 3396, 480, 1274, 63, 1985, 401, 298, 1274, 6592, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 5303, 12, 378, 12, 5049, 12, 488, 12, 990, 14431, 7205, 298, 19510, 63, 9387, 582, 3930, 3697, 3396, 480, 19510, 63, 9387, 401, 298, 19510, 29799, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 6718, 12, 488, 12, 488, 12, 519, 624, 59, 1, 3, 22074, 29323, 2862, 7590, 11, 4202, 2696, 13186, 16875, 9529, 7023, 7272, 62, 18005, 12911, 93, 94, 65, 13, 6353, 13, 58, 16, 13, 25, 8194, 16, 12, 1085, 93, 7208, 990, 14431, 7205, 298, 1739, 63, 1287, 582, 3930, 3697, 3396, 480, 1739, 63, 1287, 401, 298, 1739, 3310, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768 ]
[ 2765, 859, 3509, 314, 8605, 2556, 367, 7046, 20821, 311, 4688, 6028, 1692, 1041, 199, 199, 504, 2263, 1017, 67, 573, 492, 4688, 6028, 1692, 199, 504, 2263, 1017, 67, 1018, 2024, 492, 3930, 3697, 3396, 12, 3930, 3396, 199, 504, 2263, 1017, 67, 2024, 492, 3394, 3396, 421, 199, 533, 7046, 20821, 311, 6361, 83, 26, 272, 29948, 63, 6689, 63, 16205, 275, 298, 7011, 2, 272, 29948, 63, 6689, 63, 15704, 275, 298, 3827, 2, 272, 18877, 18, 63, 15048, 63, 9185, 275, 298, 403, 2, 272, 18877, 18, 63, 15048, 63, 16205, 275, 298, 7011, 2, 272, 18877, 18, 63, 15048, 63, 14742, 275, 298, 2861, 2, 272, 18877, 18, 63, 15048, 63, 13387, 1149, 275, 298, 14136, 2, 272, 3611, 2566, 63, 1761, 275, 298, 452, 2, 272, 3611, 2566, 63, 9185, 275, 298, 3592, 2, 272, 3611, 2566, 63, 9735, 275, 298, 8815, 2, 272, 3611, 2566, 63, 17457, 275, 298, 15036, 2, 421, 199, 533, 7046, 20821, 311, 8, 22625, 1692, 304, 272, 408, 2765, 365, 7046, 20821, 311, 1021, 1041, 339, 950, 83, 275, 7046, 20821, 311, 6361, 83, 342, 272, 19720, 63, 6750, 275, 663, 4157, 339, 1303, 63, 2024, 275, 469, 267, 298, 25140, 582, 3930, 3396, 480, 5150, 20821, 311, 401, 298, 1404, 20821, 311, 401, 298, 15523, 13, 10599, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 298, 3205, 2959, 401, 378, 3581, 70, 12, 990, 2097, 2113, 401, 298, 739, 13, 2118, 401, 298, 751, 2255, 359, 85, 7, 1404, 51, 6737, 14057, 995, 359, 85, 7, 1404, 20821, 311, 52, 1330, 297, 399, 7, 1404, 20821, 311, 1899, 995, 2097, 1002, 401, 298, 1084, 10252, 267, 298, 1494, 2238, 582, 3930, 3396, 480, 5150, 20821, 311, 401, 298, 1404, 20821, 311, 401, 298, 15523, 13, 10599, 401, 3394, 3396, 14, 3353, 6965, 69, 12, 298, 3205, 2959, 401, 378, 3581, 70, 12, 990, 2097, 2113, 401, 298, 739, 13, 2118, 401, 298, 751, 2255, 359, 85, 7, 1404, 51, 6737, 14057, 995, 359, 85, 7, 1404, 20821, 311, 52, 1330, 297, 399, 7, 1404, 20821, 311, 1899, 995, 2097, 1002, 401, 298, 1084, 3135, 272, 789, 2378, 5931, 63, 2024, 275, 469, 398, 298, 25140, 582, 469, 288, 298, 2113, 63, 929, 582, 3930, 3697, 3396, 480, 2113, 63, 929, 401, 298, 2113, 2223, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 18, 12, 488, 12, 488, 12, 488, 12, 2097, 15049, 401, 298, 6589, 401, 298, 7011, 401, 298, 3827, 2255, 14431, 7205, 298, 957, 18, 63, 3321, 582, 3930, 3697, 3396, 480, 957, 18, 63, 3321, 401, 298, 957, 18, 4933, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 20, 12, 488, 12, 488, 12, 488, 12, 2097, 403, 401, 298, 7011, 401, 298, 2861, 401, 298, 14136, 2255, 14431, 7205, 298, 9387, 582, 3930, 3697, 3396, 480, 9387, 401, 298, 9387, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 24, 12, 488, 12, 488, 12, 519, 624, 59, 1, 3, 22074, 29323, 2862, 7590, 11, 4202, 2696, 13186, 16875, 9529, 7023, 7272, 62, 18005, 12911, 93, 94, 65, 13, 6353, 13, 58, 16, 13, 25, 8194, 16, 12, 1085, 93, 7208, 990, 14431, 7205, 298, 4272, 582, 3930, 3697, 3396, 480, 4272, 401, 298, 4272, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 709, 12, 378, 12, 5450, 12, 488, 12, 990, 14431, 7205, 298, 3908, 63, 344, 63, 498, 582, 3930, 3697, 3396, 480, 3908, 63, 344, 63, 498, 401, 298, 3908, 1304, 1197, 401, 298, 875, 401, 3394, 3396, 14, 3353, 6965, 69, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1165, 12, 378, 12, 8087, 12, 519, 624, 4735, 3168, 6, 8194, 16, 12, 1465, 93, 7208, 990, 14431, 7205, 298, 719, 582, 3930, 3697, 3396, 480, 719, 401, 298, 719, 401, 298, 1635, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 2167, 12, 488, 12, 488, 12, 488, 12, 990, 2097, 17, 13, 26439, 10252, 7205, 298, 11641, 582, 3930, 3697, 3396, 480, 11641, 401, 298, 11641, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1257, 12, 378, 12, 5450, 12, 488, 12, 990, 14431, 7205, 298, 1205, 582, 3930, 3697, 3396, 480, 1205, 401, 298, 1205, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1960, 12, 488, 12, 488, 12, 488, 12, 359, 5151, 298, 3966, 401, 298, 6062, 401, 298, 5540, 401, 298, 10649, 2255, 14431, 7205, 298, 1274, 63, 7811, 582, 3930, 3697, 3396, 480, 1274, 63, 7811, 401, 298, 1274, 14499, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 1840, 12, 378, 12, 5049, 12, 488, 12, 990, 14431, 7205, 298, 1274, 63, 1985, 582, 3930, 3697, 3396, 480, 1274, 63, 1985, 401, 298, 1274, 6592, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 5303, 12, 378, 12, 5049, 12, 488, 12, 990, 14431, 7205, 298, 19510, 63, 9387, 582, 3930, 3697, 3396, 480, 19510, 63, 9387, 401, 298, 19510, 29799, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 70, 12, 3930, 3697, 3396, 14, 5670, 63, 10387, 12, 378, 88, 6718, 12, 488, 12, 488, 12, 519, 624, 59, 1, 3, 22074, 29323, 2862, 7590, 11, 4202, 2696, 13186, 16875, 9529, 7023, 7272, 62, 18005, 12911, 93, 94, 65, 13, 6353, 13, 58, 16, 13, 25, 8194, 16, 12, 1085, 93, 7208, 990, 14431, 7205, 298, 1739, 63, 1287, 582, 3930, 3697, 3396, 480, 1739, 63, 1287, 401, 298, 1739, 3310, 401, 298, 875, 401, 3394, 3396, 14, 3353, 12768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
havt/odoo
addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py
223
7860
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp.addons.decimal_precision import decimal_precision as dp class account_analytic_account(osv.osv): _name = "account.analytic.account" _inherit = "account.analytic.account" def _get_total_estimation(self, account): tot_est = super(account_analytic_account, self)._get_total_estimation(account) if account.charge_expenses: tot_est += account.est_expenses return tot_est def _get_total_invoiced(self, account): total_invoiced = super(account_analytic_account, self)._get_total_invoiced(account) if account.charge_expenses: total_invoiced += account.expense_invoiced return total_invoiced def _get_total_remaining(self, account): total_remaining = super(account_analytic_account, self)._get_total_remaining(account) if account.charge_expenses: total_remaining += account.remaining_expense return total_remaining def _get_total_toinvoice(self, account): total_toinvoice = super(account_analytic_account, self)._get_total_toinvoice(account) if account.charge_expenses: total_toinvoice += account.expense_to_invoice return total_toinvoice def _remaining_expnse_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): if account.est_expenses != 0: res[account.id] = max(account.est_expenses - account.expense_invoiced, account.expense_to_invoice) else: res[account.id]=0.0 return res def _expense_to_invoice_calc(self, cr, uid, ids, name, arg, context=None): res = {} #We don't want consolidation for each of these fields because those complex computation is resource-greedy. for account in self.pool.get('account.analytic.account').browse(cr, uid, ids, context=context): cr.execute(""" SELECT product_id, sum(amount), user_id, to_invoice, sum(unit_amount), product_uom_id, line.name FROM account_analytic_line line LEFT JOIN account_analytic_journal journal ON (journal.id = line.journal_id) WHERE account_id = %s AND journal.type = 'purchase' AND invoice_id IS NULL AND to_invoice IS NOT NULL GROUP BY product_id, user_id, to_invoice, product_uom_id, line.name""", (account.id,)) res[account.id] = 0.0 for product_id, total_amount, user_id, factor_id, qty, uom, line_name in cr.fetchall(): #the amount to reinvoice is the real cost. We don't use the pricelist total_amount = -total_amount factor = self.pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context=context) res[account.id] += total_amount * (100 - factor.factor or 0.0) / 100.0 return res def _expense_invoiced_calc(self, cr, uid, ids, name, arg, context=None): lines_obj = self.pool.get('account.analytic.line') res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = 0.0 line_ids = lines_obj.search(cr, uid, [('account_id','=', account.id), ('invoice_id','!=',False), ('to_invoice','!=', False), ('journal_id.type', '=', 'purchase')], context=context) #Put invoices in separate array in order not to calculate them double invoices = [] for line in lines_obj.browse(cr, uid, line_ids, context=context): if line.invoice_id not in invoices: invoices.append(line.invoice_id) for invoice in invoices: res[account.id] += invoice.amount_untaxed return res def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): result = super(account_analytic_account, self)._ca_invoiced_calc(cr, uid, ids, name, arg, context=context) for acc in self.browse(cr, uid, result.keys(), context=context): result[acc.id] = result[acc.id] - (acc.expense_invoiced or 0.0) return result _columns = { 'charge_expenses' : fields.boolean('Charge Expenses'), 'expense_invoiced' : fields.function(_expense_invoiced_calc, type="float"), 'expense_to_invoice' : fields.function(_expense_to_invoice_calc, type='float'), 'remaining_expense' : fields.function(_remaining_expnse_calc, type="float"), 'est_expenses': fields.float('Estimation of Expenses to Invoice'), 'ca_invoiced': fields.function(_ca_invoiced_calc, type='float', string='Invoiced Amount', help="Total customer invoiced amount for this account.", digits_compute=dp.get_precision('Account')), } def on_change_template(self, cr, uid, ids, template_id, date_start=False, context=None): res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, date_start=date_start, context=context) if template_id and 'value' in res: template = self.browse(cr, uid, template_id, context=context) res['value']['charge_expenses'] = template.charge_expenses res['value']['est_expenses'] = template.est_expenses return res def open_hr_expense(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') dummy, act_window_id = mod_obj.get_object_reference(cr, uid, 'hr_expense', 'expense_all') result = act_obj.read(cr, uid, [act_window_id], context=context)[0] line_ids = self.pool.get('hr.expense.line').search(cr,uid,[('analytic_account', 'in', ids)]) result['domain'] = [('line_ids', 'in', line_ids)] names = [account.name for account in self.browse(cr, uid, ids, context=context)] result['name'] = _('Expenses of %s') % ','.join(names) result['context'] = {'analytic_account': ids[0]} result['view_type'] = 'form' return result def hr_to_invoice_expense(self, cr, uid, ids, context=None): domain = [('invoice_id','=',False),('to_invoice','!=',False), ('journal_id.type', '=', 'purchase'), ('account_id', 'in', ids)] names = [record.name for record in self.browse(cr, uid, ids, context=context)] name = _('Expenses to Invoice of %s') % ','.join(names) return { 'type': 'ir.actions.act_window', 'name': name, 'view_type': 'form', 'view_mode': 'tree,form', 'domain' : domain, 'res_model': 'account.analytic.line', 'nodestroy': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 504, 5166, 14, 10788, 14, 6355, 63, 6833, 492, 6107, 63, 6833, 465, 12392, 199, 199, 533, 2933, 63, 9782, 63, 2048, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2048, 14, 9782, 14, 2048, 2, 272, 485, 6486, 275, 298, 2048, 14, 9782, 14, 2048, 2, 339, 347, 485, 362, 63, 2923, 63, 597, 8182, 8, 277, 12, 2933, 304, 267, 12657, 63, 597, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 597, 8182, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 12657, 63, 597, 847, 2933, 14, 597, 63, 16886, 83, 267, 372, 12657, 63, 597, 339, 347, 485, 362, 63, 2923, 63, 25614, 8, 277, 12, 2933, 304, 267, 3141, 63, 25614, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 25614, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 3141, 63, 25614, 847, 2933, 14, 16886, 63, 25614, 267, 372, 3141, 63, 25614, 339, 347, 485, 362, 63, 2923, 63, 11266, 8, 277, 12, 2933, 304, 267, 3141, 63, 11266, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 11266, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 3141, 63, 11266, 847, 2933, 14, 11266, 63, 16886, 267, 372, 3141, 63, 11266, 339, 347, 485, 362, 63, 2923, 63, 475, 5404, 8, 277, 12, 2933, 304, 267, 3141, 63, 475, 5404, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 475, 5404, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 3141, 63, 475, 5404, 847, 2933, 14, 16886, 63, 475, 63, 5404, 267, 372, 3141, 63, 475, 5404, 339, 347, 485, 11266, 63, 1474, 19315, 63, 8104, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 367, 2933, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 2933, 14, 597, 63, 16886, 83, 1137, 378, 26, 355, 522, 59, 2048, 14, 344, 61, 275, 1390, 8, 2048, 14, 597, 63, 16886, 83, 446, 2933, 14, 16886, 63, 25614, 12, 2933, 14, 16886, 63, 475, 63, 5404, 9, 288, 587, 26, 355, 522, 59, 2048, 14, 344, 10404, 16, 14, 16, 267, 372, 522, 339, 347, 485, 16886, 63, 475, 63, 5404, 63, 8104, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 327, 6004, 2793, 1133, 2934, 406, 18533, 425, 367, 1924, 402, 3520, 1504, 2952, 5204, 6114, 14009, 365, 2073, 13, 71, 24737, 14, 267, 367, 2933, 315, 291, 14, 2293, 14, 362, 360, 2048, 14, 9782, 14, 2048, 1959, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 2467, 14, 2526, 4852, 355, 10468, 3336, 63, 344, 12, 3089, 8, 4606, 395, 922, 63, 344, 12, 370, 63, 5404, 12, 3089, 8, 3248, 63, 4606, 395, 3336, 63, 7519, 63, 344, 12, 1004, 14, 354, 355, 4442, 2933, 63, 9782, 63, 604, 1004, 490, 6578, 10593, 2933, 63, 9782, 63, 7067, 9605, 5258, 334, 7067, 14, 344, 275, 1004, 14, 7067, 63, 344, 9, 355, 6038, 2933, 63, 344, 275, 450, 83, 490, 2401, 9605, 14, 466, 275, 283, 9533, 7, 490, 2401, 8485, 63, 344, 2281, 5962, 490, 2401, 370, 63, 5404, 2281, 2845, 5962, 355, 15443, 6515, 3336, 63, 344, 12, 922, 63, 344, 12, 370, 63, 5404, 12, 3336, 63, 7519, 63, 344, 12, 1004, 14, 354, 7208, 334, 2048, 14, 344, 4641, 953, 522, 59, 2048, 14, 344, 61, 275, 378, 14, 16, 288, 367, 3336, 63, 344, 12, 3141, 63, 4606, 12, 922, 63, 344, 12, 6535, 63, 344, 12, 13556, 12, 19842, 12, 1004, 63, 354, 315, 2467, 14, 10174, 837, 355, 327, 1589, 5982, 370, 295, 5404, 365, 314, 3363, 7918, 14, 2136, 2793, 1133, 675, 314, 25162, 355, 3141, 63, 4606, 275, 446, 2923, 63, 4606, 355, 6535, 275, 291, 14, 2293, 14, 362, 360, 6271, 63, 17739, 63, 5404, 14, 4778, 1959, 4570, 8, 1556, 12, 1747, 12, 6535, 63, 344, 12, 1067, 29, 1100, 9, 355, 522, 59, 2048, 14, 344, 61, 847, 3141, 63, 4606, 627, 334, 1960, 446, 6535, 14, 4778, 503, 378, 14, 16, 9, 1182, 2948, 14, 16, 267, 372, 522, 339, 347, 485, 16886, 63, 25614, 63, 8104, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 2385, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 9782, 14, 604, 358, 267, 522, 275, 1052, 267, 367, 2933, 315 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 504, 5166, 14, 10788, 14, 6355, 63, 6833, 492, 6107, 63, 6833, 465, 12392, 199, 199, 533, 2933, 63, 9782, 63, 2048, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2048, 14, 9782, 14, 2048, 2, 272, 485, 6486, 275, 298, 2048, 14, 9782, 14, 2048, 2, 339, 347, 485, 362, 63, 2923, 63, 597, 8182, 8, 277, 12, 2933, 304, 267, 12657, 63, 597, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 597, 8182, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 12657, 63, 597, 847, 2933, 14, 597, 63, 16886, 83, 267, 372, 12657, 63, 597, 339, 347, 485, 362, 63, 2923, 63, 25614, 8, 277, 12, 2933, 304, 267, 3141, 63, 25614, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 25614, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 3141, 63, 25614, 847, 2933, 14, 16886, 63, 25614, 267, 372, 3141, 63, 25614, 339, 347, 485, 362, 63, 2923, 63, 11266, 8, 277, 12, 2933, 304, 267, 3141, 63, 11266, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 11266, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 3141, 63, 11266, 847, 2933, 14, 11266, 63, 16886, 267, 372, 3141, 63, 11266, 339, 347, 485, 362, 63, 2923, 63, 475, 5404, 8, 277, 12, 2933, 304, 267, 3141, 63, 475, 5404, 275, 1613, 8, 2048, 63, 9782, 63, 2048, 12, 291, 10445, 362, 63, 2923, 63, 475, 5404, 8, 2048, 9, 267, 340, 2933, 14, 16441, 63, 16886, 83, 26, 288, 3141, 63, 475, 5404, 847, 2933, 14, 16886, 63, 475, 63, 5404, 267, 372, 3141, 63, 475, 5404, 339, 347, 485, 11266, 63, 1474, 19315, 63, 8104, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 367, 2933, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 2933, 14, 597, 63, 16886, 83, 1137, 378, 26, 355, 522, 59, 2048, 14, 344, 61, 275, 1390, 8, 2048, 14, 597, 63, 16886, 83, 446, 2933, 14, 16886, 63, 25614, 12, 2933, 14, 16886, 63, 475, 63, 5404, 9, 288, 587, 26, 355, 522, 59, 2048, 14, 344, 10404, 16, 14, 16, 267, 372, 522, 339, 347, 485, 16886, 63, 475, 63, 5404, 63, 8104, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 327, 6004, 2793, 1133, 2934, 406, 18533, 425, 367, 1924, 402, 3520, 1504, 2952, 5204, 6114, 14009, 365, 2073, 13, 71, 24737, 14, 267, 367, 2933, 315, 291, 14, 2293, 14, 362, 360, 2048, 14, 9782, 14, 2048, 1959, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 2467, 14, 2526, 4852, 355, 10468, 3336, 63, 344, 12, 3089, 8, 4606, 395, 922, 63, 344, 12, 370, 63, 5404, 12, 3089, 8, 3248, 63, 4606, 395, 3336, 63, 7519, 63, 344, 12, 1004, 14, 354, 355, 4442, 2933, 63, 9782, 63, 604, 1004, 490, 6578, 10593, 2933, 63, 9782, 63, 7067, 9605, 5258, 334, 7067, 14, 344, 275, 1004, 14, 7067, 63, 344, 9, 355, 6038, 2933, 63, 344, 275, 450, 83, 490, 2401, 9605, 14, 466, 275, 283, 9533, 7, 490, 2401, 8485, 63, 344, 2281, 5962, 490, 2401, 370, 63, 5404, 2281, 2845, 5962, 355, 15443, 6515, 3336, 63, 344, 12, 922, 63, 344, 12, 370, 63, 5404, 12, 3336, 63, 7519, 63, 344, 12, 1004, 14, 354, 7208, 334, 2048, 14, 344, 4641, 953, 522, 59, 2048, 14, 344, 61, 275, 378, 14, 16, 288, 367, 3336, 63, 344, 12, 3141, 63, 4606, 12, 922, 63, 344, 12, 6535, 63, 344, 12, 13556, 12, 19842, 12, 1004, 63, 354, 315, 2467, 14, 10174, 837, 355, 327, 1589, 5982, 370, 295, 5404, 365, 314, 3363, 7918, 14, 2136, 2793, 1133, 675, 314, 25162, 355, 3141, 63, 4606, 275, 446, 2923, 63, 4606, 355, 6535, 275, 291, 14, 2293, 14, 362, 360, 6271, 63, 17739, 63, 5404, 14, 4778, 1959, 4570, 8, 1556, 12, 1747, 12, 6535, 63, 344, 12, 1067, 29, 1100, 9, 355, 522, 59, 2048, 14, 344, 61, 847, 3141, 63, 4606, 627, 334, 1960, 446, 6535, 14, 4778, 503, 378, 14, 16, 9, 1182, 2948, 14, 16, 267, 372, 522, 339, 347, 485, 16886, 63, 25614, 63, 8104, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 2385, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 9782, 14, 604, 358, 267, 522, 275, 1052, 267, 367, 2933, 315, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
homework/nox
src/nox/netapps/tests/pyunittests/dhcp_parse_test.py
10
4271
# Copyright 2008 (C) Nicira, Inc. # # This file is part of NOX. # # NOX 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 3 of the License, or # (at your option) any later version. # # NOX 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with NOX. If not, see <http://www.gnu.org/licenses/>. import array from nox.lib.packet.ethernet import * from nox.netapps.tests import unittest pyunit = __import__('unittest') large_dhcp = \ """\ \xff\xff\xff\xff\xff\xff\x00\x1d\x09\x21\x7f\x14\x08\x00\x45\x00\ \x02\x40\x00\x00\x00\x00\x40\x11\x78\xae\x00\x00\x00\x00\xff\xff\ \xff\xff\x00\x44\x00\x43\x02\x2c\x5e\xe2\x01\x01\x06\x00\x95\x14\ \xf7\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x1d\x09\x21\x7f\x14\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x63\x82\x53\x63\x35\x01\x01\x3d\x07\x01\ \x00\x1d\x09\x21\x7f\x14\x3c\x06\x75\x64\x68\x63\x70\x20\x37\x07\ \x01\x03\x06\x0c\x0f\x1c\x2c\xff\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ """ class DHCPTestCase(unittest.NoxTestCase): def getInterface(self): return str(DHCPTestCase) def setUp(self): pass def tearDown(self): pass def fullDHCPPacket(self): eth = ethernet(array('B',large_dhcp)) udph = eth.find('udp') iph = eth.find('ipv4') dhcph = eth.find('dhcp') assert(dhcph) assert(dhcph.op == 1) assert(dhcph.htype == 1) assert(dhcph.hlen == 6) assert(dhcph.hops == 0) assert(dhcph.xid == 0x9514f72d) assert(dhcph.secs == 0) assert(dhcph.flags == 0) assert(dhcph.ciaddr == 0) assert(dhcph.yiaddr == 0) assert(dhcph.siaddr == 0) assert(dhcph.giaddr == 0) assert(array_to_octstr(dhcph.chaddr[:6]) == '00:1d:09:21:7f:14') assert(len(dhcph.parsedOptions.keys()) == 4) def suite(ctxt): suite = pyunit.TestSuite() suite.addTest(DHCPTestCase("fullDHCPPacket", ctxt)) return suite
gpl-3.0
[ 3, 1898, 9079, 334, 35, 9, 653, 530, 20936, 12, 3277, 14, 199, 3, 221, 199, 3, 961, 570, 365, 1777, 402, 4825, 56, 14, 199, 3, 221, 199, 3, 4825, 56, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 4825, 56, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 4825, 56, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 1625, 199, 504, 949, 88, 14, 773, 14, 6253, 14, 20354, 492, 627, 199, 504, 949, 88, 14, 846, 5181, 14, 2219, 492, 2882, 199, 199, 647, 3248, 275, 636, 646, 19734, 2796, 358, 199, 199, 9629, 63, 10801, 275, 971, 199, 19659, 199, 60, 3581, 60, 3581, 60, 3581, 60, 3581, 60, 3581, 60, 3581, 60, 88, 383, 60, 88, 17, 68, 60, 88, 1643, 60, 88, 2025, 60, 88, 23, 70, 60, 88, 1079, 60, 88, 2036, 60, 88, 383, 60, 88, 2322, 60, 88, 383, 60, 199, 60, 88, 996, 60, 88, 2167, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 2167, 60, 88, 845, 60, 88, 2277, 60, 10183, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 3581, 60, 3581, 60, 199, 60, 3581, 60, 3581, 60, 88, 383, 60, 88, 1602, 60, 88, 383, 60, 88, 2824, 60, 88, 996, 60, 88, 18, 67, 60, 88, 21, 69, 60, 1845, 18, 60, 88, 614, 60, 88, 614, 60, 88, 1690, 60, 88, 383, 60, 88, 2720, 60, 88, 1079, 60, 199, 60, 1949, 23, 60, 88, 18, 68, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 17, 68, 60, 88, 1643, 60, 88, 2025, 60, 88, 23, 70, 60, 88, 1079, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383 ]
[ 1898, 9079, 334, 35, 9, 653, 530, 20936, 12, 3277, 14, 199, 3, 221, 199, 3, 961, 570, 365, 1777, 402, 4825, 56, 14, 199, 3, 221, 199, 3, 4825, 56, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 4825, 56, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 4825, 56, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 1625, 199, 504, 949, 88, 14, 773, 14, 6253, 14, 20354, 492, 627, 199, 504, 949, 88, 14, 846, 5181, 14, 2219, 492, 2882, 199, 199, 647, 3248, 275, 636, 646, 19734, 2796, 358, 199, 199, 9629, 63, 10801, 275, 971, 199, 19659, 199, 60, 3581, 60, 3581, 60, 3581, 60, 3581, 60, 3581, 60, 3581, 60, 88, 383, 60, 88, 17, 68, 60, 88, 1643, 60, 88, 2025, 60, 88, 23, 70, 60, 88, 1079, 60, 88, 2036, 60, 88, 383, 60, 88, 2322, 60, 88, 383, 60, 199, 60, 88, 996, 60, 88, 2167, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 2167, 60, 88, 845, 60, 88, 2277, 60, 10183, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 3581, 60, 3581, 60, 199, 60, 3581, 60, 3581, 60, 88, 383, 60, 88, 1602, 60, 88, 383, 60, 88, 2824, 60, 88, 996, 60, 88, 18, 67, 60, 88, 21, 69, 60, 1845, 18, 60, 88, 614, 60, 88, 614, 60, 88, 1690, 60, 88, 383, 60, 88, 2720, 60, 88, 1079, 60, 199, 60, 1949, 23, 60, 88, 18, 68, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 17, 68, 60, 88, 1643, 60, 88, 2025, 60, 88, 23, 70, 60, 88, 1079, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 199, 60, 88, 383, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
HyperloopTeam/FullOpenMDAO
lib/python2.7/site-packages/traits-4.3.0-py2.7-macosx-10.10-x86_64.egg/traits/tests/dict_test_case.py
1
3621
#------------------------------------------------------------------------------ # # Copyright (c) 2007, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in /LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Test cases for dictionary (Dict) traits. """ from __future__ import absolute_import from traits.testing.unittest_tools import unittest from ..api import on_trait_change, Dict, Event, HasTraits, Str # fixme: We'd like to use a callable instance for the listener so that we # can maintain state, but traits barfs trying to determine the signature 8^() def create_listener(): """ Create a listener for testing trait notifications. """ def listener(obj, trait_name, old, new): listener.obj = obj listener.trait_name = trait_name listener.new = new listener.old = old listener.called += 1 return listener.initialize = lambda : initialize_listener(listener) return initialize_listener(listener) def initialize_listener(listener): """ Initialize a listener so it looks like it hasn't been called. This allows us to re-use the listener without having to create and wire-up a new one. """ listener.obj = None listener.trait_name = None listener.old = None listener.new = None listener.called = 0 return listener # For convenience class DictTestCase(unittest.TestCase): """ Test cases for dictionary (Dict) traits. """ def test_modified_event(self): class Foo(HasTraits): name = Str modified = Event @on_trait_change('name') def _fire_modified_event(self): self.modified = True return class Bar(HasTraits): foos = Dict(Str, Foo) modified = Event @on_trait_change('foos_items,foos.modified') def _fire_modified_event(self, obj, trait_name, old, new): self.modified = True return bar = Bar() listener = create_listener() bar.on_trait_change(listener, 'modified') # Assign a completely new dictionary. bar.foos = {'dino' : Foo(name='dino')} self.assertEqual(1, listener.called) self.assertEqual('modified', listener.trait_name) # Add an item to an existing dictionary. listener.initialize() fred = Foo(name='fred') bar.foos['fred'] = fred self.assertEqual(1, listener.called) self.assertEqual('modified', listener.trait_name) # Modify an item already in the dictionary. listener.initialize() fred.name = 'barney' self.assertEqual(1, listener.called) self.assertEqual('modified', listener.trait_name) # Overwrite an item in the dictionary. This is the one that fails! listener.initialize() bar.foos['fred'] = Foo(name='wilma') self.assertEqual(1, listener.called) self.assertEqual('modified', listener.trait_name) return if __name__ == '__main__': unittest.main() #### EOF ######################################################################
gpl-2.0
[ 20974, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 10219, 12, 3447, 273, 20816, 12, 3277, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 961, 2032, 365, 2741, 1928, 3750, 1334, 314, 2895, 402, 314, 6289, 199, 3, 221, 4190, 5120, 315, 1182, 3961, 14, 2424, 436, 1443, 506, 295, 16832, 1454, 199, 3, 221, 1334, 314, 3704, 11736, 315, 314, 282, 1707, 32016, 379, 4190, 14, 221, 710, 4190, 199, 3, 221, 365, 2597, 2808, 18470, 737, 1455, 921, 1544, 14, 287, 273, 20816, 14, 957, 15, 2383, 15, 15400, 14, 2424, 199, 3, 199, 3, 221, 3868, 25088, 367, 1808, 3447, 273, 20816, 1551, 1350, 1, 199, 3, 199, 20974, 199, 624, 1379, 5560, 367, 2600, 334, 2141, 9, 19692, 14, 408, 421, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 19692, 14, 4776, 14, 2796, 63, 2537, 492, 2882, 199, 199, 504, 2508, 1246, 492, 641, 63, 22687, 63, 1461, 12, 7448, 12, 6763, 12, 13481, 31116, 12, 8303, 421, 199, 3, 5325, 278, 26, 2136, 5121, 2839, 370, 675, 282, 4550, 1256, 367, 314, 11647, 880, 626, 781, 199, 3, 883, 11075, 1174, 12, 1325, 19692, 4681, 2319, 9936, 370, 6705, 314, 4955, 1695, 62, 342, 199, 318, 1218, 63, 9799, 837, 272, 408, 2790, 282, 11647, 367, 5343, 30576, 13116, 14, 408, 339, 347, 11647, 8, 1113, 12, 30576, 63, 354, 12, 2269, 12, 892, 304, 398, 11647, 14, 1113, 263, 275, 1559, 267, 11647, 14, 22687, 63, 354, 275, 30576, 63, 354, 267, 11647, 14, 1222, 263, 275, 892, 267, 11647, 14, 1753, 263, 275, 2269, 267, 11647, 14, 3527, 258, 847, 413, 398, 372, 339, 11647, 14, 8489, 275, 2400, 520, 8265, 63, 9799, 8, 9799, 9, 2286, 372, 8265, 63, 9799, 8, 9799, 9, 199, 199, 318, 8265, 63, 9799, 8, 9799, 304, 272, 408, 11578, 282, 11647, 880, 652, 10734, 2839, 652, 18699, 1133, 2757, 2797, 14, 339, 961, 6127, 2739, 370, 295, 13, 1180, 314, 11647, 1928, 9445, 370, 1218, 436, 272, 11799, 13, 384, 282, 892, 1373, 14, 339, 408, 339, 11647, 14, 1113, 263, 275, 488, 272, 11647, 14, 22687, 63, 354, 275, 488, 272, 11647, 14, 1753, 263, 275, 488, 272, 11647, 14, 1222, 263, 275, 488, 272, 11647, 14, 3527, 258, 275, 378, 2286, 372, 11647, 327, 2104, 16777, 4388, 199, 533, 7448, 1746, 8, 2796, 14, 1746, 304, 272, 408, 1379, 5560, 367, 2600, 334, 2141, 9, 19692, 14, 408, 339, 347, 511, 63, 5540, 63, 1430, 8, 277, 304, 398, 1021, 8024, 8, 6362, 31116, 304, 288, 536, 258, 275, 8303, 288, 6042, 275, 6763, 7846, 768, 265, 63, 22687, 63, 1461, 360, 354, 358, 288, 347, 485, 8935, 63, 5540, 63, 1430, 8, 277, 304, 355, 291, 14, 5540, 275, 715, 355, 372, 2728, 1021, 12377, 8, 6362, 31116, 304, 288, 7090, 736, 258, 275, 7448, 8, 2848, 12, 8024, 9, 288, 6042, 275, 6763, 7846, 768, 265, 63, 22687, 63, 1461, 360, 545, 736, 63, 1744, 12, 545, 736, 14, 5540, 358, 288, 347, 485, 8935, 63, 5540, 63, 1430, 8, 277, 12, 1559, 12, 30576, 63, 354, 12, 2269, 12, 892, 304, 355, 291, 14, 5540, 275, 715, 355, 372, 398, 4681, 275, 12377, 342, 267, 11647, 275, 1218, 63, 9799, 342, 267, 4681, 14, 265, 63, 22687, 63, 1461, 8, 9799, 12, 283, 5540, 358, 398, 327, 16927, 282, 14793, 892, 2600, 14, 267, 4681, 14, 545, 736, 275, 791, 68, 10175, 7, 520, 8024, 8, 354, 534, 68, 10175, 21004, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 2728, 327, 2654, 376, 1242, 370, 376, 3411, 2600, 14, 267, 11647, 14, 8489, 342, 267, 289, 581, 275, 8024, 8, 354, 534, 22980, 358, 267, 4681, 14, 545, 736, 459, 22980, 418, 275, 289, 581, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 398, 327, 22520, 376, 1242, 2575, 315, 314, 2600, 14, 267, 11647, 14, 8489, 342, 267, 289, 581, 14, 354, 275, 283, 1700, 23263, 7, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 398, 327, 7259, 952, 376, 1242, 315, 314, 2600, 14, 961, 365, 314, 1373, 626, 6918, 1, 267, 11647, 14, 8489, 342, 267, 4681, 14, 545, 736, 459, 22980, 418, 275, 8024, 8, 354, 534, 87, 382, 391, 358, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 398, 372, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 199, 381, 9027, 15779, 3726, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 199, 3, 221, 1898, 334, 67, 9, 10219, 12, 3447, 273, 20816, 12, 3277, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 961, 2032, 365, 2741, 1928, 3750, 1334, 314, 2895, 402, 314, 6289, 199, 3, 221, 4190, 5120, 315, 1182, 3961, 14, 2424, 436, 1443, 506, 295, 16832, 1454, 199, 3, 221, 1334, 314, 3704, 11736, 315, 314, 282, 1707, 32016, 379, 4190, 14, 221, 710, 4190, 199, 3, 221, 365, 2597, 2808, 18470, 737, 1455, 921, 1544, 14, 287, 273, 20816, 14, 957, 15, 2383, 15, 15400, 14, 2424, 199, 3, 199, 3, 221, 3868, 25088, 367, 1808, 3447, 273, 20816, 1551, 1350, 1, 199, 3, 199, 20974, 199, 624, 1379, 5560, 367, 2600, 334, 2141, 9, 19692, 14, 408, 421, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 19692, 14, 4776, 14, 2796, 63, 2537, 492, 2882, 199, 199, 504, 2508, 1246, 492, 641, 63, 22687, 63, 1461, 12, 7448, 12, 6763, 12, 13481, 31116, 12, 8303, 421, 199, 3, 5325, 278, 26, 2136, 5121, 2839, 370, 675, 282, 4550, 1256, 367, 314, 11647, 880, 626, 781, 199, 3, 883, 11075, 1174, 12, 1325, 19692, 4681, 2319, 9936, 370, 6705, 314, 4955, 1695, 62, 342, 199, 318, 1218, 63, 9799, 837, 272, 408, 2790, 282, 11647, 367, 5343, 30576, 13116, 14, 408, 339, 347, 11647, 8, 1113, 12, 30576, 63, 354, 12, 2269, 12, 892, 304, 398, 11647, 14, 1113, 263, 275, 1559, 267, 11647, 14, 22687, 63, 354, 275, 30576, 63, 354, 267, 11647, 14, 1222, 263, 275, 892, 267, 11647, 14, 1753, 263, 275, 2269, 267, 11647, 14, 3527, 258, 847, 413, 398, 372, 339, 11647, 14, 8489, 275, 2400, 520, 8265, 63, 9799, 8, 9799, 9, 2286, 372, 8265, 63, 9799, 8, 9799, 9, 199, 199, 318, 8265, 63, 9799, 8, 9799, 304, 272, 408, 11578, 282, 11647, 880, 652, 10734, 2839, 652, 18699, 1133, 2757, 2797, 14, 339, 961, 6127, 2739, 370, 295, 13, 1180, 314, 11647, 1928, 9445, 370, 1218, 436, 272, 11799, 13, 384, 282, 892, 1373, 14, 339, 408, 339, 11647, 14, 1113, 263, 275, 488, 272, 11647, 14, 22687, 63, 354, 275, 488, 272, 11647, 14, 1753, 263, 275, 488, 272, 11647, 14, 1222, 263, 275, 488, 272, 11647, 14, 3527, 258, 275, 378, 2286, 372, 11647, 327, 2104, 16777, 4388, 199, 533, 7448, 1746, 8, 2796, 14, 1746, 304, 272, 408, 1379, 5560, 367, 2600, 334, 2141, 9, 19692, 14, 408, 339, 347, 511, 63, 5540, 63, 1430, 8, 277, 304, 398, 1021, 8024, 8, 6362, 31116, 304, 288, 536, 258, 275, 8303, 288, 6042, 275, 6763, 7846, 768, 265, 63, 22687, 63, 1461, 360, 354, 358, 288, 347, 485, 8935, 63, 5540, 63, 1430, 8, 277, 304, 355, 291, 14, 5540, 275, 715, 355, 372, 2728, 1021, 12377, 8, 6362, 31116, 304, 288, 7090, 736, 258, 275, 7448, 8, 2848, 12, 8024, 9, 288, 6042, 275, 6763, 7846, 768, 265, 63, 22687, 63, 1461, 360, 545, 736, 63, 1744, 12, 545, 736, 14, 5540, 358, 288, 347, 485, 8935, 63, 5540, 63, 1430, 8, 277, 12, 1559, 12, 30576, 63, 354, 12, 2269, 12, 892, 304, 355, 291, 14, 5540, 275, 715, 355, 372, 398, 4681, 275, 12377, 342, 267, 11647, 275, 1218, 63, 9799, 342, 267, 4681, 14, 265, 63, 22687, 63, 1461, 8, 9799, 12, 283, 5540, 358, 398, 327, 16927, 282, 14793, 892, 2600, 14, 267, 4681, 14, 545, 736, 275, 791, 68, 10175, 7, 520, 8024, 8, 354, 534, 68, 10175, 21004, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 2728, 327, 2654, 376, 1242, 370, 376, 3411, 2600, 14, 267, 11647, 14, 8489, 342, 267, 289, 581, 275, 8024, 8, 354, 534, 22980, 358, 267, 4681, 14, 545, 736, 459, 22980, 418, 275, 289, 581, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 398, 327, 22520, 376, 1242, 2575, 315, 314, 2600, 14, 267, 11647, 14, 8489, 342, 267, 289, 581, 14, 354, 275, 283, 1700, 23263, 7, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 398, 327, 7259, 952, 376, 1242, 315, 314, 2600, 14, 961, 365, 314, 1373, 626, 6918, 1, 267, 11647, 14, 8489, 342, 267, 4681, 14, 545, 736, 459, 22980, 418, 275, 8024, 8, 354, 534, 87, 382, 391, 358, 267, 291, 14, 629, 8, 17, 12, 11647, 14, 3527, 9, 267, 291, 14, 629, 360, 5540, 297, 11647, 14, 22687, 63, 354, 9, 398, 372, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 199, 381, 9027, 15779, 3726, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
azaghal/ansible
test/units/module_utils/common/text/converters/test_to_str.py
27
2519
# -*- coding: utf-8 -*- # (c) 2016 Toshio Kuratomi <tkuratomi@ansible.com> # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type import itertools import pytest from ansible.module_utils.six import PY3 from ansible.module_utils.common.text.converters import to_text, to_bytes, to_native from ansible.utils.unsafe_proxy import AnsibleUnsafeBytes, AnsibleUnsafeText # Format: byte representation, text representation, encoding of byte representation VALID_STRINGS = ( (b'abcde', u'abcde', 'ascii'), (b'caf\xc3\xa9', u'caf\xe9', 'utf-8'), (b'caf\xe9', u'caf\xe9', 'latin-1'), # u'くらとみ' (b'\xe3\x81\x8f\xe3\x82\x89\xe3\x81\xa8\xe3\x81\xbf', u'\u304f\u3089\u3068\u307f', 'utf-8'), (b'\x82\xad\x82\xe7\x82\xc6\x82\xdd', u'\u304f\u3089\u3068\u307f', 'shift-jis'), ) @pytest.mark.parametrize('in_string, encoding, expected', itertools.chain(((d[0], d[2], d[1]) for d in VALID_STRINGS), ((d[1], d[2], d[1]) for d in VALID_STRINGS))) def test_to_text(in_string, encoding, expected): """test happy path of decoding to text""" assert to_text(in_string, encoding) == expected @pytest.mark.parametrize('in_string, encoding, expected', itertools.chain(((d[0], d[2], d[0]) for d in VALID_STRINGS), ((d[1], d[2], d[0]) for d in VALID_STRINGS))) def test_to_bytes(in_string, encoding, expected): """test happy path of encoding to bytes""" assert to_bytes(in_string, encoding) == expected @pytest.mark.parametrize('in_string, encoding, expected', itertools.chain(((d[0], d[2], d[1] if PY3 else d[0]) for d in VALID_STRINGS), ((d[1], d[2], d[1] if PY3 else d[0]) for d in VALID_STRINGS))) def test_to_native(in_string, encoding, expected): """test happy path of encoding to native strings""" assert to_native(in_string, encoding) == expected def test_to_text_unsafe(): assert isinstance(to_text(AnsibleUnsafeBytes(b'foo')), AnsibleUnsafeText) assert to_text(AnsibleUnsafeBytes(b'foo')) == AnsibleUnsafeText(u'foo') def test_to_bytes_unsafe(): assert isinstance(to_bytes(AnsibleUnsafeText(u'foo')), AnsibleUnsafeBytes) assert to_bytes(AnsibleUnsafeText(u'foo')) == AnsibleUnsafeBytes(b'foo')
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 1898, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 7975, 199, 199, 646, 4613, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 7843, 19, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 14, 505, 14, 17911, 492, 370, 63, 505, 12, 370, 63, 2394, 12, 370, 63, 6106, 199, 504, 3242, 14, 1208, 14, 14242, 63, 3280, 492, 2622, 9251, 6504, 5571, 12, 2622, 9251, 6504, 1872, 421, 199, 3, 9701, 26, 3696, 6025, 12, 1318, 6025, 12, 2644, 402, 3696, 6025, 199, 5600, 63, 31271, 275, 334, 272, 334, 66, 7, 28109, 297, 399, 7, 28109, 297, 283, 4371, 659, 272, 334, 66, 7, 27956, 60, 1812, 19, 60, 1800, 25, 297, 399, 7, 27956, 60, 1845, 25, 297, 283, 1624, 13, 24, 659, 272, 334, 66, 7, 27956, 60, 1845, 25, 297, 399, 7, 27956, 60, 1845, 25, 297, 283, 10378, 13, 17, 659, 272, 327, 399, 7, 4197, 238, 5573, 232, 29472, 4197, 124, 7, 272, 334, 66, 1154, 1845, 19, 60, 88, 2835, 60, 88, 24, 70, 60, 1845, 19, 60, 88, 2564, 60, 88, 1407, 60, 1845, 19, 60, 88, 2835, 60, 1800, 24, 60, 1845, 19, 60, 88, 2835, 60, 9566, 297, 399, 1154, 85, 8533, 70, 60, 85, 1216, 1407, 60, 85, 1216, 2333, 60, 85, 11516, 70, 297, 283, 1624, 13, 24, 659, 272, 334, 66, 1154, 88, 2564, 60, 10135, 60, 88, 2564, 60, 1845, 23, 60, 88, 2564, 60, 1812, 22, 60, 88, 2564, 60, 11110, 297, 399, 1154, 85, 8533, 70, 60, 85, 1216, 1407, 60, 85, 1216, 2333, 60, 85, 11516, 70, 297, 283, 4723, 13, 18941, 659, 199, 9, 421, 199, 32, 4462, 14, 1657, 14, 10396, 360, 262, 63, 875, 12, 2644, 12, 1420, 297, 586, 7975, 14, 4429, 12925, 68, 59, 16, 467, 366, 59, 18, 467, 366, 59, 17, 566, 367, 366, 315, 22049, 63, 31271, 395, 1460, 3666, 68, 59, 17, 467, 366, 59, 18, 467, 366, 59, 17, 566, 367, 366, 315, 22049, 63, 31271, 1724, 199, 318, 511, 63, 475, 63, 505, 8, 262, 63, 875, 12, 2644, 12, 1420, 304, 272, 408, 396, 394, 18869, 931, 402, 15952, 370, 1318, 624, 272, 702, 370, 63, 505, 8, 262, 63, 875, 12, 2644, 9, 508, 1420, 421, 199, 32, 4462, 14, 1657, 14, 10396, 360, 262, 63, 875, 12, 2644, 12, 1420, 297, 586, 7975, 14, 4429, 12925, 68, 59, 16, 467, 366, 59, 18, 467, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 395, 1460, 3666, 68, 59, 17, 467, 366, 59, 18, 467, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 1724, 199, 318, 511, 63, 475, 63, 2394, 8, 262, 63, 875, 12, 2644, 12, 1420, 304, 272, 408, 396, 394, 18869, 931, 402, 2644, 370, 2783, 624, 272, 702, 370, 63, 2394, 8, 262, 63, 875, 12, 2644, 9, 508, 1420, 421, 199, 32, 4462, 14, 1657, 14, 10396, 360, 262, 63, 875, 12, 2644, 12, 1420, 297, 586, 7975, 14, 4429, 12925, 68, 59, 16, 467, 366, 59, 18, 467, 366, 59, 17, 61, 340, 7843, 19, 587, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 395, 1460, 3666, 68, 59, 17, 467, 366, 59, 18, 467, 366, 59, 17, 61, 340, 7843, 19, 587, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 1724, 199, 318, 511, 63, 475, 63, 6106, 8, 262, 63, 875, 12, 2644, 12, 1420, 304, 272, 408, 396, 394, 18869, 931, 402, 2644, 370, 5438, 3326, 624, 272, 702, 370, 63, 6106, 8, 262, 63, 875, 12, 2644, 9, 508, 1420, 421, 199, 318, 511, 63, 475, 63, 505, 63, 14242, 837, 272, 702, 1228, 8, 475, 63, 505, 8, 10047, 9251, 6504, 5571, 8, 66, 7, 1421, 3855, 2622, 9251, 6504, 1872, 9, 272, 702, 370, 63, 505, 8, 10047, 9251, 6504, 5571, 8, 66, 7, 1421, 1333, 508, 2622, 9251, 6504, 1872, 8, 85, 7, 1421, 358, 421, 199, 318, 511, 63, 475, 63, 2394, 63, 14242, 837, 272, 702, 1228, 8, 475, 63, 2394, 8, 10047, 9251, 6504, 1872, 8, 85, 7, 1421, 3855, 2622, 9251, 6504, 5571, 9, 272, 702, 370, 63, 2394, 8, 10047, 9251, 6504, 1872, 8, 85, 7, 1421, 1333, 508, 2622, 9251, 6504, 5571, 8, 66, 7, 1421, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 1898, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 7975, 199, 199, 646, 4613, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 7843, 19, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 14, 505, 14, 17911, 492, 370, 63, 505, 12, 370, 63, 2394, 12, 370, 63, 6106, 199, 504, 3242, 14, 1208, 14, 14242, 63, 3280, 492, 2622, 9251, 6504, 5571, 12, 2622, 9251, 6504, 1872, 421, 199, 3, 9701, 26, 3696, 6025, 12, 1318, 6025, 12, 2644, 402, 3696, 6025, 199, 5600, 63, 31271, 275, 334, 272, 334, 66, 7, 28109, 297, 399, 7, 28109, 297, 283, 4371, 659, 272, 334, 66, 7, 27956, 60, 1812, 19, 60, 1800, 25, 297, 399, 7, 27956, 60, 1845, 25, 297, 283, 1624, 13, 24, 659, 272, 334, 66, 7, 27956, 60, 1845, 25, 297, 399, 7, 27956, 60, 1845, 25, 297, 283, 10378, 13, 17, 659, 272, 327, 399, 7, 4197, 238, 5573, 232, 29472, 4197, 124, 7, 272, 334, 66, 1154, 1845, 19, 60, 88, 2835, 60, 88, 24, 70, 60, 1845, 19, 60, 88, 2564, 60, 88, 1407, 60, 1845, 19, 60, 88, 2835, 60, 1800, 24, 60, 1845, 19, 60, 88, 2835, 60, 9566, 297, 399, 1154, 85, 8533, 70, 60, 85, 1216, 1407, 60, 85, 1216, 2333, 60, 85, 11516, 70, 297, 283, 1624, 13, 24, 659, 272, 334, 66, 1154, 88, 2564, 60, 10135, 60, 88, 2564, 60, 1845, 23, 60, 88, 2564, 60, 1812, 22, 60, 88, 2564, 60, 11110, 297, 399, 1154, 85, 8533, 70, 60, 85, 1216, 1407, 60, 85, 1216, 2333, 60, 85, 11516, 70, 297, 283, 4723, 13, 18941, 659, 199, 9, 421, 199, 32, 4462, 14, 1657, 14, 10396, 360, 262, 63, 875, 12, 2644, 12, 1420, 297, 586, 7975, 14, 4429, 12925, 68, 59, 16, 467, 366, 59, 18, 467, 366, 59, 17, 566, 367, 366, 315, 22049, 63, 31271, 395, 1460, 3666, 68, 59, 17, 467, 366, 59, 18, 467, 366, 59, 17, 566, 367, 366, 315, 22049, 63, 31271, 1724, 199, 318, 511, 63, 475, 63, 505, 8, 262, 63, 875, 12, 2644, 12, 1420, 304, 272, 408, 396, 394, 18869, 931, 402, 15952, 370, 1318, 624, 272, 702, 370, 63, 505, 8, 262, 63, 875, 12, 2644, 9, 508, 1420, 421, 199, 32, 4462, 14, 1657, 14, 10396, 360, 262, 63, 875, 12, 2644, 12, 1420, 297, 586, 7975, 14, 4429, 12925, 68, 59, 16, 467, 366, 59, 18, 467, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 395, 1460, 3666, 68, 59, 17, 467, 366, 59, 18, 467, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 1724, 199, 318, 511, 63, 475, 63, 2394, 8, 262, 63, 875, 12, 2644, 12, 1420, 304, 272, 408, 396, 394, 18869, 931, 402, 2644, 370, 2783, 624, 272, 702, 370, 63, 2394, 8, 262, 63, 875, 12, 2644, 9, 508, 1420, 421, 199, 32, 4462, 14, 1657, 14, 10396, 360, 262, 63, 875, 12, 2644, 12, 1420, 297, 586, 7975, 14, 4429, 12925, 68, 59, 16, 467, 366, 59, 18, 467, 366, 59, 17, 61, 340, 7843, 19, 587, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 395, 1460, 3666, 68, 59, 17, 467, 366, 59, 18, 467, 366, 59, 17, 61, 340, 7843, 19, 587, 366, 59, 16, 566, 367, 366, 315, 22049, 63, 31271, 1724, 199, 318, 511, 63, 475, 63, 6106, 8, 262, 63, 875, 12, 2644, 12, 1420, 304, 272, 408, 396, 394, 18869, 931, 402, 2644, 370, 5438, 3326, 624, 272, 702, 370, 63, 6106, 8, 262, 63, 875, 12, 2644, 9, 508, 1420, 421, 199, 318, 511, 63, 475, 63, 505, 63, 14242, 837, 272, 702, 1228, 8, 475, 63, 505, 8, 10047, 9251, 6504, 5571, 8, 66, 7, 1421, 3855, 2622, 9251, 6504, 1872, 9, 272, 702, 370, 63, 505, 8, 10047, 9251, 6504, 5571, 8, 66, 7, 1421, 1333, 508, 2622, 9251, 6504, 1872, 8, 85, 7, 1421, 358, 421, 199, 318, 511, 63, 475, 63, 2394, 63, 14242, 837, 272, 702, 1228, 8, 475, 63, 2394, 8, 10047, 9251, 6504, 1872, 8, 85, 7, 1421, 3855, 2622, 9251, 6504, 5571, 9, 272, 702, 370, 63, 2394, 8, 10047, 9251, 6504, 1872, 8, 85, 7, 1421, 1333, 508, 2622, 9251, 6504, 5571, 8, 66, 7, 1421, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mcking49/apache-flask
Python/Lib/site-packages/pip/_vendor/distlib/version.py
132
23711
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2016 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # """ Implementation of a flexible versioning scheme providing support for PEP-440, setuptools-compatible and semantic versioning. """ import logging import re from .compat import string_types __all__ = ['NormalizedVersion', 'NormalizedMatcher', 'LegacyVersion', 'LegacyMatcher', 'SemanticVersion', 'SemanticMatcher', 'UnsupportedVersionError', 'get_scheme'] logger = logging.getLogger(__name__) class UnsupportedVersionError(ValueError): """This is an unsupported version.""" pass class Version(object): def __init__(self, s): self._string = s = s.strip() self._parts = parts = self.parse(s) assert isinstance(parts, tuple) assert len(parts) > 0 def parse(self, s): raise NotImplementedError('please implement in a subclass') def _check_compatible(self, other): if type(self) != type(other): raise TypeError('cannot compare %r and %r' % (self, other)) def __eq__(self, other): self._check_compatible(other) return self._parts == other._parts def __ne__(self, other): return not self.__eq__(other) def __lt__(self, other): self._check_compatible(other) return self._parts < other._parts def __gt__(self, other): return not (self.__lt__(other) or self.__eq__(other)) def __le__(self, other): return self.__lt__(other) or self.__eq__(other) def __ge__(self, other): return self.__gt__(other) or self.__eq__(other) # See http://docs.python.org/reference/datamodel#object.__hash__ def __hash__(self): return hash(self._parts) def __repr__(self): return "%s('%s')" % (self.__class__.__name__, self._string) def __str__(self): return self._string @property def is_prerelease(self): raise NotImplementedError('Please implement in subclasses.') class Matcher(object): version_class = None dist_re = re.compile(r"^(\w[\s\w'.-]*)(\((.*)\))?") comp_re = re.compile(r'^(<=|>=|<|>|!=|={2,3}|~=)?\s*([^\s,]+)$') num_re = re.compile(r'^\d+(\.\d+)*$') # value is either a callable or the name of a method _operators = { '<': lambda v, c, p: v < c, '>': lambda v, c, p: v > c, '<=': lambda v, c, p: v == c or v < c, '>=': lambda v, c, p: v == c or v > c, '==': lambda v, c, p: v == c, '===': lambda v, c, p: v == c, # by default, compatible => >=. '~=': lambda v, c, p: v == c or v > c, '!=': lambda v, c, p: v != c, } def __init__(self, s): if self.version_class is None: raise ValueError('Please specify a version class') self._string = s = s.strip() m = self.dist_re.match(s) if not m: raise ValueError('Not valid: %r' % s) groups = m.groups('') self.name = groups[0].strip() self.key = self.name.lower() # for case-insensitive comparisons clist = [] if groups[2]: constraints = [c.strip() for c in groups[2].split(',')] for c in constraints: m = self.comp_re.match(c) if not m: raise ValueError('Invalid %r in %r' % (c, s)) groups = m.groups() op = groups[0] or '~=' s = groups[1] if s.endswith('.*'): if op not in ('==', '!='): raise ValueError('\'.*\' not allowed for ' '%r constraints' % op) # Could be a partial version (e.g. for '2.*') which # won't parse as a version, so keep it as a string vn, prefix = s[:-2], True if not self.num_re.match(vn): # Just to check that vn is a valid version self.version_class(vn) else: # Should parse as a version, so we can create an # instance for the comparison vn, prefix = self.version_class(s), False clist.append((op, vn, prefix)) self._parts = tuple(clist) def match(self, version): """ Check if the provided version matches the constraints. :param version: The version to match against this instance. :type version: Strring or :class:`Version` instance. """ if isinstance(version, string_types): version = self.version_class(version) for operator, constraint, prefix in self._parts: f = self._operators.get(operator) if isinstance(f, string_types): f = getattr(self, f) if not f: msg = ('%r not implemented ' 'for %s' % (operator, self.__class__.__name__)) raise NotImplementedError(msg) if not f(version, constraint, prefix): return False return True @property def exact_version(self): result = None if len(self._parts) == 1 and self._parts[0][0] in ('==', '==='): result = self._parts[0][1] return result def _check_compatible(self, other): if type(self) != type(other) or self.name != other.name: raise TypeError('cannot compare %s and %s' % (self, other)) def __eq__(self, other): self._check_compatible(other) return self.key == other.key and self._parts == other._parts def __ne__(self, other): return not self.__eq__(other) # See http://docs.python.org/reference/datamodel#object.__hash__ def __hash__(self): return hash(self.key) + hash(self._parts) def __repr__(self): return "%s(%r)" % (self.__class__.__name__, self._string) def __str__(self): return self._string PEP440_VERSION_RE = re.compile(r'^v?(\d+!)?(\d+(\.\d+)*)((a|b|c|rc)(\d+))?' r'(\.(post)(\d+))?(\.(dev)(\d+))?' r'(\+([a-zA-Z\d]+(\.[a-zA-Z\d]+)?))?$') def _pep_440_key(s): s = s.strip() m = PEP440_VERSION_RE.match(s) if not m: raise UnsupportedVersionError('Not a valid version: %s' % s) groups = m.groups() nums = tuple(int(v) for v in groups[1].split('.')) while len(nums) > 1 and nums[-1] == 0: nums = nums[:-1] if not groups[0]: epoch = 0 else: epoch = int(groups[0]) pre = groups[4:6] post = groups[7:9] dev = groups[10:12] local = groups[13] if pre == (None, None): pre = () else: pre = pre[0], int(pre[1]) if post == (None, None): post = () else: post = post[0], int(post[1]) if dev == (None, None): dev = () else: dev = dev[0], int(dev[1]) if local is None: local = () else: parts = [] for part in local.split('.'): # to ensure that numeric compares as > lexicographic, avoid # comparing them directly, but encode a tuple which ensures # correct sorting if part.isdigit(): part = (1, int(part)) else: part = (0, part) parts.append(part) local = tuple(parts) if not pre: # either before pre-release, or final release and after if not post and dev: # before pre-release pre = ('a', -1) # to sort before a0 else: pre = ('z',) # to sort after all pre-releases # now look at the state of post and dev. if not post: post = ('_',) # sort before 'a' if not dev: dev = ('final',) #print('%s -> %s' % (s, m.groups())) return epoch, nums, pre, post, dev, local _normalized_key = _pep_440_key class NormalizedVersion(Version): """A rational version. Good: 1.2 # equivalent to "1.2.0" 1.2.0 1.2a1 1.2.3a2 1.2.3b1 1.2.3c1 1.2.3.4 TODO: fill this out Bad: 1 # mininum two numbers 1.2a # release level must have a release serial 1.2.3b """ def parse(self, s): result = _normalized_key(s) # _normalized_key loses trailing zeroes in the release # clause, since that's needed to ensure that X.Y == X.Y.0 == X.Y.0.0 # However, PEP 440 prefix matching needs it: for example, # (~= 1.4.5.0) matches differently to (~= 1.4.5.0.0). m = PEP440_VERSION_RE.match(s) # must succeed groups = m.groups() self._release_clause = tuple(int(v) for v in groups[1].split('.')) return result PREREL_TAGS = set(['a', 'b', 'c', 'rc', 'dev']) @property def is_prerelease(self): return any(t[0] in self.PREREL_TAGS for t in self._parts if t) def _match_prefix(x, y): x = str(x) y = str(y) if x == y: return True if not x.startswith(y): return False n = len(y) return x[n] == '.' class NormalizedMatcher(Matcher): version_class = NormalizedVersion # value is either a callable or the name of a method _operators = { '~=': '_match_compatible', '<': '_match_lt', '>': '_match_gt', '<=': '_match_le', '>=': '_match_ge', '==': '_match_eq', '===': '_match_arbitrary', '!=': '_match_ne', } def _adjust_local(self, version, constraint, prefix): if prefix: strip_local = '+' not in constraint and version._parts[-1] else: # both constraint and version are # NormalizedVersion instances. # If constraint does not have a local component, # ensure the version doesn't, either. strip_local = not constraint._parts[-1] and version._parts[-1] if strip_local: s = version._string.split('+', 1)[0] version = self.version_class(s) return version, constraint def _match_lt(self, version, constraint, prefix): version, constraint = self._adjust_local(version, constraint, prefix) if version >= constraint: return False release_clause = constraint._release_clause pfx = '.'.join([str(i) for i in release_clause]) return not _match_prefix(version, pfx) def _match_gt(self, version, constraint, prefix): version, constraint = self._adjust_local(version, constraint, prefix) if version <= constraint: return False release_clause = constraint._release_clause pfx = '.'.join([str(i) for i in release_clause]) return not _match_prefix(version, pfx) def _match_le(self, version, constraint, prefix): version, constraint = self._adjust_local(version, constraint, prefix) return version <= constraint def _match_ge(self, version, constraint, prefix): version, constraint = self._adjust_local(version, constraint, prefix) return version >= constraint def _match_eq(self, version, constraint, prefix): version, constraint = self._adjust_local(version, constraint, prefix) if not prefix: result = (version == constraint) else: result = _match_prefix(version, constraint) return result def _match_arbitrary(self, version, constraint, prefix): return str(version) == str(constraint) def _match_ne(self, version, constraint, prefix): version, constraint = self._adjust_local(version, constraint, prefix) if not prefix: result = (version != constraint) else: result = not _match_prefix(version, constraint) return result def _match_compatible(self, version, constraint, prefix): version, constraint = self._adjust_local(version, constraint, prefix) if version == constraint: return True if version < constraint: return False # if not prefix: # return True release_clause = constraint._release_clause if len(release_clause) > 1: release_clause = release_clause[:-1] pfx = '.'.join([str(i) for i in release_clause]) return _match_prefix(version, pfx) _REPLACEMENTS = ( (re.compile('[.+-]$'), ''), # remove trailing puncts (re.compile(r'^[.](\d)'), r'0.\1'), # .N -> 0.N at start (re.compile('^[.-]'), ''), # remove leading puncts (re.compile(r'^\((.*)\)$'), r'\1'), # remove parentheses (re.compile(r'^v(ersion)?\s*(\d+)'), r'\2'), # remove leading v(ersion) (re.compile(r'^r(ev)?\s*(\d+)'), r'\2'), # remove leading v(ersion) (re.compile('[.]{2,}'), '.'), # multiple runs of '.' (re.compile(r'\b(alfa|apha)\b'), 'alpha'), # misspelt alpha (re.compile(r'\b(pre-alpha|prealpha)\b'), 'pre.alpha'), # standardise (re.compile(r'\(beta\)$'), 'beta'), # remove parentheses ) _SUFFIX_REPLACEMENTS = ( (re.compile('^[:~._+-]+'), ''), # remove leading puncts (re.compile('[,*")([\]]'), ''), # remove unwanted chars (re.compile('[~:+_ -]'), '.'), # replace illegal chars (re.compile('[.]{2,}'), '.'), # multiple runs of '.' (re.compile(r'\.$'), ''), # trailing '.' ) _NUMERIC_PREFIX = re.compile(r'(\d+(\.\d+)*)') def _suggest_semantic_version(s): """ Try to suggest a semantic form for a version for which _suggest_normalized_version couldn't come up with anything. """ result = s.strip().lower() for pat, repl in _REPLACEMENTS: result = pat.sub(repl, result) if not result: result = '0.0.0' # Now look for numeric prefix, and separate it out from # the rest. #import pdb; pdb.set_trace() m = _NUMERIC_PREFIX.match(result) if not m: prefix = '0.0.0' suffix = result else: prefix = m.groups()[0].split('.') prefix = [int(i) for i in prefix] while len(prefix) < 3: prefix.append(0) if len(prefix) == 3: suffix = result[m.end():] else: suffix = '.'.join([str(i) for i in prefix[3:]]) + result[m.end():] prefix = prefix[:3] prefix = '.'.join([str(i) for i in prefix]) suffix = suffix.strip() if suffix: #import pdb; pdb.set_trace() # massage the suffix. for pat, repl in _SUFFIX_REPLACEMENTS: suffix = pat.sub(repl, suffix) if not suffix: result = prefix else: sep = '-' if 'dev' in suffix else '+' result = prefix + sep + suffix if not is_semver(result): result = None return result def _suggest_normalized_version(s): """Suggest a normalized version close to the given version string. If you have a version string that isn't rational (i.e. NormalizedVersion doesn't like it) then you might be able to get an equivalent (or close) rational version from this function. This does a number of simple normalizations to the given string, based on observation of versions currently in use on PyPI. Given a dump of those version during PyCon 2009, 4287 of them: - 2312 (53.93%) match NormalizedVersion without change with the automatic suggestion - 3474 (81.04%) match when using this suggestion method @param s {str} An irrational version string. @returns A rational version string, or None, if couldn't determine one. """ try: _normalized_key(s) return s # already rational except UnsupportedVersionError: pass rs = s.lower() # part of this could use maketrans for orig, repl in (('-alpha', 'a'), ('-beta', 'b'), ('alpha', 'a'), ('beta', 'b'), ('rc', 'c'), ('-final', ''), ('-pre', 'c'), ('-release', ''), ('.release', ''), ('-stable', ''), ('+', '.'), ('_', '.'), (' ', ''), ('.final', ''), ('final', '')): rs = rs.replace(orig, repl) # if something ends with dev or pre, we add a 0 rs = re.sub(r"pre$", r"pre0", rs) rs = re.sub(r"dev$", r"dev0", rs) # if we have something like "b-2" or "a.2" at the end of the # version, that is pobably beta, alpha, etc # let's remove the dash or dot rs = re.sub(r"([abc]|rc)[\-\.](\d+)$", r"\1\2", rs) # 1.0-dev-r371 -> 1.0.dev371 # 0.1-dev-r79 -> 0.1.dev79 rs = re.sub(r"[\-\.](dev)[\-\.]?r?(\d+)$", r".\1\2", rs) # Clean: 2.0.a.3, 2.0.b1, 0.9.0~c1 rs = re.sub(r"[.~]?([abc])\.?", r"\1", rs) # Clean: v0.3, v1.0 if rs.startswith('v'): rs = rs[1:] # Clean leading '0's on numbers. #TODO: unintended side-effect on, e.g., "2003.05.09" # PyPI stats: 77 (~2%) better rs = re.sub(r"\b0+(\d+)(?!\d)", r"\1", rs) # Clean a/b/c with no version. E.g. "1.0a" -> "1.0a0". Setuptools infers # zero. # PyPI stats: 245 (7.56%) better rs = re.sub(r"(\d+[abc])$", r"\g<1>0", rs) # the 'dev-rNNN' tag is a dev tag rs = re.sub(r"\.?(dev-r|dev\.r)\.?(\d+)$", r".dev\2", rs) # clean the - when used as a pre delimiter rs = re.sub(r"-(a|b|c)(\d+)$", r"\1\2", rs) # a terminal "dev" or "devel" can be changed into ".dev0" rs = re.sub(r"[\.\-](dev|devel)$", r".dev0", rs) # a terminal "dev" can be changed into ".dev0" rs = re.sub(r"(?![\.\-])dev$", r".dev0", rs) # a terminal "final" or "stable" can be removed rs = re.sub(r"(final|stable)$", "", rs) # The 'r' and the '-' tags are post release tags # 0.4a1.r10 -> 0.4a1.post10 # 0.9.33-17222 -> 0.9.33.post17222 # 0.9.33-r17222 -> 0.9.33.post17222 rs = re.sub(r"\.?(r|-|-r)\.?(\d+)$", r".post\2", rs) # Clean 'r' instead of 'dev' usage: # 0.9.33+r17222 -> 0.9.33.dev17222 # 1.0dev123 -> 1.0.dev123 # 1.0.git123 -> 1.0.dev123 # 1.0.bzr123 -> 1.0.dev123 # 0.1a0dev.123 -> 0.1a0.dev123 # PyPI stats: ~150 (~4%) better rs = re.sub(r"\.?(dev|git|bzr)\.?(\d+)$", r".dev\2", rs) # Clean '.pre' (normalized from '-pre' above) instead of 'c' usage: # 0.2.pre1 -> 0.2c1 # 0.2-c1 -> 0.2c1 # 1.0preview123 -> 1.0c123 # PyPI stats: ~21 (0.62%) better rs = re.sub(r"\.?(pre|preview|-c)(\d+)$", r"c\g<2>", rs) # Tcl/Tk uses "px" for their post release markers rs = re.sub(r"p(\d+)$", r".post\1", rs) try: _normalized_key(rs) except UnsupportedVersionError: rs = None return rs # # Legacy version processing (distribute-compatible) # _VERSION_PART = re.compile(r'([a-z]+|\d+|[\.-])', re.I) _VERSION_REPLACE = { 'pre': 'c', 'preview': 'c', '-': 'final-', 'rc': 'c', 'dev': '@', '': None, '.': None, } def _legacy_key(s): def get_parts(s): result = [] for p in _VERSION_PART.split(s.lower()): p = _VERSION_REPLACE.get(p, p) if p: if '0' <= p[:1] <= '9': p = p.zfill(8) else: p = '*' + p result.append(p) result.append('*final') return result result = [] for p in get_parts(s): if p.startswith('*'): if p < '*final': while result and result[-1] == '*final-': result.pop() while result and result[-1] == '00000000': result.pop() result.append(p) return tuple(result) class LegacyVersion(Version): def parse(self, s): return _legacy_key(s) @property def is_prerelease(self): result = False for x in self._parts: if (isinstance(x, string_types) and x.startswith('*') and x < '*final'): result = True break return result class LegacyMatcher(Matcher): version_class = LegacyVersion _operators = dict(Matcher._operators) _operators['~='] = '_match_compatible' numeric_re = re.compile('^(\d+(\.\d+)*)') def _match_compatible(self, version, constraint, prefix): if version < constraint: return False m = self.numeric_re.match(str(constraint)) if not m: logger.warning('Cannot compute compatible match for version %s ' ' and constraint %s', version, constraint) return True s = m.groups()[0] if '.' in s: s = s.rsplit('.', 1)[0] return _match_prefix(version, s) # # Semantic versioning # _SEMVER_RE = re.compile(r'^(\d+)\.(\d+)\.(\d+)' r'(-[a-z0-9]+(\.[a-z0-9-]+)*)?' r'(\+[a-z0-9]+(\.[a-z0-9-]+)*)?$', re.I) def is_semver(s): return _SEMVER_RE.match(s) def _semantic_key(s): def make_tuple(s, absent): if s is None: result = (absent,) else: parts = s[1:].split('.') # We can't compare ints and strings on Python 3, so fudge it # by zero-filling numeric values so simulate a numeric comparison result = tuple([p.zfill(8) if p.isdigit() else p for p in parts]) return result m = is_semver(s) if not m: raise UnsupportedVersionError(s) groups = m.groups() major, minor, patch = [int(i) for i in groups[:3]] # choose the '|' and '*' so that versions sort correctly pre, build = make_tuple(groups[3], '|'), make_tuple(groups[5], '*') return (major, minor, patch), pre, build class SemanticVersion(Version): def parse(self, s): return _semantic_key(s) @property def is_prerelease(self): return self._parts[1][0] != '|' class SemanticMatcher(Matcher): version_class = SemanticVersion class VersionScheme(object): def __init__(self, key, matcher, suggester=None): self.key = key self.matcher = matcher self.suggester = suggester def is_valid_version(self, s): try: self.matcher.version_class(s) result = True except UnsupportedVersionError: result = False return result def is_valid_matcher(self, s): try: self.matcher(s) result = True except UnsupportedVersionError: result = False return result def is_valid_constraint_list(self, s): """ Used for processing some metadata fields """ return self.is_valid_matcher('dummy_name (%s)' % s) def suggest(self, s): if self.suggester is None: result = None else: result = self.suggester(s) return result _SCHEMES = { 'normalized': VersionScheme(_normalized_key, NormalizedMatcher, _suggest_normalized_version), 'legacy': VersionScheme(_legacy_key, LegacyMatcher, lambda self, s: s), 'semantic': VersionScheme(_semantic_key, SemanticMatcher, _suggest_semantic_version), } _SCHEMES['default'] = _SCHEMES['normalized'] def get_scheme(name): if name not in _SCHEMES: raise ValueError('unknown scheme name: %r' % name) return _SCHEMES[name]
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 9261, 710, 2018, 2290, 2752, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 624, 199, 7921, 402, 282, 26841, 1015, 316, 5687, 13070, 2291, 367, 13663, 13, 14162, 12, 199, 13623, 13, 6490, 436, 32451, 1015, 316, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 295, 199, 199, 504, 1275, 5819, 492, 1059, 63, 1313, 199, 199, 363, 452, 363, 275, 788, 29492, 3353, 297, 283, 29492, 16073, 297, 1779, 283, 22628, 3353, 297, 283, 22628, 16073, 297, 1779, 283, 1513, 23127, 3353, 297, 283, 1513, 23127, 16073, 297, 1779, 283, 12647, 3353, 547, 297, 283, 362, 63, 5512, 418, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 19022, 3353, 547, 8, 3393, 304, 272, 408, 2765, 365, 376, 16313, 1015, 1041, 272, 986, 421, 199, 533, 3394, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 308, 304, 267, 291, 423, 875, 275, 308, 275, 308, 14, 1913, 342, 267, 291, 423, 4181, 275, 4184, 275, 291, 14, 1122, 8, 83, 9, 267, 702, 1228, 8, 4181, 12, 2008, 9, 267, 702, 822, 8, 4181, 9, 690, 378, 339, 347, 2198, 8, 277, 12, 308, 304, 267, 746, 4279, 360, 27567, 5669, 315, 282, 5516, 358, 339, 347, 485, 1074, 63, 6490, 8, 277, 12, 1163, 304, 267, 340, 730, 8, 277, 9, 1137, 730, 8, 1848, 304, 288, 746, 3146, 360, 11250, 6540, 450, 82, 436, 450, 82, 7, 450, 334, 277, 12, 1163, 430, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 291, 423, 1074, 63, 6490, 8, 1848, 9, 267, 372, 291, 423, 4181, 508, 1163, 423, 4181, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 291, 423, 1074, 63, 6490, 8, 1848, 9, 267, 372, 291, 423, 4181, 665, 1163, 423, 4181, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 440, 334, 277, 855, 4116, 721, 1848, 9, 503, 291, 855, 4077, 721, 1848, 430, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 372, 291, 855, 4116, 721, 1848, 9, 503, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 291, 855, 3308, 721, 1848, 9, 503, 291, 855, 4077, 721, 1848, 9, 339, 327, 1666, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4443, 15, 576, 1238, 3, 785, 855, 2227, 363, 272, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 277, 423, 4181, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2071, 83, 3508, 83, 19124, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 423, 875, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 423, 875, 339, 768, 1829, 272, 347, 365, 63, 657, 3221, 8, 277, 304, 267, 746, 4279, 360, 8254, 5669, 315, 9180, 2659, 421, 199, 533, 9814, 281, 8, 785, 304, 272, 1015, 63, 533, 275, 488, 339, 2917, 63, 264, 275, 295, 14, 2014, 8, 82, 16136, 2961, 87, 7023, 83, 60, 87, 1370, 13, 3672, 10127, 1332, 2795, 2862, 430, 18582, 272, 1013, 63, 264, 275, 295, 14, 2014, 8, 82, 31996, 12932, 92, 8119, 92, 28, 92, 21521, 1111, 92, 3126, 18, 12, 19, 22441, 94, 29, 5547, 60, 83, 10, 21690, 83, 12, 11896, 9988, 272, 1967, 63, 264, 275, 295, 14, 2014, 8, 82, 15542, 68, 20900, 3134, 68, 11, 3342, 9988, 339, 327, 574, 365, 1902, 282, 4550, 503, 314, 536, 402, 282, 1083, 272, 485, 12688, 275, 469, 267, 2650, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 665, 286, 12, 267, 12696, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 690, 286, 12, 267, 2650, 18749, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 503, 373, 665, 286, 12, 267, 283, 8119, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 503, 373, 690, 286, 12, 267, 283, 389, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 12, 267, 283, 5918, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 12, 267, 327, 701, 849, 12, 9025, 9265, 2356, 14, 267, 17352, 18749, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 503, 373, 690, 286, 12, 267, 26656, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 1137, 286, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 308, 304, 267, 340, 291, 14, 1023, 63, 533, 365, 488, 26, 288, 746, 1722, 360, 8254, 4165, 282, 1015, 1021, 358, 267, 291, 423, 875, 275, 308, 275, 308, 14, 1913, 342, 267, 333, 275, 291, 14, 2686, 63, 264, 14, 1431, 8, 83, 9, 267, 340, 440, 333, 26, 288, 746, 1722, 360, 1763, 1686, 26, 450, 82, 7, 450, 308, 9, 267, 4652, 275, 333, 14, 2634, 8355, 267, 291, 14, 354, 275, 4652, 59, 16, 1055, 1913, 342, 267, 291, 14, 498, 275, 291, 14, 354, 14, 2325, 342, 259, 327, 367, 1930, 13, 15851, 20448, 267, 286, 513, 275, 942, 267, 340, 4652, 59, 18, 2189, 288, 9565, 275, 359, 67, 14, 1913, 342, 367, 286, 315, 4652, 59, 18, 1055, 1294, 29972, 288, 367, 286, 315, 9565, 26, 355, 333, 275, 291, 14, 863, 63, 264, 14, 1431, 8, 67, 9, 355, 340, 440, 333, 26, 490, 746, 1722, 360, 3364, 450, 82, 315, 450, 82, 7, 450, 334, 67, 12, 308, 430, 355, 4652, 275, 333, 14, 2634, 342, 355, 1687, 275, 4652, 59, 16, 61, 503, 17352, 534, 355, 308, 275, 4652, 59, 17, 61, 355, 340, 308, 14, 4130, 360, 2795, 735, 490, 340, 1687, 440, 315, 661, 389, 297, 14597, 534, 304, 717, 746, 1722, 2258, 24898, 3985, 440, 4370, 367, 283, 1460, 1543, 82, 9565, 7, 450, 1687, 9, 490, 327, 18615, 506, 282, 7417, 1015, 334, 69, 14, 71, 14, 367, 283, 18, 24915, 1314, 490, 327, 7859, 1133, 2198, 465, 282, 1015, 12, 880, 4215 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 9261, 710, 2018, 2290, 2752, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 624, 199, 7921, 402, 282, 26841, 1015, 316, 5687, 13070, 2291, 367, 13663, 13, 14162, 12, 199, 13623, 13, 6490, 436, 32451, 1015, 316, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 295, 199, 199, 504, 1275, 5819, 492, 1059, 63, 1313, 199, 199, 363, 452, 363, 275, 788, 29492, 3353, 297, 283, 29492, 16073, 297, 1779, 283, 22628, 3353, 297, 283, 22628, 16073, 297, 1779, 283, 1513, 23127, 3353, 297, 283, 1513, 23127, 16073, 297, 1779, 283, 12647, 3353, 547, 297, 283, 362, 63, 5512, 418, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 19022, 3353, 547, 8, 3393, 304, 272, 408, 2765, 365, 376, 16313, 1015, 1041, 272, 986, 421, 199, 533, 3394, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 308, 304, 267, 291, 423, 875, 275, 308, 275, 308, 14, 1913, 342, 267, 291, 423, 4181, 275, 4184, 275, 291, 14, 1122, 8, 83, 9, 267, 702, 1228, 8, 4181, 12, 2008, 9, 267, 702, 822, 8, 4181, 9, 690, 378, 339, 347, 2198, 8, 277, 12, 308, 304, 267, 746, 4279, 360, 27567, 5669, 315, 282, 5516, 358, 339, 347, 485, 1074, 63, 6490, 8, 277, 12, 1163, 304, 267, 340, 730, 8, 277, 9, 1137, 730, 8, 1848, 304, 288, 746, 3146, 360, 11250, 6540, 450, 82, 436, 450, 82, 7, 450, 334, 277, 12, 1163, 430, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 291, 423, 1074, 63, 6490, 8, 1848, 9, 267, 372, 291, 423, 4181, 508, 1163, 423, 4181, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 291, 423, 1074, 63, 6490, 8, 1848, 9, 267, 372, 291, 423, 4181, 665, 1163, 423, 4181, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 440, 334, 277, 855, 4116, 721, 1848, 9, 503, 291, 855, 4077, 721, 1848, 430, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 372, 291, 855, 4116, 721, 1848, 9, 503, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 291, 855, 3308, 721, 1848, 9, 503, 291, 855, 4077, 721, 1848, 9, 339, 327, 1666, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4443, 15, 576, 1238, 3, 785, 855, 2227, 363, 272, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 277, 423, 4181, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2071, 83, 3508, 83, 19124, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 423, 875, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 423, 875, 339, 768, 1829, 272, 347, 365, 63, 657, 3221, 8, 277, 304, 267, 746, 4279, 360, 8254, 5669, 315, 9180, 2659, 421, 199, 533, 9814, 281, 8, 785, 304, 272, 1015, 63, 533, 275, 488, 339, 2917, 63, 264, 275, 295, 14, 2014, 8, 82, 16136, 2961, 87, 7023, 83, 60, 87, 1370, 13, 3672, 10127, 1332, 2795, 2862, 430, 18582, 272, 1013, 63, 264, 275, 295, 14, 2014, 8, 82, 31996, 12932, 92, 8119, 92, 28, 92, 21521, 1111, 92, 3126, 18, 12, 19, 22441, 94, 29, 5547, 60, 83, 10, 21690, 83, 12, 11896, 9988, 272, 1967, 63, 264, 275, 295, 14, 2014, 8, 82, 15542, 68, 20900, 3134, 68, 11, 3342, 9988, 339, 327, 574, 365, 1902, 282, 4550, 503, 314, 536, 402, 282, 1083, 272, 485, 12688, 275, 469, 267, 2650, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 665, 286, 12, 267, 12696, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 690, 286, 12, 267, 2650, 18749, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 503, 373, 665, 286, 12, 267, 283, 8119, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 503, 373, 690, 286, 12, 267, 283, 389, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 12, 267, 283, 5918, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 12, 267, 327, 701, 849, 12, 9025, 9265, 2356, 14, 267, 17352, 18749, 2400, 373, 12, 286, 12, 299, 26, 373, 508, 286, 503, 373, 690, 286, 12, 267, 26656, 356, 2400, 373, 12, 286, 12, 299, 26, 373, 1137, 286, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 308, 304, 267, 340, 291, 14, 1023, 63, 533, 365, 488, 26, 288, 746, 1722, 360, 8254, 4165, 282, 1015, 1021, 358, 267, 291, 423, 875, 275, 308, 275, 308, 14, 1913, 342, 267, 333, 275, 291, 14, 2686, 63, 264, 14, 1431, 8, 83, 9, 267, 340, 440, 333, 26, 288, 746, 1722, 360, 1763, 1686, 26, 450, 82, 7, 450, 308, 9, 267, 4652, 275, 333, 14, 2634, 8355, 267, 291, 14, 354, 275, 4652, 59, 16, 1055, 1913, 342, 267, 291, 14, 498, 275, 291, 14, 354, 14, 2325, 342, 259, 327, 367, 1930, 13, 15851, 20448, 267, 286, 513, 275, 942, 267, 340, 4652, 59, 18, 2189, 288, 9565, 275, 359, 67, 14, 1913, 342, 367, 286, 315, 4652, 59, 18, 1055, 1294, 29972, 288, 367, 286, 315, 9565, 26, 355, 333, 275, 291, 14, 863, 63, 264, 14, 1431, 8, 67, 9, 355, 340, 440, 333, 26, 490, 746, 1722, 360, 3364, 450, 82, 315, 450, 82, 7, 450, 334, 67, 12, 308, 430, 355, 4652, 275, 333, 14, 2634, 342, 355, 1687, 275, 4652, 59, 16, 61, 503, 17352, 534, 355, 308, 275, 4652, 59, 17, 61, 355, 340, 308, 14, 4130, 360, 2795, 735, 490, 340, 1687, 440, 315, 661, 389, 297, 14597, 534, 304, 717, 746, 1722, 2258, 24898, 3985, 440, 4370, 367, 283, 1460, 1543, 82, 9565, 7, 450, 1687, 9, 490, 327, 18615, 506, 282, 7417, 1015, 334, 69, 14, 71, 14, 367, 283, 18, 24915, 1314, 490, 327, 7859, 1133, 2198, 465, 282, 1015, 12, 880, 4215, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
furbrain/Coherence
misc/Nautilus/coherence_upnp_upload_extension.py
2
3477
#!/usr/bin/python # -*- coding: utf-8 -*- # Licensed under the MIT license # http://opensource.org/licenses/mit-license.php # Copyright 2008 Frank Scholz <coherence@beebits.net> """ Coherence and Nautilus bridge to upload files into a DLNA/UPnP MediaServer usable as Nautilus Extension or a Script for use an extension, copy it to ~/.nautilus/python-extensions or for a system-wide installation to /usr/lib/nautilus/extensions-2.0/python for us as a script put it into ~/.gnome2/nautilus-scripts with a describing name of maybe "upload to UPnP MediaServer" connection to Coherence is established via DBus """ import sys import os import pygtk pygtk.require("2.0") import gtk from coherence.ui.av_widgets import DeviceImportWidget def show_upload_widget(files, standalone=True): window = gtk.Window(gtk.WINDOW_TOPLEVEL) if standalone: window.connect("delete_event", gtk.main_quit) window.set_default_size(350, 300) window.set_title('Coherence DLNA/UPnP Upload') ui = DeviceImportWidget(standalone=standalone, root=window) window.add(ui.window) for filename in files: ui.add_file(filename) window.show_all() try: import nautilus from urllib import unquote import dbus from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) import dbus.service # dbus defines BUS_NAME = 'org.Coherence' OBJECT_PATH = '/org/Coherence' def log(t): return f = open('/tmp/coherence.log', 'a') f.write(t + '\n') f.close() class CoherenceUploadExtension(nautilus.MenuProvider): def __init__(self): print "CoherenceUploadExtension", os.getpid() log("CoherenceUploadExtension %r" % os.getpid()) self.coherence = None try: self.init_controlpoint() except: import traceback log("can't setup %r" % traceback.format_exc()) print "can't setup Coherence connection" def init_controlpoint(self): self.bus = dbus.SessionBus() self.coherence = self.bus.get_object(BUS_NAME, OBJECT_PATH) def get_file_items(self, window, files): log("get_file_items") log("coherence %r" % self.coherence) if self.coherence == None: return log("files %d" % len(files)) if len(files) == 0: return log("get_file_items 2") for file in files: log("get_file_items 3 %r" % file) if file.is_directory() or file.get_uri_scheme() != 'file': return item = nautilus.MenuItem('CoherenceUploadExtension::import_resources', 'Upload to MediaServer...', 'Upload the selected files to a DLNA/UPnP MediaServer') item.connect('activate', self.import_resources, files) return item, def import_resources(self, menu, files): if len(files) == 0: return show_upload_widget([unquote(file.get_uri()[7:]) for file in files], standalone=False) except ImportError: pass if __name__ == '__main__': import os.path files = [x for x in sys.argv[1:] if not os.path.isdir(x)] show_upload_widget(files) gtk.gdk.threads_init() gtk.main()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 3909, 1334, 314, 10697, 4190, 199, 3, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 3, 1898, 9079, 11007, 22985, 393, 90, 665, 331, 426, 4646, 32, 19446, 5609, 14, 846, 30, 199, 199, 624, 1849, 426, 4646, 436, 11290, 1974, 527, 13928, 370, 5802, 1584, 1901, 282, 577, 44, 7170, 15, 2160, 30035, 12300, 3120, 339, 18025, 465, 11290, 1974, 527, 13282, 503, 282, 14914, 339, 367, 675, 376, 3329, 12, 1331, 652, 370, 25975, 3540, 1974, 527, 15, 1548, 13, 5359, 272, 503, 367, 282, 2656, 13, 13062, 12096, 370, 1182, 2647, 15, 773, 15, 3540, 1974, 527, 15, 5359, 13, 18, 14, 16, 15, 1548, 339, 367, 2739, 465, 282, 2884, 5324, 652, 1901, 25975, 784, 1377, 18, 15, 3540, 1974, 527, 13, 6429, 543, 272, 282, 13660, 536, 402, 11703, 298, 5064, 370, 7215, 30035, 12300, 3120, 2, 339, 1950, 370, 1849, 426, 4646, 365, 23594, 4799, 6249, 527, 199, 199, 624, 199, 199, 646, 984, 199, 646, 747, 199, 199, 646, 1134, 12275, 199, 647, 12275, 14, 4365, 480, 18, 14, 16, 531, 199, 646, 8116, 199, 199, 504, 512, 426, 4646, 14, 1907, 14, 1214, 63, 8583, 492, 12272, 6295, 3339, 421, 199, 318, 2498, 63, 5064, 63, 3440, 8, 1725, 12, 18042, 29, 549, 304, 339, 4353, 275, 8116, 14, 4301, 8, 12275, 14, 15480, 63, 11422, 11817, 9, 272, 340, 18042, 26, 267, 4353, 14, 2242, 480, 1807, 63, 1430, 401, 8116, 14, 973, 63, 10589, 9, 272, 4353, 14, 409, 63, 885, 63, 890, 8, 13595, 12, 9601, 9, 272, 4353, 14, 409, 63, 1213, 360, 967, 426, 4646, 577, 44, 7170, 15, 2160, 30035, 19149, 358, 339, 8574, 275, 12272, 6295, 3339, 8, 20323, 29, 20323, 12, 1738, 29, 3806, 9, 339, 4353, 14, 525, 8, 1907, 14, 3806, 9, 339, 367, 1788, 315, 1584, 26, 267, 8574, 14, 525, 63, 493, 8, 1501, 9, 339, 4353, 14, 2384, 63, 452, 342, 199, 199, 893, 26, 272, 492, 11802, 1974, 527, 272, 687, 4011, 492, 14342, 272, 492, 21140, 272, 687, 21140, 14, 22644, 14, 30816, 492, 6249, 527, 39, 6756, 7382, 272, 6249, 527, 39, 6756, 7382, 8, 409, 63, 305, 63, 885, 29, 549, 9, 272, 492, 21140, 14, 1364, 339, 327, 21140, 7890, 272, 9534, 63, 2339, 275, 283, 1308, 14, 967, 426, 4646, 7, 272, 28652, 5550, 63, 3243, 275, 1994, 1308, 15, 967, 426, 4646, 7, 2378, 347, 943, 8, 84, 304, 267, 372, 267, 289, 275, 1551, 2336, 2791, 15, 331, 426, 4646, 14, 793, 297, 283, 65, 358, 267, 289, 14, 952, 8, 84, 435, 1557, 78, 358, 267, 289, 14, 1600, 342, 2378, 1021, 1849, 426, 4646, 10301, 6382, 8, 3540, 1974, 527, 14, 5977, 6663, 304, 398, 347, 636, 826, 721, 277, 304, 288, 870, 298, 967, 426, 4646, 10301, 6382, 401, 747, 14, 17829, 342, 288, 943, 480, 967, 426, 4646, 10301, 6382, 450, 82, 2, 450, 747, 14, 17829, 1012, 288, 291, 14, 331, 426, 4646, 275, 488, 288, 862, 26, 355, 291, 14, 826, 63, 2785, 1403, 342, 288, 871, 26, 355, 492, 5190, 355, 943, 480, 2425, 1133, 3272, 450, 82, 2, 450, 5190, 14, 908, 63, 2804, 1012, 355, 870, 298, 2425, 1133, 3272, 1849, 426, 4646, 1950, 2, 398, 347, 4205, 63, 2785, 1403, 8, 277, 304, 288, 291, 14, 5610, 275, 21140, 14, 4434, 12106, 342, 288, 291, 14, 331, 426, 4646, 275, 291, 14, 5610, 14, 362, 63, 785, 8, 24753, 63, 2339, 12, 28652, 5550, 63, 3243, 9, 398, 347, 664, 63, 493, 63, 1744, 8, 277, 12, 4353, 12, 1584, 304, 288, 943, 480, 362, 63, 493, 63, 1744, 531, 288, 943, 480, 331, 426, 4646, 450, 82, 2, 450, 291, 14, 331, 426, 4646, 9, 288, 340, 291, 14, 331, 426, 4646, 508, 488, 26, 355, 372, 288, 943, 480, 1725, 450, 68, 2, 450, 822, 8, 1725, 430, 288, 340, 822, 8, 1725, 9, 508, 378, 26, 355, 372, 953, 943, 480, 362, 63, 493, 63, 1744, 499, 531, 288, 367, 570, 315, 1584, 26, 355, 943, 480, 362, 63, 493, 63, 1744, 650, 450, 82, 2, 450, 570, 9, 355, 340, 570, 14, 374, 63, 3619, 342, 503, 570, 14, 362, 63, 2302, 63, 5512, 342, 1137, 283, 493, 356, 490, 372, 953, 1242, 275, 11802, 1974, 527, 14, 20973, 360, 967, 426, 4646, 10301, 6382, 447, 646, 63, 4435, 297, 3660, 283, 10301, 370, 12300, 3120, 20833, 3660, 283, 10301, 314, 4895, 1584, 370, 282, 577, 44, 7170, 15, 2160, 30035, 12300, 3120, 358, 288, 1242, 14, 2242, 360, 8222, 297, 291, 14, 646, 63, 4435, 12, 1584, 9, 953, 372, 1242, 12, 398, 347, 492, 63, 4435, 8, 277, 12, 6269, 12, 1584, 304, 288, 340, 822, 8, 1725, 9, 508, 378, 26, 355, 372, 953, 2498, 63, 5064, 63, 3440, 779, 12240, 8, 493, 14, 362, 63, 2302, 3430, 23, 5728, 367, 570, 315, 1584, 467, 18042, 29, 797, 9, 421, 199, 2590, 3545, 26, 272, 986, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 492, 747, 14, 515, 272, 1584, 275, 359, 88, 367, 671, 315, 984, 14, 3020, 59, 17, 2938, 340, 440, 747, 14, 515, 14, 6027, 8, 88, 1874, 272, 2498, 63, 5064, 63, 3440, 8, 1725, 9, 339, 8116, 14, 24697, 14, 6962, 63, 826, 342, 272, 8116, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 3909, 1334, 314, 10697, 4190, 199, 3, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 3, 1898, 9079, 11007, 22985, 393, 90, 665, 331, 426, 4646, 32, 19446, 5609, 14, 846, 30, 199, 199, 624, 1849, 426, 4646, 436, 11290, 1974, 527, 13928, 370, 5802, 1584, 1901, 282, 577, 44, 7170, 15, 2160, 30035, 12300, 3120, 339, 18025, 465, 11290, 1974, 527, 13282, 503, 282, 14914, 339, 367, 675, 376, 3329, 12, 1331, 652, 370, 25975, 3540, 1974, 527, 15, 1548, 13, 5359, 272, 503, 367, 282, 2656, 13, 13062, 12096, 370, 1182, 2647, 15, 773, 15, 3540, 1974, 527, 15, 5359, 13, 18, 14, 16, 15, 1548, 339, 367, 2739, 465, 282, 2884, 5324, 652, 1901, 25975, 784, 1377, 18, 15, 3540, 1974, 527, 13, 6429, 543, 272, 282, 13660, 536, 402, 11703, 298, 5064, 370, 7215, 30035, 12300, 3120, 2, 339, 1950, 370, 1849, 426, 4646, 365, 23594, 4799, 6249, 527, 199, 199, 624, 199, 199, 646, 984, 199, 646, 747, 199, 199, 646, 1134, 12275, 199, 647, 12275, 14, 4365, 480, 18, 14, 16, 531, 199, 646, 8116, 199, 199, 504, 512, 426, 4646, 14, 1907, 14, 1214, 63, 8583, 492, 12272, 6295, 3339, 421, 199, 318, 2498, 63, 5064, 63, 3440, 8, 1725, 12, 18042, 29, 549, 304, 339, 4353, 275, 8116, 14, 4301, 8, 12275, 14, 15480, 63, 11422, 11817, 9, 272, 340, 18042, 26, 267, 4353, 14, 2242, 480, 1807, 63, 1430, 401, 8116, 14, 973, 63, 10589, 9, 272, 4353, 14, 409, 63, 885, 63, 890, 8, 13595, 12, 9601, 9, 272, 4353, 14, 409, 63, 1213, 360, 967, 426, 4646, 577, 44, 7170, 15, 2160, 30035, 19149, 358, 339, 8574, 275, 12272, 6295, 3339, 8, 20323, 29, 20323, 12, 1738, 29, 3806, 9, 339, 4353, 14, 525, 8, 1907, 14, 3806, 9, 339, 367, 1788, 315, 1584, 26, 267, 8574, 14, 525, 63, 493, 8, 1501, 9, 339, 4353, 14, 2384, 63, 452, 342, 199, 199, 893, 26, 272, 492, 11802, 1974, 527, 272, 687, 4011, 492, 14342, 272, 492, 21140, 272, 687, 21140, 14, 22644, 14, 30816, 492, 6249, 527, 39, 6756, 7382, 272, 6249, 527, 39, 6756, 7382, 8, 409, 63, 305, 63, 885, 29, 549, 9, 272, 492, 21140, 14, 1364, 339, 327, 21140, 7890, 272, 9534, 63, 2339, 275, 283, 1308, 14, 967, 426, 4646, 7, 272, 28652, 5550, 63, 3243, 275, 1994, 1308, 15, 967, 426, 4646, 7, 2378, 347, 943, 8, 84, 304, 267, 372, 267, 289, 275, 1551, 2336, 2791, 15, 331, 426, 4646, 14, 793, 297, 283, 65, 358, 267, 289, 14, 952, 8, 84, 435, 1557, 78, 358, 267, 289, 14, 1600, 342, 2378, 1021, 1849, 426, 4646, 10301, 6382, 8, 3540, 1974, 527, 14, 5977, 6663, 304, 398, 347, 636, 826, 721, 277, 304, 288, 870, 298, 967, 426, 4646, 10301, 6382, 401, 747, 14, 17829, 342, 288, 943, 480, 967, 426, 4646, 10301, 6382, 450, 82, 2, 450, 747, 14, 17829, 1012, 288, 291, 14, 331, 426, 4646, 275, 488, 288, 862, 26, 355, 291, 14, 826, 63, 2785, 1403, 342, 288, 871, 26, 355, 492, 5190, 355, 943, 480, 2425, 1133, 3272, 450, 82, 2, 450, 5190, 14, 908, 63, 2804, 1012, 355, 870, 298, 2425, 1133, 3272, 1849, 426, 4646, 1950, 2, 398, 347, 4205, 63, 2785, 1403, 8, 277, 304, 288, 291, 14, 5610, 275, 21140, 14, 4434, 12106, 342, 288, 291, 14, 331, 426, 4646, 275, 291, 14, 5610, 14, 362, 63, 785, 8, 24753, 63, 2339, 12, 28652, 5550, 63, 3243, 9, 398, 347, 664, 63, 493, 63, 1744, 8, 277, 12, 4353, 12, 1584, 304, 288, 943, 480, 362, 63, 493, 63, 1744, 531, 288, 943, 480, 331, 426, 4646, 450, 82, 2, 450, 291, 14, 331, 426, 4646, 9, 288, 340, 291, 14, 331, 426, 4646, 508, 488, 26, 355, 372, 288, 943, 480, 1725, 450, 68, 2, 450, 822, 8, 1725, 430, 288, 340, 822, 8, 1725, 9, 508, 378, 26, 355, 372, 953, 943, 480, 362, 63, 493, 63, 1744, 499, 531, 288, 367, 570, 315, 1584, 26, 355, 943, 480, 362, 63, 493, 63, 1744, 650, 450, 82, 2, 450, 570, 9, 355, 340, 570, 14, 374, 63, 3619, 342, 503, 570, 14, 362, 63, 2302, 63, 5512, 342, 1137, 283, 493, 356, 490, 372, 953, 1242, 275, 11802, 1974, 527, 14, 20973, 360, 967, 426, 4646, 10301, 6382, 447, 646, 63, 4435, 297, 3660, 283, 10301, 370, 12300, 3120, 20833, 3660, 283, 10301, 314, 4895, 1584, 370, 282, 577, 44, 7170, 15, 2160, 30035, 12300, 3120, 358, 288, 1242, 14, 2242, 360, 8222, 297, 291, 14, 646, 63, 4435, 12, 1584, 9, 953, 372, 1242, 12, 398, 347, 492, 63, 4435, 8, 277, 12, 6269, 12, 1584, 304, 288, 340, 822, 8, 1725, 9, 508, 378, 26, 355, 372, 953, 2498, 63, 5064, 63, 3440, 779, 12240, 8, 493, 14, 362, 63, 2302, 3430, 23, 5728, 367, 570, 315, 1584, 467, 18042, 29, 797, 9, 421, 199, 2590, 3545, 26, 272, 986, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 492, 747, 14, 515, 272, 1584, 275, 359, 88, 367, 671, 315, 984, 14, 3020, 59, 17, 2938, 340, 440, 747, 14, 515, 14, 6027, 8, 88, 1874, 272, 2498, 63, 5064, 63, 3440, 8, 1725, 9, 339, 8116, 14, 24697, 14, 6962, 63, 826, 342, 272, 8116, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wemanuel/smry
smry/server-auth/ls/google-cloud-sdk/platform/gsutil/third_party/boto/tests/integration/ec2/autoscale/__init__.py
114
1098
# Copyright (c) 2011 Reza Lotun http://reza.lotun.name # # 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, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing 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 MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR 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.
apache-2.0
[ 3, 1898, 334, 67, 9, 7760, 799, 8076, 491, 357, 324, 1455, 921, 264, 8076, 14, 1653, 324, 14, 354, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 7760, 799, 8076, 491, 357, 324, 1455, 921, 264, 8076, 14, 1653, 324, 14, 354, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
linuxipho/mycroft-core
mycroft/configuration/config.py
1
8186
# Copyright 2017 Mycroft AI 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 re import json import inflection from os.path import exists, isfile from requests import RequestException from mycroft.util.json_helper import load_commented_json, merge_dict from mycroft.util.log import LOG from .locations import DEFAULT_CONFIG, SYSTEM_CONFIG, USER_CONFIG def is_remote_list(values): ''' check if this list corresponds to a backend formatted collection of dictionaries ''' for v in values: if not isinstance(v, dict): return False if "@type" not in v.keys(): return False return True def translate_remote(config, setting): """ Translate config names from server to equivalents usable in mycroft-core. Args: config: base config to populate settings: remote settings to be translated """ IGNORED_SETTINGS = ["uuid", "@type", "active", "user", "device"] for k, v in setting.items(): if k not in IGNORED_SETTINGS: # Translate the CamelCase values stored remotely into the # Python-style names used within mycroft-core. key = inflection.underscore(re.sub(r"Setting(s)?", "", k)) if isinstance(v, dict): config[key] = config.get(key, {}) translate_remote(config[key], v) elif isinstance(v, list): if is_remote_list(v): if key not in config: config[key] = {} translate_list(config[key], v) else: config[key] = v else: config[key] = v def translate_list(config, values): """ Translate list formated by mycroft server. Args: config (dict): target config values (list): list from mycroft server config """ for v in values: module = v["@type"] if v.get("active"): config["module"] = module config[module] = config.get(module, {}) translate_remote(config[module], v) class LocalConf(dict): """ Config dict from file. """ def __init__(self, path): super(LocalConf, self).__init__() if path: self.path = path self.load_local(path) def load_local(self, path): """ Load local json file into self. Args: path (str): file to load """ if exists(path) and isfile(path): try: config = load_commented_json(path) for key in config: self.__setitem__(key, config[key]) LOG.debug("Configuration {} loaded".format(path)) except Exception as e: LOG.error("Error loading configuration '{}'".format(path)) LOG.error(repr(e)) else: LOG.debug("Configuration '{}' not defined, skipping".format(path)) def store(self, path=None): """ Cache the received settings locally. The cache will be used if the remote is unreachable to load settings that are as close to the user's as possible """ path = path or self.path with open(path, 'w') as f: json.dump(self, f, indent=2) def merge(self, conf): merge_dict(self, conf) class RemoteConf(LocalConf): """ Config dict fetched from mycroft.ai """ def __init__(self, cache=None): super(RemoteConf, self).__init__(None) cache = cache or '/var/tmp/mycroft_web_cache.json' from mycroft.api import is_paired if not is_paired(): self.load_local(cache) return try: # Here to avoid cyclic import from mycroft.api import DeviceApi api = DeviceApi() setting = api.get_settings() try: location = api.get_location() except RequestException as e: LOG.error("RequestException fetching remote location: {}" .format(str(e))) if exists(cache) and isfile(cache): location = load_commented_json(cache).get('location') if location: setting["location"] = location # Remove server specific entries config = {} translate_remote(config, setting) for key in config: self.__setitem__(key, config[key]) self.store(cache) except RequestException as e: LOG.error("RequestException fetching remote configuration: {}" .format(str(e))) self.load_local(cache) except Exception as e: LOG.error("Failed to fetch remote configuration: %s" % repr(e), exc_info=True) self.load_local(cache) class Configuration: __config = {} # Cached config __patch = {} # Patch config that skills can update to override config @staticmethod def get(configs=None, cache=True): """ Get configuration, returns cached instance if available otherwise builds a new configuration dict. Args: configs (list): List of configuration dicts cache (boolean): True if the result should be cached """ if Configuration.__config: return Configuration.__config else: return Configuration.load_config_stack(configs, cache) @staticmethod def load_config_stack(configs=None, cache=False): """ load a stack of config dicts into a single dict Args: configs (list): list of dicts to load cache (boolean): True if result should be cached Returns: merged dict of all configuration files """ if not configs: configs = [LocalConf(DEFAULT_CONFIG), RemoteConf(), LocalConf(SYSTEM_CONFIG), LocalConf(USER_CONFIG), Configuration.__patch] else: # Handle strings in stack for index, item in enumerate(configs): if isinstance(item, str): configs[index] = LocalConf(item) # Merge all configs into one base = {} for c in configs: merge_dict(base, c) # copy into cache if cache: Configuration.__config.clear() for key in base: Configuration.__config[key] = base[key] return Configuration.__config else: return base @staticmethod def init(ws): """ Setup websocket handlers to update config. Args: ws: Websocket instance """ ws.on("configuration.updated", Configuration.updated) ws.on("configuration.patch", Configuration.patch) @staticmethod def updated(message): """ handler for configuration.updated, triggers an update of cached config. """ Configuration.load_config_stack(cache=True) @staticmethod def patch(message): """ patch the volatile dict usable by skills Args: message: Messagebus message should contain a config in the data payload. """ config = message.data.get("config", {}) merge_dict(Configuration.__patch, config) Configuration.load_config_stack(cache=True)
apache-2.0
[ 199, 3, 1898, 9708, 4932, 67, 293, 856, 437, 41, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 295, 199, 646, 2022, 199, 646, 10739, 1486, 199, 504, 747, 14, 515, 492, 3495, 12, 29214, 199, 504, 4145, 492, 4784, 1726, 199, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1001, 63, 3676, 492, 2248, 63, 957, 2509, 63, 1001, 12, 5389, 63, 807, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 793, 492, 5051, 199, 199, 504, 1275, 8022, 492, 6186, 63, 5569, 12, 20859, 63, 5569, 12, 13044, 63, 5569, 421, 199, 318, 365, 63, 3846, 63, 513, 8, 1459, 304, 272, 1449, 1104, 340, 642, 769, 13718, 370, 282, 4865, 7871, 3245, 402, 272, 11196, 1449, 272, 367, 373, 315, 1338, 26, 267, 340, 440, 1228, 8, 86, 12, 1211, 304, 288, 372, 756, 267, 340, 9244, 466, 2, 440, 315, 373, 14, 1612, 837, 288, 372, 756, 272, 372, 715, 421, 199, 318, 9028, 63, 3846, 8, 888, 12, 4260, 304, 272, 408, 267, 25540, 1101, 1561, 687, 1654, 370, 7353, 83, 18025, 267, 315, 3002, 67, 293, 856, 13, 1018, 14, 398, 3033, 26, 355, 1101, 26, 258, 1300, 1101, 370, 13904, 355, 2202, 26, 257, 3982, 2202, 370, 506, 14598, 272, 408, 272, 27499, 25517, 63, 13931, 275, 2097, 2580, 401, 9244, 466, 401, 298, 2682, 401, 298, 751, 401, 298, 1782, 937, 339, 367, 1022, 12, 373, 315, 4260, 14, 1744, 837, 267, 340, 1022, 440, 315, 27499, 25517, 63, 13931, 26, 288, 327, 25540, 314, 445, 14868, 1538, 1338, 5489, 3982, 590, 1901, 314, 288, 327, 2018, 13, 2487, 1561, 1202, 4453, 3002, 67, 293, 856, 13, 1018, 14, 288, 790, 275, 10739, 1486, 14, 21831, 8, 264, 14, 954, 8, 82, 2, 7776, 8, 83, 5547, 401, 4873, 1022, 430, 288, 340, 1228, 8, 86, 12, 1211, 304, 355, 1101, 59, 498, 61, 275, 1101, 14, 362, 8, 498, 12, 5009, 355, 9028, 63, 3846, 8, 888, 59, 498, 467, 373, 9, 288, 916, 1228, 8, 86, 12, 769, 304, 355, 340, 365, 63, 3846, 63, 513, 8, 86, 304, 490, 340, 790, 440, 315, 1101, 26, 717, 1101, 59, 498, 61, 275, 1052, 490, 9028, 63, 513, 8, 888, 59, 498, 467, 373, 9, 355, 587, 26, 490, 1101, 59, 498, 61, 275, 373, 288, 587, 26, 355, 1101, 59, 498, 61, 275, 373, 421, 199, 318, 9028, 63, 513, 8, 888, 12, 1338, 304, 272, 408, 267, 25540, 769, 1824, 972, 701, 3002, 67, 293, 856, 1654, 14, 398, 3033, 26, 288, 1101, 334, 807, 304, 1347, 1101, 288, 1338, 334, 513, 304, 769, 687, 3002, 67, 293, 856, 1654, 1101, 272, 408, 272, 367, 373, 315, 1338, 26, 267, 859, 275, 373, 905, 32, 466, 937, 267, 340, 373, 14, 362, 480, 2682, 2349, 288, 1101, 905, 578, 937, 275, 859, 267, 1101, 59, 578, 61, 275, 1101, 14, 362, 8, 578, 12, 5009, 267, 9028, 63, 3846, 8, 888, 59, 578, 467, 373, 9, 421, 199, 533, 10111, 8930, 8, 807, 304, 272, 408, 267, 4094, 1211, 687, 570, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 931, 304, 267, 1613, 8, 5339, 8930, 12, 291, 2843, 826, 4533, 267, 340, 931, 26, 288, 291, 14, 515, 275, 931, 288, 291, 14, 912, 63, 1832, 8, 515, 9, 339, 347, 2248, 63, 1832, 8, 277, 12, 931, 304, 267, 408, 288, 7190, 2257, 2022, 570, 1901, 291, 14, 953, 3033, 26, 355, 931, 334, 495, 304, 570, 370, 2248, 267, 408, 267, 340, 3495, 8, 515, 9, 436, 29214, 8, 515, 304, 288, 862, 26, 355, 1101, 275, 2248, 63, 957, 2509, 63, 1001, 8, 515, 9, 355, 367, 790, 315, 1101, 26, 490, 291, 855, 8617, 721, 498, 12, 1101, 59, 498, 566, 2234, 5051, 14, 1757, 480, 5688, 1052, 6511, 1674, 908, 8, 515, 430, 288, 871, 2186, 465, 325, 26, 355, 5051, 14, 705, 480, 547, 8697, 2897, 19574, 1674, 908, 8, 515, 430, 355, 5051, 14, 705, 8, 2722, 8, 69, 430, 267, 587, 26, 288, 5051, 14, 1757, 480, 5688, 19574, 440, 3247, 12, 16068, 1674, 908, 8, 515, 430, 339, 347, 3877, 8, 277, 12, 931, 29, 403, 304, 267, 408, 288, 11977, 314, 3086, 2202, 17738, 14, 710, 2581, 911, 506, 1202, 340, 288, 314, 3982, 365, 625, 15837, 370, 2248, 2202, 626, 787, 465, 4002, 288, 370, 314, 922, 1159, 465, 3962, 267, 408, 267, 931, 275, 931, 503, 291, 14, 515, 267, 543, 1551, 8, 515, 12, 283, 87, 358, 465, 289, 26, 288, 2022, 14, 2724, 8, 277, 12, 289, 12, 4363, 29, 18, 9, 339, 347, 5389, 8, 277, 12, 3743, 304, 267, 5389, 63, 807, 8, 277, 12, 3743, 9, 421, 199, 533, 17283, 8930, 8, 5339, 8930, 304, 272, 408, 267, 4094, 1211, 19251, 687, 3002, 67, 293, 856, 14, 5789, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2581, 29, 403, 304, 267, 1613, 8, 6713, 8930, 12, 291, 2843, 826, 721, 403, 9, 398, 2581, 275, 2581, 503, 1994, 1391, 15, 2791, 15, 1662, 67, 293, 856, 63, 2520, 63, 1637, 14, 1001, 7, 267, 687, 3002, 67, 293, 856, 14, 1246, 492, 365, 63, 29796, 267, 340, 440, 365, 63, 29796, 837, 288, 291, 14, 912, 63, 1832, 8, 1637, 9, 288, 372, 398, 862, 26, 288, 327, 11842, 370 ]
[ 3, 1898, 9708, 4932, 67, 293, 856, 437, 41, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 295, 199, 646, 2022, 199, 646, 10739, 1486, 199, 504, 747, 14, 515, 492, 3495, 12, 29214, 199, 504, 4145, 492, 4784, 1726, 199, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1001, 63, 3676, 492, 2248, 63, 957, 2509, 63, 1001, 12, 5389, 63, 807, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 793, 492, 5051, 199, 199, 504, 1275, 8022, 492, 6186, 63, 5569, 12, 20859, 63, 5569, 12, 13044, 63, 5569, 421, 199, 318, 365, 63, 3846, 63, 513, 8, 1459, 304, 272, 1449, 1104, 340, 642, 769, 13718, 370, 282, 4865, 7871, 3245, 402, 272, 11196, 1449, 272, 367, 373, 315, 1338, 26, 267, 340, 440, 1228, 8, 86, 12, 1211, 304, 288, 372, 756, 267, 340, 9244, 466, 2, 440, 315, 373, 14, 1612, 837, 288, 372, 756, 272, 372, 715, 421, 199, 318, 9028, 63, 3846, 8, 888, 12, 4260, 304, 272, 408, 267, 25540, 1101, 1561, 687, 1654, 370, 7353, 83, 18025, 267, 315, 3002, 67, 293, 856, 13, 1018, 14, 398, 3033, 26, 355, 1101, 26, 258, 1300, 1101, 370, 13904, 355, 2202, 26, 257, 3982, 2202, 370, 506, 14598, 272, 408, 272, 27499, 25517, 63, 13931, 275, 2097, 2580, 401, 9244, 466, 401, 298, 2682, 401, 298, 751, 401, 298, 1782, 937, 339, 367, 1022, 12, 373, 315, 4260, 14, 1744, 837, 267, 340, 1022, 440, 315, 27499, 25517, 63, 13931, 26, 288, 327, 25540, 314, 445, 14868, 1538, 1338, 5489, 3982, 590, 1901, 314, 288, 327, 2018, 13, 2487, 1561, 1202, 4453, 3002, 67, 293, 856, 13, 1018, 14, 288, 790, 275, 10739, 1486, 14, 21831, 8, 264, 14, 954, 8, 82, 2, 7776, 8, 83, 5547, 401, 4873, 1022, 430, 288, 340, 1228, 8, 86, 12, 1211, 304, 355, 1101, 59, 498, 61, 275, 1101, 14, 362, 8, 498, 12, 5009, 355, 9028, 63, 3846, 8, 888, 59, 498, 467, 373, 9, 288, 916, 1228, 8, 86, 12, 769, 304, 355, 340, 365, 63, 3846, 63, 513, 8, 86, 304, 490, 340, 790, 440, 315, 1101, 26, 717, 1101, 59, 498, 61, 275, 1052, 490, 9028, 63, 513, 8, 888, 59, 498, 467, 373, 9, 355, 587, 26, 490, 1101, 59, 498, 61, 275, 373, 288, 587, 26, 355, 1101, 59, 498, 61, 275, 373, 421, 199, 318, 9028, 63, 513, 8, 888, 12, 1338, 304, 272, 408, 267, 25540, 769, 1824, 972, 701, 3002, 67, 293, 856, 1654, 14, 398, 3033, 26, 288, 1101, 334, 807, 304, 1347, 1101, 288, 1338, 334, 513, 304, 769, 687, 3002, 67, 293, 856, 1654, 1101, 272, 408, 272, 367, 373, 315, 1338, 26, 267, 859, 275, 373, 905, 32, 466, 937, 267, 340, 373, 14, 362, 480, 2682, 2349, 288, 1101, 905, 578, 937, 275, 859, 267, 1101, 59, 578, 61, 275, 1101, 14, 362, 8, 578, 12, 5009, 267, 9028, 63, 3846, 8, 888, 59, 578, 467, 373, 9, 421, 199, 533, 10111, 8930, 8, 807, 304, 272, 408, 267, 4094, 1211, 687, 570, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 931, 304, 267, 1613, 8, 5339, 8930, 12, 291, 2843, 826, 4533, 267, 340, 931, 26, 288, 291, 14, 515, 275, 931, 288, 291, 14, 912, 63, 1832, 8, 515, 9, 339, 347, 2248, 63, 1832, 8, 277, 12, 931, 304, 267, 408, 288, 7190, 2257, 2022, 570, 1901, 291, 14, 953, 3033, 26, 355, 931, 334, 495, 304, 570, 370, 2248, 267, 408, 267, 340, 3495, 8, 515, 9, 436, 29214, 8, 515, 304, 288, 862, 26, 355, 1101, 275, 2248, 63, 957, 2509, 63, 1001, 8, 515, 9, 355, 367, 790, 315, 1101, 26, 490, 291, 855, 8617, 721, 498, 12, 1101, 59, 498, 566, 2234, 5051, 14, 1757, 480, 5688, 1052, 6511, 1674, 908, 8, 515, 430, 288, 871, 2186, 465, 325, 26, 355, 5051, 14, 705, 480, 547, 8697, 2897, 19574, 1674, 908, 8, 515, 430, 355, 5051, 14, 705, 8, 2722, 8, 69, 430, 267, 587, 26, 288, 5051, 14, 1757, 480, 5688, 19574, 440, 3247, 12, 16068, 1674, 908, 8, 515, 430, 339, 347, 3877, 8, 277, 12, 931, 29, 403, 304, 267, 408, 288, 11977, 314, 3086, 2202, 17738, 14, 710, 2581, 911, 506, 1202, 340, 288, 314, 3982, 365, 625, 15837, 370, 2248, 2202, 626, 787, 465, 4002, 288, 370, 314, 922, 1159, 465, 3962, 267, 408, 267, 931, 275, 931, 503, 291, 14, 515, 267, 543, 1551, 8, 515, 12, 283, 87, 358, 465, 289, 26, 288, 2022, 14, 2724, 8, 277, 12, 289, 12, 4363, 29, 18, 9, 339, 347, 5389, 8, 277, 12, 3743, 304, 267, 5389, 63, 807, 8, 277, 12, 3743, 9, 421, 199, 533, 17283, 8930, 8, 5339, 8930, 304, 272, 408, 267, 4094, 1211, 19251, 687, 3002, 67, 293, 856, 14, 5789, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2581, 29, 403, 304, 267, 1613, 8, 6713, 8930, 12, 291, 2843, 826, 721, 403, 9, 398, 2581, 275, 2581, 503, 1994, 1391, 15, 2791, 15, 1662, 67, 293, 856, 63, 2520, 63, 1637, 14, 1001, 7, 267, 687, 3002, 67, 293, 856, 14, 1246, 492, 365, 63, 29796, 267, 340, 440, 365, 63, 29796, 837, 288, 291, 14, 912, 63, 1832, 8, 1637, 9, 288, 372, 398, 862, 26, 288, 327, 11842, 370, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
zaw9c1/p2pool
nattraverso/utils.py
288
1563
""" Various utility functions used in the nattraverso package. @author: Raphael Slinckx @copyright: Copyright 2005 @license: LGPL @contact: U{raphael@slinckx.net<mailto:raphael@slinckx.net>} @version: 0.1.0 """ __revision__ = "$id" def is_rfc1918_ip(ip): """ Checks if the given ip address is a rfc1918 one. @param ip: The ip address to test @type ip: a string "x.x.x.x" @return: True if it's a LAN address, False otherwise """ if isinstance(ip, basestring): ip = _ip_to_number(ip) for net, mask in _nets: if ip&mask == net: return True return False def is_bogus_ip(ip): """ Checks if the given ip address is bogus, i.e. 0.0.0.0 or 127.0.0.1. @param ip: The ip address to test @type ip: a string "x.x.x.x" @return: True if it's bogus, False otherwise """ return ip.startswith('0.') or ip.startswith('127.') def _ip_to_number(ipstr): """ Translate a string ip address to a packed number. @param ipstr: the ip address to transform @type ipstr: a string "x.x.x.x" @return: an int32 number representing the ip address """ net = [ int(digit) for digit in ipstr.split('.') ] + [ 0, 0, 0 ] net = net[:4] return ((((((0L+net[0])<<8) + net[1])<<8) + net[2])<<8) +net[3] # List of rfc1918 net/mask _rfc1918_networks = [('127', 8), ('192.168', 16), ('10', 8), ('172.16', 12)] # Machine readable form of the above _nets = [(_ip_to_number(net), (2L**32 -1)^(2L**(32-mask)-1)) for net, mask in _rfc1918_networks]
gpl-3.0
[ 624, 199, 9958, 1785, 11420, 3423, 1202, 315, 314, 13872, 1239, 422, 1152, 2559, 14, 199, 199, 32, 2502, 26, 820, 439, 2411, 352, 428, 472, 346, 88, 199, 32, 7307, 26, 1898, 11811, 199, 32, 1682, 26, 32426, 199, 32, 7811, 26, 738, 91, 345, 2914, 352, 32, 83, 472, 346, 88, 14, 846, 28, 26206, 26, 345, 2914, 352, 32, 83, 472, 346, 88, 14, 846, 23307, 199, 32, 1023, 26, 378, 14, 17, 14, 16, 199, 624, 199, 363, 5792, 363, 275, 7880, 344, 2, 199, 199, 318, 365, 63, 8973, 1167, 1085, 63, 711, 8, 711, 304, 272, 408, 272, 13813, 340, 314, 1627, 3384, 2287, 365, 282, 18158, 1167, 1085, 1373, 14, 2286, 768, 635, 3384, 26, 710, 3384, 2287, 370, 511, 272, 768, 466, 3384, 26, 282, 1059, 298, 88, 14, 88, 14, 88, 14, 88, 2, 272, 768, 1107, 26, 715, 340, 652, 1159, 282, 491, 879, 2287, 12, 756, 4257, 272, 408, 272, 340, 1228, 8, 711, 12, 7116, 304, 267, 3384, 275, 485, 711, 63, 475, 63, 1955, 8, 711, 9, 2286, 367, 1851, 12, 3656, 315, 485, 20490, 26, 267, 340, 3384, 6, 2629, 508, 1851, 26, 288, 372, 715, 2286, 372, 756, 199, 199, 318, 365, 63, 18665, 63, 711, 8, 711, 304, 272, 408, 272, 13813, 340, 314, 1627, 3384, 2287, 365, 23703, 12, 284, 14, 69, 14, 378, 14, 16, 14, 16, 14, 16, 503, 12792, 14, 16, 14, 16, 14, 17, 14, 2286, 768, 635, 3384, 26, 710, 3384, 2287, 370, 511, 272, 768, 466, 3384, 26, 282, 1059, 298, 88, 14, 88, 14, 88, 14, 88, 2, 272, 768, 1107, 26, 715, 340, 652, 1159, 23703, 12, 756, 4257, 272, 408, 272, 372, 3384, 14, 2460, 360, 16, 2659, 503, 3384, 14, 2460, 360, 4195, 2659, 199, 199, 318, 485, 711, 63, 475, 63, 1955, 8, 711, 495, 304, 272, 408, 272, 25540, 282, 1059, 3384, 2287, 370, 282, 13170, 1329, 14, 2286, 768, 635, 3384, 495, 26, 314, 3384, 2287, 370, 5793, 272, 768, 466, 3384, 495, 26, 282, 1059, 298, 88, 14, 88, 14, 88, 14, 88, 2, 272, 768, 1107, 26, 376, 1109, 708, 1329, 6144, 314, 3384, 2287, 272, 408, 272, 1851, 275, 359, 1109, 8, 8573, 9, 367, 10964, 315, 3384, 495, 14, 1294, 7563, 1622, 435, 359, 378, 12, 378, 12, 378, 1622, 272, 1851, 275, 1851, 1491, 20, 61, 272, 372, 221, 20337, 12925, 16, 44, 11, 846, 59, 16, 566, 8999, 24, 9, 435, 1851, 59, 17, 566, 8999, 24, 9, 435, 1851, 59, 18, 566, 8999, 24, 9, 435, 846, 59, 19, 61, 199, 199, 3, 3820, 402, 18158, 1167, 1085, 1851, 15, 2629, 199, 63, 8973, 1167, 1085, 63, 7642, 275, 4274, 4195, 297, 1695, 395, 661, 5756, 14, 6568, 297, 3193, 395, 661, 709, 297, 1695, 395, 661, 10419, 14, 975, 297, 3144, 1874, 199, 3, 18722, 12701, 1824, 402, 314, 3432, 199, 63, 20490, 275, 359, 1547, 711, 63, 475, 63, 1955, 8, 846, 395, 334, 18, 44, 538, 708, 446, 17, 18979, 8, 18, 44, 14192, 708, 13, 2629, 7216, 17, 430, 272, 367, 1851, 12, 3656, 315, 485, 8973, 1167, 1085, 63, 7642, 61, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 9958, 1785, 11420, 3423, 1202, 315, 314, 13872, 1239, 422, 1152, 2559, 14, 199, 199, 32, 2502, 26, 820, 439, 2411, 352, 428, 472, 346, 88, 199, 32, 7307, 26, 1898, 11811, 199, 32, 1682, 26, 32426, 199, 32, 7811, 26, 738, 91, 345, 2914, 352, 32, 83, 472, 346, 88, 14, 846, 28, 26206, 26, 345, 2914, 352, 32, 83, 472, 346, 88, 14, 846, 23307, 199, 32, 1023, 26, 378, 14, 17, 14, 16, 199, 624, 199, 363, 5792, 363, 275, 7880, 344, 2, 199, 199, 318, 365, 63, 8973, 1167, 1085, 63, 711, 8, 711, 304, 272, 408, 272, 13813, 340, 314, 1627, 3384, 2287, 365, 282, 18158, 1167, 1085, 1373, 14, 2286, 768, 635, 3384, 26, 710, 3384, 2287, 370, 511, 272, 768, 466, 3384, 26, 282, 1059, 298, 88, 14, 88, 14, 88, 14, 88, 2, 272, 768, 1107, 26, 715, 340, 652, 1159, 282, 491, 879, 2287, 12, 756, 4257, 272, 408, 272, 340, 1228, 8, 711, 12, 7116, 304, 267, 3384, 275, 485, 711, 63, 475, 63, 1955, 8, 711, 9, 2286, 367, 1851, 12, 3656, 315, 485, 20490, 26, 267, 340, 3384, 6, 2629, 508, 1851, 26, 288, 372, 715, 2286, 372, 756, 199, 199, 318, 365, 63, 18665, 63, 711, 8, 711, 304, 272, 408, 272, 13813, 340, 314, 1627, 3384, 2287, 365, 23703, 12, 284, 14, 69, 14, 378, 14, 16, 14, 16, 14, 16, 503, 12792, 14, 16, 14, 16, 14, 17, 14, 2286, 768, 635, 3384, 26, 710, 3384, 2287, 370, 511, 272, 768, 466, 3384, 26, 282, 1059, 298, 88, 14, 88, 14, 88, 14, 88, 2, 272, 768, 1107, 26, 715, 340, 652, 1159, 23703, 12, 756, 4257, 272, 408, 272, 372, 3384, 14, 2460, 360, 16, 2659, 503, 3384, 14, 2460, 360, 4195, 2659, 199, 199, 318, 485, 711, 63, 475, 63, 1955, 8, 711, 495, 304, 272, 408, 272, 25540, 282, 1059, 3384, 2287, 370, 282, 13170, 1329, 14, 2286, 768, 635, 3384, 495, 26, 314, 3384, 2287, 370, 5793, 272, 768, 466, 3384, 495, 26, 282, 1059, 298, 88, 14, 88, 14, 88, 14, 88, 2, 272, 768, 1107, 26, 376, 1109, 708, 1329, 6144, 314, 3384, 2287, 272, 408, 272, 1851, 275, 359, 1109, 8, 8573, 9, 367, 10964, 315, 3384, 495, 14, 1294, 7563, 1622, 435, 359, 378, 12, 378, 12, 378, 1622, 272, 1851, 275, 1851, 1491, 20, 61, 272, 372, 221, 20337, 12925, 16, 44, 11, 846, 59, 16, 566, 8999, 24, 9, 435, 1851, 59, 17, 566, 8999, 24, 9, 435, 1851, 59, 18, 566, 8999, 24, 9, 435, 846, 59, 19, 61, 199, 199, 3, 3820, 402, 18158, 1167, 1085, 1851, 15, 2629, 199, 63, 8973, 1167, 1085, 63, 7642, 275, 4274, 4195, 297, 1695, 395, 661, 5756, 14, 6568, 297, 3193, 395, 661, 709, 297, 1695, 395, 661, 10419, 14, 975, 297, 3144, 1874, 199, 3, 18722, 12701, 1824, 402, 314, 3432, 199, 63, 20490, 275, 359, 1547, 711, 63, 475, 63, 1955, 8, 846, 395, 334, 18, 44, 538, 708, 446, 17, 18979, 8, 18, 44, 14192, 708, 13, 2629, 7216, 17, 430, 272, 367, 1851, 12, 3656, 315, 485, 8973, 1167, 1085, 63, 7642, 61, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
seewindcn/tortoisehg
src/mercurial/py3kcompat.py
2
2156
# py3kcompat.py - compatibility definitions for running hg in py3k # # Copyright 2010 Renato Cunha <renatoc@gmail.com> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from __future__ import absolute_import import builtins import numbers Number = numbers.Number def bytesformatter(format, args): '''Custom implementation of a formatter for bytestrings. This function currently relies on the string formatter to do the formatting and always returns bytes objects. >>> bytesformatter(20, 10) 0 >>> bytesformatter('unicode %s, %s!', ('string', 'foo')) b'unicode string, foo!' >>> bytesformatter(b'test %s', 'me') b'test me' >>> bytesformatter('test %s', 'me') b'test me' >>> bytesformatter(b'test %s', b'me') b'test me' >>> bytesformatter('test %s', b'me') b'test me' >>> bytesformatter('test %d: %s', (1, b'result')) b'test 1: result' ''' # The current implementation just converts from bytes to unicode, do # what's needed and then convert the results back to bytes. # Another alternative is to use the Python C API implementation. if isinstance(format, Number): # If the fixer erroneously passes a number remainder operation to # bytesformatter, we just return the correct operation return format % args if isinstance(format, bytes): format = format.decode('utf-8', 'surrogateescape') if isinstance(args, bytes): args = args.decode('utf-8', 'surrogateescape') if isinstance(args, tuple): newargs = [] for arg in args: if isinstance(arg, bytes): arg = arg.decode('utf-8', 'surrogateescape') newargs.append(arg) args = tuple(newargs) ret = format % args return ret.encode('utf-8', 'surrogateescape') builtins.bytesformatter = bytesformatter origord = builtins.ord def fakeord(char): if isinstance(char, int): return char return origord(char) builtins.ord = fakeord if __name__ == '__main__': import doctest doctest.testmod()
gpl-2.0
[ 3, 1134, 19, 75, 5819, 14, 647, 446, 7163, 10269, 367, 3879, 18016, 315, 1134, 19, 75, 199, 3, 199, 3, 1898, 7129, 10055, 11318, 445, 324, 2411, 665, 828, 292, 679, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1202, 436, 1854, 7182, 370, 314, 2895, 402, 314, 199, 3, 1664, 1696, 1684, 844, 1015, 499, 503, 1263, 2945, 1015, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 12963, 199, 646, 5579, 199, 199, 3259, 275, 5579, 14, 3259, 199, 199, 318, 2783, 8911, 8, 908, 12, 1249, 304, 272, 1449, 7223, 4514, 402, 282, 9698, 367, 18792, 25182, 14, 339, 961, 805, 5544, 25749, 641, 314, 1059, 9698, 370, 886, 314, 272, 10803, 436, 3544, 2529, 2783, 2251, 14, 339, 1306, 2783, 8911, 8, 1165, 12, 1616, 9, 272, 378, 272, 1306, 2783, 8911, 360, 2975, 450, 83, 12, 450, 83, 12389, 661, 875, 297, 283, 1421, 1333, 272, 330, 7, 2975, 1059, 12, 3925, 11213, 272, 1306, 2783, 8911, 8, 66, 1133, 597, 450, 83, 297, 283, 278, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 360, 396, 450, 83, 297, 283, 278, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 8, 66, 1133, 597, 450, 83, 297, 330, 6704, 69, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 360, 396, 450, 83, 297, 330, 6704, 69, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 360, 396, 450, 68, 26, 450, 83, 297, 334, 17, 12, 330, 3984, 83, 427, 1333, 272, 330, 1133, 597, 413, 26, 754, 7, 272, 1449, 272, 327, 710, 1453, 4514, 2951, 15373, 687, 2783, 370, 2649, 12, 886, 272, 327, 4052, 1159, 4346, 436, 2066, 3957, 314, 2058, 1771, 370, 2783, 14, 272, 327, 22604, 13943, 365, 370, 675, 314, 2018, 445, 3261, 4514, 14, 272, 340, 1228, 8, 908, 12, 4860, 304, 267, 327, 982, 314, 24739, 2329, 368, 1785, 590, 14933, 282, 1329, 15748, 3439, 370, 267, 327, 2783, 8911, 12, 781, 2951, 372, 314, 3211, 3439, 267, 372, 1475, 450, 1249, 272, 340, 1228, 8, 908, 12, 2783, 304, 267, 1475, 275, 1475, 14, 2708, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 272, 340, 1228, 8, 589, 12, 2783, 304, 267, 1249, 275, 1249, 14, 2708, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 272, 340, 1228, 8, 589, 12, 2008, 304, 267, 892, 589, 275, 942, 267, 367, 1680, 315, 1249, 26, 288, 340, 1228, 8, 1273, 12, 2783, 304, 355, 1680, 275, 1680, 14, 2708, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 288, 892, 589, 14, 740, 8, 1273, 9, 267, 1249, 275, 2008, 8, 1222, 589, 9, 272, 2203, 275, 1475, 450, 1249, 272, 372, 2203, 14, 2143, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 199, 10372, 14, 2394, 8911, 275, 2783, 8911, 199, 199, 2981, 2181, 275, 12963, 14, 2181, 199, 318, 4026, 2181, 8, 1560, 304, 272, 340, 1228, 8, 1560, 12, 1109, 304, 267, 372, 1495, 272, 372, 2306, 2181, 8, 1560, 9, 199, 10372, 14, 2181, 275, 4026, 2181, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 8868, 272, 8868, 14, 29446, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1134, 19, 75, 5819, 14, 647, 446, 7163, 10269, 367, 3879, 18016, 315, 1134, 19, 75, 199, 3, 199, 3, 1898, 7129, 10055, 11318, 445, 324, 2411, 665, 828, 292, 679, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1202, 436, 1854, 7182, 370, 314, 2895, 402, 314, 199, 3, 1664, 1696, 1684, 844, 1015, 499, 503, 1263, 2945, 1015, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 12963, 199, 646, 5579, 199, 199, 3259, 275, 5579, 14, 3259, 199, 199, 318, 2783, 8911, 8, 908, 12, 1249, 304, 272, 1449, 7223, 4514, 402, 282, 9698, 367, 18792, 25182, 14, 339, 961, 805, 5544, 25749, 641, 314, 1059, 9698, 370, 886, 314, 272, 10803, 436, 3544, 2529, 2783, 2251, 14, 339, 1306, 2783, 8911, 8, 1165, 12, 1616, 9, 272, 378, 272, 1306, 2783, 8911, 360, 2975, 450, 83, 12, 450, 83, 12389, 661, 875, 297, 283, 1421, 1333, 272, 330, 7, 2975, 1059, 12, 3925, 11213, 272, 1306, 2783, 8911, 8, 66, 1133, 597, 450, 83, 297, 283, 278, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 360, 396, 450, 83, 297, 283, 278, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 8, 66, 1133, 597, 450, 83, 297, 330, 6704, 69, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 360, 396, 450, 83, 297, 330, 6704, 69, 358, 272, 330, 1133, 597, 562, 7, 272, 1306, 2783, 8911, 360, 396, 450, 68, 26, 450, 83, 297, 334, 17, 12, 330, 3984, 83, 427, 1333, 272, 330, 1133, 597, 413, 26, 754, 7, 272, 1449, 272, 327, 710, 1453, 4514, 2951, 15373, 687, 2783, 370, 2649, 12, 886, 272, 327, 4052, 1159, 4346, 436, 2066, 3957, 314, 2058, 1771, 370, 2783, 14, 272, 327, 22604, 13943, 365, 370, 675, 314, 2018, 445, 3261, 4514, 14, 272, 340, 1228, 8, 908, 12, 4860, 304, 267, 327, 982, 314, 24739, 2329, 368, 1785, 590, 14933, 282, 1329, 15748, 3439, 370, 267, 327, 2783, 8911, 12, 781, 2951, 372, 314, 3211, 3439, 267, 372, 1475, 450, 1249, 272, 340, 1228, 8, 908, 12, 2783, 304, 267, 1475, 275, 1475, 14, 2708, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 272, 340, 1228, 8, 589, 12, 2783, 304, 267, 1249, 275, 1249, 14, 2708, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 272, 340, 1228, 8, 589, 12, 2008, 304, 267, 892, 589, 275, 942, 267, 367, 1680, 315, 1249, 26, 288, 340, 1228, 8, 1273, 12, 2783, 304, 355, 1680, 275, 1680, 14, 2708, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 288, 892, 589, 14, 740, 8, 1273, 9, 267, 1249, 275, 2008, 8, 1222, 589, 9, 272, 2203, 275, 1475, 450, 1249, 272, 372, 2203, 14, 2143, 360, 1624, 13, 24, 297, 283, 16380, 3765, 358, 199, 10372, 14, 2394, 8911, 275, 2783, 8911, 199, 199, 2981, 2181, 275, 12963, 14, 2181, 199, 318, 4026, 2181, 8, 1560, 304, 272, 340, 1228, 8, 1560, 12, 1109, 304, 267, 372, 1495, 272, 372, 2306, 2181, 8, 1560, 9, 199, 10372, 14, 2181, 275, 4026, 2181, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 8868, 272, 8868, 14, 29446, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wevote/WebAppPublic
apis_v1/documentation_source/positions_count_for_one_ballot_item_doc.py
1
2560
# apis_v1/documentation_source/positions_count_for_one_ballot_item_doc.py # Brought to you by We Vote. Be good. # -*- coding: UTF-8 -*- def positions_count_for_one_ballot_item_doc_template_values(url_root): """ Show documentation about positionsCountForOneBallotItem """ required_query_parameter_list = [ { 'name': 'voter_device_id', 'value': 'string', # boolean, integer, long, string 'description': 'An 88 character unique identifier linked to a voter record on the server', }, { 'name': 'api_key', 'value': 'string (from post, cookie, or get (in that order))', # boolean, integer, long, string 'description': 'The unique key provided to any organization using the WeVoteServer APIs', }, { 'name': 'ballot_item_we_vote_id', 'value': 'string', # boolean, integer, long, string 'description': 'The unique identifier for one ballot item.', }, ] optional_query_parameter_list = [ ] potential_status_codes_list = [ ] try_now_link_variables_dict = { } api_response = '{\n' \ ' "success": boolean,\n' \ ' "status": string,\n' \ ' "ballot_item_we_vote_id: string,\n' \ ' "ballot_item_list": list ' \ '(we return a list so this API can be consumed like positionsCountForAllBallotItems)\n' \ ' [\n' \ ' "ballot_item_we_vote_id": string,\n' \ ' "support_count": integer,\n' \ ' "oppose_count": integer,\n' \ ' ],\n' \ '}' template_values = { 'api_name': 'positionsCountForOneBallotItem', 'api_slug': 'positionsCountForOneBallotItem', 'api_introduction': "Retrieve all positions held by this voter in one list.", 'try_now_link': 'apis_v1:positionsCountForOneBallotItemView', 'try_now_link_variables_dict': try_now_link_variables_dict, 'url_root': url_root, 'get_or_post': 'GET', 'required_query_parameter_list': required_query_parameter_list, 'optional_query_parameter_list': optional_query_parameter_list, 'api_response': api_response, 'api_response_notes': "", 'potential_status_codes_list': potential_status_codes_list, } return template_values
bsd-3-clause
[ 3, 2771, 374, 63, 86, 17, 15, 9970, 63, 1365, 15, 12658, 63, 835, 63, 509, 63, 368, 63, 4982, 1653, 63, 1053, 63, 1301, 14, 647, 199, 3, 699, 7930, 913, 370, 1265, 701, 2136, 812, 1583, 14, 6423, 6954, 14, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 421, 199, 318, 12266, 63, 835, 63, 509, 63, 368, 63, 4982, 1653, 63, 1053, 63, 1301, 63, 1160, 63, 1459, 8, 633, 63, 1231, 304, 272, 408, 272, 12968, 3794, 3595, 12266, 2353, 1858, 4395, 13129, 1653, 2081, 272, 408, 272, 1415, 63, 1131, 63, 5329, 63, 513, 275, 359, 267, 469, 288, 283, 354, 356, 260, 283, 2392, 351, 63, 1782, 63, 344, 297, 288, 283, 585, 356, 263, 283, 875, 297, 221, 327, 5046, 12, 3000, 12, 1846, 12, 1059, 288, 283, 1802, 356, 221, 283, 2493, 10523, 4528, 3747, 5148, 10632, 370, 282, 14164, 351, 2777, 641, 314, 1654, 297, 267, 1660, 267, 469, 288, 283, 354, 356, 260, 283, 1246, 63, 498, 297, 288, 283, 585, 356, 263, 283, 875, 334, 504, 2963, 12, 5494, 12, 503, 664, 334, 262, 626, 1865, 22629, 221, 327, 5046, 12, 3000, 12, 1846, 12, 1059, 288, 283, 1802, 356, 221, 283, 1918, 3747, 790, 2741, 370, 1263, 13237, 1808, 314, 2136, 54, 1583, 3120, 15913, 297, 267, 1660, 267, 469, 288, 283, 354, 356, 260, 283, 4982, 1653, 63, 1053, 63, 1129, 63, 14317, 63, 344, 297, 288, 283, 585, 356, 263, 283, 875, 297, 221, 327, 5046, 12, 3000, 12, 1846, 12, 1059, 288, 283, 1802, 356, 221, 283, 1918, 3747, 5148, 367, 1373, 8091, 1653, 1242, 3130, 267, 1660, 272, 1622, 272, 2716, 63, 1131, 63, 5329, 63, 513, 275, 359, 272, 1622, 339, 12330, 63, 1205, 63, 6021, 63, 513, 275, 359, 272, 1622, 339, 862, 63, 2131, 63, 1073, 63, 3669, 63, 807, 275, 469, 272, 789, 339, 2986, 63, 1310, 275, 5041, 60, 78, 7, 971, 673, 283, 221, 298, 3742, 582, 5046, 4202, 78, 7, 971, 673, 283, 221, 298, 1205, 582, 1059, 4202, 78, 7, 971, 673, 283, 221, 298, 4982, 1653, 63, 1053, 63, 1129, 63, 14317, 63, 344, 26, 1059, 4202, 78, 7, 971, 673, 283, 221, 298, 4982, 1653, 63, 1053, 63, 513, 582, 769, 283, 971, 673, 8189, 1129, 372, 282, 769, 880, 642, 3261, 883, 506, 16949, 2839, 12266, 2353, 30462, 13129, 1653, 7412, 2862, 78, 7, 971, 673, 283, 257, 359, 60, 78, 7, 971, 673, 283, 258, 298, 4982, 1653, 63, 1053, 63, 1129, 63, 14317, 63, 344, 582, 1059, 4202, 78, 7, 971, 673, 283, 258, 298, 4058, 63, 835, 582, 3000, 4202, 78, 7, 971, 673, 283, 258, 298, 411, 4070, 63, 835, 582, 3000, 4202, 78, 7, 971, 673, 283, 257, 2156, 60, 78, 7, 971, 673, 23618, 339, 1978, 63, 1459, 275, 469, 267, 283, 1246, 63, 354, 356, 283, 12658, 2353, 1858, 4395, 13129, 1653, 2081, 297, 267, 283, 1246, 63, 5464, 356, 283, 12658, 2353, 1858, 4395, 13129, 1653, 2081, 297, 267, 283, 1246, 63, 18206, 5199, 356, 288, 298, 15310, 1006, 12266, 23608, 701, 642, 14164, 351, 315, 1373, 769, 4765, 267, 283, 893, 63, 2131, 63, 1073, 356, 283, 12662, 63, 86, 17, 26, 12658, 2353, 1858, 4395, 13129, 1653, 2081, 2768, 297, 267, 283, 893, 63, 2131, 63, 1073, 63, 3669, 63, 807, 356, 862, 63, 2131, 63, 1073, 63, 3669, 63, 807, 12, 267, 283, 633, 63, 1231, 356, 1166, 63, 1231, 12, 267, 283, 362, 63, 269, 63, 1932, 356, 283, 2970, 297, 267, 283, 2427, 63, 1131, 63, 5329, 63, 513, 356, 1415, 63, 1131, 63, 5329, 63, 513, 12, 267, 283, 4144, 63, 1131, 63, 5329, 63, 513, 356, 2716, 63, 1131, 63, 5329, 63, 513, 12, 267, 283, 1246, 63, 1310, 356, 2986, 63, 1310, 12, 267, 283, 1246, 63, 1310, 63, 5983, 356, 288, 4873, 267, 283, 24668, 63, 1205, 63, 6021, 63, 513, 356, 12330, 63, 1205, 63, 6021, 63, 513, 12, 272, 789, 272, 372, 1978, 63, 1459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2771, 374, 63, 86, 17, 15, 9970, 63, 1365, 15, 12658, 63, 835, 63, 509, 63, 368, 63, 4982, 1653, 63, 1053, 63, 1301, 14, 647, 199, 3, 699, 7930, 913, 370, 1265, 701, 2136, 812, 1583, 14, 6423, 6954, 14, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 421, 199, 318, 12266, 63, 835, 63, 509, 63, 368, 63, 4982, 1653, 63, 1053, 63, 1301, 63, 1160, 63, 1459, 8, 633, 63, 1231, 304, 272, 408, 272, 12968, 3794, 3595, 12266, 2353, 1858, 4395, 13129, 1653, 2081, 272, 408, 272, 1415, 63, 1131, 63, 5329, 63, 513, 275, 359, 267, 469, 288, 283, 354, 356, 260, 283, 2392, 351, 63, 1782, 63, 344, 297, 288, 283, 585, 356, 263, 283, 875, 297, 221, 327, 5046, 12, 3000, 12, 1846, 12, 1059, 288, 283, 1802, 356, 221, 283, 2493, 10523, 4528, 3747, 5148, 10632, 370, 282, 14164, 351, 2777, 641, 314, 1654, 297, 267, 1660, 267, 469, 288, 283, 354, 356, 260, 283, 1246, 63, 498, 297, 288, 283, 585, 356, 263, 283, 875, 334, 504, 2963, 12, 5494, 12, 503, 664, 334, 262, 626, 1865, 22629, 221, 327, 5046, 12, 3000, 12, 1846, 12, 1059, 288, 283, 1802, 356, 221, 283, 1918, 3747, 790, 2741, 370, 1263, 13237, 1808, 314, 2136, 54, 1583, 3120, 15913, 297, 267, 1660, 267, 469, 288, 283, 354, 356, 260, 283, 4982, 1653, 63, 1053, 63, 1129, 63, 14317, 63, 344, 297, 288, 283, 585, 356, 263, 283, 875, 297, 221, 327, 5046, 12, 3000, 12, 1846, 12, 1059, 288, 283, 1802, 356, 221, 283, 1918, 3747, 5148, 367, 1373, 8091, 1653, 1242, 3130, 267, 1660, 272, 1622, 272, 2716, 63, 1131, 63, 5329, 63, 513, 275, 359, 272, 1622, 339, 12330, 63, 1205, 63, 6021, 63, 513, 275, 359, 272, 1622, 339, 862, 63, 2131, 63, 1073, 63, 3669, 63, 807, 275, 469, 272, 789, 339, 2986, 63, 1310, 275, 5041, 60, 78, 7, 971, 673, 283, 221, 298, 3742, 582, 5046, 4202, 78, 7, 971, 673, 283, 221, 298, 1205, 582, 1059, 4202, 78, 7, 971, 673, 283, 221, 298, 4982, 1653, 63, 1053, 63, 1129, 63, 14317, 63, 344, 26, 1059, 4202, 78, 7, 971, 673, 283, 221, 298, 4982, 1653, 63, 1053, 63, 513, 582, 769, 283, 971, 673, 8189, 1129, 372, 282, 769, 880, 642, 3261, 883, 506, 16949, 2839, 12266, 2353, 30462, 13129, 1653, 7412, 2862, 78, 7, 971, 673, 283, 257, 359, 60, 78, 7, 971, 673, 283, 258, 298, 4982, 1653, 63, 1053, 63, 1129, 63, 14317, 63, 344, 582, 1059, 4202, 78, 7, 971, 673, 283, 258, 298, 4058, 63, 835, 582, 3000, 4202, 78, 7, 971, 673, 283, 258, 298, 411, 4070, 63, 835, 582, 3000, 4202, 78, 7, 971, 673, 283, 257, 2156, 60, 78, 7, 971, 673, 23618, 339, 1978, 63, 1459, 275, 469, 267, 283, 1246, 63, 354, 356, 283, 12658, 2353, 1858, 4395, 13129, 1653, 2081, 297, 267, 283, 1246, 63, 5464, 356, 283, 12658, 2353, 1858, 4395, 13129, 1653, 2081, 297, 267, 283, 1246, 63, 18206, 5199, 356, 288, 298, 15310, 1006, 12266, 23608, 701, 642, 14164, 351, 315, 1373, 769, 4765, 267, 283, 893, 63, 2131, 63, 1073, 356, 283, 12662, 63, 86, 17, 26, 12658, 2353, 1858, 4395, 13129, 1653, 2081, 2768, 297, 267, 283, 893, 63, 2131, 63, 1073, 63, 3669, 63, 807, 356, 862, 63, 2131, 63, 1073, 63, 3669, 63, 807, 12, 267, 283, 633, 63, 1231, 356, 1166, 63, 1231, 12, 267, 283, 362, 63, 269, 63, 1932, 356, 283, 2970, 297, 267, 283, 2427, 63, 1131, 63, 5329, 63, 513, 356, 1415, 63, 1131, 63, 5329, 63, 513, 12, 267, 283, 4144, 63, 1131, 63, 5329, 63, 513, 356, 2716, 63, 1131, 63, 5329, 63, 513, 12, 267, 283, 1246, 63, 1310, 356, 2986, 63, 1310, 12, 267, 283, 1246, 63, 1310, 63, 5983, 356, 288, 4873, 267, 283, 24668, 63, 1205, 63, 6021, 63, 513, 356, 12330, 63, 1205, 63, 6021, 63, 513, 12, 272, 789, 272, 372, 1978, 63, 1459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Glyfina-Fernando/pymtl
pisa/pisa_inst_andi_test.py
4
3873
#========================================================================= # pisa_andi_test.py #========================================================================= import pytest import random import pisa_encoding from pymtl import Bits, sext, zext from PisaSim import PisaSim from pisa_inst_test_utils import * #------------------------------------------------------------------------- # gen_basic_test #------------------------------------------------------------------------- def gen_basic_test(): return """ mfc0 r1, mngr2proc < 0x0f0f0f0f nop nop nop nop nop nop nop nop andi r3, r1, 0x00ff nop nop nop nop nop nop nop nop mtc0 r3, proc2mngr >0x0000000f nop nop nop nop nop nop nop nop """ #------------------------------------------------------------------------- # gen_dest_byp_test #------------------------------------------------------------------------- def gen_dest_byp_test(): return [ gen_rimm_dest_byp_test( 5, "andi", 0x00000f0f, 0x00ff, 0x0000000f ), gen_rimm_dest_byp_test( 4, "andi", 0x0000f0f0, 0x0ff0, 0x000000f0 ), gen_rimm_dest_byp_test( 3, "andi", 0x00000f0f, 0xff00, 0x00000f00 ), gen_rimm_dest_byp_test( 2, "andi", 0x0000f0f0, 0xf00f, 0x0000f000 ), gen_rimm_dest_byp_test( 1, "andi", 0x00000f0f, 0x00ff, 0x0000000f ), gen_rimm_dest_byp_test( 0, "andi", 0x0000f0f0, 0x0ff0, 0x000000f0 ), ] #------------------------------------------------------------------------- # gen_src_byp_test #------------------------------------------------------------------------- def gen_src_byp_test(): return [ gen_rimm_src_byp_test( 5, "andi", 0x00000f0f, 0x00ff, 0x0000000f ), gen_rimm_src_byp_test( 4, "andi", 0x0000f0f0, 0x0ff0, 0x000000f0 ), gen_rimm_src_byp_test( 3, "andi", 0x00000f0f, 0xff00, 0x00000f00 ), gen_rimm_src_byp_test( 2, "andi", 0x0000f0f0, 0xf00f, 0x0000f000 ), gen_rimm_src_byp_test( 1, "andi", 0x00000f0f, 0x00ff, 0x0000000f ), gen_rimm_src_byp_test( 0, "andi", 0x0000f0f0, 0x0ff0, 0x000000f0 ), ] #------------------------------------------------------------------------- # gen_srcs_dest_test #------------------------------------------------------------------------- def gen_srcs_dest_test(): return [ gen_rimm_src_eq_dest_test( "andi", 0x00000f0f, 0xff00, 0x00000f00 ), ] #------------------------------------------------------------------------- # gen_value_test #------------------------------------------------------------------------- def gen_value_test(): return [ gen_rimm_value_test( "andi", 0xff00ff00, 0x0f0f, 0x00000f00 ), gen_rimm_value_test( "andi", 0x0ff00ff0, 0xf0f0, 0x000000f0 ), gen_rimm_value_test( "andi", 0x00ff00ff, 0x0f0f, 0x0000000f ), gen_rimm_value_test( "andi", 0xf00ff00f, 0xf0f0, 0x0000f000 ), ] #------------------------------------------------------------------------- # gen_random_test #------------------------------------------------------------------------- def gen_random_test(): asm_code = [] for i in xrange(100): src = Bits( 32, random.randint(0,0xffffffff) ) imm = Bits( 16, random.randint(0,0xffff) ) dest = src & zext(imm,32) asm_code.append( gen_rimm_value_test( "andi", src.uint(), imm.uint(), dest.uint() ) ) return asm_code #------------------------------------------------------------------------- # test_basic #------------------------------------------------------------------------- @pytest.mark.parametrize( "name,test", [ asm_test( gen_basic_test ), asm_test( gen_dest_byp_test ), asm_test( gen_src_byp_test ), asm_test( gen_srcs_dest_test ), asm_test( gen_value_test ), asm_test( gen_random_test ), ]) def test( name, test ): sim = PisaSim( trace_en=True ) sim.load( pisa_encoding.assemble( test() ) ) sim.run()
bsd-3-clause
[ 14813, 15495, 199, 3, 299, 13655, 63, 290, 328, 63, 396, 14, 647, 199, 14813, 15495, 199, 199, 646, 4613, 199, 646, 2196, 199, 646, 299, 13655, 63, 2991, 199, 199, 504, 1134, 2037, 76, 257, 492, 26612, 12, 542, 400, 12, 29986, 400, 199, 504, 510, 13655, 7467, 492, 510, 13655, 7467, 199, 199, 504, 299, 13655, 63, 3615, 63, 396, 63, 1208, 492, 627, 199, 199, 25812, 199, 3, 3805, 63, 4316, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 4316, 63, 396, 837, 523, 372, 408, 272, 333, 3003, 16, 519, 17, 12, 21945, 2587, 18, 4687, 665, 378, 88, 16, 70, 16, 70, 16, 70, 16, 70, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 376, 328, 519, 19, 12, 519, 17, 12, 378, 88, 383, 556, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 333, 3641, 16, 519, 19, 12, 6499, 18, 10344, 2587, 690, 16, 88, 9084, 70, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 523, 408, 199, 199, 25812, 199, 3, 3805, 63, 2614, 63, 991, 80, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2614, 63, 991, 80, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 959, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 841, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 650, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 3581, 383, 12, 378, 88, 5345, 70, 383, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 499, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 1949, 383, 70, 12, 378, 88, 993, 70, 1493, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 413, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 378, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 2164, 63, 991, 80, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2164, 63, 991, 80, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 959, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 841, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 650, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 3581, 383, 12, 378, 88, 5345, 70, 383, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 499, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 1949, 383, 70, 12, 378, 88, 993, 70, 1493, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 413, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 378, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 2164, 83, 63, 2614, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2164, 83, 63, 2614, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 2164, 63, 4077, 63, 2614, 63, 396, 8, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 3581, 383, 12, 378, 88, 5345, 70, 383, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 585, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 585, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 3581, 383, 556, 383, 12, 378, 88, 16, 70, 16, 70, 12, 378, 88, 5345, 70, 383, 2318, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 88, 16, 556, 383, 556, 16, 12, 378, 1949, 16, 70, 16, 12, 378, 88, 3273, 70, 16, 2318, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 88, 383, 556, 383, 556, 12, 378, 88, 16, 70, 16, 70, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 1949, 383, 556, 383, 70, 12, 378, 1949, 16, 70, 16, 12, 378, 88, 993, 70, 1493, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 2355, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2355, 63, 396, 837, 523, 21875, 63, 600, 275, 942, 523, 367, 284, 315, 4945, 8, 1960, 304, 272, 2928, 221, 275, 26612, 8, 4337, 12, 2196, 14, 8393, 8, 16, 12, 16, 21870, 9, 776, 272, 25531, 221, 275, 26612, 8, 3193, 12, 2196, 14, 8393, 8, 16, 12, 16, 27581, 9, 776 ]
[ 15495, 199, 3, 299, 13655, 63, 290, 328, 63, 396, 14, 647, 199, 14813, 15495, 199, 199, 646, 4613, 199, 646, 2196, 199, 646, 299, 13655, 63, 2991, 199, 199, 504, 1134, 2037, 76, 257, 492, 26612, 12, 542, 400, 12, 29986, 400, 199, 504, 510, 13655, 7467, 492, 510, 13655, 7467, 199, 199, 504, 299, 13655, 63, 3615, 63, 396, 63, 1208, 492, 627, 199, 199, 25812, 199, 3, 3805, 63, 4316, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 4316, 63, 396, 837, 523, 372, 408, 272, 333, 3003, 16, 519, 17, 12, 21945, 2587, 18, 4687, 665, 378, 88, 16, 70, 16, 70, 16, 70, 16, 70, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 376, 328, 519, 19, 12, 519, 17, 12, 378, 88, 383, 556, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 333, 3641, 16, 519, 19, 12, 6499, 18, 10344, 2587, 690, 16, 88, 9084, 70, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 272, 302, 411, 523, 408, 199, 199, 25812, 199, 3, 3805, 63, 2614, 63, 991, 80, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2614, 63, 991, 80, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 959, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 841, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 650, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 3581, 383, 12, 378, 88, 5345, 70, 383, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 499, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 1949, 383, 70, 12, 378, 88, 993, 70, 1493, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 413, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2614, 63, 991, 80, 63, 396, 8, 378, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 2164, 63, 991, 80, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2164, 63, 991, 80, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 959, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 841, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 650, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 3581, 383, 12, 378, 88, 5345, 70, 383, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 499, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 1949, 383, 70, 12, 378, 88, 993, 70, 1493, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 413, 12, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 88, 383, 556, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 2164, 63, 991, 80, 63, 396, 8, 378, 12, 298, 290, 328, 401, 378, 88, 993, 70, 16, 70, 16, 12, 378, 88, 16, 556, 16, 12, 378, 88, 3273, 70, 16, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 2164, 83, 63, 2614, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2164, 83, 63, 2614, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 2164, 63, 4077, 63, 2614, 63, 396, 8, 298, 290, 328, 401, 378, 88, 5345, 70, 16, 70, 12, 378, 3581, 383, 12, 378, 88, 5345, 70, 383, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 585, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 585, 63, 396, 837, 523, 372, 359, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 3581, 383, 556, 383, 12, 378, 88, 16, 70, 16, 70, 12, 378, 88, 5345, 70, 383, 2318, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 88, 16, 556, 383, 556, 16, 12, 378, 1949, 16, 70, 16, 12, 378, 88, 3273, 70, 16, 2318, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 88, 383, 556, 383, 556, 12, 378, 88, 16, 70, 16, 70, 12, 378, 88, 9084, 70, 2318, 272, 3805, 63, 322, 596, 63, 585, 63, 396, 8, 298, 290, 328, 401, 378, 1949, 383, 556, 383, 70, 12, 378, 1949, 16, 70, 16, 12, 378, 88, 993, 70, 1493, 2318, 523, 1622, 199, 199, 25812, 199, 3, 3805, 63, 2355, 63, 396, 199, 25812, 199, 199, 318, 3805, 63, 2355, 63, 396, 837, 523, 21875, 63, 600, 275, 942, 523, 367, 284, 315, 4945, 8, 1960, 304, 272, 2928, 221, 275, 26612, 8, 4337, 12, 2196, 14, 8393, 8, 16, 12, 16, 21870, 9, 776, 272, 25531, 221, 275, 26612, 8, 3193, 12, 2196, 14, 8393, 8, 16, 12, 16, 27581, 9, 776, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
djvoleur/V_925R4_BOF7
tools/perf/scripts/python/event_analyzing_sample.py
4719
7393
# event_analyzing_sample.py: general event handler in python # # Current perf report is already very powerful with the annotation integrated, # and this script is not trying to be as powerful as perf report, but # providing end user/developer a flexible way to analyze the events other # than trace points. # # The 2 database related functions in this script just show how to gather # the basic information, and users can modify and write their own functions # according to their specific requirement. # # The first function "show_general_events" just does a basic grouping for all # generic events with the help of sqlite, and the 2nd one "show_pebs_ll" is # for a x86 HW PMU event: PEBS with load latency data. # import os import sys import math import struct import sqlite3 sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from EventClass import * # # If the perf.data has a big number of samples, then the insert operation # will be very time consuming (about 10+ minutes for 10000 samples) if the # .db database is on disk. Move the .db file to RAM based FS to speedup # the handling, which will cut the time down to several seconds. # con = sqlite3.connect("/dev/shm/perf.db") con.isolation_level = None def trace_begin(): print "In trace_begin:\n" # # Will create several tables at the start, pebs_ll is for PEBS data with # load latency info, while gen_events is for general event. # con.execute(""" create table if not exists gen_events ( name text, symbol text, comm text, dso text );""") con.execute(""" create table if not exists pebs_ll ( name text, symbol text, comm text, dso text, flags integer, ip integer, status integer, dse integer, dla integer, lat integer );""") # # Create and insert event object to a database so that user could # do more analysis with simple database commands. # def process_event(param_dict): event_attr = param_dict["attr"] sample = param_dict["sample"] raw_buf = param_dict["raw_buf"] comm = param_dict["comm"] name = param_dict["ev_name"] # Symbol and dso info are not always resolved if (param_dict.has_key("dso")): dso = param_dict["dso"] else: dso = "Unknown_dso" if (param_dict.has_key("symbol")): symbol = param_dict["symbol"] else: symbol = "Unknown_symbol" # Create the event object and insert it to the right table in database event = create_event(name, comm, dso, symbol, raw_buf) insert_db(event) def insert_db(event): if event.ev_type == EVTYPE_GENERIC: con.execute("insert into gen_events values(?, ?, ?, ?)", (event.name, event.symbol, event.comm, event.dso)) elif event.ev_type == EVTYPE_PEBS_LL: event.ip &= 0x7fffffffffffffff event.dla &= 0x7fffffffffffffff con.execute("insert into pebs_ll values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (event.name, event.symbol, event.comm, event.dso, event.flags, event.ip, event.status, event.dse, event.dla, event.lat)) def trace_end(): print "In trace_end:\n" # We show the basic info for the 2 type of event classes show_general_events() show_pebs_ll() con.close() # # As the event number may be very big, so we can't use linear way # to show the histogram in real number, but use a log2 algorithm. # def num2sym(num): # Each number will have at least one '#' snum = '#' * (int)(math.log(num, 2) + 1) return snum def show_general_events(): # Check the total record number in the table count = con.execute("select count(*) from gen_events") for t in count: print "There is %d records in gen_events table" % t[0] if t[0] == 0: return print "Statistics about the general events grouped by thread/symbol/dso: \n" # Group by thread commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)") print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) for row in commq: print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by symbol print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") for row in symbolq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by dso print "\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74) dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") for row in dsoq: print "%40s %8d %s" % (row[0], row[1], num2sym(row[1])) # # This function just shows the basic info, and we could do more with the # data in the tables, like checking the function parameters when some # big latency events happen. # def show_pebs_ll(): count = con.execute("select count(*) from pebs_ll") for t in count: print "There is %d records in pebs_ll table" % t[0] if t[0] == 0: return print "Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n" # Group by thread commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)") print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) for row in commq: print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by symbol print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)") for row in symbolq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by dse dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)") print "\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58) for row in dseq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by latency latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat") print "\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58) for row in latq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) def trace_unhandled(event_name, context, event_fields_dict): print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
gpl-2.0
[ 3, 1566, 63, 4797, 20135, 63, 3271, 14, 647, 26, 8605, 1566, 3016, 315, 2366, 199, 3, 199, 3, 9338, 8582, 3622, 365, 2575, 7437, 7074, 1893, 543, 314, 11262, 17806, 972, 12, 199, 3, 436, 642, 2884, 365, 440, 9936, 370, 506, 465, 7074, 1893, 465, 8582, 3622, 12, 1325, 199, 3, 13070, 1284, 922, 15, 11071, 282, 26841, 4340, 370, 19897, 314, 4474, 1163, 199, 3, 2419, 3307, 4501, 14, 199, 3, 199, 3, 710, 499, 3050, 4048, 3423, 315, 642, 2884, 2951, 2498, 4212, 370, 13082, 199, 3, 314, 5678, 2556, 12, 436, 4390, 883, 2811, 436, 2218, 3932, 5705, 3423, 199, 3, 7182, 370, 3932, 2488, 10685, 14, 199, 3, 199, 3, 710, 1642, 805, 298, 2384, 63, 10706, 63, 4368, 2, 2951, 1630, 282, 5678, 17786, 367, 1006, 199, 3, 7809, 4474, 543, 314, 1720, 402, 11723, 12, 436, 314, 499, 977, 1373, 298, 2384, 63, 321, 1533, 63, 914, 2, 365, 199, 3, 367, 282, 671, 1184, 869, 55, 27320, 53, 1566, 26, 19599, 11087, 543, 2248, 23967, 666, 14, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 3473, 199, 646, 2702, 199, 646, 11723, 19, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 267, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 6763, 2543, 492, 627, 199, 199, 3, 199, 3, 982, 314, 8582, 14, 576, 965, 282, 7282, 1329, 402, 5845, 12, 2066, 314, 5518, 3439, 199, 3, 911, 506, 7437, 900, 406, 26745, 334, 10254, 1616, 11, 9395, 367, 11630, 5845, 9, 340, 314, 199, 3, 1275, 697, 3050, 365, 641, 4543, 14, 14171, 314, 1275, 697, 570, 370, 30207, 4079, 27500, 370, 8112, 384, 199, 3, 314, 7252, 12, 1314, 911, 10415, 314, 900, 3224, 370, 9978, 4696, 14, 199, 3, 199, 388, 275, 11723, 19, 14, 2242, 4769, 2374, 15, 609, 77, 15, 9452, 14, 697, 531, 199, 388, 14, 20808, 63, 1896, 275, 488, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 607, 3307, 63, 5037, 3427, 78, 2, 398, 327, 267, 327, 12823, 1218, 9978, 6716, 737, 314, 1343, 12, 4837, 1533, 63, 914, 365, 367, 19599, 11087, 666, 543, 267, 327, 2248, 23967, 2256, 12, 1830, 3805, 63, 4368, 365, 367, 8605, 1566, 14, 267, 327, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 3805, 63, 4368, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 355, 20682, 6141, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 4837, 1533, 63, 914, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 12, 717, 3285, 3000, 12, 717, 3384, 3000, 12, 717, 2004, 3000, 12, 717, 366, 261, 3000, 12, 717, 366, 416, 3000, 12, 717, 8396, 3000, 355, 20682, 6141, 199, 199, 3, 199, 3, 2790, 436, 5518, 1566, 909, 370, 282, 3050, 880, 626, 922, 4293, 199, 3, 886, 1655, 11284, 543, 3486, 3050, 3718, 14, 199, 3, 199, 318, 2112, 63, 1430, 8, 635, 63, 807, 304, 267, 1566, 63, 962, 275, 1215, 63, 807, 905, 962, 937, 267, 2690, 258, 275, 1215, 63, 807, 905, 3271, 937, 267, 3066, 63, 1436, 259, 275, 1215, 63, 807, 905, 1773, 63, 1436, 937, 267, 1923, 755, 275, 1215, 63, 807, 905, 1404, 937, 267, 536, 755, 275, 1215, 63, 807, 905, 6857, 63, 354, 937, 398, 327, 10080, 436, 25547, 2256, 787, 440, 3544, 12152, 267, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 32211, 14150, 355, 25547, 275, 1215, 63, 807, 905, 32211, 937, 267, 587, 26, 355, 25547, 275, 298, 5912, 63, 32211, 2, 398, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 5155, 14150, 355, 5272, 275, 1215, 63, 807, 905, 5155, 937, 267, 587, 26, 355, 5272, 275, 298, 5912, 63, 5155, 2, 398, 327, 2790, 314, 1566, 909, 436, 5518, 652, 370, 314, 2451, 1817, 315, 3050, 267, 1566, 275, 1218, 63, 1430, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 5518, 63, 697, 8, 1430, 9, 199, 199, 318, 5518, 63, 697, 8, 1430, 304, 267, 340, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 29395, 26, 355, 406, 14, 2526, 480, 3176, 1901, 3805, 63, 4368, 1338, 2229, 12, 21259, 21259, 5805, 4186, 1816, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 430, 267, 916, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 1510, 11087, 63, 4464, 26, 355, 1566, 14, 711, 18415, 378, 88, 23, 15798, 12596, 70, 355, 1566, 14, 68, 416, 18415, 378, 88, 23, 15798, 12596, 70, 355, 406, 14, 2526, 480, 3176, 1901, 4837, 1533, 63, 914, 1338, 7558, 12, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 5805, 4186, 717, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 12, 1566, 14, 2469, 12, 1816, 1566, 14, 711, 12, 1566, 14, 1205, 12, 1566, 14, 68, 261, 12, 1566, 14, 68, 416, 12, 1566, 14, 4452, 430, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 607, 3307, 63, 500, 3427, 78, 2, 267, 327, 2136, 2498, 314, 5678, 2256, 367, 314, 499, 730, 402, 1566, 3992, 267, 2498, 63, 10706, 63, 4368, 342, 267, 2498, 63, 321, 1533, 63, 914, 342, 267, 406, 14, 1600, 342, 199, 199, 3, 199, 3, 3709, 314, 1566, 1329, 1443, 506, 7437, 7282, 12, 880, 781, 883, 1133, 675, 7798, 4340, 199, 3, 370, 2498, 314, 15379, 315, 3363, 1329, 12, 1325, 675, 282, 943, 18, 5563, 14, 199, 3, 199, 199, 318, 1967, 18, 3840, 8, 1507, 304, 267, 327, 7048, 1329, 911, 1172, 737, 5210, 1373, 19619, 267, 308, 1507, 275, 19619, 627, 334, 442, 5130, 3442, 14, 793, 8, 1507, 12, 499, 9, 435, 413, 9, 267, 372, 308, 1507, 199, 199, 318, 2498, 63, 10706, 63, 4368, 837 ]
[ 1566, 63, 4797, 20135, 63, 3271, 14, 647, 26, 8605, 1566, 3016, 315, 2366, 199, 3, 199, 3, 9338, 8582, 3622, 365, 2575, 7437, 7074, 1893, 543, 314, 11262, 17806, 972, 12, 199, 3, 436, 642, 2884, 365, 440, 9936, 370, 506, 465, 7074, 1893, 465, 8582, 3622, 12, 1325, 199, 3, 13070, 1284, 922, 15, 11071, 282, 26841, 4340, 370, 19897, 314, 4474, 1163, 199, 3, 2419, 3307, 4501, 14, 199, 3, 199, 3, 710, 499, 3050, 4048, 3423, 315, 642, 2884, 2951, 2498, 4212, 370, 13082, 199, 3, 314, 5678, 2556, 12, 436, 4390, 883, 2811, 436, 2218, 3932, 5705, 3423, 199, 3, 7182, 370, 3932, 2488, 10685, 14, 199, 3, 199, 3, 710, 1642, 805, 298, 2384, 63, 10706, 63, 4368, 2, 2951, 1630, 282, 5678, 17786, 367, 1006, 199, 3, 7809, 4474, 543, 314, 1720, 402, 11723, 12, 436, 314, 499, 977, 1373, 298, 2384, 63, 321, 1533, 63, 914, 2, 365, 199, 3, 367, 282, 671, 1184, 869, 55, 27320, 53, 1566, 26, 19599, 11087, 543, 2248, 23967, 666, 14, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 3473, 199, 646, 2702, 199, 646, 11723, 19, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 267, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 6763, 2543, 492, 627, 199, 199, 3, 199, 3, 982, 314, 8582, 14, 576, 965, 282, 7282, 1329, 402, 5845, 12, 2066, 314, 5518, 3439, 199, 3, 911, 506, 7437, 900, 406, 26745, 334, 10254, 1616, 11, 9395, 367, 11630, 5845, 9, 340, 314, 199, 3, 1275, 697, 3050, 365, 641, 4543, 14, 14171, 314, 1275, 697, 570, 370, 30207, 4079, 27500, 370, 8112, 384, 199, 3, 314, 7252, 12, 1314, 911, 10415, 314, 900, 3224, 370, 9978, 4696, 14, 199, 3, 199, 388, 275, 11723, 19, 14, 2242, 4769, 2374, 15, 609, 77, 15, 9452, 14, 697, 531, 199, 388, 14, 20808, 63, 1896, 275, 488, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 607, 3307, 63, 5037, 3427, 78, 2, 398, 327, 267, 327, 12823, 1218, 9978, 6716, 737, 314, 1343, 12, 4837, 1533, 63, 914, 365, 367, 19599, 11087, 666, 543, 267, 327, 2248, 23967, 2256, 12, 1830, 3805, 63, 4368, 365, 367, 8605, 1566, 14, 267, 327, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 3805, 63, 4368, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 355, 20682, 6141, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 4837, 1533, 63, 914, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 12, 717, 3285, 3000, 12, 717, 3384, 3000, 12, 717, 2004, 3000, 12, 717, 366, 261, 3000, 12, 717, 366, 416, 3000, 12, 717, 8396, 3000, 355, 20682, 6141, 199, 199, 3, 199, 3, 2790, 436, 5518, 1566, 909, 370, 282, 3050, 880, 626, 922, 4293, 199, 3, 886, 1655, 11284, 543, 3486, 3050, 3718, 14, 199, 3, 199, 318, 2112, 63, 1430, 8, 635, 63, 807, 304, 267, 1566, 63, 962, 275, 1215, 63, 807, 905, 962, 937, 267, 2690, 258, 275, 1215, 63, 807, 905, 3271, 937, 267, 3066, 63, 1436, 259, 275, 1215, 63, 807, 905, 1773, 63, 1436, 937, 267, 1923, 755, 275, 1215, 63, 807, 905, 1404, 937, 267, 536, 755, 275, 1215, 63, 807, 905, 6857, 63, 354, 937, 398, 327, 10080, 436, 25547, 2256, 787, 440, 3544, 12152, 267, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 32211, 14150, 355, 25547, 275, 1215, 63, 807, 905, 32211, 937, 267, 587, 26, 355, 25547, 275, 298, 5912, 63, 32211, 2, 398, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 5155, 14150, 355, 5272, 275, 1215, 63, 807, 905, 5155, 937, 267, 587, 26, 355, 5272, 275, 298, 5912, 63, 5155, 2, 398, 327, 2790, 314, 1566, 909, 436, 5518, 652, 370, 314, 2451, 1817, 315, 3050, 267, 1566, 275, 1218, 63, 1430, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 5518, 63, 697, 8, 1430, 9, 199, 199, 318, 5518, 63, 697, 8, 1430, 304, 267, 340, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 29395, 26, 355, 406, 14, 2526, 480, 3176, 1901, 3805, 63, 4368, 1338, 2229, 12, 21259, 21259, 5805, 4186, 1816, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 430, 267, 916, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 1510, 11087, 63, 4464, 26, 355, 1566, 14, 711, 18415, 378, 88, 23, 15798, 12596, 70, 355, 1566, 14, 68, 416, 18415, 378, 88, 23, 15798, 12596, 70, 355, 406, 14, 2526, 480, 3176, 1901, 4837, 1533, 63, 914, 1338, 7558, 12, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 5805, 4186, 717, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 12, 1566, 14, 2469, 12, 1816, 1566, 14, 711, 12, 1566, 14, 1205, 12, 1566, 14, 68, 261, 12, 1566, 14, 68, 416, 12, 1566, 14, 4452, 430, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 607, 3307, 63, 500, 3427, 78, 2, 267, 327, 2136, 2498, 314, 5678, 2256, 367, 314, 499, 730, 402, 1566, 3992, 267, 2498, 63, 10706, 63, 4368, 342, 267, 2498, 63, 321, 1533, 63, 914, 342, 267, 406, 14, 1600, 342, 199, 199, 3, 199, 3, 3709, 314, 1566, 1329, 1443, 506, 7437, 7282, 12, 880, 781, 883, 1133, 675, 7798, 4340, 199, 3, 370, 2498, 314, 15379, 315, 3363, 1329, 12, 1325, 675, 282, 943, 18, 5563, 14, 199, 3, 199, 199, 318, 1967, 18, 3840, 8, 1507, 304, 267, 327, 7048, 1329, 911, 1172, 737, 5210, 1373, 19619, 267, 308, 1507, 275, 19619, 627, 334, 442, 5130, 3442, 14, 793, 8, 1507, 12, 499, 9, 435, 413, 9, 267, 372, 308, 1507, 199, 199, 318, 2498, 63, 10706, 63, 4368, 837, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kubermatic/kubernetes
cluster/juju/layers/kubeapi-load-balancer/reactive/load_balancer.py
39
7034
#!/usr/bin/env python # Copyright 2015 The Kubernetes Authors. # # 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 os import socket import subprocess from charms import layer from charms.reactive import when, when_any, when_not from charms.reactive import set_state, remove_state from charmhelpers.core import hookenv from charmhelpers.core import host from charmhelpers.contrib.charmsupport import nrpe from charms.reactive.helpers import data_changed from charms.layer import nginx from charms.layer import tls_client from subprocess import Popen from subprocess import PIPE from subprocess import STDOUT from subprocess import CalledProcessError @when('certificates.available') def request_server_certificates(tls): '''Send the data that is required to create a server certificate for this server.''' # Use the public ip of this unit as the Common Name for the certificate. common_name = hookenv.unit_public_ip() # Create SANs that the tls layer will add to the server cert. sans = [ hookenv.unit_public_ip(), hookenv.unit_private_ip(), socket.gethostname(), ] # maybe they have extra names they want as SANs extra_sans = hookenv.config('extra_sans') if extra_sans and not extra_sans == "": sans.extend(extra_sans.split()) # Create a path safe name by removing path characters from the unit name. certificate_name = hookenv.local_unit().replace('/', '_') # Request a server cert with this information. tls.request_server_cert(common_name, sans, certificate_name) @when('config.changed.extra_sans', 'certificates.available') def update_certificate(tls): # Using the config.changed.extra_sans flag to catch changes. # IP changes will take ~5 minutes or so to propagate, but # it will update. request_server_certificates(tls) @when('certificates.server.cert.available', 'nginx.available', 'tls_client.server.certificate.written') def kick_nginx(tls): # we are just going to sighup it, but still want to avoid kicking it # without need if data_changed('cert', tls.get_server_cert()): # certificate changed, so sighup nginx hookenv.log("Certificate information changed, sending SIGHUP to nginx") host.service_restart('nginx') tls_client.reset_certificate_write_flag('server') @when('config.changed.port') def close_old_port(): config = hookenv.config() old_port = config.previous('port') if not old_port: return try: hookenv.close_port(old_port) except CalledProcessError: hookenv.log('Port %d already closed, skipping.' % old_port) @when('nginx.available', 'apiserver.available', 'certificates.server.cert.available') def install_load_balancer(apiserver, tls): ''' Create the default vhost template for load balancing ''' # Get the tls paths from the layer data. layer_options = layer.options('tls-client') server_cert_path = layer_options.get('server_certificate_path') cert_exists = server_cert_path and os.path.isfile(server_cert_path) server_key_path = layer_options.get('server_key_path') key_exists = server_key_path and os.path.isfile(server_key_path) # Do both the key and certificate exist? if cert_exists and key_exists: # At this point the cert and key exist, and they are owned by root. chown = ['chown', 'www-data:www-data', server_cert_path] # Change the owner to www-data so the nginx process can read the cert. subprocess.call(chown) chown = ['chown', 'www-data:www-data', server_key_path] # Change the owner to www-data so the nginx process can read the key. subprocess.call(chown) port = hookenv.config('port') hookenv.open_port(port) services = apiserver.services() nginx.configure_site( 'apilb', 'apilb.conf', server_name='_', services=services, port=port, server_certificate=server_cert_path, server_key=server_key_path, ) hookenv.status_set('active', 'Loadbalancer ready.') @when('nginx.available') def set_nginx_version(): ''' Surface the currently deployed version of nginx to Juju ''' cmd = 'nginx -v' p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) raw = p.stdout.read() # The version comes back as: # nginx version: nginx/1.10.0 (Ubuntu) version = raw.split(b'/')[-1].split(b' ')[0] hookenv.application_version_set(version.rstrip()) @when('website.available') def provide_application_details(website): ''' re-use the nginx layer website relation to relay the hostname/port to any consuming kubernetes-workers, or other units that require the kubernetes API ''' website.configure(port=hookenv.config('port')) @when('loadbalancer.available') def provide_loadbalancing(loadbalancer): '''Send the public address and port to the public-address interface, so the subordinates can get the public address of this loadbalancer.''' loadbalancer.set_address_port(hookenv.unit_get('public-address'), hookenv.config('port')) @when('nrpe-external-master.available') @when_not('nrpe-external-master.initial-config') def initial_nrpe_config(nagios=None): set_state('nrpe-external-master.initial-config') update_nrpe_config(nagios) @when('nginx.available') @when('nrpe-external-master.available') @when_any('config.changed.nagios_context', 'config.changed.nagios_servicegroups') def update_nrpe_config(unused=None): services = ('nginx',) hostname = nrpe.get_nagios_hostname() current_unit = nrpe.get_nagios_unit_name() nrpe_setup = nrpe.NRPE(hostname=hostname) nrpe.add_init_service_checks(nrpe_setup, services, current_unit) nrpe_setup.write() @when_not('nrpe-external-master.available') @when('nrpe-external-master.initial-config') def remove_nrpe_config(nagios=None): remove_state('nrpe-external-master.initial-config') # List of systemd services for which the checks will be removed services = ('nginx',) # The current nrpe-external-master interface doesn't handle a lot of logic, # use the charm-helpers code for now. hostname = nrpe.get_nagios_hostname() nrpe_setup = nrpe.NRPE(hostname=hostname) for service in services: nrpe_setup.remove_check(shortname=service)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6900, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 199, 504, 1495, 706, 492, 4045, 199, 504, 1495, 706, 14, 264, 2682, 492, 1380, 12, 1380, 63, 1629, 12, 1380, 63, 1397, 199, 504, 1495, 706, 14, 264, 2682, 492, 663, 63, 929, 12, 2813, 63, 929, 199, 504, 1495, 77, 7546, 14, 1018, 492, 21404, 199, 504, 1495, 77, 7546, 14, 1018, 492, 1591, 199, 504, 1495, 77, 7546, 14, 2828, 14, 1560, 706, 384, 719, 492, 14762, 321, 199, 504, 1495, 706, 14, 264, 2682, 14, 7546, 492, 666, 63, 2489, 199, 199, 504, 1495, 706, 14, 1897, 492, 302, 19101, 199, 504, 1495, 706, 14, 1897, 492, 15142, 63, 1258, 199, 199, 504, 3873, 492, 13995, 199, 504, 3873, 492, 22773, 199, 504, 3873, 492, 4384, 12619, 199, 504, 3873, 492, 12295, 19148, 421, 199, 32, 6526, 360, 16159, 14, 4561, 358, 199, 318, 1056, 63, 1000, 63, 16159, 8, 9945, 304, 272, 1449, 6795, 314, 666, 626, 365, 1415, 370, 1218, 282, 1654, 5897, 367, 272, 642, 1654, 10595, 272, 327, 3645, 314, 4575, 3384, 402, 642, 4137, 465, 314, 13964, 2812, 367, 314, 5897, 14, 272, 2863, 63, 354, 275, 21404, 14, 3248, 63, 3455, 63, 711, 342, 272, 327, 2790, 428, 879, 83, 626, 314, 15142, 4045, 911, 1050, 370, 314, 1654, 6250, 14, 272, 308, 796, 275, 359, 267, 21404, 14, 3248, 63, 3455, 63, 711, 1062, 267, 21404, 14, 3248, 63, 4239, 63, 711, 1062, 267, 2838, 14, 29789, 1062, 272, 1622, 272, 327, 11703, 2985, 1172, 2402, 1561, 2985, 2934, 465, 428, 879, 83, 272, 2402, 63, 26052, 275, 21404, 14, 888, 360, 2911, 63, 26052, 358, 272, 340, 2402, 63, 26052, 436, 440, 2402, 63, 26052, 508, 10812, 267, 308, 796, 14, 2880, 8, 2911, 63, 26052, 14, 1294, 1012, 272, 327, 2790, 282, 931, 5048, 536, 701, 12881, 931, 4110, 687, 314, 4137, 536, 14, 272, 5897, 63, 354, 275, 21404, 14, 1832, 63, 3248, 1252, 1814, 10998, 18962, 272, 327, 4784, 282, 1654, 6250, 543, 642, 2556, 14, 272, 15142, 14, 1069, 63, 1000, 63, 4736, 8, 2330, 63, 354, 12, 308, 796, 12, 5897, 63, 354, 9, 421, 199, 32, 6526, 360, 888, 14, 2489, 14, 2911, 63, 26052, 297, 283, 16159, 14, 4561, 358, 199, 318, 1678, 63, 6999, 8, 9945, 304, 272, 327, 11719, 314, 1101, 14, 2489, 14, 2911, 63, 26052, 3305, 370, 8579, 4493, 14, 272, 327, 3531, 4493, 911, 5452, 6146, 21, 9395, 503, 880, 370, 19843, 12, 1325, 272, 327, 652, 911, 1678, 14, 272, 1056, 63, 1000, 63, 16159, 8, 9945, 9, 421, 199, 32, 6526, 360, 16159, 14, 1000, 14, 4736, 14, 4561, 297, 489, 283, 25826, 14, 4561, 297, 283, 9945, 63, 1258, 14, 1000, 14, 6999, 14, 8938, 358, 199, 318, 29898, 63, 25826, 8, 9945, 304, 272, 327, 781, 787, 2951, 9995, 370, 308, 2056, 384, 652, 12, 1325, 5139, 2934, 370, 5126, 29898, 316, 652, 272, 327, 1928, 1929, 272, 340, 666, 63, 2489, 360, 4736, 297, 15142, 14, 362, 63, 1000, 63, 4736, 5109, 267, 327, 5897, 2896, 12, 880, 308, 2056, 384, 302, 19101, 267, 21404, 14, 793, 480, 11414, 2556, 2896, 12, 10209, 428, 13454, 2160, 370, 302, 19101, 531, 267, 1591, 14, 1364, 63, 10506, 360, 25826, 358, 272, 15142, 63, 1258, 14, 3958, 63, 6999, 63, 952, 63, 4173, 360, 1000, 358, 421, 199, 32, 6526, 360, 888, 14, 2489, 14, 719, 358, 199, 318, 4002, 63, 1753, 63, 719, 837, 272, 1101, 275, 21404, 14, 888, 342, 272, 2269, 63, 719, 275, 1101, 14, 6352, 360, 719, 358, 272, 340, 440, 2269, 63, 719, 26, 267, 372, 272, 862, 26, 267, 21404, 14, 1600, 63, 719, 8, 1753, 63, 719, 9, 272, 871, 12295, 19148, 26, 267, 21404, 14, 793, 360, 4313, 450, 68, 2575, 6876, 12, 16068, 3530, 450, 2269, 63, 719, 9, 421, 199, 32, 6526, 360, 25826, 14, 4561, 297, 283, 1246, 1000, 14, 4561, 297, 489, 283, 16159, 14, 1000, 14, 4736, 14, 4561, 358, 199, 318, 3907, 63, 912, 63, 11841, 8, 1246, 1000, 12, 15142, 304, 272, 1449, 2790, 314, 849, 373, 1102, 1978, 367, 2248, 29300, 1449, 272, 327, 2372, 314, 15142, 3792, 687, 314, 4045, 666, 14, 272, 4045, 63, 1419, 275, 4045, 14, 1419, 360, 9945, 13, 1258, 358, 272, 1654, 63, 4736, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 6999, 63, 515, 358, 272, 6250, 63, 2444, 275, 1654, 63, 4736, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 4736, 63, 515, 9, 272, 1654, 63, 498, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 498, 63, 515, 358, 272, 790, 63, 2444, 275, 1654, 63, 498, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 498, 63, 515, 9, 272, 327, 4226, 3865, 314, 790, 436, 5897, 2187, 31, 272, 340, 6250, 63, 2444, 436, 790, 63, 2444, 26, 267, 327, 2854, 642, 2376, 314, 6250, 436, 790, 2187, 12, 436, 2985, 787, 23191, 701, 1738, 14, 267, 286, 1917, 78, 275, 788, 20933, 297, 283, 1544, 13, 576, 26, 1544, 13, 576, 297, 1654, 63, 4736, 63, 515, 61, 398, 327, 7743, 314, 5771, 370, 20732, 13, 576, 880, 314 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6900, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 199, 504, 1495, 706, 492, 4045, 199, 504, 1495, 706, 14, 264, 2682, 492, 1380, 12, 1380, 63, 1629, 12, 1380, 63, 1397, 199, 504, 1495, 706, 14, 264, 2682, 492, 663, 63, 929, 12, 2813, 63, 929, 199, 504, 1495, 77, 7546, 14, 1018, 492, 21404, 199, 504, 1495, 77, 7546, 14, 1018, 492, 1591, 199, 504, 1495, 77, 7546, 14, 2828, 14, 1560, 706, 384, 719, 492, 14762, 321, 199, 504, 1495, 706, 14, 264, 2682, 14, 7546, 492, 666, 63, 2489, 199, 199, 504, 1495, 706, 14, 1897, 492, 302, 19101, 199, 504, 1495, 706, 14, 1897, 492, 15142, 63, 1258, 199, 199, 504, 3873, 492, 13995, 199, 504, 3873, 492, 22773, 199, 504, 3873, 492, 4384, 12619, 199, 504, 3873, 492, 12295, 19148, 421, 199, 32, 6526, 360, 16159, 14, 4561, 358, 199, 318, 1056, 63, 1000, 63, 16159, 8, 9945, 304, 272, 1449, 6795, 314, 666, 626, 365, 1415, 370, 1218, 282, 1654, 5897, 367, 272, 642, 1654, 10595, 272, 327, 3645, 314, 4575, 3384, 402, 642, 4137, 465, 314, 13964, 2812, 367, 314, 5897, 14, 272, 2863, 63, 354, 275, 21404, 14, 3248, 63, 3455, 63, 711, 342, 272, 327, 2790, 428, 879, 83, 626, 314, 15142, 4045, 911, 1050, 370, 314, 1654, 6250, 14, 272, 308, 796, 275, 359, 267, 21404, 14, 3248, 63, 3455, 63, 711, 1062, 267, 21404, 14, 3248, 63, 4239, 63, 711, 1062, 267, 2838, 14, 29789, 1062, 272, 1622, 272, 327, 11703, 2985, 1172, 2402, 1561, 2985, 2934, 465, 428, 879, 83, 272, 2402, 63, 26052, 275, 21404, 14, 888, 360, 2911, 63, 26052, 358, 272, 340, 2402, 63, 26052, 436, 440, 2402, 63, 26052, 508, 10812, 267, 308, 796, 14, 2880, 8, 2911, 63, 26052, 14, 1294, 1012, 272, 327, 2790, 282, 931, 5048, 536, 701, 12881, 931, 4110, 687, 314, 4137, 536, 14, 272, 5897, 63, 354, 275, 21404, 14, 1832, 63, 3248, 1252, 1814, 10998, 18962, 272, 327, 4784, 282, 1654, 6250, 543, 642, 2556, 14, 272, 15142, 14, 1069, 63, 1000, 63, 4736, 8, 2330, 63, 354, 12, 308, 796, 12, 5897, 63, 354, 9, 421, 199, 32, 6526, 360, 888, 14, 2489, 14, 2911, 63, 26052, 297, 283, 16159, 14, 4561, 358, 199, 318, 1678, 63, 6999, 8, 9945, 304, 272, 327, 11719, 314, 1101, 14, 2489, 14, 2911, 63, 26052, 3305, 370, 8579, 4493, 14, 272, 327, 3531, 4493, 911, 5452, 6146, 21, 9395, 503, 880, 370, 19843, 12, 1325, 272, 327, 652, 911, 1678, 14, 272, 1056, 63, 1000, 63, 16159, 8, 9945, 9, 421, 199, 32, 6526, 360, 16159, 14, 1000, 14, 4736, 14, 4561, 297, 489, 283, 25826, 14, 4561, 297, 283, 9945, 63, 1258, 14, 1000, 14, 6999, 14, 8938, 358, 199, 318, 29898, 63, 25826, 8, 9945, 304, 272, 327, 781, 787, 2951, 9995, 370, 308, 2056, 384, 652, 12, 1325, 5139, 2934, 370, 5126, 29898, 316, 652, 272, 327, 1928, 1929, 272, 340, 666, 63, 2489, 360, 4736, 297, 15142, 14, 362, 63, 1000, 63, 4736, 5109, 267, 327, 5897, 2896, 12, 880, 308, 2056, 384, 302, 19101, 267, 21404, 14, 793, 480, 11414, 2556, 2896, 12, 10209, 428, 13454, 2160, 370, 302, 19101, 531, 267, 1591, 14, 1364, 63, 10506, 360, 25826, 358, 272, 15142, 63, 1258, 14, 3958, 63, 6999, 63, 952, 63, 4173, 360, 1000, 358, 421, 199, 32, 6526, 360, 888, 14, 2489, 14, 719, 358, 199, 318, 4002, 63, 1753, 63, 719, 837, 272, 1101, 275, 21404, 14, 888, 342, 272, 2269, 63, 719, 275, 1101, 14, 6352, 360, 719, 358, 272, 340, 440, 2269, 63, 719, 26, 267, 372, 272, 862, 26, 267, 21404, 14, 1600, 63, 719, 8, 1753, 63, 719, 9, 272, 871, 12295, 19148, 26, 267, 21404, 14, 793, 360, 4313, 450, 68, 2575, 6876, 12, 16068, 3530, 450, 2269, 63, 719, 9, 421, 199, 32, 6526, 360, 25826, 14, 4561, 297, 283, 1246, 1000, 14, 4561, 297, 489, 283, 16159, 14, 1000, 14, 4736, 14, 4561, 358, 199, 318, 3907, 63, 912, 63, 11841, 8, 1246, 1000, 12, 15142, 304, 272, 1449, 2790, 314, 849, 373, 1102, 1978, 367, 2248, 29300, 1449, 272, 327, 2372, 314, 15142, 3792, 687, 314, 4045, 666, 14, 272, 4045, 63, 1419, 275, 4045, 14, 1419, 360, 9945, 13, 1258, 358, 272, 1654, 63, 4736, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 6999, 63, 515, 358, 272, 6250, 63, 2444, 275, 1654, 63, 4736, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 4736, 63, 515, 9, 272, 1654, 63, 498, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 498, 63, 515, 358, 272, 790, 63, 2444, 275, 1654, 63, 498, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 498, 63, 515, 9, 272, 327, 4226, 3865, 314, 790, 436, 5897, 2187, 31, 272, 340, 6250, 63, 2444, 436, 790, 63, 2444, 26, 267, 327, 2854, 642, 2376, 314, 6250, 436, 790, 2187, 12, 436, 2985, 787, 23191, 701, 1738, 14, 267, 286, 1917, 78, 275, 788, 20933, 297, 283, 1544, 13, 576, 26, 1544, 13, 576, 297, 1654, 63, 4736, 63, 515, 61, 398, 327, 7743, 314, 5771, 370, 20732, 13, 576, 880, 314, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nhuntwalker/astroML
setup.py
3
2016
from distutils.core import setup DESCRIPTION = "tools for machine learning and data mining in Astronomy" LONG_DESCRIPTION = open('README.rst').read() NAME = "astroML" AUTHOR = "Jake VanderPlas" AUTHOR_EMAIL = "vanderplas@astro.washington.edu" MAINTAINER = "Jake VanderPlas" MAINTAINER_EMAIL = "vanderplas@astro.washington.edu" URL = 'http://astroML.github.com' DOWNLOAD_URL = 'http://github.com/astroML/astroML' LICENSE = 'BSD' import astroML VERSION = astroML.__version__ setup(name=NAME, version=VERSION, description=DESCRIPTION, long_description=LONG_DESCRIPTION, author=AUTHOR, author_email=AUTHOR_EMAIL, maintainer=MAINTAINER, maintainer_email=MAINTAINER_EMAIL, url=URL, download_url=DOWNLOAD_URL, license=LICENSE, packages=['astroML', 'astroML.tests', 'astroML.clustering', 'astroML.clustering.tests', 'astroML.classification', 'astroML.linear_model', 'astroML.datasets', 'astroML.datasets.tools', 'astroML.density_estimation', 'astroML.density_estimation.tests', 'astroML.time_series', 'astroML.time_series.tests', 'astroML.dimensionality', 'astroML.dimensionality.tests', 'astroML.plotting', 'astroML.plotting.tests', 'astroML.stats', 'astroML.stats.tests', ], classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: BSD License', 'Natural Language :: English', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Topic :: Scientific/Engineering :: Astronomy'], )
bsd-2-clause
[ 504, 7065, 14, 1018, 492, 3272, 199, 199, 17705, 275, 298, 2537, 367, 6844, 9328, 436, 666, 1748, 316, 315, 437, 495, 17293, 2, 199, 12375, 63, 17705, 275, 1551, 360, 18195, 14, 8332, 1959, 739, 342, 199, 2339, 275, 298, 1810, 293, 1698, 2, 199, 27938, 275, 298, 42, 1728, 812, 11438, 3714, 305, 2, 199, 27938, 63, 10089, 275, 298, 86, 11438, 1168, 305, 32, 1810, 293, 14, 87, 1119, 31673, 14, 8654, 2, 199, 2054, 2919, 9021, 540, 275, 298, 42, 1728, 812, 11438, 3714, 305, 2, 199, 2054, 2919, 9021, 540, 63, 10089, 275, 298, 86, 11438, 1168, 305, 32, 1810, 293, 14, 87, 1119, 31673, 14, 8654, 2, 199, 2632, 275, 283, 1014, 921, 1810, 293, 1698, 14, 5031, 14, 957, 7, 199, 24930, 63, 2632, 275, 283, 1014, 921, 5031, 14, 957, 15, 1810, 293, 1698, 15, 1810, 293, 1698, 7, 199, 3961, 275, 283, 15400, 7, 199, 199, 646, 6073, 293, 1698, 199, 4612, 275, 6073, 293, 1698, 855, 1023, 363, 199, 199, 2758, 8, 354, 29, 2339, 12, 489, 1015, 29, 4612, 12, 489, 1369, 29, 17705, 12, 489, 1846, 63, 1802, 29, 12375, 63, 17705, 12, 489, 4132, 29, 27938, 12, 489, 4132, 63, 2123, 29, 27938, 63, 10089, 12, 489, 11075, 281, 29, 2054, 2919, 9021, 540, 12, 489, 11075, 281, 63, 2123, 29, 2054, 2919, 9021, 540, 63, 10089, 12, 489, 1166, 29, 2632, 12, 489, 5235, 63, 633, 29, 24930, 63, 2632, 12, 489, 4190, 29, 3961, 12, 489, 6117, 2968, 1810, 293, 1698, 297, 355, 283, 1810, 293, 1698, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 25802, 297, 355, 283, 1810, 293, 1698, 14, 25802, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 14368, 297, 355, 283, 1810, 293, 1698, 14, 6676, 63, 1238, 297, 355, 283, 1810, 293, 1698, 14, 12281, 297, 355, 283, 1810, 293, 1698, 14, 12281, 14, 2537, 297, 355, 283, 1810, 293, 1698, 14, 15669, 63, 597, 8182, 297, 355, 283, 1810, 293, 1698, 14, 15669, 63, 597, 8182, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 521, 63, 5602, 297, 355, 283, 1810, 293, 1698, 14, 521, 63, 5602, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 7430, 6712, 297, 355, 283, 1810, 293, 1698, 14, 7430, 6712, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 2798, 1337, 297, 355, 283, 1810, 293, 1698, 14, 2798, 1337, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 3200, 297, 355, 283, 1810, 293, 1698, 14, 3200, 14, 2219, 297, 288, 2156, 489, 19137, 1524, 267, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 267, 283, 8263, 3800, 19809, 297, 267, 283, 23910, 23975, 3800, 27491, 15, 497, 1733, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 267, 283, 23604, 4889, 8466, 3800, 20144, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 437, 495, 17293, 995, 1362, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7065, 14, 1018, 492, 3272, 199, 199, 17705, 275, 298, 2537, 367, 6844, 9328, 436, 666, 1748, 316, 315, 437, 495, 17293, 2, 199, 12375, 63, 17705, 275, 1551, 360, 18195, 14, 8332, 1959, 739, 342, 199, 2339, 275, 298, 1810, 293, 1698, 2, 199, 27938, 275, 298, 42, 1728, 812, 11438, 3714, 305, 2, 199, 27938, 63, 10089, 275, 298, 86, 11438, 1168, 305, 32, 1810, 293, 14, 87, 1119, 31673, 14, 8654, 2, 199, 2054, 2919, 9021, 540, 275, 298, 42, 1728, 812, 11438, 3714, 305, 2, 199, 2054, 2919, 9021, 540, 63, 10089, 275, 298, 86, 11438, 1168, 305, 32, 1810, 293, 14, 87, 1119, 31673, 14, 8654, 2, 199, 2632, 275, 283, 1014, 921, 1810, 293, 1698, 14, 5031, 14, 957, 7, 199, 24930, 63, 2632, 275, 283, 1014, 921, 5031, 14, 957, 15, 1810, 293, 1698, 15, 1810, 293, 1698, 7, 199, 3961, 275, 283, 15400, 7, 199, 199, 646, 6073, 293, 1698, 199, 4612, 275, 6073, 293, 1698, 855, 1023, 363, 199, 199, 2758, 8, 354, 29, 2339, 12, 489, 1015, 29, 4612, 12, 489, 1369, 29, 17705, 12, 489, 1846, 63, 1802, 29, 12375, 63, 17705, 12, 489, 4132, 29, 27938, 12, 489, 4132, 63, 2123, 29, 27938, 63, 10089, 12, 489, 11075, 281, 29, 2054, 2919, 9021, 540, 12, 489, 11075, 281, 63, 2123, 29, 2054, 2919, 9021, 540, 63, 10089, 12, 489, 1166, 29, 2632, 12, 489, 5235, 63, 633, 29, 24930, 63, 2632, 12, 489, 4190, 29, 3961, 12, 489, 6117, 2968, 1810, 293, 1698, 297, 355, 283, 1810, 293, 1698, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 25802, 297, 355, 283, 1810, 293, 1698, 14, 25802, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 14368, 297, 355, 283, 1810, 293, 1698, 14, 6676, 63, 1238, 297, 355, 283, 1810, 293, 1698, 14, 12281, 297, 355, 283, 1810, 293, 1698, 14, 12281, 14, 2537, 297, 355, 283, 1810, 293, 1698, 14, 15669, 63, 597, 8182, 297, 355, 283, 1810, 293, 1698, 14, 15669, 63, 597, 8182, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 521, 63, 5602, 297, 355, 283, 1810, 293, 1698, 14, 521, 63, 5602, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 7430, 6712, 297, 355, 283, 1810, 293, 1698, 14, 7430, 6712, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 2798, 1337, 297, 355, 283, 1810, 293, 1698, 14, 2798, 1337, 14, 2219, 297, 355, 283, 1810, 293, 1698, 14, 3200, 297, 355, 283, 1810, 293, 1698, 14, 3200, 14, 2219, 297, 288, 2156, 489, 19137, 1524, 267, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 267, 283, 8263, 3800, 19809, 297, 267, 283, 23910, 23975, 3800, 27491, 15, 497, 1733, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 267, 283, 23604, 4889, 8466, 3800, 20144, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 437, 495, 17293, 995, 1362, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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an@gmail.com> # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import copy import os import os.path import re import tempfile from ansible import constants as C from ansible.errors import AnsibleFileNotFound, AnsibleParserError from ansible.module_utils.basic import is_executable from ansible.module_utils.six import binary_type, text_type from ansible.module_utils._text import to_bytes, to_native, to_text from ansible.parsing.quoting import unquote from ansible.parsing.utils.yaml import from_yaml from ansible.parsing.vault import VaultLib, b_HEADER, is_encrypted, is_encrypted_file, parse_vaulttext_envelope from ansible.utils.path import unfrackpath try: from __main__ import display except ImportError: from ansible.utils.display import Display display = Display() # Tries to determine if a path is inside a role, last dir must be 'tasks' # this is not perfect but people should really avoid 'tasks' dirs outside roles when using Ansible. RE_TASKS = re.compile(u'(?:^|%s)+tasks%s?$' % (os.path.sep, os.path.sep)) class DataLoader: ''' The DataLoader class is used to load and parse YAML or JSON content, either from a given file name or from a string that was previously read in through other means. A Vault password can be specified, and any vault-encrypted files will be decrypted. Data read from files will also be cached, so the file will never be read from disk more than once. Usage: dl = DataLoader() # optionally: dl.set_vault_password('foo') ds = dl.load('...') ds = dl.load_from_file('/path/to/file') ''' def __init__(self): self._basedir = '.' self._FILE_CACHE = dict() self._tempfiles = set() # initialize the vault stuff with an empty password # TODO: replace with a ref to something that can get the password # a creds/auth provider # self.set_vault_password(None) self._vaults = {} self._vault = VaultLib() self.set_vault_secrets(None) # TODO: since we can query vault_secrets late, we could provide this to DataLoader init def set_vault_secrets(self, vault_secrets): self._vault.secrets = vault_secrets def load(self, data, file_name='<string>', show_content=True): '''Backwards compat for now''' return from_yaml(data, file_name, show_content, self._vault.secrets) def load_from_file(self, file_name, cache=True, unsafe=False): ''' Loads data from a file, which can contain either JSON or YAML. ''' file_name = self.path_dwim(file_name) display.debug("Loading data from %s" % file_name) # if the file has already been read in and cached, we'll # return those results to avoid more file/vault operations if cache and file_name in self._FILE_CACHE: parsed_data = self._FILE_CACHE[file_name] else: # read the file contents and load the data structure from them (b_file_data, show_content) = self._get_file_contents(file_name) file_data = to_text(b_file_data, errors='surrogate_or_strict') parsed_data = self.load(data=file_data, file_name=file_name, show_content=show_content) # cache the file contents for next time self._FILE_CACHE[file_name] = parsed_data if unsafe: return parsed_data else: # return a deep copy here, so the cache is not affected return copy.deepcopy(parsed_data) def path_exists(self, path): path = self.path_dwim(path) return os.path.exists(to_bytes(path, errors='surrogate_or_strict')) def is_file(self, path): path = self.path_dwim(path) return os.path.isfile(to_bytes(path, errors='surrogate_or_strict')) or path == os.devnull def is_directory(self, path): path = self.path_dwim(path) return os.path.isdir(to_bytes(path, errors='surrogate_or_strict')) def list_directory(self, path): path = self.path_dwim(path) return os.listdir(path) def is_executable(self, path): '''is the given path executable?''' path = self.path_dwim(path) return is_executable(path) def _decrypt_if_vault_data(self, b_vault_data, b_file_name=None): '''Decrypt b_vault_data if encrypted and return b_data and the show_content flag''' if not is_encrypted(b_vault_data): show_content = True return b_vault_data, show_content b_ciphertext, b_version, cipher_name, vault_id = parse_vaulttext_envelope(b_vault_data) b_data = self._vault.decrypt(b_vault_data, filename=b_file_name) show_content = False return b_data, show_content def _get_file_contents(self, file_name): ''' Reads the file contents from the given file name If the contents are vault-encrypted, it will decrypt them and return the decrypted data :arg file_name: The name of the file to read. If this is a relative path, it will be expanded relative to the basedir :raises AnsibleFileNotFOund: if the file_name does not refer to a file :raises AnsibleParserError: if we were unable to read the file :return: Returns a byte string of the file contents ''' if not file_name or not isinstance(file_name, (binary_type, text_type)): raise AnsibleParserError("Invalid filename: '%s'" % str(file_name)) b_file_name = to_bytes(self.path_dwim(file_name)) # This is what we really want but have to fix unittests to make it pass # if not os.path.exists(b_file_name) or not os.path.isfile(b_file_name): if not self.path_exists(b_file_name) or not self.is_file(b_file_name): raise AnsibleFileNotFound("Unable to retrieve file contents", file_name=file_name) try: with open(b_file_name, 'rb') as f: data = f.read() return self._decrypt_if_vault_data(data, b_file_name) except (IOError, OSError) as e: raise AnsibleParserError("an error occurred while trying to read the file '%s': %s" % (file_name, str(e)), orig_exc=e) def get_basedir(self): ''' returns the current basedir ''' return self._basedir def set_basedir(self, basedir): ''' sets the base directory, used to find files when a relative path is given ''' if basedir is not None: self._basedir = to_text(basedir) def path_dwim(self, given): ''' make relative paths work like folks expect. ''' given = unquote(given) given = to_text(given, errors='surrogate_or_strict') if given.startswith(to_text(os.path.sep)) or given.startswith(u'~'): path = given else: basedir = to_text(self._basedir, errors='surrogate_or_strict') path = os.path.join(basedir, given) return unfrackpath(path, follow=False) def _is_role(self, path): ''' imperfect role detection, roles are still valid w/o tasks|meta/main.yml|yaml|etc ''' b_path = to_bytes(path, errors='surrogate_or_strict') b_upath = to_bytes(unfrackpath(path, follow=False), errors='surrogate_or_strict') for b_finddir in (b'meta', b'tasks'): for b_suffix in (b'.yml', b'.yaml', b''): b_main = b'main%s' % (b_suffix) b_tasked = os.path.join(b_finddir, b_main) if ( RE_TASKS.search(path) and os.path.exists(os.path.join(b_path, b_main)) or os.path.exists(os.path.join(b_upath, b_tasked)) or os.path.exists(os.path.join(os.path.dirname(b_path), b_tasked)) ): return True return False def path_dwim_relative(self, path, dirname, source, is_role=False): ''' find one file in either a role or playbook dir with or without explicitly named dirname subdirs Used in action plugins and lookups to find supplemental files that could be in either place. ''' search = [] source = to_text(source, errors='surrogate_or_strict') # I have full path, nothing else needs to be looked at if source.startswith(to_text(os.path.sep)) or source.startswith(u'~'): search.append(unfrackpath(source, follow=False)) else: # base role/play path + templates/files/vars + relative filename search.append(os.path.join(path, dirname, source)) basedir = unfrackpath(path, follow=False) # not told if role, but detect if it is a role and if so make sure you get correct base path if not is_role: is_role = self._is_role(path) if is_role and RE_TASKS.search(path): basedir = unfrackpath(os.path.dirname(path), follow=False) cur_basedir = self._basedir self.set_basedir(basedir) # resolved base role/play path + templates/files/vars + relative filename search.append(unfrackpath(os.path.join(basedir, dirname, source), follow=False)) self.set_basedir(cur_basedir) if is_role and not source.endswith(dirname): # look in role's tasks dir w/o dirname search.append(unfrackpath(os.path.join(basedir, 'tasks', source), follow=False)) # try to create absolute path for loader basedir + templates/files/vars + filename search.append(unfrackpath(os.path.join(dirname, source), follow=False)) # try to create absolute path for loader basedir search.append(unfrackpath(os.path.join(basedir, source), follow=False)) # try to create absolute path for dirname + filename search.append(self.path_dwim(os.path.join(dirname, source))) # try to create absolute path for filename search.append(self.path_dwim(source)) for candidate in search: if os.path.exists(to_bytes(candidate, errors='surrogate_or_strict')): break return candidate def path_dwim_relative_stack(self, paths, dirname, source, is_role=False): ''' find one file in first path in stack taking roles into account and adding play basedir as fallback :arg paths: A list of text strings which are the paths to look for the filename in. :arg dirname: A text string representing a directory. The directory is prepended to the source to form the path to search for. :arg source: A text string which is the filename to search for :rtype: A text string :returns: An absolute path to the filename ``source`` if found :raises: An AnsibleFileNotFound Exception if the file is found to exist in the search paths ''' b_dirname = to_bytes(dirname) b_source = to_bytes(source) result = None search = [] if source is None: display.warning('Invalid request to find a file that matches a "null" value') elif source and (source.startswith('~') or source.startswith(os.path.sep)): # path is absolute, no relative needed, check existence and return source test_path = unfrackpath(b_source, follow=False) if os.path.exists(to_bytes(test_path, errors='surrogate_or_strict')): result = test_path else: display.debug(u'evaluation_path:\n\t%s' % '\n\t'.join(paths)) for path in paths: upath = unfrackpath(path, follow=False) b_upath = to_bytes(upath, errors='surrogate_or_strict') b_mydir = os.path.dirname(b_upath) # if path is in role and 'tasks' not there already, add it into the search if (is_role or self._is_role(path)) and b_mydir.endswith(b'tasks'): search.append(os.path.join(os.path.dirname(b_mydir), b_dirname, b_source)) search.append(os.path.join(b_mydir, b_source)) else: # don't add dirname if user already is using it in source if b_source.split(b'/')[0] != dirname: search.append(os.path.join(b_upath, b_dirname, b_source)) search.append(os.path.join(b_upath, b_source)) # always append basedir as last resort # don't add dirname if user already is using it in source if b_source.split(b'/')[0] != dirname: search.append(os.path.join(to_bytes(self.get_basedir()), b_dirname, b_source)) search.append(os.path.join(to_bytes(self.get_basedir()), b_source)) display.debug(u'search_path:\n\t%s' % to_text(b'\n\t'.join(search))) for b_candidate in search: display.vvvvv(u'looking for "%s" at "%s"' % (source, to_text(b_candidate))) if os.path.exists(b_candidate): result = to_text(b_candidate) break if result is None: raise AnsibleFileNotFound(file_name=source, paths=[to_text(p) for p in search]) return result def _create_content_tempfile(self, content): ''' Create a tempfile containing defined content ''' fd, content_tempfile = tempfile.mkstemp() f = os.fdopen(fd, 'wb') content = to_bytes(content) try: f.write(content) except Exception as err: os.remove(content_tempfile) raise Exception(err) finally: f.close() return content_tempfile def get_real_file(self, file_path, decrypt=True): """ If the file is vault encrypted return a path to a temporary decrypted file If the file is not encrypted then the path is returned Temporary files are cleanup in the destructor """ if not file_path or not isinstance(file_path, (binary_type, text_type)): raise AnsibleParserError("Invalid filename: '%s'" % to_native(file_path)) b_file_path = to_bytes(file_path, errors='surrogate_or_strict') if not self.path_exists(b_file_path) or not self.is_file(b_file_path): raise AnsibleFileNotFound(file_name=file_path) real_path = self.path_dwim(file_path) try: if decrypt: with open(to_bytes(real_path), 'rb') as f: # Limit how much of the file is read since we do not know # whether this is a vault file and therefore it could be very # large. if is_encrypted_file(f, count=len(b_HEADER)): # if the file is encrypted and no password was specified, # the decrypt call would throw an error, but we check first # since the decrypt function doesn't know the file name data = f.read() if not self._vault.secrets: raise AnsibleParserError("A vault password or secret must be specified to decrypt %s" % to_native(file_path)) data = self._vault.decrypt(data, filename=real_path) # Make a temp file real_path = self._create_content_tempfile(data) self._tempfiles.add(real_path) return real_path except (IOError, OSError) as e: raise AnsibleParserError("an error occurred while trying to read the file '%s': %s" % (to_native(real_path), to_native(e)), orig_exc=e) def cleanup_tmp_file(self, file_path): """ Removes any temporary files created from a previous call to get_real_file. file_path must be the path returned from a previous call to get_real_file. """ if file_path in self._tempfiles: os.unlink(file_path) self._tempfiles.remove(file_path) def cleanup_all_tmp_files(self): for f in self._tempfiles: try: self.cleanup_tmp_file(f) except Exception as e: display.warning("Unable to cleanup temp files: %s" % to_native(e)) def find_vars_files(self, path, name, extensions=None, allow_dir=True): """ Find vars files in a given path with specified name. This will find files in a dir named <name>/ or a file called <name> ending in known extensions. """ b_path = to_bytes(os.path.join(path, name)) found = [] if extensions is None: # Look for file with no extension first to find dir before file extensions = [''] + C.YAML_FILENAME_EXTENSIONS # add valid extensions to name for ext in extensions: if '.' in ext: full_path = b_path + to_bytes(ext) elif ext: full_path = b'.'.join([b_path, to_bytes(ext)]) else: full_path = b_path if self.path_exists(full_path): if self.is_directory(full_path): if allow_dir: found.extend(self._get_dir_vars_files(to_text(full_path), extensions)) else: next else: found.append(full_path) break return found def _get_dir_vars_files(self, path, extensions): found = [] for spath in sorted(self.list_directory(path)): if not spath.startswith(u'.') and not spath.endswith(u'~'): # skip hidden and backups ext = os.path.splitext(spath)[-1] full_spath = os.path.join(path, spath) if self.is_directory(full_spath) and not ext: # recursive search if dir found.extend(self._get_dir_vars_files(full_spath, extensions)) elif self.is_file(full_spath) and (not ext or to_text(ext) in extensions): # only consider files with valid extensions or no extension found.append(full_spath) return found
gpl-3.0
[ 3, 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 1331, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 5549, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2550, 492, 2622, 1173, 4667, 12, 31775, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 365, 63, 5904, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 3366, 63, 466, 12, 1318, 63, 466, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 6106, 12, 370, 63, 505, 199, 504, 3242, 14, 11059, 14, 25272, 492, 14342, 199, 504, 3242, 14, 11059, 14, 1208, 14, 5963, 492, 687, 63, 5963, 199, 504, 3242, 14, 11059, 14, 10077, 492, 812, 558, 4728, 12, 330, 63, 7311, 12, 365, 63, 15078, 12, 365, 63, 15078, 63, 493, 12, 2198, 63, 10077, 505, 63, 19707, 199, 504, 3242, 14, 1208, 14, 515, 492, 625, 70, 8085, 515, 199, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 3, 377, 1996, 370, 6705, 340, 282, 931, 365, 6272, 282, 4719, 12, 2061, 2935, 1471, 506, 283, 5054, 7, 199, 3, 642, 365, 440, 23668, 1325, 13135, 1077, 7710, 5126, 283, 5054, 7, 7606, 9682, 11689, 1380, 1808, 2622, 14, 199, 907, 63, 17179, 51, 275, 295, 14, 2014, 8, 85, 20459, 62, 15287, 83, 6393, 5054, 5, 83, 31, 12913, 450, 334, 736, 14, 515, 14, 4127, 12, 747, 14, 515, 14, 4127, 430, 421, 199, 533, 3918, 5455, 26, 339, 1449, 272, 710, 3918, 5455, 1021, 365, 1202, 370, 2248, 436, 2198, 18916, 503, 4840, 1564, 12, 272, 1902, 687, 282, 1627, 570, 536, 503, 687, 282, 1059, 626, 1990, 10889, 272, 1586, 315, 4012, 1163, 4910, 14, 437, 812, 558, 2505, 883, 506, 2013, 12, 436, 272, 1263, 12738, 13, 15078, 1584, 911, 506, 477, 8274, 14, 339, 3918, 1586, 687, 1584, 911, 2597, 506, 6328, 12, 880, 314, 570, 911, 7078, 506, 272, 1586, 687, 4543, 1655, 2419, 5403, 14, 339, 11028, 26, 398, 15396, 275, 3918, 5455, 342, 267, 327, 14190, 26, 15396, 14, 409, 63, 10077, 63, 2060, 360, 1421, 358, 267, 6364, 275, 15396, 14, 912, 360, 15103, 267, 6364, 275, 15396, 14, 912, 63, 504, 63, 493, 2336, 515, 15, 475, 15, 493, 358, 272, 1449, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 12484, 275, 7815, 267, 291, 423, 3817, 63, 8677, 275, 1211, 342, 267, 291, 423, 808, 1725, 275, 663, 342, 398, 327, 8265, 314, 12738, 8292, 543, 376, 2701, 2505, 267, 327, 3254, 26, 3350, 543, 282, 2984, 370, 6020, 626, 883, 664, 314, 2505, 267, 327, 755, 282, 20023, 15, 1178, 5022, 267, 327, 291, 14, 409, 63, 10077, 63, 2060, 8, 403, 9, 267, 291, 423, 10077, 83, 275, 1052, 267, 291, 423, 10077, 275, 812, 558, 4728, 342, 267, 291, 14, 409, 63, 10077, 63, 16153, 8, 403, 9, 339, 327, 3254, 26, 3967, 781, 883, 1827, 12738, 63, 16153, 2465, 12, 781, 4293, 5647, 642, 370, 3918, 5455, 4205, 272, 347, 663, 63, 10077, 63, 16153, 8, 277, 12, 12738, 63, 16153, 304, 267, 291, 423, 10077, 14, 16153, 275, 12738, 63, 16153, 339, 347, 2248, 8, 277, 12, 666, 12, 570, 63, 354, 15829, 875, 4206, 2498, 63, 1317, 29, 549, 304, 267, 1449, 4540, 4751, 8434, 367, 3063, 2344, 267, 372, 687, 63, 5963, 8, 576, 12, 570, 63, 354, 12, 2498, 63, 1317, 12, 291, 423, 10077, 14, 16153, 9, 339, 347, 2248, 63, 504, 63, 493, 8, 277, 12, 570, 63, 354, 12, 2581, 29, 549, 12, 19293, 29, 797, 304, 267, 1449, 30367, 666, 687, 282, 570, 12, 1314, 883, 1395, 1902, 4840, 503, 18916, 14, 221, 1449, 398, 570, 63, 354, 275, 291, 14, 515, 63, 10772, 1017, 8, 493, 63, 354, 9, 267, 2929, 14, 1757, 480, 19236, 666, 687, 450, 83, 2, 450, 570, 63, 354, 9, 398, 327, 340, 314, 570, 965, 2575, 2757, 1586, 315, 436, 6328, 12, 781, 7171, 267, 327, 372, 5204, 2058, 370, 5126, 1655, 570, 15, 10077, 5331, 267, 340, 2581, 436, 570, 63, 354, 315, 291, 423, 3817, 63, 8677, 26, 288, 4565, 63, 576, 275, 291, 423, 3817, 63, 8677, 59, 493, 63, 354, 61, 267, 587, 26, 288, 327, 1586, 314, 570, 4072, 436, 2248, 314, 666, 5523, 687, 3062, 288, 334, 66, 63, 493, 63, 576, 12, 2498, 63, 1317, 9, 275, 291, 423, 362, 63, 493, 63, 4407, 8, 493, 63, 354, 9, 953, 570, 63, 576, 275, 370, 63, 505, 8, 66, 63, 493, 63, 576, 12, 2552, 534, 16380, 63, 269, 63, 4768, 358, 288, 4565, 63, 576, 275, 291, 14, 912, 8, 576, 29, 493, 63, 576, 12, 570, 63, 354, 29, 493, 63, 354, 12, 2498, 63, 1317, 29, 2384, 63, 1317, 9, 953, 327, 2581, 314, 570, 4072, 367, 2163, 900, 288, 291, 423, 3817, 63, 8677, 59, 493, 63, 354, 61, 275, 4565, 63, 576, 398, 340, 19293, 26, 288, 372, 4565, 63, 576, 267, 587, 26, 288, 327, 372, 282, 13217, 1331, 2348, 12, 880, 314, 2581, 365, 440, 16955, 288, 372, 1331, 14, 8293, 8, 6751, 63, 576, 9, 339, 347, 931, 63, 2444, 8, 277, 12, 931, 304, 267, 931, 275, 291, 14, 515, 63, 10772, 1017, 8, 515, 9, 267, 372, 747, 14, 515, 14, 2444, 8, 475, 63, 2394, 8, 515, 12, 2552, 534, 16380, 63, 269, 63, 4768, 1333, 339, 347, 365, 63 ]
[ 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 1331, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 5549, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2550, 492, 2622, 1173, 4667, 12, 31775, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 365, 63, 5904, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 3366, 63, 466, 12, 1318, 63, 466, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 6106, 12, 370, 63, 505, 199, 504, 3242, 14, 11059, 14, 25272, 492, 14342, 199, 504, 3242, 14, 11059, 14, 1208, 14, 5963, 492, 687, 63, 5963, 199, 504, 3242, 14, 11059, 14, 10077, 492, 812, 558, 4728, 12, 330, 63, 7311, 12, 365, 63, 15078, 12, 365, 63, 15078, 63, 493, 12, 2198, 63, 10077, 505, 63, 19707, 199, 504, 3242, 14, 1208, 14, 515, 492, 625, 70, 8085, 515, 199, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 3, 377, 1996, 370, 6705, 340, 282, 931, 365, 6272, 282, 4719, 12, 2061, 2935, 1471, 506, 283, 5054, 7, 199, 3, 642, 365, 440, 23668, 1325, 13135, 1077, 7710, 5126, 283, 5054, 7, 7606, 9682, 11689, 1380, 1808, 2622, 14, 199, 907, 63, 17179, 51, 275, 295, 14, 2014, 8, 85, 20459, 62, 15287, 83, 6393, 5054, 5, 83, 31, 12913, 450, 334, 736, 14, 515, 14, 4127, 12, 747, 14, 515, 14, 4127, 430, 421, 199, 533, 3918, 5455, 26, 339, 1449, 272, 710, 3918, 5455, 1021, 365, 1202, 370, 2248, 436, 2198, 18916, 503, 4840, 1564, 12, 272, 1902, 687, 282, 1627, 570, 536, 503, 687, 282, 1059, 626, 1990, 10889, 272, 1586, 315, 4012, 1163, 4910, 14, 437, 812, 558, 2505, 883, 506, 2013, 12, 436, 272, 1263, 12738, 13, 15078, 1584, 911, 506, 477, 8274, 14, 339, 3918, 1586, 687, 1584, 911, 2597, 506, 6328, 12, 880, 314, 570, 911, 7078, 506, 272, 1586, 687, 4543, 1655, 2419, 5403, 14, 339, 11028, 26, 398, 15396, 275, 3918, 5455, 342, 267, 327, 14190, 26, 15396, 14, 409, 63, 10077, 63, 2060, 360, 1421, 358, 267, 6364, 275, 15396, 14, 912, 360, 15103, 267, 6364, 275, 15396, 14, 912, 63, 504, 63, 493, 2336, 515, 15, 475, 15, 493, 358, 272, 1449, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 12484, 275, 7815, 267, 291, 423, 3817, 63, 8677, 275, 1211, 342, 267, 291, 423, 808, 1725, 275, 663, 342, 398, 327, 8265, 314, 12738, 8292, 543, 376, 2701, 2505, 267, 327, 3254, 26, 3350, 543, 282, 2984, 370, 6020, 626, 883, 664, 314, 2505, 267, 327, 755, 282, 20023, 15, 1178, 5022, 267, 327, 291, 14, 409, 63, 10077, 63, 2060, 8, 403, 9, 267, 291, 423, 10077, 83, 275, 1052, 267, 291, 423, 10077, 275, 812, 558, 4728, 342, 267, 291, 14, 409, 63, 10077, 63, 16153, 8, 403, 9, 339, 327, 3254, 26, 3967, 781, 883, 1827, 12738, 63, 16153, 2465, 12, 781, 4293, 5647, 642, 370, 3918, 5455, 4205, 272, 347, 663, 63, 10077, 63, 16153, 8, 277, 12, 12738, 63, 16153, 304, 267, 291, 423, 10077, 14, 16153, 275, 12738, 63, 16153, 339, 347, 2248, 8, 277, 12, 666, 12, 570, 63, 354, 15829, 875, 4206, 2498, 63, 1317, 29, 549, 304, 267, 1449, 4540, 4751, 8434, 367, 3063, 2344, 267, 372, 687, 63, 5963, 8, 576, 12, 570, 63, 354, 12, 2498, 63, 1317, 12, 291, 423, 10077, 14, 16153, 9, 339, 347, 2248, 63, 504, 63, 493, 8, 277, 12, 570, 63, 354, 12, 2581, 29, 549, 12, 19293, 29, 797, 304, 267, 1449, 30367, 666, 687, 282, 570, 12, 1314, 883, 1395, 1902, 4840, 503, 18916, 14, 221, 1449, 398, 570, 63, 354, 275, 291, 14, 515, 63, 10772, 1017, 8, 493, 63, 354, 9, 267, 2929, 14, 1757, 480, 19236, 666, 687, 450, 83, 2, 450, 570, 63, 354, 9, 398, 327, 340, 314, 570, 965, 2575, 2757, 1586, 315, 436, 6328, 12, 781, 7171, 267, 327, 372, 5204, 2058, 370, 5126, 1655, 570, 15, 10077, 5331, 267, 340, 2581, 436, 570, 63, 354, 315, 291, 423, 3817, 63, 8677, 26, 288, 4565, 63, 576, 275, 291, 423, 3817, 63, 8677, 59, 493, 63, 354, 61, 267, 587, 26, 288, 327, 1586, 314, 570, 4072, 436, 2248, 314, 666, 5523, 687, 3062, 288, 334, 66, 63, 493, 63, 576, 12, 2498, 63, 1317, 9, 275, 291, 423, 362, 63, 493, 63, 4407, 8, 493, 63, 354, 9, 953, 570, 63, 576, 275, 370, 63, 505, 8, 66, 63, 493, 63, 576, 12, 2552, 534, 16380, 63, 269, 63, 4768, 358, 288, 4565, 63, 576, 275, 291, 14, 912, 8, 576, 29, 493, 63, 576, 12, 570, 63, 354, 29, 493, 63, 354, 12, 2498, 63, 1317, 29, 2384, 63, 1317, 9, 953, 327, 2581, 314, 570, 4072, 367, 2163, 900, 288, 291, 423, 3817, 63, 8677, 59, 493, 63, 354, 61, 275, 4565, 63, 576, 398, 340, 19293, 26, 288, 372, 4565, 63, 576, 267, 587, 26, 288, 327, 372, 282, 13217, 1331, 2348, 12, 880, 314, 2581, 365, 440, 16955, 288, 372, 1331, 14, 8293, 8, 6751, 63, 576, 9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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
a-doumoulakis/tensorflow
tensorflow/compiler/tests/conv2d_test.py
35
14570
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # 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. # ============================================================================== """Tests for Conv2D via the XLA JIT. The canned results in these tests are created by running each test using the Tensorflow CPU device and saving the output. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.compiler.tests.xla_test import XLATestCase from tensorflow.python.framework import dtypes from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_nn_ops from tensorflow.python.ops import nn_ops from tensorflow.python.platform import googletest class Conv2DTest(XLATestCase): def _VerifyValues(self, input_sizes, filter_sizes, stride, padding, expected): """Tests that tf.nn.conv2d produces the expected value. Args: input_sizes: Input tensor dimensions in [batch, input_rows, input_cols, input_depth]. filter_sizes: Filter tensor dimensions in [kernel_rows, kernel_cols, input_depth, output_depth]. stride: Stride. padding: Padding type. expected: Expected output. """ total_size_1 = np.prod(input_sizes) total_size_2 = np.prod(filter_sizes) x1 = np.arange(1, total_size_1 + 1, dtype=np.float32).reshape(input_sizes) x2 = np.arange(1, total_size_2 + 1, dtype=np.float32).reshape(filter_sizes) strides = [1, stride, stride, 1] with self.test_session() as sess: with self.test_scope(): t1 = array_ops.placeholder(dtypes.float32, shape=input_sizes) t2 = array_ops.placeholder(dtypes.float32, shape=filter_sizes) out = nn_ops.conv2d( t1, t2, strides=strides, padding=padding, data_format="NHWC") value = sess.run(out, {t1: x1, t2: x2}) self.assertArrayNear(expected, np.ravel(value), 1e-3) def testConv2D1x1Filter(self): expected_output = [ 30.0, 36.0, 42.0, 66.0, 81.0, 96.0, 102.0, 126.0, 150.0, 138.0, 171.0, 204.0, 174.0, 216.0, 258.0, 210.0, 261.0, 312.0 ] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[1, 1, 3, 3], stride=1, padding="VALID", expected=expected_output) def testConv2D2x2Filter(self): expected_output = [2271.0, 2367.0, 2463.0, 2901.0, 3033.0, 3165.0] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[2, 2, 3, 3], stride=1, padding="VALID", expected=expected_output) def testConv2D1x2Filter(self): expected_output = [ 231.0, 252.0, 273.0, 384.0, 423.0, 462.0, 690.0, 765.0, 840.0, 843.0, 936.0, 1029.0 ] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[1, 2, 3, 3], stride=1, padding="VALID", expected=expected_output) def testConv2D2x2FilterStride2(self): expected_output = [2271.0, 2367.0, 2463.0] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[2, 2, 3, 3], stride=2, padding="VALID", expected=expected_output) def testConv2D2x2FilterStride2Same(self): expected_output = [2271.0, 2367.0, 2463.0, 1230.0, 1305.0, 1380.0] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[2, 2, 3, 3], stride=2, padding="SAME", expected=expected_output) class Conv2DBackpropInputTest(XLATestCase): def _VerifyValues(self, input_sizes, filter_sizes, out_backprop_sizes, stride, padding, expected): """Tests that gen_nn_ops.conv2d_backprop_input produces the expected output. Args: input_sizes: Input tensor dimensions in [batch, input_rows, input_cols, input_depth]. filter_sizes: Filter tensor dimensions in [kernel_rows, kernel_cols, input_depth, output_depth]. out_backprop_sizes: Output gradients tensor dimensions. stride: Stride. padding: Padding type. expected: Expected output. """ total_size_1 = np.prod(filter_sizes) total_size_2 = np.prod(out_backprop_sizes) x1 = np.arange(1, total_size_1 + 1, dtype=np.float32).reshape(filter_sizes) x2 = np.arange( 1, total_size_2 + 1, dtype=np.float32).reshape(out_backprop_sizes) strides = [1, stride, stride, 1] with self.test_session() as sess: with self.test_scope(): t1 = array_ops.placeholder(dtypes.float32, shape=filter_sizes) t2 = array_ops.placeholder(dtypes.float32, shape=out_backprop_sizes) out = gen_nn_ops.conv2d_backprop_input( input_sizes=input_sizes, filter=t1, out_backprop=t2, strides=strides, padding=padding, data_format="NHWC") value = sess.run(out, {t1: x1, t2: x2}) self.assertArrayNear(expected, np.ravel(value), 1e-3) def testConv2D1x1Filter(self): expected_output = [ 5, 11, 17, 11, 25, 39, 17, 39, 61, 23, 53, 83, 29, 67, 105, 35, 81, 127, 41, 95, 149, 47, 109, 171, 53, 123, 193, 59, 137, 215, 65, 151, 237, 71, 165, 259, 77, 179, 281, 83, 193, 303, 89, 207, 325, 95, 221, 347. ] self._VerifyValues( input_sizes=[1, 4, 4, 3], filter_sizes=[1, 1, 3, 2], out_backprop_sizes=[1, 4, 4, 2], stride=1, padding="VALID", expected=expected_output) def testConv2D1x2FilterStride3Width5(self): expected_output = [1, 2, 0, 2, 4] self._VerifyValues( input_sizes=[1, 1, 5, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=3, padding="VALID", expected=expected_output) def testConv2D1x2FilterStride3Width6(self): expected_output = [1, 2, 0, 2, 4, 0] self._VerifyValues( input_sizes=[1, 1, 6, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=3, padding="VALID", expected=expected_output) def testConv2D1x2FilterStride3Width7(self): expected_output = [1, 2, 0, 2, 4, 0, 0] self._VerifyValues( input_sizes=[1, 1, 7, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=3, padding="VALID", expected=expected_output) def testConv2D2x2FilterC1Same(self): expected_output = [1, 4, 7, 7, 23, 33] self._VerifyValues( input_sizes=[1, 2, 3, 1], filter_sizes=[2, 2, 1, 1], out_backprop_sizes=[1, 2, 3, 1], stride=1, padding="SAME", expected=expected_output) def testConv2D2x2Filter(self): expected_output = [ 14, 32, 50, 100, 163, 226, 167, 212, 257, 122, 140, 158, 478, 541, 604, 437, 482, 527 ] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[2, 2, 3, 3], out_backprop_sizes=[1, 1, 2, 3], stride=1, padding="VALID", expected=expected_output) def testConv2D2x2FilterSame(self): expected_output = [ 14, 32, 50, 100, 163, 226, 217, 334, 451, 190, 307, 424, 929, 1217, 1505, 1487, 1883, 2279 ] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[2, 2, 3, 3], out_backprop_sizes=[1, 2, 3, 3], stride=1, padding="SAME", expected=expected_output) def testConv2D1x2Filter(self): expected_output = [1, 4, 4, 3, 10, 8, 5, 16, 12] self._VerifyValues( input_sizes=[1, 3, 3, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 3, 2, 1], stride=1, padding="VALID", expected=expected_output) def testConv2D1x2FilterSame(self): expected_output = [1, 4, 7, 4, 13, 16, 7, 22, 25] self._VerifyValues( input_sizes=[1, 3, 3, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 3, 3, 1], stride=1, padding="SAME", expected=expected_output) def testConv2D2x2FilterStride2(self): expected_output = [1, 2, 5, 4, 6, 0, 0, 0, 0, 0, 3, 6, 13, 8, 12] self._VerifyValues( input_sizes=[1, 3, 5, 1], filter_sizes=[1, 3, 1, 1], out_backprop_sizes=[1, 2, 2, 1], stride=2, padding="VALID", expected=expected_output) def testConv2D2x2FilterStride2Same(self): expected_output = [1, 2, 2, 3, 4, 6] self._VerifyValues( input_sizes=[1, 2, 3, 1], filter_sizes=[2, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=2, padding="SAME", expected=expected_output) class Conv2DBackpropFilterTest(XLATestCase): def _VerifyValues(self, input_sizes, filter_sizes, out_backprop_sizes, stride, padding, expected): """Tests that gen_nn_ops.conv2d_backprop_filter produces the right output. Args: input_sizes: Input tensor dimensions in [batch, input_rows, input_cols, input_depth]. filter_sizes: Filter tensor dimensions in [kernel_rows, kernel_cols, input_depth, output_depth]. out_backprop_sizes: Output gradients tensor dimensions. stride: Stride. padding: Padding type. expected: Expected output. """ total_size_1 = np.prod(input_sizes) total_size_2 = np.prod(out_backprop_sizes) x1 = np.arange(1, total_size_1 + 1, dtype=np.float32).reshape(input_sizes) x2 = np.arange( 1, total_size_2 + 1, dtype=np.float32).reshape(out_backprop_sizes) strides = [1, stride, stride, 1] with self.test_session() as sess: with self.test_scope(): t1 = array_ops.placeholder(dtypes.float32, shape=input_sizes) t2 = array_ops.placeholder(dtypes.float32, shape=out_backprop_sizes) tensor = gen_nn_ops.conv2d_backprop_filter( input=t1, filter_sizes=filter_sizes, out_backprop=t2, strides=strides, padding=padding, data_format="NHWC") value = sess.run(tensor, {t1: x1, t2: x2}) self.assertArrayNear(expected, np.ravel(value), 1e-3) def testConv2D1x1Filter(self): expected_output = [8056, 8432, 8312, 8704, 8568, 8976] self._VerifyValues( input_sizes=[1, 4, 4, 3], filter_sizes=[1, 1, 3, 2], out_backprop_sizes=[1, 4, 4, 2], stride=1, padding="VALID", expected=expected_output) def testConv2D1x2Filter(self): expected_output = [120, 141] self._VerifyValues( input_sizes=[1, 3, 3, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 3, 2, 1], stride=1, padding="VALID", expected=expected_output) def testConv2D2x2FilterDepth1(self): expected_output = [5, 8, 14, 17] self._VerifyValues( input_sizes=[1, 2, 3, 1], filter_sizes=[2, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=1, padding="VALID", expected=expected_output) def testConv2D2x2Filter(self): expected_output = [ 17, 22, 27, 22, 29, 36, 27, 36, 45, 32, 43, 54, 37, 50, 63, 42, 57, 72, 62, 85, 108, 67, 92, 117, 72, 99, 126, 77, 106, 135, 82, 113, 144, 87, 120, 153 ] self._VerifyValues( input_sizes=[1, 2, 3, 3], filter_sizes=[2, 2, 3, 3], out_backprop_sizes=[1, 1, 2, 3], stride=1, padding="VALID", expected=expected_output) def testConv2D1x2FilterStride3Width5(self): expected_output = [9, 12] self._VerifyValues( input_sizes=[1, 1, 5, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=3, padding="VALID", expected=expected_output) def testConv2D1x2FilterStride3Width6(self): expected_output = [9, 12] self._VerifyValues( input_sizes=[1, 1, 6, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=3, padding="VALID", expected=expected_output) def testConv2D1x2FilterStride3Width7(self): expected_output = [9, 12] self._VerifyValues( input_sizes=[1, 1, 7, 1], filter_sizes=[1, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=3, padding="VALID", expected=expected_output) def testConv2D1x3Filter(self): expected_output = [5, 8, 11] self._VerifyValues( input_sizes=[1, 1, 4, 1], filter_sizes=[1, 3, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=1, padding="VALID", expected=expected_output) def testConv2D1x3FilterSame(self): expected_output = [20, 30, 20] self._VerifyValues( input_sizes=[1, 1, 4, 1], filter_sizes=[1, 3, 1, 1], out_backprop_sizes=[1, 1, 4, 1], stride=1, padding="SAME", expected=expected_output) def testConv2D1x3FilterSameOutbackprop2(self): expected_output = [7, 10, 3] self._VerifyValues( input_sizes=[1, 1, 4, 1], filter_sizes=[1, 3, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=2, padding="SAME", expected=expected_output) def testConv2D2x2FilterC1Same(self): expected_output = [91, 58, 32, 17] self._VerifyValues( input_sizes=[1, 2, 3, 1], filter_sizes=[2, 2, 1, 1], out_backprop_sizes=[1, 2, 3, 1], stride=1, padding="SAME", expected=expected_output) def testConv2D2x2FilterStride2(self): expected_output = [92, 102, 112] self._VerifyValues( input_sizes=[1, 3, 5, 1], filter_sizes=[1, 3, 1, 1], out_backprop_sizes=[1, 2, 2, 1], stride=2, padding="VALID", expected=expected_output) def testConv2D2x2FilterStride2Same(self): expected_output = [7, 2, 16, 5] self._VerifyValues( input_sizes=[1, 2, 3, 1], filter_sizes=[2, 2, 1, 1], out_backprop_sizes=[1, 1, 2, 1], stride=2, padding="SAME", expected=expected_output) if __name__ == "__main__": googletest.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 19140, 18, 36, 4799, 314, 1323, 5837, 1603, 649, 14, 199, 199, 1918, 883, 7439, 2058, 315, 3520, 2295, 787, 2737, 701, 3879, 1924, 511, 1808, 314, 199, 3861, 1659, 11952, 2243, 436, 13369, 314, 1072, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 5772, 14, 2219, 14, 88, 416, 63, 396, 492, 1323, 20307, 27309, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 4411, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 19140, 18, 36, 774, 8, 56, 20307, 27309, 304, 819, 347, 485, 7496, 6550, 8, 277, 12, 1324, 63, 7723, 12, 2457, 63, 7723, 12, 7345, 12, 6273, 12, 1420, 304, 272, 408, 2925, 626, 2833, 14, 4411, 14, 5598, 18, 68, 16904, 314, 1420, 574, 14, 339, 3033, 26, 489, 1324, 63, 7723, 26, 6924, 2345, 7365, 315, 267, 359, 2912, 12, 1324, 63, 3838, 12, 1324, 63, 4574, 12, 1324, 63, 4631, 1055, 489, 2457, 63, 7723, 26, 9388, 2345, 7365, 315, 267, 359, 4989, 63, 3838, 12, 5114, 63, 4574, 12, 1324, 63, 4631, 12, 1072, 63, 4631, 1055, 489, 7345, 26, 31309, 271, 14, 489, 6273, 26, 510, 4095, 730, 14, 489, 1420, 26, 13796, 1072, 14, 272, 408, 272, 3141, 63, 890, 63, 17, 275, 980, 14, 8788, 8, 1210, 63, 7723, 9, 272, 3141, 63, 890, 63, 18, 275, 980, 14, 8788, 8, 1541, 63, 7723, 9, 272, 671, 17, 275, 980, 14, 5605, 8, 17, 12, 3141, 63, 890, 63, 17, 435, 413, 12, 2152, 29, 1590, 14, 1609, 708, 680, 5217, 8, 1210, 63, 7723, 9, 272, 671, 18, 275, 980, 14, 5605, 8, 17, 12, 3141, 63, 890, 63, 18, 435, 413, 12, 2152, 29, 1590, 14, 1609, 708, 680, 5217, 8, 1541, 63, 7723, 9, 272, 11883, 275, 359, 17, 12, 7345, 12, 7345, 12, 413, 61, 339, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 307, 17, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 29, 1210, 63, 7723, 9, 267, 307, 18, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 29, 1541, 63, 7723, 9, 267, 734, 275, 11542, 63, 1483, 14, 5598, 18, 68, 8, 288, 307, 17, 12, 307, 18, 12, 11883, 29, 16759, 12, 6273, 29, 8358, 12, 666, 63, 908, 628, 46, 27121, 531, 489, 574, 275, 4043, 14, 1065, 8, 548, 12, 469, 84, 17, 26, 671, 17, 12, 307, 18, 26, 671, 18, 1552, 489, 291, 14, 479, 3836, 46, 2210, 8, 2062, 12, 980, 14, 11186, 8, 585, 395, 413, 69, 13, 19, 9, 819, 347, 511, 11596, 18, 36, 17, 88, 17, 4131, 8, 277, 304, 272, 1420, 63, 1199, 275, 359, 267, 4233, 14, 16, 12, 8780, 14, 16, 12, 5685, 14, 16, 12, 14157, 14, 16, 12, 19071, 14, 16, 12, 15580, 14, 16, 12, 12996, 14, 16, 12, 21572, 14, 16, 12, 14711, 14, 16, 12, 26309, 14, 16, 12, 413, 3172, 14, 16, 12, 267, 14785, 14, 16, 12, 30698, 14, 16, 12, 30630, 14, 16, 12, 499, 2010, 14, 16, 12, 26160, 14, 16, 12, 499, 2976, 14, 16, 12, 650, 713, 14, 16, 272, 1622, 272, 291, 423, 7496, 6550, 8, 267, 1324, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 2457, 63, 7723, 1524, 17, 12, 413, 12, 650, 12, 650, 467, 267, 7345, 29, 17, 12, 267, 6273, 628, 5600, 401, 267, 1420, 29, 2062, 63, 1199, 9, 819, 347, 511, 11596, 18, 36, 18, 88, 18, 4131, 8, 277, 304, 272, 1420, 63, 1199, 275, 359, 1081, 3172, 14, 16, 12, 499, 12684, 14, 16, 12, 499, 25245, 14, 16, 12, 7349, 614, 14, 16, 12, 4233, 1153, 14, 16, 12, 650, 10355, 14, 16, 61, 272, 291, 423, 7496, 6550, 8, 267, 1324, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 2457, 63, 7723, 1524, 18, 12, 499, 12, 650, 12, 650, 467, 267, 7345, 29, 17, 12, 267, 6273, 628, 5600, 401, 267, 1420, 29, 2062, 63, 1199, 9, 819, 347, 511, 11596, 18, 36, 17, 88, 18, 4131, 8, 277, 304, 272, 1420, 63, 1199, 275, 359, 267, 499, 2192, 14, 16, 12, 27210, 14, 16, 12, 499, 2898, 14, 16, 12, 29772, 14, 16, 12, 841, 1789, 14, 16, 12, 841, 2789, 14, 16, 12, 1227, 2710, 14, 16, 12, 1520, 2182, 14, 16, 12, 29675, 14, 16, 12, 8264, 19, 14, 16, 12, 267, 1749, 1344, 14, 16, 12, 12996, 25, 14, 16, 272, 1622, 272, 291, 423, 7496, 6550, 8, 267, 1324, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 2457, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 7345, 29, 17, 12, 267, 6273, 628, 5600, 401, 267 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 19140, 18, 36, 4799, 314, 1323, 5837, 1603, 649, 14, 199, 199, 1918, 883, 7439, 2058, 315, 3520, 2295, 787, 2737, 701, 3879, 1924, 511, 1808, 314, 199, 3861, 1659, 11952, 2243, 436, 13369, 314, 1072, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 5772, 14, 2219, 14, 88, 416, 63, 396, 492, 1323, 20307, 27309, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 4411, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 19140, 18, 36, 774, 8, 56, 20307, 27309, 304, 819, 347, 485, 7496, 6550, 8, 277, 12, 1324, 63, 7723, 12, 2457, 63, 7723, 12, 7345, 12, 6273, 12, 1420, 304, 272, 408, 2925, 626, 2833, 14, 4411, 14, 5598, 18, 68, 16904, 314, 1420, 574, 14, 339, 3033, 26, 489, 1324, 63, 7723, 26, 6924, 2345, 7365, 315, 267, 359, 2912, 12, 1324, 63, 3838, 12, 1324, 63, 4574, 12, 1324, 63, 4631, 1055, 489, 2457, 63, 7723, 26, 9388, 2345, 7365, 315, 267, 359, 4989, 63, 3838, 12, 5114, 63, 4574, 12, 1324, 63, 4631, 12, 1072, 63, 4631, 1055, 489, 7345, 26, 31309, 271, 14, 489, 6273, 26, 510, 4095, 730, 14, 489, 1420, 26, 13796, 1072, 14, 272, 408, 272, 3141, 63, 890, 63, 17, 275, 980, 14, 8788, 8, 1210, 63, 7723, 9, 272, 3141, 63, 890, 63, 18, 275, 980, 14, 8788, 8, 1541, 63, 7723, 9, 272, 671, 17, 275, 980, 14, 5605, 8, 17, 12, 3141, 63, 890, 63, 17, 435, 413, 12, 2152, 29, 1590, 14, 1609, 708, 680, 5217, 8, 1210, 63, 7723, 9, 272, 671, 18, 275, 980, 14, 5605, 8, 17, 12, 3141, 63, 890, 63, 18, 435, 413, 12, 2152, 29, 1590, 14, 1609, 708, 680, 5217, 8, 1541, 63, 7723, 9, 272, 11883, 275, 359, 17, 12, 7345, 12, 7345, 12, 413, 61, 339, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 307, 17, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 29, 1210, 63, 7723, 9, 267, 307, 18, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 29, 1541, 63, 7723, 9, 267, 734, 275, 11542, 63, 1483, 14, 5598, 18, 68, 8, 288, 307, 17, 12, 307, 18, 12, 11883, 29, 16759, 12, 6273, 29, 8358, 12, 666, 63, 908, 628, 46, 27121, 531, 489, 574, 275, 4043, 14, 1065, 8, 548, 12, 469, 84, 17, 26, 671, 17, 12, 307, 18, 26, 671, 18, 1552, 489, 291, 14, 479, 3836, 46, 2210, 8, 2062, 12, 980, 14, 11186, 8, 585, 395, 413, 69, 13, 19, 9, 819, 347, 511, 11596, 18, 36, 17, 88, 17, 4131, 8, 277, 304, 272, 1420, 63, 1199, 275, 359, 267, 4233, 14, 16, 12, 8780, 14, 16, 12, 5685, 14, 16, 12, 14157, 14, 16, 12, 19071, 14, 16, 12, 15580, 14, 16, 12, 12996, 14, 16, 12, 21572, 14, 16, 12, 14711, 14, 16, 12, 26309, 14, 16, 12, 413, 3172, 14, 16, 12, 267, 14785, 14, 16, 12, 30698, 14, 16, 12, 30630, 14, 16, 12, 499, 2010, 14, 16, 12, 26160, 14, 16, 12, 499, 2976, 14, 16, 12, 650, 713, 14, 16, 272, 1622, 272, 291, 423, 7496, 6550, 8, 267, 1324, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 2457, 63, 7723, 1524, 17, 12, 413, 12, 650, 12, 650, 467, 267, 7345, 29, 17, 12, 267, 6273, 628, 5600, 401, 267, 1420, 29, 2062, 63, 1199, 9, 819, 347, 511, 11596, 18, 36, 18, 88, 18, 4131, 8, 277, 304, 272, 1420, 63, 1199, 275, 359, 1081, 3172, 14, 16, 12, 499, 12684, 14, 16, 12, 499, 25245, 14, 16, 12, 7349, 614, 14, 16, 12, 4233, 1153, 14, 16, 12, 650, 10355, 14, 16, 61, 272, 291, 423, 7496, 6550, 8, 267, 1324, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 2457, 63, 7723, 1524, 18, 12, 499, 12, 650, 12, 650, 467, 267, 7345, 29, 17, 12, 267, 6273, 628, 5600, 401, 267, 1420, 29, 2062, 63, 1199, 9, 819, 347, 511, 11596, 18, 36, 17, 88, 18, 4131, 8, 277, 304, 272, 1420, 63, 1199, 275, 359, 267, 499, 2192, 14, 16, 12, 27210, 14, 16, 12, 499, 2898, 14, 16, 12, 29772, 14, 16, 12, 841, 1789, 14, 16, 12, 841, 2789, 14, 16, 12, 1227, 2710, 14, 16, 12, 1520, 2182, 14, 16, 12, 29675, 14, 16, 12, 8264, 19, 14, 16, 12, 267, 1749, 1344, 14, 16, 12, 12996, 25, 14, 16, 272, 1622, 272, 291, 423, 7496, 6550, 8, 267, 1324, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 2457, 63, 7723, 1524, 17, 12, 499, 12, 650, 12, 650, 467, 267, 7345, 29, 17, 12, 267, 6273, 628, 5600, 401, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
longde123/MultiversePlatform
server/config/common/character_factory.py
1
4399
# # The Multiverse Platform is made available under the MIT License. # # Copyright (c) 2012 The Multiverse Foundation # # 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. # # from multiverse.mars import * from multiverse.mars.objects import * from multiverse.mars.core import * from multiverse.mars.events import * from multiverse.mars.util import * from multiverse.mars.plugins import * from multiverse.server.plugins import * from multiverse.server.math import * from multiverse.server.events import * from multiverse.server.objects import * from multiverse.server.engine import * from java.lang import * displayContext = DisplayContext("human_female.mesh") displayContext.addSubmesh(DisplayContext.Submesh("bodyShape-lib.0", "human_female.skin_material")) displayContext.addSubmesh(DisplayContext.Submesh("head_aShape-lib.0", "human_female.head_a_material")) displayContext.addSubmesh(DisplayContext.Submesh("hair_bShape-lib.0", "human_female.hair_b_material")) # default player template player = Template("DefaultPlayer") player.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_DISPLAY_CONTEXT, displayContext) player.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_OBJECT_TYPE, ObjectTypes.player) player.put(InventoryClient.NAMESPACE, InventoryClient.TEMPL_ITEMS, "") ObjectManagerClient.registerTemplate(player) # character factory class SampleFactory (CharacterFactory): def createCharacter(self, worldName, uid, properties): name = properties.get("characterName"); # Player start location loc = Point(-135343, 0, -202945) # Player start instance; assumes you have an instance named "default" instanceOid = InstanceClient.getInstanceOid("default") overrideTemplate = Template() if name: overrideTemplate.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_NAME, name) overrideTemplate.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_INSTANCE, Long(instanceOid)) overrideTemplate.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_LOC, loc) # Initialize the player's instance restore stack restorePoint = InstanceRestorePoint("default", loc) restorePoint.setFallbackFlag(True) restoreStack = LinkedList() restoreStack.add(restorePoint) overrideTempate.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_INSTANCE_RESTORE_STACK, restoreStack) overrideTempate.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_CURRENT_INSTANCE_NAME, "default") # Make the player persistent (will be saved in database) overrideTemplate.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_PERSISTENT, Boolean(True)); # Create the player object objOid = ObjectManagerClient.generateObject( "DefaultPlayer", overrideTemplate) Log.debug("SampleFactory: generated obj oid=" + str(objOid)) return objOid sampleFactory = SampleFactory() LoginPlugin.getCharacterGenerator().setCharacterFactory(sampleFactory);
mit
[ 3, 199, 3, 221, 710, 6879, 2077, 16078, 365, 6326, 2808, 1334, 314, 10697, 844, 14, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6029, 710, 6879, 2077, 2752, 199, 3, 199, 3, 221, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 221, 199, 3, 221, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 221, 199, 3, 221, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 221, 199, 3, 221, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 221, 199, 3, 221, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 221, 199, 3, 221, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 221, 199, 3, 221, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 221, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 221, 199, 3, 221, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 221, 199, 3, 221, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 221, 199, 3, 221, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 221, 199, 3, 221, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 221, 199, 3, 221, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 221, 199, 3, 221, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 221, 199, 3, 221, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 221, 199, 3, 221, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 221, 199, 3, 221, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 3, 199, 199, 504, 3510, 2077, 14, 77, 4291, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1018, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 4368, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1974, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 5265, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 5265, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3442, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 4368, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3908, 492, 627, 199, 504, 12120, 14, 4159, 492, 627, 199, 199, 2918, 2998, 275, 12175, 2998, 480, 14864, 63, 771, 17667, 14, 6480, 531, 199, 2918, 2998, 14, 525, 2610, 6480, 8, 7687, 2998, 14, 2610, 6480, 480, 2030, 7238, 13, 773, 14, 16, 401, 1740, 298, 14864, 63, 771, 17667, 14, 16409, 63, 9820, 2237, 199, 2918, 2998, 14, 525, 2610, 6480, 8, 7687, 2998, 14, 2610, 6480, 480, 2993, 63, 65, 7238, 13, 773, 14, 16, 401, 1740, 298, 14864, 63, 771, 17667, 14, 2993, 63, 65, 63, 9820, 2237, 199, 2918, 2998, 14, 525, 2610, 6480, 8, 7687, 2998, 14, 2610, 6480, 480, 2411, 723, 63, 66, 7238, 13, 773, 14, 16, 401, 1740, 298, 14864, 63, 771, 17667, 14, 2411, 723, 63, 66, 63, 9820, 2237, 199, 199, 3, 849, 7748, 1978, 199, 6147, 275, 5458, 480, 2698, 10921, 531, 199, 199, 6147, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 1779, 13064, 2988, 3041, 14, 24136, 63, 20993, 63, 9059, 12, 1779, 2929, 2998, 9, 199, 199, 6147, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 1779, 13064, 2988, 3041, 14, 24136, 63, 9868, 63, 2711, 12, 1779, 6935, 4100, 14, 6147, 9, 199, 199, 6147, 14, 524, 8, 19304, 3041, 14, 13001, 12, 1779, 19337, 3041, 14, 24136, 63, 10439, 51, 12, 1779, 6899, 199, 1692, 2988, 3041, 14, 2683, 4231, 8, 6147, 9, 199, 199, 3, 4528, 6434, 199, 533, 15227, 2927, 334, 14852, 2927, 304, 272, 347, 1218, 14852, 8, 277, 12, 6701, 985, 12, 1747, 12, 4382, 304, 267, 536, 275, 4382, 14, 362, 480, 10856, 985, 3547, 421, 198, 3, 25610, 1343, 2909, 267, 4355, 275, 7584, 2801, 8312, 14761, 12, 378, 12, 446, 25078, 2322, 9, 398, 327, 25610, 1343, 1256, 27, 15194, 1265, 1172, 376, 1256, 4310, 298, 885, 2, 267, 1256, 47, 344, 275, 10066, 3041, 14, 29964, 47, 344, 480, 885, 531, 398, 4278, 4231, 275, 5458, 342, 398, 340, 536, 26, 288, 4278, 4231, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 355, 13064, 2988, 3041, 14, 24136, 63, 2339, 12, 536, 9, 398, 4278, 4231, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 355, 13064, 2988, 3041, 14, 24136, 63, 18235, 12, 19944, 8, 842, 47, 344, 430, 267, 4278, 4231, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 355, 13064, 2988, 3041, 14, 24136, 63, 5752, 12, 4355, 9, 398, 327, 11578, 314, 7748, 1159, 1256, 9066, 3464, 267, 9066, 3428, 275, 10066, 21012, 3428, 480, 885, 401, 4355, 9, 267, 9066, 3428, 14, 409, 21860, 5318, 8, 549, 9, 267, 9066, 4851, 275, 10967, 379, 1296, 342, 267, 9066, 4851, 14, 525, 8, 8011, 3428, 9, 267, 4278, 6530, 323, 14, 524, 8, 8814, 14, 9868, 63, 28541, 12, 2049, 6935, 2988, 3041, 14, 24136, 63, 18235, 63, 15740, 5788, 63, 17014, 12, 9066, 4851, 9, 267, 4278, 6530, 323, 14, 524, 8, 8814, 14, 9868, 63, 28541, 12, 2049, 6935, 2988, 3041, 14, 24136, 63, 14211, 63, 18235, 63, 2339, 12, 298, 885, 531, 421, 198, 3, 4155, 314, 7748, 16149, 334, 14117, 506, 6290, 315, 3050, 9, 267, 4278, 4231, 14, 524, 8, 8814, 14, 9868, 63, 28541, 12, 288, 6935, 2988, 3041, 14, 24136, 63, 4227, 29367, 1309, 12, 9411, 8, 549, 16674, 421, 198, 3, 2790, 314, 7748, 909, 267, 1559, 47, 344, 275, 6935, 2988, 3041, 14, 4208, 1692, 8, 355, 298, 2698, 10921, 401, 4278, 4231, 9, 267, 5297, 14, 1757, 480, 8176, 2927, 26, 4046, 1559, 20109, 628, 435, 620, 8, 1113, 47, 344, 430, 398, 372, 1559, 47, 344, 199, 199, 3271, 2927, 275, 15227, 2927, 342, 199, 8880, 5061, 14 ]
[ 199, 3, 221, 710, 6879, 2077, 16078, 365, 6326, 2808, 1334, 314, 10697, 844, 14, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6029, 710, 6879, 2077, 2752, 199, 3, 199, 3, 221, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 221, 199, 3, 221, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 221, 199, 3, 221, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 221, 199, 3, 221, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 221, 199, 3, 221, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 221, 199, 3, 221, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 221, 199, 3, 221, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 221, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 221, 199, 3, 221, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 221, 199, 3, 221, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 221, 199, 3, 221, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 221, 199, 3, 221, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 221, 199, 3, 221, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 221, 199, 3, 221, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 221, 199, 3, 221, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 221, 199, 3, 221, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 221, 199, 3, 221, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 3, 199, 199, 504, 3510, 2077, 14, 77, 4291, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1018, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 4368, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1974, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 5265, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 5265, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3442, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 4368, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3908, 492, 627, 199, 504, 12120, 14, 4159, 492, 627, 199, 199, 2918, 2998, 275, 12175, 2998, 480, 14864, 63, 771, 17667, 14, 6480, 531, 199, 2918, 2998, 14, 525, 2610, 6480, 8, 7687, 2998, 14, 2610, 6480, 480, 2030, 7238, 13, 773, 14, 16, 401, 1740, 298, 14864, 63, 771, 17667, 14, 16409, 63, 9820, 2237, 199, 2918, 2998, 14, 525, 2610, 6480, 8, 7687, 2998, 14, 2610, 6480, 480, 2993, 63, 65, 7238, 13, 773, 14, 16, 401, 1740, 298, 14864, 63, 771, 17667, 14, 2993, 63, 65, 63, 9820, 2237, 199, 2918, 2998, 14, 525, 2610, 6480, 8, 7687, 2998, 14, 2610, 6480, 480, 2411, 723, 63, 66, 7238, 13, 773, 14, 16, 401, 1740, 298, 14864, 63, 771, 17667, 14, 2411, 723, 63, 66, 63, 9820, 2237, 199, 199, 3, 849, 7748, 1978, 199, 6147, 275, 5458, 480, 2698, 10921, 531, 199, 199, 6147, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 1779, 13064, 2988, 3041, 14, 24136, 63, 20993, 63, 9059, 12, 1779, 2929, 2998, 9, 199, 199, 6147, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 1779, 13064, 2988, 3041, 14, 24136, 63, 9868, 63, 2711, 12, 1779, 6935, 4100, 14, 6147, 9, 199, 199, 6147, 14, 524, 8, 19304, 3041, 14, 13001, 12, 1779, 19337, 3041, 14, 24136, 63, 10439, 51, 12, 1779, 6899, 199, 1692, 2988, 3041, 14, 2683, 4231, 8, 6147, 9, 199, 199, 3, 4528, 6434, 199, 533, 15227, 2927, 334, 14852, 2927, 304, 272, 347, 1218, 14852, 8, 277, 12, 6701, 985, 12, 1747, 12, 4382, 304, 267, 536, 275, 4382, 14, 362, 480, 10856, 985, 3547, 421, 198, 3, 25610, 1343, 2909, 267, 4355, 275, 7584, 2801, 8312, 14761, 12, 378, 12, 446, 25078, 2322, 9, 398, 327, 25610, 1343, 1256, 27, 15194, 1265, 1172, 376, 1256, 4310, 298, 885, 2, 267, 1256, 47, 344, 275, 10066, 3041, 14, 29964, 47, 344, 480, 885, 531, 398, 4278, 4231, 275, 5458, 342, 398, 340, 536, 26, 288, 4278, 4231, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 355, 13064, 2988, 3041, 14, 24136, 63, 2339, 12, 536, 9, 398, 4278, 4231, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 355, 13064, 2988, 3041, 14, 24136, 63, 18235, 12, 19944, 8, 842, 47, 344, 430, 267, 4278, 4231, 14, 524, 8, 15943, 2988, 3041, 14, 13001, 12, 355, 13064, 2988, 3041, 14, 24136, 63, 5752, 12, 4355, 9, 398, 327, 11578, 314, 7748, 1159, 1256, 9066, 3464, 267, 9066, 3428, 275, 10066, 21012, 3428, 480, 885, 401, 4355, 9, 267, 9066, 3428, 14, 409, 21860, 5318, 8, 549, 9, 267, 9066, 4851, 275, 10967, 379, 1296, 342, 267, 9066, 4851, 14, 525, 8, 8011, 3428, 9, 267, 4278, 6530, 323, 14, 524, 8, 8814, 14, 9868, 63, 28541, 12, 2049, 6935, 2988, 3041, 14, 24136, 63, 18235, 63, 15740, 5788, 63, 17014, 12, 9066, 4851, 9, 267, 4278, 6530, 323, 14, 524, 8, 8814, 14, 9868, 63, 28541, 12, 2049, 6935, 2988, 3041, 14, 24136, 63, 14211, 63, 18235, 63, 2339, 12, 298, 885, 531, 421, 198, 3, 4155, 314, 7748, 16149, 334, 14117, 506, 6290, 315, 3050, 9, 267, 4278, 4231, 14, 524, 8, 8814, 14, 9868, 63, 28541, 12, 288, 6935, 2988, 3041, 14, 24136, 63, 4227, 29367, 1309, 12, 9411, 8, 549, 16674, 421, 198, 3, 2790, 314, 7748, 909, 267, 1559, 47, 344, 275, 6935, 2988, 3041, 14, 4208, 1692, 8, 355, 298, 2698, 10921, 401, 4278, 4231, 9, 267, 5297, 14, 1757, 480, 8176, 2927, 26, 4046, 1559, 20109, 628, 435, 620, 8, 1113, 47, 344, 430, 398, 372, 1559, 47, 344, 199, 199, 3271, 2927, 275, 15227, 2927, 342, 199, 8880, 5061, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
datadesk/panda
panda/migrations/0018_auto__add_field_taskstatus_task_description.py
6
13100
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'TaskStatus.task_description' db.add_column('panda_taskstatus', 'task_description', self.gf('django.db.models.fields.TextField')(default=''), keep_default=False) def backwards(self, orm): # Deleting field 'TaskStatus.task_description' db.delete_column('panda_taskstatus', 'task_description') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'panda.activitylog': { 'Meta': {'unique_together': "(('user', 'when'),)", 'object_name': 'ActivityLog'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'activity_logs'", 'to': "orm['auth.User']"}), 'when': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}) }, 'panda.category': { 'Meta': {'object_name': 'Category'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '256'}) }, 'panda.dataset': { 'Meta': {'ordering': "['-creation_date']", 'object_name': 'Dataset'}, 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'datasets'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['panda.Category']"}), 'column_schema': ('panda.fields.JSONField', [], {'default': 'None', 'null': 'True'}), 'creation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'to': "orm['auth.User']"}), 'current_task': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['panda.TaskStatus']", 'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'initial_upload': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'initial_upload_for'", 'null': 'True', 'to': "orm['panda.DataUpload']"}), 'last_modification': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'last_modified': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'last_modified_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}), 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'locked_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'row_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'sample_data': ('panda.fields.JSONField', [], {'default': 'None', 'null': 'True'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '256'}) }, 'panda.dataupload': { 'Meta': {'ordering': "['creation_date']", 'object_name': 'DataUpload'}, 'columns': ('panda.fields.JSONField', [], {'null': 'True'}), 'creation_date': ('django.db.models.fields.DateTimeField', [], {}), 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'data_type': ('django.db.models.fields.CharField', [], {'max_length': '4', 'null': 'True', 'blank': 'True'}), 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'data_uploads'", 'null': 'True', 'to': "orm['panda.Dataset']"}), 'dialect': ('panda.fields.JSONField', [], {'null': 'True'}), 'encoding': ('django.db.models.fields.CharField', [], {'default': "'utf-8'", 'max_length': '32'}), 'filename': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'guessed_types': ('panda.fields.JSONField', [], {'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'imported': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'sample_data': ('panda.fields.JSONField', [], {'null': 'True'}), 'size': ('django.db.models.fields.IntegerField', [], {}) }, 'panda.export': { 'Meta': {'ordering': "['creation_date']", 'object_name': 'Export'}, 'creation_date': ('django.db.models.fields.DateTimeField', [], {}), 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'exports'", 'null': 'True', 'to': "orm['panda.Dataset']"}), 'filename': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'size': ('django.db.models.fields.IntegerField', [], {}) }, 'panda.notification': { 'Meta': {'ordering': "['-sent_at']", 'object_name': 'Notification'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'message': ('django.db.models.fields.TextField', [], {}), 'read_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': "orm['auth.User']"}), 'related_dataset': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['panda.Dataset']", 'null': 'True'}), 'related_export': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['panda.Export']", 'null': 'True'}), 'related_task': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['panda.TaskStatus']", 'null': 'True'}), 'sent_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'type': ('django.db.models.fields.CharField', [], {'default': "'Info'", 'max_length': '16'}) }, 'panda.relatedupload': { 'Meta': {'ordering': "['creation_date']", 'object_name': 'RelatedUpload'}, 'creation_date': ('django.db.models.fields.DateTimeField', [], {}), 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'related_uploads'", 'to': "orm['panda.Dataset']"}), 'filename': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'size': ('django.db.models.fields.IntegerField', [], {}) }, 'panda.searchlog': { 'Meta': {'object_name': 'SearchLog'}, 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'searches'", 'null': 'True', 'to': "orm['panda.Dataset']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'query': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'search_logs'", 'to': "orm['auth.User']"}), 'when': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) }, 'panda.taskstatus': { 'Meta': {'object_name': 'TaskStatus'}, 'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tasks'", 'null': 'True', 'to': "orm['auth.User']"}), 'end': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'message': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'start': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'PENDING'", 'max_length': '50'}), 'task_description': ('django.db.models.fields.TextField', [], {}), 'task_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'traceback': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'panda.userprofile': { 'Meta': {'object_name': 'UserProfile'}, 'activation_key': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}), 'activation_key_expiration': ('django.db.models.fields.DateTimeField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'}) } } complete_apps = ['panda']
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 4476, 3694, 14, 1765, 63, 1802, 7, 267, 1592, 14, 525, 63, 2301, 360, 80, 18328, 63, 1765, 1205, 297, 283, 1765, 63, 1802, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 534, 659, 1993, 4215, 63, 885, 29, 797, 9, 339, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 4476, 3694, 14, 1765, 63, 1802, 7, 267, 1592, 14, 1807, 63, 2301, 360, 80, 18328, 63, 1765, 1205, 297, 283, 1765, 63, 1802, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 80, 18328, 14, 8240, 793, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 751, 297, 283, 6526, 9878, 283, 785, 63, 354, 356, 283, 14350, 2445, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 4476, 3694, 14, 1765, 63, 1802, 7, 267, 1592, 14, 525, 63, 2301, 360, 80, 18328, 63, 1765, 1205, 297, 283, 1765, 63, 1802, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 534, 659, 1993, 4215, 63, 885, 29, 797, 9, 339, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 4476, 3694, 14, 1765, 63, 1802, 7, 267, 1592, 14, 1807, 63, 2301, 360, 80, 18328, 63, 1765, 1205, 297, 283, 1765, 63, 1802, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 80, 18328, 14, 8240, 793, 356, 469, 288, 283, 3396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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
uschmidt83/SublimeLinter-for-ST2
sublimelinter/modules/notes.py
9
2249
'''notes.py Used to highlight user-defined "annotations" such as TODO, README, etc., depending user choice. ''' import sublime from base_linter import BaseLinter CONFIG = { 'language': 'Annotations' } class Linter(BaseLinter): DEFAULT_NOTES = ["TODO", "README", "FIXME"] def built_in_check(self, view, code, filename): annotations = self.select_annotations(view) regions = [] for annotation in annotations: regions.extend(self.find_all(code, annotation, view)) return regions def select_annotations(self, view): '''selects the list of annotations to use''' return view.settings().get("annotations", self.DEFAULT_NOTES) def extract_annotations(self, code, view, filename): '''extract all lines with annotations''' annotations = self.select_annotations(view) annotation_starts = [] for annotation in annotations: start = 0 length = len(annotation) while True: start = code.find(annotation, start) if start != -1: end = start + length annotation_starts.append(start) start = end else: break regions_with_notes = set([]) for point in annotation_starts: regions_with_notes.add(view.extract_scope(point)) regions_with_notes = sorted(list(regions_with_notes)) text = [] for region in regions_with_notes: row, col = view.rowcol(region.begin()) text.append("[{0}:{1}]".format(filename, row + 1)) text.append(view.substr(region)) return '\n'.join(text) def find_all(self, text, string, view): ''' finds all occurences of "string" in "text" and notes their positions as a sublime Region ''' found = [] length = len(string) start = 0 while True: start = text.find(string, start) if start != -1: end = start + length found.append(sublime.Region(start, end)) start = end else: break return found
mit
[ 2344, 5983, 14, 647, 199, 199, 9167, 370, 11850, 922, 13, 4037, 298, 11270, 2, 4066, 465, 3254, 12, 27781, 12, 5423, 2020, 199, 2601, 3219, 922, 7141, 14, 199, 2344, 199, 199, 646, 1007, 18687, 199, 199, 504, 1300, 63, 25240, 492, 3523, 44, 1058, 199, 199, 5569, 275, 469, 272, 283, 3671, 356, 283, 21761, 1298, 7, 199, 93, 421, 199, 533, 491, 1058, 8, 1563, 44, 1058, 304, 272, 6186, 63, 4609, 654, 275, 2097, 11768, 401, 298, 18195, 401, 298, 31779, 937, 339, 347, 6137, 63, 262, 63, 1074, 8, 277, 12, 2455, 12, 1233, 12, 1788, 304, 267, 15538, 275, 291, 14, 2416, 63, 11270, 8, 1345, 9, 267, 16150, 275, 942, 398, 367, 11262, 315, 15538, 26, 288, 16150, 14, 2880, 8, 277, 14, 1623, 63, 452, 8, 600, 12, 11262, 12, 2455, 430, 398, 372, 16150, 339, 347, 3504, 63, 11270, 8, 277, 12, 2455, 304, 267, 1449, 2416, 83, 314, 769, 402, 15538, 370, 675, 2344, 267, 372, 2455, 14, 1751, 1252, 362, 480, 11270, 401, 291, 14, 3472, 63, 4609, 654, 9, 339, 347, 5536, 63, 11270, 8, 277, 12, 1233, 12, 2455, 12, 1788, 304, 267, 1449, 5005, 1006, 2385, 543, 15538, 2344, 267, 15538, 275, 291, 14, 2416, 63, 11270, 8, 1345, 9, 267, 11262, 63, 17116, 275, 942, 398, 367, 11262, 315, 15538, 26, 288, 1343, 275, 378, 288, 2582, 275, 822, 8, 9340, 9, 953, 1830, 715, 26, 355, 1343, 275, 1233, 14, 1623, 8, 9340, 12, 1343, 9, 2234, 340, 1343, 1137, 446, 17, 26, 490, 1284, 275, 1343, 435, 2582, 490, 11262, 63, 17116, 14, 740, 8, 928, 9, 490, 1343, 275, 1284, 355, 587, 26, 490, 2059, 398, 16150, 63, 1045, 63, 5983, 275, 663, 4157, 398, 367, 2376, 315, 11262, 63, 17116, 26, 288, 16150, 63, 1045, 63, 5983, 14, 525, 8, 1345, 14, 5005, 63, 2645, 8, 1403, 430, 398, 16150, 63, 1045, 63, 5983, 275, 3355, 8, 513, 8, 11963, 63, 1045, 63, 5983, 430, 267, 1318, 275, 942, 398, 367, 4897, 315, 16150, 63, 1045, 63, 5983, 26, 288, 1962, 12, 1048, 275, 2455, 14, 1143, 761, 8, 4551, 14, 5037, 1012, 288, 1318, 14, 740, 10994, 91, 16, 16495, 17, 11049, 1674, 908, 8, 1501, 12, 1962, 435, 413, 430, 288, 1318, 14, 740, 8, 1345, 14, 22668, 8, 4551, 430, 398, 372, 1557, 78, 1370, 904, 8, 505, 9, 339, 347, 2342, 63, 452, 8, 277, 12, 1318, 12, 1059, 12, 2455, 304, 267, 1449, 17651, 1006, 14706, 608, 78, 823, 402, 298, 875, 2, 315, 298, 505, 2, 436, 12681, 3932, 12266, 288, 465, 282, 1007, 18687, 22240, 267, 1449, 267, 1911, 275, 942, 267, 2582, 275, 822, 8, 875, 9, 267, 1343, 275, 378, 398, 1830, 715, 26, 288, 1343, 275, 1318, 14, 1623, 8, 875, 12, 1343, 9, 953, 340, 1343, 1137, 446, 17, 26, 355, 1284, 275, 1343, 435, 2582, 355, 1911, 14, 740, 8, 954, 18687, 14, 10708, 8, 928, 12, 1284, 430, 355, 1343, 275, 1284, 288, 587, 26, 355, 2059, 398, 372, 1911, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5983, 14, 647, 199, 199, 9167, 370, 11850, 922, 13, 4037, 298, 11270, 2, 4066, 465, 3254, 12, 27781, 12, 5423, 2020, 199, 2601, 3219, 922, 7141, 14, 199, 2344, 199, 199, 646, 1007, 18687, 199, 199, 504, 1300, 63, 25240, 492, 3523, 44, 1058, 199, 199, 5569, 275, 469, 272, 283, 3671, 356, 283, 21761, 1298, 7, 199, 93, 421, 199, 533, 491, 1058, 8, 1563, 44, 1058, 304, 272, 6186, 63, 4609, 654, 275, 2097, 11768, 401, 298, 18195, 401, 298, 31779, 937, 339, 347, 6137, 63, 262, 63, 1074, 8, 277, 12, 2455, 12, 1233, 12, 1788, 304, 267, 15538, 275, 291, 14, 2416, 63, 11270, 8, 1345, 9, 267, 16150, 275, 942, 398, 367, 11262, 315, 15538, 26, 288, 16150, 14, 2880, 8, 277, 14, 1623, 63, 452, 8, 600, 12, 11262, 12, 2455, 430, 398, 372, 16150, 339, 347, 3504, 63, 11270, 8, 277, 12, 2455, 304, 267, 1449, 2416, 83, 314, 769, 402, 15538, 370, 675, 2344, 267, 372, 2455, 14, 1751, 1252, 362, 480, 11270, 401, 291, 14, 3472, 63, 4609, 654, 9, 339, 347, 5536, 63, 11270, 8, 277, 12, 1233, 12, 2455, 12, 1788, 304, 267, 1449, 5005, 1006, 2385, 543, 15538, 2344, 267, 15538, 275, 291, 14, 2416, 63, 11270, 8, 1345, 9, 267, 11262, 63, 17116, 275, 942, 398, 367, 11262, 315, 15538, 26, 288, 1343, 275, 378, 288, 2582, 275, 822, 8, 9340, 9, 953, 1830, 715, 26, 355, 1343, 275, 1233, 14, 1623, 8, 9340, 12, 1343, 9, 2234, 340, 1343, 1137, 446, 17, 26, 490, 1284, 275, 1343, 435, 2582, 490, 11262, 63, 17116, 14, 740, 8, 928, 9, 490, 1343, 275, 1284, 355, 587, 26, 490, 2059, 398, 16150, 63, 1045, 63, 5983, 275, 663, 4157, 398, 367, 2376, 315, 11262, 63, 17116, 26, 288, 16150, 63, 1045, 63, 5983, 14, 525, 8, 1345, 14, 5005, 63, 2645, 8, 1403, 430, 398, 16150, 63, 1045, 63, 5983, 275, 3355, 8, 513, 8, 11963, 63, 1045, 63, 5983, 430, 267, 1318, 275, 942, 398, 367, 4897, 315, 16150, 63, 1045, 63, 5983, 26, 288, 1962, 12, 1048, 275, 2455, 14, 1143, 761, 8, 4551, 14, 5037, 1012, 288, 1318, 14, 740, 10994, 91, 16, 16495, 17, 11049, 1674, 908, 8, 1501, 12, 1962, 435, 413, 430, 288, 1318, 14, 740, 8, 1345, 14, 22668, 8, 4551, 430, 398, 372, 1557, 78, 1370, 904, 8, 505, 9, 339, 347, 2342, 63, 452, 8, 277, 12, 1318, 12, 1059, 12, 2455, 304, 267, 1449, 17651, 1006, 14706, 608, 78, 823, 402, 298, 875, 2, 315, 298, 505, 2, 436, 12681, 3932, 12266, 288, 465, 282, 1007, 18687, 22240, 267, 1449, 267, 1911, 275, 942, 267, 2582, 275, 822, 8, 875, 9, 267, 1343, 275, 378, 398, 1830, 715, 26, 288, 1343, 275, 1318, 14, 1623, 8, 875, 12, 1343, 9, 953, 340, 1343, 1137, 446, 17, 26, 355, 1284, 275, 1343, 435, 2582, 355, 1911, 14, 740, 8, 954, 18687, 14, 10708, 8, 928, 12, 1284, 430, 355, 1343, 275, 1284, 288, 587, 26, 355, 2059, 398, 372, 1911, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
avinashkunuje/phantomjs
src/qt/qtwebkit/Tools/BuildSlaveSupport/build.webkit.org-config/htdigestparser.py
123
2341
# Copyright (C) 2011 Apple 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: # 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. # # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. """htdigestparser - a parser for htdigest files""" import hashlib import string class HTDigestParser(object): def __init__(self, digest_file): self._entries = self.parse_file(digest_file) def authenticate(self, username, realm, password): hashed_password = hashlib.md5(':'.join((username, realm, password))).hexdigest() return [username, realm, hashed_password] in self.entries() def entries(self): return self._entries def parse_file(self, digest_file): entries = [line.rstrip().split(':') for line in digest_file] # Perform some sanity-checking to ensure the file is valid. valid_characters = set(string.hexdigits) for entry in entries: if len(entry) != 3: return [] hashed_password = entry[-1] if len(hashed_password) != 32: return [] if not set(hashed_password).issubset(valid_characters): return [] return entries
bsd-3-clause
[ 3, 1898, 334, 35, 9, 7760, 21257, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 19525, 906, 7839, 14, 2401, 473, 9730, 6483, 1124, 1179, 2281, 891, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 19525, 906, 7839, 14, 1549, 473, 9730, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 517, 5671, 2087, 446, 282, 1798, 367, 1243, 5671, 1584, 624, 199, 199, 646, 8337, 199, 646, 1059, 421, 199, 533, 4102, 18541, 2842, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10017, 63, 493, 304, 267, 291, 423, 3189, 275, 291, 14, 1122, 63, 493, 8, 5671, 63, 493, 9, 339, 347, 12895, 8, 277, 12, 3434, 12, 10482, 12, 2505, 304, 267, 19871, 63, 2060, 275, 8337, 14, 1064, 21, 6176, 1370, 904, 1332, 2473, 12, 10482, 12, 2505, 23261, 11453, 342, 267, 372, 359, 2473, 12, 10482, 12, 19871, 63, 2060, 61, 315, 291, 14, 3189, 342, 339, 347, 4811, 8, 277, 304, 267, 372, 291, 423, 3189, 339, 347, 2198, 63, 493, 8, 277, 12, 10017, 63, 493, 304, 267, 4811, 275, 359, 604, 14, 6735, 1252, 1294, 11633, 367, 1004, 315, 10017, 63, 493, 61, 398, 327, 14795, 2005, 16740, 13, 19527, 370, 4868, 314, 570, 365, 1686, 14, 267, 1686, 63, 16516, 275, 663, 8, 875, 14, 4097, 7022, 9, 267, 367, 2397, 315, 4811, 26, 288, 340, 822, 8, 2373, 9, 1137, 650, 26, 355, 372, 942, 288, 19871, 63, 2060, 275, 2397, 1988, 17, 61, 288, 340, 822, 8, 26368, 63, 2060, 9, 1137, 4337, 26, 355, 372, 942, 288, 340, 440, 663, 8, 26368, 63, 2060, 680, 374, 9401, 8, 1078, 63, 16516, 304, 355, 372, 942, 398, 372, 4811, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 7760, 21257, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 19525, 906, 7839, 14, 2401, 473, 9730, 6483, 1124, 1179, 2281, 891, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 19525, 906, 7839, 14, 1549, 473, 9730, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 517, 5671, 2087, 446, 282, 1798, 367, 1243, 5671, 1584, 624, 199, 199, 646, 8337, 199, 646, 1059, 421, 199, 533, 4102, 18541, 2842, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10017, 63, 493, 304, 267, 291, 423, 3189, 275, 291, 14, 1122, 63, 493, 8, 5671, 63, 493, 9, 339, 347, 12895, 8, 277, 12, 3434, 12, 10482, 12, 2505, 304, 267, 19871, 63, 2060, 275, 8337, 14, 1064, 21, 6176, 1370, 904, 1332, 2473, 12, 10482, 12, 2505, 23261, 11453, 342, 267, 372, 359, 2473, 12, 10482, 12, 19871, 63, 2060, 61, 315, 291, 14, 3189, 342, 339, 347, 4811, 8, 277, 304, 267, 372, 291, 423, 3189, 339, 347, 2198, 63, 493, 8, 277, 12, 10017, 63, 493, 304, 267, 4811, 275, 359, 604, 14, 6735, 1252, 1294, 11633, 367, 1004, 315, 10017, 63, 493, 61, 398, 327, 14795, 2005, 16740, 13, 19527, 370, 4868, 314, 570, 365, 1686, 14, 267, 1686, 63, 16516, 275, 663, 8, 875, 14, 4097, 7022, 9, 267, 367, 2397, 315, 4811, 26, 288, 340, 822, 8, 2373, 9, 1137, 650, 26, 355, 372, 942, 288, 19871, 63, 2060, 275, 2397, 1988, 17, 61, 288, 340, 822, 8, 26368, 63, 2060, 9, 1137, 4337, 26, 355, 372, 942, 288, 340, 440, 663, 8, 26368, 63, 2060, 680, 374, 9401, 8, 1078, 63, 16516, 304, 355, 372, 942, 398, 372, 4811, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ice9js/servo
tests/wpt/web-platform-tests/old-tests/webdriver/windows/window_manipulation.py
142
1556
# -*- mode: python; fill-column: 100; comment-column: 100; -*- import os import sys import unittest sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../.."))) import base_test from selenium.common import exceptions class WindowingTest(base_test.WebDriverBaseTest): def test_maximize(self): #self.driver.get(self.webserver.where_is("windows/res/win1.html")) self.driver.maximize_window() def test_window_size_manipulation(self): #self.driver.get(self.webserver.where_is("windows/res/win1.html")) self.driver.set_window_size(400, 400) window_size = self.driver.get_window_size() self.assertTrue("width" in window_size) self.assertTrue("height" in window_size) self.assertEquals({"width": 400, "height":400}, window_size) """ todo: make that work see: https://w3c.github.io/webdriver/webdriver-spec.html#setwindowsize result = self.driver.set_window_size(100, 100) self.assertTrue("status" in result) self.assertEquals(result["status"], 500) """ def test_window_position_manipulation(self): #self.driver.get(self.webserver.where_is("windows/res/win1.html")) self.driver.set_window_position(400, 400) window_position = self.driver.get_window_position() self.assertTrue("x" in window_position) self.assertTrue("y" in window_position) self.assertEquals({"x": 400, "y": 400}, window_position) if __name__ == "__main__": unittest.main()
mpl-2.0
[ 3, 1882, 818, 26, 2366, 27, 5554, 13, 2301, 26, 2948, 27, 3721, 13, 2301, 26, 2948, 27, 1882, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2882, 199, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 29024, 703, 13324, 199, 646, 1300, 63, 396, 199, 504, 19481, 14, 2330, 492, 4967, 421, 199, 533, 15689, 316, 774, 8, 1095, 63, 396, 14, 27009, 23170, 304, 272, 347, 511, 63, 988, 11807, 8, 277, 304, 267, 327, 277, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 8258, 15, 470, 15, 2676, 17, 14, 1360, 2237, 267, 291, 14, 3090, 14, 988, 11807, 63, 3806, 342, 339, 347, 511, 63, 3806, 63, 890, 63, 29798, 5332, 8, 277, 304, 267, 327, 277, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 8258, 15, 470, 15, 2676, 17, 14, 1360, 2237, 267, 291, 14, 3090, 14, 409, 63, 3806, 63, 890, 8, 5303, 12, 8290, 9, 267, 4353, 63, 890, 275, 291, 14, 3090, 14, 362, 63, 3806, 63, 890, 342, 267, 291, 14, 1815, 480, 2063, 2, 315, 4353, 63, 890, 9, 267, 291, 14, 1815, 480, 3333, 2, 315, 4353, 63, 890, 9, 267, 291, 14, 2947, 6333, 2063, 582, 8290, 12, 298, 3333, 582, 5303, 1386, 4353, 63, 890, 9, 398, 408, 267, 11386, 26, 1852, 626, 1736, 267, 1937, 26, 4178, 921, 87, 19, 67, 14, 5031, 14, 2308, 15, 17946, 15, 17946, 13, 1650, 14, 1360, 3, 409, 3806, 890, 355, 754, 275, 291, 14, 3090, 14, 409, 63, 3806, 63, 890, 8, 1960, 12, 2948, 9, 355, 291, 14, 1815, 480, 1205, 2, 315, 754, 9, 355, 291, 14, 2947, 8, 1099, 905, 1205, 2255, 6891, 9, 267, 408, 339, 347, 511, 63, 3806, 63, 3124, 63, 29798, 5332, 8, 277, 304, 267, 327, 277, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 8258, 15, 470, 15, 2676, 17, 14, 1360, 2237, 267, 291, 14, 3090, 14, 409, 63, 3806, 63, 3124, 8, 5303, 12, 8290, 9, 267, 4353, 63, 3124, 275, 291, 14, 3090, 14, 362, 63, 3806, 63, 3124, 342, 267, 291, 14, 1815, 480, 88, 2, 315, 4353, 63, 3124, 9, 267, 291, 14, 1815, 480, 89, 2, 315, 4353, 63, 3124, 9, 267, 291, 14, 2947, 6333, 88, 582, 8290, 12, 298, 89, 582, 8290, 1386, 4353, 63, 3124, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 818, 26, 2366, 27, 5554, 13, 2301, 26, 2948, 27, 3721, 13, 2301, 26, 2948, 27, 1882, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2882, 199, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 29024, 703, 13324, 199, 646, 1300, 63, 396, 199, 504, 19481, 14, 2330, 492, 4967, 421, 199, 533, 15689, 316, 774, 8, 1095, 63, 396, 14, 27009, 23170, 304, 272, 347, 511, 63, 988, 11807, 8, 277, 304, 267, 327, 277, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 8258, 15, 470, 15, 2676, 17, 14, 1360, 2237, 267, 291, 14, 3090, 14, 988, 11807, 63, 3806, 342, 339, 347, 511, 63, 3806, 63, 890, 63, 29798, 5332, 8, 277, 304, 267, 327, 277, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 8258, 15, 470, 15, 2676, 17, 14, 1360, 2237, 267, 291, 14, 3090, 14, 409, 63, 3806, 63, 890, 8, 5303, 12, 8290, 9, 267, 4353, 63, 890, 275, 291, 14, 3090, 14, 362, 63, 3806, 63, 890, 342, 267, 291, 14, 1815, 480, 2063, 2, 315, 4353, 63, 890, 9, 267, 291, 14, 1815, 480, 3333, 2, 315, 4353, 63, 890, 9, 267, 291, 14, 2947, 6333, 2063, 582, 8290, 12, 298, 3333, 582, 5303, 1386, 4353, 63, 890, 9, 398, 408, 267, 11386, 26, 1852, 626, 1736, 267, 1937, 26, 4178, 921, 87, 19, 67, 14, 5031, 14, 2308, 15, 17946, 15, 17946, 13, 1650, 14, 1360, 3, 409, 3806, 890, 355, 754, 275, 291, 14, 3090, 14, 409, 63, 3806, 63, 890, 8, 1960, 12, 2948, 9, 355, 291, 14, 1815, 480, 1205, 2, 315, 754, 9, 355, 291, 14, 2947, 8, 1099, 905, 1205, 2255, 6891, 9, 267, 408, 339, 347, 511, 63, 3806, 63, 3124, 63, 29798, 5332, 8, 277, 304, 267, 327, 277, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 8258, 15, 470, 15, 2676, 17, 14, 1360, 2237, 267, 291, 14, 3090, 14, 409, 63, 3806, 63, 3124, 8, 5303, 12, 8290, 9, 267, 4353, 63, 3124, 275, 291, 14, 3090, 14, 362, 63, 3806, 63, 3124, 342, 267, 291, 14, 1815, 480, 88, 2, 315, 4353, 63, 3124, 9, 267, 291, 14, 1815, 480, 89, 2, 315, 4353, 63, 3124, 9, 267, 291, 14, 2947, 6333, 88, 582, 8290, 12, 298, 89, 582, 8290, 1386, 4353, 63, 3124, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
shoopio/shoop
shuup/importer/admin_module/import_views.py
1
7325
# -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2019, Shoop Commerce Ltd. All rights reserved. # # This source code is licensed under the OSL-3.0 license found in the # LICENSE file in the root directory of this source tree. import hashlib import logging import os from datetime import datetime from django.contrib import messages from django.core.urlresolvers import reverse from django.db.transaction import atomic from django.http.response import Http404, HttpResponse, HttpResponseBadRequest from django.shortcuts import redirect from django.utils.translation import ugettext_lazy as _ from django.views.generic import FormView, TemplateView, View from shuup.admin.shop_provider import get_shop from shuup.importer.admin_module.forms import ImportForm, ImportSettingsForm from shuup.importer.transforms import transform_file from shuup.importer.utils import ( get_import_file_path, get_importer, get_importer_choices ) from shuup.utils.excs import Problem logger = logging.getLogger(__name__) class ImportProcessView(TemplateView): template_name = "shuup/importer/admin/import_process.jinja" importer = None def dispatch(self, request, *args, **kwargs): self.importer_cls = get_importer(request.GET.get("importer")) self.model_str = request.GET.get("importer") self.lang = request.GET.get("lang") return super(ImportProcessView, self).dispatch(request, *args, **kwargs) def _transform_request_file(self): try: filename = get_import_file_path(self.request.GET.get("n")) if not os.path.isfile(filename): raise ValueError(_("%s is not a file") % self.request.GET.get("n")) except: raise Problem(_("File missing.")) try: mode = "xls" if filename.endswith("xlsx"): mode = "xlsx" if filename.endswith("csv"): mode = "csv" if self.importer_cls.custom_file_transformer: return self.importer_cls.transform_file(mode, filename) return transform_file(mode, filename) except (Exception, RuntimeError) as e: messages.error(self.request, e) def prepare(self): self.data = self._transform_request_file() if self.data is None: return False self.importer = self.importer_cls(self.data, get_shop(self.request), self.lang) self.importer.process_data() if self.request.method == "POST": # check if mapping was done for field in self.importer.unmatched_fields: key = "remap[%s]" % field vals = self.request.POST.getlist(key) if len(vals): self.importer.manually_match(field, vals[0]) self.importer.do_remap() self.settings_form = ImportSettingsForm(data=self.request.POST if self.request.POST else None) if self.settings_form.is_bound: self.settings_form.is_valid() return True def post(self, request, *args, **kwargs): prepared = self.prepare() if not prepared: return redirect(reverse("shuup_admin:importer.import")) try: with atomic(): self.importer.do_import(self.settings_form.cleaned_data["import_mode"]) except Exception: logger.exception("Failed to import data") messages.error(request, _("Failed to import the file.")) return redirect(reverse("shuup_admin:importer.import")) self.template_name = "shuup/importer/admin/import_process_complete.jinja" return self.render_to_response(self.get_context_data(**kwargs)) def get_context_data(self, **kwargs): context = super(ImportProcessView, self).get_context_data(**kwargs) context["data"] = self.data context["importer"] = self.importer context["form"] = self.settings_form context["model_fields"] = self.importer.get_fields_for_mapping() context["visible_rows"] = self.data.rows[1:5] return context def get(self, request, *args, **kwargs): prepared = self.prepare() if not prepared: return redirect(reverse("shuup_admin:importer.import")) return self.render_to_response(self.get_context_data(**kwargs)) class ImportView(FormView): template_name = "shuup/importer/admin/import.jinja" form_class = ImportForm def post(self, request, *args, **kwargs): file = self.request.FILES["file"] basename, ext = os.path.splitext(file.name) import_name = "%s%s" % (hashlib.sha256(("%s" % datetime.now()).encode("utf-8")).hexdigest(), ext) full_path = get_import_file_path(import_name) if not os.path.isdir(os.path.dirname(full_path)): os.makedirs(os.path.dirname(full_path)) with open(full_path, 'wb+') as destination: for chunk in file.chunks(): destination.write(chunk) next_url = request.POST.get("next") importer = request.POST.get("importer") lang = request.POST.get("language") return redirect("%s?n=%s&importer=%s&lang=%s" % (next_url, import_name, importer, lang)) def get_form_kwargs(self): kwargs = super(ImportView, self).get_form_kwargs() initial = kwargs.get("initial", {}) initial["importer"] = self.request.GET.get("importer", initial.get("initial")) kwargs.update({ "request": self.request, "initial": initial }) return kwargs def get_context_data(self, **kwargs): context = super(ImportView, self).get_context_data(**kwargs) # check whether the importer has a example file template # if so, we also add a url to download the example file importer = self.request.GET.get("importer") # no importer passed, get the first choice available if not importer: importers = list(get_importer_choices()) if importers: importer = importers[0][0] if importer: importer_cls = get_importer(importer) context.update(importer_cls.get_help_context_data(self.request)) context["importer"] = importer_cls return context class ExampleFileDownloadView(View): def get(self, request, *args, **kwargs): importer = request.GET.get("importer") file_name = request.GET.get("file_name") if not importer or not file_name: return HttpResponseBadRequest(_("Invalid parameters")) importer_cls = get_importer(importer) if not importer_cls or not importer_cls.has_example_file(): raise Http404(_("Invalid importer")) example_file = importer_cls.get_example_file(file_name) if not example_file: raise Http404(_("Invalid file name")) response = HttpResponse(content_type=example_file.content_type) response['Content-Disposition'] = 'attachment; filename=%s' % example_file.file_name data = importer_cls.get_example_file_content(example_file, request) if not data: raise Http404(_("File not found")) data.seek(0) response.write(data.getvalue()) return response
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 5244, 85, 384, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 6029, 13, 14982, 12, 428, 526, 411, 5429, 25192, 12126, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 1350, 1233, 365, 18233, 1334, 314, 4403, 44, 13, 19, 14, 16, 4190, 1911, 315, 314, 199, 3, 5113, 570, 315, 314, 1738, 2082, 402, 642, 1350, 3123, 14, 199, 646, 8337, 199, 646, 2050, 199, 646, 747, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 14, 5945, 492, 15374, 199, 504, 1639, 14, 1014, 14, 1310, 492, 4760, 5188, 12, 6183, 12, 6183, 12380, 199, 504, 1639, 14, 17469, 492, 4660, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 4196, 14, 6767, 492, 8204, 2768, 12, 5458, 2768, 12, 10935, 199, 199, 504, 1033, 85, 384, 14, 2113, 14, 10568, 63, 3780, 492, 664, 63, 10568, 199, 504, 1033, 85, 384, 14, 12138, 14, 2113, 63, 578, 14, 3351, 492, 3161, 2821, 12, 3161, 5268, 2821, 199, 504, 1033, 85, 384, 14, 12138, 14, 15133, 492, 5793, 63, 493, 199, 504, 1033, 85, 384, 14, 12138, 14, 1208, 492, 334, 272, 664, 63, 646, 63, 493, 63, 515, 12, 664, 63, 12138, 12, 664, 63, 12138, 63, 4577, 199, 9, 199, 504, 1033, 85, 384, 14, 1208, 14, 476, 1259, 492, 20980, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3161, 3498, 2768, 8, 4231, 2768, 304, 272, 1978, 63, 354, 275, 298, 609, 85, 384, 15, 12138, 15, 2113, 15, 646, 63, 1412, 14, 12264, 2, 272, 13479, 275, 488, 339, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 12138, 63, 1886, 275, 664, 63, 12138, 8, 1069, 14, 2970, 14, 362, 480, 12138, 2237, 267, 291, 14, 1238, 63, 495, 275, 1056, 14, 2970, 14, 362, 480, 12138, 531, 267, 291, 14, 4159, 275, 1056, 14, 2970, 14, 362, 480, 4159, 531, 267, 372, 1613, 8, 6295, 3498, 2768, 12, 291, 680, 6052, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 485, 4711, 63, 1069, 63, 493, 8, 277, 304, 267, 862, 26, 288, 1788, 275, 664, 63, 646, 63, 493, 63, 515, 8, 277, 14, 1069, 14, 2970, 14, 362, 480, 78, 2237, 288, 340, 440, 747, 14, 515, 14, 6292, 8, 1501, 304, 355, 746, 1722, 1547, 3647, 83, 365, 440, 282, 570, 531, 450, 291, 14, 1069, 14, 2970, 14, 362, 480, 78, 2237, 267, 871, 26, 288, 746, 20980, 6115, 1173, 4124, 13853, 267, 862, 26, 288, 818, 275, 298, 19023, 2, 288, 340, 1788, 14, 4130, 480, 19023, 88, 2349, 355, 818, 275, 298, 19023, 88, 2, 288, 340, 1788, 14, 4130, 480, 4737, 2349, 355, 818, 275, 298, 4737, 2, 288, 340, 291, 14, 12138, 63, 1886, 14, 4229, 63, 493, 63, 19754, 26, 355, 372, 291, 14, 12138, 63, 1886, 14, 4711, 63, 493, 8, 632, 12, 1788, 9, 288, 372, 5793, 63, 493, 8, 632, 12, 1788, 9, 267, 871, 334, 1726, 12, 6064, 9, 465, 325, 26, 288, 3788, 14, 705, 8, 277, 14, 1069, 12, 325, 9, 339, 347, 9275, 8, 277, 304, 267, 291, 14, 576, 275, 291, 423, 4711, 63, 1069, 63, 493, 342, 267, 340, 291, 14, 576, 365, 488, 26, 288, 372, 756, 398, 291, 14, 12138, 275, 291, 14, 12138, 63, 1886, 8, 277, 14, 576, 12, 664, 63, 10568, 8, 277, 14, 1069, 395, 291, 14, 4159, 9, 267, 291, 14, 12138, 14, 1412, 63, 576, 342, 398, 340, 291, 14, 1069, 14, 765, 508, 298, 4030, 582, 288, 327, 1104, 340, 4412, 1990, 4224, 288, 367, 901, 315, 291, 14, 12138, 14, 324, 10151, 63, 955, 26, 355, 790, 275, 298, 25340, 9722, 83, 8480, 450, 901, 355, 5322, 275, 291, 14, 1069, 14, 4030, 14, 21343, 8, 498, 9, 355, 340, 822, 8, 3643, 304, 490, 291, 14, 12138, 14, 1237, 3163, 63, 1431, 8, 698, 12, 5322, 59, 16, 566, 288, 291, 14, 12138, 14, 1117, 63, 25340, 342, 398, 291, 14, 1751, 63, 964, 275, 3161, 5268, 2821, 8, 576, 29, 277, 14, 1069, 14, 4030, 340, 291, 14, 1069, 14, 4030, 587, 488, 9, 267, 340, 291, 14, 1751, 63, 964, 14, 374, 63, 3556, 26, 288, 291, 14, 1751, 63, 964, 14, 374, 63, 1078, 342, 267, 372, 715, 339, 347, 2963, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 16318, 275, 291, 14, 6726, 342, 267, 340, 440, 16318, 26, 288, 372, 4660, 8, 4471, 480, 609, 85, 384, 63, 2113, 26, 12138, 14, 646, 2237, 267, 862, 26, 288, 543, 15374, 837, 355, 291, 14, 12138, 14, 1117, 63, 646, 8, 277, 14, 1751, 63, 964, 14, 8275, 63, 576, 905, 646, 63, 632, 3135, 267, 871, 2186, 26, 288, 2512, 14, 1971, 480, 4276, 370, 492, 666, 531, 288, 3788, 14, 705, 8, 1069, 12, 3824, 4276, 370, 492, 314, 570, 13853, 288, 372, 4660, 8, 4471, 480, 609, 85, 384, 63, 2113, 26, 12138, 14, 646, 2237, 398, 291, 14, 1160, 63, 354, 275, 298, 609, 85, 384, 15, 12138, 15, 2113, 15, 646, 63, 1412, 63, 4883, 14, 12264, 2, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 277, 14, 362, 63, 1100, 63, 576, 3682, 958, 430, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 1067, 275, 1613, 8, 6295, 3498, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 1067, 905, 576, 937, 275, 291, 14, 576, 267, 1067, 905, 12138, 937, 275, 291, 14, 12138, 267, 1067, 905, 964, 937, 275, 291, 14, 1751, 63, 964, 267, 1067, 905, 1238, 63, 955, 937, 275, 291, 14, 12138, 14, 362, 63, 955, 63, 509, 63, 4745, 342, 267, 1067, 905, 6604, 63, 3838, 937, 275, 291, 14, 576, 14, 3838, 59, 17, 26, 21, 61 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 5244, 85, 384, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 6029, 13, 14982, 12, 428, 526, 411, 5429, 25192, 12126, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 1350, 1233, 365, 18233, 1334, 314, 4403, 44, 13, 19, 14, 16, 4190, 1911, 315, 314, 199, 3, 5113, 570, 315, 314, 1738, 2082, 402, 642, 1350, 3123, 14, 199, 646, 8337, 199, 646, 2050, 199, 646, 747, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 14, 5945, 492, 15374, 199, 504, 1639, 14, 1014, 14, 1310, 492, 4760, 5188, 12, 6183, 12, 6183, 12380, 199, 504, 1639, 14, 17469, 492, 4660, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 4196, 14, 6767, 492, 8204, 2768, 12, 5458, 2768, 12, 10935, 199, 199, 504, 1033, 85, 384, 14, 2113, 14, 10568, 63, 3780, 492, 664, 63, 10568, 199, 504, 1033, 85, 384, 14, 12138, 14, 2113, 63, 578, 14, 3351, 492, 3161, 2821, 12, 3161, 5268, 2821, 199, 504, 1033, 85, 384, 14, 12138, 14, 15133, 492, 5793, 63, 493, 199, 504, 1033, 85, 384, 14, 12138, 14, 1208, 492, 334, 272, 664, 63, 646, 63, 493, 63, 515, 12, 664, 63, 12138, 12, 664, 63, 12138, 63, 4577, 199, 9, 199, 504, 1033, 85, 384, 14, 1208, 14, 476, 1259, 492, 20980, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3161, 3498, 2768, 8, 4231, 2768, 304, 272, 1978, 63, 354, 275, 298, 609, 85, 384, 15, 12138, 15, 2113, 15, 646, 63, 1412, 14, 12264, 2, 272, 13479, 275, 488, 339, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 12138, 63, 1886, 275, 664, 63, 12138, 8, 1069, 14, 2970, 14, 362, 480, 12138, 2237, 267, 291, 14, 1238, 63, 495, 275, 1056, 14, 2970, 14, 362, 480, 12138, 531, 267, 291, 14, 4159, 275, 1056, 14, 2970, 14, 362, 480, 4159, 531, 267, 372, 1613, 8, 6295, 3498, 2768, 12, 291, 680, 6052, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 485, 4711, 63, 1069, 63, 493, 8, 277, 304, 267, 862, 26, 288, 1788, 275, 664, 63, 646, 63, 493, 63, 515, 8, 277, 14, 1069, 14, 2970, 14, 362, 480, 78, 2237, 288, 340, 440, 747, 14, 515, 14, 6292, 8, 1501, 304, 355, 746, 1722, 1547, 3647, 83, 365, 440, 282, 570, 531, 450, 291, 14, 1069, 14, 2970, 14, 362, 480, 78, 2237, 267, 871, 26, 288, 746, 20980, 6115, 1173, 4124, 13853, 267, 862, 26, 288, 818, 275, 298, 19023, 2, 288, 340, 1788, 14, 4130, 480, 19023, 88, 2349, 355, 818, 275, 298, 19023, 88, 2, 288, 340, 1788, 14, 4130, 480, 4737, 2349, 355, 818, 275, 298, 4737, 2, 288, 340, 291, 14, 12138, 63, 1886, 14, 4229, 63, 493, 63, 19754, 26, 355, 372, 291, 14, 12138, 63, 1886, 14, 4711, 63, 493, 8, 632, 12, 1788, 9, 288, 372, 5793, 63, 493, 8, 632, 12, 1788, 9, 267, 871, 334, 1726, 12, 6064, 9, 465, 325, 26, 288, 3788, 14, 705, 8, 277, 14, 1069, 12, 325, 9, 339, 347, 9275, 8, 277, 304, 267, 291, 14, 576, 275, 291, 423, 4711, 63, 1069, 63, 493, 342, 267, 340, 291, 14, 576, 365, 488, 26, 288, 372, 756, 398, 291, 14, 12138, 275, 291, 14, 12138, 63, 1886, 8, 277, 14, 576, 12, 664, 63, 10568, 8, 277, 14, 1069, 395, 291, 14, 4159, 9, 267, 291, 14, 12138, 14, 1412, 63, 576, 342, 398, 340, 291, 14, 1069, 14, 765, 508, 298, 4030, 582, 288, 327, 1104, 340, 4412, 1990, 4224, 288, 367, 901, 315, 291, 14, 12138, 14, 324, 10151, 63, 955, 26, 355, 790, 275, 298, 25340, 9722, 83, 8480, 450, 901, 355, 5322, 275, 291, 14, 1069, 14, 4030, 14, 21343, 8, 498, 9, 355, 340, 822, 8, 3643, 304, 490, 291, 14, 12138, 14, 1237, 3163, 63, 1431, 8, 698, 12, 5322, 59, 16, 566, 288, 291, 14, 12138, 14, 1117, 63, 25340, 342, 398, 291, 14, 1751, 63, 964, 275, 3161, 5268, 2821, 8, 576, 29, 277, 14, 1069, 14, 4030, 340, 291, 14, 1069, 14, 4030, 587, 488, 9, 267, 340, 291, 14, 1751, 63, 964, 14, 374, 63, 3556, 26, 288, 291, 14, 1751, 63, 964, 14, 374, 63, 1078, 342, 267, 372, 715, 339, 347, 2963, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 16318, 275, 291, 14, 6726, 342, 267, 340, 440, 16318, 26, 288, 372, 4660, 8, 4471, 480, 609, 85, 384, 63, 2113, 26, 12138, 14, 646, 2237, 267, 862, 26, 288, 543, 15374, 837, 355, 291, 14, 12138, 14, 1117, 63, 646, 8, 277, 14, 1751, 63, 964, 14, 8275, 63, 576, 905, 646, 63, 632, 3135, 267, 871, 2186, 26, 288, 2512, 14, 1971, 480, 4276, 370, 492, 666, 531, 288, 3788, 14, 705, 8, 1069, 12, 3824, 4276, 370, 492, 314, 570, 13853, 288, 372, 4660, 8, 4471, 480, 609, 85, 384, 63, 2113, 26, 12138, 14, 646, 2237, 398, 291, 14, 1160, 63, 354, 275, 298, 609, 85, 384, 15, 12138, 15, 2113, 15, 646, 63, 1412, 63, 4883, 14, 12264, 2, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 277, 14, 362, 63, 1100, 63, 576, 3682, 958, 430, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 1067, 275, 1613, 8, 6295, 3498, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 1067, 905, 576, 937, 275, 291, 14, 576, 267, 1067, 905, 12138, 937, 275, 291, 14, 12138, 267, 1067, 905, 964, 937, 275, 291, 14, 1751, 63, 964, 267, 1067, 905, 1238, 63, 955, 937, 275, 291, 14, 12138, 14, 362, 63, 955, 63, 509, 63, 4745, 342, 267, 1067, 905, 6604, 63, 3838, 937, 275, 291, 14, 576, 14, 3838, 59, 17, 26, 21, 61, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
davidcusatis/horizon
openstack_dashboard/dashboards/admin/volumes/volumes/forms.py
12
10196
# Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, 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. from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import forms from horizon import messages from horizon.utils import validators as utils_validators from openstack_dashboard.api import cinder from openstack_dashboard.dashboards.admin.volumes.snapshots.forms \ import populate_status_choices from openstack_dashboard.dashboards.project.volumes.volumes \ import forms as project_forms # This set of states was pulled from cinder's admin_actions.py STATUS_CHOICES = ( ('attaching', _('Attaching')), ('available', _('Available')), ('creating', _('Creating')), ('deleting', _('Deleting')), ('detaching', _('Detaching')), ('error', _('Error')), ('error_deleting', _('Error Deleting')), ('in-use', _('In Use')), ('maintenance', _('Maintenance')), ) class ManageVolume(forms.SelfHandlingForm): identifier = forms.CharField( max_length=255, label=_("Identifier"), help_text=_("Name or other identifier for existing volume")) id_type = forms.ChoiceField( label=_("Identifier Type"), help_text=_("Type of backend device identifier provided")) host = forms.CharField( max_length=255, label=_("Host"), help_text=_("Cinder host on which the existing volume resides; " "takes the form: host@backend-name#pool")) name = forms.CharField( max_length=255, label=_("Volume Name"), required=False, help_text=_("Volume name to be assigned")) description = forms.CharField(max_length=255, widget=forms.Textarea( attrs={'rows': 4}), label=_("Description"), required=False) metadata = forms.CharField(max_length=255, widget=forms.Textarea( attrs={'rows': 2}), label=_("Metadata"), required=False, help_text=_("Comma-separated key=value pairs"), validators=[utils_validators.validate_metadata]) volume_type = forms.ChoiceField( label=_("Volume Type"), required=False) availability_zone = forms.ChoiceField( label=_("Availability Zone"), required=False) bootable = forms.BooleanField( label=_("Bootable"), required=False, help_text=_("Specifies that the newly created volume " "should be marked as bootable")) def __init__(self, request, *args, **kwargs): super(ManageVolume, self).__init__(request, *args, **kwargs) self.fields['id_type'].choices = [("source-name", _("Name"))] + \ [("source-id", _("ID"))] volume_types = cinder.volume_type_list(request) self.fields['volume_type'].choices = [("", _("No volume type"))] + \ [(type.name, type.name) for type in volume_types] self.fields['availability_zone'].choices = \ project_forms.availability_zones(request) def handle(self, request, data): try: az = data.get('availability_zone') # assume user enters metadata with "key1=val1,key2=val2" # convert to dictionary metadataDict = {} metadata = data.get('metadata') if metadata: metadata.replace(" ", "") for item in metadata.split(','): key, value = item.split('=') metadataDict[key] = value cinder.volume_manage(request, host=data['host'], identifier=data['identifier'], id_type=data['id_type'], name=data['name'], description=data['description'], volume_type=data['volume_type'], availability_zone=az, metadata=metadataDict, bootable=data['bootable']) # for success message, use identifier if user does not # provide a volume name volume_name = data['name'] if not volume_name: volume_name = data['identifier'] messages.success( request, _('Successfully sent the request to manage volume: %s') % volume_name) return True except Exception: redirect = reverse("horizon:admin:volumes:index") exceptions.handle(request, _("Unable to manage volume."), redirect=redirect) class UnmanageVolume(forms.SelfHandlingForm): name = forms.CharField(label=_("Volume Name"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) host = forms.CharField(label=_("Host"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) volume_id = forms.CharField(label=_("ID"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) def handle(self, request, data): try: cinder.volume_unmanage(request, self.initial['volume_id']) messages.success( request, _('Successfully sent the request to unmanage volume: %s') % data['name']) return True except Exception: redirect = reverse("horizon:admin:volumes:index") exceptions.handle(request, _("Unable to unmanage volume."), redirect=redirect) class MigrateVolume(forms.SelfHandlingForm): name = forms.CharField(label=_("Volume Name"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) current_host = forms.CharField(label=_("Current Host"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) host = forms.ChoiceField(label=_("Destination Host"), help_text=_("Choose a Host to migrate to.")) force_host_copy = forms.BooleanField(label=_("Force Host Copy"), initial=False, required=False) def __init__(self, request, *args, **kwargs): super(MigrateVolume, self).__init__(request, *args, **kwargs) initial = kwargs.get('initial', {}) self.fields['host'].choices = self.populate_host_choices(request, initial) def populate_host_choices(self, request, initial): hosts = initial.get('hosts') current_host = initial.get('current_host') host_list = [(host.name, host.name) for host in hosts if host.name != current_host] if host_list: host_list.insert(0, ("", _("Select a new host"))) else: host_list.insert(0, ("", _("No other hosts available"))) return sorted(host_list) def handle(self, request, data): try: cinder.volume_migrate(request, self.initial['volume_id'], data['host'], data['force_host_copy']) messages.success( request, _('Successfully sent the request to migrate volume: %s') % data['name']) return True except Exception: redirect = reverse("horizon:admin:volumes:volumes_tab") exceptions.handle(request, _("Failed to migrate volume."), redirect=redirect) class UpdateStatus(forms.SelfHandlingForm): status = forms.ChoiceField(label=_("Status")) def __init__(self, request, *args, **kwargs): super(UpdateStatus, self).__init__(request, *args, **kwargs) initial = kwargs.get('initial', {}) self.fields['status'].choices = ( populate_status_choices(initial, STATUS_CHOICES)) def handle(self, request, data): # Obtain the localized status for including in the message for choice in self.fields['status'].choices: if choice[0] == data['status']: new_status = choice[1] break else: new_status = data['status'] try: cinder.volume_reset_state(request, self.initial['volume_id'], data['status']) messages.success(request, _('Successfully updated volume status to "%s".') % new_status) return True except Exception: redirect = reverse("horizon:admin:volumes:index") exceptions.handle(request, _('Unable to update volume status to "%s".') % new_status, redirect=redirect)
apache-2.0
[ 3, 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 3788, 199, 504, 21726, 14, 1208, 492, 14370, 465, 3778, 63, 11346, 199, 199, 504, 13869, 63, 9743, 14, 1246, 492, 13069, 199, 504, 13869, 63, 9743, 14, 30424, 14, 2113, 14, 8838, 14, 15331, 14, 3351, 971, 272, 492, 13904, 63, 1205, 63, 4577, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 8838, 14, 8838, 971, 272, 492, 4513, 465, 2199, 63, 3351, 421, 199, 3, 961, 663, 402, 6363, 1990, 25239, 1146, 687, 13069, 1159, 4628, 63, 3723, 14, 647, 199, 6305, 63, 16236, 275, 334, 272, 661, 5040, 316, 297, 4018, 13240, 316, 3855, 272, 661, 4561, 297, 4018, 11464, 3855, 272, 661, 20358, 297, 4018, 14380, 3855, 272, 661, 7346, 1337, 297, 4018, 22001, 3855, 272, 661, 14481, 316, 297, 4018, 21097, 23302, 3855, 272, 661, 705, 297, 4018, 547, 3855, 272, 661, 705, 63, 7346, 1337, 297, 4018, 547, 15920, 3855, 272, 661, 262, 13, 1180, 297, 4018, 607, 3645, 3855, 272, 661, 19725, 297, 4018, 6756, 12182, 3855, 199, 9, 421, 199, 533, 14944, 6464, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 5148, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 7544, 1288, 267, 1720, 63, 505, 9384, 985, 503, 1163, 5148, 367, 3411, 3301, 2237, 272, 1305, 63, 466, 275, 4513, 14, 15792, 8, 267, 1768, 9384, 7544, 2434, 1288, 267, 1720, 63, 505, 9384, 804, 402, 4865, 2243, 5148, 2741, 2237, 272, 1591, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 4965, 1288, 267, 1720, 63, 505, 9384, 35, 5755, 1591, 641, 1314, 314, 3411, 3301, 295, 19564, 27, 298, 490, 298, 31613, 314, 1824, 26, 1591, 32, 4620, 13, 354, 3, 2293, 2237, 272, 536, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 6464, 2812, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6464, 536, 370, 506, 7943, 2237, 272, 1369, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 841, 8688, 267, 1768, 9384, 5831, 1288, 1415, 29, 797, 9, 272, 3341, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 499, 8688, 267, 1768, 9384, 5142, 1288, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 25732, 13, 12794, 790, 29, 585, 6342, 1288, 267, 14370, 1524, 1208, 63, 11346, 14, 3502, 63, 2343, 566, 272, 3301, 63, 466, 275, 4513, 14, 15792, 8, 267, 1768, 9384, 6464, 2434, 1288, 267, 1415, 29, 797, 9, 272, 14962, 63, 2619, 275, 4513, 14, 15792, 8, 267, 1768, 9384, 26462, 22518, 1288, 267, 1415, 29, 797, 9, 339, 8498, 461, 275, 4513, 14, 5036, 8, 267, 1768, 9384, 17989, 461, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6154, 5604, 626, 314, 13903, 2737, 3301, 298, 490, 298, 5626, 506, 11584, 465, 8498, 461, 2237, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 20588, 6464, 12, 291, 2843, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 291, 14, 955, 459, 344, 63, 466, 2278, 4577, 275, 10003, 1365, 13, 354, 401, 3824, 985, 2237, 61, 435, 971, 1460, 10003, 1365, 13, 344, 401, 3824, 998, 2237, 61, 267, 3301, 63, 1313, 275, 13069, 14, 2405, 63, 466, 63, 513, 8, 1069, 9, 267, 291, 14, 955, 459, 2405, 63, 466, 2278, 4577, 275, 3842, 5151, 3824, 1944, 3301, 730, 2237, 61, 435, 971, 6163, 3842, 466, 14, 354, 12, 730, 14, 354, 9, 6343, 367, 730, 315, 3301, 63, 1313, 61, 267, 291, 14, 955, 459, 11856, 63, 2619, 2278, 4577, 275, 971, 288, 2199, 63, 3351, 14, 11856, 63, 13325, 8, 1069, 9, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 862, 26, 288, 24978, 275, 666, 14, 362, 360, 11856, 63, 2619, 358, 953, 327, 5534, 922, 655, 878, 3341, 543, 298, 498, 17, 29, 637, 17, 12, 498, 18, 29, 637, 18, 2, 288, 327, 3957, 370, 2600, 288, 3341, 2141, 275, 1052, 288, 3341, 275, 666, 14, 362, 360, 2343, 358, 288, 340, 3341, 26, 355, 3341, 14, 1814, 480, 3872, 6899, 355, 367, 1242, 315, 3341, 14, 1294, 25908, 490, 790, 12, 574, 275, 1242, 14, 1294, 23917, 490, 3341, 2141, 59, 498, 61, 275, 574, 953, 13069, 14, 2405, 63, 9053, 8, 1069, 12, 639, 1591, 29, 576, 459, 1102, 995, 639, 5148, 29, 576, 459, 5364, 995, 639, 1305, 63, 466, 29, 576, 459, 344, 63, 466, 995, 639, 536, 29, 576, 459, 354, 995, 639, 1369, 29, 576, 459, 1802, 995, 639, 3301, 63, 466, 29, 576, 459, 2405, 63 ]
[ 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 3788, 199, 504, 21726, 14, 1208, 492, 14370, 465, 3778, 63, 11346, 199, 199, 504, 13869, 63, 9743, 14, 1246, 492, 13069, 199, 504, 13869, 63, 9743, 14, 30424, 14, 2113, 14, 8838, 14, 15331, 14, 3351, 971, 272, 492, 13904, 63, 1205, 63, 4577, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 8838, 14, 8838, 971, 272, 492, 4513, 465, 2199, 63, 3351, 421, 199, 3, 961, 663, 402, 6363, 1990, 25239, 1146, 687, 13069, 1159, 4628, 63, 3723, 14, 647, 199, 6305, 63, 16236, 275, 334, 272, 661, 5040, 316, 297, 4018, 13240, 316, 3855, 272, 661, 4561, 297, 4018, 11464, 3855, 272, 661, 20358, 297, 4018, 14380, 3855, 272, 661, 7346, 1337, 297, 4018, 22001, 3855, 272, 661, 14481, 316, 297, 4018, 21097, 23302, 3855, 272, 661, 705, 297, 4018, 547, 3855, 272, 661, 705, 63, 7346, 1337, 297, 4018, 547, 15920, 3855, 272, 661, 262, 13, 1180, 297, 4018, 607, 3645, 3855, 272, 661, 19725, 297, 4018, 6756, 12182, 3855, 199, 9, 421, 199, 533, 14944, 6464, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 5148, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 7544, 1288, 267, 1720, 63, 505, 9384, 985, 503, 1163, 5148, 367, 3411, 3301, 2237, 272, 1305, 63, 466, 275, 4513, 14, 15792, 8, 267, 1768, 9384, 7544, 2434, 1288, 267, 1720, 63, 505, 9384, 804, 402, 4865, 2243, 5148, 2741, 2237, 272, 1591, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 4965, 1288, 267, 1720, 63, 505, 9384, 35, 5755, 1591, 641, 1314, 314, 3411, 3301, 295, 19564, 27, 298, 490, 298, 31613, 314, 1824, 26, 1591, 32, 4620, 13, 354, 3, 2293, 2237, 272, 536, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 6464, 2812, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6464, 536, 370, 506, 7943, 2237, 272, 1369, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 841, 8688, 267, 1768, 9384, 5831, 1288, 1415, 29, 797, 9, 272, 3341, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 499, 8688, 267, 1768, 9384, 5142, 1288, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 25732, 13, 12794, 790, 29, 585, 6342, 1288, 267, 14370, 1524, 1208, 63, 11346, 14, 3502, 63, 2343, 566, 272, 3301, 63, 466, 275, 4513, 14, 15792, 8, 267, 1768, 9384, 6464, 2434, 1288, 267, 1415, 29, 797, 9, 272, 14962, 63, 2619, 275, 4513, 14, 15792, 8, 267, 1768, 9384, 26462, 22518, 1288, 267, 1415, 29, 797, 9, 339, 8498, 461, 275, 4513, 14, 5036, 8, 267, 1768, 9384, 17989, 461, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6154, 5604, 626, 314, 13903, 2737, 3301, 298, 490, 298, 5626, 506, 11584, 465, 8498, 461, 2237, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 20588, 6464, 12, 291, 2843, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 291, 14, 955, 459, 344, 63, 466, 2278, 4577, 275, 10003, 1365, 13, 354, 401, 3824, 985, 2237, 61, 435, 971, 1460, 10003, 1365, 13, 344, 401, 3824, 998, 2237, 61, 267, 3301, 63, 1313, 275, 13069, 14, 2405, 63, 466, 63, 513, 8, 1069, 9, 267, 291, 14, 955, 459, 2405, 63, 466, 2278, 4577, 275, 3842, 5151, 3824, 1944, 3301, 730, 2237, 61, 435, 971, 6163, 3842, 466, 14, 354, 12, 730, 14, 354, 9, 6343, 367, 730, 315, 3301, 63, 1313, 61, 267, 291, 14, 955, 459, 11856, 63, 2619, 2278, 4577, 275, 971, 288, 2199, 63, 3351, 14, 11856, 63, 13325, 8, 1069, 9, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 862, 26, 288, 24978, 275, 666, 14, 362, 360, 11856, 63, 2619, 358, 953, 327, 5534, 922, 655, 878, 3341, 543, 298, 498, 17, 29, 637, 17, 12, 498, 18, 29, 637, 18, 2, 288, 327, 3957, 370, 2600, 288, 3341, 2141, 275, 1052, 288, 3341, 275, 666, 14, 362, 360, 2343, 358, 288, 340, 3341, 26, 355, 3341, 14, 1814, 480, 3872, 6899, 355, 367, 1242, 315, 3341, 14, 1294, 25908, 490, 790, 12, 574, 275, 1242, 14, 1294, 23917, 490, 3341, 2141, 59, 498, 61, 275, 574, 953, 13069, 14, 2405, 63, 9053, 8, 1069, 12, 639, 1591, 29, 576, 459, 1102, 995, 639, 5148, 29, 576, 459, 5364, 995, 639, 1305, 63, 466, 29, 576, 459, 344, 63, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
navotsil/Open-Knesset
laws/migrations/0027_auto__add_candidatelistvotingstatistics.py
14
36983
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): depends_on = ( ('polyorg','0001_initial'), ) def forwards(self, orm): # Adding model 'CandidateListVotingStatistics' db.create_table('laws_candidatelistvotingstatistics', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('candidates_list', self.gf('django.db.models.fields.related.OneToOneField')(related_name='voting_statistics', unique=True, to=orm['polyorg.CandidateList'])), )) db.send_create_signal('laws', ['CandidateListVotingStatistics']) def backwards(self, orm): # Deleting model 'CandidateListVotingStatistics' db.delete_table('laws_candidatelistvotingstatistics') models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, u'auth.permission': { 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, u'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, u'committees.committee': { 'Meta': {'object_name': 'Committee'}, 'aliases': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'chairpersons': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'chaired_committees'", 'blank': 'True', 'to': u"orm['mks.Member']"}), 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'members': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'committees'", 'blank': 'True', 'to': u"orm['mks.Member']"}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'portal_knesset_broadcasts_url': ('django.db.models.fields.URLField', [], {'max_length': '1000', 'blank': 'True'}), 'replacements': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'replacing_in_committees'", 'blank': 'True', 'to': u"orm['mks.Member']"}), 'type': ('django.db.models.fields.CharField', [], {'default': "'committee'", 'max_length': '10'}) }, u'committees.committeemeeting': { 'Meta': {'ordering': "('-date',)", 'object_name': 'CommitteeMeeting'}, 'committee': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'meetings'", 'to': u"orm['committees.Committee']"}), 'date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}), 'date_string': ('django.db.models.fields.CharField', [], {'max_length': '256'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'mks_attended': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'committee_meetings'", 'symmetrical': 'False', 'to': u"orm['mks.Member']"}), 'protocol_text': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'src_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'topics': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'votes_mentioned': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'committee_meetings'", 'blank': 'True', 'to': u"orm['laws.Vote']"}) }, u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, u'events.event': { 'Meta': {'object_name': 'Event'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'what': ('django.db.models.fields.TextField', [], {}), 'when': ('django.db.models.fields.DateTimeField', [], {}), 'when_over': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'when_over_guessed': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'where': ('django.db.models.fields.TextField', [], {'default': "u'earth'"}), 'which_pk': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'which_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'event_for_event'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}), 'who': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['persons.Person']", 'null': 'True', 'symmetrical': 'False'}), 'why': ('django.db.models.fields.TextField', [], {'null': 'True'}) }, u'laws.bill': { 'Meta': {'ordering': "('-stage_date', '-id')", 'object_name': 'Bill'}, 'approval_vote': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'bill_approved'", 'unique': 'True', 'null': 'True', 'to': u"orm['laws.Vote']"}), 'first_committee_meetings': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'bills_first'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['committees.CommitteeMeeting']"}), 'first_vote': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'bills_first'", 'null': 'True', 'to': u"orm['laws.Vote']"}), 'full_title': ('django.db.models.fields.CharField', [], {'max_length': '2000', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'joiners': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'bills_joined'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['mks.Member']"}), 'law': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'bills'", 'null': 'True', 'to': u"orm['laws.Law']"}), 'popular_name': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'}), 'popular_name_slug': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'}), 'pre_votes': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'bills_pre_votes'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['laws.Vote']"}), 'proposers': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'bills'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['mks.Member']"}), 'second_committee_meetings': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'bills_second'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['committees.CommitteeMeeting']"}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '1000'}), 'stage': ('django.db.models.fields.CharField', [], {'max_length': '10'}), 'stage_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}) }, u'laws.billbudgetestimation': { 'Meta': {'unique_together': "(('bill', 'estimator'),)", 'object_name': 'BillBudgetEstimation'}, 'bill': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'budget_ests'", 'to': u"orm['laws.Bill']"}), 'estimator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'budget_ests'", 'null': 'True', 'to': u"orm['auth.User']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'one_time_ext': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'one_time_gov': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'summary': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'time': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'yearly_ext': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'yearly_gov': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, u'laws.candidatelistvotingstatistics': { 'Meta': {'object_name': 'CandidateListVotingStatistics'}, 'candidates_list': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'voting_statistics'", 'unique': 'True', 'to': u"orm['polyorg.CandidateList']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, u'laws.govlegislationcommitteedecision': { 'Meta': {'object_name': 'GovLegislationCommitteeDecision'}, 'bill': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'gov_decisions'", 'null': 'True', 'to': u"orm['laws.Bill']"}), 'date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'source_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'stand': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'subtitle': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'text': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}) }, u'laws.govproposal': { 'Meta': {'object_name': 'GovProposal'}, 'bill': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'gov_proposal'", 'unique': 'True', 'null': 'True', 'to': u"orm['laws.Bill']"}), 'booklet_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'committee_meetings': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "u'laws_govproposal_related'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['committees.CommitteeMeeting']"}), 'content_html': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}), 'date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'knesset_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'law': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "u'laws_govproposal_related'", 'null': 'True', 'to': u"orm['laws.Law']"}), 'source_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}), 'votes': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "u'laws_govproposal_related'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['laws.Vote']"}) }, u'laws.knessetproposal': { 'Meta': {'object_name': 'KnessetProposal'}, 'bill': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'knesset_proposal'", 'unique': 'True', 'null': 'True', 'to': u"orm['laws.Bill']"}), 'booklet_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'committee': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'bills'", 'null': 'True', 'to': u"orm['committees.Committee']"}), 'committee_meetings': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "u'laws_knessetproposal_related'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['committees.CommitteeMeeting']"}), 'content_html': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}), 'date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'knesset_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'law': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "u'laws_knessetproposal_related'", 'null': 'True', 'to': u"orm['laws.Law']"}), 'originals': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'knesset_proposals'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['laws.PrivateProposal']"}), 'source_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}), 'votes': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "u'laws_knessetproposal_related'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['laws.Vote']"}) }, u'laws.law': { 'Meta': {'object_name': 'Law'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'merged_into': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'duplicates'", 'null': 'True', 'to': u"orm['laws.Law']"}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}) }, u'laws.membervotingstatistics': { 'Meta': {'object_name': 'MemberVotingStatistics'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'member': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'voting_statistics'", 'unique': 'True', 'to': u"orm['mks.Member']"}) }, u'laws.partyvotingstatistics': { 'Meta': {'object_name': 'PartyVotingStatistics'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'party': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'voting_statistics'", 'unique': 'True', 'to': u"orm['mks.Party']"}) }, u'laws.privateproposal': { 'Meta': {'object_name': 'PrivateProposal'}, 'bill': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'proposals'", 'null': 'True', 'to': u"orm['laws.Bill']"}), 'committee_meetings': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "u'laws_privateproposal_related'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['committees.CommitteeMeeting']"}), 'content_html': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}), 'date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'joiners': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'proposals_joined'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['mks.Member']"}), 'knesset_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'law': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "u'laws_privateproposal_related'", 'null': 'True', 'to': u"orm['laws.Law']"}), 'proposal_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'proposers': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'proposals_proposed'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['mks.Member']"}), 'source_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}), 'votes': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "u'laws_privateproposal_related'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['laws.Vote']"}) }, u'laws.vote': { 'Meta': {'ordering': "('-time', '-id')", 'object_name': 'Vote'}, 'against_coalition': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_opposition': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_own_bill': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_party': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_votes_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'controversy': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'for_votes_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'full_text': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'full_text_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'importance': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'meeting_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'src_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'src_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'summary': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'time': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), 'time_string': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}), 'vote_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'votes': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'votes'", 'blank': 'True', 'through': u"orm['laws.VoteAction']", 'to': u"orm['mks.Member']"}), 'votes_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, u'laws.voteaction': { 'Meta': {'object_name': 'VoteAction'}, 'against_coalition': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'against_opposition': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'against_own_bill': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'against_party': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'member': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Member']"}), 'type': ('django.db.models.fields.CharField', [], {'max_length': '10'}), 'vote': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['laws.Vote']"}) }, u'mks.knesset': { 'Meta': {'object_name': 'Knesset'}, 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'number': ('django.db.models.fields.IntegerField', [], {'primary_key': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}) }, u'mks.member': { 'Meta': {'ordering': "['name']", 'object_name': 'Member'}, 'area_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'average_monthly_committee_presence': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'average_weekly_presence_hours': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'backlinks_enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'bills_stats_approved': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'bills_stats_first': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'bills_stats_pre': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'bills_stats_proposed': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'blog': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['planet.Blog']", 'unique': 'True', 'null': 'True', 'blank': 'True'}), 'current_party': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'members'", 'null': 'True', 'to': u"orm['mks.Party']"}), 'current_position': ('django.db.models.fields.PositiveIntegerField', [], {'default': '999', 'blank': 'True'}), 'current_role_descriptions': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'date_of_death': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'family_status': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), 'fax': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'gender': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'img_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}), 'is_current': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'number_of_children': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'parties': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'all_members'", 'symmetrical': 'False', 'through': u"orm['mks.Membership']", 'to': u"orm['mks.Party']"}), 'phone': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'place_of_birth': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lat': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lon': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'residence_centrality': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'residence_economy': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}), 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'year_of_aliyah': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, u'mks.membership': { 'Meta': {'object_name': 'Membership'}, 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'member': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Member']"}), 'party': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Party']"}), 'position': ('django.db.models.fields.PositiveIntegerField', [], {'default': '999', 'blank': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}) }, u'mks.party': { 'Meta': {'ordering': "('-number_of_seats',)", 'unique_together': "(('knesset', 'name'),)", 'object_name': 'Party'}, 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_coalition': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'knesset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'parties'", 'null': 'True', 'to': u"orm['mks.Knesset']"}), 'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'number_of_members': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'number_of_seats': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}) }, u'persons.person': { 'Meta': {'ordering': "('name',)", 'object_name': 'Person'}, 'area_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'date_of_death': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), 'family_status': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), 'fax': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'gender': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'img_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}), 'mk': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'person'", 'null': 'True', 'to': u"orm['mks.Member']"}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'number_of_children': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'phone': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'place_of_birth': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lat': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lon': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'residence_centrality': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'residence_economy': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'titles': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'persons'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['persons.Title']"}), 'year_of_aliyah': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, u'persons.title': { 'Meta': {'object_name': 'Title'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}) }, u'planet.blog': { 'Meta': {'ordering': "('title', 'url')", 'object_name': 'Blog'}, 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'url': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '1024', 'db_index': 'True'}) }, u'polyorg.candidate': { 'Meta': {'ordering': "('ordinal',)", 'object_name': 'Candidate'}, 'candidates_list': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['polyorg.CandidateList']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ordinal': ('django.db.models.fields.IntegerField', [], {}), 'party': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['polyorg.Party']", 'null': 'True', 'blank': 'True'}), 'person': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['persons.Person']"}), 'votes': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, u'polyorg.candidatelist': { 'Meta': {'object_name': 'CandidateList'}, 'ballot': ('django.db.models.fields.CharField', [], {'max_length': '4'}), 'candidates': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['persons.Person']", 'null': 'True', 'through': u"orm['polyorg.Candidate']", 'blank': 'True'}), 'facebook_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'img_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}), 'mpg_html_report': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}), 'number_of_seats': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'platform': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'surplus_partner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['polyorg.CandidateList']", 'null': 'True', 'blank': 'True'}), 'twitter_account': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}), 'wikipedia_page': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}), 'youtube_user': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}) }, u'polyorg.party': { 'Meta': {'object_name': 'Party'}, 'accepts_memberships': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}) }, u'tagging.tag': { 'Meta': {'ordering': "('name',)", 'object_name': 'Tag'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}) }, u'tagging.taggeditem': { 'Meta': {'unique_together': "(('tag', 'content_type', 'object_id'),)", 'object_name': 'TaggedItem'}, 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'to': u"orm['tagging.Tag']"}) } } complete_apps = ['laws']
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 8350, 63, 265, 275, 334, 267, 661, 6023, 1308, 1673, 4183, 63, 2747, 659, 272, 776, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 26925, 1296, 54, 15866, 20750, 7, 267, 1592, 14, 981, 63, 1224, 360, 416, 3569, 63, 9007, 513, 86, 15866, 13724, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 16389, 63, 513, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 2407, 63, 354, 534, 86, 15866, 63, 13724, 297, 3747, 29, 549, 12, 370, 29, 1025, 459, 6023, 1308, 14, 26925, 1296, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 416, 3569, 297, 788, 26925, 1296, 54, 15866, 20750, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 26925, 1296, 54, 15866, 20750, 7, 267, 1592, 14, 1807, 63, 1224, 360, 416, 3569, 63, 9007, 513, 86, 15866, 13724, 358, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 3543, 266, 397, 14, 3543, 15557, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 11421, 15557, 2267, 288, 283, 8602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 335, 8387, 32146, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 3546, 335, 5789, 581, 63, 3543, 266, 397, 4662, 283, 2500, 356, 283, 549, 297, 283, 475 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 8350, 63, 265, 275, 334, 267, 661, 6023, 1308, 1673, 4183, 63, 2747, 659, 272, 776, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 26925, 1296, 54, 15866, 20750, 7, 267, 1592, 14, 981, 63, 1224, 360, 416, 3569, 63, 9007, 513, 86, 15866, 13724, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 16389, 63, 513, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 2407, 63, 354, 534, 86, 15866, 63, 13724, 297, 3747, 29, 549, 12, 370, 29, 1025, 459, 6023, 1308, 14, 26925, 1296, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 416, 3569, 297, 788, 26925, 1296, 54, 15866, 20750, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 26925, 1296, 54, 15866, 20750, 7, 267, 1592, 14, 1807, 63, 1224, 360, 416, 3569, 63, 9007, 513, 86, 15866, 13724, 358, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 3543, 266, 397, 14, 3543, 15557, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 11421, 15557, 2267, 288, 283, 8602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 335, 8387, 32146, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 3546, 335, 5789, 581, 63, 3543, 266, 397, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
manjunaths/tensorflow
tensorflow/contrib/learn/python/learn/estimators/dynamic_rnn_estimator_test.py
11
32370
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # 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. # ============================================================================== """Tests for learn.estimators.dynamic_rnn_estimator.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import tempfile # TODO: #6568 Remove this hack that makes dlopen() not crash. if hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags'): import ctypes sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL) import numpy as np from tensorflow.contrib import rnn from tensorflow.contrib.layers.python.layers import feature_column from tensorflow.contrib.layers.python.layers import target_column as target_column_lib from tensorflow.contrib.learn.python.learn.estimators import dynamic_rnn_estimator from tensorflow.contrib.learn.python.learn.estimators import model_fn as model_fn_lib from tensorflow.contrib.learn.python.learn.estimators import run_config from tensorflow.contrib.rnn.python.ops import core_rnn_cell_impl from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import random_seed from tensorflow.python.framework import sparse_tensor from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import functional_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test class IdentityRNNCell(rnn.RNNCell): def __init__(self, state_size, output_size): self._state_size = state_size self._output_size = output_size @property def state_size(self): return self._state_size @property def output_size(self): return self._output_size def __call__(self, inputs, state): return array_ops.identity(inputs), array_ops.ones( [array_ops.shape(inputs)[0], self.state_size]) class MockTargetColumn(object): def __init__(self, num_label_columns=None): self._num_label_columns = num_label_columns def get_eval_ops(self, features, activations, labels, metrics): raise NotImplementedError( 'MockTargetColumn.get_eval_ops called unexpectedly.') def logits_to_predictions(self, flattened_activations, proba=False): raise NotImplementedError( 'MockTargetColumn.logits_to_predictions called unexpectedly.') def loss(self, activations, labels, features): raise NotImplementedError('MockTargetColumn.loss called unexpectedly.') @property def num_label_columns(self): if self._num_label_columns is None: raise ValueError('MockTargetColumn.num_label_columns has not been set.') return self._num_label_columns def set_num_label_columns(self, n): self._num_label_columns = n def sequence_length_mask(values, lengths): masked = values for i, length in enumerate(lengths): masked[i, length:, :] = np.zeros_like(masked[i, length:, :]) return masked class DynamicRnnEstimatorTest(test.TestCase): NUM_RNN_CELL_UNITS = 8 NUM_LABEL_COLUMNS = 6 INPUTS_COLUMN = feature_column.real_valued_column( 'inputs', dimension=NUM_LABEL_COLUMNS) def setUp(self): super(DynamicRnnEstimatorTest, self).setUp() self.rnn_cell = core_rnn_cell_impl.BasicRNNCell(self.NUM_RNN_CELL_UNITS) self.mock_target_column = MockTargetColumn( num_label_columns=self.NUM_LABEL_COLUMNS) location = feature_column.sparse_column_with_keys( 'location', keys=['west_side', 'east_side', 'nyc']) location_onehot = feature_column.one_hot_column(location) self.context_feature_columns = [location_onehot] wire_cast = feature_column.sparse_column_with_keys( 'wire_cast', ['marlo', 'omar', 'stringer']) wire_cast_embedded = feature_column.embedding_column(wire_cast, dimension=8) measurements = feature_column.real_valued_column( 'measurements', dimension=2) self.sequence_feature_columns = [measurements, wire_cast_embedded] def GetColumnsToTensors(self): """Get columns_to_tensors matching setUp(), in the current default graph.""" return { 'location': sparse_tensor.SparseTensor( indices=[[0, 0], [1, 0], [2, 0]], values=['west_side', 'west_side', 'nyc'], dense_shape=[3, 1]), 'wire_cast': sparse_tensor.SparseTensor( indices=[[0, 0, 0], [0, 1, 0], [1, 0, 0], [1, 1, 0], [1, 1, 1], [2, 0, 0]], values=[b'marlo', b'stringer', b'omar', b'stringer', b'marlo', b'marlo'], dense_shape=[3, 2, 2]), 'measurements': random_ops.random_uniform( [3, 2, 2], seed=4711) } def GetClassificationTargetsOrNone(self, mode): """Get targets matching setUp() and mode, in the current default graph.""" return (random_ops.random_uniform( [3, 2, 1], 0, 2, dtype=dtypes.int64, seed=1412) if mode != model_fn_lib.ModeKeys.INFER else None) def testBuildSequenceInputInput(self): sequence_input = dynamic_rnn_estimator.build_sequence_input( self.GetColumnsToTensors(), self.sequence_feature_columns, self.context_feature_columns) with self.test_session() as sess: sess.run(variables.global_variables_initializer()) sess.run(data_flow_ops.tables_initializer()) sequence_input_val = sess.run(sequence_input) expected_shape = np.array([ 3, # expected batch size 2, # padded sequence length 3 + 8 + 2 # location keys + embedding dim + measurement dimension ]) self.assertAllEqual(expected_shape, sequence_input_val.shape) def testConstructRNN(self): initial_state = None sequence_input = dynamic_rnn_estimator.build_sequence_input( self.GetColumnsToTensors(), self.sequence_feature_columns, self.context_feature_columns) activations_t, final_state_t = dynamic_rnn_estimator.construct_rnn( initial_state, sequence_input, self.rnn_cell, self.mock_target_column.num_label_columns) # Obtain values of activations and final state. with session.Session() as sess: sess.run(variables.global_variables_initializer()) sess.run(data_flow_ops.tables_initializer()) activations, final_state = sess.run([activations_t, final_state_t]) expected_activations_shape = np.array([3, 2, self.NUM_LABEL_COLUMNS]) self.assertAllEqual(expected_activations_shape, activations.shape) expected_state_shape = np.array([3, self.NUM_RNN_CELL_UNITS]) self.assertAllEqual(expected_state_shape, final_state.shape) def testMaskActivationsAndLabels(self): """Test `mask_activations_and_labels`.""" batch_size = 4 padded_length = 6 num_classes = 4 np.random.seed(1234) sequence_length = np.random.randint(0, padded_length + 1, batch_size) activations = np.random.rand(batch_size, padded_length, num_classes) labels = np.random.randint(0, num_classes, [batch_size, padded_length]) (activations_masked_t, labels_masked_t) = dynamic_rnn_estimator.mask_activations_and_labels( constant_op.constant( activations, dtype=dtypes.float32), constant_op.constant( labels, dtype=dtypes.int32), constant_op.constant( sequence_length, dtype=dtypes.int32)) with session.Session() as sess: activations_masked, labels_masked = sess.run( [activations_masked_t, labels_masked_t]) expected_activations_shape = [sum(sequence_length), num_classes] np.testing.assert_equal( expected_activations_shape, activations_masked.shape, 'Wrong activations shape. Expected {}; got {}.'.format( expected_activations_shape, activations_masked.shape)) expected_labels_shape = [sum(sequence_length)] np.testing.assert_equal(expected_labels_shape, labels_masked.shape, 'Wrong labels shape. Expected {}; got {}.'.format( expected_labels_shape, labels_masked.shape)) masked_index = 0 for i in range(batch_size): for j in range(sequence_length[i]): actual_activations = activations_masked[masked_index] expected_activations = activations[i, j, :] np.testing.assert_almost_equal( expected_activations, actual_activations, err_msg='Unexpected logit value at index [{}, {}, :].' ' Expected {}; got {}.'.format(i, j, expected_activations, actual_activations)) actual_labels = labels_masked[masked_index] expected_labels = labels[i, j] np.testing.assert_almost_equal( expected_labels, actual_labels, err_msg='Unexpected logit value at index [{}, {}].' ' Expected {}; got {}.'.format(i, j, expected_labels, actual_labels)) masked_index += 1 def testSelectLastActivations(self): """Test `select_last_activations`.""" batch_size = 4 padded_length = 6 num_classes = 4 np.random.seed(4444) sequence_length = np.random.randint(0, padded_length + 1, batch_size) activations = np.random.rand(batch_size, padded_length, num_classes) last_activations_t = dynamic_rnn_estimator.select_last_activations( constant_op.constant( activations, dtype=dtypes.float32), constant_op.constant( sequence_length, dtype=dtypes.int32)) with session.Session() as sess: last_activations = sess.run(last_activations_t) expected_activations_shape = [batch_size, num_classes] np.testing.assert_equal( expected_activations_shape, last_activations.shape, 'Wrong activations shape. Expected {}; got {}.'.format( expected_activations_shape, last_activations.shape)) for i in range(batch_size): actual_activations = last_activations[i, :] expected_activations = activations[i, sequence_length[i] - 1, :] np.testing.assert_almost_equal( expected_activations, actual_activations, err_msg='Unexpected logit value at index [{}, :].' ' Expected {}; got {}.'.format(i, expected_activations, actual_activations)) # testGetDynamicRnnModelFn{Train,Eval,Infer}() test which fields # of ModelFnOps are set depending on mode. def testGetDynamicRnnModelFnTrain(self): model_fn_ops = self._GetModelFnOpsForMode(model_fn_lib.ModeKeys.TRAIN) self.assertIsNotNone(model_fn_ops.predictions) self.assertIsNotNone(model_fn_ops.loss) self.assertIsNotNone(model_fn_ops.train_op) # None may get normalized to {}; we accept neither. self.assertNotEqual(len(model_fn_ops.eval_metric_ops), 0) def testGetDynamicRnnModelFnEval(self): model_fn_ops = self._GetModelFnOpsForMode(model_fn_lib.ModeKeys.EVAL) self.assertIsNotNone(model_fn_ops.predictions) self.assertIsNotNone(model_fn_ops.loss) self.assertIsNone(model_fn_ops.train_op) # None may get normalized to {}; we accept neither. self.assertNotEqual(len(model_fn_ops.eval_metric_ops), 0) def testGetDynamicRnnModelFnInfer(self): model_fn_ops = self._GetModelFnOpsForMode(model_fn_lib.ModeKeys.INFER) self.assertIsNotNone(model_fn_ops.predictions) self.assertIsNone(model_fn_ops.loss) self.assertIsNone(model_fn_ops.train_op) # None may get normalized to {}; we accept both. self.assertFalse(model_fn_ops.eval_metric_ops) def _GetModelFnOpsForMode(self, mode): """Helper for testGetDynamicRnnModelFn{Train,Eval,Infer}().""" model_fn = dynamic_rnn_estimator._get_dynamic_rnn_model_fn( self.rnn_cell, target_column=target_column_lib.multi_class_target(n_classes=2), # Only CLASSIFICATION yields eval metrics to test for. problem_type=dynamic_rnn_estimator.ProblemType.CLASSIFICATION, prediction_type=dynamic_rnn_estimator.PredictionType.MULTIPLE_VALUE, optimizer='SGD', sequence_feature_columns=self.sequence_feature_columns, context_feature_columns=self.context_feature_columns, learning_rate=0.1) labels = self.GetClassificationTargetsOrNone(mode) model_fn_ops = model_fn( features=self.GetColumnsToTensors(), labels=labels, mode=mode) return model_fn_ops def testExport(self): input_feature_key = 'magic_input_feature_key' def get_input_fn(mode): def input_fn(): features = self.GetColumnsToTensors() if mode == model_fn_lib.ModeKeys.INFER: input_examples = array_ops.placeholder(dtypes.string) features[input_feature_key] = input_examples # Real code would now parse features out of input_examples, # but this test can just stick to the constants above. return features, self.GetClassificationTargetsOrNone(mode) return input_fn model_dir = tempfile.mkdtemp() def estimator_fn(): return dynamic_rnn_estimator.multi_value_rnn_classifier( num_classes=2, num_units=self.NUM_RNN_CELL_UNITS, sequence_feature_columns=self.sequence_feature_columns, context_feature_columns=self.context_feature_columns, predict_probabilities=True, model_dir=model_dir) # Train a bit to create an exportable checkpoint. estimator_fn().fit(input_fn=get_input_fn(model_fn_lib.ModeKeys.TRAIN), steps=100) # Now export, but from a fresh estimator instance, like you would # in an export binary. That means .export() has to work without # .fit() being called on the same object. export_dir = tempfile.mkdtemp() print('Exporting to', export_dir) estimator_fn().export( export_dir, input_fn=get_input_fn(model_fn_lib.ModeKeys.INFER), use_deprecated_input_fn=False, input_feature_key=input_feature_key) def testStateTupleDictConversion(self): """Test `state_tuple_to_dict` and `dict_to_state_tuple`.""" cell_sizes = [5, 3, 7] # A MultiRNNCell of LSTMCells is both a common choice and an interesting # test case, because it has two levels of nesting, with an inner class that # is not a plain tuple. cell = core_rnn_cell_impl.MultiRNNCell( [core_rnn_cell_impl.LSTMCell(i) for i in cell_sizes]) state_dict = { dynamic_rnn_estimator._get_state_name(i): array_ops.expand_dims(math_ops.range(cell_size), 0) for i, cell_size in enumerate([5, 5, 3, 3, 7, 7]) } expected_state = (core_rnn_cell_impl.LSTMStateTuple( np.reshape(np.arange(5), [1, -1]), np.reshape(np.arange(5), [1, -1])), core_rnn_cell_impl.LSTMStateTuple( np.reshape(np.arange(3), [1, -1]), np.reshape(np.arange(3), [1, -1])), core_rnn_cell_impl.LSTMStateTuple( np.reshape(np.arange(7), [1, -1]), np.reshape(np.arange(7), [1, -1]))) actual_state = dynamic_rnn_estimator.dict_to_state_tuple(state_dict, cell) flattened_state = dynamic_rnn_estimator.state_tuple_to_dict(actual_state) with self.test_session() as sess: (state_dict_val, actual_state_val, flattened_state_val) = sess.run( [state_dict, actual_state, flattened_state]) def _recursive_assert_equal(x, y): self.assertEqual(type(x), type(y)) if isinstance(x, (list, tuple)): self.assertEqual(len(x), len(y)) for i, _ in enumerate(x): _recursive_assert_equal(x[i], y[i]) elif isinstance(x, np.ndarray): np.testing.assert_array_equal(x, y) else: self.fail('Unexpected type: {}'.format(type(x))) for k in state_dict_val.keys(): np.testing.assert_array_almost_equal( state_dict_val[k], flattened_state_val[k], err_msg='Wrong value for state component {}.'.format(k)) _recursive_assert_equal(expected_state, actual_state_val) def testMultiRNNState(self): """Test that state flattening/reconstruction works for `MultiRNNCell`.""" batch_size = 11 sequence_length = 16 train_steps = 5 cell_sizes = [4, 8, 7] learning_rate = 0.1 def get_shift_input_fn(batch_size, sequence_length, seed=None): def input_fn(): random_sequence = random_ops.random_uniform( [batch_size, sequence_length + 1], 0, 2, dtype=dtypes.int32, seed=seed) labels = array_ops.slice(random_sequence, [0, 0], [batch_size, sequence_length]) inputs = array_ops.expand_dims( math_ops.to_float( array_ops.slice(random_sequence, [0, 1], [batch_size, sequence_length])), 2) input_dict = { dynamic_rnn_estimator._get_state_name(i): random_ops.random_uniform( [batch_size, cell_size], seed=((i + 1) * seed)) for i, cell_size in enumerate([4, 4, 8, 8, 7, 7]) } input_dict['inputs'] = inputs return input_dict, labels return input_fn seq_columns = [feature_column.real_valued_column('inputs', dimension=1)] config = run_config.RunConfig(tf_random_seed=21212) cell = core_rnn_cell_impl.MultiRNNCell( [core_rnn_cell_impl.BasicLSTMCell(size) for size in cell_sizes]) sequence_estimator = dynamic_rnn_estimator.multi_value_rnn_classifier( num_classes=2, num_units=None, sequence_feature_columns=seq_columns, cell_type=cell, learning_rate=learning_rate, config=config, predict_probabilities=True) train_input_fn = get_shift_input_fn(batch_size, sequence_length, seed=12321) eval_input_fn = get_shift_input_fn(batch_size, sequence_length, seed=32123) sequence_estimator.fit(input_fn=train_input_fn, steps=train_steps) prediction_dict = sequence_estimator.predict( input_fn=eval_input_fn, as_iterable=False) for i, state_size in enumerate([4, 4, 8, 8, 7, 7]): state_piece = prediction_dict[dynamic_rnn_estimator._get_state_name(i)] self.assertListEqual(list(state_piece.shape), [batch_size, state_size]) def testMultipleRuns(self): """Tests resuming training by feeding state.""" cell_sizes = [4, 7] batch_size = 11 learning_rate = 0.1 train_sequence_length = 21 train_steps = 121 prediction_steps = [3, 2, 5, 11, 6] def get_input_fn(batch_size, sequence_length, state_dict, starting_step=0): def input_fn(): sequence = constant_op.constant( [[(starting_step + i + j) % 2 for j in range(sequence_length + 1)] for i in range(batch_size)], dtype=dtypes.int32) labels = array_ops.slice(sequence, [0, 0], [batch_size, sequence_length]) inputs = array_ops.expand_dims( math_ops.to_float( array_ops.slice(sequence, [0, 1], [batch_size, sequence_length ])), 2) input_dict = state_dict input_dict['inputs'] = inputs return input_dict, labels return input_fn seq_columns = [feature_column.real_valued_column('inputs', dimension=1)] config = run_config.RunConfig(tf_random_seed=21212) cell = core_rnn_cell_impl.MultiRNNCell( [core_rnn_cell_impl.BasicLSTMCell(size) for size in cell_sizes]) model_dir = tempfile.mkdtemp() sequence_estimator = dynamic_rnn_estimator.multi_value_rnn_classifier( num_classes=2, num_units=None, sequence_feature_columns=seq_columns, cell_type=cell, learning_rate=learning_rate, config=config, model_dir=model_dir) train_input_fn = get_input_fn( batch_size, train_sequence_length, state_dict={}) sequence_estimator.fit(input_fn=train_input_fn, steps=train_steps) def incremental_predict(estimator, increments): """Run `estimator.predict` for `i` steps for `i` in `increments`.""" step = 0 incremental_state_dict = {} for increment in increments: input_fn = get_input_fn( batch_size, increment, state_dict=incremental_state_dict, starting_step=step) prediction_dict = estimator.predict( input_fn=input_fn, as_iterable=False) step += increment incremental_state_dict = { k: v for (k, v) in prediction_dict.items() if k.startswith(dynamic_rnn_estimator.RNNKeys.STATE_PREFIX) } return prediction_dict pred_all_at_once = incremental_predict(sequence_estimator, [sum(prediction_steps)]) pred_step_by_step = incremental_predict(sequence_estimator, prediction_steps) # Check that the last `prediction_steps[-1]` steps give the same # predictions. np.testing.assert_array_equal( pred_all_at_once['predictions'][:, -1 * prediction_steps[-1]:], pred_step_by_step['predictions'], err_msg='Mismatch on last {} predictions.'.format(prediction_steps[-1])) # Check that final states are identical. for k, v in pred_all_at_once.items(): if k.startswith(dynamic_rnn_estimator.RNNKeys.STATE_PREFIX): np.testing.assert_array_equal( v, pred_step_by_step[k], err_msg='Mismatch on state {}.'.format(k)) # TODO(jamieas): move all tests below to a benchmark test. class DynamicRNNEstimatorLearningTest(test.TestCase): """Learning tests for dynamic RNN Estimators.""" def testLearnSineFunction(self): """Tests learning a sine function.""" batch_size = 8 sequence_length = 64 train_steps = 200 eval_steps = 20 cell_size = 4 learning_rate = 0.1 loss_threshold = 0.02 def get_sin_input_fn(batch_size, sequence_length, increment, seed=None): def _sin_fn(x): ranger = math_ops.linspace( array_ops.reshape(x[0], []), (sequence_length - 1) * increment, sequence_length + 1) return math_ops.sin(ranger) def input_fn(): starts = random_ops.random_uniform( [batch_size], maxval=(2 * np.pi), seed=seed) sin_curves = functional_ops.map_fn( _sin_fn, (starts,), dtype=dtypes.float32) inputs = array_ops.expand_dims( array_ops.slice(sin_curves, [0, 0], [batch_size, sequence_length]), 2) labels = array_ops.slice(sin_curves, [0, 1], [batch_size, sequence_length]) return {'inputs': inputs}, labels return input_fn seq_columns = [ feature_column.real_valued_column( 'inputs', dimension=cell_size) ] config = run_config.RunConfig(tf_random_seed=1234) sequence_estimator = dynamic_rnn_estimator.multi_value_rnn_regressor( num_units=cell_size, sequence_feature_columns=seq_columns, learning_rate=learning_rate, input_keep_probability=0.9, output_keep_probability=0.9, config=config) train_input_fn = get_sin_input_fn( batch_size, sequence_length, np.pi / 32, seed=1234) eval_input_fn = get_sin_input_fn( batch_size, sequence_length, np.pi / 32, seed=4321) sequence_estimator.fit(input_fn=train_input_fn, steps=train_steps) loss = sequence_estimator.evaluate( input_fn=eval_input_fn, steps=eval_steps)['loss'] self.assertLess(loss, loss_threshold, 'Loss should be less than {}; got {}'.format(loss_threshold, loss)) def testLearnShiftByOne(self): """Tests that learning a 'shift-by-one' example. Each label sequence consists of the input sequence 'shifted' by one place. The RNN must learn to 'remember' the previous input. """ batch_size = 16 sequence_length = 32 train_steps = 200 eval_steps = 20 cell_size = 4 learning_rate = 0.3 accuracy_threshold = 0.9 def get_shift_input_fn(batch_size, sequence_length, seed=None): def input_fn(): random_sequence = random_ops.random_uniform( [batch_size, sequence_length + 1], 0, 2, dtype=dtypes.int32, seed=seed) labels = array_ops.slice(random_sequence, [0, 0], [batch_size, sequence_length]) inputs = array_ops.expand_dims( math_ops.to_float( array_ops.slice(random_sequence, [0, 1], [batch_size, sequence_length])), 2) return {'inputs': inputs}, labels return input_fn seq_columns = [ feature_column.real_valued_column( 'inputs', dimension=cell_size) ] config = run_config.RunConfig(tf_random_seed=21212) sequence_estimator = dynamic_rnn_estimator.multi_value_rnn_classifier( num_classes=2, num_units=cell_size, sequence_feature_columns=seq_columns, learning_rate=learning_rate, config=config, predict_probabilities=True) train_input_fn = get_shift_input_fn(batch_size, sequence_length, seed=12321) eval_input_fn = get_shift_input_fn(batch_size, sequence_length, seed=32123) sequence_estimator.fit(input_fn=train_input_fn, steps=train_steps) evaluation = sequence_estimator.evaluate( input_fn=eval_input_fn, steps=eval_steps) accuracy = evaluation['accuracy'] self.assertGreater(accuracy, accuracy_threshold, 'Accuracy should be higher than {}; got {}'.format( accuracy_threshold, accuracy)) # Testing `predict` when `predict_probabilities=True`. prediction_dict = sequence_estimator.predict( input_fn=eval_input_fn, as_iterable=False) self.assertListEqual( sorted(list(prediction_dict.keys())), sorted([ dynamic_rnn_estimator.RNNKeys.PREDICTIONS_KEY, dynamic_rnn_estimator.RNNKeys.PROBABILITIES_KEY, dynamic_rnn_estimator._get_state_name(0) ])) predictions = prediction_dict[dynamic_rnn_estimator.RNNKeys.PREDICTIONS_KEY] probabilities = prediction_dict[ dynamic_rnn_estimator.RNNKeys.PROBABILITIES_KEY] self.assertListEqual(list(predictions.shape), [batch_size, sequence_length]) self.assertListEqual( list(probabilities.shape), [batch_size, sequence_length, 2]) def testLearnMean(self): """Test learning to calculate a mean.""" batch_size = 16 sequence_length = 3 train_steps = 200 eval_steps = 20 cell_type = 'basic_rnn' cell_size = 8 optimizer_type = 'Momentum' learning_rate = 0.1 momentum = 0.9 loss_threshold = 0.1 def get_mean_input_fn(batch_size, sequence_length, seed=None): def input_fn(): # Create examples by choosing 'centers' and adding uniform noise. centers = math_ops.matmul( random_ops.random_uniform( [batch_size, 1], -0.75, 0.75, dtype=dtypes.float32, seed=seed), array_ops.ones([1, sequence_length])) noise = random_ops.random_uniform( [batch_size, sequence_length], -0.25, 0.25, dtype=dtypes.float32, seed=seed) sequences = centers + noise inputs = array_ops.expand_dims(sequences, 2) labels = math_ops.reduce_mean(sequences, reduction_indices=[1]) return {'inputs': inputs}, labels return input_fn seq_columns = [ feature_column.real_valued_column( 'inputs', dimension=cell_size) ] config = run_config.RunConfig(tf_random_seed=6) sequence_regressor = dynamic_rnn_estimator.single_value_rnn_regressor( num_units=cell_size, sequence_feature_columns=seq_columns, cell_type=cell_type, optimizer_type=optimizer_type, learning_rate=learning_rate, momentum=momentum, config=config) train_input_fn = get_mean_input_fn(batch_size, sequence_length, 121) eval_input_fn = get_mean_input_fn(batch_size, sequence_length, 212) sequence_regressor.fit(input_fn=train_input_fn, steps=train_steps) evaluation = sequence_regressor.evaluate( input_fn=eval_input_fn, steps=eval_steps) loss = evaluation['loss'] self.assertLess(loss, loss_threshold, 'Loss should be less than {}; got {}'.format(loss_threshold, loss)) def testLearnMajority(self): """Test learning the 'majority' function.""" batch_size = 16 sequence_length = 7 train_steps = 200 eval_steps = 20 cell_type = 'lstm' cell_size = 4 optimizer_type = 'Momentum' learning_rate = 2.0 momentum = 0.9 accuracy_threshold = 0.9 def get_majority_input_fn(batch_size, sequence_length, seed=None): random_seed.set_random_seed(seed) def input_fn(): random_sequence = random_ops.random_uniform( [batch_size, sequence_length], 0, 2, dtype=dtypes.int32, seed=seed) inputs = array_ops.expand_dims(math_ops.to_float(random_sequence), 2) labels = math_ops.to_int32( array_ops.squeeze( math_ops.reduce_sum( inputs, reduction_indices=[1]) > (sequence_length / 2.0))) return {'inputs': inputs}, labels return input_fn seq_columns = [ feature_column.real_valued_column( 'inputs', dimension=cell_size) ] config = run_config.RunConfig(tf_random_seed=77) sequence_classifier = dynamic_rnn_estimator.single_value_rnn_classifier( num_classes=2, num_units=cell_size, sequence_feature_columns=seq_columns, cell_type=cell_type, optimizer_type=optimizer_type, learning_rate=learning_rate, momentum=momentum, config=config, predict_probabilities=True) train_input_fn = get_majority_input_fn(batch_size, sequence_length, 1111) eval_input_fn = get_majority_input_fn(batch_size, sequence_length, 2222) sequence_classifier.fit(input_fn=train_input_fn, steps=train_steps) evaluation = sequence_classifier.evaluate( input_fn=eval_input_fn, steps=eval_steps) accuracy = evaluation['accuracy'] self.assertGreater(accuracy, accuracy_threshold, 'Accuracy should be higher than {}; got {}'.format( accuracy_threshold, accuracy)) # Testing `predict` when `predict_probabilities=True`. prediction_dict = sequence_classifier.predict( input_fn=eval_input_fn, as_iterable=False) self.assertListEqual( sorted(list(prediction_dict.keys())), sorted([ dynamic_rnn_estimator.RNNKeys.PREDICTIONS_KEY, dynamic_rnn_estimator.RNNKeys.PROBABILITIES_KEY, dynamic_rnn_estimator._get_state_name(0), dynamic_rnn_estimator._get_state_name(1) ])) predictions = prediction_dict[dynamic_rnn_estimator.RNNKeys.PREDICTIONS_KEY] probabilities = prediction_dict[ dynamic_rnn_estimator.RNNKeys.PROBABILITIES_KEY] self.assertListEqual(list(predictions.shape), [batch_size]) self.assertListEqual(list(probabilities.shape), [batch_size, 2]) if __name__ == '__main__': test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 12537, 14, 10646, 14, 7764, 63, 12845, 63, 8627, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 5549, 199, 199, 3, 3254, 26, 327, 22, 15085, 5852, 642, 11176, 626, 7704, 366, 8329, 342, 440, 12420, 14, 199, 692, 2688, 8, 1274, 12, 283, 362, 68, 8329, 2469, 358, 436, 2688, 8, 1274, 12, 283, 409, 68, 8329, 2469, 735, 523, 492, 5577, 523, 984, 14, 409, 68, 8329, 2469, 8, 1274, 14, 362, 68, 8329, 2469, 342, 1204, 5577, 14, 11876, 6533, 63, 13808, 9, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 492, 19433, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 3878, 63, 2301, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 1347, 63, 2301, 465, 1347, 63, 2301, 63, 773, 199, 504, 3228, 14, 2828, 14, 4643, 14, 1548, 14, 4643, 14, 10646, 492, 8336, 63, 12845, 63, 8627, 199, 504, 3228, 14, 2828, 14, 4643, 14, 1548, 14, 4643, 14, 10646, 492, 1402, 63, 2324, 465, 1402, 63, 2324, 63, 773, 199, 504, 3228, 14, 2828, 14, 4643, 14, 1548, 14, 4643, 14, 10646, 492, 1255, 63, 888, 199, 504, 3228, 14, 2828, 14, 12845, 14, 1548, 14, 1483, 492, 6170, 63, 12845, 63, 3890, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 666, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 22380, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 22034, 32675, 8, 12845, 14, 32675, 304, 819, 347, 636, 826, 721, 277, 12, 1174, 63, 890, 12, 1072, 63, 890, 304, 272, 291, 423, 929, 63, 890, 275, 1174, 63, 890, 272, 291, 423, 1199, 63, 890, 275, 1072, 63, 890, 819, 768, 1829, 523, 347, 1174, 63, 890, 8, 277, 304, 272, 372, 291, 423, 929, 63, 890, 819, 768, 1829, 523, 347, 1072, 63, 890, 8, 277, 304, 272, 372, 291, 423, 1199, 63, 890, 819, 347, 636, 1250, 721, 277, 12, 4153, 12, 1174, 304, 272, 372, 1625, 63, 1483, 14, 5582, 8, 3711, 395, 1625, 63, 1483, 14, 4548, 8, 267, 359, 1144, 63, 1483, 14, 1392, 8, 3711, 2788, 16, 467, 291, 14, 929, 63, 890, 566, 421, 199, 533, 4420, 4277, 4547, 8, 785, 304, 819, 347, 636, 826, 721, 277, 12, 1967, 63, 1302, 63, 3406, 29, 403, 304, 272, 291, 423, 1507, 63, 1302, 63, 3406, 275, 1967, 63, 1302, 63, 3406, 819, 347, 664, 63, 2579, 63, 1483, 8, 277, 12, 4534, 12, 32038, 12, 3628, 12, 7186, 304, 272, 746, 4279, 8, 267, 283, 3346, 4277, 4547, 14, 362, 63, 2579, 63, 1483, 2797, 10537, 590, 2659, 819, 347, 11051, 63, 475, 63, 9869, 8, 277, 12, 18767, 63, 31117, 12, 557, 2470, 29, 797, 304, 272, 746, 4279, 8, 267, 283, 3346, 4277, 4547, 14, 10492, 63, 475, 63, 9869, 2797, 10537, 590, 2659, 819, 347, 5621, 8, 277, 12, 32038, 12, 3628, 12, 4534, 304, 272, 746, 4279, 360, 3346, 4277, 4547, 14, 4358, 2797, 10537, 590, 2659, 819, 768, 1829, 523, 347, 1967, 63, 1302, 63, 3406, 8, 277, 304, 272, 340, 291, 423, 1507, 63, 1302, 63, 3406, 365, 488, 26, 489, 746, 1722, 360, 3346, 4277, 4547, 14, 1507, 63, 1302, 63, 3406, 965, 440, 2757, 663, 2659, 272, 372, 291, 423, 1507, 63, 1302, 63, 3406, 819, 347, 663, 63, 1507, 63, 1302, 63, 3406, 8, 277, 12, 302, 304, 272, 291, 423, 1507, 63, 1302, 63, 3406, 275, 302, 421, 199, 318, 3414, 63, 1267, 63, 2629, 8, 1459, 12, 17464, 304, 523, 9742, 275, 1338, 523, 367, 284, 12, 2582, 315, 3874, 8, 14563, 304, 272, 9742, 59, 73, 12, 2582, 11941, 12228, 275, 980, 14, 4250, 63, 2930, 8, 11018, 59, 73, 12, 2582, 11941, 520, 566, 523, 372, 9742, 421, 199, 533, 21907, 50, 4411, 13183, 774, 8, 396, 14, 1746, 304, 819, 11576, 63, 24124, 63, 26474, 63, 27522, 275, 1695, 523, 11576, 63, 13837, 63, 28427, 275, 1227, 523, 21955, 51, 63, 21436, 275, 3878, 63, 2301, 14, 3093, 63, 16611, 63, 2301, 8, 489, 283, 3711, 297, 6240, 29, 7125, 63, 13837, 63, 28427, 9, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 14451, 50, 4411, 13183, 774, 12, 291, 680, 5996, 342, 272, 291, 14, 12845, 63, 3890, 275, 6170, 63, 12845, 63, 3890, 63, 5472, 14, 6845, 32675, 8, 277, 14, 7125, 63, 24124, 63, 26474, 63, 27522, 9, 272, 291, 14, 1805, 63, 1375, 63, 2301, 275, 4420, 4277 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 12537, 14, 10646, 14, 7764, 63, 12845, 63, 8627, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 5549, 199, 199, 3, 3254, 26, 327, 22, 15085, 5852, 642, 11176, 626, 7704, 366, 8329, 342, 440, 12420, 14, 199, 692, 2688, 8, 1274, 12, 283, 362, 68, 8329, 2469, 358, 436, 2688, 8, 1274, 12, 283, 409, 68, 8329, 2469, 735, 523, 492, 5577, 523, 984, 14, 409, 68, 8329, 2469, 8, 1274, 14, 362, 68, 8329, 2469, 342, 1204, 5577, 14, 11876, 6533, 63, 13808, 9, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 492, 19433, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 3878, 63, 2301, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 1347, 63, 2301, 465, 1347, 63, 2301, 63, 773, 199, 504, 3228, 14, 2828, 14, 4643, 14, 1548, 14, 4643, 14, 10646, 492, 8336, 63, 12845, 63, 8627, 199, 504, 3228, 14, 2828, 14, 4643, 14, 1548, 14, 4643, 14, 10646, 492, 1402, 63, 2324, 465, 1402, 63, 2324, 63, 773, 199, 504, 3228, 14, 2828, 14, 4643, 14, 1548, 14, 4643, 14, 10646, 492, 1255, 63, 888, 199, 504, 3228, 14, 2828, 14, 12845, 14, 1548, 14, 1483, 492, 6170, 63, 12845, 63, 3890, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 666, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 22380, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 22034, 32675, 8, 12845, 14, 32675, 304, 819, 347, 636, 826, 721, 277, 12, 1174, 63, 890, 12, 1072, 63, 890, 304, 272, 291, 423, 929, 63, 890, 275, 1174, 63, 890, 272, 291, 423, 1199, 63, 890, 275, 1072, 63, 890, 819, 768, 1829, 523, 347, 1174, 63, 890, 8, 277, 304, 272, 372, 291, 423, 929, 63, 890, 819, 768, 1829, 523, 347, 1072, 63, 890, 8, 277, 304, 272, 372, 291, 423, 1199, 63, 890, 819, 347, 636, 1250, 721, 277, 12, 4153, 12, 1174, 304, 272, 372, 1625, 63, 1483, 14, 5582, 8, 3711, 395, 1625, 63, 1483, 14, 4548, 8, 267, 359, 1144, 63, 1483, 14, 1392, 8, 3711, 2788, 16, 467, 291, 14, 929, 63, 890, 566, 421, 199, 533, 4420, 4277, 4547, 8, 785, 304, 819, 347, 636, 826, 721, 277, 12, 1967, 63, 1302, 63, 3406, 29, 403, 304, 272, 291, 423, 1507, 63, 1302, 63, 3406, 275, 1967, 63, 1302, 63, 3406, 819, 347, 664, 63, 2579, 63, 1483, 8, 277, 12, 4534, 12, 32038, 12, 3628, 12, 7186, 304, 272, 746, 4279, 8, 267, 283, 3346, 4277, 4547, 14, 362, 63, 2579, 63, 1483, 2797, 10537, 590, 2659, 819, 347, 11051, 63, 475, 63, 9869, 8, 277, 12, 18767, 63, 31117, 12, 557, 2470, 29, 797, 304, 272, 746, 4279, 8, 267, 283, 3346, 4277, 4547, 14, 10492, 63, 475, 63, 9869, 2797, 10537, 590, 2659, 819, 347, 5621, 8, 277, 12, 32038, 12, 3628, 12, 4534, 304, 272, 746, 4279, 360, 3346, 4277, 4547, 14, 4358, 2797, 10537, 590, 2659, 819, 768, 1829, 523, 347, 1967, 63, 1302, 63, 3406, 8, 277, 304, 272, 340, 291, 423, 1507, 63, 1302, 63, 3406, 365, 488, 26, 489, 746, 1722, 360, 3346, 4277, 4547, 14, 1507, 63, 1302, 63, 3406, 965, 440, 2757, 663, 2659, 272, 372, 291, 423, 1507, 63, 1302, 63, 3406, 819, 347, 663, 63, 1507, 63, 1302, 63, 3406, 8, 277, 12, 302, 304, 272, 291, 423, 1507, 63, 1302, 63, 3406, 275, 302, 421, 199, 318, 3414, 63, 1267, 63, 2629, 8, 1459, 12, 17464, 304, 523, 9742, 275, 1338, 523, 367, 284, 12, 2582, 315, 3874, 8, 14563, 304, 272, 9742, 59, 73, 12, 2582, 11941, 12228, 275, 980, 14, 4250, 63, 2930, 8, 11018, 59, 73, 12, 2582, 11941, 520, 566, 523, 372, 9742, 421, 199, 533, 21907, 50, 4411, 13183, 774, 8, 396, 14, 1746, 304, 819, 11576, 63, 24124, 63, 26474, 63, 27522, 275, 1695, 523, 11576, 63, 13837, 63, 28427, 275, 1227, 523, 21955, 51, 63, 21436, 275, 3878, 63, 2301, 14, 3093, 63, 16611, 63, 2301, 8, 489, 283, 3711, 297, 6240, 29, 7125, 63, 13837, 63, 28427, 9, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 14451, 50, 4411, 13183, 774, 12, 291, 680, 5996, 342, 272, 291, 14, 12845, 63, 3890, 275, 6170, 63, 12845, 63, 3890, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Universal-Model-Converter/UMC3.0a
data/Python/x86/Lib/site-packages/OpenGL/raw/GL/EXT/draw_range_elements.py
3
1132
'''OpenGL extension EXT.draw_range_elements Automatically generated by the get_gl_extensions script, do not edit! ''' from OpenGL import platform, constants, constant, arrays from OpenGL import extensions from OpenGL.GL import glget import ctypes EXTENSION_NAME = 'GL_EXT_draw_range_elements' _DEPRECATED = False GL_MAX_ELEMENTS_VERTICES_EXT = constant.Constant( 'GL_MAX_ELEMENTS_VERTICES_EXT', 0x80E8 ) GL_MAX_ELEMENTS_INDICES_EXT = constant.Constant( 'GL_MAX_ELEMENTS_INDICES_EXT', 0x80E9 ) glDrawRangeElementsEXT = platform.createExtensionFunction( 'glDrawRangeElementsEXT',dll=platform.GL, extension=EXTENSION_NAME, resultType=None, argTypes=(constants.GLenum,constants.GLuint,constants.GLuint,constants.GLsizei,constants.GLenum,ctypes.c_void_p,), doc='glDrawRangeElementsEXT(GLenum(mode), GLuint(start), GLuint(end), GLsizei(count), GLenum(type), c_void_p(indices)) -> None', argNames=('mode','start','end','count','type','indices',), deprecated=_DEPRECATED, ) def glInitDrawRangeElementsEXT(): '''Return boolean indicating whether this extension is available''' return extensions.hasGLExtension( EXTENSION_NAME )
mit
[ 2344, 4299, 2226, 3329, 20203, 14, 5485, 63, 1842, 63, 5527, 199, 199, 3358, 17174, 4046, 701, 314, 664, 63, 3528, 63, 5359, 2884, 12, 886, 440, 5283, 1, 199, 2344, 199, 504, 24374, 492, 4298, 12, 5262, 12, 4413, 12, 6572, 199, 504, 24374, 492, 5478, 199, 504, 24374, 14, 2226, 492, 6482, 362, 199, 646, 5577, 199, 15498, 63, 2339, 275, 283, 2226, 63, 2472, 63, 5485, 63, 1842, 63, 5527, 7, 199, 63, 25832, 275, 756, 199, 2226, 63, 4283, 63, 12535, 51, 63, 8851, 7040, 63, 2472, 275, 4413, 14, 9737, 8, 283, 2226, 63, 4283, 63, 12535, 51, 63, 8851, 7040, 63, 2472, 297, 378, 88, 1257, 37, 24, 776, 199, 2226, 63, 4283, 63, 12535, 51, 63, 3192, 7040, 63, 2472, 275, 4413, 14, 9737, 8, 283, 2226, 63, 4283, 63, 12535, 51, 63, 3192, 7040, 63, 2472, 297, 378, 88, 1257, 37, 25, 776, 199, 3528, 9654, 4709, 6255, 2472, 275, 4298, 14, 981, 6382, 3481, 8, 221, 199, 7, 3528, 9654, 4709, 6255, 2472, 297, 9259, 29, 3246, 14, 2226, 12, 199, 3435, 29, 15498, 63, 2339, 12, 199, 1099, 804, 29, 403, 12, 221, 199, 1273, 4100, 2687, 5559, 14, 17821, 12, 5559, 14, 17609, 12, 5559, 14, 17609, 12, 5559, 14, 2226, 15875, 12, 5559, 14, 17821, 12, 9798, 14, 67, 63, 1647, 63, 80, 4706, 199, 1301, 534, 3528, 9654, 4709, 6255, 2472, 8, 17821, 8, 632, 395, 15716, 8, 928, 395, 15716, 8, 500, 395, 18542, 8, 835, 395, 12858, 8, 466, 395, 286, 63, 1647, 63, 80, 8, 4108, 430, 1035, 488, 297, 199, 1273, 5866, 7782, 632, 1673, 928, 1673, 500, 1673, 835, 1673, 466, 1673, 4108, 5529, 199, 6667, 3699, 25832, 12, 199, 9, 421, 199, 318, 6482, 9346, 9654, 4709, 6255, 2472, 837, 272, 1449, 1767, 5046, 9297, 3775, 642, 3329, 365, 2808, 2344, 272, 372, 5478, 14, 1989, 12827, 88, 724, 438, 8, 20203, 742, 3579, 63, 2339, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4299, 2226, 3329, 20203, 14, 5485, 63, 1842, 63, 5527, 199, 199, 3358, 17174, 4046, 701, 314, 664, 63, 3528, 63, 5359, 2884, 12, 886, 440, 5283, 1, 199, 2344, 199, 504, 24374, 492, 4298, 12, 5262, 12, 4413, 12, 6572, 199, 504, 24374, 492, 5478, 199, 504, 24374, 14, 2226, 492, 6482, 362, 199, 646, 5577, 199, 15498, 63, 2339, 275, 283, 2226, 63, 2472, 63, 5485, 63, 1842, 63, 5527, 7, 199, 63, 25832, 275, 756, 199, 2226, 63, 4283, 63, 12535, 51, 63, 8851, 7040, 63, 2472, 275, 4413, 14, 9737, 8, 283, 2226, 63, 4283, 63, 12535, 51, 63, 8851, 7040, 63, 2472, 297, 378, 88, 1257, 37, 24, 776, 199, 2226, 63, 4283, 63, 12535, 51, 63, 3192, 7040, 63, 2472, 275, 4413, 14, 9737, 8, 283, 2226, 63, 4283, 63, 12535, 51, 63, 3192, 7040, 63, 2472, 297, 378, 88, 1257, 37, 25, 776, 199, 3528, 9654, 4709, 6255, 2472, 275, 4298, 14, 981, 6382, 3481, 8, 221, 199, 7, 3528, 9654, 4709, 6255, 2472, 297, 9259, 29, 3246, 14, 2226, 12, 199, 3435, 29, 15498, 63, 2339, 12, 199, 1099, 804, 29, 403, 12, 221, 199, 1273, 4100, 2687, 5559, 14, 17821, 12, 5559, 14, 17609, 12, 5559, 14, 17609, 12, 5559, 14, 2226, 15875, 12, 5559, 14, 17821, 12, 9798, 14, 67, 63, 1647, 63, 80, 4706, 199, 1301, 534, 3528, 9654, 4709, 6255, 2472, 8, 17821, 8, 632, 395, 15716, 8, 928, 395, 15716, 8, 500, 395, 18542, 8, 835, 395, 12858, 8, 466, 395, 286, 63, 1647, 63, 80, 8, 4108, 430, 1035, 488, 297, 199, 1273, 5866, 7782, 632, 1673, 928, 1673, 500, 1673, 835, 1673, 466, 1673, 4108, 5529, 199, 6667, 3699, 25832, 12, 199, 9, 421, 199, 318, 6482, 9346, 9654, 4709, 6255, 2472, 837, 272, 1449, 1767, 5046, 9297, 3775, 642, 3329, 365, 2808, 2344, 272, 372, 5478, 14, 1989, 12827, 88, 724, 438, 8, 20203, 742, 3579, 63, 2339, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
zhangpf/vbox
src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py
21
4869
# Copyright (c) 2001, Stanford University # All rights reserved. # # See the file LICENSE.txt for information on redistributing this software. import sys import apiutil apiutil.CopyrightC() print """/* DO NOT EDIT - AUTOMATICALLY GENERATED BY packspu_beginend.py */ #include "packspu.h" #include "assert.h" #include "cr_packfunctions.h" #include "packspu_proto.h" void PACKSPU_APIENTRY packspu_Begin( GLenum mode ) { GET_THREAD(thread); CRPackBuffer *buf = &thread->BeginEndBuffer; /* XXX comparing mode >= 0 here is not needed since mode is unsigned */ CRASSERT( mode >= GL_POINTS && mode <= GL_POLYGON ); #if CR_ARB_vertex_buffer_object { GLboolean serverArrays = GL_FALSE; GET_CONTEXT(ctx); if (ctx->clientState->extensions.ARB_vertex_buffer_object) serverArrays = crStateUseServerArrays(); if (serverArrays) { CRClientState *clientState = &(ctx->clientState->client); if (clientState->array.locked && !clientState->array.synced) { crPackLockArraysEXT(clientState->array.lockFirst, clientState->array.lockCount); clientState->array.synced = GL_TRUE; } } } #endif if (pack_spu.swap) { crPackBeginSWAP( mode ); } else { crPackBegin( mode ); } if ( thread->netServer.conn->Barf ) { thread->BeginEndMode = mode; thread->BeginEndState = -1; if ( mode == GL_LINES || mode == GL_TRIANGLES || mode == GL_QUADS || mode == GL_POLYGON ) { CRASSERT(!buf->pack); crPackReleaseBuffer( thread->packer ); buf->pack = crNetAlloc( thread->netServer.conn ); crPackInitBuffer( buf, buf->pack, thread->netServer.conn->buffer_size, thread->netServer.conn->mtu ); buf->holds_BeginEnd = 1; buf->in_BeginEnd = 1; crPackSetBuffer( thread->packer, buf ); thread->BeginEndState = 0; } } } void PACKSPU_APIENTRY packspu_End( void ) { GET_THREAD(thread); CRPackBuffer *buf = &thread->BeginEndBuffer; if ( thread->netServer.conn->Barf && (thread->BeginEndMode == GL_LINES || thread->BeginEndMode == GL_TRIANGLES || thread->BeginEndMode == GL_QUADS || thread->BeginEndMode == GL_POLYGON ) ) { CRASSERT(buf->pack); crPackReleaseBuffer( thread->packer ); crPackSetBuffer( thread->packer, &thread->normBuffer ); if ( !crPackCanHoldBuffer( buf ) ) packspuFlush( (void *) thread ); crPackAppendBuffer( buf ); crNetFree( thread->netServer.conn, buf->pack ); buf->pack = NULL; } if (pack_spu.swap) { crPackEndSWAP(); } else { crPackEnd(); } } static void DoVertex( void ) { GET_THREAD(thread); CRPackBuffer *buf = &thread->BeginEndBuffer; CRPackBuffer *gbuf = &thread->normBuffer; int num_data; int num_opcode; /*crDebug( "really doing Vertex" );*/ crPackReleaseBuffer( thread->packer ); num_data = buf->data_current - buf->data_start; num_opcode = buf->opcode_start - buf->opcode_current; crPackSetBuffer( thread->packer, gbuf ); if ( !crPackCanHoldBuffer( buf ) ) /* doesn't hold, first flush gbuf*/ packspuFlush( (void *) thread ); crPackAppendBuffer( buf ); crPackReleaseBuffer( thread->packer ); crPackSetBuffer( thread->packer, buf ); crPackResetPointers(thread->packer); } static void RunState( void ) { GET_THREAD(thread); if (! thread->netServer.conn->Barf ) return; if (thread->BeginEndState == -1) return; switch(thread->BeginEndMode) { case GL_POLYGON: return; case GL_LINES: thread->BeginEndState = (thread->BeginEndState + 1) % 2; if (thread->BeginEndState) return; break; case GL_TRIANGLES: thread->BeginEndState = (thread->BeginEndState + 1) % 3; if (thread->BeginEndState) return; break; case GL_QUADS: thread->BeginEndState = (thread->BeginEndState + 1) % 4; if (thread->BeginEndState) return; break; } DoVertex(); } """ keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") for func_name in apiutil.AllSpecials( "packspu_vertex" ): params = apiutil.Parameters(func_name) print 'void PACKSPU_APIENTRY packspu_%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params) ) print '{' print '\tif (pack_spu.swap)' print '\t{' print '\t\tcrPack%sSWAP( %s );' % ( func_name, apiutil.MakeCallString( params ) ) print '\t}' print '\telse' print '\t{' print '\t\tcrPack%s( %s );' % ( func_name, apiutil.MakeCallString( params ) ) print '\t}' print '\tRunState();' print '}'
gpl-2.0
[ 3, 1898, 334, 67, 9, 12521, 12, 1933, 290, 18090, 15904, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 314, 570, 5113, 14, 2424, 367, 2556, 641, 295, 20231, 4655, 642, 2032, 14, 199, 199, 646, 984, 199, 199, 646, 2986, 1974, 421, 199, 1246, 1974, 14, 7384, 35, 342, 199, 199, 1361, 408, 6331, 3506, 2845, 24981, 446, 20331, 7474, 619, 948, 28292, 29087, 6989, 6515, 1706, 681, 85, 63, 5037, 500, 14, 647, 11589, 199, 3, 2613, 298, 1389, 681, 85, 14, 72, 2, 199, 3, 2613, 298, 479, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 1389, 5777, 14, 72, 2, 199, 3, 2613, 298, 1389, 681, 85, 63, 2625, 14, 72, 2, 199, 199, 1647, 510, 3099, 5763, 53, 63, 3735, 7285, 1706, 681, 85, 63, 5595, 8, 12858, 818, 776, 199, 91, 272, 9576, 63, 16103, 8, 2671, 2736, 272, 17101, 2305, 3299, 627, 1436, 275, 1253, 2671, 5118, 5595, 3005, 3299, 27, 339, 13505, 5787, 20234, 818, 2356, 378, 2348, 365, 440, 4346, 3967, 818, 365, 7381, 11589, 272, 17101, 24790, 8, 818, 2356, 3563, 63, 7217, 51, 10883, 818, 2695, 3563, 63, 23602, 20682, 199, 199, 3, 692, 17101, 63, 8611, 63, 11417, 63, 2738, 63, 785, 272, 469, 267, 3563, 4871, 1654, 29033, 275, 3563, 63, 19823, 27, 267, 9576, 63, 9059, 8, 3799, 2736, 267, 340, 334, 3799, 5118, 1258, 2223, 5118, 5359, 14, 8611, 63, 11417, 63, 2738, 63, 785, 9, 288, 1654, 29033, 275, 2467, 2223, 6119, 3120, 29033, 7303, 267, 340, 334, 1000, 29033, 9, 469, 288, 17101, 3041, 2223, 627, 1258, 2223, 275, 1253, 8, 3799, 5118, 1258, 2223, 5118, 1258, 2736, 288, 340, 334, 1258, 2223, 5118, 1144, 14, 9325, 10883, 8546, 1258, 2223, 5118, 1144, 14, 9466, 6867, 9, 288, 469, 355, 2467, 2305, 6432, 29033, 2472, 8, 1258, 2223, 5118, 1144, 14, 831, 7147, 12, 1890, 2223, 5118, 1144, 14, 831, 2353, 2736, 355, 1890, 2223, 5118, 1144, 14, 9466, 6867, 275, 3563, 63, 15064, 27, 288, 789, 267, 789, 272, 789, 199, 3, 13739, 339, 340, 334, 1389, 63, 681, 85, 14, 9286, 9, 272, 469, 267, 2467, 2305, 5595, 8745, 1282, 8, 818, 20682, 272, 789, 272, 587, 272, 469, 267, 2467, 2305, 5595, 8, 818, 20682, 272, 789, 339, 340, 334, 2462, 5118, 846, 3120, 14, 1631, 5118, 5281, 70, 776, 469, 267, 2462, 5118, 5595, 3005, 1385, 275, 818, 27, 267, 2462, 5118, 5595, 3005, 2223, 275, 446, 17, 27, 267, 340, 334, 818, 508, 3563, 63, 23023, 12208, 818, 508, 3563, 63, 1766, 23273, 2226, 654, 12208, 818, 508, 3563, 63, 2328, 1554, 51, 12208, 818, 508, 3563, 63, 23602, 776, 267, 469, 288, 17101, 24790, 8, 1, 1436, 5118, 1389, 2736, 953, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 288, 4123, 5118, 1389, 275, 2467, 2480, 2439, 2102, 8, 2462, 5118, 846, 3120, 14, 1631, 20682, 288, 2467, 2305, 9346, 3299, 8, 4123, 12, 4123, 5118, 1389, 12, 2462, 5118, 846, 3120, 14, 1631, 5118, 2738, 63, 890, 12, 2462, 5118, 846, 3120, 14, 1631, 5118, 17696, 20682, 288, 4123, 5118, 72, 8250, 63, 5595, 3005, 275, 413, 27, 288, 4123, 5118, 262, 63, 5595, 3005, 275, 413, 27, 288, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 4123, 20682, 953, 2462, 5118, 5595, 3005, 2223, 275, 378, 27, 267, 789, 272, 789, 199, 93, 199, 199, 1647, 510, 3099, 5763, 53, 63, 3735, 7285, 1706, 681, 85, 63, 3005, 8, 2309, 776, 199, 91, 272, 9576, 63, 16103, 8, 2671, 2736, 272, 17101, 2305, 3299, 627, 1436, 275, 1253, 2671, 5118, 5595, 3005, 3299, 27, 339, 340, 334, 2462, 5118, 846, 3120, 14, 1631, 5118, 5281, 70, 10883, 267, 334, 2671, 5118, 5595, 3005, 1385, 508, 3563, 63, 23023, 267, 12208, 2462, 5118, 5595, 3005, 1385, 508, 3563, 63, 1766, 23273, 2226, 654, 267, 12208, 2462, 5118, 5595, 3005, 1385, 508, 3563, 63, 2328, 1554, 51, 267, 12208, 2462, 5118, 5595, 3005, 1385, 508, 3563, 63, 23602, 776, 776, 272, 469, 267, 17101, 24790, 8, 1436, 5118, 1389, 2736, 398, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 267, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 1253, 2671, 5118, 4791, 3299, 20682, 267, 340, 334, 8546, 1556, 2305, 6049, 31003, 3299, 8, 4123, 776, 776, 288, 1706, 681, 85, 20053, 8, 334, 1647, 24104, 2462, 20682, 398, 2467, 2305, 8310, 3299, 8, 4123, 20682, 267, 2467, 2480, 10146, 8, 2462, 5118, 846, 3120, 14, 1631, 12, 4123, 5118, 1389, 20682, 267, 4123, 5118, 1389, 275, 5962, 27, 272, 789, 339, 340, 334, 1389, 63, 681, 85, 14, 9286, 9, 272, 469, 267, 2467, 2305, 3005, 8745, 1282, 7303, 272, 789, 272, 587, 272, 469, 267, 2467, 2305, 3005, 7303, 272, 789, 199, 93, 199, 199, 1986, 2309, 4226, 9787, 8, 2309, 776, 199, 91, 272, 9576, 63, 16103, 8, 2671, 2736, 272, 17101, 2305, 3299, 627, 1436, 275, 1253, 2671, 5118, 5595, 3005, 3299, 27, 272, 17101, 2305, 3299, 627, 71, 1436, 275, 1253, 2671, 5118, 4791, 3299, 27, 272, 1109, 1967, 63, 576, 27, 272, 1109, 1967, 63, 14325, 27, 339, 13505, 1556, 7084, 8, 298, 29428, 9689, 5444, 3858, 2, 20682, 15870, 272, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 272, 1967, 63, 576, 275, 4123, 5118, 576, 63, 1818, 446, 4123, 5118, 576, 63, 928, 27, 272, 1967, 63, 14325, 275, 4123, 5118, 14325, 63, 928, 446, 4123, 5118, 14325, 63, 1818, 27, 272, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 486, 1436, 20682, 272, 340, 334, 8546, 1556, 2305, 6049, 31003, 3299, 8, 4123, 776, 776, 267, 13505, 3181, 1133, 10266, 12, 1642, 8976, 486, 1436, 15870, 267, 1706, 681, 85, 20053, 8, 334, 1647, 24104, 2462, 20682, 339, 2467, 2305, 8310, 3299, 8, 4123, 20682, 272, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 272, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 4123, 20682, 272, 2467, 2305, 9637, 1575, 11005, 8, 2671, 5118, 1389, 281, 2736, 199, 93, 199, 199, 1986, 2309, 3378, 2223, 8, 2309, 776, 199, 91, 272, 9576 ]
[ 1898, 334, 67, 9, 12521, 12, 1933, 290, 18090, 15904, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 314, 570, 5113, 14, 2424, 367, 2556, 641, 295, 20231, 4655, 642, 2032, 14, 199, 199, 646, 984, 199, 199, 646, 2986, 1974, 421, 199, 1246, 1974, 14, 7384, 35, 342, 199, 199, 1361, 408, 6331, 3506, 2845, 24981, 446, 20331, 7474, 619, 948, 28292, 29087, 6989, 6515, 1706, 681, 85, 63, 5037, 500, 14, 647, 11589, 199, 3, 2613, 298, 1389, 681, 85, 14, 72, 2, 199, 3, 2613, 298, 479, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 1389, 5777, 14, 72, 2, 199, 3, 2613, 298, 1389, 681, 85, 63, 2625, 14, 72, 2, 199, 199, 1647, 510, 3099, 5763, 53, 63, 3735, 7285, 1706, 681, 85, 63, 5595, 8, 12858, 818, 776, 199, 91, 272, 9576, 63, 16103, 8, 2671, 2736, 272, 17101, 2305, 3299, 627, 1436, 275, 1253, 2671, 5118, 5595, 3005, 3299, 27, 339, 13505, 5787, 20234, 818, 2356, 378, 2348, 365, 440, 4346, 3967, 818, 365, 7381, 11589, 272, 17101, 24790, 8, 818, 2356, 3563, 63, 7217, 51, 10883, 818, 2695, 3563, 63, 23602, 20682, 199, 199, 3, 692, 17101, 63, 8611, 63, 11417, 63, 2738, 63, 785, 272, 469, 267, 3563, 4871, 1654, 29033, 275, 3563, 63, 19823, 27, 267, 9576, 63, 9059, 8, 3799, 2736, 267, 340, 334, 3799, 5118, 1258, 2223, 5118, 5359, 14, 8611, 63, 11417, 63, 2738, 63, 785, 9, 288, 1654, 29033, 275, 2467, 2223, 6119, 3120, 29033, 7303, 267, 340, 334, 1000, 29033, 9, 469, 288, 17101, 3041, 2223, 627, 1258, 2223, 275, 1253, 8, 3799, 5118, 1258, 2223, 5118, 1258, 2736, 288, 340, 334, 1258, 2223, 5118, 1144, 14, 9325, 10883, 8546, 1258, 2223, 5118, 1144, 14, 9466, 6867, 9, 288, 469, 355, 2467, 2305, 6432, 29033, 2472, 8, 1258, 2223, 5118, 1144, 14, 831, 7147, 12, 1890, 2223, 5118, 1144, 14, 831, 2353, 2736, 355, 1890, 2223, 5118, 1144, 14, 9466, 6867, 275, 3563, 63, 15064, 27, 288, 789, 267, 789, 272, 789, 199, 3, 13739, 339, 340, 334, 1389, 63, 681, 85, 14, 9286, 9, 272, 469, 267, 2467, 2305, 5595, 8745, 1282, 8, 818, 20682, 272, 789, 272, 587, 272, 469, 267, 2467, 2305, 5595, 8, 818, 20682, 272, 789, 339, 340, 334, 2462, 5118, 846, 3120, 14, 1631, 5118, 5281, 70, 776, 469, 267, 2462, 5118, 5595, 3005, 1385, 275, 818, 27, 267, 2462, 5118, 5595, 3005, 2223, 275, 446, 17, 27, 267, 340, 334, 818, 508, 3563, 63, 23023, 12208, 818, 508, 3563, 63, 1766, 23273, 2226, 654, 12208, 818, 508, 3563, 63, 2328, 1554, 51, 12208, 818, 508, 3563, 63, 23602, 776, 267, 469, 288, 17101, 24790, 8, 1, 1436, 5118, 1389, 2736, 953, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 288, 4123, 5118, 1389, 275, 2467, 2480, 2439, 2102, 8, 2462, 5118, 846, 3120, 14, 1631, 20682, 288, 2467, 2305, 9346, 3299, 8, 4123, 12, 4123, 5118, 1389, 12, 2462, 5118, 846, 3120, 14, 1631, 5118, 2738, 63, 890, 12, 2462, 5118, 846, 3120, 14, 1631, 5118, 17696, 20682, 288, 4123, 5118, 72, 8250, 63, 5595, 3005, 275, 413, 27, 288, 4123, 5118, 262, 63, 5595, 3005, 275, 413, 27, 288, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 4123, 20682, 953, 2462, 5118, 5595, 3005, 2223, 275, 378, 27, 267, 789, 272, 789, 199, 93, 199, 199, 1647, 510, 3099, 5763, 53, 63, 3735, 7285, 1706, 681, 85, 63, 3005, 8, 2309, 776, 199, 91, 272, 9576, 63, 16103, 8, 2671, 2736, 272, 17101, 2305, 3299, 627, 1436, 275, 1253, 2671, 5118, 5595, 3005, 3299, 27, 339, 340, 334, 2462, 5118, 846, 3120, 14, 1631, 5118, 5281, 70, 10883, 267, 334, 2671, 5118, 5595, 3005, 1385, 508, 3563, 63, 23023, 267, 12208, 2462, 5118, 5595, 3005, 1385, 508, 3563, 63, 1766, 23273, 2226, 654, 267, 12208, 2462, 5118, 5595, 3005, 1385, 508, 3563, 63, 2328, 1554, 51, 267, 12208, 2462, 5118, 5595, 3005, 1385, 508, 3563, 63, 23602, 776, 776, 272, 469, 267, 17101, 24790, 8, 1436, 5118, 1389, 2736, 398, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 267, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 1253, 2671, 5118, 4791, 3299, 20682, 267, 340, 334, 8546, 1556, 2305, 6049, 31003, 3299, 8, 4123, 776, 776, 288, 1706, 681, 85, 20053, 8, 334, 1647, 24104, 2462, 20682, 398, 2467, 2305, 8310, 3299, 8, 4123, 20682, 267, 2467, 2480, 10146, 8, 2462, 5118, 846, 3120, 14, 1631, 12, 4123, 5118, 1389, 20682, 267, 4123, 5118, 1389, 275, 5962, 27, 272, 789, 339, 340, 334, 1389, 63, 681, 85, 14, 9286, 9, 272, 469, 267, 2467, 2305, 3005, 8745, 1282, 7303, 272, 789, 272, 587, 272, 469, 267, 2467, 2305, 3005, 7303, 272, 789, 199, 93, 199, 199, 1986, 2309, 4226, 9787, 8, 2309, 776, 199, 91, 272, 9576, 63, 16103, 8, 2671, 2736, 272, 17101, 2305, 3299, 627, 1436, 275, 1253, 2671, 5118, 5595, 3005, 3299, 27, 272, 17101, 2305, 3299, 627, 71, 1436, 275, 1253, 2671, 5118, 4791, 3299, 27, 272, 1109, 1967, 63, 576, 27, 272, 1109, 1967, 63, 14325, 27, 339, 13505, 1556, 7084, 8, 298, 29428, 9689, 5444, 3858, 2, 20682, 15870, 272, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 272, 1967, 63, 576, 275, 4123, 5118, 576, 63, 1818, 446, 4123, 5118, 576, 63, 928, 27, 272, 1967, 63, 14325, 275, 4123, 5118, 14325, 63, 928, 446, 4123, 5118, 14325, 63, 1818, 27, 272, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 486, 1436, 20682, 272, 340, 334, 8546, 1556, 2305, 6049, 31003, 3299, 8, 4123, 776, 776, 267, 13505, 3181, 1133, 10266, 12, 1642, 8976, 486, 1436, 15870, 267, 1706, 681, 85, 20053, 8, 334, 1647, 24104, 2462, 20682, 339, 2467, 2305, 8310, 3299, 8, 4123, 20682, 272, 2467, 2305, 9625, 3299, 8, 2462, 5118, 1389, 281, 20682, 272, 2467, 2305, 1084, 3299, 8, 2462, 5118, 1389, 281, 12, 4123, 20682, 272, 2467, 2305, 9637, 1575, 11005, 8, 2671, 5118, 1389, 281, 2736, 199, 93, 199, 199, 1986, 2309, 3378, 2223, 8, 2309, 776, 199, 91, 272, 9576, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
PeridotYouClod/gRPC-Makerboards
generated/proto_out/sensors_pb2_grpc.py
1
20413
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc import generated.proto_out.sensors_pb2 as sensors__pb2 class FrontEndStub(object): """http://www.grpc.io/docs/guides/concepts.html is good reference for #tags #FrontEnd #Simple The FrontEnd server is the endpoint that most client interactions should use. These are public facing and used by servers in the outside world. Note: Currently there is no security in place so this should only be used for localhost applications only be used behind a firewall. """ def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.GetLux = channel.unary_unary( '/FrontEnd/GetLux', request_serializer=sensors__pb2.GetLuxRequest.SerializeToString, response_deserializer=sensors__pb2.GetLuxReply.FromString, ) self.GetTemperature = channel.unary_unary( '/FrontEnd/GetTemperature', request_serializer=sensors__pb2.GetTemperatureRequest.SerializeToString, response_deserializer=sensors__pb2.GetTemperatureReply.FromString, ) self.GetSound = channel.unary_unary( '/FrontEnd/GetSound', request_serializer=sensors__pb2.GetSoundRequest.SerializeToString, response_deserializer=sensors__pb2.GetSoundReply.FromString, ) self.GetIrButtonPressed = channel.unary_unary( '/FrontEnd/GetIrButtonPressed', request_serializer=sensors__pb2.GetIrButtonPressedRequest.SerializeToString, response_deserializer=sensors__pb2.GetIrButtonPressedReply.FromString, ) self.GetSonar = channel.unary_unary( '/FrontEnd/GetSonar', request_serializer=sensors__pb2.GetSonarRequest.SerializeToString, response_deserializer=sensors__pb2.GetSonarReply.FromString, ) self.SetLedStrip = channel.unary_unary( '/FrontEnd/SetLedStrip', request_serializer=sensors__pb2.SetLedStripRequest.SerializeToString, response_deserializer=sensors__pb2.SetLedStripReply.FromString, ) self.GetButtonPressed = channel.unary_unary( '/FrontEnd/GetButtonPressed', request_serializer=sensors__pb2.GetButtonPressedRequest.SerializeToString, response_deserializer=sensors__pb2.GetButtonPressedReply.FromString, ) self.SendToRfBlaster = channel.unary_unary( '/FrontEnd/SendToRfBlaster', request_serializer=sensors__pb2.SendToRfBlasterRequest.SerializeToString, response_deserializer=sensors__pb2.SendToRfBlasterReply.FromString, ) class FrontEndServicer(object): """http://www.grpc.io/docs/guides/concepts.html is good reference for #tags #FrontEnd #Simple The FrontEnd server is the endpoint that most client interactions should use. These are public facing and used by servers in the outside world. Note: Currently there is no security in place so this should only be used for localhost applications only be used behind a firewall. """ def GetLux(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetTemperature(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetSound(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetIrButtonPressed(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetSonar(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def SetLedStrip(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetButtonPressed(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def SendToRfBlaster(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def add_FrontEndServicer_to_server(servicer, server): rpc_method_handlers = { 'GetLux': grpc.unary_unary_rpc_method_handler( servicer.GetLux, request_deserializer=sensors__pb2.GetLuxRequest.FromString, response_serializer=sensors__pb2.GetLuxReply.SerializeToString, ), 'GetTemperature': grpc.unary_unary_rpc_method_handler( servicer.GetTemperature, request_deserializer=sensors__pb2.GetTemperatureRequest.FromString, response_serializer=sensors__pb2.GetTemperatureReply.SerializeToString, ), 'GetSound': grpc.unary_unary_rpc_method_handler( servicer.GetSound, request_deserializer=sensors__pb2.GetSoundRequest.FromString, response_serializer=sensors__pb2.GetSoundReply.SerializeToString, ), 'GetIrButtonPressed': grpc.unary_unary_rpc_method_handler( servicer.GetIrButtonPressed, request_deserializer=sensors__pb2.GetIrButtonPressedRequest.FromString, response_serializer=sensors__pb2.GetIrButtonPressedReply.SerializeToString, ), 'GetSonar': grpc.unary_unary_rpc_method_handler( servicer.GetSonar, request_deserializer=sensors__pb2.GetSonarRequest.FromString, response_serializer=sensors__pb2.GetSonarReply.SerializeToString, ), 'SetLedStrip': grpc.unary_unary_rpc_method_handler( servicer.SetLedStrip, request_deserializer=sensors__pb2.SetLedStripRequest.FromString, response_serializer=sensors__pb2.SetLedStripReply.SerializeToString, ), 'GetButtonPressed': grpc.unary_unary_rpc_method_handler( servicer.GetButtonPressed, request_deserializer=sensors__pb2.GetButtonPressedRequest.FromString, response_serializer=sensors__pb2.GetButtonPressedReply.SerializeToString, ), 'SendToRfBlaster': grpc.unary_unary_rpc_method_handler( servicer.SendToRfBlaster, request_deserializer=sensors__pb2.SendToRfBlasterRequest.FromString, response_serializer=sensors__pb2.SendToRfBlasterReply.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( 'FrontEnd', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) class PushFrontEndStub(object): """#FrontEnd #ServerStreaming The FrontEnd server is the endpoint that most client interactions should use. These are public facing and used by servers in the outside world. This server is for streaming events. Note: Currently there is no security in place so this should only be used for localhost applications only be used behind a firewall. """ def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.Subscribe = channel.unary_unary( '/PushFrontEnd/Subscribe', request_serializer=sensors__pb2.SubscribeRequest.SerializeToString, response_deserializer=sensors__pb2.SubscribeReply.FromString, ) self.StreamButtonPressed = channel.unary_stream( '/PushFrontEnd/StreamButtonPressed', request_serializer=sensors__pb2.GetButtonPressedRequest.SerializeToString, response_deserializer=sensors__pb2.GetButtonPressedReply.FromString, ) class PushFrontEndServicer(object): """#FrontEnd #ServerStreaming The FrontEnd server is the endpoint that most client interactions should use. These are public facing and used by servers in the outside world. This server is for streaming events. Note: Currently there is no security in place so this should only be used for localhost applications only be used behind a firewall. """ def Subscribe(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def StreamButtonPressed(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def add_PushFrontEndServicer_to_server(servicer, server): rpc_method_handlers = { 'Subscribe': grpc.unary_unary_rpc_method_handler( servicer.Subscribe, request_deserializer=sensors__pb2.SubscribeRequest.FromString, response_serializer=sensors__pb2.SubscribeReply.SerializeToString, ), 'StreamButtonPressed': grpc.unary_stream_rpc_method_handler( servicer.StreamButtonPressed, request_deserializer=sensors__pb2.GetButtonPressedRequest.FromString, response_serializer=sensors__pb2.GetButtonPressedReply.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( 'PushFrontEnd', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) class ArduinoStub(object): """#Backend #Simple Arduino server handles interactions between Arduino brand devices & other servers. (New to Arduino: https://www.arduino.cc/en/Guide/Introduction) Note: Do not have clients depend on this it should be behind a FrontEnd. """ def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.GetIrButtonPressed = channel.unary_unary( '/Arduino/GetIrButtonPressed', request_serializer=sensors__pb2.GetIrButtonPressedRequest.SerializeToString, response_deserializer=sensors__pb2.GetIrButtonPressedReply.FromString, ) self.GetSonar = channel.unary_unary( '/Arduino/GetSonar', request_serializer=sensors__pb2.GetSonarRequest.SerializeToString, response_deserializer=sensors__pb2.GetSonarReply.FromString, ) self.SendToRfBlaster = channel.unary_unary( '/Arduino/SendToRfBlaster', request_serializer=sensors__pb2.SendToRfBlasterRequest.SerializeToString, response_deserializer=sensors__pb2.SendToRfBlasterReply.FromString, ) class ArduinoServicer(object): """#Backend #Simple Arduino server handles interactions between Arduino brand devices & other servers. (New to Arduino: https://www.arduino.cc/en/Guide/Introduction) Note: Do not have clients depend on this it should be behind a FrontEnd. """ def GetIrButtonPressed(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetSonar(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def SendToRfBlaster(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def add_ArduinoServicer_to_server(servicer, server): rpc_method_handlers = { 'GetIrButtonPressed': grpc.unary_unary_rpc_method_handler( servicer.GetIrButtonPressed, request_deserializer=sensors__pb2.GetIrButtonPressedRequest.FromString, response_serializer=sensors__pb2.GetIrButtonPressedReply.SerializeToString, ), 'GetSonar': grpc.unary_unary_rpc_method_handler( servicer.GetSonar, request_deserializer=sensors__pb2.GetSonarRequest.FromString, response_serializer=sensors__pb2.GetSonarReply.SerializeToString, ), 'SendToRfBlaster': grpc.unary_unary_rpc_method_handler( servicer.SendToRfBlaster, request_deserializer=sensors__pb2.SendToRfBlasterRequest.FromString, response_serializer=sensors__pb2.SendToRfBlasterReply.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( 'Arduino', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) class WioLinkStub(object): """#Backend #Simple WioLink server handles interactions between Wio Link brand devices & other servers. (New to Wio Link: http://wiki.seeed.cc/Wio_Link/) Note: Do not have clients depend on this it should be behind a FrontEnd. """ def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.GetLux = channel.unary_unary( '/WioLink/GetLux', request_serializer=sensors__pb2.GetLuxRequest.SerializeToString, response_deserializer=sensors__pb2.GetLuxReply.FromString, ) self.GetTemperature = channel.unary_unary( '/WioLink/GetTemperature', request_serializer=sensors__pb2.GetTemperatureRequest.SerializeToString, response_deserializer=sensors__pb2.GetTemperatureReply.FromString, ) self.GetSound = channel.unary_unary( '/WioLink/GetSound', request_serializer=sensors__pb2.GetSoundRequest.SerializeToString, response_deserializer=sensors__pb2.GetSoundReply.FromString, ) self.SetLedStrip = channel.unary_unary( '/WioLink/SetLedStrip', request_serializer=sensors__pb2.SetLedStripRequest.SerializeToString, response_deserializer=sensors__pb2.SetLedStripReply.FromString, ) self.GetButtonPressed = channel.unary_unary( '/WioLink/GetButtonPressed', request_serializer=sensors__pb2.GetButtonPressedRequest.SerializeToString, response_deserializer=sensors__pb2.GetButtonPressedReply.FromString, ) class WioLinkServicer(object): """#Backend #Simple WioLink server handles interactions between Wio Link brand devices & other servers. (New to Wio Link: http://wiki.seeed.cc/Wio_Link/) Note: Do not have clients depend on this it should be behind a FrontEnd. """ def GetLux(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetTemperature(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetSound(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def SetLedStrip(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def GetButtonPressed(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def add_WioLinkServicer_to_server(servicer, server): rpc_method_handlers = { 'GetLux': grpc.unary_unary_rpc_method_handler( servicer.GetLux, request_deserializer=sensors__pb2.GetLuxRequest.FromString, response_serializer=sensors__pb2.GetLuxReply.SerializeToString, ), 'GetTemperature': grpc.unary_unary_rpc_method_handler( servicer.GetTemperature, request_deserializer=sensors__pb2.GetTemperatureRequest.FromString, response_serializer=sensors__pb2.GetTemperatureReply.SerializeToString, ), 'GetSound': grpc.unary_unary_rpc_method_handler( servicer.GetSound, request_deserializer=sensors__pb2.GetSoundRequest.FromString, response_serializer=sensors__pb2.GetSoundReply.SerializeToString, ), 'SetLedStrip': grpc.unary_unary_rpc_method_handler( servicer.SetLedStrip, request_deserializer=sensors__pb2.SetLedStripRequest.FromString, response_serializer=sensors__pb2.SetLedStripReply.SerializeToString, ), 'GetButtonPressed': grpc.unary_unary_rpc_method_handler( servicer.GetButtonPressed, request_deserializer=sensors__pb2.GetButtonPressedRequest.FromString, response_serializer=sensors__pb2.GetButtonPressedReply.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( 'WioLink', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) class PushStub(object): """#ServerStreaming #Backend Push server pushes data when a sensor event occurs for the client to react to. """ def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.Subscribe = channel.unary_unary( '/Push/Subscribe', request_serializer=sensors__pb2.SubscribeRequest.SerializeToString, response_deserializer=sensors__pb2.SubscribeReply.FromString, ) self.StreamButtonPressed = channel.unary_stream( '/Push/StreamButtonPressed', request_serializer=sensors__pb2.GetButtonPressedRequest.SerializeToString, response_deserializer=sensors__pb2.GetButtonPressedReply.FromString, ) class PushServicer(object): """#ServerStreaming #Backend Push server pushes data when a sensor event occurs for the client to react to. """ def Subscribe(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def StreamButtonPressed(self, request, context): # missing associated documentation comment in .proto file pass context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def add_PushServicer_to_server(servicer, server): rpc_method_handlers = { 'Subscribe': grpc.unary_unary_rpc_method_handler( servicer.Subscribe, request_deserializer=sensors__pb2.SubscribeRequest.FromString, response_serializer=sensors__pb2.SubscribeReply.SerializeToString, ), 'StreamButtonPressed': grpc.unary_stream_rpc_method_handler( servicer.StreamButtonPressed, request_deserializer=sensors__pb2.GetButtonPressedRequest.FromString, response_serializer=sensors__pb2.GetButtonPressedReply.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( 'Push', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,))
mit
[ 3, 17065, 701, 314, 30700, 2018, 4113, 6365, 3589, 14, 3506, 2845, 24981, 1, 199, 646, 19753, 199, 199, 646, 4046, 14, 2625, 63, 548, 14, 22675, 63, 3317, 18, 465, 19678, 363, 3317, 18, 421, 199, 533, 481, 82, 1888, 3005, 8067, 8, 785, 304, 523, 408, 1014, 921, 1544, 14, 15391, 14, 2308, 15, 4757, 15, 5885, 3424, 15, 21318, 83, 14, 1360, 365, 6954, 3659, 367, 327, 2969, 819, 327, 17607, 3005, 327, 3184, 523, 710, 481, 82, 1888, 3005, 1654, 365, 314, 6037, 626, 4750, 1890, 315, 22990, 523, 1077, 675, 14, 5723, 787, 4575, 21625, 316, 436, 1202, 701, 8037, 315, 314, 9682, 523, 6701, 14, 819, 3390, 26, 13550, 2337, 365, 949, 6391, 315, 4192, 880, 642, 1077, 1454, 506, 1202, 523, 367, 11667, 13103, 1454, 506, 1202, 22172, 282, 12042, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 3623, 304, 272, 408, 11447, 14, 339, 3033, 26, 489, 3623, 26, 437, 19753, 14, 5358, 14, 272, 408, 272, 291, 14, 1002, 44, 2521, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 44, 2521, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 44, 2521, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 44, 2521, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1002, 27409, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 27409, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 27409, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 27409, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 17526, 1034, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 17526, 1034, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 17526, 1034, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 17526, 1034, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1002, 32602, 4259, 32153, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 32602, 4259, 32153, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 32602, 4259, 32153, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 32602, 4259, 32153, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 17526, 265, 285, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 17526, 265, 285, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 17526, 265, 285, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 17526, 265, 285, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1084, 44, 379, 21332, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1084, 44, 379, 21332, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1084, 44, 379, 21332, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1084, 44, 379, 21332, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1002, 4259, 32153, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 4259, 32153, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 4259, 32153, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 4259, 32153, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 6795, 1378, 28115, 24613, 2311, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 6795, 1378, 28115, 24613, 2311, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 6795, 1378, 28115, 24613, 2311, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 6795, 1378, 28115, 24613, 2311, 14166, 14, 7671, 12, 267, 776, 421, 199, 533, 481, 82, 1888, 3005, 1505, 30150, 8, 785, 304, 523, 408, 1014, 921, 1544, 14, 15391, 14, 2308, 15, 4757, 15, 5885, 3424, 15, 21318, 83, 14, 1360, 365, 6954, 3659, 367, 327, 2969, 819, 327, 17607, 3005, 327, 3184, 523, 710, 481, 82, 1888, 3005, 1654, 365, 314, 6037, 626, 4750, 1890, 315, 22990, 523, 1077, 675, 14, 5723, 787, 4575, 21625, 316, 436, 1202, 701, 8037, 315, 314, 9682, 523, 6701, 14, 819, 3390, 26, 13550, 2337, 365, 949, 6391, 315, 4192, 880, 642, 1077, 1454, 506, 1202, 523, 367, 11667, 13103, 1454, 506, 1202, 22172, 282, 12042, 14, 523, 408, 819, 347, 2372, 44, 2521, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 27409, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 18670, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 32602, 4259, 32153, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 51, 265, 285, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409 ]
[ 17065, 701, 314, 30700, 2018, 4113, 6365, 3589, 14, 3506, 2845, 24981, 1, 199, 646, 19753, 199, 199, 646, 4046, 14, 2625, 63, 548, 14, 22675, 63, 3317, 18, 465, 19678, 363, 3317, 18, 421, 199, 533, 481, 82, 1888, 3005, 8067, 8, 785, 304, 523, 408, 1014, 921, 1544, 14, 15391, 14, 2308, 15, 4757, 15, 5885, 3424, 15, 21318, 83, 14, 1360, 365, 6954, 3659, 367, 327, 2969, 819, 327, 17607, 3005, 327, 3184, 523, 710, 481, 82, 1888, 3005, 1654, 365, 314, 6037, 626, 4750, 1890, 315, 22990, 523, 1077, 675, 14, 5723, 787, 4575, 21625, 316, 436, 1202, 701, 8037, 315, 314, 9682, 523, 6701, 14, 819, 3390, 26, 13550, 2337, 365, 949, 6391, 315, 4192, 880, 642, 1077, 1454, 506, 1202, 523, 367, 11667, 13103, 1454, 506, 1202, 22172, 282, 12042, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 3623, 304, 272, 408, 11447, 14, 339, 3033, 26, 489, 3623, 26, 437, 19753, 14, 5358, 14, 272, 408, 272, 291, 14, 1002, 44, 2521, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 44, 2521, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 44, 2521, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 44, 2521, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1002, 27409, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 27409, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 27409, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 27409, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 17526, 1034, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 17526, 1034, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 17526, 1034, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 17526, 1034, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1002, 32602, 4259, 32153, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 32602, 4259, 32153, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 32602, 4259, 32153, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 32602, 4259, 32153, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 17526, 265, 285, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 17526, 265, 285, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 17526, 265, 285, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 17526, 265, 285, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1084, 44, 379, 21332, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1084, 44, 379, 21332, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1084, 44, 379, 21332, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1084, 44, 379, 21332, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 1002, 4259, 32153, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 1002, 4259, 32153, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 1002, 4259, 32153, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 1002, 4259, 32153, 14166, 14, 7671, 12, 267, 776, 272, 291, 14, 6795, 1378, 28115, 24613, 2311, 275, 3623, 14, 13124, 63, 13124, 8, 267, 1994, 17607, 3005, 15, 6795, 1378, 28115, 24613, 2311, 297, 267, 1056, 63, 8349, 29, 22675, 363, 3317, 18, 14, 6795, 1378, 28115, 24613, 2311, 2017, 14, 9436, 12, 267, 1177, 63, 27470, 29, 22675, 363, 3317, 18, 14, 6795, 1378, 28115, 24613, 2311, 14166, 14, 7671, 12, 267, 776, 421, 199, 533, 481, 82, 1888, 3005, 1505, 30150, 8, 785, 304, 523, 408, 1014, 921, 1544, 14, 15391, 14, 2308, 15, 4757, 15, 5885, 3424, 15, 21318, 83, 14, 1360, 365, 6954, 3659, 367, 327, 2969, 819, 327, 17607, 3005, 327, 3184, 523, 710, 481, 82, 1888, 3005, 1654, 365, 314, 6037, 626, 4750, 1890, 315, 22990, 523, 1077, 675, 14, 5723, 787, 4575, 21625, 316, 436, 1202, 701, 8037, 315, 314, 9682, 523, 6701, 14, 819, 3390, 26, 13550, 2337, 365, 949, 6391, 315, 4192, 880, 642, 1077, 1454, 506, 1202, 523, 367, 11667, 13103, 1454, 506, 1202, 22172, 282, 12042, 14, 523, 408, 819, 347, 2372, 44, 2521, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 27409, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 18670, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 32602, 4259, 32153, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 63, 5087, 360, 3767, 440, 6366, 10916, 272, 746, 4279, 360, 3767, 440, 6366, 10916, 819, 347, 2372, 51, 265, 285, 8, 277, 12, 1056, 12, 1067, 304, 272, 327, 4124, 4568, 3794, 3721, 315, 1275, 2625, 570, 272, 986, 272, 1067, 14, 409, 63, 600, 8, 15391, 14, 23018, 14, 1734, 8947, 10320, 1149, 9, 272, 1067, 14, 409, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
skirpichev/omg
diofant/vector/dyadic.py
1
8076
from ..core import AtomicExpr, Integer, Pow from ..matrices import ImmutableMatrix from .basisdependent import (BasisDependent, BasisDependentAdd, BasisDependentMul, BasisDependentZero) class Dyadic(BasisDependent): """ Super class for all Dyadic-classes. References ========== * https://en.wikipedia.org/wiki/Dyadic_tensor * Kane, T., Levinson, D. Dynamics Theory and Applications. 1985 McGraw-Hill """ _op_priority = 13.0 @property def components(self): """ Returns the components of this dyadic in the form of a Python dictionary mapping BaseDyadic instances to the corresponding measure numbers. """ # The '_components' attribute is defined according to the # subclass of Dyadic the instance belongs to. return self._components def dot(self, other): """ Returns the dot product(also called inner product) of this Dyadic, with another Dyadic or Vector. If 'other' is a Dyadic, this returns a Dyadic. Else, it returns a Vector (unless an error is encountered). Parameters ========== other : Dyadic/Vector The other Dyadic or Vector to take the inner product with Examples ======== >>> from diofant.vector import CoordSysCartesian >>> N = CoordSysCartesian('N') >>> D1 = N.i.outer(N.j) >>> D2 = N.j.outer(N.j) >>> D1.dot(D2) (N.i|N.j) >>> D1.dot(N.j) N.i """ from .vector import Vector if isinstance(other, BasisDependentZero): return Vector.zero elif isinstance(other, Vector): outvec = Vector.zero for k, v in self.components.items(): vect_dot = k.args[1].dot(other) outvec += vect_dot * v * k.args[0] return outvec elif isinstance(other, Dyadic): outdyad = Dyadic.zero for k1, v1 in self.components.items(): for k2, v2 in other.components.items(): vect_dot = k1.args[1].dot(k2.args[0]) outer_product = k1.args[0].outer(k2.args[1]) outdyad += vect_dot * v1 * v2 * outer_product return outdyad else: raise TypeError('Inner product is not defined for ' + str(type(other)) + ' and Dyadics.') def __and__(self, other): return self.dot(other) __and__.__doc__ = dot.__doc__ def cross(self, other): """ Returns the cross product between this Dyadic, and a Vector, as a Vector instance. Parameters ========== other : Vector The Vector that we are crossing this Dyadic with Examples ======== >>> from diofant.vector import CoordSysCartesian >>> N = CoordSysCartesian('N') >>> d = N.i.outer(N.i) >>> d.cross(N.j) (N.i|N.k) """ from .vector import Vector if other == Vector.zero: return Dyadic.zero elif isinstance(other, Vector): outdyad = Dyadic.zero for k, v in self.components.items(): cross_product = k.args[1].cross(other) outer = k.args[0].outer(cross_product) outdyad += v * outer return outdyad else: raise TypeError(str(type(other)) + ' not supported for ' + 'cross with dyadics') def __xor__(self, other): return self.cross(other) __xor__.__doc__ = cross.__doc__ def to_matrix(self, system, second_system=None): """ Returns the matrix form of the dyadic with respect to one or two coordinate systems. Parameters ========== system : CoordSysCartesian The coordinate system that the rows and columns of the matrix correspond to. If a second system is provided, this only corresponds to the rows of the matrix. second_system : CoordSysCartesian, optional, default=None The coordinate system that the columns of the matrix correspond to. Examples ======== >>> from diofant.vector import CoordSysCartesian >>> N = CoordSysCartesian('N') >>> v = N.i + 2*N.j >>> d = v.outer(N.i) >>> d.to_matrix(N) Matrix([ [1, 0, 0], [2, 0, 0], [0, 0, 0]]) >>> q = Symbol('q') >>> P = N.orient_new_axis('P', q, N.k) >>> d.to_matrix(N, P) Matrix([ [ cos(q), -sin(q), 0], [2*cos(q), -2*sin(q), 0], [ 0, 0, 0]]) """ if second_system is None: second_system = system return ImmutableMatrix([i.dot(self).dot(j) for i in system for j in second_system]).reshape(3, 3) class BaseDyadic(Dyadic, AtomicExpr): """Class to denote a base dyadic tensor component.""" def __new__(cls, vector1, vector2): from .vector import Vector, BaseVector, VectorZero # Verify arguments if not isinstance(vector1, (BaseVector, VectorZero)) or \ not isinstance(vector2, (BaseVector, VectorZero)): raise TypeError('BaseDyadic cannot be composed of non-base ' + 'vectors') # Handle special case of zero vector elif vector1 == Vector.zero or vector2 == Vector.zero: return Dyadic.zero # Initialize instance obj = super().__new__(cls, vector1, vector2) obj._base_instance = obj obj._measure_number = 1 obj._components = {obj: Integer(1)} obj._sys = vector1._sys obj._pretty_form = ('(' + vector1._pretty_form + '|' + vector2._pretty_form + ')') obj._latex_form = ('(' + vector1._latex_form + '{|}' + vector2._latex_form + ')') return obj def __str__(self, printer=None): return '(' + str(self.args[0]) + '|' + str(self.args[1]) + ')' _diofantstr = __str__ _diofantrepr = _diofantstr class DyadicMul(BasisDependentMul, Dyadic): """Products of scalars and BaseDyadics.""" def __new__(cls, *args, **options): obj = BasisDependentMul.__new__(cls, *args, **options) return obj @property def base_dyadic(self): """The BaseDyadic involved in the product.""" return self._base_instance @property def measure_number(self): """The scalar expression involved in the definition of this DyadicMul. """ return self._measure_number class DyadicAdd(BasisDependentAdd, Dyadic): """Class to hold dyadic sums.""" def __new__(cls, *args, **options): obj = BasisDependentAdd.__new__(cls, *args, **options) return obj def __str__(self, printer=None): ret_str = '' items = list(self.components.items()) items.sort(key=lambda x: x[0].__str__()) for k, v in items: temp_dyad = k * v ret_str += temp_dyad.__str__(printer) + ' + ' return ret_str[:-3] __repr__ = __str__ _diofantstr = __str__ class DyadicZero(BasisDependentZero, Dyadic): """Class to denote a zero dyadic.""" _op_priority = 13.1 _pretty_form = '(0|0)' _latex_form = r'(\mathbf{\hat{0}}|\mathbf{\hat{0}})' def __new__(cls): obj = BasisDependentZero.__new__(cls) return obj def _dyad_div(one, other): """Helper for division involving dyadics.""" if isinstance(other, Dyadic): raise TypeError('Cannot divide two dyadics') else: return DyadicMul(one, Pow(other, -1)) Dyadic._expr_type = Dyadic Dyadic._mul_func = DyadicMul Dyadic._add_func = DyadicAdd Dyadic._zero_func = DyadicZero Dyadic._base_func = BaseDyadic Dyadic._div_helper = _dyad_div Dyadic.zero = DyadicZero()
bsd-3-clause
[ 504, 2508, 1018, 492, 18840, 530, 8561, 12, 7225, 12, 510, 583, 199, 504, 2508, 19032, 492, 25609, 6443, 199, 504, 1275, 19220, 7106, 492, 334, 34, 4864, 872, 5476, 12, 699, 4864, 872, 5476, 1123, 12, 2490, 699, 4864, 872, 5476, 16867, 12, 699, 4864, 872, 5476, 8681, 9, 421, 199, 533, 577, 11552, 5000, 8, 34, 4864, 872, 5476, 304, 272, 408, 272, 17897, 1021, 367, 1006, 577, 11552, 5000, 13, 2888, 14, 339, 14504, 272, 21938, 339, 627, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 36, 11552, 5000, 63, 3128, 272, 627, 1804, 5865, 12, 377, 2020, 491, 6857, 262, 834, 12, 577, 14, 577, 4019, 2932, 710, 1089, 436, 24636, 14, 5851, 2426, 22895, 39, 1773, 13, 40, 778, 339, 408, 339, 485, 411, 63, 6693, 275, 4944, 14, 16, 339, 768, 1829, 272, 347, 7323, 8, 277, 304, 267, 408, 267, 1803, 314, 7323, 402, 642, 366, 11552, 5000, 315, 314, 1824, 402, 282, 267, 2018, 2600, 4412, 3523, 36, 11552, 5000, 4454, 370, 314, 267, 5226, 9775, 5579, 14, 398, 408, 267, 327, 710, 2513, 4608, 7, 2225, 365, 3247, 7182, 370, 314, 267, 327, 5516, 402, 577, 11552, 5000, 314, 1256, 15006, 370, 14, 267, 372, 291, 423, 4608, 339, 347, 6308, 8, 277, 12, 1163, 304, 267, 408, 267, 1803, 314, 6308, 3336, 8, 12344, 2797, 6506, 3336, 9, 402, 642, 267, 577, 11552, 5000, 12, 543, 4573, 577, 11552, 5000, 503, 11388, 14, 267, 982, 283, 1848, 7, 365, 282, 577, 11552, 5000, 12, 642, 2529, 282, 577, 11552, 5000, 14, 19524, 12, 652, 2529, 267, 282, 11388, 334, 18447, 376, 1125, 365, 14556, 680, 398, 3897, 267, 21938, 398, 1163, 520, 577, 11552, 5000, 15, 3646, 288, 710, 1163, 577, 11552, 5000, 503, 11388, 370, 5452, 314, 6506, 3336, 543, 398, 6058, 267, 12655, 398, 1306, 687, 487, 1618, 867, 14, 4106, 492, 1849, 2181, 11319, 16034, 19157, 267, 1306, 653, 275, 1849, 2181, 11319, 16034, 19157, 360, 46, 358, 267, 1306, 577, 17, 275, 653, 14, 73, 14, 7837, 8, 46, 14, 74, 9, 267, 1306, 577, 18, 275, 653, 14, 74, 14, 7837, 8, 46, 14, 74, 9, 267, 1306, 577, 17, 14, 3287, 8, 36, 18, 9, 267, 334, 46, 14, 73, 92, 46, 14, 74, 9, 267, 1306, 577, 17, 14, 3287, 8, 46, 14, 74, 9, 267, 653, 14, 73, 398, 408, 267, 687, 1275, 4106, 492, 11388, 398, 340, 1228, 8, 1848, 12, 699, 4864, 872, 5476, 8681, 304, 288, 372, 11388, 14, 4262, 267, 916, 1228, 8, 1848, 12, 11388, 304, 288, 734, 6046, 275, 11388, 14, 4262, 288, 367, 1022, 12, 373, 315, 291, 14, 4608, 14, 1744, 837, 355, 373, 449, 63, 3287, 275, 1022, 14, 589, 59, 17, 1055, 3287, 8, 1848, 9, 355, 734, 6046, 847, 373, 449, 63, 3287, 627, 373, 627, 1022, 14, 589, 59, 16, 61, 288, 372, 734, 6046, 267, 916, 1228, 8, 1848, 12, 577, 11552, 5000, 304, 288, 734, 8161, 350, 275, 577, 11552, 5000, 14, 4262, 288, 367, 1022, 17, 12, 373, 17, 315, 291, 14, 4608, 14, 1744, 837, 355, 367, 1022, 18, 12, 373, 18, 315, 1163, 14, 4608, 14, 1744, 837, 490, 373, 449, 63, 3287, 275, 1022, 17, 14, 589, 59, 17, 1055, 3287, 8, 75, 18, 14, 589, 59, 16, 566, 490, 6890, 63, 2558, 275, 1022, 17, 14, 589, 59, 16, 1055, 7837, 8, 75, 18, 14, 589, 59, 17, 566, 490, 734, 8161, 350, 847, 373, 449, 63, 3287, 627, 373, 17, 627, 373, 18, 627, 6890, 63, 2558, 288, 372, 734, 8161, 350, 267, 587, 26, 288, 746, 3146, 360, 22964, 3336, 365, 440, 3247, 367, 283, 435, 1169, 620, 8, 466, 8, 1848, 430, 435, 283, 436, 577, 11552, 328, 1259, 2659, 339, 347, 636, 460, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 3287, 8, 1848, 9, 272, 636, 460, 4914, 1301, 363, 275, 6308, 855, 1301, 363, 339, 347, 8059, 8, 277, 12, 1163, 304, 267, 408, 267, 1803, 314, 8059, 3336, 3382, 642, 577, 11552, 5000, 12, 436, 282, 11388, 12, 465, 282, 267, 11388, 1256, 14, 398, 3897, 267, 21938, 398, 1163, 520, 11388, 288, 710, 11388, 626, 781, 787, 8059, 316, 642, 577, 11552, 5000, 543, 398, 6058, 267, 12655, 398, 1306, 687, 487, 1618, 867, 14, 4106, 492, 1849, 2181, 11319, 16034, 19157, 267, 1306, 653, 275, 1849, 2181, 11319, 16034, 19157, 360, 46, 358, 267, 1306, 366, 275, 653, 14, 73, 14, 7837, 8, 46, 14, 73, 9, 267, 1306, 366, 14, 7925, 8, 46, 14, 74, 9, 267, 334, 46, 14, 73, 92, 46, 14, 75, 9, 398, 408, 267, 687, 1275, 4106, 492, 11388, 398, 340, 1163, 508, 11388, 14, 4262, 26, 288, 372, 577, 11552, 5000, 14, 4262, 267, 916, 1228, 8, 1848, 12, 11388, 304, 288, 734, 8161, 350, 275, 577, 11552, 5000, 14, 4262, 288, 367, 1022, 12, 373, 315, 291, 14, 4608, 14, 1744, 837, 355, 8059, 63, 2558, 275, 1022, 14, 589, 59, 17, 1055, 7925, 8, 1848, 9, 355, 6890, 275, 1022, 14, 589, 59, 16, 1055, 7837, 8, 7925, 63, 2558, 9, 355, 734, 8161, 350, 847, 373, 627, 6890, 288, 372, 734, 8161, 350, 267, 587, 26, 288, 746, 3146, 8, 495, 8, 466, 8, 1848, 430, 435, 283, 440, 3748, 367, 283, 435, 1169, 283, 7925, 543, 366, 11552, 328, 1259, 358, 339, 347, 636, 15721, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 7925, 8, 1848, 9, 272, 636, 15721, 4914, 1301, 363, 275, 8059, 855, 1301, 363, 339, 347, 370, 63, 3642, 8, 277, 12, 2656, 12, 3499, 63, 2253, 29, 403, 304, 267, 408, 267, 1803, 314, 3634, 1824, 402, 314, 366, 11552, 5000, 543, 14021, 370, 1373, 503, 2877, 267, 10021, 10460, 14, 398, 3897, 267, 21938, 398, 2656, 520, 1849, 2181, 11319, 16034, 19157, 288, 710, 10021, 2656, 626, 314, 4730, 436, 4362, 402, 314, 3634, 288, 17118, 370, 14, 982, 282, 3499, 2656, 365, 2741, 12, 642, 288, 1454, 13718, 370, 314, 4730, 402, 314, 3634, 14, 267, 3499, 63, 2253, 520, 1849, 2181, 11319, 16034, 19157, 12 ]
[ 2508, 1018, 492, 18840, 530, 8561, 12, 7225, 12, 510, 583, 199, 504, 2508, 19032, 492, 25609, 6443, 199, 504, 1275, 19220, 7106, 492, 334, 34, 4864, 872, 5476, 12, 699, 4864, 872, 5476, 1123, 12, 2490, 699, 4864, 872, 5476, 16867, 12, 699, 4864, 872, 5476, 8681, 9, 421, 199, 533, 577, 11552, 5000, 8, 34, 4864, 872, 5476, 304, 272, 408, 272, 17897, 1021, 367, 1006, 577, 11552, 5000, 13, 2888, 14, 339, 14504, 272, 21938, 339, 627, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 36, 11552, 5000, 63, 3128, 272, 627, 1804, 5865, 12, 377, 2020, 491, 6857, 262, 834, 12, 577, 14, 577, 4019, 2932, 710, 1089, 436, 24636, 14, 5851, 2426, 22895, 39, 1773, 13, 40, 778, 339, 408, 339, 485, 411, 63, 6693, 275, 4944, 14, 16, 339, 768, 1829, 272, 347, 7323, 8, 277, 304, 267, 408, 267, 1803, 314, 7323, 402, 642, 366, 11552, 5000, 315, 314, 1824, 402, 282, 267, 2018, 2600, 4412, 3523, 36, 11552, 5000, 4454, 370, 314, 267, 5226, 9775, 5579, 14, 398, 408, 267, 327, 710, 2513, 4608, 7, 2225, 365, 3247, 7182, 370, 314, 267, 327, 5516, 402, 577, 11552, 5000, 314, 1256, 15006, 370, 14, 267, 372, 291, 423, 4608, 339, 347, 6308, 8, 277, 12, 1163, 304, 267, 408, 267, 1803, 314, 6308, 3336, 8, 12344, 2797, 6506, 3336, 9, 402, 642, 267, 577, 11552, 5000, 12, 543, 4573, 577, 11552, 5000, 503, 11388, 14, 267, 982, 283, 1848, 7, 365, 282, 577, 11552, 5000, 12, 642, 2529, 282, 577, 11552, 5000, 14, 19524, 12, 652, 2529, 267, 282, 11388, 334, 18447, 376, 1125, 365, 14556, 680, 398, 3897, 267, 21938, 398, 1163, 520, 577, 11552, 5000, 15, 3646, 288, 710, 1163, 577, 11552, 5000, 503, 11388, 370, 5452, 314, 6506, 3336, 543, 398, 6058, 267, 12655, 398, 1306, 687, 487, 1618, 867, 14, 4106, 492, 1849, 2181, 11319, 16034, 19157, 267, 1306, 653, 275, 1849, 2181, 11319, 16034, 19157, 360, 46, 358, 267, 1306, 577, 17, 275, 653, 14, 73, 14, 7837, 8, 46, 14, 74, 9, 267, 1306, 577, 18, 275, 653, 14, 74, 14, 7837, 8, 46, 14, 74, 9, 267, 1306, 577, 17, 14, 3287, 8, 36, 18, 9, 267, 334, 46, 14, 73, 92, 46, 14, 74, 9, 267, 1306, 577, 17, 14, 3287, 8, 46, 14, 74, 9, 267, 653, 14, 73, 398, 408, 267, 687, 1275, 4106, 492, 11388, 398, 340, 1228, 8, 1848, 12, 699, 4864, 872, 5476, 8681, 304, 288, 372, 11388, 14, 4262, 267, 916, 1228, 8, 1848, 12, 11388, 304, 288, 734, 6046, 275, 11388, 14, 4262, 288, 367, 1022, 12, 373, 315, 291, 14, 4608, 14, 1744, 837, 355, 373, 449, 63, 3287, 275, 1022, 14, 589, 59, 17, 1055, 3287, 8, 1848, 9, 355, 734, 6046, 847, 373, 449, 63, 3287, 627, 373, 627, 1022, 14, 589, 59, 16, 61, 288, 372, 734, 6046, 267, 916, 1228, 8, 1848, 12, 577, 11552, 5000, 304, 288, 734, 8161, 350, 275, 577, 11552, 5000, 14, 4262, 288, 367, 1022, 17, 12, 373, 17, 315, 291, 14, 4608, 14, 1744, 837, 355, 367, 1022, 18, 12, 373, 18, 315, 1163, 14, 4608, 14, 1744, 837, 490, 373, 449, 63, 3287, 275, 1022, 17, 14, 589, 59, 17, 1055, 3287, 8, 75, 18, 14, 589, 59, 16, 566, 490, 6890, 63, 2558, 275, 1022, 17, 14, 589, 59, 16, 1055, 7837, 8, 75, 18, 14, 589, 59, 17, 566, 490, 734, 8161, 350, 847, 373, 449, 63, 3287, 627, 373, 17, 627, 373, 18, 627, 6890, 63, 2558, 288, 372, 734, 8161, 350, 267, 587, 26, 288, 746, 3146, 360, 22964, 3336, 365, 440, 3247, 367, 283, 435, 1169, 620, 8, 466, 8, 1848, 430, 435, 283, 436, 577, 11552, 328, 1259, 2659, 339, 347, 636, 460, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 3287, 8, 1848, 9, 272, 636, 460, 4914, 1301, 363, 275, 6308, 855, 1301, 363, 339, 347, 8059, 8, 277, 12, 1163, 304, 267, 408, 267, 1803, 314, 8059, 3336, 3382, 642, 577, 11552, 5000, 12, 436, 282, 11388, 12, 465, 282, 267, 11388, 1256, 14, 398, 3897, 267, 21938, 398, 1163, 520, 11388, 288, 710, 11388, 626, 781, 787, 8059, 316, 642, 577, 11552, 5000, 543, 398, 6058, 267, 12655, 398, 1306, 687, 487, 1618, 867, 14, 4106, 492, 1849, 2181, 11319, 16034, 19157, 267, 1306, 653, 275, 1849, 2181, 11319, 16034, 19157, 360, 46, 358, 267, 1306, 366, 275, 653, 14, 73, 14, 7837, 8, 46, 14, 73, 9, 267, 1306, 366, 14, 7925, 8, 46, 14, 74, 9, 267, 334, 46, 14, 73, 92, 46, 14, 75, 9, 398, 408, 267, 687, 1275, 4106, 492, 11388, 398, 340, 1163, 508, 11388, 14, 4262, 26, 288, 372, 577, 11552, 5000, 14, 4262, 267, 916, 1228, 8, 1848, 12, 11388, 304, 288, 734, 8161, 350, 275, 577, 11552, 5000, 14, 4262, 288, 367, 1022, 12, 373, 315, 291, 14, 4608, 14, 1744, 837, 355, 8059, 63, 2558, 275, 1022, 14, 589, 59, 17, 1055, 7925, 8, 1848, 9, 355, 6890, 275, 1022, 14, 589, 59, 16, 1055, 7837, 8, 7925, 63, 2558, 9, 355, 734, 8161, 350, 847, 373, 627, 6890, 288, 372, 734, 8161, 350, 267, 587, 26, 288, 746, 3146, 8, 495, 8, 466, 8, 1848, 430, 435, 283, 440, 3748, 367, 283, 435, 1169, 283, 7925, 543, 366, 11552, 328, 1259, 358, 339, 347, 636, 15721, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 7925, 8, 1848, 9, 272, 636, 15721, 4914, 1301, 363, 275, 8059, 855, 1301, 363, 339, 347, 370, 63, 3642, 8, 277, 12, 2656, 12, 3499, 63, 2253, 29, 403, 304, 267, 408, 267, 1803, 314, 3634, 1824, 402, 314, 366, 11552, 5000, 543, 14021, 370, 1373, 503, 2877, 267, 10021, 10460, 14, 398, 3897, 267, 21938, 398, 2656, 520, 1849, 2181, 11319, 16034, 19157, 288, 710, 10021, 2656, 626, 314, 4730, 436, 4362, 402, 314, 3634, 288, 17118, 370, 14, 982, 282, 3499, 2656, 365, 2741, 12, 642, 288, 1454, 13718, 370, 314, 4730, 402, 314, 3634, 14, 267, 3499, 63, 2253, 520, 1849, 2181, 11319, 16034, 19157, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
UCBerkeleySETI/blimpy
blimpy/plotting/plot_time_series.py
1
1628
from .config import * from ..utils import rebin, db from .plot_utils import calc_extent def plot_time_series(wf, f_start=None, f_stop=None, if_id=0, logged=True, orientation='h', MJD_time=False, **kwargs): """ Plot the time series. Args: f_start (float): start frequency, in MHz f_stop (float): stop frequency, in MHz logged (bool): Plot in linear (False) or dB units (True), kwargs: keyword args to be passed to matplotlib imshow() """ ax = plt.gca() plot_f, plot_data = wf.grab_data(f_start, f_stop, if_id) # Since the data has been squeezed, the axis for time goes away if only one bin, causing a bug with axis=1 if len(plot_data.shape) > 1: plot_data = np.nanmean(plot_data, axis=1) else: plot_data = np.nanmean(plot_data) if logged and wf.header['nbits'] >= 8: plot_data = db(plot_data) # Make proper time axis for plotting (but only for plotting!). Note that this makes the values inclusive. extent = calc_extent(wf, plot_f=plot_f, plot_t=wf.timestamps, MJD_time=MJD_time) plot_t = np.linspace(extent[2], extent[3], len(wf.timestamps)) if MJD_time: tlabel = "Time [MJD]" else: tlabel = "Time [s]" if logged: plabel = "Power [dB]" else: plabel = "Power [counts]" # Reverse oder if vertical orientation. if 'v' in orientation: plt.plot(plot_data, plot_t, **kwargs) plt.xlabel(plabel) else: plt.plot(plot_t, plot_data, **kwargs) plt.xlabel(tlabel) plt.ylabel(plabel) ax.autoscale(axis='both', tight=True)
bsd-3-clause
[ 504, 1275, 888, 492, 627, 199, 504, 2508, 1208, 492, 295, 1393, 12, 1592, 199, 504, 1275, 2798, 63, 1208, 492, 12831, 63, 11599, 199, 199, 318, 5137, 63, 521, 63, 5602, 8, 14114, 12, 289, 63, 928, 29, 403, 12, 289, 63, 2379, 29, 403, 12, 340, 63, 344, 29, 16, 12, 10367, 29, 549, 12, 16774, 534, 72, 297, 603, 42, 36, 63, 521, 29, 797, 12, 1011, 958, 304, 272, 408, 14794, 314, 900, 6779, 14, 10813, 3033, 26, 267, 289, 63, 928, 334, 1609, 304, 1343, 9857, 12, 315, 603, 13026, 267, 289, 63, 2379, 334, 1609, 304, 3631, 9857, 12, 315, 603, 13026, 267, 10367, 334, 2245, 304, 14794, 315, 7798, 334, 797, 9, 503, 366, 34, 6204, 334, 549, 395, 267, 2074, 26, 4252, 1249, 370, 506, 3032, 370, 8027, 284, 706, 1917, 342, 272, 408, 339, 2185, 275, 4488, 14, 71, 696, 342, 272, 5137, 63, 70, 12, 5137, 63, 576, 275, 17328, 14, 22090, 63, 576, 8, 70, 63, 928, 12, 289, 63, 2379, 12, 340, 63, 344, 9, 339, 327, 9336, 314, 666, 965, 2757, 308, 12221, 7068, 12, 314, 3114, 367, 900, 13538, 13437, 340, 1454, 1373, 2517, 12, 25498, 282, 6519, 543, 3114, 29, 17, 272, 340, 822, 8, 2798, 63, 576, 14, 1392, 9, 690, 413, 26, 267, 5137, 63, 576, 275, 980, 14, 4304, 3670, 8, 2798, 63, 576, 12, 3114, 29, 17, 9, 272, 587, 26, 267, 5137, 63, 576, 275, 980, 14, 4304, 3670, 8, 2798, 63, 576, 9, 339, 340, 10367, 436, 17328, 14, 1291, 459, 4994, 1405, 418, 2356, 1695, 26, 267, 5137, 63, 576, 275, 1592, 8, 2798, 63, 576, 9, 339, 327, 4155, 5576, 900, 3114, 367, 25174, 334, 7911, 1454, 367, 25174, 1, 680, 3390, 626, 642, 7704, 314, 1338, 20728, 14, 272, 13675, 275, 12831, 63, 11599, 8, 14114, 12, 5137, 63, 70, 29, 2798, 63, 70, 12, 5137, 63, 84, 29, 14114, 14, 25430, 12, 603, 42, 36, 63, 521, 29, 30495, 36, 63, 521, 9, 272, 5137, 63, 84, 275, 980, 14, 11649, 8, 11599, 59, 18, 467, 13675, 59, 19, 467, 822, 8, 14114, 14, 25430, 430, 339, 340, 603, 42, 36, 63, 521, 26, 267, 307, 1302, 275, 298, 1366, 359, 30495, 36, 8480, 272, 587, 26, 267, 307, 1302, 275, 298, 1366, 359, 83, 8480, 339, 340, 10367, 26, 267, 299, 1302, 275, 298, 6921, 359, 26256, 8480, 272, 587, 26, 267, 299, 1302, 275, 298, 6921, 359, 6851, 8480, 339, 327, 22734, 312, 424, 340, 13763, 16774, 14, 272, 340, 283, 86, 7, 315, 16774, 26, 267, 4488, 14, 2798, 8, 2798, 63, 576, 12, 5137, 63, 84, 12, 1011, 958, 9, 267, 4488, 14, 14168, 8, 1168, 902, 9, 339, 587, 26, 267, 4488, 14, 2798, 8, 2798, 63, 84, 12, 5137, 63, 576, 12, 1011, 958, 9, 267, 4488, 14, 14168, 8, 84, 1302, 9, 267, 4488, 14, 13849, 8, 1168, 902, 9, 339, 2185, 14, 29906, 8, 3127, 534, 10727, 297, 3367, 913, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1275, 888, 492, 627, 199, 504, 2508, 1208, 492, 295, 1393, 12, 1592, 199, 504, 1275, 2798, 63, 1208, 492, 12831, 63, 11599, 199, 199, 318, 5137, 63, 521, 63, 5602, 8, 14114, 12, 289, 63, 928, 29, 403, 12, 289, 63, 2379, 29, 403, 12, 340, 63, 344, 29, 16, 12, 10367, 29, 549, 12, 16774, 534, 72, 297, 603, 42, 36, 63, 521, 29, 797, 12, 1011, 958, 304, 272, 408, 14794, 314, 900, 6779, 14, 10813, 3033, 26, 267, 289, 63, 928, 334, 1609, 304, 1343, 9857, 12, 315, 603, 13026, 267, 289, 63, 2379, 334, 1609, 304, 3631, 9857, 12, 315, 603, 13026, 267, 10367, 334, 2245, 304, 14794, 315, 7798, 334, 797, 9, 503, 366, 34, 6204, 334, 549, 395, 267, 2074, 26, 4252, 1249, 370, 506, 3032, 370, 8027, 284, 706, 1917, 342, 272, 408, 339, 2185, 275, 4488, 14, 71, 696, 342, 272, 5137, 63, 70, 12, 5137, 63, 576, 275, 17328, 14, 22090, 63, 576, 8, 70, 63, 928, 12, 289, 63, 2379, 12, 340, 63, 344, 9, 339, 327, 9336, 314, 666, 965, 2757, 308, 12221, 7068, 12, 314, 3114, 367, 900, 13538, 13437, 340, 1454, 1373, 2517, 12, 25498, 282, 6519, 543, 3114, 29, 17, 272, 340, 822, 8, 2798, 63, 576, 14, 1392, 9, 690, 413, 26, 267, 5137, 63, 576, 275, 980, 14, 4304, 3670, 8, 2798, 63, 576, 12, 3114, 29, 17, 9, 272, 587, 26, 267, 5137, 63, 576, 275, 980, 14, 4304, 3670, 8, 2798, 63, 576, 9, 339, 340, 10367, 436, 17328, 14, 1291, 459, 4994, 1405, 418, 2356, 1695, 26, 267, 5137, 63, 576, 275, 1592, 8, 2798, 63, 576, 9, 339, 327, 4155, 5576, 900, 3114, 367, 25174, 334, 7911, 1454, 367, 25174, 1, 680, 3390, 626, 642, 7704, 314, 1338, 20728, 14, 272, 13675, 275, 12831, 63, 11599, 8, 14114, 12, 5137, 63, 70, 29, 2798, 63, 70, 12, 5137, 63, 84, 29, 14114, 14, 25430, 12, 603, 42, 36, 63, 521, 29, 30495, 36, 63, 521, 9, 272, 5137, 63, 84, 275, 980, 14, 11649, 8, 11599, 59, 18, 467, 13675, 59, 19, 467, 822, 8, 14114, 14, 25430, 430, 339, 340, 603, 42, 36, 63, 521, 26, 267, 307, 1302, 275, 298, 1366, 359, 30495, 36, 8480, 272, 587, 26, 267, 307, 1302, 275, 298, 1366, 359, 83, 8480, 339, 340, 10367, 26, 267, 299, 1302, 275, 298, 6921, 359, 26256, 8480, 272, 587, 26, 267, 299, 1302, 275, 298, 6921, 359, 6851, 8480, 339, 327, 22734, 312, 424, 340, 13763, 16774, 14, 272, 340, 283, 86, 7, 315, 16774, 26, 267, 4488, 14, 2798, 8, 2798, 63, 576, 12, 5137, 63, 84, 12, 1011, 958, 9, 267, 4488, 14, 14168, 8, 1168, 902, 9, 339, 587, 26, 267, 4488, 14, 2798, 8, 2798, 63, 84, 12, 5137, 63, 576, 12, 1011, 958, 9, 267, 4488, 14, 14168, 8, 84, 1302, 9, 267, 4488, 14, 13849, 8, 1168, 902, 9, 339, 2185, 14, 29906, 8, 3127, 534, 10727, 297, 3367, 913, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
taestone/opennmt_merge
benchmark/getTests.py
8
2786
import requests import argparse import sys import time from datetime import date import os import json import subprocess import re url = 'http://scorer.nmt-benchmark.net' def main(args): scriptpath=os.path.dirname(os.path.realpath(__file__)) parser = argparse.ArgumentParser(description='Benchmark test download') parser.add_argument('--apikey', help='Your API key',required=True) parser.add_argument('--src', help='Source language',required=True) parser.add_argument('--tgt', help='Target language',required=True) parser.add_argument('--basedir', default='.', help='Directory to download the tests to - will create a directory') args = parser.parse_args(args) assert len(args.src)==2 and len(args.tgt)==2, "invalid langugage pair" assert len(args.apikey)==20, "invalid api key" assert os.path.isdir(args.basedir), "invalid directory" today = date.today() testdir = "benchmark-nmt-test-"+args.src+args.tgt+"-"+today.isoformat() pathtestdir = os.path.join(args.basedir,testdir) assert not os.path.exists(pathtestdir), "directory ["+pathtestdir+"] already exists" response = requests.get(url + '/test/list/' + args.apikey + '?src=' + args.src + '&tgt=' + args.tgt) if response.status_code != requests.codes.ok: response.raise_for_status() sys.exit(1) R=response.json() if len(R)==0: print 'no testset available for '+args.src+'>'+args.tgt sys.exit(0) else: print str(len(R))+' testset(s) available for '+args.src+'>'+args.tgt os.mkdir(pathtestdir) for r in R: print "downloading - "+r['source']['fileName']+" into "+pathtestdir response = requests.get(url + '/test/download/' + args.apikey + '?fileId=' + r['_id']) if response.status_code != requests.codes.ok: response.raise_for_status() os.exit(1) with open(os.path.join(pathtestdir,r['source']['fileName']+".info"), "wb") as testinfo: testinfo.write(json.dumps(r,indent=True)) with open(os.path.join(pathtestdir,r['source']['fileName']+".org"), "wb") as test: test.write(response.content) testtxt = open(os.path.join(pathtestdir,r['source']['fileName']+".txt"), "wb") if re.search(r"\.(sgm|sgml|xml)$",r['source']['fileName']): p = subprocess.Popen(["perl",scriptpath+"/3rdParty/input-from-sgm.perl"],stdin=subprocess.PIPE,stdout=testtxt) p.stdin.write(response.content) p.communicate() else: testtxt.write(response.content) print "--> text version available: ",os.path.join(pathtestdir,r['source']['fileName']+".txt") testtxt.close() if __name__ == '__main__': sys.exit(main(sys.argv[1:]))
mit
[ 646, 4145, 199, 646, 7534, 199, 646, 984, 199, 646, 900, 199, 504, 2197, 492, 1434, 199, 646, 747, 199, 646, 2022, 199, 646, 3873, 199, 646, 295, 199, 199, 633, 275, 283, 1014, 921, 22135, 14, 78, 2037, 13, 11861, 14, 846, 7, 199, 199, 318, 2446, 8, 589, 304, 272, 2884, 515, 29, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 339, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 18644, 511, 5235, 358, 272, 1798, 14, 525, 63, 2094, 4517, 28181, 297, 1720, 534, 14398, 3261, 790, 297, 2427, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 4517, 2164, 297, 1720, 534, 2980, 2637, 297, 2427, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 4517, 15328, 297, 1720, 534, 4277, 2637, 297, 2427, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 4517, 12484, 297, 849, 534, 3130, 717, 1720, 534, 6231, 370, 5235, 314, 2295, 370, 446, 911, 1218, 282, 2082, 358, 339, 1249, 275, 1798, 14, 1122, 63, 589, 8, 589, 9, 339, 702, 822, 8, 589, 14, 2164, 12694, 18, 436, 822, 8, 589, 14, 15328, 12694, 18, 12, 298, 3197, 6339, 1518, 474, 4092, 2, 272, 702, 822, 8, 589, 14, 28181, 12694, 1165, 12, 298, 3197, 2986, 790, 2, 272, 702, 747, 14, 515, 14, 6027, 8, 589, 14, 12484, 395, 298, 3197, 2082, 2, 339, 11168, 275, 1434, 14, 8136, 342, 272, 7368, 275, 298, 11861, 13, 78, 2037, 13, 396, 13, 7709, 589, 14, 2164, 11, 589, 14, 15328, 15200, 8136, 14, 17070, 342, 272, 931, 16634, 275, 747, 14, 515, 14, 904, 8, 589, 14, 12484, 12, 16634, 9, 339, 702, 440, 747, 14, 515, 14, 2444, 8, 515, 16634, 395, 298, 3619, 2097, 11, 515, 16634, 11, 937, 2575, 3495, 2, 339, 1177, 275, 4145, 14, 362, 8, 633, 435, 1994, 396, 15, 513, 4805, 435, 1249, 14, 28181, 435, 8720, 2164, 534, 435, 1249, 14, 2164, 435, 7673, 15328, 534, 435, 1249, 14, 15328, 9, 272, 340, 1177, 14, 1205, 63, 600, 1137, 4145, 14, 6021, 14, 745, 26, 267, 1177, 14, 3730, 63, 509, 63, 1205, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 820, 29, 1310, 14, 1001, 342, 339, 340, 822, 8, 50, 12694, 16, 26, 267, 870, 283, 889, 511, 409, 2808, 367, 6681, 589, 14, 2164, 4786, 3524, 11, 589, 14, 15328, 267, 984, 14, 2224, 8, 16, 9, 272, 587, 26, 267, 870, 620, 8, 552, 8, 50, 430, 4786, 511, 409, 8, 83, 9, 2808, 367, 6681, 589, 14, 2164, 4786, 3524, 11, 589, 14, 15328, 339, 747, 14, 8215, 8, 515, 16634, 9, 339, 367, 519, 315, 820, 26, 267, 870, 298, 4249, 316, 446, 7210, 82, 459, 1365, 2545, 15450, 418, 5207, 1901, 7210, 515, 16634, 267, 1177, 275, 4145, 14, 362, 8, 633, 435, 1994, 396, 15, 4249, 4805, 435, 1249, 14, 28181, 435, 8720, 493, 1304, 534, 435, 519, 8680, 344, 1105, 267, 340, 1177, 14, 1205, 63, 600, 1137, 4145, 14, 6021, 14, 745, 26, 288, 1177, 14, 3730, 63, 509, 63, 1205, 342, 288, 747, 14, 2224, 8, 17, 9, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 815, 1288, 298, 6603, 531, 465, 511, 815, 26, 288, 511, 815, 14, 952, 8, 1001, 14, 4180, 8, 82, 12, 3724, 29, 549, 430, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 1308, 1288, 298, 6603, 531, 465, 511, 26, 288, 511, 14, 952, 8, 1310, 14, 1317, 9, 267, 511, 2424, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 2424, 1288, 298, 6603, 531, 267, 340, 295, 14, 1733, 8, 82, 3212, 14, 8, 1226, 77, 92, 1226, 757, 92, 1652, 9, 11918, 82, 459, 1365, 2545, 15450, 9090, 288, 299, 275, 3873, 14, 7942, 5234, 22805, 401, 1579, 515, 24792, 19, 6883, 25233, 15, 1210, 13, 504, 13, 1226, 77, 14, 22805, 2255, 6626, 29, 5781, 14, 6089, 12, 2703, 29, 396, 2424, 9, 288, 299, 14, 6626, 14, 952, 8, 1310, 14, 1317, 9, 288, 299, 14, 10664, 342, 267, 587, 26, 288, 511, 2424, 14, 952, 8, 1310, 14, 1317, 9, 267, 870, 4320, 30, 1318, 1015, 2808, 26, 3872, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 2424, 531, 267, 511, 2424, 14, 1600, 342, 6905, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 984, 14, 2224, 8, 973, 8, 1274, 14, 3020, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4145, 199, 646, 7534, 199, 646, 984, 199, 646, 900, 199, 504, 2197, 492, 1434, 199, 646, 747, 199, 646, 2022, 199, 646, 3873, 199, 646, 295, 199, 199, 633, 275, 283, 1014, 921, 22135, 14, 78, 2037, 13, 11861, 14, 846, 7, 199, 199, 318, 2446, 8, 589, 304, 272, 2884, 515, 29, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 339, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 18644, 511, 5235, 358, 272, 1798, 14, 525, 63, 2094, 4517, 28181, 297, 1720, 534, 14398, 3261, 790, 297, 2427, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 4517, 2164, 297, 1720, 534, 2980, 2637, 297, 2427, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 4517, 15328, 297, 1720, 534, 4277, 2637, 297, 2427, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 4517, 12484, 297, 849, 534, 3130, 717, 1720, 534, 6231, 370, 5235, 314, 2295, 370, 446, 911, 1218, 282, 2082, 358, 339, 1249, 275, 1798, 14, 1122, 63, 589, 8, 589, 9, 339, 702, 822, 8, 589, 14, 2164, 12694, 18, 436, 822, 8, 589, 14, 15328, 12694, 18, 12, 298, 3197, 6339, 1518, 474, 4092, 2, 272, 702, 822, 8, 589, 14, 28181, 12694, 1165, 12, 298, 3197, 2986, 790, 2, 272, 702, 747, 14, 515, 14, 6027, 8, 589, 14, 12484, 395, 298, 3197, 2082, 2, 339, 11168, 275, 1434, 14, 8136, 342, 272, 7368, 275, 298, 11861, 13, 78, 2037, 13, 396, 13, 7709, 589, 14, 2164, 11, 589, 14, 15328, 15200, 8136, 14, 17070, 342, 272, 931, 16634, 275, 747, 14, 515, 14, 904, 8, 589, 14, 12484, 12, 16634, 9, 339, 702, 440, 747, 14, 515, 14, 2444, 8, 515, 16634, 395, 298, 3619, 2097, 11, 515, 16634, 11, 937, 2575, 3495, 2, 339, 1177, 275, 4145, 14, 362, 8, 633, 435, 1994, 396, 15, 513, 4805, 435, 1249, 14, 28181, 435, 8720, 2164, 534, 435, 1249, 14, 2164, 435, 7673, 15328, 534, 435, 1249, 14, 15328, 9, 272, 340, 1177, 14, 1205, 63, 600, 1137, 4145, 14, 6021, 14, 745, 26, 267, 1177, 14, 3730, 63, 509, 63, 1205, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 820, 29, 1310, 14, 1001, 342, 339, 340, 822, 8, 50, 12694, 16, 26, 267, 870, 283, 889, 511, 409, 2808, 367, 6681, 589, 14, 2164, 4786, 3524, 11, 589, 14, 15328, 267, 984, 14, 2224, 8, 16, 9, 272, 587, 26, 267, 870, 620, 8, 552, 8, 50, 430, 4786, 511, 409, 8, 83, 9, 2808, 367, 6681, 589, 14, 2164, 4786, 3524, 11, 589, 14, 15328, 339, 747, 14, 8215, 8, 515, 16634, 9, 339, 367, 519, 315, 820, 26, 267, 870, 298, 4249, 316, 446, 7210, 82, 459, 1365, 2545, 15450, 418, 5207, 1901, 7210, 515, 16634, 267, 1177, 275, 4145, 14, 362, 8, 633, 435, 1994, 396, 15, 4249, 4805, 435, 1249, 14, 28181, 435, 8720, 493, 1304, 534, 435, 519, 8680, 344, 1105, 267, 340, 1177, 14, 1205, 63, 600, 1137, 4145, 14, 6021, 14, 745, 26, 288, 1177, 14, 3730, 63, 509, 63, 1205, 342, 288, 747, 14, 2224, 8, 17, 9, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 815, 1288, 298, 6603, 531, 465, 511, 815, 26, 288, 511, 815, 14, 952, 8, 1001, 14, 4180, 8, 82, 12, 3724, 29, 549, 430, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 1308, 1288, 298, 6603, 531, 465, 511, 26, 288, 511, 14, 952, 8, 1310, 14, 1317, 9, 267, 511, 2424, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 2424, 1288, 298, 6603, 531, 267, 340, 295, 14, 1733, 8, 82, 3212, 14, 8, 1226, 77, 92, 1226, 757, 92, 1652, 9, 11918, 82, 459, 1365, 2545, 15450, 9090, 288, 299, 275, 3873, 14, 7942, 5234, 22805, 401, 1579, 515, 24792, 19, 6883, 25233, 15, 1210, 13, 504, 13, 1226, 77, 14, 22805, 2255, 6626, 29, 5781, 14, 6089, 12, 2703, 29, 396, 2424, 9, 288, 299, 14, 6626, 14, 952, 8, 1310, 14, 1317, 9, 288, 299, 14, 10664, 342, 267, 587, 26, 288, 511, 2424, 14, 952, 8, 1310, 14, 1317, 9, 267, 870, 4320, 30, 1318, 1015, 2808, 26, 3872, 736, 14, 515, 14, 904, 8, 515, 16634, 12, 82, 459, 1365, 2545, 15450, 21899, 1674, 2424, 531, 267, 511, 2424, 14, 1600, 342, 6905, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 984, 14, 2224, 8, 973, 8, 1274, 14, 3020, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Servir-Mekong/SurfaceWaterTool
lib/oauth2client/contrib/gce.py
39
5431
# Copyright 2014 Google Inc. All rights reserved. # # 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 Compute Engine Utilities for making it easier to use OAuth 2.0 on Google Compute Engine. """ import logging import warnings from six.moves import http_client from oauth2client import client from oauth2client.contrib import _metadata logger = logging.getLogger(__name__) _SCOPES_WARNING = """\ You have requested explicit scopes to be used with a GCE service account. Using this argument will have no effect on the actual scopes for tokens requested. These scopes are set at VM instance creation time and can't be overridden in the request. """ class AppAssertionCredentials(client.AssertionCredentials): """Credentials object for Compute Engine Assertion Grants This object will allow a Compute Engine instance 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 Compute Engine instance 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. Note that :attr:`service_account_email` and :attr:`scopes` will both return None until the credentials have been refreshed. To check whether credentials have previously been refreshed use :attr:`invalid`. """ def __init__(self, email=None, *args, **kwargs): """Constructor for AppAssertionCredentials Args: email: an email that specifies the service account to use. Only necessary if using custom service accounts (see https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances#createdefaultserviceaccount). """ if 'scopes' in kwargs: warnings.warn(_SCOPES_WARNING) kwargs['scopes'] = None # Assertion type is no longer used, but still in the # parent class signature. super(AppAssertionCredentials, self).__init__(None, *args, **kwargs) self.service_account_email = email self.scopes = None self.invalid = True @classmethod def from_json(cls, json_data): raise NotImplementedError( 'Cannot serialize credentials for GCE service accounts.') def to_json(self): raise NotImplementedError( 'Cannot serialize credentials for GCE service accounts.') def retrieve_scopes(self, http): """Retrieves the canonical list of scopes for this access token. Overrides client.Credentials.retrieve_scopes. Fetches scopes info from the metadata server. Args: http: httplib2.Http, an http object to be used to make the refresh request. Returns: A set of strings containing the canonical list of scopes. """ self._retrieve_info(http) return self.scopes def _retrieve_info(self, http): """Retrieves service account info for invalid credentials. Args: http: an object to be used to make HTTP requests. """ if self.invalid: info = _metadata.get_service_account_info( http, service_account=self.service_account_email or 'default') self.invalid = False self.service_account_email = info['email'] self.scopes = info['scopes'] def _refresh(self, http): """Refreshes the access token. Skip all the storage hoops and just refresh using the API. Args: http: an object to be used to make HTTP requests. Raises: HttpAccessTokenRefreshError: When the refresh fails. """ try: self._retrieve_info(http) self.access_token, self.token_expiry = _metadata.get_token( http, service_account=self.service_account_email) except http_client.HTTPException as err: raise client.HttpAccessTokenRefreshError(str(err)) @property def serialization_data(self): raise NotImplementedError( 'Cannot serialize credentials for GCE service accounts.') def create_scoped_required(self): return False def sign_blob(self, blob): """Cryptographically sign a blob (of bytes). This method is provided to support a common interface, but the actual key used for a Google Compute Engine service account is not available, so it can't be used to sign content. Args: blob: bytes, Message to be signed. Raises: NotImplementedError, always. """ raise NotImplementedError( 'Compute Engine service accounts cannot sign blobs')
gpl-3.0
[ 3, 1898, 6927, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 22905, 367, 4475, 8354, 12580, 199, 199, 22905, 367, 10663, 652, 14905, 370, 675, 11715, 499, 14, 16, 641, 4475, 8354, 12580, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 3598, 199, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 199, 504, 9725, 18, 1258, 492, 1890, 199, 504, 9725, 18, 1258, 14, 2828, 492, 485, 2343, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 15901, 48, 654, 63, 9171, 275, 9638, 199, 5556, 1172, 5839, 5027, 14570, 370, 506, 1202, 543, 282, 31556, 2435, 2933, 14, 199, 10369, 642, 1423, 911, 1172, 949, 7763, 641, 314, 3503, 14570, 367, 4645, 199, 11151, 14, 5723, 14570, 787, 663, 737, 7525, 1256, 7143, 900, 436, 199, 2425, 1133, 506, 10087, 315, 314, 1056, 14, 199, 624, 421, 199, 533, 4693, 26860, 13428, 8, 1258, 14, 26860, 13428, 304, 272, 408, 13428, 909, 367, 8354, 12580, 3709, 4535, 598, 82, 2285, 339, 961, 909, 911, 2040, 282, 8354, 12580, 1256, 370, 10405, 6337, 370, 272, 4475, 436, 1163, 11715, 499, 14, 16, 8037, 626, 883, 4911, 22835, 14, 2779, 883, 506, 272, 1202, 367, 314, 12016, 402, 18549, 666, 5489, 1334, 376, 2933, 7943, 370, 272, 314, 8354, 12580, 1256, 6337, 14, 339, 961, 16338, 1630, 440, 4409, 282, 6369, 370, 17321, 2952, 652, 272, 8469, 282, 2877, 6768, 3046, 6369, 12, 436, 16119, 965, 1006, 402, 314, 1415, 272, 2556, 370, 3550, 436, 9236, 2399, 5705, 2879, 4645, 14, 339, 3390, 626, 520, 962, 1705, 1364, 63, 2048, 63, 2123, 64, 436, 520, 962, 1705, 14129, 64, 272, 911, 3865, 372, 488, 5133, 314, 6235, 1172, 2757, 9236, 379, 14, 272, 4005, 1104, 3775, 6235, 1172, 10889, 2757, 9236, 379, 675, 272, 520, 962, 1705, 3197, 2313, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3031, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 11447, 367, 4693, 26860, 13428, 398, 3033, 26, 288, 3031, 26, 376, 3031, 626, 9314, 314, 2435, 2933, 370, 675, 14, 673, 5972, 5784, 340, 1808, 3537, 2435, 12639, 673, 334, 3239, 4178, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 2732, 15, 981, 13, 4296, 13, 1364, 13, 8370, 13, 509, 13, 5990, 3, 981, 885, 1364, 2048, 680, 267, 408, 267, 340, 283, 14129, 7, 315, 2074, 26, 288, 3598, 14, 4050, 1547, 15901, 48, 654, 63, 9171, 9, 288, 2074, 459, 14129, 418, 275, 488, 398, 327, 3709, 4535, 730, 365, 949, 8088, 1202, 12, 1325, 5139, 315, 314, 267, 327, 1676, 1021, 4955, 14, 267, 1613, 8, 2640, 26860, 13428, 12, 291, 2843, 826, 721, 403, 12, 627, 589, 12, 1011, 958, 9, 398, 291, 14, 1364, 63, 2048, 63, 2123, 275, 3031, 267, 291, 14, 14129, 275, 488, 267, 291, 14, 3197, 275, 715, 339, 768, 3744, 272, 347, 687, 63, 1001, 8, 1886, 12, 2022, 63, 576, 304, 267, 746, 4279, 8, 288, 283, 6612, 8437, 6235, 367, 31556, 2435, 12639, 2659, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 746, 4279, 8, 288, 283, 6612, 8437, 6235, 367, 31556, 2435, 12639, 2659, 339, 347, 8044, 63, 14129, 8, 277, 12, 1455, 304, 267, 408, 28112, 314, 11358, 769, 402, 14570, 367, 642, 2879, 1526, 14, 398, 31144, 1890, 14, 13428, 14, 14270, 63, 14129, 14, 16347, 397, 14570, 2256, 267, 687, 314, 3341, 1654, 14, 398, 3033, 26, 288, 1455, 26, 8809, 18, 14, 5779, 12, 376, 1455, 909, 370, 506, 1202, 370, 1852, 314, 9236, 2116, 1056, 14, 398, 1803, 26, 288, 437, 663, 402, 3326, 3035, 314, 11358, 769, 402, 14570, 14, 267, 408, 267, 291, 423, 14270, 63, 815, 8, 1014, 9, 267, 372, 291, 14, 14129, 339, 347, 485, 14270, 63, 815, 8, 277, 12, 1455, 304, 267, 408, 28112, 2435, 2933, 2256, 367, 3866, 6235, 14, 398, 3033, 26, 288, 1455, 26, 376, 909, 370, 506, 1202, 370, 1852, 3101, 4145, 14, 267, 408, 267, 340, 291, 14, 3197, 26, 288, 2256, 275, 485, 2343, 14, 362, 63, 1364, 63, 2048, 63, 815, 8, 355, 1455, 12, 355, 2435, 63, 2048, 29, 277, 14, 1364, 63, 2048, 63, 2123, 503, 283, 885, 358, 288, 291, 14, 3197, 275, 756, 288, 291, 14, 1364, 63, 2048, 63, 2123, 275, 2256, 459, 2123, 418, 288, 291, 14, 14129, 275, 2256, 459, 14129, 418, 339, 347, 485, 6635, 8, 277, 12, 1455, 304, 267, 408, 18730, 397, 314, 2879, 1526, 14, 398, 8232, 1006, 314, 4887, 2636, 1483, 436, 2951, 9236, 1808, 314, 3261, 14, 398, 3033, 26, 288, 1455, 26, 376, 909, 370, 506, 1202, 370, 1852, 3101, 4145, 14, 398, 6218, 26, 288, 4760, 3946, 3264, 18730, 547, 26, 3979, 314, 9236, 6918, 14, 267, 408, 267, 862, 26, 288, 291, 423, 14270, 63, 815, 8, 1014, 9, 288, 291, 14, 2732, 63, 1418, 12, 291, 14, 1418, 63, 16844, 275, 485, 2343, 14, 362, 63, 1418, 8, 355, 1455, 12, 2435, 63, 2048, 29, 277, 14, 1364, 63, 2048, 63, 2123, 9, 267, 871, 1455, 63, 1258, 14, 26871, 465, 2329, 26, 288, 746, 1890, 14, 5779, 3946, 3264, 18730, 547, 8, 495, 8, 1508, 430, 339, 768, 1829, 272, 347, 16953, 63, 576, 8, 277, 304, 267, 746, 4279, 8, 288, 283, 6612, 8437, 6235, 367, 31556, 2435 ]
[ 1898, 6927, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 22905, 367, 4475, 8354, 12580, 199, 199, 22905, 367, 10663, 652, 14905, 370, 675, 11715, 499, 14, 16, 641, 4475, 8354, 12580, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 3598, 199, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 199, 504, 9725, 18, 1258, 492, 1890, 199, 504, 9725, 18, 1258, 14, 2828, 492, 485, 2343, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 15901, 48, 654, 63, 9171, 275, 9638, 199, 5556, 1172, 5839, 5027, 14570, 370, 506, 1202, 543, 282, 31556, 2435, 2933, 14, 199, 10369, 642, 1423, 911, 1172, 949, 7763, 641, 314, 3503, 14570, 367, 4645, 199, 11151, 14, 5723, 14570, 787, 663, 737, 7525, 1256, 7143, 900, 436, 199, 2425, 1133, 506, 10087, 315, 314, 1056, 14, 199, 624, 421, 199, 533, 4693, 26860, 13428, 8, 1258, 14, 26860, 13428, 304, 272, 408, 13428, 909, 367, 8354, 12580, 3709, 4535, 598, 82, 2285, 339, 961, 909, 911, 2040, 282, 8354, 12580, 1256, 370, 10405, 6337, 370, 272, 4475, 436, 1163, 11715, 499, 14, 16, 8037, 626, 883, 4911, 22835, 14, 2779, 883, 506, 272, 1202, 367, 314, 12016, 402, 18549, 666, 5489, 1334, 376, 2933, 7943, 370, 272, 314, 8354, 12580, 1256, 6337, 14, 339, 961, 16338, 1630, 440, 4409, 282, 6369, 370, 17321, 2952, 652, 272, 8469, 282, 2877, 6768, 3046, 6369, 12, 436, 16119, 965, 1006, 402, 314, 1415, 272, 2556, 370, 3550, 436, 9236, 2399, 5705, 2879, 4645, 14, 339, 3390, 626, 520, 962, 1705, 1364, 63, 2048, 63, 2123, 64, 436, 520, 962, 1705, 14129, 64, 272, 911, 3865, 372, 488, 5133, 314, 6235, 1172, 2757, 9236, 379, 14, 272, 4005, 1104, 3775, 6235, 1172, 10889, 2757, 9236, 379, 675, 272, 520, 962, 1705, 3197, 2313, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3031, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 11447, 367, 4693, 26860, 13428, 398, 3033, 26, 288, 3031, 26, 376, 3031, 626, 9314, 314, 2435, 2933, 370, 675, 14, 673, 5972, 5784, 340, 1808, 3537, 2435, 12639, 673, 334, 3239, 4178, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 2732, 15, 981, 13, 4296, 13, 1364, 13, 8370, 13, 509, 13, 5990, 3, 981, 885, 1364, 2048, 680, 267, 408, 267, 340, 283, 14129, 7, 315, 2074, 26, 288, 3598, 14, 4050, 1547, 15901, 48, 654, 63, 9171, 9, 288, 2074, 459, 14129, 418, 275, 488, 398, 327, 3709, 4535, 730, 365, 949, 8088, 1202, 12, 1325, 5139, 315, 314, 267, 327, 1676, 1021, 4955, 14, 267, 1613, 8, 2640, 26860, 13428, 12, 291, 2843, 826, 721, 403, 12, 627, 589, 12, 1011, 958, 9, 398, 291, 14, 1364, 63, 2048, 63, 2123, 275, 3031, 267, 291, 14, 14129, 275, 488, 267, 291, 14, 3197, 275, 715, 339, 768, 3744, 272, 347, 687, 63, 1001, 8, 1886, 12, 2022, 63, 576, 304, 267, 746, 4279, 8, 288, 283, 6612, 8437, 6235, 367, 31556, 2435, 12639, 2659, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 746, 4279, 8, 288, 283, 6612, 8437, 6235, 367, 31556, 2435, 12639, 2659, 339, 347, 8044, 63, 14129, 8, 277, 12, 1455, 304, 267, 408, 28112, 314, 11358, 769, 402, 14570, 367, 642, 2879, 1526, 14, 398, 31144, 1890, 14, 13428, 14, 14270, 63, 14129, 14, 16347, 397, 14570, 2256, 267, 687, 314, 3341, 1654, 14, 398, 3033, 26, 288, 1455, 26, 8809, 18, 14, 5779, 12, 376, 1455, 909, 370, 506, 1202, 370, 1852, 314, 9236, 2116, 1056, 14, 398, 1803, 26, 288, 437, 663, 402, 3326, 3035, 314, 11358, 769, 402, 14570, 14, 267, 408, 267, 291, 423, 14270, 63, 815, 8, 1014, 9, 267, 372, 291, 14, 14129, 339, 347, 485, 14270, 63, 815, 8, 277, 12, 1455, 304, 267, 408, 28112, 2435, 2933, 2256, 367, 3866, 6235, 14, 398, 3033, 26, 288, 1455, 26, 376, 909, 370, 506, 1202, 370, 1852, 3101, 4145, 14, 267, 408, 267, 340, 291, 14, 3197, 26, 288, 2256, 275, 485, 2343, 14, 362, 63, 1364, 63, 2048, 63, 815, 8, 355, 1455, 12, 355, 2435, 63, 2048, 29, 277, 14, 1364, 63, 2048, 63, 2123, 503, 283, 885, 358, 288, 291, 14, 3197, 275, 756, 288, 291, 14, 1364, 63, 2048, 63, 2123, 275, 2256, 459, 2123, 418, 288, 291, 14, 14129, 275, 2256, 459, 14129, 418, 339, 347, 485, 6635, 8, 277, 12, 1455, 304, 267, 408, 18730, 397, 314, 2879, 1526, 14, 398, 8232, 1006, 314, 4887, 2636, 1483, 436, 2951, 9236, 1808, 314, 3261, 14, 398, 3033, 26, 288, 1455, 26, 376, 909, 370, 506, 1202, 370, 1852, 3101, 4145, 14, 398, 6218, 26, 288, 4760, 3946, 3264, 18730, 547, 26, 3979, 314, 9236, 6918, 14, 267, 408, 267, 862, 26, 288, 291, 423, 14270, 63, 815, 8, 1014, 9, 288, 291, 14, 2732, 63, 1418, 12, 291, 14, 1418, 63, 16844, 275, 485, 2343, 14, 362, 63, 1418, 8, 355, 1455, 12, 2435, 63, 2048, 29, 277, 14, 1364, 63, 2048, 63, 2123, 9, 267, 871, 1455, 63, 1258, 14, 26871, 465, 2329, 26, 288, 746, 1890, 14, 5779, 3946, 3264, 18730, 547, 8, 495, 8, 1508, 430, 339, 768, 1829, 272, 347, 16953, 63, 576, 8, 277, 304, 267, 746, 4279, 8, 288, 283, 6612, 8437, 6235, 367, 31556, 2435, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
adityacs/ansible
lib/ansible/modules/system/pamd.py
16
20236
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016, Kenneth D. Evensen <kevensen@redhat.com> # # This file is part of Ansible (sort of) # # Ansible 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 3 of the License, or # (at your option) any later version. # # Ansible 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = """ module: pamd author: - "Kenneth D. Evensen (@kevensen)" short_description: Manage PAM Modules description: - Edit PAM service's type, control, module path and module arguments. In order for a PAM rule to be modified, the type, control and module_path must match an existing rule. See man(5) pam.d for details. version_added: "2.3" options: name: required: true description: - The name generally refers to the PAM service file to change, for example system-auth. type: required: true description: - The type of the PAM rule being modified. The type, control and module_path all must match a rule to be modified. control: required: true description: - The control of the PAM rule being modified. This may be a complicated control with brackets. If this is the case, be sure to put "[bracketed controls]" in quotes. The type, control and module_path all must match a rule to be modified. module_path: required: true description: - The module path of the PAM rule being modified. The type, control and module_path all must match a rule to be modified. new_type: required: false description: - The type to assign to the new rule. new_control: required: false description: - The control to assign to the new rule. new_module_path: required: false description: - The control to assign to the new rule. module_arguments: required: false description: - When state is 'updated', the module_arguments will replace existing module_arguments. When state is 'args_absent' args matching those listed in module_arguments will be removed. When state is 'args_present' any args listed in module_arguments are added if missing from the existing rule. Furthermore, if the module argument takes a value denoted by '=', the value will be changed to that specified in module_arguments. state: required: false default: updated choices: - updated - before - after - args_present - args_absent description: - The default of 'updated' will modify an existing rule if type, control and module_path all match an existing rule. With 'before', the new rule will be inserted before a rule matching type, control and module_path. Similarly, with 'after', the new rule will be inserted after an existing rule matching type, control and module_path. With either 'before' or 'after' new_type, new_control, and new_module_path must all be specified. If state is 'args_absent' or 'args_present', new_type, new_control, and new_module_path will be ignored. path: required: false default: /etc/pam.d/ description: - This is the path to the PAM service files """ EXAMPLES = """ - name: Update pamd rule's control in /etc/pam.d/system-auth pamd: name: system-auth type: auth control: required module_path: pam_faillock.so new_control: sufficient - name: Update pamd rule's complex control in /etc/pam.d/system-auth pamd: name: system-auth type: session control: '[success=1 default=ignore]' module_path: pam_succeed_if.so new_control: '[success=2 default=ignore]' - name: Insert a new rule before an existing rule pamd: name: system-auth type: auth control: required module_path: pam_faillock.so new_type: auth new_control: sufficient new_module_path: pam_faillock.so state: before - name: Insert a new rule after an existing rule pamd: name: system-auth type: auth control: required module_path: pam_faillock.so new_type: auth new_control: sufficient new_module_path: pam_faillock.so state: after - name: Remove module arguments from an existing rule pamd: name: system-auth type: auth control: required module_path: pam_faillock.so module_arguments: '' state: updated - name: Replace all module arguments in an existing rule pamd: name: system-auth type: auth control: required module_path: pam_faillock.so module_arguments: 'preauth silent deny=3 unlock_time=604800 fail_interval=900' state: updated - name: Remove specific arguments from a rule pamd: name: system-auth type: session control='[success=1 default=ignore]' module_path: pam_succeed_if.so module_arguments: 'crond quiet' state: args_absent - name: Ensure specific arguments are present in a rule pamd: name: system-auth type: session control: '[success=1 default=ignore]' module_path: pam_succeed_if.so module_arguments: 'crond quiet' state: args_present - name: Update specific argument value in a rule pamd: name: system-auth type: auth control: required module_path: pam_faillock.so module_arguments: 'fail_interval=300' state: args_present """ RETURN = ''' dest: description: path to pam.d service that was changed returned: success type: string sample: "/etc/pam.d/system-auth" ... ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pycompat24 import get_exception # The PamdRule class encapsulates a rule in a pam.d service class PamdRule(object): def __init__(self, rule_type, rule_control, rule_module_path, rule_module_args=None): self.rule_type = rule_type self.rule_control = rule_control self.rule_module_path = rule_module_path try: if (rule_module_args is not None and type(rule_module_args) is list): self.rule_module_args = rule_module_args elif (rule_module_args is not None and type(rule_module_args) is str): self.rule_module_args = rule_module_args.split() except AttributeError: self.rule_module_args = [] @classmethod def rulefromstring(cls, stringline): split_line = stringline.split() rule_type = split_line[0] rule_control = split_line[1] if rule_control.startswith('['): rule_control = stringline[stringline.index('['): stringline.index(']')+1] if "]" in split_line[2]: rule_module_path = split_line[3] rule_module_args = split_line[4:] else: rule_module_path = split_line[2] rule_module_args = split_line[3:] return cls(rule_type, rule_control, rule_module_path, rule_module_args) def get_module_args_as_string(self): try: if self.rule_module_args is not None: return ' '.join(self.rule_module_args) except AttributeError: pass return '' def __str__(self): return "%-10s\t%s\t%s %s" % (self.rule_type, self.rule_control, self.rule_module_path, self.get_module_args_as_string()) # PamdService encapsulates an entire service and contains one or more rules class PamdService(object): def __init__(self, path, name, ansible): self.path = path self.name = name self.check = ansible.check_mode self.ansible = ansible self.fname = self.path + "/" + self.name self.preamble = [] self.rules = [] try: for line in open(self.fname, 'r'): if line.startswith('#') and not line.isspace(): self.preamble.append(line.rstrip()) elif not line.startswith('#') and not line.isspace(): self.rules.append(PamdRule.rulefromstring (stringline=line.rstrip())) except Exception: e = get_exception() self.ansible.fail_json(msg='Unable to open/read PAM module file ' + '%s with error %s' % (self.fname, str(e))) def __str__(self): return self.fname def update_rule(service, old_rule, new_rule): changed = False change_count = 0 result = {'action': 'update_rule'} for rule in service.rules: if (old_rule.rule_type == rule.rule_type and old_rule.rule_control == rule.rule_control and old_rule.rule_module_path == rule.rule_module_path): if (new_rule.rule_type is not None and new_rule.rule_type != rule.rule_type): rule.rule_type = new_rule.rule_type changed = True if (new_rule.rule_control is not None and new_rule.rule_control != rule.rule_control): rule.rule_control = new_rule.rule_control changed = True if (new_rule.rule_module_path is not None and new_rule.rule_module_path != rule.rule_module_path): rule.rule_module_path = new_rule.rule_module_path changed = True try: if (new_rule.rule_module_args is not None and new_rule.rule_module_args != rule.rule_module_args): rule.rule_module_args = new_rule.rule_module_args changed = True except AttributeError: pass if changed: result['updated_rule_'+str(change_count)] = str(rule) result['new_rule'] = str(new_rule) change_count += 1 result['change_count'] = change_count return changed, result def insert_before_rule(service, old_rule, new_rule): index = 0 change_count = 0 result = {'action': 'insert_before_rule'} changed = False for rule in service.rules: if (old_rule.rule_type == rule.rule_type and old_rule.rule_control == rule.rule_control and old_rule.rule_module_path == rule.rule_module_path): if index == 0: service.rules.insert(0, new_rule) changed = True elif (new_rule.rule_type != service.rules[index-1].rule_type or new_rule.rule_control != service.rules[index-1].rule_control or new_rule.rule_module_path != service.rules[index-1].rule_module_path): service.rules.insert(index, new_rule) changed = True if changed: result['new_rule'] = str(new_rule) result['before_rule_'+str(change_count)] = str(rule) change_count += 1 index += 1 result['change_count'] = change_count return changed, result def insert_after_rule(service, old_rule, new_rule): index = 0 change_count = 0 result = {'action': 'insert_after_rule'} changed = False for rule in service.rules: if (old_rule.rule_type == rule.rule_type and old_rule.rule_control == rule.rule_control and old_rule.rule_module_path == rule.rule_module_path): if (new_rule.rule_type != service.rules[index+1].rule_type or new_rule.rule_control != service.rules[index+1].rule_control or new_rule.rule_module_path != service.rules[index+1].rule_module_path): service.rules.insert(index+1, new_rule) changed = True if changed: result['new_rule'] = str(new_rule) result['after_rule_'+str(change_count)] = str(rule) change_count += 1 index += 1 result['change_count'] = change_count return changed, result def remove_module_arguments(service, old_rule, module_args): result = {'action': 'args_absent'} changed = False change_count = 0 for rule in service.rules: if (old_rule.rule_type == rule.rule_type and old_rule.rule_control == rule.rule_control and old_rule.rule_module_path == rule.rule_module_path): for arg_to_remove in module_args: for arg in rule.rule_module_args: if arg == arg_to_remove: rule.rule_module_args.remove(arg) changed = True result['removed_arg_'+str(change_count)] = arg result['from_rule_'+str(change_count)] = str(rule) change_count += 1 result['change_count'] = change_count return changed, result def add_module_arguments(service, old_rule, module_args): result = {'action': 'args_present'} changed = False change_count = 0 for rule in service.rules: if (old_rule.rule_type == rule.rule_type and old_rule.rule_control == rule.rule_control and old_rule.rule_module_path == rule.rule_module_path): for arg_to_add in module_args: if "=" in arg_to_add: pre_string = arg_to_add[:arg_to_add.index('=')+1] indicies = [i for i, arg in enumerate(rule.rule_module_args) if arg.startswith(pre_string)] if len(indicies) == 0: rule.rule_module_args.append(arg_to_add) changed = True result['added_arg_'+str(change_count)] = arg_to_add result['to_rule_'+str(change_count)] = str(rule) change_count += 1 else: for i in indicies: if rule.rule_module_args[i] != arg_to_add: rule.rule_module_args[i] = arg_to_add changed = True result['updated_arg_' + str(change_count)] = arg_to_add result['in_rule_' + str(change_count)] = str(rule) change_count += 1 elif arg_to_add not in rule.rule_module_args: rule.rule_module_args.append(arg_to_add) changed = True result['added_arg_'+str(change_count)] = arg_to_add result['to_rule_'+str(change_count)] = str(rule) change_count += 1 result['change_count'] = change_count return changed, result def write_rules(service): previous_rule = None f = open(service.fname, 'w') for amble in service.preamble: f.write(amble+'\n') for rule in service.rules: if (previous_rule is not None and previous_rule.rule_type != rule.rule_type): f.write('\n') f.write(str(rule)+'\n') previous_rule = rule f.close() def main(): module = AnsibleModule( argument_spec=dict( name=dict(required=True, type='str'), type=dict(required=True, choices=['account', 'auth', 'password', 'session']), control=dict(required=True, type='str'), module_path=dict(required=True, type='str'), new_type=dict(required=False, choices=['account', 'auth', 'password', 'session']), new_control=dict(required=False, type='str'), new_module_path=dict(required=False, type='str'), module_arguments=dict(required=False, type='list'), state=dict(required=False, default="updated", choices=['before', 'after', 'updated', 'args_absent', 'args_present']), path=dict(required=False, default='/etc/pam.d', type='str') ), supports_check_mode=True, required_if=[ ("state", "args_present", ["module_arguments"]), ("state", "args_absent", ["module_arguments"]) ] ) service = module.params['name'] old_type = module.params['type'] old_control = module.params['control'] old_module_path = module.params['module_path'] new_type = module.params['new_type'] new_control = module.params['new_control'] new_module_path = module.params['new_module_path'] module_arguments = module.params['module_arguments'] state = module.params['state'] path = module.params['path'] pamd = PamdService(path, service, module) old_rule = PamdRule(old_type, old_control, old_module_path) new_rule = PamdRule(new_type, new_control, new_module_path, module_arguments) try: if state == 'updated': change, result = update_rule(pamd, old_rule, new_rule) elif state == 'before': if (new_rule.rule_control is None or new_rule.rule_type is None or new_rule.rule_module_path is None): module.fail_json(msg='When inserting a new rule before ' + 'or after an existing rule, new_type, ' + 'new_control and new_module_path must ' + 'all be set.') change, result = insert_before_rule(pamd, old_rule, new_rule) elif state == 'after': if (new_rule.rule_control is None or new_rule.rule_type is None or new_rule.rule_module_path is None): module.fail_json(msg='When inserting a new rule before' + 'or after an existing rule, new_type,' + ' new_control and new_module_path must' + ' all be set.') change, result = insert_after_rule(pamd, old_rule, new_rule) elif state == 'args_absent': change, result = remove_module_arguments(pamd, old_rule, module_arguments) elif state == 'args_present': change, result = add_module_arguments(pamd, old_rule, module_arguments) if not module.check_mode: write_rules(pamd) except Exception: e = get_exception() module.fail_json(msg='error running changing pamd: %s' % str(e)) facts = {} facts['pamd'] = {'changed': change, 'result': result} module.params['dest'] = pamd.fname module.exit_json(changed=change, ansible_facts=facts) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 12, 1804, 287, 685, 273, 577, 14, 662, 86, 677, 78, 665, 415, 86, 677, 78, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 334, 3191, 402, 9, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 408, 199, 578, 26, 299, 21778, 199, 2502, 26, 272, 446, 298, 43, 287, 685, 273, 577, 14, 662, 86, 677, 78, 8593, 415, 86, 677, 78, 2924, 199, 3612, 63, 1802, 26, 14944, 510, 1156, 18167, 199, 1802, 26, 523, 446, 16407, 510, 1156, 2435, 1159, 730, 12, 3304, 12, 859, 931, 436, 859, 2368, 14, 272, 1010, 1865, 367, 282, 510, 1156, 2332, 370, 506, 6042, 12, 314, 730, 12, 3304, 436, 272, 859, 63, 515, 1471, 1336, 376, 3411, 2332, 14, 221, 1666, 2169, 8, 21, 9, 299, 455, 14, 68, 367, 2436, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 1419, 26, 523, 536, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 536, 16711, 15724, 370, 314, 510, 1156, 2435, 570, 370, 267, 1570, 12, 367, 2893, 2656, 13, 1178, 14, 523, 730, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 730, 402, 314, 510, 1156, 2332, 3769, 6042, 14, 221, 710, 730, 12, 3304, 267, 436, 859, 63, 515, 1006, 1471, 1336, 282, 2332, 370, 506, 6042, 14, 523, 3304, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 3304, 402, 314, 510, 1156, 2332, 3769, 6042, 14, 221, 961, 1443, 506, 282, 267, 23515, 3304, 543, 21873, 14, 221, 982, 642, 365, 314, 1930, 12, 506, 267, 3238, 370, 5324, 7369, 7828, 21531, 471, 13467, 8480, 315, 9344, 14, 221, 710, 730, 12, 267, 3304, 436, 859, 63, 515, 1006, 1471, 1336, 282, 2332, 370, 506, 6042, 14, 523, 859, 63, 515, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 859, 931, 402, 314, 510, 1156, 2332, 3769, 6042, 14, 221, 710, 730, 12, 267, 3304, 436, 859, 63, 515, 1006, 1471, 1336, 282, 2332, 370, 506, 6042, 14, 523, 892, 63, 466, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 710, 730, 370, 5090, 370, 314, 892, 2332, 14, 523, 892, 63, 2785, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 710, 3304, 370, 5090, 370, 314, 892, 2332, 14, 523, 892, 63, 578, 63, 515, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 710, 3304, 370, 5090, 370, 314, 892, 2332, 14, 523, 859, 63, 4958, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 3979, 1174, 365, 283, 5334, 297, 314, 859, 63, 4958, 911, 3350, 3411, 489, 859, 63, 4958, 14, 221, 3979, 1174, 365, 283, 589, 63, 5575, 7, 1249, 4877, 5204, 489, 10532, 315, 859, 63, 4958, 911, 506, 4829, 14, 221, 3979, 1174, 365, 489, 283, 589, 63, 1881, 7, 1263, 1249, 10532, 315, 859, 63, 4958, 787, 3483, 340, 489, 4124, 687, 314, 3411, 2332, 14, 221, 28876, 6878, 12, 340, 314, 859, 1423, 489, 6181, 282, 574, 477, 889, 471, 701, 6291, 314, 574, 911, 506, 2896, 370, 626, 2013, 489, 315, 859, 63, 4958, 14, 523, 1174, 26, 272, 1415, 26, 3055, 272, 849, 26, 4588, 272, 3415, 26, 272, 446, 4588, 272, 446, 2544, 272, 446, 2410, 272, 446, 1249, 63, 1881, 272, 446, 1249, 63, 5575, 272, 1369, 26, 272, 446, 710, 849, 402, 283, 5334, 7, 911, 2811, 376, 3411, 2332, 340, 730, 12, 489, 3304, 436, 859, 63, 515, 1006, 1336, 376, 3411, 2332, 14, 221, 8777, 283, 5182, 297, 489, 314, 892, 2332, 911, 506, 11788, 2544, 282, 2332, 4877, 730, 12, 3304, 489, 436, 859, 63, 515, 14, 221, 20046, 590, 12, 543, 283, 4399, 297, 314, 892, 2332, 911, 506, 11788, 489, 2410, 376, 3411, 2332, 4877, 730, 12, 3304, 436, 859, 63, 515, 14, 221, 8777, 489, 1902, 283, 5182, 7, 503, 283, 4399, 7, 892, 63, 466, 12, 892, 63, 2785, 12, 436, 892, 63, 578, 63, 515, 489, 1471, 1006, 506, 2013, 14, 221, 982, 1174, 365, 283, 589, 63, 5575, 7, 503, 283, 589, 63, 1881, 297, 489, 892, 63, 466, 12, 892, 63, 2785, 12, 436, 892, 63, 578, 63, 515, 911, 506, 5525, 14, 523, 931, 26, 272, 1415, 26, 3055, 272, 849, 26, 1182, 6839, 15, 28024, 14, 68, 15, 272, 1369, 26, 272, 446, 961, 365, 314, 931, 370, 314, 510, 1156, 2435, 1584, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 6162, 299, 21778, 2332, 1159, 3304, 315, 1182, 6839, 15, 28024, 14, 68, 15, 2253, 13, 1178, 523, 299, 21778, 26, 272, 536, 26, 2656, 13, 1178, 272, 730, 26, 1790, 272, 3304, 26, 1415, 272, 859, 63, 515, 26, 299, 455, 63, 1633, 831, 14, 1152, 272, 892, 63, 2785, 26, 19258, 199, 199, 13, 536, 26, 6162, 299, 21778, 2332, 1159, 6114, 3304, 315, 1182, 6839, 15, 28024, 14, 68, 15, 2253, 13, 1178, 523, 299 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 12, 1804, 287, 685, 273, 577, 14, 662, 86, 677, 78, 665, 415, 86, 677, 78, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 334, 3191, 402, 9, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 408, 199, 578, 26, 299, 21778, 199, 2502, 26, 272, 446, 298, 43, 287, 685, 273, 577, 14, 662, 86, 677, 78, 8593, 415, 86, 677, 78, 2924, 199, 3612, 63, 1802, 26, 14944, 510, 1156, 18167, 199, 1802, 26, 523, 446, 16407, 510, 1156, 2435, 1159, 730, 12, 3304, 12, 859, 931, 436, 859, 2368, 14, 272, 1010, 1865, 367, 282, 510, 1156, 2332, 370, 506, 6042, 12, 314, 730, 12, 3304, 436, 272, 859, 63, 515, 1471, 1336, 376, 3411, 2332, 14, 221, 1666, 2169, 8, 21, 9, 299, 455, 14, 68, 367, 2436, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 1419, 26, 523, 536, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 536, 16711, 15724, 370, 314, 510, 1156, 2435, 570, 370, 267, 1570, 12, 367, 2893, 2656, 13, 1178, 14, 523, 730, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 730, 402, 314, 510, 1156, 2332, 3769, 6042, 14, 221, 710, 730, 12, 3304, 267, 436, 859, 63, 515, 1006, 1471, 1336, 282, 2332, 370, 506, 6042, 14, 523, 3304, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 3304, 402, 314, 510, 1156, 2332, 3769, 6042, 14, 221, 961, 1443, 506, 282, 267, 23515, 3304, 543, 21873, 14, 221, 982, 642, 365, 314, 1930, 12, 506, 267, 3238, 370, 5324, 7369, 7828, 21531, 471, 13467, 8480, 315, 9344, 14, 221, 710, 730, 12, 267, 3304, 436, 859, 63, 515, 1006, 1471, 1336, 282, 2332, 370, 506, 6042, 14, 523, 859, 63, 515, 26, 272, 1415, 26, 2549, 272, 1369, 26, 489, 446, 710, 859, 931, 402, 314, 510, 1156, 2332, 3769, 6042, 14, 221, 710, 730, 12, 267, 3304, 436, 859, 63, 515, 1006, 1471, 1336, 282, 2332, 370, 506, 6042, 14, 523, 892, 63, 466, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 710, 730, 370, 5090, 370, 314, 892, 2332, 14, 523, 892, 63, 2785, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 710, 3304, 370, 5090, 370, 314, 892, 2332, 14, 523, 892, 63, 578, 63, 515, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 710, 3304, 370, 5090, 370, 314, 892, 2332, 14, 523, 859, 63, 4958, 26, 272, 1415, 26, 3055, 272, 1369, 26, 272, 446, 3979, 1174, 365, 283, 5334, 297, 314, 859, 63, 4958, 911, 3350, 3411, 489, 859, 63, 4958, 14, 221, 3979, 1174, 365, 283, 589, 63, 5575, 7, 1249, 4877, 5204, 489, 10532, 315, 859, 63, 4958, 911, 506, 4829, 14, 221, 3979, 1174, 365, 489, 283, 589, 63, 1881, 7, 1263, 1249, 10532, 315, 859, 63, 4958, 787, 3483, 340, 489, 4124, 687, 314, 3411, 2332, 14, 221, 28876, 6878, 12, 340, 314, 859, 1423, 489, 6181, 282, 574, 477, 889, 471, 701, 6291, 314, 574, 911, 506, 2896, 370, 626, 2013, 489, 315, 859, 63, 4958, 14, 523, 1174, 26, 272, 1415, 26, 3055, 272, 849, 26, 4588, 272, 3415, 26, 272, 446, 4588, 272, 446, 2544, 272, 446, 2410, 272, 446, 1249, 63, 1881, 272, 446, 1249, 63, 5575, 272, 1369, 26, 272, 446, 710, 849, 402, 283, 5334, 7, 911, 2811, 376, 3411, 2332, 340, 730, 12, 489, 3304, 436, 859, 63, 515, 1006, 1336, 376, 3411, 2332, 14, 221, 8777, 283, 5182, 297, 489, 314, 892, 2332, 911, 506, 11788, 2544, 282, 2332, 4877, 730, 12, 3304, 489, 436, 859, 63, 515, 14, 221, 20046, 590, 12, 543, 283, 4399, 297, 314, 892, 2332, 911, 506, 11788, 489, 2410, 376, 3411, 2332, 4877, 730, 12, 3304, 436, 859, 63, 515, 14, 221, 8777, 489, 1902, 283, 5182, 7, 503, 283, 4399, 7, 892, 63, 466, 12, 892, 63, 2785, 12, 436, 892, 63, 578, 63, 515, 489, 1471, 1006, 506, 2013, 14, 221, 982, 1174, 365, 283, 589, 63, 5575, 7, 503, 283, 589, 63, 1881, 297, 489, 892, 63, 466, 12, 892, 63, 2785, 12, 436, 892, 63, 578, 63, 515, 911, 506, 5525, 14, 523, 931, 26, 272, 1415, 26, 3055, 272, 849, 26, 1182, 6839, 15, 28024, 14, 68, 15, 272, 1369, 26, 272, 446, 961, 365, 314, 931, 370, 314, 510, 1156, 2435, 1584, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 6162, 299, 21778, 2332, 1159, 3304, 315, 1182, 6839, 15, 28024, 14, 68, 15, 2253, 13, 1178, 523, 299, 21778, 26, 272, 536, 26, 2656, 13, 1178, 272, 730, 26, 1790, 272, 3304, 26, 1415, 272, 859, 63, 515, 26, 299, 455, 63, 1633, 831, 14, 1152, 272, 892, 63, 2785, 26, 19258, 199, 199, 13, 536, 26, 6162, 299, 21778, 2332, 1159, 6114, 3304, 315, 1182, 6839, 15, 28024, 14, 68, 15, 2253, 13, 1178, 523, 299, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
fillycheezstake/MissionPlanner
Lib/email/iterators.py
68
2275
# Copyright (C) 2001-2006 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Various types of useful iterators and generators.""" __all__ = [ 'body_line_iterator', 'typed_subpart_iterator', 'walk', # Do not include _structure() since it's part of the debugging API. ] import sys from cStringIO import StringIO # This function will become a method of the Message class def walk(self): """Walk over the message tree, yielding each subpart. The walk is performed in depth-first order. This method is a generator. """ yield self if self.is_multipart(): for subpart in self.get_payload(): for subsubpart in subpart.walk(): yield subsubpart # These two functions are imported into the Iterators.py interface module. def body_line_iterator(msg, decode=False): """Iterate over the parts, returning string payloads line-by-line. Optional decode (default False) is passed through to .get_payload(). """ for subpart in msg.walk(): payload = subpart.get_payload(decode=decode) if isinstance(payload, basestring): for line in StringIO(payload): yield line def typed_subpart_iterator(msg, maintype='text', subtype=None): """Iterate over the subparts with a given MIME type. Use `maintype' as the main MIME type to match against; this defaults to "text". Optional `subtype' is the MIME subtype to match against; if omitted, only the main type is matched. """ for subpart in msg.walk(): if subpart.get_content_maintype() == maintype: if subtype is None or subpart.get_content_subtype() == subtype: yield subpart def _structure(msg, fp=None, level=0, include_default=False): """A handy debugging aid""" if fp is None: fp = sys.stdout tab = ' ' * (level * 4) print >> fp, tab + msg.get_content_type(), if include_default: print >> fp, '[%s]' % msg.get_default_type() else: print >> fp if msg.is_multipart(): for subpart in msg.get_payload(): _structure(subpart, fp, level+1, include_default)
gpl-3.0
[ 3, 1898, 334, 35, 9, 12521, 13, 7968, 2018, 2290, 2752, 202, 199, 3, 6529, 26, 12377, 651, 644, 285, 2231, 87, 202, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 2999, 199, 624, 9958, 1785, 2943, 402, 2997, 28241, 436, 16952, 1041, 2999, 199, 363, 452, 363, 275, 359, 1128, 283, 2030, 63, 604, 63, 5778, 297, 1128, 283, 22033, 63, 954, 2064, 63, 5778, 297, 1128, 283, 7757, 297, 1128, 327, 4226, 440, 2387, 485, 6976, 342, 3967, 652, 1159, 1777, 402, 314, 10201, 3261, 14, 1128, 1622, 2999, 199, 646, 984, 202, 199, 504, 15073, 492, 5228, 10060, 1223, 201, 202, 199, 3, 961, 805, 911, 8649, 282, 1083, 402, 314, 6430, 1021, 202, 199, 318, 12778, 8, 277, 304, 1128, 408, 31491, 1806, 314, 1245, 3123, 12, 32035, 1924, 1007, 2064, 14, 2958, 710, 12778, 365, 10585, 315, 5818, 13, 2246, 1865, 14, 221, 961, 1083, 365, 282, 1128, 4306, 14, 1128, 408, 1128, 1995, 291, 1128, 340, 291, 14, 374, 63, 10123, 837, 1039, 367, 1007, 2064, 315, 291, 14, 362, 63, 4749, 837, 1675, 367, 1007, 954, 2064, 315, 1007, 2064, 14, 7757, 837, 2628, 1995, 1007, 954, 2064, 10060, 1223, 201, 202, 199, 3, 5723, 2877, 3423, 787, 8439, 1901, 314, 11953, 2750, 14, 647, 3217, 859, 14, 202, 199, 318, 2396, 63, 604, 63, 5778, 8, 1328, 12, 4849, 29, 797, 304, 1128, 408, 3315, 323, 1806, 314, 4184, 12, 8152, 1059, 4886, 83, 1004, 13, 991, 13, 604, 14, 2958, 4879, 4849, 334, 885, 756, 9, 365, 3032, 4012, 370, 1275, 362, 63, 4749, 1252, 1128, 408, 1128, 367, 1007, 2064, 315, 1499, 14, 7757, 837, 1039, 4886, 275, 1007, 2064, 14, 362, 63, 4749, 8, 2708, 29, 2708, 9, 1039, 340, 1228, 8, 4749, 12, 7116, 304, 1675, 367, 1004, 315, 5228, 8, 4749, 304, 2628, 1995, 1004, 8065, 199, 318, 20041, 63, 954, 2064, 63, 5778, 8, 1328, 12, 2446, 466, 534, 505, 297, 15686, 29, 403, 304, 1128, 408, 3315, 323, 1806, 314, 1007, 4181, 543, 282, 1627, 14735, 730, 14, 2958, 3645, 658, 973, 466, 7, 465, 314, 2446, 14735, 730, 370, 1336, 6169, 27, 642, 4243, 370, 1128, 298, 505, 1674, 221, 4879, 658, 10512, 7, 365, 314, 14735, 15686, 370, 1336, 6169, 27, 340, 1128, 11684, 12, 1454, 314, 2446, 730, 365, 7838, 14, 1128, 408, 1128, 367, 1007, 2064, 315, 1499, 14, 7757, 837, 1039, 340, 1007, 2064, 14, 362, 63, 1317, 63, 973, 466, 342, 508, 2446, 466, 26, 1675, 340, 15686, 365, 488, 503, 1007, 2064, 14, 362, 63, 1317, 63, 10512, 342, 508, 15686, 26, 2628, 1995, 1007, 2064, 10060, 1223, 201, 202, 199, 318, 485, 6976, 8, 1328, 12, 4090, 29, 403, 12, 2166, 29, 16, 12, 2387, 63, 885, 29, 797, 304, 1128, 408, 33, 4926, 89, 10201, 23939, 624, 1128, 340, 4090, 365, 488, 26, 1039, 4090, 275, 984, 14, 2703, 1128, 5174, 275, 283, 283, 627, 334, 1896, 627, 841, 9, 1128, 870, 4331, 4090, 12, 5174, 435, 1499, 14, 362, 63, 1317, 63, 466, 1062, 1128, 340, 2387, 63, 885, 26, 1039, 870, 4331, 4090, 12, 30423, 83, 6616, 450, 1499, 14, 362, 63, 885, 63, 466, 342, 1128, 587, 26, 1039, 870, 4331, 4090, 1128, 340, 1499, 14, 374, 63, 10123, 837, 1039, 367, 1007, 2064, 315, 1499, 14, 362, 63, 4749, 837, 1675, 485, 6976, 8, 954, 2064, 12, 4090, 12, 2166, 11, 17, 12, 2387, 63, 885, 9, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 12521, 13, 7968, 2018, 2290, 2752, 202, 199, 3, 6529, 26, 12377, 651, 644, 285, 2231, 87, 202, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 2999, 199, 624, 9958, 1785, 2943, 402, 2997, 28241, 436, 16952, 1041, 2999, 199, 363, 452, 363, 275, 359, 1128, 283, 2030, 63, 604, 63, 5778, 297, 1128, 283, 22033, 63, 954, 2064, 63, 5778, 297, 1128, 283, 7757, 297, 1128, 327, 4226, 440, 2387, 485, 6976, 342, 3967, 652, 1159, 1777, 402, 314, 10201, 3261, 14, 1128, 1622, 2999, 199, 646, 984, 202, 199, 504, 15073, 492, 5228, 10060, 1223, 201, 202, 199, 3, 961, 805, 911, 8649, 282, 1083, 402, 314, 6430, 1021, 202, 199, 318, 12778, 8, 277, 304, 1128, 408, 31491, 1806, 314, 1245, 3123, 12, 32035, 1924, 1007, 2064, 14, 2958, 710, 12778, 365, 10585, 315, 5818, 13, 2246, 1865, 14, 221, 961, 1083, 365, 282, 1128, 4306, 14, 1128, 408, 1128, 1995, 291, 1128, 340, 291, 14, 374, 63, 10123, 837, 1039, 367, 1007, 2064, 315, 291, 14, 362, 63, 4749, 837, 1675, 367, 1007, 954, 2064, 315, 1007, 2064, 14, 7757, 837, 2628, 1995, 1007, 954, 2064, 10060, 1223, 201, 202, 199, 3, 5723, 2877, 3423, 787, 8439, 1901, 314, 11953, 2750, 14, 647, 3217, 859, 14, 202, 199, 318, 2396, 63, 604, 63, 5778, 8, 1328, 12, 4849, 29, 797, 304, 1128, 408, 3315, 323, 1806, 314, 4184, 12, 8152, 1059, 4886, 83, 1004, 13, 991, 13, 604, 14, 2958, 4879, 4849, 334, 885, 756, 9, 365, 3032, 4012, 370, 1275, 362, 63, 4749, 1252, 1128, 408, 1128, 367, 1007, 2064, 315, 1499, 14, 7757, 837, 1039, 4886, 275, 1007, 2064, 14, 362, 63, 4749, 8, 2708, 29, 2708, 9, 1039, 340, 1228, 8, 4749, 12, 7116, 304, 1675, 367, 1004, 315, 5228, 8, 4749, 304, 2628, 1995, 1004, 8065, 199, 318, 20041, 63, 954, 2064, 63, 5778, 8, 1328, 12, 2446, 466, 534, 505, 297, 15686, 29, 403, 304, 1128, 408, 3315, 323, 1806, 314, 1007, 4181, 543, 282, 1627, 14735, 730, 14, 2958, 3645, 658, 973, 466, 7, 465, 314, 2446, 14735, 730, 370, 1336, 6169, 27, 642, 4243, 370, 1128, 298, 505, 1674, 221, 4879, 658, 10512, 7, 365, 314, 14735, 15686, 370, 1336, 6169, 27, 340, 1128, 11684, 12, 1454, 314, 2446, 730, 365, 7838, 14, 1128, 408, 1128, 367, 1007, 2064, 315, 1499, 14, 7757, 837, 1039, 340, 1007, 2064, 14, 362, 63, 1317, 63, 973, 466, 342, 508, 2446, 466, 26, 1675, 340, 15686, 365, 488, 503, 1007, 2064, 14, 362, 63, 1317, 63, 10512, 342, 508, 15686, 26, 2628, 1995, 1007, 2064, 10060, 1223, 201, 202, 199, 318, 485, 6976, 8, 1328, 12, 4090, 29, 403, 12, 2166, 29, 16, 12, 2387, 63, 885, 29, 797, 304, 1128, 408, 33, 4926, 89, 10201, 23939, 624, 1128, 340, 4090, 365, 488, 26, 1039, 4090, 275, 984, 14, 2703, 1128, 5174, 275, 283, 283, 627, 334, 1896, 627, 841, 9, 1128, 870, 4331, 4090, 12, 5174, 435, 1499, 14, 362, 63, 1317, 63, 466, 1062, 1128, 340, 2387, 63, 885, 26, 1039, 870, 4331, 4090, 12, 30423, 83, 6616, 450, 1499, 14, 362, 63, 885, 63, 466, 342, 1128, 587, 26, 1039, 870, 4331, 4090, 1128, 340, 1499, 14, 374, 63, 10123, 837, 1039, 367, 1007, 2064, 315, 1499, 14, 362, 63, 4749, 837, 1675, 485, 6976, 8, 954, 2064, 12, 4090, 12, 2166, 11, 17, 12, 2387, 63, 885, 9, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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4:ai from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL v3' __copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>' __docformat__ = 'restructuredtext en' import os from calibre import replace_entities from calibre.ebooks.metadata.toc import TOC from calibre.ebooks.mobi.reader.headers import NULL_INDEX from calibre.ebooks.mobi.reader.index import read_index tag_fieldname_map = { 1: ['pos',0], 2: ['len',0], 3: ['noffs',0], 4: ['hlvl',0], 5: ['koffs',0], 6: ['pos_fid',0], 21: ['parent',0], 22: ['child1',0], 23: ['childn',0], 69: ['image_index',0], 70 : ['desc_offset', 0], # 'Description offset in cncx' 71 : ['author_offset', 0], # 'Author offset in cncx' 72 : ['image_caption_offset', 0], # 'Image caption offset in cncx', 73 : ['image_attr_offset', 0], # 'Image attribution offset in cncx', } default_entry = { 'pos': -1, 'len': 0, 'noffs': -1, 'text' : "Unknown Text", 'hlvl' : -1, 'kind' : "Unknown Class", 'pos_fid' : None, 'parent' : -1, 'child1' : -1, 'childn' : -1, 'description': None, 'author': None, 'image_caption': None, 'image_attribution': None, } def read_ncx(sections, index, codec): index_entries = [] if index != NULL_INDEX: table, cncx = read_index(sections, index, codec) for num, x in enumerate(table.iteritems()): text, tag_map = x entry = default_entry.copy() entry['name'] = text entry['num'] = num for tag in tag_fieldname_map.iterkeys(): fieldname, i = tag_fieldname_map[tag] if tag in tag_map: fieldvalue = tag_map[tag][i] if tag == 6: # Appears to be an idx into the KF8 elems table with an # offset fieldvalue = tuple(tag_map[tag]) entry[fieldname] = fieldvalue for which, name in {3:'text', 5:'kind', 70:'description', 71:'author', 72:'image_caption', 73:'image_attribution'}.iteritems(): if tag == which: entry[name] = cncx.get(fieldvalue, default_entry[name]) index_entries.append(entry) return index_entries def build_toc(index_entries): ans = TOC(base_path=os.getcwdu()) levels = {x['hlvl'] for x in index_entries} num_map = {-1: ans} level_map = {l:[x for x in index_entries if x['hlvl'] == l] for l in levels} for lvl in sorted(levels): for item in level_map[lvl]: parent = num_map[item['parent']] child = parent.add_item(item['href'], item['idtag'], replace_entities(item['text'], encoding=None)) num_map[item['num']] = child # Set play orders in depth first order for i, item in enumerate(ans.flat()): item.play_order = i return ans
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7409, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 646, 747, 199, 199, 504, 19238, 492, 3350, 63, 8327, 199, 504, 19238, 14, 69, 8858, 14, 2343, 14, 13255, 492, 2296, 35, 199, 504, 19238, 14, 69, 8858, 14, 573, 4492, 14, 5503, 14, 2139, 492, 5962, 63, 10215, 199, 504, 19238, 14, 69, 8858, 14, 573, 4492, 14, 5503, 14, 1080, 492, 1586, 63, 1080, 199, 199, 1450, 63, 13646, 63, 1130, 275, 469, 267, 413, 26, 221, 788, 1712, 297, 16, 467, 267, 499, 26, 221, 788, 552, 297, 16, 467, 267, 650, 26, 221, 788, 889, 556, 83, 297, 16, 467, 267, 841, 26, 221, 788, 72, 27803, 297, 16, 467, 267, 959, 26, 221, 788, 75, 1997, 83, 297, 16, 467, 267, 1227, 26, 221, 788, 1712, 63, 9430, 297, 16, 467, 267, 7829, 26, 788, 1708, 297, 16, 467, 267, 6928, 26, 788, 1739, 17, 297, 16, 467, 267, 6546, 26, 788, 1739, 78, 297, 16, 467, 267, 14610, 26, 788, 1569, 63, 1080, 297, 16, 467, 267, 10045, 520, 788, 3257, 63, 2743, 297, 378, 467, 327, 283, 5831, 3268, 315, 286, 7966, 88, 7, 267, 17245, 520, 788, 2502, 63, 2743, 297, 378, 467, 327, 283, 5949, 3268, 315, 286, 7966, 88, 7, 267, 15323, 520, 788, 1569, 63, 13410, 63, 2743, 297, 378, 467, 327, 283, 3491, 19038, 3268, 315, 286, 7966, 88, 297, 267, 18525, 520, 788, 1569, 63, 962, 63, 2743, 297, 378, 467, 327, 283, 3491, 737, 15980, 3268, 315, 286, 7966, 88, 297, 199, 199, 93, 199, 199, 885, 63, 2373, 275, 469, 490, 283, 1712, 356, 221, 446, 17, 12, 490, 283, 552, 356, 221, 378, 12, 490, 283, 889, 556, 83, 356, 446, 17, 12, 490, 283, 505, 7, 520, 298, 5912, 4516, 401, 490, 283, 72, 27803, 7, 520, 446, 17, 12, 490, 283, 5091, 7, 520, 298, 5912, 8089, 401, 490, 283, 1712, 63, 9430, 7, 520, 488, 12, 490, 283, 1708, 7, 520, 446, 17, 12, 490, 283, 1739, 17, 7, 520, 446, 17, 12, 490, 283, 1739, 78, 7, 520, 446, 17, 12, 490, 283, 1802, 356, 488, 12, 490, 283, 2502, 356, 488, 12, 490, 283, 1569, 63, 13410, 356, 488, 12, 490, 283, 1569, 63, 292, 15980, 356, 488, 12, 199, 93, 199, 199, 318, 1586, 63, 7966, 88, 8, 7786, 12, 1478, 12, 9076, 304, 272, 1478, 63, 3189, 275, 942, 339, 340, 1478, 1137, 5962, 63, 10215, 26, 267, 1817, 12, 286, 7966, 88, 275, 1586, 63, 1080, 8, 7786, 12, 1478, 12, 9076, 9, 398, 367, 1967, 12, 671, 315, 3874, 8, 1224, 14, 4611, 5109, 288, 1318, 12, 1947, 63, 1130, 275, 671, 288, 2397, 275, 849, 63, 2373, 14, 1574, 342, 288, 2397, 459, 354, 418, 275, 1318, 288, 2397, 459, 1507, 418, 275, 1967, 953, 367, 1947, 315, 1947, 63, 13646, 63, 1130, 14, 16007, 837, 355, 18887, 12, 284, 275, 1947, 63, 13646, 63, 1130, 59, 1450, 61, 355, 340, 1947, 315, 1947, 63, 1130, 26, 490, 901, 585, 275, 1947, 63, 1130, 59, 1450, 1527, 73, 61, 490, 340, 1947, 508, 1227, 26, 717, 327, 13450, 321, 4291, 370, 506, 376, 4280, 1901, 314, 1804, 38, 24, 20840, 1817, 543, 376, 717, 327, 3268, 717, 901, 585, 275, 2008, 8, 1450, 63, 1130, 59, 1450, 566, 490, 2397, 59, 13646, 61, 275, 901, 585, 490, 367, 1314, 12, 536, 315, 469, 19, 4881, 505, 297, 959, 4881, 5091, 297, 10045, 4881, 1802, 297, 1169, 17245, 4881, 2502, 297, 15323, 4881, 1569, 63, 13410, 297, 1169, 18525, 4881, 1569, 63, 292, 15980, 936, 14, 4611, 837, 717, 340, 1947, 508, 1314, 26, 1169, 2397, 59, 354, 61, 275, 286, 7966, 88, 14, 362, 8, 698, 585, 12, 2511, 849, 63, 2373, 59, 354, 566, 288, 1478, 63, 3189, 14, 740, 8, 2373, 9, 339, 372, 1478, 63, 3189, 199, 199, 318, 1900, 63, 13255, 8, 1080, 63, 3189, 304, 272, 4987, 275, 2296, 35, 8, 1095, 63, 515, 29, 736, 14, 362, 15346, 2033, 1012, 272, 11106, 275, 469, 88, 459, 72, 27803, 418, 367, 671, 315, 1478, 63, 3189, 93, 272, 1967, 63, 1130, 275, 469, 13, 17, 26, 4987, 93, 272, 2166, 63, 1130, 275, 469, 76, 7766, 88, 367, 671, 315, 1478, 63, 3189, 340, 671, 459, 72, 27803, 418, 508, 634, 61, 367, 634, 315, 288, 11106, 93, 272, 367, 634, 7300, 315, 3355, 8, 11402, 304, 267, 367, 1242, 315, 2166, 63, 1130, 59, 27803, 2189, 288, 1676, 275, 1967, 63, 1130, 59, 1053, 459, 1708, 6538, 288, 1982, 275, 1676, 14, 525, 63, 1053, 8, 1053, 459, 6399, 995, 1242, 459, 344, 1450, 995, 490, 3350, 63, 8327, 8, 1053, 459, 505, 995, 2644, 29, 403, 430, 288, 1967, 63, 1130, 59, 1053, 459, 1507, 6538, 275, 1982, 339, 327, 2494, 5232, 15460, 315, 5818, 1642, 1865, 272, 367, 284, 12, 1242, 315, 3874, 8, 796, 14, 7088, 5109, 267, 1242, 14, 2802, 63, 1648, 275, 284, 339, 372, 4987, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7409, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 646, 747, 199, 199, 504, 19238, 492, 3350, 63, 8327, 199, 504, 19238, 14, 69, 8858, 14, 2343, 14, 13255, 492, 2296, 35, 199, 504, 19238, 14, 69, 8858, 14, 573, 4492, 14, 5503, 14, 2139, 492, 5962, 63, 10215, 199, 504, 19238, 14, 69, 8858, 14, 573, 4492, 14, 5503, 14, 1080, 492, 1586, 63, 1080, 199, 199, 1450, 63, 13646, 63, 1130, 275, 469, 267, 413, 26, 221, 788, 1712, 297, 16, 467, 267, 499, 26, 221, 788, 552, 297, 16, 467, 267, 650, 26, 221, 788, 889, 556, 83, 297, 16, 467, 267, 841, 26, 221, 788, 72, 27803, 297, 16, 467, 267, 959, 26, 221, 788, 75, 1997, 83, 297, 16, 467, 267, 1227, 26, 221, 788, 1712, 63, 9430, 297, 16, 467, 267, 7829, 26, 788, 1708, 297, 16, 467, 267, 6928, 26, 788, 1739, 17, 297, 16, 467, 267, 6546, 26, 788, 1739, 78, 297, 16, 467, 267, 14610, 26, 788, 1569, 63, 1080, 297, 16, 467, 267, 10045, 520, 788, 3257, 63, 2743, 297, 378, 467, 327, 283, 5831, 3268, 315, 286, 7966, 88, 7, 267, 17245, 520, 788, 2502, 63, 2743, 297, 378, 467, 327, 283, 5949, 3268, 315, 286, 7966, 88, 7, 267, 15323, 520, 788, 1569, 63, 13410, 63, 2743, 297, 378, 467, 327, 283, 3491, 19038, 3268, 315, 286, 7966, 88, 297, 267, 18525, 520, 788, 1569, 63, 962, 63, 2743, 297, 378, 467, 327, 283, 3491, 737, 15980, 3268, 315, 286, 7966, 88, 297, 199, 199, 93, 199, 199, 885, 63, 2373, 275, 469, 490, 283, 1712, 356, 221, 446, 17, 12, 490, 283, 552, 356, 221, 378, 12, 490, 283, 889, 556, 83, 356, 446, 17, 12, 490, 283, 505, 7, 520, 298, 5912, 4516, 401, 490, 283, 72, 27803, 7, 520, 446, 17, 12, 490, 283, 5091, 7, 520, 298, 5912, 8089, 401, 490, 283, 1712, 63, 9430, 7, 520, 488, 12, 490, 283, 1708, 7, 520, 446, 17, 12, 490, 283, 1739, 17, 7, 520, 446, 17, 12, 490, 283, 1739, 78, 7, 520, 446, 17, 12, 490, 283, 1802, 356, 488, 12, 490, 283, 2502, 356, 488, 12, 490, 283, 1569, 63, 13410, 356, 488, 12, 490, 283, 1569, 63, 292, 15980, 356, 488, 12, 199, 93, 199, 199, 318, 1586, 63, 7966, 88, 8, 7786, 12, 1478, 12, 9076, 304, 272, 1478, 63, 3189, 275, 942, 339, 340, 1478, 1137, 5962, 63, 10215, 26, 267, 1817, 12, 286, 7966, 88, 275, 1586, 63, 1080, 8, 7786, 12, 1478, 12, 9076, 9, 398, 367, 1967, 12, 671, 315, 3874, 8, 1224, 14, 4611, 5109, 288, 1318, 12, 1947, 63, 1130, 275, 671, 288, 2397, 275, 849, 63, 2373, 14, 1574, 342, 288, 2397, 459, 354, 418, 275, 1318, 288, 2397, 459, 1507, 418, 275, 1967, 953, 367, 1947, 315, 1947, 63, 13646, 63, 1130, 14, 16007, 837, 355, 18887, 12, 284, 275, 1947, 63, 13646, 63, 1130, 59, 1450, 61, 355, 340, 1947, 315, 1947, 63, 1130, 26, 490, 901, 585, 275, 1947, 63, 1130, 59, 1450, 1527, 73, 61, 490, 340, 1947, 508, 1227, 26, 717, 327, 13450, 321, 4291, 370, 506, 376, 4280, 1901, 314, 1804, 38, 24, 20840, 1817, 543, 376, 717, 327, 3268, 717, 901, 585, 275, 2008, 8, 1450, 63, 1130, 59, 1450, 566, 490, 2397, 59, 13646, 61, 275, 901, 585, 490, 367, 1314, 12, 536, 315, 469, 19, 4881, 505, 297, 959, 4881, 5091, 297, 10045, 4881, 1802, 297, 1169, 17245, 4881, 2502, 297, 15323, 4881, 1569, 63, 13410, 297, 1169, 18525, 4881, 1569, 63, 292, 15980, 936, 14, 4611, 837, 717, 340, 1947, 508, 1314, 26, 1169, 2397, 59, 354, 61, 275, 286, 7966, 88, 14, 362, 8, 698, 585, 12, 2511, 849, 63, 2373, 59, 354, 566, 288, 1478, 63, 3189, 14, 740, 8, 2373, 9, 339, 372, 1478, 63, 3189, 199, 199, 318, 1900, 63, 13255, 8, 1080, 63, 3189, 304, 272, 4987, 275, 2296, 35, 8, 1095, 63, 515, 29, 736, 14, 362, 15346, 2033, 1012, 272, 11106, 275, 469, 88, 459, 72, 27803, 418, 367, 671, 315, 1478, 63, 3189, 93, 272, 1967, 63, 1130, 275, 469, 13, 17, 26, 4987, 93, 272, 2166, 63, 1130, 275, 469, 76, 7766, 88, 367, 671, 315, 1478, 63, 3189, 340, 671, 459, 72, 27803, 418, 508, 634, 61, 367, 634, 315, 288, 11106, 93, 272, 367, 634, 7300, 315, 3355, 8, 11402, 304, 267, 367, 1242, 315, 2166, 63, 1130, 59, 27803, 2189, 288, 1676, 275, 1967, 63, 1130, 59, 1053, 459, 1708, 6538, 288, 1982, 275, 1676, 14, 525, 63, 1053, 8, 1053, 459, 6399, 995, 1242, 459, 344, 1450, 995, 490, 3350, 63, 8327, 8, 1053, 459, 505, 995, 2644, 29, 403, 430, 288, 1967, 63, 1130, 59, 1053, 459, 1507, 6538, 275, 1982, 339, 327, 2494, 5232, 15460, 315, 5818, 1642, 1865, 272, 367, 284, 12, 1242, 315, 3874, 8, 796, 14, 7088, 5109, 267, 1242, 14, 2802, 63, 1648, 275, 284, 339, 372, 4987, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aplicatii-romanesti/allinclusive-kodi-pi
.kodi/userdata/addon_data/plugin.video.p2p-streams/acestream/ace/python-modules/M2Crypto/X509.py
8
34646
"""M2Crypto wrapper for OpenSSL X509 API. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. Portions created by Open Source Applications Foundation (OSAF) are Copyright (C) 2004-2007 OSAF. All Rights Reserved. Author: Heikki Toivonen """ # M2Crypto from M2Crypto import ASN1, BIO, Err, EVP, util import m2 FORMAT_DER = 0 FORMAT_PEM = 1 class X509Error(Exception): pass m2.x509_init(X509Error) V_OK = m2.X509_V_OK def new_extension(name, value, critical=0, _pyfree=1): """ Create new X509_Extension instance. """ if name == 'subjectKeyIdentifier' and \ value.strip('0123456789abcdefABCDEF:') is not '': raise ValueError('value must be precomputed hash') lhash = m2.x509v3_lhash() ctx = m2.x509v3_set_conf_lhash(lhash) x509_ext_ptr = m2.x509v3_ext_conf(lhash, ctx, name, value) x509_ext = X509_Extension(x509_ext_ptr, _pyfree) x509_ext.set_critical(critical) return x509_ext class X509_Extension: """ X509 Extension """ m2_x509_extension_free = m2.x509_extension_free def __init__(self, x509_ext_ptr=None, _pyfree=1): self.x509_ext = x509_ext_ptr self._pyfree = _pyfree def __del__(self): if getattr(self, '_pyfree', 0) and self.x509_ext: self.m2_x509_extension_free(self.x509_ext) def _ptr(self): return self.x509_ext def set_critical(self, critical=1): """ Mark this extension critical or noncritical. By default an extension is not critical. @type critical: int @param critical: Nonzero sets this extension as critical. Calling this method without arguments will set this extension to critical. """ return m2.x509_extension_set_critical(self.x509_ext, critical) def get_critical(self): """ Return whether or not this is a critical extension. @rtype: int @return: Nonzero if this is a critical extension. """ return m2.x509_extension_get_critical(self.x509_ext) def get_name(self): """ Get the extension name, for example 'subjectAltName'. """ return m2.x509_extension_get_name(self.x509_ext) def get_value(self, flag=0, indent=0): """ Get the extension value, for example 'DNS:www.example.com'. @param flag: Flag to control what and how to print. @param indent: How many spaces to print before actual value. """ buf=BIO.MemoryBuffer() m2.x509_ext_print(buf.bio_ptr(), self.x509_ext, flag, indent) return buf.read_all() class X509_Extension_Stack: """ X509 Extension Stack @warning: Do not modify the underlying OpenSSL stack except through this interface, or use any OpenSSL functions that do so indirectly. Doing so will get the OpenSSL stack and the internal pystack of this class out of sync, leading to python memory leaks, exceptions or even python crashes! """ m2_sk_x509_extension_free = m2.sk_x509_extension_free def __init__(self, stack=None, _pyfree=0): if stack is not None: self.stack = stack self._pyfree = _pyfree num = m2.sk_x509_extension_num(self.stack) for i in range(num): self.pystack.append(X509_Extension(m2.sk_x509_extension_value(self.stack, i), _pyfree=_pyfree)) else: self.stack = m2.sk_x509_extension_new_null() self._pyfree = 1 self.pystack = [] # This must be kept in sync with self.stack def __del__(self): if getattr(self, '_pyfree', 0): self.m2_sk_x509_extension_free(self.stack) def __len__(self): assert m2.sk_x509_extension_num(self.stack) == len(self.pystack) return len(self.pystack) def __getitem__(self, idx): return self.pystack[idx] def __iter__(self): return iter(self.pystack) def _ptr(self): return self.stack def push(self, x509_ext): """ Push X509_Extension object onto the stack. @type x509_ext: M2Crypto.X509.X509_Extension @param x509_ext: X509_Extension object to be pushed onto the stack. @return: The number of extensions on the stack. """ self.pystack.append(x509_ext) ret = m2.sk_x509_extension_push(self.stack, x509_ext._ptr()) assert ret == len(self.pystack) return ret def pop(self): """ Pop X509_Extension object from the stack. @return: X509_Extension popped """ x509_ext_ptr = m2.sk_x509_extension_pop(self.stack) if x509_ext_ptr is None: assert len(self.pystack) == 0 return None return self.pystack.pop() class X509_Name_Entry: """ X509 Name Entry """ m2_x509_name_entry_free = m2.x509_name_entry_free def __init__(self, x509_name_entry, _pyfree=0): self.x509_name_entry = x509_name_entry self._pyfree = _pyfree def __del__(self): if getattr(self, '_pyfree', 0): self.m2_x509_name_entry_free(self.x509_name_entry) def _ptr(self): return self.x509_name_entry def set_object(self, asn1obj): return m2.x509_name_entry_set_object(self.x509_name_entry, asn1obj._ptr()) def set_data(self, data, type=ASN1.MBSTRING_ASC): return m2.x509_name_entry_set_data(self.x509_name_entry, type, data) def get_object(self): return ASN1.ASN1_Object(m2.x509_name_entry_get_object(self.x509_name_entry)) def get_data(self): return ASN1.ASN1_String(m2.x509_name_entry_get_data(self.x509_name_entry)) def create_by_txt( self, field, type, entry, len): return m2.x509_name_entry_create_by_txt(self.x509_name_entry._ptr(), field, type, entry, len) class X509_Name: """ X509 Name """ nid = {'C' : m2.NID_countryName, 'SP' : m2.NID_stateOrProvinceName, 'ST' : m2.NID_stateOrProvinceName, 'stateOrProvinceName' : m2.NID_stateOrProvinceName, 'L' : m2.NID_localityName, 'localityName' : m2.NID_localityName, 'O' : m2.NID_organizationName, 'organizationName' : m2.NID_organizationName, 'OU' : m2.NID_organizationalUnitName, 'organizationUnitName' : m2.NID_organizationalUnitName, 'CN' : m2.NID_commonName, 'commonName' : m2.NID_commonName, 'Email' : m2.NID_pkcs9_emailAddress, 'emailAddress' : m2.NID_pkcs9_emailAddress, 'serialNumber' : m2.NID_serialNumber, 'SN' : m2.NID_surname, 'surname' : m2.NID_surname, 'GN' : m2.NID_givenName, 'givenName' : m2.NID_givenName } m2_x509_name_free = m2.x509_name_free def __init__(self, x509_name=None, _pyfree=0): if x509_name is not None: assert m2.x509_name_type_check(x509_name), "'x509_name' type error" self.x509_name = x509_name self._pyfree = _pyfree else: self.x509_name = m2.x509_name_new () self._pyfree = 1 def __del__(self): if getattr(self, '_pyfree', 0): self.m2_x509_name_free(self.x509_name) def __str__(self): assert m2.x509_name_type_check(self.x509_name), "'x509_name' type error" return m2.x509_name_oneline(self.x509_name) def __getattr__(self, attr): if attr in self.nid: assert m2.x509_name_type_check(self.x509_name), "'x509_name' type error" return m2.x509_name_by_nid(self.x509_name, self.nid[attr]) if attr in self.__dict__: return self.__dict__[attr] raise AttributeError, (self, attr) def __setattr__(self, attr, value): if attr in self.nid: assert m2.x509_name_type_check(self.x509_name), "'x509_name' type error" return m2.x509_name_set_by_nid(self.x509_name, self.nid[attr], value) self.__dict__[attr] = value def __len__(self): return m2.x509_name_entry_count(self.x509_name) def __getitem__(self, idx): if not 0 <= idx < self.entry_count(): raise IndexError("index out of range") return X509_Name_Entry(m2.x509_name_get_entry(self.x509_name, idx)) def __iter__(self): for i in xrange(self.entry_count()): yield self[i] def _ptr(self): #assert m2.x509_name_type_check(self.x509_name), "'x509_name' type error" return self.x509_name def add_entry_by_txt(self, field, type, entry, len, loc, set): return m2.x509_name_add_entry_by_txt(self.x509_name, field, type, entry, len, loc, set ) def entry_count( self ): return m2.x509_name_entry_count( self.x509_name ) def get_entries_by_nid(self, nid): ret = [] lastpos = -1 while True: lastpos = m2.x509_name_get_index_by_nid(self.x509_name, nid, lastpos) if lastpos == -1: break ret.append(self[lastpos]) return ret def as_text(self, indent=0, flags=m2.XN_FLAG_COMPAT): """ as_text returns the name as a string. @param indent: Each line in multiline format is indented by this many spaces. @param flags: Flags that control how the output should be formatted. """ assert m2.x509_name_type_check(self.x509_name), "'x509_name' type error" buf=BIO.MemoryBuffer() m2.x509_name_print_ex(buf.bio_ptr(), self.x509_name, indent, flags) return buf.read_all() def as_der(self): assert m2.x509_name_type_check(self.x509_name), "'x509_name' type error" return m2.x509_name_get_der(self.x509_name) def as_hash(self): assert m2.x509_name_type_check(self.x509_name), "'x509_name' type error" return m2.x509_name_hash(self.x509_name) class X509: """ X.509 Certificate """ m2_x509_free = m2.x509_free def __init__(self, x509=None, _pyfree=0): if x509 is not None: assert m2.x509_type_check(x509), "'x509' type error" self.x509 = x509 self._pyfree = _pyfree else: self.x509 = m2.x509_new () self._pyfree = 1 def __del__(self): if getattr(self, '_pyfree', 0): self.m2_x509_free(self.x509) def _ptr(self): assert m2.x509_type_check(self.x509), "'x509' type error" return self.x509 def as_text(self): assert m2.x509_type_check(self.x509), "'x509' type error" buf=BIO.MemoryBuffer() m2.x509_print(buf.bio_ptr(), self.x509) return buf.read_all() def as_der(self): assert m2.x509_type_check(self.x509), "'x509' type error" return m2.i2d_x509(self.x509) def as_pem(self): buf=BIO.MemoryBuffer() m2.x509_write_pem(buf.bio_ptr(), self.x509) return buf.read_all() def save_pem(self, filename): """ save_pem """ bio=BIO.openfile(filename, 'wb') return m2.x509_write_pem(bio.bio_ptr(), self.x509) def save(self, filename, format=FORMAT_PEM): """ Saves X.509 certificate to a file. Default output format is PEM. @type filename: string @param filename: Name of the file the cert will be saved to. @type format: int @param format: Controls what output format is used to save the cert. Either FORMAT_PEM or FORMAT_DER to save in PEM or DER format. Raises a ValueError if an unknow format is used. """ bio = BIO.openfile(filename, 'wb') if format == FORMAT_PEM: return m2.x509_write_pem(bio.bio_ptr(), self.x509) elif format == FORMAT_DER: return m2.i2d_x509_bio(bio.bio_ptr(), self.x509) else: raise ValueError("Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER") def set_version(self, version): """ Set version. @type version: int @param version: Version number. @rtype: int @return: Returns 0 on failure. """ assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_version(self.x509, version) def set_not_before(self, asn1_utctime): assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_not_before(self.x509, asn1_utctime._ptr()) def set_not_after(self, asn1_utctime): assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_not_after(self.x509, asn1_utctime._ptr()) def set_subject_name(self, name): assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_subject_name(self.x509, name.x509_name) def set_issuer_name(self, name): assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_issuer_name(self.x509, name.x509_name) def get_version(self): assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_get_version(self.x509) def get_serial_number(self): assert m2.x509_type_check(self.x509), "'x509' type error" asn1_integer = m2.x509_get_serial_number(self.x509) return m2.asn1_integer_get(asn1_integer) def set_serial_number(self, serial): """ Set serial number. @type serial: int @param serial: Serial number. """ assert m2.x509_type_check(self.x509), "'x509' type error" # This "magically" changes serial since asn1_integer # is C pointer to x509's internal serial number. asn1_integer = m2.x509_get_serial_number(self.x509) return m2.asn1_integer_set(asn1_integer, serial) # XXX Or should I do this? #asn1_integer = m2.asn1_integer_new() #m2.asn1_integer_set(asn1_integer, serial) #return m2.x509_set_serial_number(self.x509, asn1_integer) def get_not_before(self): assert m2.x509_type_check(self.x509), "'x509' type error" return ASN1.ASN1_UTCTIME(m2.x509_get_not_before(self.x509)) def get_not_after(self): assert m2.x509_type_check(self.x509), "'x509' type error" return ASN1.ASN1_UTCTIME(m2.x509_get_not_after(self.x509)) def get_pubkey(self): assert m2.x509_type_check(self.x509), "'x509' type error" return EVP.PKey(m2.x509_get_pubkey(self.x509), _pyfree=1) def set_pubkey(self, pkey): """ Set the public key for the certificate @type pkey: EVP_PKEY @param pkey: Public key """ assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_pubkey(self.x509, pkey.pkey) def get_issuer(self): assert m2.x509_type_check(self.x509), "'x509' type error" return X509_Name(m2.x509_get_issuer_name(self.x509)) def set_issuer(self, name): """ Set issuer name. @type name: X509_Name @param name: subjectName field. """ assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_issuer_name(self.x509, name.x509_name) def get_subject(self): assert m2.x509_type_check(self.x509), "'x509' type error" return X509_Name(m2.x509_get_subject_name(self.x509)) def set_subject(self, name): """ Set subject name. @type name: X509_Name @param name: subjectName field. """ assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_set_subject_name(self.x509, name.x509_name) def add_ext(self, ext): """ Add X509 extension to this certificate. @type ext: X509_Extension @param ext: Extension """ assert m2.x509_type_check(self.x509), "'x509' type error" return m2.x509_add_ext(self.x509, ext.x509_ext, -1) def get_ext(self, name): """ Get X509 extension by name. @type name: Name of the extension @param name: str @return: X509_Extension """ # Optimizations to reduce attribute accesses m2x509_get_ext = m2.x509_get_ext m2x509_extension_get_name = m2.x509_extension_get_name x509 = self.x509 for i in range(m2.x509_get_ext_count(x509)): extPtr = m2x509_get_ext(x509, i) if m2x509_extension_get_name(extPtr) == name: return X509_Extension(extPtr, _pyfree=0) raise LookupError def get_ext_at(self, index): """ Get X509 extension by index. @type index: Name of the extension @param index: int @return: X509_Extension """ if index < 0 or index >= self.get_ext_count(): raise IndexError return X509_Extension(m2.x509_get_ext(self.x509, index), _pyfree=0) def get_ext_count(self): """ Get X509 extension count. """ return m2.x509_get_ext_count(self.x509) def sign(self, pkey, md): """ Sign the certificate. @type pkey: EVP_PKEY @param pkey: Public key @type md: str @param md: Message digest algorithm to use for signing, for example 'sha1'. """ assert m2.x509_type_check(self.x509), "'x509' type error" mda = getattr(m2, md, None) if mda is None: raise ValueError, ('unknown message digest', md) return m2.x509_sign(self.x509, pkey.pkey, mda()) def verify(self, pkey=None): assert m2.x509_type_check(self.x509), "'x509' type error" if pkey: return m2.x509_verify(self.x509, pkey.pkey) else: return m2.x509_verify(self.x509, self.get_pubkey().pkey) def check_ca(self): """ Check if the certificate is a Certificate Authority (CA) certificate. @return: 0 if the certificate is not CA, nonzero otherwise. @requires: OpenSSL 0.9.8 or newer """ return m2.x509_check_ca(self.x509) def check_purpose(self, id, ca): """ Check if the certificate's purpose matches the asked purpose. @param id: Purpose id. See X509_PURPOSE_* constants. @param ca: 1 if the certificate should be CA, 0 otherwise. @return: 0 if the certificate purpose does not match, nonzero otherwise. """ return m2.x509_check_purpose(self.x509, id, ca) def get_fingerprint(self, md='md5'): """ Get the fingerprint of the certificate. @param md: Message digest algorithm to use. @return: String containing the fingerprint in hex format. """ der = self.as_der() md = EVP.MessageDigest(md) md.update(der) digest = md.final() return hex(util.octx_to_num(digest))[2:-1].upper() def load_cert(file, format=FORMAT_PEM): """ Load certificate from file. @type file: string @param file: Name of file containing certificate in either DER or PEM format. @type format: int, either FORMAT_PEM or FORMAT_DER @param format: Describes the format of the file to be loaded, either PEM or DER. @rtype: M2Crypto.X509.X509 @return: M2Crypto.X509.X509 object. """ bio = BIO.openfile(file) if format == FORMAT_PEM: return load_cert_bio(bio) elif format == FORMAT_DER: cptr = m2.d2i_x509(bio._ptr()) if cptr is None: raise X509Error(Err.get_error()) return X509(cptr, _pyfree=1) else: raise ValueError("Unknown format. Must be either FORMAT_DER or FORMAT_PEM") def load_cert_bio(bio, format=FORMAT_PEM): """ Load certificate from a bio. @type bio: M2Crypto.BIO.BIO @param bio: BIO pointing at a certificate in either DER or PEM format. @type format: int, either FORMAT_PEM or FORMAT_DER @param format: Describes the format of the cert to be loaded, either PEM or DER. @rtype: M2Crypto.X509.X509 @return: M2Crypto.X509.X509 object. """ if format == FORMAT_PEM: cptr = m2.x509_read_pem(bio._ptr()) elif format == FORMAT_DER: cptr = m2.d2i_x509(bio._ptr()) else: raise ValueError("Unknown format. Must be either FORMAT_DER or FORMAT_PEM") if cptr is None: raise X509Error(Err.get_error()) return X509(cptr, _pyfree=1) def load_cert_string(string, format=FORMAT_PEM): """ Load certificate from a string. @type string: string @param string: String containing a certificate in either DER or PEM format. @type format: int, either FORMAT_PEM or FORMAT_DER @param format: Describes the format of the cert to be loaded, either PEM or DER. @rtype: M2Crypto.X509.X509 @return: M2Crypto.X509.X509 object. """ bio = BIO.MemoryBuffer(string) return load_cert_bio(bio, format) def load_cert_der_string(string): """ Load certificate from a string. @type string: string @param string: String containing a certificate in DER format. @rtype: M2Crypto.X509.X509 @return: M2Crypto.X509.X509 object. """ bio = BIO.MemoryBuffer(string) cptr = m2.d2i_x509(bio._ptr()) if cptr is None: raise X509Error(Err.get_error()) return X509(cptr, _pyfree=1) class X509_Store_Context: """ X509 Store Context """ m2_x509_store_ctx_free = m2.x509_store_ctx_free def __init__(self, x509_store_ctx, _pyfree=0): self.ctx = x509_store_ctx self._pyfree = _pyfree def __del__(self): if self._pyfree: self.m2_x509_store_ctx_free(self.ctx) def _ptr(self): return self.ctx def get_current_cert(self): """ Get current X.509 certificate. @warning: The returned certificate is NOT refcounted, so you can not rely on it being valid once the store context goes away or is modified. """ return X509(m2.x509_store_ctx_get_current_cert(self.ctx), _pyfree=0) def get_error(self): """ Get error code. """ return m2.x509_store_ctx_get_error(self.ctx) def get_error_depth(self): """ Get error depth. """ return m2.x509_store_ctx_get_error_depth(self.ctx) def get1_chain(self): """ Get certificate chain. @return: Reference counted (i.e. safe to use even after the store context goes away) stack of certificates in the chain. @rtype: X509_Stack """ return X509_Stack(m2.x509_store_ctx_get1_chain(self.ctx), 1, 1) class X509_Store: """ X509 Store """ m2_x509_store_free = m2.x509_store_free def __init__(self, store=None, _pyfree=0): if store is not None: self.store = store self._pyfree = _pyfree else: self.store = m2.x509_store_new() self._pyfree = 1 def __del__(self): if getattr(self, '_pyfree', 0): self.m2_x509_store_free(self.store) def _ptr(self): return self.store def load_info(self, file): ret = m2.x509_store_load_locations(self.store, file) if ret < 1: raise X509Error(Err.get_error()) return ret load_locations = load_info def add_x509(self, x509): assert isinstance(x509, X509) return m2.x509_store_add_cert(self.store, x509._ptr()) add_cert = add_x509 class X509_Stack: """ X509 Stack @warning: Do not modify the underlying OpenSSL stack except through this interface, or use any OpenSSL functions that do so indirectly. Doing so will get the OpenSSL stack and the internal pystack of this class out of sync, leading to python memory leaks, exceptions or even python crashes! """ m2_sk_x509_free = m2.sk_x509_free def __init__(self, stack=None, _pyfree=0, _pyfree_x509=0): if stack is not None: self.stack = stack self._pyfree = _pyfree self.pystack = [] # This must be kept in sync with self.stack num = m2.sk_x509_num(self.stack) for i in range(num): self.pystack.append(X509(m2.sk_x509_value(self.stack, i), _pyfree=_pyfree_x509)) else: self.stack = m2.sk_x509_new_null() self._pyfree = 1 self.pystack = [] # This must be kept in sync with self.stack def __del__(self): if getattr(self, '_pyfree', 0): self.m2_sk_x509_free(self.stack) def __len__(self): assert m2.sk_x509_num(self.stack) == len(self.pystack) return len(self.pystack) def __getitem__(self, idx): return self.pystack[idx] def __iter__(self): return iter(self.pystack) def _ptr(self): return self.stack def push(self, x509): """ push an X509 certificate onto the stack. @param x509: X509 object. @return: The number of X509 objects currently on the stack. """ assert isinstance(x509, X509) self.pystack.append(x509) ret = m2.sk_x509_push(self.stack, x509._ptr()) assert ret == len(self.pystack) return ret def pop(self): """ pop a certificate from the stack. @return: X509 object that was popped, or None if there is nothing to pop. """ x509_ptr = m2.sk_x509_pop(self.stack) if x509_ptr is None: assert len(self.pystack) == 0 return None return self.pystack.pop() def as_der(self): """ Return the stack as a DER encoded string """ return m2.get_der_encoding_stack(self.stack) def new_stack_from_der(der_string): """ Create a new X509_Stack from DER string. @return: X509_Stack """ stack_ptr = m2.make_stack_from_der_sequence(der_string) if stack_ptr is None: raise X509Error(Err.get_error()) return X509_Stack(stack_ptr, 1, 1) class Request: """ X509 Certificate Request. """ m2_x509_req_free = m2.x509_req_free def __init__(self, req=None, _pyfree=0): if req is not None: self.req = req self._pyfree = _pyfree else: self.req = m2.x509_req_new() self._pyfree = 1 def __del__(self): if getattr(self, '_pyfree', 0): self.m2_x509_req_free(self.req) def as_text(self): buf=BIO.MemoryBuffer() m2.x509_req_print(buf.bio_ptr(), self.req) return buf.read_all() def as_pem(self): buf=BIO.MemoryBuffer() m2.x509_req_write_pem(buf.bio_ptr(), self.req) return buf.read_all() def as_der(self): buf = BIO.MemoryBuffer() m2.i2d_x509_req_bio(buf.bio_ptr(), self.req) return buf.read_all() def save_pem(self, filename): bio=BIO.openfile(filename, 'wb') return m2.x509_req_write_pem(bio.bio_ptr(), self.req) def save(self, filename, format=FORMAT_PEM): """ Saves X.509 certificate request to a file. Default output format is PEM. @type filename: string @param filename: Name of the file the request will be saved to. @type format: int @param format: Controls what output format is used to save the request. Either FORMAT_PEM or FORMAT_DER to save in PEM or DER format. Raises ValueError if an unknown format is used. """ bio = BIO.openfile(filename, 'wb') if format == FORMAT_PEM: return m2.x509_req_write_pem(bio.bio_ptr(), self.req) elif format == FORMAT_DER: return m2.i2d_x509_req_bio(bio.bio_ptr(), self.req) else: raise ValueError("Unknown filetype. Must be either FORMAT_DER or FORMAT_PEM") def get_pubkey(self): """ Get the public key for the request. @rtype: EVP_PKEY @return: Public key from the request. """ return EVP.PKey(m2.x509_req_get_pubkey(self.req), _pyfree=1) def set_pubkey(self, pkey): """ Set the public key for the request. @type pkey: EVP_PKEY @param pkey: Public key @rtype: int @return: Return 1 for success and 0 for failure. """ return m2.x509_req_set_pubkey( self.req, pkey.pkey ) def get_version(self): """ Get version. @rtype: int @return: Returns version. """ return m2.x509_req_get_version(self.req) def set_version(self, version): """ Set version. @type version: int @param version: Version number. @rtype: int @return: Returns 0 on failure. """ return m2.x509_req_set_version( self.req, version ) def get_subject(self): return X509_Name(m2.x509_req_get_subject_name( self.req )) def set_subject_name(self, name): """ Set subject name. @type name: X509_Name @param name: subjectName field. """ return m2.x509_req_set_subject_name( self.req, name.x509_name ) set_subject = set_subject_name def add_extensions(self, ext_stack): """ Add X509 extensions to this request. @type ext_stack: X509_Extension_Stack @param ext_stack: Stack of extensions to add. """ return m2.x509_req_add_extensions(self.req, ext_stack._ptr()) def verify(self, pkey): return m2.x509_req_verify(self.req, pkey.pkey) def sign(self, pkey, md): mda = getattr(m2, md, None) if mda is None: raise ValueError, ('unknown message digest', md) return m2.x509_req_sign(self.req, pkey.pkey, mda()) def load_request(file, format=FORMAT_PEM): """ Load certificate request from file. @type file: string @param file: Name of file containing certificate request in either PEM or DER format. @type format: int, either FORMAT_PEM or FORMAT_DER @param format: Describes the format of the file to be loaded, either PEM or DER. @rtype: M2Crypto.X509.Request @return: M2Crypto.X509.Request object. """ f=BIO.openfile(file) if format == FORMAT_PEM: cptr=m2.x509_req_read_pem(f.bio_ptr()) elif format == FORMAT_DER: cptr = m2.d2i_x509_req(f.bio_ptr()) else: raise ValueError("Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER") f.close() if cptr is None: raise X509Error(Err.get_error()) return Request(cptr, 1) def load_request_bio(bio, format=FORMAT_PEM): """ Load certificate request from a bio. @type bio: M2Crypto.BIO.BIO @param bio: BIO pointing at a certificate request in either DER or PEM format. @type format: int, either FORMAT_PEM or FORMAT_DER @param format: Describes the format of the request to be loaded, either PEM or DER. @rtype: M2Crypto.X509.Request @return: M2Crypto.X509.Request object. """ if format == FORMAT_PEM: cptr = m2.x509_req_read_pem(bio._ptr()) elif format == FORMAT_DER: cptr = m2.d2i_x509_req(bio._ptr()) else: raise ValueError("Unknown format. Must be either FORMAT_DER or FORMAT_PEM") if cptr is None: raise X509Error(Err.get_error()) return Request(cptr, _pyfree=1) def load_request_string(string, format=FORMAT_PEM): """ Load certificate request from a string. @type string: string @param string: String containing a certificate request in either DER or PEM format. @type format: int, either FORMAT_PEM or FORMAT_DER @param format: Describes the format of the request to be loaded, either PEM or DER. @rtype: M2Crypto.X509.Request @return: M2Crypto.X509.Request object. """ bio = BIO.MemoryBuffer(string) return load_request_bio(bio, format) def load_request_der_string(string): """ Load certificate request from a string. @type string: string @param string: String containing a certificate request in DER format. @rtype: M2Crypto.X509.Request @return: M2Crypto.X509.Request object. """ bio = BIO.MemoryBuffer(string) return load_request_bio(bio, FORMAT_DER) class CRL: """ X509 Certificate Revocation List """ m2_x509_crl_free = m2.x509_crl_free def __init__(self, crl=None, _pyfree=0): if crl is not None: self.crl = crl self._pyfree = _pyfree else: self.crl = m2.x509_crl_new() self._pyfree = 1 def __del__(self): if getattr(self, '_pyfree', 0): self.m2_x509_crl_free(self.crl) def as_text(self): """ Return CRL in PEM format in a string. @rtype: string @return: String containing the CRL in PEM format. """ buf=BIO.MemoryBuffer() m2.x509_crl_print(buf.bio_ptr(), self.crl) return buf.read_all() def load_crl(file): """ Load CRL from file. @type file: string @param file: Name of file containing CRL in PEM format. @rtype: M2Crypto.X509.CRL @return: M2Crypto.X509.CRL object. """ f=BIO.openfile(file) cptr=m2.x509_crl_read_pem(f.bio_ptr()) f.close() if cptr is None: raise X509Error(Err.get_error()) return CRL(cptr, 1)
apache-2.0
[ 624, 45, 18, 17134, 4975, 367, 14296, 1323, 6576, 3261, 14, 199, 199, 7384, 334, 67, 9, 21300, 13, 15431, 653, 71, 11308, 7420, 428, 73, 951, 14, 2900, 4481, 4644, 14, 199, 199, 48, 18434, 2737, 701, 3232, 5800, 24636, 2752, 334, 3100, 5699, 9, 787, 199, 7384, 334, 35, 9, 8353, 13, 9488, 593, 4251, 38, 14, 2900, 5924, 5702, 14, 199, 5949, 26, 5311, 3258, 8810, 4005, 1003, 265, 287, 199, 624, 199, 199, 3, 603, 18, 17134, 199, 504, 603, 18, 17134, 492, 31139, 17, 12, 699, 2090, 12, 221, 5432, 12, 662, 14159, 12, 4884, 199, 646, 333, 18, 199, 199, 4807, 63, 11733, 275, 378, 199, 4807, 63, 24160, 275, 413, 199, 199, 533, 1323, 6576, 547, 8, 1726, 304, 986, 199, 199, 77, 18, 14, 88, 6576, 63, 826, 8, 56, 6576, 547, 9, 199, 199, 54, 63, 3593, 275, 333, 18, 14, 56, 6576, 63, 54, 63, 3593, 199, 199, 318, 892, 63, 3435, 8, 354, 12, 574, 12, 19698, 29, 16, 12, 485, 647, 4624, 29, 17, 304, 272, 408, 272, 2790, 892, 1323, 6576, 63, 6382, 1256, 14, 272, 408, 272, 340, 536, 508, 283, 5875, 1197, 7544, 7, 436, 971, 267, 574, 14, 1913, 360, 11371, 10678, 18820, 10993, 365, 440, 8061, 267, 746, 1722, 360, 585, 1471, 506, 876, 14378, 2631, 358, 272, 634, 2227, 275, 333, 18, 14, 88, 6576, 86, 19, 63, 76, 2227, 342, 272, 4027, 275, 333, 18, 14, 88, 6576, 86, 19, 63, 409, 63, 2190, 63, 76, 2227, 8, 76, 2227, 9, 272, 671, 6576, 63, 832, 63, 4695, 275, 333, 18, 14, 88, 6576, 86, 19, 63, 832, 63, 2190, 8, 76, 2227, 12, 4027, 12, 536, 12, 574, 9, 272, 671, 6576, 63, 832, 275, 1323, 6576, 63, 6382, 8, 88, 6576, 63, 832, 63, 4695, 12, 485, 647, 4624, 9, 272, 671, 6576, 63, 832, 14, 409, 63, 13138, 8, 13138, 9, 272, 372, 671, 6576, 63, 832, 221, 421, 199, 533, 1323, 6576, 63, 6382, 26, 272, 408, 272, 1323, 6576, 13282, 272, 408, 2286, 333, 18, 63, 88, 6576, 63, 3435, 63, 4624, 275, 333, 18, 14, 88, 6576, 63, 3435, 63, 4624, 2286, 347, 636, 826, 721, 277, 12, 671, 6576, 63, 832, 63, 4695, 29, 403, 12, 485, 647, 4624, 29, 17, 304, 267, 291, 14, 88, 6576, 63, 832, 275, 671, 6576, 63, 832, 63, 4695, 267, 291, 423, 647, 4624, 275, 485, 647, 4624, 339, 347, 636, 2264, 721, 277, 304, 267, 340, 2519, 8, 277, 12, 2513, 647, 4624, 297, 378, 9, 436, 291, 14, 88, 6576, 63, 832, 26, 288, 291, 14, 77, 18, 63, 88, 6576, 63, 3435, 63, 4624, 8, 277, 14, 88, 6576, 63, 832, 9, 339, 347, 485, 4695, 8, 277, 304, 267, 372, 291, 14, 88, 6576, 63, 832, 339, 347, 663, 63, 13138, 8, 277, 12, 19698, 29, 17, 304, 267, 408, 267, 7173, 642, 3329, 19698, 503, 2222, 13138, 14, 4885, 849, 376, 267, 3329, 365, 440, 19698, 14, 398, 768, 466, 19698, 26, 221, 1109, 267, 768, 635, 19698, 26, 10172, 4262, 5951, 642, 3329, 465, 19698, 14, 586, 23892, 642, 1083, 1928, 2368, 911, 586, 663, 642, 3329, 370, 19698, 14, 267, 408, 267, 372, 333, 18, 14, 88, 6576, 63, 3435, 63, 409, 63, 13138, 8, 277, 14, 88, 6576, 63, 832, 12, 19698, 9, 2286, 347, 664, 63, 13138, 8, 277, 304, 267, 408, 267, 1432, 3775, 503, 440, 642, 365, 282, 19698, 3329, 14, 398, 768, 4500, 26, 257, 1109, 267, 768, 1107, 26, 221, 10172, 4262, 340, 642, 365, 282, 19698, 3329, 14, 267, 408, 267, 372, 333, 18, 14, 88, 6576, 63, 3435, 63, 362, 63, 13138, 8, 277, 14, 88, 6576, 63, 832, 9, 2286, 347, 664, 63, 354, 8, 277, 304, 267, 408, 267, 2372, 314, 3329, 536, 12, 367, 2893, 283, 5875, 29171, 1370, 267, 408, 267, 372, 333, 18, 14, 88, 6576, 63, 3435, 63, 362, 63, 354, 8, 277, 14, 88, 6576, 63, 832, 9, 339, 347, 664, 63, 585, 8, 277, 12, 3305, 29, 16, 12, 4363, 29, 16, 304, 267, 408, 267, 2372, 314, 3329, 574, 12, 367, 2893, 283, 12323, 26, 1544, 14, 2694, 14, 957, 1370, 2728, 768, 635, 3305, 26, 257, 18241, 370, 3304, 4052, 436, 4212, 370, 870, 14, 267, 768, 635, 4363, 26, 7494, 5002, 7883, 370, 870, 2544, 3503, 574, 14, 267, 408, 267, 4123, 29, 34, 2090, 14, 8628, 3299, 342, 267, 333, 18, 14, 88, 6576, 63, 832, 63, 1361, 8, 1436, 14, 17614, 63, 4695, 1062, 291, 14, 88, 6576, 63, 832, 12, 3305, 12, 4363, 9, 267, 372, 4123, 14, 739, 63, 452, 342, 258, 421, 199, 533, 1323, 6576, 63, 6382, 63, 4851, 26, 272, 408, 272, 1323, 6576, 13282, 13894, 2286, 768, 3764, 26, 4226, 440, 2811, 314, 8793, 14296, 3464, 272, 871, 4012, 642, 3217, 12, 503, 675, 1263, 14296, 3423, 626, 886, 880, 272, 19458, 590, 14, 4226, 316, 880, 911, 664, 314, 14296, 3464, 436, 314, 5007, 1134, 2340, 272, 402, 642, 1021, 734, 402, 7604, 12, 9186, 370, 2366, 4402, 1026, 14631, 12, 4967, 272, 503, 2755, 2366, 2467, 9030, 1, 272, 408, 339, 333, 18, 63, 1339, 63, 88, 6576, 63, 3435, 63, 4624, 275, 333, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 4624, 339, 347, 636, 826, 721, 277, 12, 3464, 29, 403, 12, 485, 647, 4624, 29, 16, 304, 267, 340, 3464, 365, 440, 488, 26, 288, 291, 14, 2340, 275, 3464, 288, 291, 423, 647, 4624, 275, 485, 647, 4624, 288, 1967, 275, 333, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 1507, 8, 277, 14, 2340, 9, 288, 367, 284, 315, 1425, 8, 1507, 304, 355, 291, 14, 647, 2340, 14, 740, 8, 56, 6576, 63, 6382, 8, 77, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 585, 8, 277, 14, 2340, 12, 284, 395, 8962, 485, 647, 4624, 3699, 647, 4624, 430, 267, 587, 26, 288, 291, 14, 2340, 275, 333, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 1222, 63, 2307, 342, 288, 291, 423, 647 ]
[ 45, 18, 17134, 4975, 367, 14296, 1323, 6576, 3261, 14, 199, 199, 7384, 334, 67, 9, 21300, 13, 15431, 653, 71, 11308, 7420, 428, 73, 951, 14, 2900, 4481, 4644, 14, 199, 199, 48, 18434, 2737, 701, 3232, 5800, 24636, 2752, 334, 3100, 5699, 9, 787, 199, 7384, 334, 35, 9, 8353, 13, 9488, 593, 4251, 38, 14, 2900, 5924, 5702, 14, 199, 5949, 26, 5311, 3258, 8810, 4005, 1003, 265, 287, 199, 624, 199, 199, 3, 603, 18, 17134, 199, 504, 603, 18, 17134, 492, 31139, 17, 12, 699, 2090, 12, 221, 5432, 12, 662, 14159, 12, 4884, 199, 646, 333, 18, 199, 199, 4807, 63, 11733, 275, 378, 199, 4807, 63, 24160, 275, 413, 199, 199, 533, 1323, 6576, 547, 8, 1726, 304, 986, 199, 199, 77, 18, 14, 88, 6576, 63, 826, 8, 56, 6576, 547, 9, 199, 199, 54, 63, 3593, 275, 333, 18, 14, 56, 6576, 63, 54, 63, 3593, 199, 199, 318, 892, 63, 3435, 8, 354, 12, 574, 12, 19698, 29, 16, 12, 485, 647, 4624, 29, 17, 304, 272, 408, 272, 2790, 892, 1323, 6576, 63, 6382, 1256, 14, 272, 408, 272, 340, 536, 508, 283, 5875, 1197, 7544, 7, 436, 971, 267, 574, 14, 1913, 360, 11371, 10678, 18820, 10993, 365, 440, 8061, 267, 746, 1722, 360, 585, 1471, 506, 876, 14378, 2631, 358, 272, 634, 2227, 275, 333, 18, 14, 88, 6576, 86, 19, 63, 76, 2227, 342, 272, 4027, 275, 333, 18, 14, 88, 6576, 86, 19, 63, 409, 63, 2190, 63, 76, 2227, 8, 76, 2227, 9, 272, 671, 6576, 63, 832, 63, 4695, 275, 333, 18, 14, 88, 6576, 86, 19, 63, 832, 63, 2190, 8, 76, 2227, 12, 4027, 12, 536, 12, 574, 9, 272, 671, 6576, 63, 832, 275, 1323, 6576, 63, 6382, 8, 88, 6576, 63, 832, 63, 4695, 12, 485, 647, 4624, 9, 272, 671, 6576, 63, 832, 14, 409, 63, 13138, 8, 13138, 9, 272, 372, 671, 6576, 63, 832, 221, 421, 199, 533, 1323, 6576, 63, 6382, 26, 272, 408, 272, 1323, 6576, 13282, 272, 408, 2286, 333, 18, 63, 88, 6576, 63, 3435, 63, 4624, 275, 333, 18, 14, 88, 6576, 63, 3435, 63, 4624, 2286, 347, 636, 826, 721, 277, 12, 671, 6576, 63, 832, 63, 4695, 29, 403, 12, 485, 647, 4624, 29, 17, 304, 267, 291, 14, 88, 6576, 63, 832, 275, 671, 6576, 63, 832, 63, 4695, 267, 291, 423, 647, 4624, 275, 485, 647, 4624, 339, 347, 636, 2264, 721, 277, 304, 267, 340, 2519, 8, 277, 12, 2513, 647, 4624, 297, 378, 9, 436, 291, 14, 88, 6576, 63, 832, 26, 288, 291, 14, 77, 18, 63, 88, 6576, 63, 3435, 63, 4624, 8, 277, 14, 88, 6576, 63, 832, 9, 339, 347, 485, 4695, 8, 277, 304, 267, 372, 291, 14, 88, 6576, 63, 832, 339, 347, 663, 63, 13138, 8, 277, 12, 19698, 29, 17, 304, 267, 408, 267, 7173, 642, 3329, 19698, 503, 2222, 13138, 14, 4885, 849, 376, 267, 3329, 365, 440, 19698, 14, 398, 768, 466, 19698, 26, 221, 1109, 267, 768, 635, 19698, 26, 10172, 4262, 5951, 642, 3329, 465, 19698, 14, 586, 23892, 642, 1083, 1928, 2368, 911, 586, 663, 642, 3329, 370, 19698, 14, 267, 408, 267, 372, 333, 18, 14, 88, 6576, 63, 3435, 63, 409, 63, 13138, 8, 277, 14, 88, 6576, 63, 832, 12, 19698, 9, 2286, 347, 664, 63, 13138, 8, 277, 304, 267, 408, 267, 1432, 3775, 503, 440, 642, 365, 282, 19698, 3329, 14, 398, 768, 4500, 26, 257, 1109, 267, 768, 1107, 26, 221, 10172, 4262, 340, 642, 365, 282, 19698, 3329, 14, 267, 408, 267, 372, 333, 18, 14, 88, 6576, 63, 3435, 63, 362, 63, 13138, 8, 277, 14, 88, 6576, 63, 832, 9, 2286, 347, 664, 63, 354, 8, 277, 304, 267, 408, 267, 2372, 314, 3329, 536, 12, 367, 2893, 283, 5875, 29171, 1370, 267, 408, 267, 372, 333, 18, 14, 88, 6576, 63, 3435, 63, 362, 63, 354, 8, 277, 14, 88, 6576, 63, 832, 9, 339, 347, 664, 63, 585, 8, 277, 12, 3305, 29, 16, 12, 4363, 29, 16, 304, 267, 408, 267, 2372, 314, 3329, 574, 12, 367, 2893, 283, 12323, 26, 1544, 14, 2694, 14, 957, 1370, 2728, 768, 635, 3305, 26, 257, 18241, 370, 3304, 4052, 436, 4212, 370, 870, 14, 267, 768, 635, 4363, 26, 7494, 5002, 7883, 370, 870, 2544, 3503, 574, 14, 267, 408, 267, 4123, 29, 34, 2090, 14, 8628, 3299, 342, 267, 333, 18, 14, 88, 6576, 63, 832, 63, 1361, 8, 1436, 14, 17614, 63, 4695, 1062, 291, 14, 88, 6576, 63, 832, 12, 3305, 12, 4363, 9, 267, 372, 4123, 14, 739, 63, 452, 342, 258, 421, 199, 533, 1323, 6576, 63, 6382, 63, 4851, 26, 272, 408, 272, 1323, 6576, 13282, 13894, 2286, 768, 3764, 26, 4226, 440, 2811, 314, 8793, 14296, 3464, 272, 871, 4012, 642, 3217, 12, 503, 675, 1263, 14296, 3423, 626, 886, 880, 272, 19458, 590, 14, 4226, 316, 880, 911, 664, 314, 14296, 3464, 436, 314, 5007, 1134, 2340, 272, 402, 642, 1021, 734, 402, 7604, 12, 9186, 370, 2366, 4402, 1026, 14631, 12, 4967, 272, 503, 2755, 2366, 2467, 9030, 1, 272, 408, 339, 333, 18, 63, 1339, 63, 88, 6576, 63, 3435, 63, 4624, 275, 333, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 4624, 339, 347, 636, 826, 721, 277, 12, 3464, 29, 403, 12, 485, 647, 4624, 29, 16, 304, 267, 340, 3464, 365, 440, 488, 26, 288, 291, 14, 2340, 275, 3464, 288, 291, 423, 647, 4624, 275, 485, 647, 4624, 288, 1967, 275, 333, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 1507, 8, 277, 14, 2340, 9, 288, 367, 284, 315, 1425, 8, 1507, 304, 355, 291, 14, 647, 2340, 14, 740, 8, 56, 6576, 63, 6382, 8, 77, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 585, 8, 277, 14, 2340, 12, 284, 395, 8962, 485, 647, 4624, 3699, 647, 4624, 430, 267, 587, 26, 288, 291, 14, 2340, 275, 333, 18, 14, 1339, 63, 88, 6576, 63, 3435, 63, 1222, 63, 2307, 342, 288, 291, 423, 647, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ojengwa/osmc
package/mediacenter-skin-osmc/files/usr/share/kodi/addons/script.module.unidecode/lib/unidecode/x063.py
252
4656
data = ( 'Bo ', # 0x00 'Chi ', # 0x01 'Gua ', # 0x02 'Zhi ', # 0x03 'Kuo ', # 0x04 'Duo ', # 0x05 'Duo ', # 0x06 'Zhi ', # 0x07 'Qie ', # 0x08 'An ', # 0x09 'Nong ', # 0x0a 'Zhen ', # 0x0b 'Ge ', # 0x0c 'Jiao ', # 0x0d 'Ku ', # 0x0e 'Dong ', # 0x0f 'Ru ', # 0x10 'Tiao ', # 0x11 'Lie ', # 0x12 'Zha ', # 0x13 'Lu ', # 0x14 'Die ', # 0x15 'Wa ', # 0x16 'Jue ', # 0x17 'Mushiru ', # 0x18 'Ju ', # 0x19 'Zhi ', # 0x1a 'Luan ', # 0x1b 'Ya ', # 0x1c 'Zhua ', # 0x1d 'Ta ', # 0x1e 'Xie ', # 0x1f 'Nao ', # 0x20 'Dang ', # 0x21 'Jiao ', # 0x22 'Zheng ', # 0x23 'Ji ', # 0x24 'Hui ', # 0x25 'Xun ', # 0x26 'Ku ', # 0x27 'Ai ', # 0x28 'Tuo ', # 0x29 'Nuo ', # 0x2a 'Cuo ', # 0x2b 'Bo ', # 0x2c 'Geng ', # 0x2d 'Ti ', # 0x2e 'Zhen ', # 0x2f 'Cheng ', # 0x30 'Suo ', # 0x31 'Suo ', # 0x32 'Keng ', # 0x33 'Mei ', # 0x34 'Long ', # 0x35 'Ju ', # 0x36 'Peng ', # 0x37 'Jian ', # 0x38 'Yi ', # 0x39 'Ting ', # 0x3a 'Shan ', # 0x3b 'Nuo ', # 0x3c 'Wan ', # 0x3d 'Xie ', # 0x3e 'Cha ', # 0x3f 'Feng ', # 0x40 'Jiao ', # 0x41 'Wu ', # 0x42 'Jun ', # 0x43 'Jiu ', # 0x44 'Tong ', # 0x45 'Kun ', # 0x46 'Huo ', # 0x47 'Tu ', # 0x48 'Zhuo ', # 0x49 'Pou ', # 0x4a 'Le ', # 0x4b 'Ba ', # 0x4c 'Han ', # 0x4d 'Shao ', # 0x4e 'Nie ', # 0x4f 'Juan ', # 0x50 'Ze ', # 0x51 'Song ', # 0x52 'Ye ', # 0x53 'Jue ', # 0x54 'Bu ', # 0x55 'Huan ', # 0x56 'Bu ', # 0x57 'Zun ', # 0x58 'Yi ', # 0x59 'Zhai ', # 0x5a 'Lu ', # 0x5b 'Sou ', # 0x5c 'Tuo ', # 0x5d 'Lao ', # 0x5e 'Sun ', # 0x5f 'Bang ', # 0x60 'Jian ', # 0x61 'Huan ', # 0x62 'Dao ', # 0x63 '[?] ', # 0x64 'Wan ', # 0x65 'Qin ', # 0x66 'Peng ', # 0x67 'She ', # 0x68 'Lie ', # 0x69 'Min ', # 0x6a 'Men ', # 0x6b 'Fu ', # 0x6c 'Bai ', # 0x6d 'Ju ', # 0x6e 'Dao ', # 0x6f 'Wo ', # 0x70 'Ai ', # 0x71 'Juan ', # 0x72 'Yue ', # 0x73 'Zong ', # 0x74 'Chen ', # 0x75 'Chui ', # 0x76 'Jie ', # 0x77 'Tu ', # 0x78 'Ben ', # 0x79 'Na ', # 0x7a 'Nian ', # 0x7b 'Nuo ', # 0x7c 'Zu ', # 0x7d 'Wo ', # 0x7e 'Xi ', # 0x7f 'Xian ', # 0x80 'Cheng ', # 0x81 'Dian ', # 0x82 'Sao ', # 0x83 'Lun ', # 0x84 'Qing ', # 0x85 'Gang ', # 0x86 'Duo ', # 0x87 'Shou ', # 0x88 'Diao ', # 0x89 'Pou ', # 0x8a 'Di ', # 0x8b 'Zhang ', # 0x8c 'Gun ', # 0x8d 'Ji ', # 0x8e 'Tao ', # 0x8f 'Qia ', # 0x90 'Qi ', # 0x91 'Pai ', # 0x92 'Shu ', # 0x93 'Qian ', # 0x94 'Ling ', # 0x95 'Yi ', # 0x96 'Ya ', # 0x97 'Jue ', # 0x98 'Zheng ', # 0x99 'Liang ', # 0x9a 'Gua ', # 0x9b 'Yi ', # 0x9c 'Huo ', # 0x9d 'Shan ', # 0x9e 'Zheng ', # 0x9f 'Lue ', # 0xa0 'Cai ', # 0xa1 'Tan ', # 0xa2 'Che ', # 0xa3 'Bing ', # 0xa4 'Jie ', # 0xa5 'Ti ', # 0xa6 'Kong ', # 0xa7 'Tui ', # 0xa8 'Yan ', # 0xa9 'Cuo ', # 0xaa 'Zou ', # 0xab 'Ju ', # 0xac 'Tian ', # 0xad 'Qian ', # 0xae 'Ken ', # 0xaf 'Bai ', # 0xb0 'Shou ', # 0xb1 'Jie ', # 0xb2 'Lu ', # 0xb3 'Guo ', # 0xb4 'Haba ', # 0xb5 '[?] ', # 0xb6 'Zhi ', # 0xb7 'Dan ', # 0xb8 'Mang ', # 0xb9 'Xian ', # 0xba 'Sao ', # 0xbb 'Guan ', # 0xbc 'Peng ', # 0xbd 'Yuan ', # 0xbe 'Nuo ', # 0xbf 'Jian ', # 0xc0 'Zhen ', # 0xc1 'Jiu ', # 0xc2 'Jian ', # 0xc3 'Yu ', # 0xc4 'Yan ', # 0xc5 'Kui ', # 0xc6 'Nan ', # 0xc7 'Hong ', # 0xc8 'Rou ', # 0xc9 'Pi ', # 0xca 'Wei ', # 0xcb 'Sai ', # 0xcc 'Zou ', # 0xcd 'Xuan ', # 0xce 'Miao ', # 0xcf 'Ti ', # 0xd0 'Nie ', # 0xd1 'Cha ', # 0xd2 'Shi ', # 0xd3 'Zong ', # 0xd4 'Zhen ', # 0xd5 'Yi ', # 0xd6 'Shun ', # 0xd7 'Heng ', # 0xd8 'Bian ', # 0xd9 'Yang ', # 0xda 'Huan ', # 0xdb 'Yan ', # 0xdc 'Zuan ', # 0xdd 'An ', # 0xde 'Xu ', # 0xdf 'Ya ', # 0xe0 'Wo ', # 0xe1 'Ke ', # 0xe2 'Chuai ', # 0xe3 'Ji ', # 0xe4 'Ti ', # 0xe5 'La ', # 0xe6 'La ', # 0xe7 'Cheng ', # 0xe8 'Kai ', # 0xe9 'Jiu ', # 0xea 'Jiu ', # 0xeb 'Tu ', # 0xec 'Jie ', # 0xed 'Hui ', # 0xee 'Geng ', # 0xef 'Chong ', # 0xf0 'Shuo ', # 0xf1 'She ', # 0xf2 'Xie ', # 0xf3 'Yuan ', # 0xf4 'Qian ', # 0xf5 'Ye ', # 0xf6 'Cha ', # 0xf7 'Zha ', # 0xf8 'Bei ', # 0xf9 'Yao ', # 0xfa '[?] ', # 0xfb '[?] ', # 0xfc 'Lan ', # 0xfd 'Wen ', # 0xfe 'Qin ', # 0xff )
gpl-2.0
[ 576, 275, 334, 199, 7, 2208, 1656, 259, 327, 378, 88, 383, 199, 7, 29218, 1656, 259, 327, 378, 88, 614, 199, 7, 39, 1458, 1656, 259, 327, 378, 88, 996, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 1644, 199, 7, 43, 13780, 1656, 259, 327, 378, 88, 966, 199, 7, 36, 13780, 1656, 259, 327, 378, 88, 1717, 199, 7, 36, 13780, 1656, 259, 327, 378, 88, 1690, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 1780, 199, 7, 49, 1873, 1656, 259, 327, 378, 88, 2036, 199, 7, 2493, 1656, 259, 327, 378, 88, 1643, 199, 7, 46, 951, 1656, 259, 327, 378, 88, 16, 65, 199, 7, 12674, 287, 1656, 259, 327, 378, 88, 16, 66, 199, 7, 4240, 1656, 259, 327, 378, 88, 16, 67, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 16, 68, 199, 7, 31487, 1656, 259, 327, 378, 88, 16, 69, 199, 7, 36, 951, 1656, 259, 327, 378, 88, 16, 70, 199, 7, 50, 85, 1656, 259, 327, 378, 88, 709, 199, 7, 52, 18939, 1656, 259, 327, 378, 88, 845, 199, 7, 44, 1873, 1656, 259, 327, 378, 88, 713, 199, 7, 58, 2411, 1656, 259, 327, 378, 88, 969, 199, 7, 18176, 1656, 259, 327, 378, 88, 1079, 199, 7, 1341, 69, 1656, 259, 327, 378, 88, 1046, 199, 7, 24804, 1656, 259, 327, 378, 88, 975, 199, 7, 42, 310, 1656, 259, 327, 378, 88, 1196, 199, 7, 45, 2084, 723, 85, 1656, 259, 327, 378, 88, 1085, 199, 7, 24783, 1656, 259, 327, 378, 88, 1167, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 17, 65, 199, 7, 44, 7856, 1656, 259, 327, 378, 88, 17, 66, 199, 7, 28786, 1656, 259, 327, 378, 88, 17, 67, 199, 7, 12674, 1458, 1656, 259, 327, 378, 88, 17, 68, 199, 7, 22620, 1656, 259, 327, 378, 88, 17, 69, 199, 7, 56, 1873, 1656, 259, 327, 378, 88, 17, 70, 199, 7, 46, 8035, 1656, 259, 327, 378, 88, 1165, 199, 7, 36, 621, 1656, 259, 327, 378, 88, 2025, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 1081, 199, 7, 12674, 7420, 1656, 259, 327, 378, 88, 1789, 199, 7, 16911, 1656, 259, 327, 378, 88, 1194, 199, 7, 40, 1907, 1656, 259, 327, 378, 88, 821, 199, 7, 56, 324, 1656, 259, 327, 378, 88, 1479, 199, 7, 31487, 1656, 259, 327, 378, 88, 1465, 199, 7, 28960, 1656, 259, 327, 378, 88, 1651, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 1398, 199, 7, 46, 13780, 1656, 259, 327, 378, 88, 18, 65, 199, 7, 35, 13780, 1656, 259, 327, 378, 88, 18, 66, 199, 7, 2208, 1656, 259, 327, 378, 88, 18, 67, 199, 7, 39, 7420, 1656, 259, 327, 378, 88, 18, 68, 199, 7, 22731, 1656, 259, 327, 378, 88, 18, 69, 199, 7, 12674, 287, 1656, 259, 327, 378, 88, 18, 70, 199, 7, 1049, 7420, 1656, 259, 327, 378, 88, 1216, 199, 7, 51, 13780, 1656, 259, 327, 378, 88, 2192, 199, 7, 51, 13780, 1656, 259, 327, 378, 88, 708, 199, 7, 43, 7420, 1656, 259, 327, 378, 88, 1153, 199, 7, 1352, 73, 1656, 259, 327, 378, 88, 1082, 199, 7, 9551, 1656, 259, 327, 378, 88, 1276, 199, 7, 24783, 1656, 259, 327, 378, 88, 1344, 199, 7, 48, 7420, 1656, 259, 327, 378, 88, 1401, 199, 7, 42, 5653, 1656, 259, 327, 378, 88, 1703, 199, 7, 21001, 1656, 259, 327, 378, 88, 1355, 199, 7, 52, 316, 1656, 259, 327, 378, 88, 19, 65, 199, 7, 2662, 290, 1656, 259, 327, 378, 88, 19, 66, 199, 7, 46, 13780, 1656, 259, 327, 378, 88, 19, 67, 199, 7, 55, 290, 1656, 259, 327, 378, 88, 19, 68, 199, 7, 56, 1873, 1656, 259, 327, 378, 88, 19, 69, 199, 7, 1049, 65, 1656, 259, 327, 378, 88, 19, 70, 199, 7, 38, 7420, 1656, 259, 327, 378, 88, 2167, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 2953, 199, 7, 25728, 1656, 259, 327, 378, 88, 2260, 199, 7, 42, 324, 1656, 259, 327, 378, 88, 2824, 199, 7, 16911, 85, 1656, 259, 327, 378, 88, 1602, 199, 7, 52, 951, 1656, 259, 327, 378, 88, 2322, 199, 7, 43, 324, 1656, 259, 327, 378, 88, 2466, 199, 7, 40, 13780, 1656, 259, 327, 378, 88, 2417, 199, 7, 30669, 1656, 259, 327, 378, 88, 2006, 199, 7, 31183, 79, 1656, 259, 327, 378, 88, 1887, 199, 7, 48, 810, 1656, 259, 327, 378, 88, 20, 65, 199, 7, 2553, 1656, 259, 327, 378, 88, 20, 66, 199, 7, 13864, 1656, 259, 327, 378, 88, 20, 67, 199, 7, 40, 290, 1656, 259, 327, 378, 88, 20, 68, 199, 7, 23527, 79, 1656, 259, 327, 378, 88, 20, 69, 199, 7, 46, 1873, 1656, 259, 327, 378, 88, 20, 70, 199, 7, 42, 7856, 1656, 259, 327, 378, 88, 1400, 199, 7, 58, 69, 1656, 259, 327, 378, 88, 2869, 199, 7, 51, 951, 1656, 259, 327, 378, 88, 2528, 199, 7, 57, 69, 1656, 259, 327, 378, 88, 2481, 199, 7, 42, 310, 1656, 259, 327, 378, 88, 1477, 199, 7, 1713, 1656, 259, 327, 378, 88, 1229, 199, 7, 40, 7856, 1656, 259, 327, 378, 88, 1367, 199, 7, 1713, 1656, 259, 327, 378, 88, 1641, 199, 7, 58, 324, 1656, 259, 327, 378, 88, 2010, 199, 7, 21001, 1656, 259, 327, 378, 88, 1427, 199, 7, 58, 17945, 1656, 259, 327, 378, 88, 21, 65, 199, 7, 18176, 1656, 259, 327, 378, 88, 21, 66, 199, 7, 51, 810, 1656, 259, 327, 378, 88, 21, 67, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 21, 68, 199, 7, 7833, 79, 1656, 259, 327, 378, 88, 21, 69, 199, 7, 22546, 1656, 259, 327, 378, 88, 21, 70, 199, 7, 34, 621, 1656, 259, 327, 378, 88, 2259, 199, 7, 42, 5653, 1656, 259, 327, 378, 88, 2976, 199, 7, 40, 7856, 1656, 259, 327, 378, 88, 2789, 199, 7, 27361, 1656, 259, 327, 378, 88, 2766, 199, 17892, 1656, 259, 327, 378, 88, 772, 199, 7, 55 ]
[ 275, 334, 199, 7, 2208, 1656, 259, 327, 378, 88, 383, 199, 7, 29218, 1656, 259, 327, 378, 88, 614, 199, 7, 39, 1458, 1656, 259, 327, 378, 88, 996, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 1644, 199, 7, 43, 13780, 1656, 259, 327, 378, 88, 966, 199, 7, 36, 13780, 1656, 259, 327, 378, 88, 1717, 199, 7, 36, 13780, 1656, 259, 327, 378, 88, 1690, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 1780, 199, 7, 49, 1873, 1656, 259, 327, 378, 88, 2036, 199, 7, 2493, 1656, 259, 327, 378, 88, 1643, 199, 7, 46, 951, 1656, 259, 327, 378, 88, 16, 65, 199, 7, 12674, 287, 1656, 259, 327, 378, 88, 16, 66, 199, 7, 4240, 1656, 259, 327, 378, 88, 16, 67, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 16, 68, 199, 7, 31487, 1656, 259, 327, 378, 88, 16, 69, 199, 7, 36, 951, 1656, 259, 327, 378, 88, 16, 70, 199, 7, 50, 85, 1656, 259, 327, 378, 88, 709, 199, 7, 52, 18939, 1656, 259, 327, 378, 88, 845, 199, 7, 44, 1873, 1656, 259, 327, 378, 88, 713, 199, 7, 58, 2411, 1656, 259, 327, 378, 88, 969, 199, 7, 18176, 1656, 259, 327, 378, 88, 1079, 199, 7, 1341, 69, 1656, 259, 327, 378, 88, 1046, 199, 7, 24804, 1656, 259, 327, 378, 88, 975, 199, 7, 42, 310, 1656, 259, 327, 378, 88, 1196, 199, 7, 45, 2084, 723, 85, 1656, 259, 327, 378, 88, 1085, 199, 7, 24783, 1656, 259, 327, 378, 88, 1167, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 17, 65, 199, 7, 44, 7856, 1656, 259, 327, 378, 88, 17, 66, 199, 7, 28786, 1656, 259, 327, 378, 88, 17, 67, 199, 7, 12674, 1458, 1656, 259, 327, 378, 88, 17, 68, 199, 7, 22620, 1656, 259, 327, 378, 88, 17, 69, 199, 7, 56, 1873, 1656, 259, 327, 378, 88, 17, 70, 199, 7, 46, 8035, 1656, 259, 327, 378, 88, 1165, 199, 7, 36, 621, 1656, 259, 327, 378, 88, 2025, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 1081, 199, 7, 12674, 7420, 1656, 259, 327, 378, 88, 1789, 199, 7, 16911, 1656, 259, 327, 378, 88, 1194, 199, 7, 40, 1907, 1656, 259, 327, 378, 88, 821, 199, 7, 56, 324, 1656, 259, 327, 378, 88, 1479, 199, 7, 31487, 1656, 259, 327, 378, 88, 1465, 199, 7, 28960, 1656, 259, 327, 378, 88, 1651, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 1398, 199, 7, 46, 13780, 1656, 259, 327, 378, 88, 18, 65, 199, 7, 35, 13780, 1656, 259, 327, 378, 88, 18, 66, 199, 7, 2208, 1656, 259, 327, 378, 88, 18, 67, 199, 7, 39, 7420, 1656, 259, 327, 378, 88, 18, 68, 199, 7, 22731, 1656, 259, 327, 378, 88, 18, 69, 199, 7, 12674, 287, 1656, 259, 327, 378, 88, 18, 70, 199, 7, 1049, 7420, 1656, 259, 327, 378, 88, 1216, 199, 7, 51, 13780, 1656, 259, 327, 378, 88, 2192, 199, 7, 51, 13780, 1656, 259, 327, 378, 88, 708, 199, 7, 43, 7420, 1656, 259, 327, 378, 88, 1153, 199, 7, 1352, 73, 1656, 259, 327, 378, 88, 1082, 199, 7, 9551, 1656, 259, 327, 378, 88, 1276, 199, 7, 24783, 1656, 259, 327, 378, 88, 1344, 199, 7, 48, 7420, 1656, 259, 327, 378, 88, 1401, 199, 7, 42, 5653, 1656, 259, 327, 378, 88, 1703, 199, 7, 21001, 1656, 259, 327, 378, 88, 1355, 199, 7, 52, 316, 1656, 259, 327, 378, 88, 19, 65, 199, 7, 2662, 290, 1656, 259, 327, 378, 88, 19, 66, 199, 7, 46, 13780, 1656, 259, 327, 378, 88, 19, 67, 199, 7, 55, 290, 1656, 259, 327, 378, 88, 19, 68, 199, 7, 56, 1873, 1656, 259, 327, 378, 88, 19, 69, 199, 7, 1049, 65, 1656, 259, 327, 378, 88, 19, 70, 199, 7, 38, 7420, 1656, 259, 327, 378, 88, 2167, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 2953, 199, 7, 25728, 1656, 259, 327, 378, 88, 2260, 199, 7, 42, 324, 1656, 259, 327, 378, 88, 2824, 199, 7, 16911, 85, 1656, 259, 327, 378, 88, 1602, 199, 7, 52, 951, 1656, 259, 327, 378, 88, 2322, 199, 7, 43, 324, 1656, 259, 327, 378, 88, 2466, 199, 7, 40, 13780, 1656, 259, 327, 378, 88, 2417, 199, 7, 30669, 1656, 259, 327, 378, 88, 2006, 199, 7, 31183, 79, 1656, 259, 327, 378, 88, 1887, 199, 7, 48, 810, 1656, 259, 327, 378, 88, 20, 65, 199, 7, 2553, 1656, 259, 327, 378, 88, 20, 66, 199, 7, 13864, 1656, 259, 327, 378, 88, 20, 67, 199, 7, 40, 290, 1656, 259, 327, 378, 88, 20, 68, 199, 7, 23527, 79, 1656, 259, 327, 378, 88, 20, 69, 199, 7, 46, 1873, 1656, 259, 327, 378, 88, 20, 70, 199, 7, 42, 7856, 1656, 259, 327, 378, 88, 1400, 199, 7, 58, 69, 1656, 259, 327, 378, 88, 2869, 199, 7, 51, 951, 1656, 259, 327, 378, 88, 2528, 199, 7, 57, 69, 1656, 259, 327, 378, 88, 2481, 199, 7, 42, 310, 1656, 259, 327, 378, 88, 1477, 199, 7, 1713, 1656, 259, 327, 378, 88, 1229, 199, 7, 40, 7856, 1656, 259, 327, 378, 88, 1367, 199, 7, 1713, 1656, 259, 327, 378, 88, 1641, 199, 7, 58, 324, 1656, 259, 327, 378, 88, 2010, 199, 7, 21001, 1656, 259, 327, 378, 88, 1427, 199, 7, 58, 17945, 1656, 259, 327, 378, 88, 21, 65, 199, 7, 18176, 1656, 259, 327, 378, 88, 21, 66, 199, 7, 51, 810, 1656, 259, 327, 378, 88, 21, 67, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 21, 68, 199, 7, 7833, 79, 1656, 259, 327, 378, 88, 21, 69, 199, 7, 22546, 1656, 259, 327, 378, 88, 21, 70, 199, 7, 34, 621, 1656, 259, 327, 378, 88, 2259, 199, 7, 42, 5653, 1656, 259, 327, 378, 88, 2976, 199, 7, 40, 7856, 1656, 259, 327, 378, 88, 2789, 199, 7, 27361, 1656, 259, 327, 378, 88, 2766, 199, 17892, 1656, 259, 327, 378, 88, 772, 199, 7, 55, 0 ]
[ 1, 1, 1, 1, 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.video.live.ragi14
pyaes.py
189
16661
"""Simple AES cipher implementation in pure Python following PEP-272 API Homepage: https://bitbucket.org/intgr/pyaes/ The goal of this module is to be as fast as reasonable in Python while still being Pythonic and readable/understandable. It is licensed under the permissive MIT license. Hopefully the code is readable and commented enough that it can serve as an introduction to the AES cipher for Python coders. In fact, it should go along well with the Stick Figure Guide to AES: http://www.moserware.com/2009/09/stick-figure-guide-to-advanced.html Contrary to intuition, this implementation numbers the 4x4 matrices from top to bottom for efficiency reasons:: 0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15 Effectively it's the transposition of what you'd expect. This actually makes the code simpler -- except the ShiftRows step, but hopefully the explanation there clears it up. """ #### # Copyright (c) 2010 Marti Raudsepp <marti@juffo.org> # # 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. #### from array import array # Globals mandated by PEP 272: # http://www.python.org/dev/peps/pep-0272/ MODE_ECB = 1 MODE_CBC = 2 #MODE_CTR = 6 block_size = 16 key_size = None def new(key, mode, IV=None): if mode == MODE_ECB: return ECBMode(AES(key)) elif mode == MODE_CBC: if IV is None: raise ValueError, "CBC mode needs an IV value!" return CBCMode(AES(key), IV) else: raise NotImplementedError #### AES cipher implementation class AES(object): block_size = 16 def __init__(self, key): self.setkey(key) def setkey(self, key): """Sets the key and performs key expansion.""" self.key = key self.key_size = len(key) if self.key_size == 16: self.rounds = 10 elif self.key_size == 24: self.rounds = 12 elif self.key_size == 32: self.rounds = 14 else: raise ValueError, "Key length must be 16, 24 or 32 bytes" self.expand_key() def expand_key(self): """Performs AES key expansion on self.key and stores in self.exkey""" # The key schedule specifies how parts of the key are fed into the # cipher's round functions. "Key expansion" means performing this # schedule in advance. Almost all implementations do this. # # Here's a description of AES key schedule: # http://en.wikipedia.org/wiki/Rijndael_key_schedule # The expanded key starts with the actual key itself exkey = array('B', self.key) # extra key expansion steps if self.key_size == 16: extra_cnt = 0 elif self.key_size == 24: extra_cnt = 2 else: extra_cnt = 3 # 4-byte temporary variable for key expansion word = exkey[-4:] # Each expansion cycle uses 'i' once for Rcon table lookup for i in xrange(1, 11): #### key schedule core: # left-rotate by 1 byte word = word[1:4] + word[0:1] # apply S-box to all bytes for j in xrange(4): word[j] = aes_sbox[word[j]] # apply the Rcon table to the leftmost byte word[0] = word[0] ^ aes_Rcon[i] #### end key schedule core for z in xrange(4): for j in xrange(4): # mix in bytes from the last subkey word[j] ^= exkey[-self.key_size + j] exkey.extend(word) # Last key expansion cycle always finishes here if len(exkey) >= (self.rounds+1) * self.block_size: break # Special substitution step for 256-bit key if self.key_size == 32: for j in xrange(4): # mix in bytes from the last subkey XORed with S-box of # current word bytes word[j] = aes_sbox[word[j]] ^ exkey[-self.key_size + j] exkey.extend(word) # Twice for 192-bit key, thrice for 256-bit key for z in xrange(extra_cnt): for j in xrange(4): # mix in bytes from the last subkey word[j] ^= exkey[-self.key_size + j] exkey.extend(word) self.exkey = exkey def add_round_key(self, block, round): """AddRoundKey step in AES. This is where the key is mixed into plaintext""" offset = round * 16 exkey = self.exkey for i in xrange(16): block[i] ^= exkey[offset + i] #print 'AddRoundKey:', block def sub_bytes(self, block, sbox): """SubBytes step, apply S-box to all bytes Depending on whether encrypting or decrypting, a different sbox array is passed in. """ for i in xrange(16): block[i] = sbox[block[i]] #print 'SubBytes :', block def shift_rows(self, b): """ShiftRows step. Shifts 2nd row to left by 1, 3rd row by 2, 4th row by 3 Since we're performing this on a transposed matrix, cells are numbered from top to bottom:: 0 4 8 12 -> 0 4 8 12 -- 1st row doesn't change 1 5 9 13 -> 5 9 13 1 -- row shifted to left by 1 (wraps around) 2 6 10 14 -> 10 14 2 6 -- shifted by 2 3 7 11 15 -> 15 3 7 11 -- shifted by 3 """ b[1], b[5], b[ 9], b[13] = b[ 5], b[ 9], b[13], b[ 1] b[2], b[6], b[10], b[14] = b[10], b[14], b[ 2], b[ 6] b[3], b[7], b[11], b[15] = b[15], b[ 3], b[ 7], b[11] #print 'ShiftRows :', b def shift_rows_inv(self, b): """Similar to shift_rows above, but performed in inverse for decryption.""" b[ 5], b[ 9], b[13], b[ 1] = b[1], b[5], b[ 9], b[13] b[10], b[14], b[ 2], b[ 6] = b[2], b[6], b[10], b[14] b[15], b[ 3], b[ 7], b[11] = b[3], b[7], b[11], b[15] #print 'ShiftRows :', b def mix_columns(self, block): """MixColumns step. Mixes the values in each column""" # Cache global multiplication tables (see below) mul_by_2 = gf_mul_by_2 mul_by_3 = gf_mul_by_3 # Since we're dealing with a transposed matrix, columns are already # sequential for i in xrange(4): col = i * 4 #v0, v1, v2, v3 = block[col : col+4] v0, v1, v2, v3 = (block[col], block[col + 1], block[col + 2], block[col + 3]) block[col ] = mul_by_2[v0] ^ v3 ^ v2 ^ mul_by_3[v1] block[col+1] = mul_by_2[v1] ^ v0 ^ v3 ^ mul_by_3[v2] block[col+2] = mul_by_2[v2] ^ v1 ^ v0 ^ mul_by_3[v3] block[col+3] = mul_by_2[v3] ^ v2 ^ v1 ^ mul_by_3[v0] #print 'MixColumns :', block def mix_columns_inv(self, block): """Similar to mix_columns above, but performed in inverse for decryption.""" # Cache global multiplication tables (see below) mul_9 = gf_mul_by_9 mul_11 = gf_mul_by_11 mul_13 = gf_mul_by_13 mul_14 = gf_mul_by_14 # Since we're dealing with a transposed matrix, columns are already # sequential for i in xrange(4): col = i * 4 v0, v1, v2, v3 = (block[col], block[col + 1], block[col + 2], block[col + 3]) #v0, v1, v2, v3 = block[col:col+4] block[col ] = mul_14[v0] ^ mul_9[v3] ^ mul_13[v2] ^ mul_11[v1] block[col+1] = mul_14[v1] ^ mul_9[v0] ^ mul_13[v3] ^ mul_11[v2] block[col+2] = mul_14[v2] ^ mul_9[v1] ^ mul_13[v0] ^ mul_11[v3] block[col+3] = mul_14[v3] ^ mul_9[v2] ^ mul_13[v1] ^ mul_11[v0] #print 'MixColumns :', block def encrypt_block(self, block): """Encrypts a single block. This is the main AES function""" # For efficiency reasons, the state between steps is transmitted via a # mutable array, not returned. self.add_round_key(block, 0) for round in xrange(1, self.rounds): self.sub_bytes(block, aes_sbox) self.shift_rows(block) self.mix_columns(block) self.add_round_key(block, round) self.sub_bytes(block, aes_sbox) self.shift_rows(block) # no mix_columns step in the last round self.add_round_key(block, self.rounds) def decrypt_block(self, block): """Decrypts a single block. This is the main AES decryption function""" # For efficiency reasons, the state between steps is transmitted via a # mutable array, not returned. self.add_round_key(block, self.rounds) # count rounds down from 15 ... 1 for round in xrange(self.rounds-1, 0, -1): self.shift_rows_inv(block) self.sub_bytes(block, aes_inv_sbox) self.add_round_key(block, round) self.mix_columns_inv(block) self.shift_rows_inv(block) self.sub_bytes(block, aes_inv_sbox) self.add_round_key(block, 0) # no mix_columns step in the last round #### ECB mode implementation class ECBMode(object): """Electronic CodeBook (ECB) mode encryption. Basically this mode applies the cipher function to each block individually; no feedback is done. NB! This is insecure for almost all purposes """ def __init__(self, cipher): self.cipher = cipher self.block_size = cipher.block_size def ecb(self, data, block_func): """Perform ECB mode with the given function""" if len(data) % self.block_size != 0: raise ValueError, "Plaintext length must be multiple of 16" block_size = self.block_size data = array('B', data) for offset in xrange(0, len(data), block_size): block = data[offset : offset+block_size] block_func(block) data[offset : offset+block_size] = block return data.tostring() def encrypt(self, data): """Encrypt data in ECB mode""" return self.ecb(data, self.cipher.encrypt_block) def decrypt(self, data): """Decrypt data in ECB mode""" return self.ecb(data, self.cipher.decrypt_block) #### CBC mode class CBCMode(object): """Cipher Block Chaining (CBC) mode encryption. This mode avoids content leaks. In CBC encryption, each plaintext block is XORed with the ciphertext block preceding it; decryption is simply the inverse. """ # A better explanation of CBC can be found here: # http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29 def __init__(self, cipher, IV): self.cipher = cipher self.block_size = cipher.block_size self.IV = array('B', IV) def encrypt(self, data): """Encrypt data in CBC mode""" block_size = self.block_size if len(data) % block_size != 0: raise ValueError, "Plaintext length must be multiple of 16" data = array('B', data) IV = self.IV for offset in xrange(0, len(data), block_size): block = data[offset : offset+block_size] # Perform CBC chaining for i in xrange(block_size): block[i] ^= IV[i] self.cipher.encrypt_block(block) data[offset : offset+block_size] = block IV = block self.IV = IV return data.tostring() def decrypt(self, data): """Decrypt data in CBC mode""" block_size = self.block_size if len(data) % block_size != 0: raise ValueError, "Ciphertext length must be multiple of 16" data = array('B', data) IV = self.IV for offset in xrange(0, len(data), block_size): ctext = data[offset : offset+block_size] block = ctext[:] self.cipher.decrypt_block(block) # Perform CBC chaining #for i in xrange(block_size): # data[offset + i] ^= IV[i] for i in xrange(block_size): block[i] ^= IV[i] data[offset : offset+block_size] = block IV = ctext #data[offset : offset+block_size] = block self.IV = IV return data.tostring() #### def galois_multiply(a, b): """Galois Field multiplicaiton for AES""" p = 0 while b: if b & 1: p ^= a a <<= 1 if a & 0x100: a ^= 0x1b b >>= 1 return p & 0xff # Precompute the multiplication tables for encryption gf_mul_by_2 = array('B', [galois_multiply(x, 2) for x in range(256)]) gf_mul_by_3 = array('B', [galois_multiply(x, 3) for x in range(256)]) # ... for decryption gf_mul_by_9 = array('B', [galois_multiply(x, 9) for x in range(256)]) gf_mul_by_11 = array('B', [galois_multiply(x, 11) for x in range(256)]) gf_mul_by_13 = array('B', [galois_multiply(x, 13) for x in range(256)]) gf_mul_by_14 = array('B', [galois_multiply(x, 14) for x in range(256)]) #### # The S-box is a 256-element array, that maps a single byte value to another # byte value. Since it's designed to be reversible, each value occurs only once # in the S-box # # More information: http://en.wikipedia.org/wiki/Rijndael_S-box aes_sbox = array('B', '637c777bf26b6fc53001672bfed7ab76' 'ca82c97dfa5947f0add4a2af9ca472c0' 'b7fd9326363ff7cc34a5e5f171d83115' '04c723c31896059a071280e2eb27b275' '09832c1a1b6e5aa0523bd6b329e32f84' '53d100ed20fcb15b6acbbe394a4c58cf' 'd0efaafb434d338545f9027f503c9fa8' '51a3408f929d38f5bcb6da2110fff3d2' 'cd0c13ec5f974417c4a77e3d645d1973' '60814fdc222a908846eeb814de5e0bdb' 'e0323a0a4906245cc2d3ac629195e479' 'e7c8376d8dd54ea96c56f4ea657aae08' 'ba78252e1ca6b4c6e8dd741f4bbd8b8a' '703eb5664803f60e613557b986c11d9e' 'e1f8981169d98e949b1e87e9ce5528df' '8ca1890dbfe6426841992d0fb054bb16'.decode('hex') ) # This is the inverse of the above. In other words: # aes_inv_sbox[aes_sbox[val]] == val aes_inv_sbox = array('B', '52096ad53036a538bf40a39e81f3d7fb' '7ce339829b2fff87348e4344c4dee9cb' '547b9432a6c2233dee4c950b42fac34e' '082ea16628d924b2765ba2496d8bd125' '72f8f66486689816d4a45ccc5d65b692' '6c704850fdedb9da5e154657a78d9d84' '90d8ab008cbcd30af7e45805b8b34506' 'd02c1e8fca3f0f02c1afbd0301138a6b' '3a9111414f67dcea97f2cfcef0b4e673' '96ac7422e7ad3585e2f937e81c75df6e' '47f11a711d29c5896fb7620eaa18be1b' 'fc563e4bc6d279209adbc0fe78cd5af4' '1fdda8338807c731b11210592780ec5f' '60517fa919b54a0d2de57a9f93c99cef' 'a0e03b4dae2af5b0c8ebbb3c83539961' '172b047eba77d626e169146355210c7d'.decode('hex') ) # The Rcon table is used in AES's key schedule (key expansion) # It's a pre-computed table of exponentation of 2 in AES's finite field # # More information: http://en.wikipedia.org/wiki/Rijndael_key_schedule aes_Rcon = array('B', '8d01020408102040801b366cd8ab4d9a' '2f5ebc63c697356ad4b37dfaefc59139' '72e4d3bd61c29f254a943366cc831d3a' '74e8cb8d01020408102040801b366cd8' 'ab4d9a2f5ebc63c697356ad4b37dfaef' 'c5913972e4d3bd61c29f254a943366cc' '831d3a74e8cb8d01020408102040801b' '366cd8ab4d9a2f5ebc63c697356ad4b3' '7dfaefc5913972e4d3bd61c29f254a94' '3366cc831d3a74e8cb8d010204081020' '40801b366cd8ab4d9a2f5ebc63c69735' '6ad4b37dfaefc5913972e4d3bd61c29f' '254a943366cc831d3a74e8cb8d010204' '08102040801b366cd8ab4d9a2f5ebc63' 'c697356ad4b37dfaefc5913972e4d3bd' '61c29f254a943366cc831d3a74e8cb'.decode('hex') )
gpl-2.0
[ 624, 3184, 19093, 10830, 4514, 315, 15111, 2018, 2569, 13663, 13, 12900, 3261, 199, 199, 12054, 1606, 26, 4178, 921, 25668, 14, 1308, 15, 442, 2587, 15, 647, 17499, 15, 199, 199, 1918, 14850, 402, 642, 859, 365, 370, 506, 465, 7377, 465, 23255, 315, 2018, 1830, 5139, 199, 1235, 316, 2018, 530, 436, 12701, 15, 7138, 7935, 461, 14, 2779, 365, 18233, 1334, 314, 1126, 32237, 199, 13965, 4190, 14, 199, 199, 40, 13458, 5836, 314, 1233, 365, 12701, 436, 21804, 8321, 626, 652, 883, 14062, 465, 376, 199, 18206, 5199, 370, 314, 19093, 10830, 367, 2018, 1233, 2393, 14, 1010, 10572, 12, 652, 1077, 2621, 3180, 199, 20501, 543, 314, 428, 8284, 16266, 15423, 370, 19093, 26, 199, 1014, 921, 1544, 14, 573, 332, 1068, 14, 957, 15, 8664, 15, 1643, 15, 18043, 13, 8941, 13, 17348, 13, 475, 13, 14652, 14, 1360, 199, 199, 714, 454, 695, 370, 1109, 1907, 296, 12, 642, 4514, 5579, 314, 841, 88, 20, 12627, 687, 2746, 370, 199, 8305, 367, 25978, 14872, 447, 819, 378, 221, 841, 221, 1695, 3144, 523, 413, 221, 959, 221, 1749, 4944, 523, 499, 221, 1227, 1616, 4329, 523, 650, 221, 1520, 4119, 4114, 199, 199, 21469, 25222, 652, 1159, 314, 1752, 3124, 402, 4052, 1265, 5121, 4282, 14, 961, 5965, 7704, 199, 1589, 1233, 28293, 1553, 871, 314, 29800, 13405, 3650, 12, 1325, 3661, 5836, 314, 17531, 199, 16990, 5436, 83, 652, 1536, 14, 199, 199, 624, 199, 199, 381, 199, 3, 1898, 334, 67, 9, 7129, 16794, 280, 3898, 1181, 261, 802, 665, 4584, 280, 32, 74, 1286, 545, 14, 1308, 30, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 381, 421, 199, 504, 1625, 492, 1625, 199, 199, 3, 13641, 83, 333, 460, 972, 701, 13663, 499, 2819, 26, 199, 3, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 996, 2819, 15, 199, 6963, 63, 4220, 34, 275, 413, 199, 6963, 63, 18255, 275, 499, 199, 3, 6963, 63, 1028, 50, 275, 1227, 199, 199, 1457, 63, 890, 275, 3193, 199, 498, 63, 890, 275, 488, 199, 199, 318, 892, 8, 498, 12, 818, 12, 27892, 29, 403, 304, 272, 340, 818, 508, 27065, 63, 4220, 34, 26, 267, 372, 662, 9956, 1385, 8, 14494, 8, 498, 430, 272, 916, 818, 508, 27065, 63, 18255, 26, 267, 340, 27892, 365, 488, 26, 288, 746, 1722, 12, 298, 18255, 818, 4839, 376, 27892, 574, 9539, 398, 372, 445, 6265, 1385, 8, 14494, 8, 498, 395, 27892, 9, 272, 587, 26, 267, 746, 4279, 199, 199, 381, 19093, 10830, 4514, 199, 199, 533, 19093, 8, 785, 304, 272, 1853, 63, 890, 275, 3193, 339, 347, 636, 826, 721, 277, 12, 790, 304, 267, 291, 14, 409, 498, 8, 498, 9, 339, 347, 663, 498, 8, 277, 12, 790, 304, 267, 408, 9899, 314, 790, 436, 18628, 790, 14819, 1041, 398, 291, 14, 498, 275, 790, 267, 291, 14, 498, 63, 890, 275, 822, 8, 498, 9, 398, 340, 291, 14, 498, 63, 890, 508, 3193, 26, 288, 291, 14, 23171, 275, 1616, 267, 916, 291, 14, 498, 63, 890, 508, 5504, 26, 288, 291, 14, 23171, 275, 3144, 267, 916, 291, 14, 498, 63, 890, 508, 4337, 26, 288, 291, 14, 23171, 275, 4329, 267, 587, 26, 288, 746, 1722, 12, 298, 1197, 2582, 1471, 506, 3193, 12, 5504, 503, 4337, 2783, 2, 398, 291, 14, 4441, 63, 498, 342, 339, 347, 6544, 63, 498, 8, 277, 304, 267, 408, 2623, 3351, 19093, 790, 14819, 641, 291, 14, 498, 436, 14086, 315, 291, 14, 476, 498, 624, 398, 327, 710, 790, 8732, 9314, 4212, 4184, 402, 314, 790, 787, 23036, 1901, 314, 267, 327, 10830, 1159, 6168, 3423, 14, 298, 1197, 14819, 2, 4910, 19203, 642, 267, 327, 8732, 315, 18695, 14, 4580, 2786, 1006, 12591, 886, 642, 14, 267, 327, 267, 327, 11842, 1159, 282, 1369, 402, 19093, 790, 8732, 26, 267, 327, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 50, 7879, 977, 10643, 63, 498, 63, 7211, 398, 327, 710, 11507, 790, 9174, 543, 314, 3503, 790, 6337, 267, 444, 498, 275, 1625, 360, 34, 297, 291, 14, 498, 9, 398, 327, 2402, 790, 14819, 7124, 267, 340, 291, 14, 498, 63, 890, 508, 3193, 26, 288, 2402, 63, 6507, 275, 378, 267, 916, 291, 14, 498, 63, 890, 508, 5504, 26, 288, 2402, 63, 6507, 275, 499, 267, 587, 26, 288, 2402, 63, 6507, 275, 650, 398, 327, 841, 13, 4414, 7937, 1750, 367, 790, 14819, 267, 4349, 275, 444, 498, 1988, 20, 2938, 267, 327, 7048, 14819, 8643, 4440, 283, 73, 7, 5403, 367, 820, 388, 1817, 4237, 267, 367, 284, 315, 4945, 8, 17, 12, 4119, 304, 953, 14055, 790, 8732, 6170, 26, 288, 327, 3602, 13, 12873, 701, 413, 3696, 288 ]
[ 3184, 19093, 10830, 4514, 315, 15111, 2018, 2569, 13663, 13, 12900, 3261, 199, 199, 12054, 1606, 26, 4178, 921, 25668, 14, 1308, 15, 442, 2587, 15, 647, 17499, 15, 199, 199, 1918, 14850, 402, 642, 859, 365, 370, 506, 465, 7377, 465, 23255, 315, 2018, 1830, 5139, 199, 1235, 316, 2018, 530, 436, 12701, 15, 7138, 7935, 461, 14, 2779, 365, 18233, 1334, 314, 1126, 32237, 199, 13965, 4190, 14, 199, 199, 40, 13458, 5836, 314, 1233, 365, 12701, 436, 21804, 8321, 626, 652, 883, 14062, 465, 376, 199, 18206, 5199, 370, 314, 19093, 10830, 367, 2018, 1233, 2393, 14, 1010, 10572, 12, 652, 1077, 2621, 3180, 199, 20501, 543, 314, 428, 8284, 16266, 15423, 370, 19093, 26, 199, 1014, 921, 1544, 14, 573, 332, 1068, 14, 957, 15, 8664, 15, 1643, 15, 18043, 13, 8941, 13, 17348, 13, 475, 13, 14652, 14, 1360, 199, 199, 714, 454, 695, 370, 1109, 1907, 296, 12, 642, 4514, 5579, 314, 841, 88, 20, 12627, 687, 2746, 370, 199, 8305, 367, 25978, 14872, 447, 819, 378, 221, 841, 221, 1695, 3144, 523, 413, 221, 959, 221, 1749, 4944, 523, 499, 221, 1227, 1616, 4329, 523, 650, 221, 1520, 4119, 4114, 199, 199, 21469, 25222, 652, 1159, 314, 1752, 3124, 402, 4052, 1265, 5121, 4282, 14, 961, 5965, 7704, 199, 1589, 1233, 28293, 1553, 871, 314, 29800, 13405, 3650, 12, 1325, 3661, 5836, 314, 17531, 199, 16990, 5436, 83, 652, 1536, 14, 199, 199, 624, 199, 199, 381, 199, 3, 1898, 334, 67, 9, 7129, 16794, 280, 3898, 1181, 261, 802, 665, 4584, 280, 32, 74, 1286, 545, 14, 1308, 30, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 381, 421, 199, 504, 1625, 492, 1625, 199, 199, 3, 13641, 83, 333, 460, 972, 701, 13663, 499, 2819, 26, 199, 3, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 996, 2819, 15, 199, 6963, 63, 4220, 34, 275, 413, 199, 6963, 63, 18255, 275, 499, 199, 3, 6963, 63, 1028, 50, 275, 1227, 199, 199, 1457, 63, 890, 275, 3193, 199, 498, 63, 890, 275, 488, 199, 199, 318, 892, 8, 498, 12, 818, 12, 27892, 29, 403, 304, 272, 340, 818, 508, 27065, 63, 4220, 34, 26, 267, 372, 662, 9956, 1385, 8, 14494, 8, 498, 430, 272, 916, 818, 508, 27065, 63, 18255, 26, 267, 340, 27892, 365, 488, 26, 288, 746, 1722, 12, 298, 18255, 818, 4839, 376, 27892, 574, 9539, 398, 372, 445, 6265, 1385, 8, 14494, 8, 498, 395, 27892, 9, 272, 587, 26, 267, 746, 4279, 199, 199, 381, 19093, 10830, 4514, 199, 199, 533, 19093, 8, 785, 304, 272, 1853, 63, 890, 275, 3193, 339, 347, 636, 826, 721, 277, 12, 790, 304, 267, 291, 14, 409, 498, 8, 498, 9, 339, 347, 663, 498, 8, 277, 12, 790, 304, 267, 408, 9899, 314, 790, 436, 18628, 790, 14819, 1041, 398, 291, 14, 498, 275, 790, 267, 291, 14, 498, 63, 890, 275, 822, 8, 498, 9, 398, 340, 291, 14, 498, 63, 890, 508, 3193, 26, 288, 291, 14, 23171, 275, 1616, 267, 916, 291, 14, 498, 63, 890, 508, 5504, 26, 288, 291, 14, 23171, 275, 3144, 267, 916, 291, 14, 498, 63, 890, 508, 4337, 26, 288, 291, 14, 23171, 275, 4329, 267, 587, 26, 288, 746, 1722, 12, 298, 1197, 2582, 1471, 506, 3193, 12, 5504, 503, 4337, 2783, 2, 398, 291, 14, 4441, 63, 498, 342, 339, 347, 6544, 63, 498, 8, 277, 304, 267, 408, 2623, 3351, 19093, 790, 14819, 641, 291, 14, 498, 436, 14086, 315, 291, 14, 476, 498, 624, 398, 327, 710, 790, 8732, 9314, 4212, 4184, 402, 314, 790, 787, 23036, 1901, 314, 267, 327, 10830, 1159, 6168, 3423, 14, 298, 1197, 14819, 2, 4910, 19203, 642, 267, 327, 8732, 315, 18695, 14, 4580, 2786, 1006, 12591, 886, 642, 14, 267, 327, 267, 327, 11842, 1159, 282, 1369, 402, 19093, 790, 8732, 26, 267, 327, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 50, 7879, 977, 10643, 63, 498, 63, 7211, 398, 327, 710, 11507, 790, 9174, 543, 314, 3503, 790, 6337, 267, 444, 498, 275, 1625, 360, 34, 297, 291, 14, 498, 9, 398, 327, 2402, 790, 14819, 7124, 267, 340, 291, 14, 498, 63, 890, 508, 3193, 26, 288, 2402, 63, 6507, 275, 378, 267, 916, 291, 14, 498, 63, 890, 508, 5504, 26, 288, 2402, 63, 6507, 275, 499, 267, 587, 26, 288, 2402, 63, 6507, 275, 650, 398, 327, 841, 13, 4414, 7937, 1750, 367, 790, 14819, 267, 4349, 275, 444, 498, 1988, 20, 2938, 267, 327, 7048, 14819, 8643, 4440, 283, 73, 7, 5403, 367, 820, 388, 1817, 4237, 267, 367, 284, 315, 4945, 8, 17, 12, 4119, 304, 953, 14055, 790, 8732, 6170, 26, 288, 327, 3602, 13, 12873, 701, 413, 3696, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
JianyuWang/neutron
neutron/openstack/common/cache/cache.py
28
2932
# Copyright 2013 Red Hat, 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. """Cache library. Supported configuration options: `default_backend`: Name of the cache backend to use. `key_namespace`: Namespace under which keys will be created. """ ######################################################################## # # THIS MODULE IS DEPRECATED # # Please refer to # https://etherpad.openstack.org/p/kilo-neutron-library-proposals for # the discussion leading to this deprecation. # # We recommend helping with the new neutron.cache library being created # as a wrapper for dogpile. # ######################################################################## from six.moves.urllib import parse from stevedore import driver def _get_oslo_configs(): """Returns the oslo config options to register.""" # NOTE(flaper87): Oslo config should be # optional. Instead of doing try / except # at the top of this file, lets import cfg # here and assume that the caller of this # function already took care of this dependency. from oslo_config import cfg return [ cfg.StrOpt('cache_url', default='memory://', help='URL to connect to the cache back end.') ] def register_oslo_configs(conf): """Registers a cache configuration options :params conf: Config object. :type conf: `cfg.ConfigOptions` """ conf.register_opts(_get_oslo_configs()) def get_cache(url='memory://'): """Loads the cache backend This function loads the cache backend specified in the given configuration. :param conf: Configuration instance to use """ parsed = parse.urlparse(url) backend = parsed.scheme query = parsed.query # NOTE(flaper87): We need the following hack # for python versions < 2.7.5. Previous versions # of python parsed query params just for 'known' # schemes. This was changed in this patch: # http://hg.python.org/cpython/rev/79e6ff3d9afd if not query and '?' in parsed.path: query = parsed.path.split('?', 1)[-1] parameters = parse.parse_qsl(query) kwargs = {'options': dict(parameters)} mgr = driver.DriverManager('neutron.openstack.common.cache.backends', backend, invoke_on_load=True, invoke_args=[parsed], invoke_kwds=kwargs) return mgr.driver
apache-2.0
[ 3, 1898, 6171, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 4437, 3555, 14, 199, 199, 10682, 2897, 1511, 26, 199, 199, 64, 885, 63, 4620, 8340, 2812, 402, 314, 2581, 4865, 370, 675, 14, 199, 64, 498, 63, 3251, 8340, 19317, 1334, 1314, 2883, 911, 506, 2737, 14, 199, 624, 199, 199, 3949, 199, 3, 199, 3, 5749, 30223, 2281, 31404, 199, 3, 199, 3, 7754, 10618, 370, 199, 3, 4178, 921, 27732, 6226, 14, 8512, 14, 1308, 15, 80, 15, 8810, 320, 13, 10271, 13, 4342, 13, 496, 1712, 2551, 367, 199, 3, 314, 16582, 9186, 370, 642, 17831, 14, 199, 3, 199, 3, 2136, 27747, 1720, 316, 543, 314, 892, 8224, 14, 1637, 3555, 3769, 2737, 199, 3, 465, 282, 4975, 367, 886, 4927, 441, 14, 199, 3, 199, 3949, 421, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 199, 504, 20345, 1354, 720, 492, 5253, 421, 199, 318, 485, 362, 63, 736, 320, 63, 7532, 837, 272, 408, 3407, 314, 11258, 1101, 1511, 370, 2274, 1041, 272, 327, 6944, 8, 14163, 529, 1555, 304, 593, 83, 320, 1101, 1077, 506, 272, 327, 2716, 14, 15345, 402, 9689, 862, 1182, 871, 272, 327, 737, 314, 2746, 402, 642, 570, 12, 19083, 492, 4810, 272, 327, 2348, 436, 5534, 626, 314, 8025, 402, 642, 272, 327, 805, 2575, 27221, 10296, 402, 642, 5936, 14, 272, 687, 11258, 63, 888, 492, 4810, 339, 372, 359, 267, 4810, 14, 19340, 360, 1637, 63, 633, 297, 849, 534, 4844, 921, 297, 673, 1720, 534, 2632, 370, 4907, 370, 314, 2581, 1771, 1284, 2659, 272, 1622, 421, 199, 318, 2274, 63, 736, 320, 63, 7532, 8, 2190, 304, 272, 408, 31136, 282, 2581, 2897, 1511, 339, 520, 1162, 3743, 26, 4094, 909, 14, 272, 520, 466, 3743, 26, 658, 4128, 14, 2028, 4558, 64, 272, 408, 272, 3743, 14, 2683, 63, 3291, 1547, 362, 63, 736, 320, 63, 7532, 1012, 421, 199, 318, 664, 63, 1637, 8, 633, 534, 4844, 921, 735, 272, 408, 30777, 314, 2581, 4865, 339, 961, 805, 14404, 314, 2581, 4865, 272, 2013, 315, 314, 1627, 2897, 14, 339, 520, 635, 3743, 26, 11595, 1256, 370, 675, 272, 408, 339, 4565, 275, 2198, 14, 10290, 8, 633, 9, 272, 4865, 275, 4565, 14, 5512, 339, 1827, 275, 4565, 14, 1131, 272, 327, 6944, 8, 14163, 529, 1555, 304, 2136, 1929, 314, 2569, 11176, 272, 327, 367, 2366, 5459, 665, 499, 14, 23, 14, 21, 14, 26902, 5459, 272, 327, 402, 2366, 4565, 1827, 1862, 2951, 367, 283, 3159, 7, 272, 327, 21149, 14, 961, 1990, 2896, 315, 642, 3371, 26, 272, 327, 1455, 921, 9208, 14, 1548, 14, 1308, 15, 67, 1548, 15, 4964, 15, 1965, 69, 22, 556, 19, 68, 25, 65, 2592, 272, 340, 440, 1827, 436, 15539, 315, 4565, 14, 515, 26, 267, 1827, 275, 4565, 14, 515, 14, 1294, 360, 7044, 413, 15786, 17, 61, 272, 2633, 275, 2198, 14, 1122, 63, 26714, 8, 1131, 9, 272, 2074, 275, 791, 1419, 356, 1211, 8, 3214, 6769, 339, 18137, 275, 5253, 14, 6158, 2988, 360, 10271, 14, 8512, 14, 2330, 14, 1637, 14, 7765, 297, 4865, 12, 3044, 12677, 63, 265, 63, 912, 29, 549, 12, 3044, 12677, 63, 589, 1524, 6751, 467, 3044, 12677, 63, 10340, 29, 958, 9, 272, 372, 18137, 14, 3090, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6171, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 4437, 3555, 14, 199, 199, 10682, 2897, 1511, 26, 199, 199, 64, 885, 63, 4620, 8340, 2812, 402, 314, 2581, 4865, 370, 675, 14, 199, 64, 498, 63, 3251, 8340, 19317, 1334, 1314, 2883, 911, 506, 2737, 14, 199, 624, 199, 199, 3949, 199, 3, 199, 3, 5749, 30223, 2281, 31404, 199, 3, 199, 3, 7754, 10618, 370, 199, 3, 4178, 921, 27732, 6226, 14, 8512, 14, 1308, 15, 80, 15, 8810, 320, 13, 10271, 13, 4342, 13, 496, 1712, 2551, 367, 199, 3, 314, 16582, 9186, 370, 642, 17831, 14, 199, 3, 199, 3, 2136, 27747, 1720, 316, 543, 314, 892, 8224, 14, 1637, 3555, 3769, 2737, 199, 3, 465, 282, 4975, 367, 886, 4927, 441, 14, 199, 3, 199, 3949, 421, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 199, 504, 20345, 1354, 720, 492, 5253, 421, 199, 318, 485, 362, 63, 736, 320, 63, 7532, 837, 272, 408, 3407, 314, 11258, 1101, 1511, 370, 2274, 1041, 272, 327, 6944, 8, 14163, 529, 1555, 304, 593, 83, 320, 1101, 1077, 506, 272, 327, 2716, 14, 15345, 402, 9689, 862, 1182, 871, 272, 327, 737, 314, 2746, 402, 642, 570, 12, 19083, 492, 4810, 272, 327, 2348, 436, 5534, 626, 314, 8025, 402, 642, 272, 327, 805, 2575, 27221, 10296, 402, 642, 5936, 14, 272, 687, 11258, 63, 888, 492, 4810, 339, 372, 359, 267, 4810, 14, 19340, 360, 1637, 63, 633, 297, 849, 534, 4844, 921, 297, 673, 1720, 534, 2632, 370, 4907, 370, 314, 2581, 1771, 1284, 2659, 272, 1622, 421, 199, 318, 2274, 63, 736, 320, 63, 7532, 8, 2190, 304, 272, 408, 31136, 282, 2581, 2897, 1511, 339, 520, 1162, 3743, 26, 4094, 909, 14, 272, 520, 466, 3743, 26, 658, 4128, 14, 2028, 4558, 64, 272, 408, 272, 3743, 14, 2683, 63, 3291, 1547, 362, 63, 736, 320, 63, 7532, 1012, 421, 199, 318, 664, 63, 1637, 8, 633, 534, 4844, 921, 735, 272, 408, 30777, 314, 2581, 4865, 339, 961, 805, 14404, 314, 2581, 4865, 272, 2013, 315, 314, 1627, 2897, 14, 339, 520, 635, 3743, 26, 11595, 1256, 370, 675, 272, 408, 339, 4565, 275, 2198, 14, 10290, 8, 633, 9, 272, 4865, 275, 4565, 14, 5512, 339, 1827, 275, 4565, 14, 1131, 272, 327, 6944, 8, 14163, 529, 1555, 304, 2136, 1929, 314, 2569, 11176, 272, 327, 367, 2366, 5459, 665, 499, 14, 23, 14, 21, 14, 26902, 5459, 272, 327, 402, 2366, 4565, 1827, 1862, 2951, 367, 283, 3159, 7, 272, 327, 21149, 14, 961, 1990, 2896, 315, 642, 3371, 26, 272, 327, 1455, 921, 9208, 14, 1548, 14, 1308, 15, 67, 1548, 15, 4964, 15, 1965, 69, 22, 556, 19, 68, 25, 65, 2592, 272, 340, 440, 1827, 436, 15539, 315, 4565, 14, 515, 26, 267, 1827, 275, 4565, 14, 515, 14, 1294, 360, 7044, 413, 15786, 17, 61, 272, 2633, 275, 2198, 14, 1122, 63, 26714, 8, 1131, 9, 272, 2074, 275, 791, 1419, 356, 1211, 8, 3214, 6769, 339, 18137, 275, 5253, 14, 6158, 2988, 360, 10271, 14, 8512, 14, 2330, 14, 1637, 14, 7765, 297, 4865, 12, 3044, 12677, 63, 265, 63, 912, 29, 549, 12, 3044, 12677, 63, 589, 1524, 6751, 467, 3044, 12677, 63, 10340, 29, 958, 9, 272, 372, 18137, 14, 3090, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
AndrewPeelMV/Blender2.78c
2.78/scripts/addons/add_curve_extra_objects/add_curve_spirals.py
2
13345
'''bl_info = { "name": "Spirals", "description": "Make spirals", "author": "Alejandro Omar Chocano Vasquez", "version": (1, 2), "blender": (2, 62, 0), "location": "View3D > Add > Curve", "warning": "", # used for warning icon and text in addons panel "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.4/Py/" "Scripts/Object/Spirals", "tracker_url": "http://alexvaqp.googlepages.com?" "func=detail&aid=<number>", "category": "Add Curve", } ''' import bpy, time from bpy.props import ( EnumProperty, BoolProperty, FloatProperty, IntProperty, ) from math import ( sin, cos, pi, exp ) from bpy_extras.object_utils import AddObjectHelper, object_data_add from bpy.types import Operator, Menu from bl_operators.presets import AddPresetBase # make normal spiral # ---------------------------------------------------------------------------- def make_spiral(props, context): # archemedian and logarithmic can be plottet in zylindrical coordinates # if props.spiral_type != 1 and props.spiral_type != 2: # return None # INPUT: turns->degree->max_phi, steps, direction # Initialise Polar Coordinate Enviroment # ------------------------------- props.degree = 360*props.turns # If you want to make the slider for degree steps = props.steps * props.turns # props.steps[per turn] -> steps[for the whole spiral] props.z_scale = props.dif_z * props.turns max_phi = pi*props.degree/180 # max angle in radian step_phi = max_phi/steps # angle in radians between two vertices if props.spiral_direction == 'CLOCKWISE': step_phi *= -1 # flip direction max_phi *= -1 step_z = props.z_scale/(steps-1) # z increase in one step verts = [] verts.extend([props.radius, 0, 0, 1]) cur_phi = 0 cur_z = 0 # ------------------------------ # Archemedean: dif_radius, radius cur_rad = props.radius step_rad = props.dif_radius/(steps * 360/props.degree) # radius increase per angle for archemedean spiral| (steps * 360/props.degree)...Steps needed for 360 deg # Logarithmic: radius, B_force, ang_div, dif_z # print("max_phi:",max_phi,"step_phi:",step_phi,"step_rad:",step_rad,"step_z:",step_z) while abs(cur_phi) <= abs(max_phi): cur_phi += step_phi cur_z += step_z # ------------------------------ if props.spiral_type == 'ARCH': cur_rad += step_rad if props.spiral_type == 'LOG': # r = a*e^{|theta| * b} cur_rad = props.radius * pow(props.B_force, abs(cur_phi)) # ------------------------------ px = cur_rad * cos(cur_phi) py = cur_rad * sin(cur_phi) verts.extend([px, py, cur_z, 1]) return verts # make Spheric spiral # ---------------------------------------------------------------------------- def make_spiral_spheric(props, context): # INPUT: turns, steps[per turn], radius # use spherical Coordinates step_phi = (2*pi) / props.steps # Step of angle in radians for one turn steps = props.steps * props.turns # props.steps[per turn] -> steps[for the whole spiral] max_phi = 2*pi*props.turns # max angle in radian step_phi = max_phi/steps # angle in radians between two vertices if props.spiral_direction == 'CLOCKWISE': # flip direction step_phi *= -1 max_phi *= -1 step_theta = pi / (steps-1) # theta increase in one step (pi == 180 deg) verts = [] verts.extend([0, 0, -props.radius, 1]) # First vertex at south pole #cur_rad = props.radius = CONST cur_phi = 0 cur_theta = -pi/2 # Beginning at south pole while abs(cur_phi) <= abs(max_phi): # Coordinate Transformation sphere->rect px = props.radius * cos(cur_theta) * cos(cur_phi) py = props.radius * cos(cur_theta) * sin(cur_phi) pz = props.radius * sin(cur_theta) verts.extend([px, py, pz, 1]) cur_theta += step_theta cur_phi += step_phi return verts # make torus spiral # ---------------------------------------------------------------------------- def make_spiral_torus(props, context): # INPUT: turns, steps, inner_radius, curves_number, mul_height, dif_inner_radius, cycles max_phi = 2*pi*props.turns * props.cycles # max angle in radian step_phi = 2*pi/props.steps # Step of angle in radians between two vertices if props.spiral_direction == 'CLOCKWISE': # flip direction step_phi *= -1 max_phi *= -1 step_theta = (2*pi / props.turns) / props.steps step_rad = props.dif_radius / (props.steps * props.turns) step_inner_rad = props.dif_inner_radius / props.steps step_z = props.dif_z / (props.steps * props.turns) verts = [] cur_phi = 0 # Inner Ring Radius Angle cur_theta = 0 # Ring Radius Angle cur_rad = props.radius cur_inner_rad = props.inner_radius cur_z = 0 n_cycle = 0 while abs(cur_phi) <= abs(max_phi): # Torus Coordinates -> Rect px = (cur_rad + cur_inner_rad * cos(cur_phi)) * cos(props.curves_number * cur_theta) py = (cur_rad + cur_inner_rad * cos(cur_phi)) * sin(props.curves_number * cur_theta) pz = cur_inner_rad * sin(cur_phi) + cur_z verts.extend([px, py, pz, 1]) if props.touch and cur_phi >= n_cycle * 2*pi: step_z = ((n_cycle+1) * props.dif_inner_radius + props.inner_radius) * 2 / (props.steps * props.turns) n_cycle += 1 cur_theta += step_theta cur_phi += step_phi cur_rad += step_rad cur_inner_rad += step_inner_rad cur_z += step_z return verts # ---------------------------------------------------------------------------- def draw_curve(props, context): if props.spiral_type == 'ARCH': verts = make_spiral(props, context) if props.spiral_type == 'LOG': verts = make_spiral(props, context) if props.spiral_type == 'SPHERE': verts = make_spiral_spheric(props, context) if props.spiral_type == 'TORUS': verts = make_spiral_torus(props, context) curve_data = bpy.data.curves.new(name='Spiral', type='CURVE') curve_data.dimensions = '3D' spline = curve_data.splines.new(type=props.curve_type) ''' if props.curve_type == 0: spline = curve_data.splines.new(type='POLY') elif props.curve_type == 1: spline = curve_data.splines.new(type='NURBS') ''' spline.points.add(len(verts)*0.25-1) # Add only one quarter of points as elements in verts, because verts looks like: "x,y,z,?,x,y,z,?,x,..." spline.points.foreach_set('co', verts) new_obj = object_data_add(context, curve_data) class CURVE_OT_spirals(Operator): bl_idname = "curve.spirals" bl_label = "Add Curve: Spirals" bl_options = {'REGISTER', 'UNDO'} # UNDO needed for operator redo and therefore also to let the addobjecthelp appear!!! bl_description = "Create different types of spirals" spiral_type = EnumProperty(items=[('ARCH', "Archemedian", "Archemedian"), ("LOG", "Logarithmic", "Logarithmic"), ("SPHERE", "Spheric", "Spheric"), ("TORUS", "Torus", "Torus")], default='ARCH', name="Spiral Type", description="Type of spiral to add") curve_type = EnumProperty(items=[('POLY', "Poly", "PolyLine"), ("NURBS", "NURBS", "NURBS")], default='POLY', name="Curve Type", description="Type of spline to use") spiral_direction = EnumProperty(items=[('COUNTER_CLOCKWISE', "Counter Clockwise", "Wind in a counter clockwise direction"), ("CLOCKWISE", "Clockwise", "Wind in a clockwise direction")], default='COUNTER_CLOCKWISE', name="Spiral Direction", description="Direction of winding") turns = IntProperty(default=1, min=1, max=1000, description="Length of Spiral in 360 deg") steps = IntProperty(default=24, min=2, max=1000, description="Number of Vertices per turn") radius = FloatProperty(default=1.00, min=0.00, max=100.00, description="radius for first turn") dif_z = FloatProperty(default=0, min=-10.00, max=100.00, description="increase in z axis per turn") # needed for 1 and 2 spiral_type # ARCHMEDEAN variables dif_radius = FloatProperty(default=0.00, min=-50.00, max=50.00, description="radius increment in each turn") # step between turns(one turn equals 360 deg) # LOG variables B_force = FloatProperty(default=1.00, min=0.00, max=30.00, description="factor of exponent") # TORUS variables inner_radius = FloatProperty(default=0.20, min=0.00, max=100, description="Inner Radius of Torus") dif_inner_radius = FloatProperty(default=0, min=-10, max=100, description="Increase of inner Radius per Cycle") dif_radius = FloatProperty(default=0, min=-10, max=100, description="Increase of Torus Radius per Cycle") cycles = FloatProperty(default=1, min=0.00, max=1000, description="Number of Cycles") curves_number = IntProperty(default=1, min=1, max=400, description="Number of curves of spiral") touch = BoolProperty(default=False, description="No empty spaces between cycles") def draw(self, context): layout = self.layout col = layout.column_flow(align=True) col.label('Presets:') row = col.row(align=True) row.menu("OBJECT_MT_spiral_curve_presets", text=bpy.types.OBJECT_MT_spiral_curve_presets.bl_label) row.operator("curve_extras.spiral_presets", text="", icon='ZOOMIN') #op = row.operator("curve.spiral_presets", text="SAVE") #op.name = bpy.types.OBJECT_MT_spiral_curve_presets.bl_label op = row.operator("curve_extras.spiral_presets", text="", icon='ZOOMOUT') op.remove_active = True layout.prop(self, 'spiral_type') layout.prop(self, 'curve_type') layout.prop(self, 'spiral_direction') layout.label(text="Spiral Parameters:") layout.prop(self, 'turns', text="Turns") layout.prop(self, 'steps', text="Steps") box = layout.box() if self.spiral_type == 'ARCH': box.prop(self, 'dif_radius', text="Radius Growth") box.prop(self, 'radius', text="Radius") box.prop(self, 'dif_z', text="Height") if self.spiral_type == 'LOG': box.prop(self, 'radius', text="Radius") box.prop(self, 'B_force', text="Expansion Force") box.prop(self, 'dif_z', text="Height") if self.spiral_type == 'SPHERE': box.prop(self, 'radius', text="Radius") if self.spiral_type == 'TORUS': box.prop(self, 'cycles', text="Number of Cycles") if self.dif_inner_radius == 0 and self.dif_z == 0: self.cycles = 1 box.prop(self, 'radius', text="Radius") if self.dif_z == 0: box.prop(self, 'dif_z', text="Height per Cycle") else: box2 = box.box() box2.prop(self, 'dif_z', text="Height per Cycle") box2.prop(self, 'touch', text="Make Snail") box.prop(self, 'inner_radius', text="Inner Radius") box.prop(self, 'curves_number', text="Curves Number") box.prop(self, 'dif_radius', text="Increase of Torus Radius") box.prop(self, 'dif_inner_radius', text="Increase of Inner Radius") @classmethod def poll(cls, context): # method called by blender to check if the operator can be run return context.scene is not None def execute(self, context): time_start = time.time() draw_curve(self, context) print("Drawing Spiral Finished: %.4f sec" % (time.time() - time_start)) return {'FINISHED'} class CURVE_EXTRAS_OT_spirals_presets(AddPresetBase, Operator): '''Spirals Presets''' bl_idname = "curve_extras.spiral_presets" bl_label = "Spirals" preset_menu = "OBJECT_MT_spiral_curve_presets" preset_subdir = "curve_extras/curve.spirals" preset_defines = [ "op = bpy.context.active_operator", ] preset_values = [ "op.spiral_type", "op.curve_type", "op.spiral_direction", "op.turns", "op.steps", "op.radius", "op.dif_z", "op.dif_radius", "op.B_force", "op.inner_radius", "op.dif_inner_radius", "op.cycles", "op.curves_number", "op.touch", ] class OBJECT_MT_spiral_curve_presets(Menu): '''Presets for curve.spiral.''' bl_label = "Spiral Curve Presets" bl_idname = "OBJECT_MT_spiral_curve_presets" preset_subdir = "curve_extras/curve.spirals" preset_operator = "script.execute_preset" draw = bpy.types.Menu.draw_preset if __name__ == "__main__": bpy.utils.register_module(__name__)
gpl-2.0
[ 2344, 3345, 63, 815, 275, 469, 272, 298, 354, 582, 298, 5058, 723, 2551, 401, 272, 298, 1802, 582, 298, 5483, 2249, 723, 2551, 401, 272, 298, 2502, 582, 298, 33, 274, 74, 460, 293, 593, 4584, 8802, 2425, 79, 812, 305, 544, 90, 401, 272, 298, 1023, 582, 334, 17, 12, 499, 395, 272, 298, 66, 24912, 582, 334, 18, 12, 16202, 12, 378, 395, 272, 298, 1985, 582, 298, 2768, 19, 36, 690, 2654, 690, 7319, 432, 401, 272, 298, 3764, 582, 4873, 327, 1202, 367, 5721, 7016, 436, 1318, 315, 21293, 12748, 272, 298, 6797, 63, 633, 582, 298, 1014, 921, 6797, 14, 66, 24912, 14, 1308, 15, 1080, 14, 8624, 15, 10597, 26, 18, 14, 20, 15, 2713, 6687, 355, 298, 25681, 15, 1692, 15, 5058, 723, 2551, 401, 272, 298, 8877, 63, 633, 582, 298, 1014, 921, 24421, 3042, 15202, 14, 3098, 5856, 14, 957, 13472, 673, 298, 1532, 29, 5506, 6, 21745, 18987, 1955, 7166, 272, 298, 3710, 582, 298, 1123, 7319, 432, 401, 199, 93, 199, 2344, 199, 646, 20575, 12, 900, 199, 504, 20575, 14, 6750, 492, 334, 267, 11305, 3697, 12, 267, 19287, 3697, 12, 267, 11140, 3697, 12, 267, 9805, 3697, 12, 267, 776, 199, 504, 3473, 492, 334, 267, 9829, 12, 267, 9794, 12, 267, 6682, 12, 267, 1437, 267, 776, 199, 504, 20575, 63, 9975, 14, 785, 63, 1208, 492, 2654, 1692, 4433, 12, 909, 63, 576, 63, 525, 199, 504, 20575, 14, 1313, 492, 11013, 12, 18281, 199, 504, 6826, 63, 12688, 14, 657, 2193, 492, 2654, 2398, 409, 1563, 421, 199, 3, 1852, 3293, 2249, 723, 279, 199, 3, 27103, 199, 318, 1852, 63, 681, 723, 279, 8, 6750, 12, 1067, 304, 272, 327, 601, 3453, 6268, 436, 943, 18327, 15003, 883, 506, 5137, 10288, 315, 1315, 89, 24491, 8825, 8983, 272, 327, 340, 10792, 14, 681, 723, 279, 63, 466, 1137, 413, 436, 10792, 14, 681, 723, 279, 63, 466, 1137, 499, 26, 272, 327, 259, 372, 488, 339, 327, 21955, 26, 25449, 5118, 10956, 5118, 988, 63, 10909, 12, 7124, 12, 7581, 272, 327, 6026, 572, 8467, 285, 25334, 323, 3447, 433, 293, 434, 272, 327, 10652, 18964, 272, 10792, 14, 10956, 275, 19434, 10, 6750, 14, 353, 83, 221, 327, 982, 1265, 2934, 370, 1852, 314, 31608, 367, 13666, 272, 7124, 275, 10792, 14, 5895, 627, 10792, 14, 353, 83, 221, 327, 10792, 14, 5895, 59, 529, 7485, 61, 1035, 7124, 59, 509, 314, 8852, 2249, 723, 279, 61, 272, 10792, 14, 90, 63, 3467, 275, 10792, 14, 7330, 63, 90, 627, 10792, 14, 353, 83, 339, 1390, 63, 10909, 275, 6682, 10, 6750, 14, 10956, 15, 7663, 221, 327, 1390, 9324, 315, 660, 6268, 272, 3650, 63, 10909, 275, 1390, 63, 10909, 15, 5895, 221, 327, 9324, 315, 26874, 3382, 2877, 14971, 272, 340, 10792, 14, 681, 723, 279, 63, 6874, 508, 283, 30690, 7095, 356, 267, 3650, 63, 10909, 9000, 446, 17, 221, 327, 18761, 7581, 267, 1390, 63, 10909, 9000, 446, 17, 272, 3650, 63, 90, 275, 10792, 14, 90, 63, 3467, 7985, 5895, 13, 17, 9, 221, 327, 1315, 19781, 315, 1373, 3650, 339, 809, 1086, 275, 942, 272, 809, 1086, 14, 2880, 779, 6750, 14, 8017, 12, 378, 12, 378, 12, 413, 566, 339, 1094, 63, 10909, 275, 378, 272, 1094, 63, 90, 275, 378, 199, 3, 10652, 10965, 199, 199, 3, 1952, 3453, 271, 290, 26, 487, 70, 63, 8017, 12, 9362, 272, 1094, 63, 9525, 275, 10792, 14, 8017, 272, 3650, 63, 9525, 275, 10792, 14, 7330, 63, 8017, 7985, 5895, 627, 19434, 15, 6750, 14, 10956, 9, 199, 3, 9362, 19781, 1126, 9324, 367, 601, 3453, 271, 290, 2249, 723, 279, 92, 334, 5895, 627, 19434, 15, 6750, 14, 10956, 680, 703, 20960, 4346, 367, 19434, 7926, 199, 3, 5297, 18327, 15003, 26, 9362, 12, 699, 63, 3990, 12, 14550, 63, 3015, 12, 487, 70, 63, 90, 199, 199, 3, 870, 480, 988, 63, 10909, 6783, 988, 63, 10909, 4589, 2926, 63, 10909, 6783, 2926, 63, 10909, 4589, 2926, 63, 9525, 6783, 2926, 63, 9525, 4589, 2926, 63, 90, 6783, 2926, 63, 90, 9, 272, 1830, 2853, 8, 895, 63, 10909, 9, 2695, 2853, 8, 988, 63, 10909, 304, 267, 1094, 63, 10909, 847, 3650, 63, 10909, 267, 1094, 63, 90, 847, 3650, 63, 90, 199, 199, 3, 10652, 10965, 267, 340, 10792, 14, 681, 723, 279, 63, 466, 508, 283, 7762, 356, 288, 1094, 63, 9525, 847, 3650, 63, 9525, 267, 340, 10792, 14, 681, 723, 279, 63, 466, 508, 283, 4947, 356, 288, 327, 519, 275, 282, 10, 69, 11683, 92, 9337, 92, 627, 330, 93, 288, 1094, 63, 9525, 275, 10792, 14, 8017, 627, 13131, 8, 6750, 14, 34, 63, 3990, 12, 2853, 8, 895, 63, 10909, 430, 199, 3, 10652, 10965, 398, 21162, 275, 1094, 63, 9525, 627, 9794, 8, 895, 63, 10909, 9, 267, 1134, 275, 1094, 63, 9525, 627, 9829, 8, 895, 63, 10909, 9, 267, 809, 1086, 14, 2880, 779, 5326, 12, 1134, 12, 1094, 63, 90, 12, 413, 566, 339, 372, 809, 1086, 421, 199, 3, 1852, 428, 7722, 530, 2249, 723, 279, 199, 3, 27103, 199, 318, 1852, 63, 681, 723, 279, 63, 23286, 530, 8, 6750, 12, 1067, 304, 272, 327, 21955, 26, 25449, 12, 7124, 59, 529, 7485, 467, 9362, 272, 327, 675, 308, 27058, 25334, 2335, 272, 3650, 63, 10909, 275, 334, 18, 10, 1038, 9, 1182, 10792, 14, 5895, 221, 327, 13382, 402, 9324, 315, 26874, 367, 1373, 7485, 272, 7124, 275, 10792, 14, 5895, 627, 10792, 14, 353, 83, 221, 327, 10792, 14, 5895, 59, 529, 7485, 61, 1035, 7124, 59, 509, 314, 8852, 2249, 723, 279, 61, 339, 1390, 63, 10909, 275, 499, 10, 1038, 10, 6750, 14, 353, 83, 221, 327, 1390, 9324, 315, 660, 6268, 272, 3650, 63, 10909, 275, 1390, 63, 10909, 15, 5895, 221, 327, 9324, 315, 26874, 3382, 2877, 14971, 272, 340, 10792, 14, 681, 723, 279, 63, 6874, 508, 283, 30690, 7095, 356, 221, 327, 18761, 7581, 267, 3650, 63, 10909, 9000, 446, 17, 267, 1390, 63, 10909, 9000, 446, 17, 272, 3650, 63, 9337, 275, 6682, 1182 ]
[ 3345, 63, 815, 275, 469, 272, 298, 354, 582, 298, 5058, 723, 2551, 401, 272, 298, 1802, 582, 298, 5483, 2249, 723, 2551, 401, 272, 298, 2502, 582, 298, 33, 274, 74, 460, 293, 593, 4584, 8802, 2425, 79, 812, 305, 544, 90, 401, 272, 298, 1023, 582, 334, 17, 12, 499, 395, 272, 298, 66, 24912, 582, 334, 18, 12, 16202, 12, 378, 395, 272, 298, 1985, 582, 298, 2768, 19, 36, 690, 2654, 690, 7319, 432, 401, 272, 298, 3764, 582, 4873, 327, 1202, 367, 5721, 7016, 436, 1318, 315, 21293, 12748, 272, 298, 6797, 63, 633, 582, 298, 1014, 921, 6797, 14, 66, 24912, 14, 1308, 15, 1080, 14, 8624, 15, 10597, 26, 18, 14, 20, 15, 2713, 6687, 355, 298, 25681, 15, 1692, 15, 5058, 723, 2551, 401, 272, 298, 8877, 63, 633, 582, 298, 1014, 921, 24421, 3042, 15202, 14, 3098, 5856, 14, 957, 13472, 673, 298, 1532, 29, 5506, 6, 21745, 18987, 1955, 7166, 272, 298, 3710, 582, 298, 1123, 7319, 432, 401, 199, 93, 199, 2344, 199, 646, 20575, 12, 900, 199, 504, 20575, 14, 6750, 492, 334, 267, 11305, 3697, 12, 267, 19287, 3697, 12, 267, 11140, 3697, 12, 267, 9805, 3697, 12, 267, 776, 199, 504, 3473, 492, 334, 267, 9829, 12, 267, 9794, 12, 267, 6682, 12, 267, 1437, 267, 776, 199, 504, 20575, 63, 9975, 14, 785, 63, 1208, 492, 2654, 1692, 4433, 12, 909, 63, 576, 63, 525, 199, 504, 20575, 14, 1313, 492, 11013, 12, 18281, 199, 504, 6826, 63, 12688, 14, 657, 2193, 492, 2654, 2398, 409, 1563, 421, 199, 3, 1852, 3293, 2249, 723, 279, 199, 3, 27103, 199, 318, 1852, 63, 681, 723, 279, 8, 6750, 12, 1067, 304, 272, 327, 601, 3453, 6268, 436, 943, 18327, 15003, 883, 506, 5137, 10288, 315, 1315, 89, 24491, 8825, 8983, 272, 327, 340, 10792, 14, 681, 723, 279, 63, 466, 1137, 413, 436, 10792, 14, 681, 723, 279, 63, 466, 1137, 499, 26, 272, 327, 259, 372, 488, 339, 327, 21955, 26, 25449, 5118, 10956, 5118, 988, 63, 10909, 12, 7124, 12, 7581, 272, 327, 6026, 572, 8467, 285, 25334, 323, 3447, 433, 293, 434, 272, 327, 10652, 18964, 272, 10792, 14, 10956, 275, 19434, 10, 6750, 14, 353, 83, 221, 327, 982, 1265, 2934, 370, 1852, 314, 31608, 367, 13666, 272, 7124, 275, 10792, 14, 5895, 627, 10792, 14, 353, 83, 221, 327, 10792, 14, 5895, 59, 529, 7485, 61, 1035, 7124, 59, 509, 314, 8852, 2249, 723, 279, 61, 272, 10792, 14, 90, 63, 3467, 275, 10792, 14, 7330, 63, 90, 627, 10792, 14, 353, 83, 339, 1390, 63, 10909, 275, 6682, 10, 6750, 14, 10956, 15, 7663, 221, 327, 1390, 9324, 315, 660, 6268, 272, 3650, 63, 10909, 275, 1390, 63, 10909, 15, 5895, 221, 327, 9324, 315, 26874, 3382, 2877, 14971, 272, 340, 10792, 14, 681, 723, 279, 63, 6874, 508, 283, 30690, 7095, 356, 267, 3650, 63, 10909, 9000, 446, 17, 221, 327, 18761, 7581, 267, 1390, 63, 10909, 9000, 446, 17, 272, 3650, 63, 90, 275, 10792, 14, 90, 63, 3467, 7985, 5895, 13, 17, 9, 221, 327, 1315, 19781, 315, 1373, 3650, 339, 809, 1086, 275, 942, 272, 809, 1086, 14, 2880, 779, 6750, 14, 8017, 12, 378, 12, 378, 12, 413, 566, 339, 1094, 63, 10909, 275, 378, 272, 1094, 63, 90, 275, 378, 199, 3, 10652, 10965, 199, 199, 3, 1952, 3453, 271, 290, 26, 487, 70, 63, 8017, 12, 9362, 272, 1094, 63, 9525, 275, 10792, 14, 8017, 272, 3650, 63, 9525, 275, 10792, 14, 7330, 63, 8017, 7985, 5895, 627, 19434, 15, 6750, 14, 10956, 9, 199, 3, 9362, 19781, 1126, 9324, 367, 601, 3453, 271, 290, 2249, 723, 279, 92, 334, 5895, 627, 19434, 15, 6750, 14, 10956, 680, 703, 20960, 4346, 367, 19434, 7926, 199, 3, 5297, 18327, 15003, 26, 9362, 12, 699, 63, 3990, 12, 14550, 63, 3015, 12, 487, 70, 63, 90, 199, 199, 3, 870, 480, 988, 63, 10909, 6783, 988, 63, 10909, 4589, 2926, 63, 10909, 6783, 2926, 63, 10909, 4589, 2926, 63, 9525, 6783, 2926, 63, 9525, 4589, 2926, 63, 90, 6783, 2926, 63, 90, 9, 272, 1830, 2853, 8, 895, 63, 10909, 9, 2695, 2853, 8, 988, 63, 10909, 304, 267, 1094, 63, 10909, 847, 3650, 63, 10909, 267, 1094, 63, 90, 847, 3650, 63, 90, 199, 199, 3, 10652, 10965, 267, 340, 10792, 14, 681, 723, 279, 63, 466, 508, 283, 7762, 356, 288, 1094, 63, 9525, 847, 3650, 63, 9525, 267, 340, 10792, 14, 681, 723, 279, 63, 466, 508, 283, 4947, 356, 288, 327, 519, 275, 282, 10, 69, 11683, 92, 9337, 92, 627, 330, 93, 288, 1094, 63, 9525, 275, 10792, 14, 8017, 627, 13131, 8, 6750, 14, 34, 63, 3990, 12, 2853, 8, 895, 63, 10909, 430, 199, 3, 10652, 10965, 398, 21162, 275, 1094, 63, 9525, 627, 9794, 8, 895, 63, 10909, 9, 267, 1134, 275, 1094, 63, 9525, 627, 9829, 8, 895, 63, 10909, 9, 267, 809, 1086, 14, 2880, 779, 5326, 12, 1134, 12, 1094, 63, 90, 12, 413, 566, 339, 372, 809, 1086, 421, 199, 3, 1852, 428, 7722, 530, 2249, 723, 279, 199, 3, 27103, 199, 318, 1852, 63, 681, 723, 279, 63, 23286, 530, 8, 6750, 12, 1067, 304, 272, 327, 21955, 26, 25449, 12, 7124, 59, 529, 7485, 467, 9362, 272, 327, 675, 308, 27058, 25334, 2335, 272, 3650, 63, 10909, 275, 334, 18, 10, 1038, 9, 1182, 10792, 14, 5895, 221, 327, 13382, 402, 9324, 315, 26874, 367, 1373, 7485, 272, 7124, 275, 10792, 14, 5895, 627, 10792, 14, 353, 83, 221, 327, 10792, 14, 5895, 59, 529, 7485, 61, 1035, 7124, 59, 509, 314, 8852, 2249, 723, 279, 61, 339, 1390, 63, 10909, 275, 499, 10, 1038, 10, 6750, 14, 353, 83, 221, 327, 1390, 9324, 315, 660, 6268, 272, 3650, 63, 10909, 275, 1390, 63, 10909, 15, 5895, 221, 327, 9324, 315, 26874, 3382, 2877, 14971, 272, 340, 10792, 14, 681, 723, 279, 63, 6874, 508, 283, 30690, 7095, 356, 221, 327, 18761, 7581, 267, 3650, 63, 10909, 9000, 446, 17, 267, 1390, 63, 10909, 9000, 446, 17, 272, 3650, 63, 9337, 275, 6682, 1182, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1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is/geos/tests/test_geos_mutation.py
109
5305
# Copyright (c) 2008-2009 Aryeh Leib Taurog, all rights reserved. # Modified from original contribution by Aryeh Leib Taurog, which was # released under the New BSD license. from django.utils import unittest from django.utils.unittest import skipUnless from .. import HAS_GEOS if HAS_GEOS: from .. import * from ..error import GEOSIndexError def getItem(o,i): return o[i] def delItem(o,i): del o[i] def setItem(o,i,v): o[i] = v if HAS_GEOS: def api_get_distance(x): return x.distance(Point(-200,-200)) def api_get_buffer(x): return x.buffer(10) def api_get_geom_typeid(x): return x.geom_typeid def api_get_num_coords(x): return x.num_coords def api_get_centroid(x): return x.centroid def api_get_empty(x): return x.empty def api_get_valid(x): return x.valid def api_get_simple(x): return x.simple def api_get_ring(x): return x.ring def api_get_boundary(x): return x.boundary def api_get_convex_hull(x): return x.convex_hull def api_get_extent(x): return x.extent def api_get_area(x): return x.area def api_get_length(x): return x.length geos_function_tests = [ val for name, val in vars().items() if hasattr(val, '__call__') and name.startswith('api_get_') ] @skipUnless(HAS_GEOS, "Geos is required.") class GEOSMutationTest(unittest.TestCase): """ Tests Pythonic Mutability of Python GEOS geometry wrappers get/set/delitem on a slice, normal list methods """ def test00_GEOSIndexException(self): 'Testing Geometry GEOSIndexError' p = Point(1,2) for i in range(-2,2): p._checkindex(i) self.assertRaises(GEOSIndexError, p._checkindex, 2) self.assertRaises(GEOSIndexError, p._checkindex, -3) def test01_PointMutations(self): 'Testing Point mutations' for p in (Point(1,2,3), fromstr('POINT (1 2 3)')): self.assertEqual(p._get_single_external(1), 2.0, 'Point _get_single_external') # _set_single p._set_single(0,100) self.assertEqual(p.coords, (100.0,2.0,3.0), 'Point _set_single') # _set_list p._set_list(2,(50,3141)) self.assertEqual(p.coords, (50.0,3141.0), 'Point _set_list') def test02_PointExceptions(self): 'Testing Point exceptions' self.assertRaises(TypeError, Point, range(1)) self.assertRaises(TypeError, Point, range(4)) def test03_PointApi(self): 'Testing Point API' q = Point(4,5,3) for p in (Point(1,2,3), fromstr('POINT (1 2 3)')): p[0:2] = [4,5] for f in geos_function_tests: self.assertEqual(f(q), f(p), 'Point ' + f.__name__) def test04_LineStringMutations(self): 'Testing LineString mutations' for ls in (LineString((1,0),(4,1),(6,-1)), fromstr('LINESTRING (1 0,4 1,6 -1)')): self.assertEqual(ls._get_single_external(1), (4.0,1.0), 'LineString _get_single_external') # _set_single ls._set_single(0,(-50,25)) self.assertEqual(ls.coords, ((-50.0,25.0),(4.0,1.0),(6.0,-1.0)), 'LineString _set_single') # _set_list ls._set_list(2, ((-50.0,25.0),(6.0,-1.0))) self.assertEqual(ls.coords, ((-50.0,25.0),(6.0,-1.0)), 'LineString _set_list') lsa = LineString(ls.coords) for f in geos_function_tests: self.assertEqual(f(lsa), f(ls), 'LineString ' + f.__name__) def test05_Polygon(self): 'Testing Polygon mutations' for pg in (Polygon(((1,0),(4,1),(6,-1),(8,10),(1,0)), ((5,4),(6,4),(6,3),(5,4))), fromstr('POLYGON ((1 0,4 1,6 -1,8 10,1 0),(5 4,6 4,6 3,5 4))')): self.assertEqual(pg._get_single_external(0), LinearRing((1,0),(4,1),(6,-1),(8,10),(1,0)), 'Polygon _get_single_external(0)') self.assertEqual(pg._get_single_external(1), LinearRing((5,4),(6,4),(6,3),(5,4)), 'Polygon _get_single_external(1)') # _set_list pg._set_list(2, (((1,2),(10,0),(12,9),(-1,15),(1,2)), ((4,2),(5,2),(5,3),(4,2)))) self.assertEqual(pg.coords, (((1.0,2.0),(10.0,0.0),(12.0,9.0),(-1.0,15.0),(1.0,2.0)), ((4.0,2.0),(5.0,2.0),(5.0,3.0),(4.0,2.0))), 'Polygon _set_list') lsa = Polygon(*pg.coords) for f in geos_function_tests: self.assertEqual(f(lsa), f(pg), 'Polygon ' + f.__name__) def test06_Collection(self): 'Testing Collection mutations' for mp in (MultiPoint(*map(Point,((3,4),(-1,2),(5,-4),(2,8)))), fromstr('MULTIPOINT (3 4,-1 2,5 -4,2 8)')): self.assertEqual(mp._get_single_external(2), Point(5,-4), 'Collection _get_single_external') mp._set_list(3, map(Point,((5,5),(3,-2),(8,1)))) self.assertEqual(mp.coords, ((5.0,5.0),(3.0,-2.0),(8.0,1.0)), 'Collection _set_list') lsa = MultiPoint(*map(Point,((5,5),(3,-2),(8,1)))) for f in geos_function_tests: self.assertEqual(f(lsa), f(mp), 'MultiPoint ' + f.__name__)
mit
[ 3, 1898, 334, 67, 9, 9079, 13, 8664, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1006, 4481, 4644, 14, 199, 3, 22016, 687, 3379, 406, 15980, 701, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1314, 1990, 199, 3, 14286, 1334, 314, 7053, 6289, 4190, 14, 199, 199, 504, 1639, 14, 1208, 492, 2882, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 5524, 199, 199, 504, 2508, 492, 7509, 63, 14151, 199, 199, 692, 7509, 63, 14151, 26, 272, 687, 2508, 492, 627, 272, 687, 2508, 705, 492, 11920, 12129, 421, 199, 318, 664, 2081, 8, 79, 12, 73, 304, 372, 312, 59, 73, 61, 199, 318, 2150, 2081, 8, 79, 12, 73, 304, 2150, 312, 59, 73, 61, 199, 318, 663, 2081, 8, 79, 12, 73, 12, 86, 304, 312, 59, 73, 61, 275, 373, 199, 199, 692, 7509, 63, 14151, 26, 272, 347, 2986, 63, 362, 63, 5590, 8, 88, 304, 372, 671, 14, 5590, 8, 3428, 2801, 1840, 3057, 1840, 430, 199, 199, 318, 2986, 63, 362, 63, 2738, 8, 88, 304, 372, 671, 14, 2738, 8, 709, 9, 199, 318, 2986, 63, 362, 63, 6481, 63, 22749, 8, 88, 304, 372, 671, 14, 6481, 63, 22749, 199, 318, 2986, 63, 362, 63, 1507, 63, 8032, 8, 88, 304, 372, 671, 14, 1507, 63, 8032, 199, 318, 2986, 63, 362, 63, 22098, 8, 88, 304, 372, 671, 14, 22098, 199, 318, 2986, 63, 362, 63, 1667, 8, 88, 304, 372, 671, 14, 1667, 199, 318, 2986, 63, 362, 63, 1078, 8, 88, 304, 372, 671, 14, 1078, 199, 318, 2986, 63, 362, 63, 4129, 8, 88, 304, 372, 671, 14, 4129, 199, 318, 2986, 63, 362, 63, 5985, 8, 88, 304, 372, 671, 14, 5985, 199, 318, 2986, 63, 362, 63, 9891, 8, 88, 304, 372, 671, 14, 9891, 199, 318, 2986, 63, 362, 63, 388, 26221, 63, 72, 979, 8, 88, 304, 372, 671, 14, 388, 26221, 63, 72, 979, 199, 318, 2986, 63, 362, 63, 11599, 8, 88, 304, 372, 671, 14, 11599, 199, 318, 2986, 63, 362, 63, 6789, 8, 88, 304, 372, 671, 14, 6789, 199, 318, 2986, 63, 362, 63, 1267, 8, 88, 304, 372, 671, 14, 1267, 199, 199, 12151, 63, 1593, 63, 2219, 275, 221, 359, 1139, 367, 536, 12, 1139, 315, 6802, 1252, 1744, 342, 717, 340, 2688, 8, 637, 12, 2560, 1250, 13766, 717, 436, 536, 14, 2460, 360, 1246, 63, 362, 15452, 1622, 421, 199, 32, 11278, 8, 13533, 63, 14151, 12, 298, 4240, 736, 365, 1415, 2685, 199, 533, 11920, 45, 10326, 774, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 2018, 530, 26550, 3616, 402, 2018, 11920, 3400, 17995, 272, 664, 15, 409, 15, 13228, 641, 282, 6014, 12, 3293, 769, 3102, 272, 408, 339, 347, 511, 383, 63, 14151, 2681, 1726, 8, 277, 304, 267, 283, 9029, 10579, 11920, 12129, 7, 267, 299, 275, 7584, 8, 17, 12, 18, 9, 267, 367, 284, 315, 1425, 2801, 18, 12, 18, 304, 299, 423, 1074, 1080, 8, 73, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 499, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 446, 19, 9, 339, 347, 511, 614, 63, 3428, 22539, 1298, 8, 277, 304, 267, 283, 9029, 7584, 8567, 1298, 7, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 291, 14, 629, 8, 80, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 499, 14, 16, 12, 283, 3428, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 299, 423, 409, 63, 4780, 8, 16, 12, 1960, 9, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1960, 14, 16, 12, 18, 14, 16, 12, 19, 14, 16, 395, 283, 3428, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 299, 423, 409, 63, 513, 8, 18, 12803, 1400, 12, 8988, 17, 430, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1400, 14, 16, 12, 8988, 17, 14, 16, 395, 283, 3428, 485, 409, 63, 513, 358, 339, 347, 511, 996, 63, 3428, 16836, 8, 277, 304, 267, 283, 9029, 7584, 4967, 7, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 17, 430, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 20, 430, 339, 347, 511, 1644, 63, 3428, 7394, 8, 277, 304, 267, 283, 9029, 7584, 3261, 7, 267, 1894, 275, 7584, 8, 20, 12, 21, 12, 19, 9, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 299, 59, 16, 26, 18, 61, 275, 359, 20, 12, 21, 61, 288, 367, 289, 315, 30259, 63, 1593, 63, 2219, 26, 355, 291, 14, 629, 8, 70, 8, 81, 395, 289, 8, 80, 395, 283, 3428, 283, 435, 289, 855, 354, 3368, 339, 347, 511, 966, 63, 22134, 22539, 1298, 8, 277, 304, 267, 283, 9029, 30020, 8567, 1298, 7, 267, 367, 9100, 315, 334, 22134, 1332, 17, 12, 16, 11865, 20, 12, 17, 11865, 22, 3057, 17, 1826, 490, 23744, 360, 6143, 29780, 334, 17, 378, 12, 20, 413, 12, 22, 446, 17, 5942, 304, 288, 291, 14, 629, 8, 478, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 334, 20, 14, 16, 12, 17, 14, 16, 395, 283, 22134, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 9100, 423, 409, 63, 4780, 8, 16, 12, 2801, 1400, 12, 821, 430, 288, 291, 14, 629, 8, 478, 14, 8032, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 20, 14, 16, 12, 17, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1826, 283, 22134, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 9100, 423, 409, 63, 513, 8, 18, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1724, 288, 291, 14, 629, 8, 478, 14, 8032 ]
[ 1898, 334, 67, 9, 9079, 13, 8664, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1006, 4481, 4644, 14, 199, 3, 22016, 687, 3379, 406, 15980, 701, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1314, 1990, 199, 3, 14286, 1334, 314, 7053, 6289, 4190, 14, 199, 199, 504, 1639, 14, 1208, 492, 2882, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 5524, 199, 199, 504, 2508, 492, 7509, 63, 14151, 199, 199, 692, 7509, 63, 14151, 26, 272, 687, 2508, 492, 627, 272, 687, 2508, 705, 492, 11920, 12129, 421, 199, 318, 664, 2081, 8, 79, 12, 73, 304, 372, 312, 59, 73, 61, 199, 318, 2150, 2081, 8, 79, 12, 73, 304, 2150, 312, 59, 73, 61, 199, 318, 663, 2081, 8, 79, 12, 73, 12, 86, 304, 312, 59, 73, 61, 275, 373, 199, 199, 692, 7509, 63, 14151, 26, 272, 347, 2986, 63, 362, 63, 5590, 8, 88, 304, 372, 671, 14, 5590, 8, 3428, 2801, 1840, 3057, 1840, 430, 199, 199, 318, 2986, 63, 362, 63, 2738, 8, 88, 304, 372, 671, 14, 2738, 8, 709, 9, 199, 318, 2986, 63, 362, 63, 6481, 63, 22749, 8, 88, 304, 372, 671, 14, 6481, 63, 22749, 199, 318, 2986, 63, 362, 63, 1507, 63, 8032, 8, 88, 304, 372, 671, 14, 1507, 63, 8032, 199, 318, 2986, 63, 362, 63, 22098, 8, 88, 304, 372, 671, 14, 22098, 199, 318, 2986, 63, 362, 63, 1667, 8, 88, 304, 372, 671, 14, 1667, 199, 318, 2986, 63, 362, 63, 1078, 8, 88, 304, 372, 671, 14, 1078, 199, 318, 2986, 63, 362, 63, 4129, 8, 88, 304, 372, 671, 14, 4129, 199, 318, 2986, 63, 362, 63, 5985, 8, 88, 304, 372, 671, 14, 5985, 199, 318, 2986, 63, 362, 63, 9891, 8, 88, 304, 372, 671, 14, 9891, 199, 318, 2986, 63, 362, 63, 388, 26221, 63, 72, 979, 8, 88, 304, 372, 671, 14, 388, 26221, 63, 72, 979, 199, 318, 2986, 63, 362, 63, 11599, 8, 88, 304, 372, 671, 14, 11599, 199, 318, 2986, 63, 362, 63, 6789, 8, 88, 304, 372, 671, 14, 6789, 199, 318, 2986, 63, 362, 63, 1267, 8, 88, 304, 372, 671, 14, 1267, 199, 199, 12151, 63, 1593, 63, 2219, 275, 221, 359, 1139, 367, 536, 12, 1139, 315, 6802, 1252, 1744, 342, 717, 340, 2688, 8, 637, 12, 2560, 1250, 13766, 717, 436, 536, 14, 2460, 360, 1246, 63, 362, 15452, 1622, 421, 199, 32, 11278, 8, 13533, 63, 14151, 12, 298, 4240, 736, 365, 1415, 2685, 199, 533, 11920, 45, 10326, 774, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 2018, 530, 26550, 3616, 402, 2018, 11920, 3400, 17995, 272, 664, 15, 409, 15, 13228, 641, 282, 6014, 12, 3293, 769, 3102, 272, 408, 339, 347, 511, 383, 63, 14151, 2681, 1726, 8, 277, 304, 267, 283, 9029, 10579, 11920, 12129, 7, 267, 299, 275, 7584, 8, 17, 12, 18, 9, 267, 367, 284, 315, 1425, 2801, 18, 12, 18, 304, 299, 423, 1074, 1080, 8, 73, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 499, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 446, 19, 9, 339, 347, 511, 614, 63, 3428, 22539, 1298, 8, 277, 304, 267, 283, 9029, 7584, 8567, 1298, 7, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 291, 14, 629, 8, 80, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 499, 14, 16, 12, 283, 3428, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 299, 423, 409, 63, 4780, 8, 16, 12, 1960, 9, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1960, 14, 16, 12, 18, 14, 16, 12, 19, 14, 16, 395, 283, 3428, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 299, 423, 409, 63, 513, 8, 18, 12803, 1400, 12, 8988, 17, 430, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1400, 14, 16, 12, 8988, 17, 14, 16, 395, 283, 3428, 485, 409, 63, 513, 358, 339, 347, 511, 996, 63, 3428, 16836, 8, 277, 304, 267, 283, 9029, 7584, 4967, 7, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 17, 430, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 20, 430, 339, 347, 511, 1644, 63, 3428, 7394, 8, 277, 304, 267, 283, 9029, 7584, 3261, 7, 267, 1894, 275, 7584, 8, 20, 12, 21, 12, 19, 9, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 299, 59, 16, 26, 18, 61, 275, 359, 20, 12, 21, 61, 288, 367, 289, 315, 30259, 63, 1593, 63, 2219, 26, 355, 291, 14, 629, 8, 70, 8, 81, 395, 289, 8, 80, 395, 283, 3428, 283, 435, 289, 855, 354, 3368, 339, 347, 511, 966, 63, 22134, 22539, 1298, 8, 277, 304, 267, 283, 9029, 30020, 8567, 1298, 7, 267, 367, 9100, 315, 334, 22134, 1332, 17, 12, 16, 11865, 20, 12, 17, 11865, 22, 3057, 17, 1826, 490, 23744, 360, 6143, 29780, 334, 17, 378, 12, 20, 413, 12, 22, 446, 17, 5942, 304, 288, 291, 14, 629, 8, 478, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 334, 20, 14, 16, 12, 17, 14, 16, 395, 283, 22134, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 9100, 423, 409, 63, 4780, 8, 16, 12, 2801, 1400, 12, 821, 430, 288, 291, 14, 629, 8, 478, 14, 8032, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 20, 14, 16, 12, 17, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1826, 283, 22134, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 9100, 423, 409, 63, 513, 8, 18, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1724, 288, 291, 14, 629, 8, 478, 14, 8032, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
beatrizjesus/my-first-blog
pasta/Lib/site-packages/django/db/models/fields/__init__.py
77
89087
# -*- coding: utf-8 -*- from __future__ import unicode_literals import collections import copy import datetime import decimal import math import uuid import warnings from base64 import b64decode, b64encode from itertools import tee from django.apps import apps from django.db import connection from django.db.models.lookups import default_lookups, RegisterLookupMixin from django.db.models.query_utils import QueryWrapper from django.conf import settings from django import forms from django.core import exceptions, validators, checks from django.utils.datastructures import DictWrapper from django.utils.dateparse import parse_date, parse_datetime, parse_time, parse_duration from django.utils.duration import duration_string from django.utils.functional import cached_property, curry, total_ordering, Promise from django.utils.text import capfirst from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import (smart_text, force_text, force_bytes, python_2_unicode_compatible) from django.utils.ipv6 import clean_ipv6_address from django.utils import six from django.utils.itercompat import is_iterable # When the _meta object was formalized, this exception was moved to # django.core.exceptions. It is retained here for backwards compatibility # purposes. from django.core.exceptions import FieldDoesNotExist # NOQA # Avoid "TypeError: Item in ``from list'' not a string" -- unicode_literals # makes these strings unicode __all__ = [str(x) for x in ( 'AutoField', 'BLANK_CHOICE_DASH', 'BigIntegerField', 'BinaryField', 'BooleanField', 'CharField', 'CommaSeparatedIntegerField', 'DateField', 'DateTimeField', 'DecimalField', 'DurationField', 'EmailField', 'Empty', 'Field', 'FieldDoesNotExist', 'FilePathField', 'FloatField', 'GenericIPAddressField', 'IPAddressField', 'IntegerField', 'NOT_PROVIDED', 'NullBooleanField', 'PositiveIntegerField', 'PositiveSmallIntegerField', 'SlugField', 'SmallIntegerField', 'TextField', 'TimeField', 'URLField', 'UUIDField', )] class Empty(object): pass class NOT_PROVIDED: pass # The values to use for "blank" in SelectFields. Will be appended to the start # of most "choices" lists. BLANK_CHOICE_DASH = [("", "---------")] def _load_field(app_label, model_name, field_name): return apps.get_model(app_label, model_name)._meta.get_field(field_name) # A guide to Field parameters: # # * name: The name of the field specified in the model. # * attname: The attribute to use on the model object. This is the same as # "name", except in the case of ForeignKeys, where "_id" is # appended. # * db_column: The db_column specified in the model (or None). # * column: The database column for this field. This is the same as # "attname", except if db_column is specified. # # Code that introspects values, or does other dynamic things, should use # attname. For example, this gets the primary key value of object "obj": # # getattr(obj, opts.pk.attname) def _empty(of_cls): new = Empty() new.__class__ = of_cls return new @total_ordering @python_2_unicode_compatible class Field(RegisterLookupMixin): """Base class for all field types""" # Designates whether empty strings fundamentally are allowed at the # database level. empty_strings_allowed = True empty_values = list(validators.EMPTY_VALUES) # These track each time a Field instance is created. Used to retain order. # The auto_creation_counter is used for fields that Django implicitly # creates, creation_counter is used for all user-specified fields. creation_counter = 0 auto_creation_counter = -1 default_validators = [] # Default set of validators default_error_messages = { 'invalid_choice': _('Value %(value)r is not a valid choice.'), 'null': _('This field cannot be null.'), 'blank': _('This field cannot be blank.'), 'unique': _('%(model_name)s with this %(field_label)s ' 'already exists.'), # Translators: The 'lookup_type' is one of 'date', 'year' or 'month'. # Eg: "Title must be unique for pub_date year" 'unique_for_date': _("%(field_label)s must be unique for " "%(date_field_label)s %(lookup_type)s."), } class_lookups = default_lookups.copy() system_check_deprecated_details = None system_check_removed_details = None # Field flags hidden = False many_to_many = None many_to_one = None one_to_many = None one_to_one = None related_model = None # Generic field type description, usually overridden by subclasses def _description(self): return _('Field of type: %(field_type)s') % { 'field_type': self.__class__.__name__ } description = property(_description) def __init__(self, verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=NOT_PROVIDED, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=[], error_messages=None): self.name = name self.verbose_name = verbose_name # May be set by set_attributes_from_name self._verbose_name = verbose_name # Store original for deconstruction self.primary_key = primary_key self.max_length, self._unique = max_length, unique self.blank, self.null = blank, null self.rel = rel self.is_relation = self.rel is not None self.default = default self.editable = editable self.serialize = serialize self.unique_for_date = unique_for_date self.unique_for_month = unique_for_month self.unique_for_year = unique_for_year self._choices = choices or [] self.help_text = help_text self.db_column = db_column self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE self.auto_created = auto_created # Set db_index to True if the field has a relationship and doesn't # explicitly set db_index. self.db_index = db_index # Adjust the appropriate creation counter, and save our local copy. if auto_created: self.creation_counter = Field.auto_creation_counter Field.auto_creation_counter -= 1 else: self.creation_counter = Field.creation_counter Field.creation_counter += 1 self._validators = validators # Store for deconstruction later messages = {} for c in reversed(self.__class__.__mro__): messages.update(getattr(c, 'default_error_messages', {})) messages.update(error_messages or {}) self._error_messages = error_messages # Store for deconstruction later self.error_messages = messages def __str__(self): """ Return "app_label.model_label.field_name". """ model = self.model app = model._meta.app_label return '%s.%s.%s' % (app, model._meta.object_name, self.name) def __repr__(self): """ Displays the module, class and name of the field. """ path = '%s.%s' % (self.__class__.__module__, self.__class__.__name__) name = getattr(self, 'name', None) if name is not None: return '<%s: %s>' % (path, name) return '<%s>' % path def check(self, **kwargs): errors = [] errors.extend(self._check_field_name()) errors.extend(self._check_choices()) errors.extend(self._check_db_index()) errors.extend(self._check_null_allowed_for_primary_keys()) errors.extend(self._check_backend_specific_checks(**kwargs)) errors.extend(self._check_deprecation_details()) return errors def _check_field_name(self): """ Check if field name is valid, i.e. 1) does not end with an underscore, 2) does not contain "__" and 3) is not "pk". """ if self.name.endswith('_'): return [ checks.Error( 'Field names must not end with an underscore.', hint=None, obj=self, id='fields.E001', ) ] elif '__' in self.name: return [ checks.Error( 'Field names must not contain "__".', hint=None, obj=self, id='fields.E002', ) ] elif self.name == 'pk': return [ checks.Error( "'pk' is a reserved word that cannot be used as a field name.", hint=None, obj=self, id='fields.E003', ) ] else: return [] def _check_choices(self): if self.choices: if (isinstance(self.choices, six.string_types) or not is_iterable(self.choices)): return [ checks.Error( "'choices' must be an iterable (e.g., a list or tuple).", hint=None, obj=self, id='fields.E004', ) ] elif any(isinstance(choice, six.string_types) or not is_iterable(choice) or len(choice) != 2 for choice in self.choices): return [ checks.Error( ("'choices' must be an iterable containing " "(actual value, human readable name) tuples."), hint=None, obj=self, id='fields.E005', ) ] else: return [] else: return [] def _check_db_index(self): if self.db_index not in (None, True, False): return [ checks.Error( "'db_index' must be None, True or False.", hint=None, obj=self, id='fields.E006', ) ] else: return [] def _check_null_allowed_for_primary_keys(self): if (self.primary_key and self.null and not connection.features.interprets_empty_strings_as_nulls): # We cannot reliably check this for backends like Oracle which # consider NULL and '' to be equal (and thus set up # character-based fields a little differently). return [ checks.Error( 'Primary keys must not have null=True.', hint=('Set null=False on the field, or ' 'remove primary_key=True argument.'), obj=self, id='fields.E007', ) ] else: return [] def _check_backend_specific_checks(self, **kwargs): return connection.validation.check_field(self, **kwargs) def _check_deprecation_details(self): if self.system_check_removed_details is not None: return [ checks.Error( self.system_check_removed_details.get( 'msg', '%s has been removed except for support in historical ' 'migrations.' % self.__class__.__name__ ), hint=self.system_check_removed_details.get('hint'), obj=self, id=self.system_check_removed_details.get('id', 'fields.EXXX'), ) ] elif self.system_check_deprecated_details is not None: return [ checks.Warning( self.system_check_deprecated_details.get( 'msg', '%s has been deprecated.' % self.__class__.__name__ ), hint=self.system_check_deprecated_details.get('hint'), obj=self, id=self.system_check_deprecated_details.get('id', 'fields.WXXX'), ) ] return [] def get_col(self, alias, output_field=None): if output_field is None: output_field = self if alias != self.model._meta.db_table or output_field != self: from django.db.models.expressions import Col return Col(alias, self, output_field) else: return self.cached_col @cached_property def cached_col(self): from django.db.models.expressions import Col return Col(self.model._meta.db_table, self) def select_format(self, compiler, sql, params): """ Custom format for select clauses. For example, GIS columns need to be selected as AsText(table.col) on MySQL as the table.col data can't be used by Django. """ return sql, params def deconstruct(self): """ Returns enough information to recreate the field as a 4-tuple: * The name of the field on the model, if contribute_to_class has been run * The import path of the field, including the class: django.db.models.IntegerField This should be the most portable version, so less specific may be better. * A list of positional arguments * A dict of keyword arguments Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types): * None, bool, str, unicode, int, long, float, complex, set, frozenset, list, tuple, dict * UUID * datetime.datetime (naive), datetime.date * top-level classes, top-level functions - will be referenced by their full import path * Storage instances - these have their own deconstruct() method This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined. There's no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values. """ # Short-form way of fetching all the default parameters keywords = {} possibles = { "verbose_name": None, "primary_key": False, "max_length": None, "unique": False, "blank": False, "null": False, "db_index": False, "default": NOT_PROVIDED, "editable": True, "serialize": True, "unique_for_date": None, "unique_for_month": None, "unique_for_year": None, "choices": [], "help_text": '', "db_column": None, "db_tablespace": settings.DEFAULT_INDEX_TABLESPACE, "auto_created": False, "validators": [], "error_messages": None, } attr_overrides = { "unique": "_unique", "choices": "_choices", "error_messages": "_error_messages", "validators": "_validators", "verbose_name": "_verbose_name", } equals_comparison = {"choices", "validators", "db_tablespace"} for name, default in possibles.items(): value = getattr(self, attr_overrides.get(name, name)) # Unroll anything iterable for choices into a concrete list if name == "choices" and isinstance(value, collections.Iterable): value = list(value) # Do correct kind of comparison if name in equals_comparison: if value != default: keywords[name] = value else: if value is not default: keywords[name] = value # Work out path - we shorten it for known Django core fields path = "%s.%s" % (self.__class__.__module__, self.__class__.__name__) if path.startswith("django.db.models.fields.related"): path = path.replace("django.db.models.fields.related", "django.db.models") if path.startswith("django.db.models.fields.files"): path = path.replace("django.db.models.fields.files", "django.db.models") if path.startswith("django.db.models.fields.proxy"): path = path.replace("django.db.models.fields.proxy", "django.db.models") if path.startswith("django.db.models.fields"): path = path.replace("django.db.models.fields", "django.db.models") # Return basic info - other fields should override this. return ( force_text(self.name, strings_only=True), path, [], keywords, ) def clone(self): """ Uses deconstruct() to clone a new copy of this Field. Will not preserve any class attachments/attribute names. """ name, path, args, kwargs = self.deconstruct() return self.__class__(*args, **kwargs) def __eq__(self, other): # Needed for @total_ordering if isinstance(other, Field): return self.creation_counter == other.creation_counter return NotImplemented def __lt__(self, other): # This is needed because bisect does not take a comparison function. if isinstance(other, Field): return self.creation_counter < other.creation_counter return NotImplemented def __hash__(self): return hash(self.creation_counter) def __deepcopy__(self, memodict): # We don't have to deepcopy very much here, since most things are not # intended to be altered after initial creation. obj = copy.copy(self) if self.rel: obj.rel = copy.copy(self.rel) if hasattr(self.rel, 'field') and self.rel.field is self: obj.rel.field = obj memodict[id(self)] = obj return obj def __copy__(self): # We need to avoid hitting __reduce__, so define this # slightly weird copy construct. obj = Empty() obj.__class__ = self.__class__ obj.__dict__ = self.__dict__.copy() return obj def __reduce__(self): """ Pickling should return the model._meta.fields instance of the field, not a new copy of that field. So, we use the app registry to load the model and then the field back. """ if not hasattr(self, 'model'): # Fields are sometimes used without attaching them to models (for # example in aggregation). In this case give back a plain field # instance. The code below will create a new empty instance of # class self.__class__, then update its dict with self.__dict__ # values - so, this is very close to normal pickle. return _empty, (self.__class__,), self.__dict__ if self.model._deferred: # Deferred model will not be found from the app registry. This # could be fixed by reconstructing the deferred model on unpickle. raise RuntimeError("Fields of deferred models can't be reduced") return _load_field, (self.model._meta.app_label, self.model._meta.object_name, self.name) def get_pk_value_on_save(self, instance): """ Hook to generate new PK values on save. This method is called when saving instances with no primary key value set. If this method returns something else than None, then the returned value is used when saving the new instance. """ if self.default: return self.get_default() return None def to_python(self, value): """ Converts the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ return value @cached_property def validators(self): # Some validators can't be created at field initialization time. # This method provides a way to delay their creation until required. return self.default_validators + self._validators def run_validators(self, value): if value in self.empty_values: return errors = [] for v in self.validators: try: v(value) except exceptions.ValidationError as e: if hasattr(e, 'code') and e.code in self.error_messages: e.message = self.error_messages[e.code] errors.extend(e.error_list) if errors: raise exceptions.ValidationError(errors) def validate(self, value, model_instance): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not self.editable: # Skip validation for non-editable fields. return if self._choices and value not in self.empty_values: for option_key, option_value in self.choices: if isinstance(option_value, (list, tuple)): # This is an optgroup, so look inside the group for # options. for optgroup_key, optgroup_value in option_value: if value == optgroup_key: return elif value == option_key: return raise exceptions.ValidationError( self.error_messages['invalid_choice'], code='invalid_choice', params={'value': value}, ) if value is None and not self.null: raise exceptions.ValidationError(self.error_messages['null'], code='null') if not self.blank and value in self.empty_values: raise exceptions.ValidationError(self.error_messages['blank'], code='blank') def clean(self, value, model_instance): """ Convert the value's type and run validation. Validation errors from to_python and validate are propagated. The correct value is returned if no error is raised. """ value = self.to_python(value) self.validate(value, model_instance) self.run_validators(value) return value def db_type(self, connection): """ Returns the database column data type for this field, for the provided connection. """ # The default implementation of this method looks at the # backend-specific data_types dictionary, looking up the field by its # "internal type". # # A Field class can implement the get_internal_type() method to specify # which *preexisting* Django Field class it's most similar to -- i.e., # a custom field might be represented by a TEXT column type, which is # the same as the TextField Django field type, which means the custom # field's get_internal_type() returns 'TextField'. # # But the limitation of the get_internal_type() / data_types approach # is that it cannot handle database column types that aren't already # mapped to one of the built-in Django field types. In this case, you # can implement db_type() instead of get_internal_type() to specify # exactly which wacky database column type you want to use. data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_") try: return connection.data_types[self.get_internal_type()] % data except KeyError: return None def db_parameters(self, connection): """ Extension of db_type(), providing a range of different return values (type, checks). This will look at db_type(), allowing custom model fields to override it. """ data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_") type_string = self.db_type(connection) try: check_string = connection.data_type_check_constraints[self.get_internal_type()] % data except KeyError: check_string = None return { "type": type_string, "check": check_string, } def db_type_suffix(self, connection): return connection.data_types_suffix.get(self.get_internal_type()) def get_db_converters(self, connection): if hasattr(self, 'from_db_value'): return [self.from_db_value] return [] @property def unique(self): return self._unique or self.primary_key def set_attributes_from_name(self, name): if not self.name: self.name = name self.attname, self.column = self.get_attname_column() self.concrete = self.column is not None if self.verbose_name is None and self.name: self.verbose_name = self.name.replace('_', ' ') def contribute_to_class(self, cls, name, virtual_only=False): self.set_attributes_from_name(name) self.model = cls if virtual_only: cls._meta.add_field(self, virtual=True) else: cls._meta.add_field(self) if self.choices: setattr(cls, 'get_%s_display' % self.name, curry(cls._get_FIELD_display, field=self)) def get_attname(self): return self.name def get_attname_column(self): attname = self.get_attname() column = self.db_column or attname return attname, column def get_cache_name(self): return '_%s_cache' % self.name def get_internal_type(self): return self.__class__.__name__ def pre_save(self, model_instance, add): """ Returns field's value just before saving. """ return getattr(model_instance, self.attname) def get_prep_value(self, value): """ Perform preliminary non-db specific value checks and conversions. """ if isinstance(value, Promise): value = value._proxy____cast() return value def get_db_prep_value(self, value, connection, prepared=False): """Returns field's value prepared for interacting with the database backend. Used by the default implementations of ``get_db_prep_save``and `get_db_prep_lookup``` """ if not prepared: value = self.get_prep_value(value) return value def get_db_prep_save(self, value, connection): """ Returns field's value prepared for saving into a database. """ return self.get_db_prep_value(value, connection=connection, prepared=False) def get_prep_lookup(self, lookup_type, value): """ Perform preliminary non-db specific lookup checks and conversions """ if hasattr(value, '_prepare'): return value._prepare() if lookup_type in { 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith', 'month', 'day', 'week_day', 'hour', 'minute', 'second', 'isnull', 'search', 'regex', 'iregex', }: return value elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): return self.get_prep_value(value) elif lookup_type in ('range', 'in'): return [self.get_prep_value(v) for v in value] elif lookup_type == 'year': try: return int(value) except ValueError: raise ValueError("The __year lookup type requires an integer " "argument") return self.get_prep_value(value) def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False): """ Returns field's value prepared for database lookup. """ if not prepared: value = self.get_prep_lookup(lookup_type, value) prepared = True if hasattr(value, 'get_compiler'): value = value.get_compiler(connection=connection) if hasattr(value, 'as_sql') or hasattr(value, '_as_sql'): # If the value has a relabeled_clone method it means the # value will be handled later on. if hasattr(value, 'relabeled_clone'): return value if hasattr(value, 'as_sql'): sql, params = value.as_sql() else: sql, params = value._as_sql(connection=connection) return QueryWrapper(('(%s)' % sql), params) if lookup_type in ('month', 'day', 'week_day', 'hour', 'minute', 'second', 'search', 'regex', 'iregex', 'contains', 'icontains', 'iexact', 'startswith', 'endswith', 'istartswith', 'iendswith'): return [value] elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): return [self.get_db_prep_value(value, connection=connection, prepared=prepared)] elif lookup_type in ('range', 'in'): return [self.get_db_prep_value(v, connection=connection, prepared=prepared) for v in value] elif lookup_type == 'isnull': return [] elif lookup_type == 'year': if isinstance(self, DateTimeField): return connection.ops.year_lookup_bounds_for_datetime_field(value) elif isinstance(self, DateField): return connection.ops.year_lookup_bounds_for_date_field(value) else: return [value] # this isn't supposed to happen else: return [value] def has_default(self): """ Returns a boolean of whether this field has a default value. """ return self.default is not NOT_PROVIDED def get_default(self): """ Returns the default value for this field. """ if self.has_default(): if callable(self.default): return self.default() return self.default if (not self.empty_strings_allowed or (self.null and not connection.features.interprets_empty_strings_as_nulls)): return None return "" def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, limit_choices_to=None): """Returns choices with a default blank choices included, for use as SelectField choices for this field.""" blank_defined = False choices = list(self.choices) if self.choices else [] named_groups = choices and isinstance(choices[0][1], (list, tuple)) if not named_groups: for choice, __ in choices: if choice in ('', None): blank_defined = True break first_choice = (blank_choice if include_blank and not blank_defined else []) if self.choices: return first_choice + choices rel_model = self.rel.to limit_choices_to = limit_choices_to or self.get_limit_choices_to() if hasattr(self.rel, 'get_related_field'): lst = [(getattr(x, self.rel.get_related_field().attname), smart_text(x)) for x in rel_model._default_manager.complex_filter( limit_choices_to)] else: lst = [(x._get_pk_val(), smart_text(x)) for x in rel_model._default_manager.complex_filter( limit_choices_to)] return first_choice + lst def get_choices_default(self): return self.get_choices() def get_flatchoices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH): """ Returns flattened choices with a default blank choice included. """ first_choice = blank_choice if include_blank else [] return first_choice + list(self.flatchoices) def _get_val_from_obj(self, obj): if obj is not None: return getattr(obj, self.attname) else: return self.get_default() def value_to_string(self, obj): """ Returns a string value of this field from the passed obj. This is used by the serialization framework. """ return smart_text(self._get_val_from_obj(obj)) def _get_choices(self): if isinstance(self._choices, collections.Iterator): choices, self._choices = tee(self._choices) return choices else: return self._choices choices = property(_get_choices) def _get_flatchoices(self): """Flattened version of choices tuple.""" flat = [] for choice, value in self.choices: if isinstance(value, (list, tuple)): flat.extend(value) else: flat.append((choice, value)) return flat flatchoices = property(_get_flatchoices) def save_form_data(self, instance, data): setattr(instance, self.name, data) def formfield(self, form_class=None, choices_form_class=None, **kwargs): """ Returns a django.forms.Field instance for this database Field. """ defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} if self.has_default(): if callable(self.default): defaults['initial'] = self.default defaults['show_hidden_initial'] = True else: defaults['initial'] = self.get_default() if self.choices: # Fields with choices get special treatment. include_blank = (self.blank or not (self.has_default() or 'initial' in kwargs)) defaults['choices'] = self.get_choices(include_blank=include_blank) defaults['coerce'] = self.to_python if self.null: defaults['empty_value'] = None if choices_form_class is not None: form_class = choices_form_class else: form_class = forms.TypedChoiceField # Many of the subclass-specific formfield arguments (min_value, # max_value) don't apply for choice fields, so be sure to only pass # the values that TypedChoiceField will understand. for k in list(kwargs): if k not in ('coerce', 'empty_value', 'choices', 'required', 'widget', 'label', 'initial', 'help_text', 'error_messages', 'show_hidden_initial'): del kwargs[k] defaults.update(kwargs) if form_class is None: form_class = forms.CharField return form_class(**defaults) def value_from_object(self, obj): """ Returns the value of this field in the given model instance. """ return getattr(obj, self.attname) class AutoField(Field): description = _("Integer") empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be an integer."), } def __init__(self, *args, **kwargs): kwargs['blank'] = True super(AutoField, self).__init__(*args, **kwargs) def check(self, **kwargs): errors = super(AutoField, self).check(**kwargs) errors.extend(self._check_primary_key()) return errors def _check_primary_key(self): if not self.primary_key: return [ checks.Error( 'AutoFields must set primary_key=True.', hint=None, obj=self, id='fields.E100', ), ] else: return [] def deconstruct(self): name, path, args, kwargs = super(AutoField, self).deconstruct() del kwargs['blank'] kwargs['primary_key'] = True return name, path, args, kwargs def get_internal_type(self): return "AutoField" def to_python(self, value): if value is None: return value try: return int(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def validate(self, value, model_instance): pass def get_db_prep_value(self, value, connection, prepared=False): if not prepared: value = self.get_prep_value(value) value = connection.ops.validate_autopk_value(value) return value def get_prep_value(self, value): value = super(AutoField, self).get_prep_value(value) if value is None: return None return int(value) def contribute_to_class(self, cls, name, **kwargs): assert not cls._meta.has_auto_field, \ "A model can't have more than one AutoField." super(AutoField, self).contribute_to_class(cls, name, **kwargs) cls._meta.has_auto_field = True cls._meta.auto_field = self def formfield(self, **kwargs): return None class BooleanField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be either True or False."), } description = _("Boolean (Either True or False)") def __init__(self, *args, **kwargs): kwargs['blank'] = True super(BooleanField, self).__init__(*args, **kwargs) def check(self, **kwargs): errors = super(BooleanField, self).check(**kwargs) errors.extend(self._check_null(**kwargs)) return errors def _check_null(self, **kwargs): if getattr(self, 'null', False): return [ checks.Error( 'BooleanFields do not accept null values.', hint='Use a NullBooleanField instead.', obj=self, id='fields.E110', ) ] else: return [] def deconstruct(self): name, path, args, kwargs = super(BooleanField, self).deconstruct() del kwargs['blank'] return name, path, args, kwargs def get_internal_type(self): return "BooleanField" def to_python(self, value): if value in (True, False): # if value is 1 or 0 than it's equal to True or False, but we want # to return a true bool for semantic reasons. return bool(value) if value in ('t', 'True', '1'): return True if value in ('f', 'False', '0'): return False raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_prep_lookup(self, lookup_type, value): # Special-case handling for filters coming from a Web request (e.g. the # admin interface). Only works for scalar values (not lists). If you're # passing in a list, you might as well make things the right type when # constructing the list. if value in ('1', '0'): value = bool(int(value)) return super(BooleanField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): value = super(BooleanField, self).get_prep_value(value) if value is None: return None return bool(value) def formfield(self, **kwargs): # Unlike most fields, BooleanField figures out include_blank from # self.null instead of self.blank. if self.choices: include_blank = not (self.has_default() or 'initial' in kwargs) defaults = {'choices': self.get_choices(include_blank=include_blank)} else: defaults = {'form_class': forms.BooleanField} defaults.update(kwargs) return super(BooleanField, self).formfield(**defaults) class CharField(Field): description = _("String (up to %(max_length)s)") def __init__(self, *args, **kwargs): super(CharField, self).__init__(*args, **kwargs) self.validators.append(validators.MaxLengthValidator(self.max_length)) def check(self, **kwargs): errors = super(CharField, self).check(**kwargs) errors.extend(self._check_max_length_attribute(**kwargs)) return errors def _check_max_length_attribute(self, **kwargs): try: max_length = int(self.max_length) if max_length <= 0: raise ValueError() except TypeError: return [ checks.Error( "CharFields must define a 'max_length' attribute.", hint=None, obj=self, id='fields.E120', ) ] except ValueError: return [ checks.Error( "'max_length' must be a positive integer.", hint=None, obj=self, id='fields.E121', ) ] else: return [] def get_internal_type(self): return "CharField" def to_python(self, value): if isinstance(value, six.string_types) or value is None: return value return smart_text(value) def get_prep_value(self, value): value = super(CharField, self).get_prep_value(value) return self.to_python(value) def formfield(self, **kwargs): # Passing max_length to forms.CharField means that the value's length # will be validated twice. This is considered acceptable since we want # the value in the form field (to pass into widget for example). defaults = {'max_length': self.max_length} defaults.update(kwargs) return super(CharField, self).formfield(**defaults) # TODO: Maybe move this into contrib, because it's specialized. class CommaSeparatedIntegerField(CharField): default_validators = [validators.validate_comma_separated_integer_list] description = _("Comma-separated integers") def formfield(self, **kwargs): defaults = { 'error_messages': { 'invalid': _('Enter only digits separated by commas.'), } } defaults.update(kwargs) return super(CommaSeparatedIntegerField, self).formfield(**defaults) class DateTimeCheckMixin(object): def check(self, **kwargs): errors = super(DateTimeCheckMixin, self).check(**kwargs) errors.extend(self._check_mutually_exclusive_options()) errors.extend(self._check_fix_default_value()) return errors def _check_mutually_exclusive_options(self): # auto_now, auto_now_add, and default are mutually exclusive # options. The use of more than one of these options together # will trigger an Error mutually_exclusive_options = [self.auto_now_add, self.auto_now, self.has_default()] enabled_options = [option not in (None, False) for option in mutually_exclusive_options].count(True) if enabled_options > 1: return [ checks.Error( "The options auto_now, auto_now_add, and default " "are mutually exclusive. Only one of these options " "may be present.", hint=None, obj=self, id='fields.E160', ) ] else: return [] def _check_fix_default_value(self): return [] class DateField(DateTimeCheckMixin, Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid date format. It must be " "in YYYY-MM-DD format."), 'invalid_date': _("'%(value)s' value has the correct format (YYYY-MM-DD) " "but it is an invalid date."), } description = _("Date (without time)") def __init__(self, verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs): self.auto_now, self.auto_now_add = auto_now, auto_now_add if auto_now or auto_now_add: kwargs['editable'] = False kwargs['blank'] = True super(DateField, self).__init__(verbose_name, name, **kwargs) def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): now = timezone.make_naive(now, timezone.utc) value = self.default if isinstance(value, datetime.datetime): if not timezone.is_naive(value): value = timezone.make_naive(value, timezone.utc) value = value.date() elif isinstance(value, datetime.date): # Nothing to do, as dates don't have tz information pass else: # No explicit date / datetime value -- no checks necessary return [] offset = datetime.timedelta(days=1) lower = (now - offset).date() upper = (now + offset).date() if lower <= value <= upper: return [ checks.Warning( 'Fixed default value provided.', hint='It seems you set a fixed date / time / datetime ' 'value as default for this field. This may not be ' 'what you want. If you want to have the current date ' 'as default, use `django.utils.timezone.now`', obj=self, id='fields.W161', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(DateField, self).deconstruct() if self.auto_now: kwargs['auto_now'] = True if self.auto_now_add: kwargs['auto_now_add'] = True if self.auto_now or self.auto_now_add: del kwargs['editable'] del kwargs['blank'] return name, path, args, kwargs def get_internal_type(self): return "DateField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.datetime): if settings.USE_TZ and timezone.is_aware(value): # Convert aware datetimes to the default time zone # before casting them to dates (#17742). default_timezone = timezone.get_default_timezone() value = timezone.make_naive(value, default_timezone) return value.date() if isinstance(value, datetime.date): return value try: parsed = parse_date(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_date'], code='invalid_date', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = datetime.date.today() setattr(model_instance, self.attname, value) return value else: return super(DateField, self).pre_save(model_instance, add) def contribute_to_class(self, cls, name, **kwargs): super(DateField, self).contribute_to_class(cls, name, **kwargs) if not self.null: setattr(cls, 'get_next_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=True)) setattr(cls, 'get_previous_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=False)) def get_prep_lookup(self, lookup_type, value): # For dates lookups, convert the value to an int # so the database backend always sees a consistent type. if lookup_type in ('month', 'day', 'week_day', 'hour', 'minute', 'second'): return int(value) return super(DateField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): value = super(DateField, self).get_prep_value(value) return self.to_python(value) def get_db_prep_value(self, value, connection, prepared=False): # Casts dates into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_date(value) def value_to_string(self, obj): val = self._get_val_from_obj(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.DateField} defaults.update(kwargs) return super(DateField, self).formfield(**defaults) class DateTimeField(DateField): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format."), 'invalid_date': _("'%(value)s' value has the correct format " "(YYYY-MM-DD) but it is an invalid date."), 'invalid_datetime': _("'%(value)s' value has the correct format " "(YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) " "but it is an invalid date/time."), } description = _("Date (with time)") # __init__ is inherited from DateField def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): now = timezone.make_naive(now, timezone.utc) value = self.default if isinstance(value, datetime.datetime): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset upper = now + second_offset if timezone.is_aware(value): value = timezone.make_naive(value, timezone.utc) elif isinstance(value, datetime.date): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset lower = datetime.datetime(lower.year, lower.month, lower.day) upper = now + second_offset upper = datetime.datetime(upper.year, upper.month, upper.day) value = datetime.datetime(value.year, value.month, value.day) else: # No explicit date / datetime value -- no checks necessary return [] if lower <= value <= upper: return [ checks.Warning( 'Fixed default value provided.', hint='It seems you set a fixed date / time / datetime ' 'value as default for this field. This may not be ' 'what you want. If you want to have the current date ' 'as default, use `django.utils.timezone.now`', obj=self, id='fields.W161', ) ] return [] def get_internal_type(self): return "DateTimeField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.datetime): return value if isinstance(value, datetime.date): value = datetime.datetime(value.year, value.month, value.day) if settings.USE_TZ: # For backwards compatibility, interpret naive datetimes in # local time. This won't work during DST change, but we can't # do much about it, so we let the exceptions percolate up the # call stack. warnings.warn("DateTimeField %s.%s received a naive datetime " "(%s) while time zone support is active." % (self.model.__name__, self.name, value), RuntimeWarning) default_timezone = timezone.get_default_timezone() value = timezone.make_aware(value, default_timezone) return value try: parsed = parse_datetime(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_datetime'], code='invalid_datetime', params={'value': value}, ) try: parsed = parse_date(value) if parsed is not None: return datetime.datetime(parsed.year, parsed.month, parsed.day) except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_date'], code='invalid_date', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = timezone.now() setattr(model_instance, self.attname, value) return value else: return super(DateTimeField, self).pre_save(model_instance, add) # contribute_to_class is inherited from DateField, it registers # get_next_by_FOO and get_prev_by_FOO # get_prep_lookup is inherited from DateField def get_prep_value(self, value): value = super(DateTimeField, self).get_prep_value(value) value = self.to_python(value) if value is not None and settings.USE_TZ and timezone.is_naive(value): # For backwards compatibility, interpret naive datetimes in local # time. This won't work during DST change, but we can't do much # about it, so we let the exceptions percolate up the call stack. try: name = '%s.%s' % (self.model.__name__, self.name) except AttributeError: name = '(unbound)' warnings.warn("DateTimeField %s received a naive datetime (%s)" " while time zone support is active." % (name, value), RuntimeWarning) default_timezone = timezone.get_default_timezone() value = timezone.make_aware(value, default_timezone) return value def get_db_prep_value(self, value, connection, prepared=False): # Casts datetimes into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_datetime(value) def value_to_string(self, obj): val = self._get_val_from_obj(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.DateTimeField} defaults.update(kwargs) return super(DateTimeField, self).formfield(**defaults) class DecimalField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be a decimal number."), } description = _("Decimal number") def __init__(self, verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs): self.max_digits, self.decimal_places = max_digits, decimal_places super(DecimalField, self).__init__(verbose_name, name, **kwargs) def check(self, **kwargs): errors = super(DecimalField, self).check(**kwargs) digits_errors = self._check_decimal_places() digits_errors.extend(self._check_max_digits()) if not digits_errors: errors.extend(self._check_decimal_places_and_max_digits(**kwargs)) else: errors.extend(digits_errors) return errors def _check_decimal_places(self): try: decimal_places = int(self.decimal_places) if decimal_places < 0: raise ValueError() except TypeError: return [ checks.Error( "DecimalFields must define a 'decimal_places' attribute.", hint=None, obj=self, id='fields.E130', ) ] except ValueError: return [ checks.Error( "'decimal_places' must be a non-negative integer.", hint=None, obj=self, id='fields.E131', ) ] else: return [] def _check_max_digits(self): try: max_digits = int(self.max_digits) if max_digits <= 0: raise ValueError() except TypeError: return [ checks.Error( "DecimalFields must define a 'max_digits' attribute.", hint=None, obj=self, id='fields.E132', ) ] except ValueError: return [ checks.Error( "'max_digits' must be a positive integer.", hint=None, obj=self, id='fields.E133', ) ] else: return [] def _check_decimal_places_and_max_digits(self, **kwargs): if int(self.decimal_places) > int(self.max_digits): return [ checks.Error( "'max_digits' must be greater or equal to 'decimal_places'.", hint=None, obj=self, id='fields.E134', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(DecimalField, self).deconstruct() if self.max_digits is not None: kwargs['max_digits'] = self.max_digits if self.decimal_places is not None: kwargs['decimal_places'] = self.decimal_places return name, path, args, kwargs def get_internal_type(self): return "DecimalField" def to_python(self, value): if value is None: return value try: return decimal.Decimal(value) except decimal.InvalidOperation: raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def _format(self, value): if isinstance(value, six.string_types): return value else: return self.format_number(value) def format_number(self, value): """ Formats a number into a string with the requisite number of digits and decimal places. """ # Method moved to django.db.backends.utils. # # It is preserved because it is used by the oracle backend # (django.db.backends.oracle.query), and also for # backwards-compatibility with any external code which may have used # this method. from django.db.backends import utils return utils.format_number(value, self.max_digits, self.decimal_places) def get_db_prep_save(self, value, connection): return connection.ops.value_to_db_decimal(self.to_python(value), self.max_digits, self.decimal_places) def get_prep_value(self, value): value = super(DecimalField, self).get_prep_value(value) return self.to_python(value) def formfield(self, **kwargs): defaults = { 'max_digits': self.max_digits, 'decimal_places': self.decimal_places, 'form_class': forms.DecimalField, } defaults.update(kwargs) return super(DecimalField, self).formfield(**defaults) class DurationField(Field): """Stores timedelta objects. Uses interval on postgres, INVERAL DAY TO SECOND on Oracle, and bigint of microseconds on other databases. """ empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "[DD] [HH:[MM:]]ss[.uuuuuu] format.") } description = _("Duration") def get_internal_type(self): return "DurationField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.timedelta): return value try: parsed = parse_duration(value) except ValueError: pass else: if parsed is not None: return parsed raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_db_prep_value(self, value, connection, prepared=False): if connection.features.has_native_duration_field: return value if value is None: return None return value.total_seconds() * 1000000 def get_db_converters(self, connection): converters = [] if not connection.features.has_native_duration_field: converters.append(connection.ops.convert_durationfield_value) return converters + super(DurationField, self).get_db_converters(connection) def value_to_string(self, obj): val = self._get_val_from_obj(obj) return '' if val is None else duration_string(val) def formfield(self, **kwargs): defaults = { 'form_class': forms.DurationField, } defaults.update(kwargs) return super(DurationField, self).formfield(**defaults) class EmailField(CharField): default_validators = [validators.validate_email] description = _("Email address") def __init__(self, *args, **kwargs): # max_length=254 to be compliant with RFCs 3696 and 5321 kwargs['max_length'] = kwargs.get('max_length', 254) super(EmailField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(EmailField, self).deconstruct() # We do not exclude max_length if it matches default as we want to change # the default in future. return name, path, args, kwargs def formfield(self, **kwargs): # As with CharField, this will cause email validation to be performed # twice. defaults = { 'form_class': forms.EmailField, } defaults.update(kwargs) return super(EmailField, self).formfield(**defaults) class FilePathField(Field): description = _("File path") def __init__(self, verbose_name=None, name=None, path='', match=None, recursive=False, allow_files=True, allow_folders=False, **kwargs): self.path, self.match, self.recursive = path, match, recursive self.allow_files, self.allow_folders = allow_files, allow_folders kwargs['max_length'] = kwargs.get('max_length', 100) super(FilePathField, self).__init__(verbose_name, name, **kwargs) def check(self, **kwargs): errors = super(FilePathField, self).check(**kwargs) errors.extend(self._check_allowing_files_or_folders(**kwargs)) return errors def _check_allowing_files_or_folders(self, **kwargs): if not self.allow_files and not self.allow_folders: return [ checks.Error( "FilePathFields must have either 'allow_files' or 'allow_folders' set to True.", hint=None, obj=self, id='fields.E140', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(FilePathField, self).deconstruct() if self.path != '': kwargs['path'] = self.path if self.match is not None: kwargs['match'] = self.match if self.recursive is not False: kwargs['recursive'] = self.recursive if self.allow_files is not True: kwargs['allow_files'] = self.allow_files if self.allow_folders is not False: kwargs['allow_folders'] = self.allow_folders if kwargs.get("max_length", None) == 100: del kwargs["max_length"] return name, path, args, kwargs def get_prep_value(self, value): value = super(FilePathField, self).get_prep_value(value) if value is None: return None return six.text_type(value) def formfield(self, **kwargs): defaults = { 'path': self.path, 'match': self.match, 'recursive': self.recursive, 'form_class': forms.FilePathField, 'allow_files': self.allow_files, 'allow_folders': self.allow_folders, } defaults.update(kwargs) return super(FilePathField, self).formfield(**defaults) def get_internal_type(self): return "FilePathField" class FloatField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be a float."), } description = _("Floating point number") def get_prep_value(self, value): value = super(FloatField, self).get_prep_value(value) if value is None: return None return float(value) def get_internal_type(self): return "FloatField" def to_python(self, value): if value is None: return value try: return float(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def formfield(self, **kwargs): defaults = {'form_class': forms.FloatField} defaults.update(kwargs) return super(FloatField, self).formfield(**defaults) class IntegerField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be an integer."), } description = _("Integer") def check(self, **kwargs): errors = super(IntegerField, self).check(**kwargs) errors.extend(self._check_max_length_warning()) return errors def _check_max_length_warning(self): if self.max_length is not None: return [ checks.Warning( "'max_length' is ignored when used with IntegerField", hint="Remove 'max_length' from field", obj=self, id='fields.W122', ) ] return [] @cached_property def validators(self): # These validators can't be added at field initialization time since # they're based on values retrieved from `connection`. range_validators = [] internal_type = self.get_internal_type() min_value, max_value = connection.ops.integer_field_range(internal_type) if min_value is not None: range_validators.append(validators.MinValueValidator(min_value)) if max_value is not None: range_validators.append(validators.MaxValueValidator(max_value)) return super(IntegerField, self).validators + range_validators def get_prep_value(self, value): value = super(IntegerField, self).get_prep_value(value) if value is None: return None return int(value) def get_prep_lookup(self, lookup_type, value): if ((lookup_type == 'gte' or lookup_type == 'lt') and isinstance(value, float)): value = math.ceil(value) return super(IntegerField, self).get_prep_lookup(lookup_type, value) def get_internal_type(self): return "IntegerField" def to_python(self, value): if value is None: return value try: return int(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def formfield(self, **kwargs): defaults = {'form_class': forms.IntegerField} defaults.update(kwargs) return super(IntegerField, self).formfield(**defaults) class BigIntegerField(IntegerField): empty_strings_allowed = False description = _("Big (8 byte) integer") MAX_BIGINT = 9223372036854775807 def get_internal_type(self): return "BigIntegerField" def formfield(self, **kwargs): defaults = {'min_value': -BigIntegerField.MAX_BIGINT - 1, 'max_value': BigIntegerField.MAX_BIGINT} defaults.update(kwargs) return super(BigIntegerField, self).formfield(**defaults) class IPAddressField(Field): empty_strings_allowed = False description = _("IPv4 address") system_check_deprecated_details = { 'msg': ( 'IPAddressField has been deprecated. Support for it (except in ' 'historical migrations) will be removed in Django 1.9.' ), 'hint': 'Use GenericIPAddressField instead.', 'id': 'fields.W900', } def __init__(self, *args, **kwargs): kwargs['max_length'] = 15 super(IPAddressField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(IPAddressField, self).deconstruct() del kwargs['max_length'] return name, path, args, kwargs def get_prep_value(self, value): value = super(IPAddressField, self).get_prep_value(value) if value is None: return None return six.text_type(value) def get_internal_type(self): return "IPAddressField" def formfield(self, **kwargs): defaults = {'form_class': forms.IPAddressField} defaults.update(kwargs) return super(IPAddressField, self).formfield(**defaults) class GenericIPAddressField(Field): empty_strings_allowed = False description = _("IP address") default_error_messages = {} def __init__(self, verbose_name=None, name=None, protocol='both', unpack_ipv4=False, *args, **kwargs): self.unpack_ipv4 = unpack_ipv4 self.protocol = protocol self.default_validators, invalid_error_message = \ validators.ip_address_validators(protocol, unpack_ipv4) self.default_error_messages['invalid'] = invalid_error_message kwargs['max_length'] = 39 super(GenericIPAddressField, self).__init__(verbose_name, name, *args, **kwargs) def check(self, **kwargs): errors = super(GenericIPAddressField, self).check(**kwargs) errors.extend(self._check_blank_and_null_values(**kwargs)) return errors def _check_blank_and_null_values(self, **kwargs): if not getattr(self, 'null', False) and getattr(self, 'blank', False): return [ checks.Error( ('GenericIPAddressFields cannot have blank=True if null=False, ' 'as blank values are stored as nulls.'), hint=None, obj=self, id='fields.E150', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(GenericIPAddressField, self).deconstruct() if self.unpack_ipv4 is not False: kwargs['unpack_ipv4'] = self.unpack_ipv4 if self.protocol != "both": kwargs['protocol'] = self.protocol if kwargs.get("max_length", None) == 39: del kwargs['max_length'] return name, path, args, kwargs def get_internal_type(self): return "GenericIPAddressField" def to_python(self, value): if value and ':' in value: return clean_ipv6_address(value, self.unpack_ipv4, self.error_messages['invalid']) return value def get_db_prep_value(self, value, connection, prepared=False): if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_ipaddress(value) def get_prep_value(self, value): value = super(GenericIPAddressField, self).get_prep_value(value) if value is None: return None if value and ':' in value: try: return clean_ipv6_address(value, self.unpack_ipv4) except exceptions.ValidationError: pass return six.text_type(value) def formfield(self, **kwargs): defaults = { 'protocol': self.protocol, 'form_class': forms.GenericIPAddressField, } defaults.update(kwargs) return super(GenericIPAddressField, self).formfield(**defaults) class NullBooleanField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be either None, True or False."), } description = _("Boolean (Either True, False or None)") def __init__(self, *args, **kwargs): kwargs['null'] = True kwargs['blank'] = True super(NullBooleanField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(NullBooleanField, self).deconstruct() del kwargs['null'] del kwargs['blank'] return name, path, args, kwargs def get_internal_type(self): return "NullBooleanField" def to_python(self, value): if value is None: return None if value in (True, False): return bool(value) if value in ('None',): return None if value in ('t', 'True', '1'): return True if value in ('f', 'False', '0'): return False raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_prep_lookup(self, lookup_type, value): # Special-case handling for filters coming from a Web request (e.g. the # admin interface). Only works for scalar values (not lists). If you're # passing in a list, you might as well make things the right type when # constructing the list. if value in ('1', '0'): value = bool(int(value)) return super(NullBooleanField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): value = super(NullBooleanField, self).get_prep_value(value) if value is None: return None return bool(value) def formfield(self, **kwargs): defaults = { 'form_class': forms.NullBooleanField, 'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} defaults.update(kwargs) return super(NullBooleanField, self).formfield(**defaults) class PositiveIntegerField(IntegerField): description = _("Positive integer") def get_internal_type(self): return "PositiveIntegerField" def formfield(self, **kwargs): defaults = {'min_value': 0} defaults.update(kwargs) return super(PositiveIntegerField, self).formfield(**defaults) class PositiveSmallIntegerField(IntegerField): description = _("Positive small integer") def get_internal_type(self): return "PositiveSmallIntegerField" def formfield(self, **kwargs): defaults = {'min_value': 0} defaults.update(kwargs) return super(PositiveSmallIntegerField, self).formfield(**defaults) class SlugField(CharField): default_validators = [validators.validate_slug] description = _("Slug (up to %(max_length)s)") def __init__(self, *args, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 50) # Set db_index=True unless it's been set manually. if 'db_index' not in kwargs: kwargs['db_index'] = True super(SlugField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(SlugField, self).deconstruct() if kwargs.get("max_length", None) == 50: del kwargs['max_length'] if self.db_index is False: kwargs['db_index'] = False else: del kwargs['db_index'] return name, path, args, kwargs def get_internal_type(self): return "SlugField" def formfield(self, **kwargs): defaults = {'form_class': forms.SlugField} defaults.update(kwargs) return super(SlugField, self).formfield(**defaults) class SmallIntegerField(IntegerField): description = _("Small integer") def get_internal_type(self): return "SmallIntegerField" class TextField(Field): description = _("Text") def get_internal_type(self): return "TextField" def get_prep_value(self, value): value = super(TextField, self).get_prep_value(value) if isinstance(value, six.string_types) or value is None: return value return smart_text(value) def formfield(self, **kwargs): # Passing max_length to forms.CharField means that the value's length # will be validated twice. This is considered acceptable since we want # the value in the form field (to pass into widget for example). defaults = {'max_length': self.max_length, 'widget': forms.Textarea} defaults.update(kwargs) return super(TextField, self).formfield(**defaults) class TimeField(DateTimeCheckMixin, Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "HH:MM[:ss[.uuuuuu]] format."), 'invalid_time': _("'%(value)s' value has the correct format " "(HH:MM[:ss[.uuuuuu]]) but it is an invalid time."), } description = _("Time") def __init__(self, verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs): self.auto_now, self.auto_now_add = auto_now, auto_now_add if auto_now or auto_now_add: kwargs['editable'] = False kwargs['blank'] = True super(TimeField, self).__init__(verbose_name, name, **kwargs) def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): now = timezone.make_naive(now, timezone.utc) value = self.default if isinstance(value, datetime.datetime): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset upper = now + second_offset if timezone.is_aware(value): value = timezone.make_naive(value, timezone.utc) elif isinstance(value, datetime.time): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset upper = now + second_offset value = datetime.datetime.combine(now.date(), value) if timezone.is_aware(value): value = timezone.make_naive(value, timezone.utc).time() else: # No explicit time / datetime value -- no checks necessary return [] if lower <= value <= upper: return [ checks.Warning( 'Fixed default value provided.', hint='It seems you set a fixed date / time / datetime ' 'value as default for this field. This may not be ' 'what you want. If you want to have the current date ' 'as default, use `django.utils.timezone.now`', obj=self, id='fields.W161', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(TimeField, self).deconstruct() if self.auto_now is not False: kwargs["auto_now"] = self.auto_now if self.auto_now_add is not False: kwargs["auto_now_add"] = self.auto_now_add if self.auto_now or self.auto_now_add: del kwargs['blank'] del kwargs['editable'] return name, path, args, kwargs def get_internal_type(self): return "TimeField" def to_python(self, value): if value is None: return None if isinstance(value, datetime.time): return value if isinstance(value, datetime.datetime): # Not usually a good idea to pass in a datetime here (it loses # information), but this can be a side-effect of interacting with a # database backend (e.g. Oracle), so we'll be accommodating. return value.time() try: parsed = parse_time(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_time'], code='invalid_time', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = datetime.datetime.now().time() setattr(model_instance, self.attname, value) return value else: return super(TimeField, self).pre_save(model_instance, add) def get_prep_value(self, value): value = super(TimeField, self).get_prep_value(value) return self.to_python(value) def get_db_prep_value(self, value, connection, prepared=False): # Casts times into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_time(value) def value_to_string(self, obj): val = self._get_val_from_obj(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.TimeField} defaults.update(kwargs) return super(TimeField, self).formfield(**defaults) class URLField(CharField): default_validators = [validators.URLValidator()] description = _("URL") def __init__(self, verbose_name=None, name=None, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 200) super(URLField, self).__init__(verbose_name, name, **kwargs) def deconstruct(self): name, path, args, kwargs = super(URLField, self).deconstruct() if kwargs.get("max_length", None) == 200: del kwargs['max_length'] return name, path, args, kwargs def formfield(self, **kwargs): # As with CharField, this will cause URL validation to be performed # twice. defaults = { 'form_class': forms.URLField, } defaults.update(kwargs) return super(URLField, self).formfield(**defaults) class BinaryField(Field): description = _("Raw binary data") empty_values = [None, b''] def __init__(self, *args, **kwargs): kwargs['editable'] = False super(BinaryField, self).__init__(*args, **kwargs) if self.max_length is not None: self.validators.append(validators.MaxLengthValidator(self.max_length)) def deconstruct(self): name, path, args, kwargs = super(BinaryField, self).deconstruct() del kwargs['editable'] return name, path, args, kwargs def get_internal_type(self): return "BinaryField" def get_default(self): if self.has_default() and not callable(self.default): return self.default default = super(BinaryField, self).get_default() if default == '': return b'' return default def get_db_prep_value(self, value, connection, prepared=False): value = super(BinaryField, self).get_db_prep_value(value, connection, prepared) if value is not None: return connection.Database.Binary(value) return value def value_to_string(self, obj): """Binary data is serialized as base64""" return b64encode(force_bytes(self._get_val_from_obj(obj))).decode('ascii') def to_python(self, value): # If it's a string, it should be base64-encoded data if isinstance(value, six.text_type): return six.memoryview(b64decode(force_bytes(value))) return value class UUIDField(Field): default_error_messages = { 'invalid': _("'%(value)s' is not a valid UUID."), } description = 'Universally unique identifier' empty_strings_allowed = False def __init__(self, verbose_name=None, **kwargs): kwargs['max_length'] = 32 super(UUIDField, self).__init__(verbose_name, **kwargs) def deconstruct(self): name, path, args, kwargs = super(UUIDField, self).deconstruct() del kwargs['max_length'] return name, path, args, kwargs def get_internal_type(self): return "UUIDField" def get_db_prep_value(self, value, connection, prepared=False): if isinstance(value, six.string_types): value = uuid.UUID(value.replace('-', '')) if isinstance(value, uuid.UUID): if connection.features.has_native_uuid_field: return value return value.hex return value def to_python(self, value): if value and not isinstance(value, uuid.UUID): try: return uuid.UUID(value) except ValueError: raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) return value def formfield(self, **kwargs): defaults = { 'form_class': forms.UUIDField, } defaults.update(kwargs) return super(UUIDField, self).formfield(**defaults)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 2197, 199, 646, 6107, 199, 646, 3473, 199, 646, 5377, 199, 646, 3598, 199, 504, 1300, 772, 492, 330, 772, 2708, 12, 330, 772, 2143, 199, 504, 7975, 492, 1565, 69, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 14, 17438, 492, 849, 63, 17438, 12, 11828, 7521, 4256, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 492, 4967, 12, 14370, 12, 5920, 199, 504, 1639, 14, 1208, 14, 23004, 492, 7448, 4590, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 602, 12, 2198, 63, 2083, 12, 2198, 63, 521, 12, 2198, 63, 5553, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 12, 1094, 651, 12, 3141, 63, 7128, 12, 27724, 572, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 334, 7853, 63, 505, 12, 3542, 63, 505, 12, 3542, 63, 2394, 12, 272, 2366, 63, 18, 63, 2975, 63, 6490, 9, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 3633, 63, 4774, 22, 63, 1562, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 199, 199, 3, 3979, 314, 485, 2024, 909, 1990, 1824, 279, 1759, 12, 642, 1919, 1990, 12155, 370, 199, 3, 1639, 14, 1018, 14, 3924, 14, 2779, 365, 30403, 2348, 367, 8552, 7163, 199, 3, 12901, 14, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 221, 327, 20432, 199, 199, 3, 19503, 298, 4333, 26, 7020, 315, 1124, 504, 769, 891, 440, 282, 1059, 2, 1553, 2649, 63, 5955, 199, 3, 7704, 3520, 3326, 2649, 199, 363, 452, 363, 275, 359, 495, 8, 88, 9, 367, 671, 315, 334, 272, 283, 4378, 297, 283, 20438, 63, 22544, 63, 29019, 297, 283, 25175, 297, 283, 6636, 792, 297, 272, 283, 5036, 297, 283, 2183, 297, 283, 25732, 20727, 3901, 297, 283, 14071, 297, 272, 283, 4626, 297, 283, 15975, 297, 283, 13283, 792, 297, 283, 16577, 297, 283, 4699, 297, 272, 283, 792, 297, 283, 792, 7400, 297, 283, 14225, 792, 297, 283, 13019, 297, 272, 283, 9417, 26969, 297, 283, 26969, 297, 283, 3901, 297, 283, 4609, 63, 21403, 1149, 297, 272, 283, 29068, 297, 283, 8591, 297, 283, 25197, 297, 272, 283, 17315, 297, 283, 14640, 297, 283, 6254, 297, 283, 27115, 297, 283, 17363, 297, 272, 283, 8757, 792, 297, 199, 1874, 421, 199, 533, 9630, 8, 785, 304, 272, 986, 421, 199, 533, 2845, 63, 21403, 1149, 26, 272, 986, 199, 199, 3, 710, 1338, 370, 675, 367, 298, 2500, 2, 315, 9496, 7304, 14, 12823, 506, 11544, 370, 314, 1343, 199, 3, 402, 4750, 298, 4577, 2, 5548, 14, 199, 20438, 63, 22544, 63, 29019, 275, 3842, 5151, 298, 9960, 11323, 421, 199, 318, 485, 912, 63, 698, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 901, 63, 354, 304, 272, 372, 8686, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 10445, 2024, 14, 362, 63, 698, 8, 698, 63, 354, 9, 421, 199, 3, 437, 22885, 370, 5024, 2633, 26, 199, 3, 199, 3, 257, 627, 536, 26, 420, 710, 536, 402, 314, 901, 2013, 315, 314, 1402, 14, 199, 3, 257, 627, 15115, 354, 26, 257, 710, 2225, 370, 675, 641, 314, 1402, 909, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 354, 401, 871, 315, 314, 1930, 402, 481, 2692, 6340, 12, 2382, 2668, 344, 2, 365, 199, 3, 4483, 11544, 14, 199, 3, 257, 627, 1592, 63, 2301, 26, 710, 1592, 63, 2301, 2013, 315, 314, 1402, 334, 269, 488, 680, 199, 3, 257, 627, 2763, 26, 259, 710, 3050, 2763, 367, 642, 901, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 13651, 401, 871, 340, 1592, 63, 2301, 365, 2013, 14, 199, 3, 199, 3, 5495, 626, 1109, 21302, 83, 1338, 12, 503, 1630, 1163, 8336, 7645, 12, 1077, 675, 199, 3, 15115, 354, 14, 2104, 2893, 12, 642, 7545, 314, 5062, 790, 574, 402, 909, 298, 1113, 582, 199, 3, 199, 3, 258, 2519, 8, 1113, 12, 3999, 14, 2051, 14, 13651, 9, 199, 199, 318, 485, 1667, 8, 1618, 63, 1886, 304, 272, 892, 275, 9630, 342, 272, 892, 855, 533, 363, 275, 402, 63, 1886, 272, 372, 892, 421, 199, 32, 2923, 63, 7128, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 5024, 8, 7099, 7521, 4256, 304, 272, 408, 1563, 1021, 367, 1006, 901, 2943, 624, 339, 327, 29410, 2335, 3775, 2701, 3326, 27440, 14040, 1183, 787, 4370, 737, 314, 272, 327, 3050, 2166, 14, 272, 2701, 63, 5465, 63, 6541, 275, 715, 272, 2701, 63, 1459, 275, 769, 8, 11346, 14, 13993, 63, 15514, 9, 339, 327, 5723, 4426, 1924, 900, 282, 5024, 1256, 365, 2737, 14, 8051, 370, 8074, 1865, 14, 272, 327, 710, 2599, 63, 8782, 63, 5337, 365, 1202, 367, 1504, 626, 5634, 19796, 272, 327, 8491, 12, 7143, 63, 5337, 365, 1202, 367, 1006, 922, 13, 10085, 1504, 14, 272, 7143, 63, 5337, 275, 378, 272, 2599, 63, 8782, 63, 5337, 275, 446, 17, 272, 849, 63, 11346, 275, 942, 221, 327, 3758, 663, 402, 14370, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 63, 5095, 356, 4018, 1110, 2818, 585, 9, 82, 365, 440, 282, 1686, 7141, 8038, 267, 283, 2307, 356, 4018, 2765, 901, 3913, 506, 2973, 8038, 267, 283, 2500, 356, 4018, 2765, 901, 3913, 506, 4596, 8038, 267, 283, 3235, 356, 4018, 2840, 1238, 63, 354, 9, 83, 543, 642, 2818, 698, 63, 1302, 9, 83, 283, 490, 283, 14039 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 2197, 199, 646, 6107, 199, 646, 3473, 199, 646, 5377, 199, 646, 3598, 199, 504, 1300, 772, 492, 330, 772, 2708, 12, 330, 772, 2143, 199, 504, 7975, 492, 1565, 69, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 14, 17438, 492, 849, 63, 17438, 12, 11828, 7521, 4256, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 492, 4967, 12, 14370, 12, 5920, 199, 504, 1639, 14, 1208, 14, 23004, 492, 7448, 4590, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 602, 12, 2198, 63, 2083, 12, 2198, 63, 521, 12, 2198, 63, 5553, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 12, 1094, 651, 12, 3141, 63, 7128, 12, 27724, 572, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 334, 7853, 63, 505, 12, 3542, 63, 505, 12, 3542, 63, 2394, 12, 272, 2366, 63, 18, 63, 2975, 63, 6490, 9, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 3633, 63, 4774, 22, 63, 1562, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 199, 199, 3, 3979, 314, 485, 2024, 909, 1990, 1824, 279, 1759, 12, 642, 1919, 1990, 12155, 370, 199, 3, 1639, 14, 1018, 14, 3924, 14, 2779, 365, 30403, 2348, 367, 8552, 7163, 199, 3, 12901, 14, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 221, 327, 20432, 199, 199, 3, 19503, 298, 4333, 26, 7020, 315, 1124, 504, 769, 891, 440, 282, 1059, 2, 1553, 2649, 63, 5955, 199, 3, 7704, 3520, 3326, 2649, 199, 363, 452, 363, 275, 359, 495, 8, 88, 9, 367, 671, 315, 334, 272, 283, 4378, 297, 283, 20438, 63, 22544, 63, 29019, 297, 283, 25175, 297, 283, 6636, 792, 297, 272, 283, 5036, 297, 283, 2183, 297, 283, 25732, 20727, 3901, 297, 283, 14071, 297, 272, 283, 4626, 297, 283, 15975, 297, 283, 13283, 792, 297, 283, 16577, 297, 283, 4699, 297, 272, 283, 792, 297, 283, 792, 7400, 297, 283, 14225, 792, 297, 283, 13019, 297, 272, 283, 9417, 26969, 297, 283, 26969, 297, 283, 3901, 297, 283, 4609, 63, 21403, 1149, 297, 272, 283, 29068, 297, 283, 8591, 297, 283, 25197, 297, 272, 283, 17315, 297, 283, 14640, 297, 283, 6254, 297, 283, 27115, 297, 283, 17363, 297, 272, 283, 8757, 792, 297, 199, 1874, 421, 199, 533, 9630, 8, 785, 304, 272, 986, 421, 199, 533, 2845, 63, 21403, 1149, 26, 272, 986, 199, 199, 3, 710, 1338, 370, 675, 367, 298, 2500, 2, 315, 9496, 7304, 14, 12823, 506, 11544, 370, 314, 1343, 199, 3, 402, 4750, 298, 4577, 2, 5548, 14, 199, 20438, 63, 22544, 63, 29019, 275, 3842, 5151, 298, 9960, 11323, 421, 199, 318, 485, 912, 63, 698, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 901, 63, 354, 304, 272, 372, 8686, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 10445, 2024, 14, 362, 63, 698, 8, 698, 63, 354, 9, 421, 199, 3, 437, 22885, 370, 5024, 2633, 26, 199, 3, 199, 3, 257, 627, 536, 26, 420, 710, 536, 402, 314, 901, 2013, 315, 314, 1402, 14, 199, 3, 257, 627, 15115, 354, 26, 257, 710, 2225, 370, 675, 641, 314, 1402, 909, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 354, 401, 871, 315, 314, 1930, 402, 481, 2692, 6340, 12, 2382, 2668, 344, 2, 365, 199, 3, 4483, 11544, 14, 199, 3, 257, 627, 1592, 63, 2301, 26, 710, 1592, 63, 2301, 2013, 315, 314, 1402, 334, 269, 488, 680, 199, 3, 257, 627, 2763, 26, 259, 710, 3050, 2763, 367, 642, 901, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 13651, 401, 871, 340, 1592, 63, 2301, 365, 2013, 14, 199, 3, 199, 3, 5495, 626, 1109, 21302, 83, 1338, 12, 503, 1630, 1163, 8336, 7645, 12, 1077, 675, 199, 3, 15115, 354, 14, 2104, 2893, 12, 642, 7545, 314, 5062, 790, 574, 402, 909, 298, 1113, 582, 199, 3, 199, 3, 258, 2519, 8, 1113, 12, 3999, 14, 2051, 14, 13651, 9, 199, 199, 318, 485, 1667, 8, 1618, 63, 1886, 304, 272, 892, 275, 9630, 342, 272, 892, 855, 533, 363, 275, 402, 63, 1886, 272, 372, 892, 421, 199, 32, 2923, 63, 7128, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 5024, 8, 7099, 7521, 4256, 304, 272, 408, 1563, 1021, 367, 1006, 901, 2943, 624, 339, 327, 29410, 2335, 3775, 2701, 3326, 27440, 14040, 1183, 787, 4370, 737, 314, 272, 327, 3050, 2166, 14, 272, 2701, 63, 5465, 63, 6541, 275, 715, 272, 2701, 63, 1459, 275, 769, 8, 11346, 14, 13993, 63, 15514, 9, 339, 327, 5723, 4426, 1924, 900, 282, 5024, 1256, 365, 2737, 14, 8051, 370, 8074, 1865, 14, 272, 327, 710, 2599, 63, 8782, 63, 5337, 365, 1202, 367, 1504, 626, 5634, 19796, 272, 327, 8491, 12, 7143, 63, 5337, 365, 1202, 367, 1006, 922, 13, 10085, 1504, 14, 272, 7143, 63, 5337, 275, 378, 272, 2599, 63, 8782, 63, 5337, 275, 446, 17, 272, 849, 63, 11346, 275, 942, 221, 327, 3758, 663, 402, 14370, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 63, 5095, 356, 4018, 1110, 2818, 585, 9, 82, 365, 440, 282, 1686, 7141, 8038, 267, 283, 2307, 356, 4018, 2765, 901, 3913, 506, 2973, 8038, 267, 283, 2500, 356, 4018, 2765, 901, 3913, 506, 4596, 8038, 267, 283, 3235, 356, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
avilaton/sqlalchemy-continuum
tests/test_delete.py
5
1356
import sqlalchemy as sa from tests import TestCase class TestDelete(TestCase): def _delete(self): article = self.Article() article.name = u'Some article' article.content = u'Some content' self.session.add(article) self.session.commit() self.session.delete(article) self.session.commit() def test_stores_operation_type(self): self._delete() versions = self.session.query(self.ArticleVersion).all() assert versions[1].operation_type == 2 def test_creates_versions_on_delete(self): self._delete() versions = self.session.query(self.ArticleVersion).all() assert len(versions) == 2 assert versions[1].name == u'Some article' assert versions[1].content == u'Some content' class TestDeleteWithDeferredColumn(TestCase): def create_models(self): class TextItem(self.Model): __tablename__ = 'text_item' __versioned__ = {} id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) name = sa.orm.deferred(sa.Column(sa.Unicode(255))) self.TextItem = TextItem def test_insert_and_delete(self): item = self.TextItem() self.session.add(item) self.session.commit() self.session.delete(item) self.session.commit()
bsd-3-clause
[ 646, 8335, 465, 2937, 199, 504, 2295, 492, 7640, 421, 199, 533, 1379, 5392, 8, 1746, 304, 272, 347, 485, 1807, 8, 277, 304, 267, 9772, 275, 291, 14, 7221, 342, 267, 9772, 14, 354, 275, 399, 7, 7700, 9772, 7, 267, 9772, 14, 1317, 275, 399, 7, 7700, 1564, 7, 267, 291, 14, 1730, 14, 525, 8, 6934, 9, 267, 291, 14, 1730, 14, 3543, 342, 398, 291, 14, 1730, 14, 1807, 8, 6934, 9, 267, 291, 14, 1730, 14, 3543, 342, 339, 347, 511, 63, 18958, 63, 5735, 63, 466, 8, 277, 304, 267, 291, 423, 1807, 342, 267, 5459, 275, 291, 14, 1730, 14, 1131, 8, 277, 14, 7221, 3353, 680, 452, 342, 267, 702, 5459, 59, 17, 1055, 5735, 63, 466, 508, 499, 339, 347, 511, 63, 28219, 63, 6234, 63, 265, 63, 1807, 8, 277, 304, 267, 291, 423, 1807, 342, 267, 5459, 275, 291, 14, 1730, 14, 1131, 8, 277, 14, 7221, 3353, 680, 452, 342, 267, 702, 822, 8, 6234, 9, 508, 499, 267, 702, 5459, 59, 17, 1055, 354, 508, 399, 7, 7700, 9772, 7, 267, 702, 5459, 59, 17, 1055, 1317, 508, 399, 7, 7700, 1564, 7, 421, 199, 533, 1379, 5392, 3007, 9937, 4547, 8, 1746, 304, 272, 347, 1218, 63, 992, 8, 277, 304, 267, 1021, 4516, 2081, 8, 277, 14, 1685, 304, 288, 636, 10983, 363, 275, 283, 505, 63, 1053, 7, 288, 636, 24155, 363, 275, 1052, 288, 1305, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 32497, 29, 549, 12, 5062, 63, 498, 29, 549, 9, 288, 536, 275, 2937, 14, 1025, 14, 12116, 8, 2231, 14, 4547, 8, 2231, 14, 7087, 8, 2299, 1724, 398, 291, 14, 1872, 2081, 275, 4516, 2081, 339, 347, 511, 63, 3176, 63, 460, 63, 1807, 8, 277, 304, 267, 1242, 275, 291, 14, 1872, 2081, 342, 267, 291, 14, 1730, 14, 525, 8, 1053, 9, 267, 291, 14, 1730, 14, 3543, 342, 267, 291, 14, 1730, 14, 1807, 8, 1053, 9, 267, 291, 14, 1730, 14, 3543, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8335, 465, 2937, 199, 504, 2295, 492, 7640, 421, 199, 533, 1379, 5392, 8, 1746, 304, 272, 347, 485, 1807, 8, 277, 304, 267, 9772, 275, 291, 14, 7221, 342, 267, 9772, 14, 354, 275, 399, 7, 7700, 9772, 7, 267, 9772, 14, 1317, 275, 399, 7, 7700, 1564, 7, 267, 291, 14, 1730, 14, 525, 8, 6934, 9, 267, 291, 14, 1730, 14, 3543, 342, 398, 291, 14, 1730, 14, 1807, 8, 6934, 9, 267, 291, 14, 1730, 14, 3543, 342, 339, 347, 511, 63, 18958, 63, 5735, 63, 466, 8, 277, 304, 267, 291, 423, 1807, 342, 267, 5459, 275, 291, 14, 1730, 14, 1131, 8, 277, 14, 7221, 3353, 680, 452, 342, 267, 702, 5459, 59, 17, 1055, 5735, 63, 466, 508, 499, 339, 347, 511, 63, 28219, 63, 6234, 63, 265, 63, 1807, 8, 277, 304, 267, 291, 423, 1807, 342, 267, 5459, 275, 291, 14, 1730, 14, 1131, 8, 277, 14, 7221, 3353, 680, 452, 342, 267, 702, 822, 8, 6234, 9, 508, 499, 267, 702, 5459, 59, 17, 1055, 354, 508, 399, 7, 7700, 9772, 7, 267, 702, 5459, 59, 17, 1055, 1317, 508, 399, 7, 7700, 1564, 7, 421, 199, 533, 1379, 5392, 3007, 9937, 4547, 8, 1746, 304, 272, 347, 1218, 63, 992, 8, 277, 304, 267, 1021, 4516, 2081, 8, 277, 14, 1685, 304, 288, 636, 10983, 363, 275, 283, 505, 63, 1053, 7, 288, 636, 24155, 363, 275, 1052, 288, 1305, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 32497, 29, 549, 12, 5062, 63, 498, 29, 549, 9, 288, 536, 275, 2937, 14, 1025, 14, 12116, 8, 2231, 14, 4547, 8, 2231, 14, 7087, 8, 2299, 1724, 398, 291, 14, 1872, 2081, 275, 4516, 2081, 339, 347, 511, 63, 3176, 63, 460, 63, 1807, 8, 277, 304, 267, 1242, 275, 291, 14, 1872, 2081, 342, 267, 291, 14, 1730, 14, 525, 8, 1053, 9, 267, 291, 14, 1730, 14, 3543, 342, 267, 291, 14, 1730, 14, 1807, 8, 1053, 9, 267, 291, 14, 1730, 14, 3543, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
garyjyao1/ansible
lib/ansible/modules/core/cloud/digital_ocean/digital_ocean.py
121
14578
#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of Ansible # # Ansible 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 3 of the License, or # (at your option) any later version. # # Ansible 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: digital_ocean short_description: Create/delete a droplet/SSH_key in DigitalOcean description: - Create/delete a droplet in DigitalOcean and optionally wait for it to be 'running', or deploy an SSH key. version_added: "1.3" author: "Vincent Viallet (@zbal)" options: command: description: - Which target you want to operate on. default: droplet choices: ['droplet', 'ssh'] state: description: - Indicate desired state of the target. default: present choices: ['present', 'active', 'absent', 'deleted'] api_token: description: - DigitalOcean api token. id: description: - Numeric, the droplet id you want to operate on. name: description: - String, this is the name of the droplet - must be formatted by hostname rules, or the name of a SSH key. unique_name: description: - Bool, require unique hostnames. By default, DigitalOcean allows multiple hosts with the same name. Setting this to "yes" allows only one host per name. Useful for idempotence. version_added: "1.4" default: "no" choices: [ "yes", "no" ] size_id: description: - This is the slug of the size you would like the droplet created with. image_id: description: - This is the slug of the image you would like the droplet created with. region_id: description: - This is the slug of the region you would like your server to be created in. ssh_key_ids: description: - Optional, array of of SSH key (numeric) ID that you would like to be added to the server. virtio: description: - "Bool, turn on virtio driver in droplet for improved network and storage I/O." version_added: "1.4" default: "yes" choices: [ "yes", "no" ] private_networking: description: - "Bool, add an additional, private network interface to droplet for inter-droplet communication." version_added: "1.4" default: "no" choices: [ "yes", "no" ] backups_enabled: description: - Optional, Boolean, enables backups for your droplet. version_added: "1.6" default: "no" choices: [ "yes", "no" ] user_data: description: - opaque blob of data which is made available to the droplet version_added: "1.10" required: false default: None wait: description: - Wait for the droplet to be in state 'running' before returning. If wait is "no" an ip_address may not be returned. default: "yes" choices: [ "yes", "no" ] wait_timeout: description: - How long before wait gives up, in seconds. default: 300 ssh_pub_key: description: - The public SSH key you want to add to your account. notes: - Two environment variables can be used, DO_API_KEY and DO_API_TOKEN. They both refer to the v2 token. - As of Ansible 2.0, Version 2 of the DigitalOcean API is used. - As of Ansible 2.0, the above parameters were changed significantly. If you are running 1.9.x or earlier, please use C(ansible-doc digital_ocean) to view the correct parameters for your version. Dedicated web docs will be available in the near future for the stable branch. requirements: - "python >= 2.6" - dopy ''' EXAMPLES = ''' # Ensure a SSH key is present # If a key matches this name, will return the ssh key id and changed = False # If no existing key matches this name, a new key is created, the ssh key id is returned and changed = False - digital_ocean: > state=present command=ssh name=my_ssh_key ssh_pub_key='ssh-rsa AAAA...' api_token=XXX # Create a new Droplet # Will return the droplet details including the droplet id (used for idempotence) - digital_ocean: > state=present command=droplet name=mydroplet api_token=XXX size_id=2gb region_id=ams2 image_id=fedora-19-x64 wait_timeout=500 register: my_droplet - debug: msg="ID is {{ my_droplet.droplet.id }}" - debug: msg="IP is {{ my_droplet.droplet.ip_address }}" # Ensure a droplet is present # If droplet id already exist, will return the droplet details and changed = False # If no droplet matches the id, a new droplet will be created and the droplet details (including the new id) are returned, changed = True. - digital_ocean: > state=present command=droplet id=123 name=mydroplet api_token=XXX size_id=2gb region_id=ams2 image_id=fedora-19-x64 wait_timeout=500 # Create a droplet with ssh key # The ssh key id can be passed as argument at the creation of a droplet (see ssh_key_ids). # Several keys can be added to ssh_key_ids as id1,id2,id3 # The keys are used to connect as root to the droplet. - digital_ocean: > state=present ssh_key_ids=123,456 name=mydroplet api_token=XXX size_id=2gb region_id=ams2 image_id=fedora-19-x64 ''' import os import time from distutils.version import LooseVersion HAS_DOPY = True try: import dopy from dopy.manager import DoError, DoManager if LooseVersion(dopy.__version__) < LooseVersion('0.3.2'): HAS_DOPY = False except ImportError: HAS_DOPY = False class TimeoutError(DoError): def __init__(self, msg, id): super(TimeoutError, self).__init__(msg) self.id = id class JsonfyMixIn(object): def to_json(self): return self.__dict__ class Droplet(JsonfyMixIn): manager = None def __init__(self, droplet_json): self.status = 'new' self.__dict__.update(droplet_json) def is_powered_on(self): return self.status == 'active' def update_attr(self, attrs=None): if attrs: for k, v in attrs.iteritems(): setattr(self, k, v) else: json = self.manager.show_droplet(self.id) if json['ip_address']: self.update_attr(json) def power_on(self): assert self.status == 'off', 'Can only power on a closed one.' json = self.manager.power_on_droplet(self.id) self.update_attr(json) def ensure_powered_on(self, wait=True, wait_timeout=300): if self.is_powered_on(): return if self.status == 'off': # powered off self.power_on() if wait: end_time = time.time() + wait_timeout while time.time() < end_time: time.sleep(min(20, end_time - time.time())) self.update_attr() if self.is_powered_on(): if not self.ip_address: raise TimeoutError('No ip is found.', self.id) return raise TimeoutError('Wait for droplet running timeout', self.id) def destroy(self): return self.manager.destroy_droplet(self.id, scrub_data=True) @classmethod def setup(cls, api_token): cls.manager = DoManager(None, api_token, api_version=2) @classmethod def add(cls, name, size_id, image_id, region_id, ssh_key_ids=None, virtio=True, private_networking=False, backups_enabled=False, user_data=None): private_networking_lower = str(private_networking).lower() backups_enabled_lower = str(backups_enabled).lower() json = cls.manager.new_droplet(name, size_id, image_id, region_id, ssh_key_ids, virtio, private_networking_lower, backups_enabled_lower,user_data) droplet = cls(json) return droplet @classmethod def find(cls, id=None, name=None): if not id and not name: return False droplets = cls.list_all() # Check first by id. digital ocean requires that it be unique for droplet in droplets: if droplet.id == id: return droplet # Failing that, check by hostname. for droplet in droplets: if droplet.name == name: return droplet return False @classmethod def list_all(cls): json = cls.manager.all_active_droplets() return map(cls, json) class SSH(JsonfyMixIn): manager = None def __init__(self, ssh_key_json): self.__dict__.update(ssh_key_json) update_attr = __init__ def destroy(self): self.manager.destroy_ssh_key(self.id) return True @classmethod def setup(cls, api_token): cls.manager = DoManager(None, api_token, api_version=2) @classmethod def find(cls, name): if not name: return False keys = cls.list_all() for key in keys: if key.name == name: return key return False @classmethod def list_all(cls): json = cls.manager.all_ssh_keys() return map(cls, json) @classmethod def add(cls, name, key_pub): json = cls.manager.new_ssh_key(name, key_pub) return cls(json) def core(module): def getkeyordie(k): v = module.params[k] if v is None: module.fail_json(msg='Unable to load %s' % k) return v try: api_token = module.params['api_token'] or os.environ['DO_API_TOKEN'] or os.environ['DO_API_KEY'] except KeyError, e: module.fail_json(msg='Unable to load %s' % e.message) changed = True command = module.params['command'] state = module.params['state'] if command == 'droplet': Droplet.setup(api_token) if state in ('active', 'present'): # First, try to find a droplet by id. droplet = Droplet.find(id=module.params['id']) # If we couldn't find the droplet and the user is allowing unique # hostnames, then check to see if a droplet with the specified # hostname already exists. if not droplet and module.params['unique_name']: droplet = Droplet.find(name=getkeyordie('name')) # If both of those attempts failed, then create a new droplet. if not droplet: droplet = Droplet.add( name=getkeyordie('name'), size_id=getkeyordie('size_id'), image_id=getkeyordie('image_id'), region_id=getkeyordie('region_id'), ssh_key_ids=module.params['ssh_key_ids'], virtio=module.params['virtio'], private_networking=module.params['private_networking'], backups_enabled=module.params['backups_enabled'], user_data=module.params.get('user_data'), ) if droplet.is_powered_on(): changed = False droplet.ensure_powered_on( wait=getkeyordie('wait'), wait_timeout=getkeyordie('wait_timeout') ) module.exit_json(changed=changed, droplet=droplet.to_json()) elif state in ('absent', 'deleted'): # First, try to find a droplet by id. droplet = Droplet.find(module.params['id']) # If we couldn't find the droplet and the user is allowing unique # hostnames, then check to see if a droplet with the specified # hostname already exists. if not droplet and module.params['unique_name']: droplet = Droplet.find(name=getkeyordie('name')) if not droplet: module.exit_json(changed=False, msg='The droplet is not found.') event_json = droplet.destroy() module.exit_json(changed=True) elif command == 'ssh': SSH.setup(api_token) name = getkeyordie('name') if state in ('active', 'present'): key = SSH.find(name) if key: module.exit_json(changed=False, ssh_key=key.to_json()) key = SSH.add(name, getkeyordie('ssh_pub_key')) module.exit_json(changed=True, ssh_key=key.to_json()) elif state in ('absent', 'deleted'): key = SSH.find(name) if not key: module.exit_json(changed=False, msg='SSH key with the name of %s is not found.' % name) key.destroy() module.exit_json(changed=True) def main(): module = AnsibleModule( argument_spec = dict( command = dict(choices=['droplet', 'ssh'], default='droplet'), state = dict(choices=['active', 'present', 'absent', 'deleted'], default='present'), api_token = dict(aliases=['API_TOKEN'], no_log=True), name = dict(type='str'), size_id = dict(), image_id = dict(), region_id = dict(), ssh_key_ids = dict(type='list'), virtio = dict(type='bool', default='yes'), private_networking = dict(type='bool', default='no'), backups_enabled = dict(type='bool', default='no'), id = dict(aliases=['droplet_id'], type='int'), unique_name = dict(type='bool', default='no'), user_data = dict(default=None), wait = dict(type='bool', default=True), wait_timeout = dict(default=300, type='int'), ssh_pub_key = dict(type='str'), ), required_together = ( ['size_id', 'image_id', 'region_id'], ), mutually_exclusive = ( ['size_id', 'ssh_pub_key'], ['image_id', 'ssh_pub_key'], ['region_id', 'ssh_pub_key'], ), required_one_of = ( ['id', 'name'], ), ) if not HAS_DOPY: module.fail_json(msg='dopy >= 0.3.2 required for this module') try: core(module) except TimeoutError, e: module.fail_json(msg=str(e), id=e.id) except (DoError, Exception), e: module.fail_json(msg=str(e)) # import module snippets from ansible.module_utils.basic import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 20545, 63, 31737, 199, 3612, 63, 1802, 26, 2790, 15, 1807, 282, 5978, 2723, 15, 13716, 63, 498, 315, 29979, 47, 20867, 199, 1802, 26, 1362, 446, 2790, 15, 1807, 282, 5978, 2723, 315, 29979, 47, 20867, 436, 14190, 3618, 367, 652, 370, 506, 283, 5720, 297, 503, 12287, 376, 12027, 790, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 2, 199, 2502, 26, 298, 54, 262, 2946, 812, 2380, 2723, 8593, 90, 4982, 2924, 199, 1419, 26, 523, 1414, 26, 272, 1369, 26, 1362, 446, 26058, 1347, 1265, 2934, 370, 19218, 641, 14, 272, 849, 26, 5978, 2723, 272, 3415, 26, 788, 4824, 2723, 297, 283, 5510, 418, 523, 1174, 26, 272, 1369, 26, 1362, 446, 1010, 10188, 6387, 1174, 402, 314, 1347, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 2682, 297, 283, 5575, 297, 283, 6062, 418, 523, 2986, 63, 1418, 26, 272, 1369, 26, 1362, 446, 29979, 47, 20867, 2986, 1526, 14, 523, 1305, 26, 272, 1369, 26, 1362, 446, 19378, 12, 314, 5978, 2723, 1305, 1265, 2934, 370, 19218, 641, 14, 523, 536, 26, 272, 1369, 26, 1362, 446, 2624, 12, 642, 365, 314, 536, 402, 314, 5978, 2723, 446, 1471, 506, 7871, 701, 6246, 4713, 12, 503, 314, 536, 402, 282, 12027, 790, 14, 523, 3747, 63, 354, 26, 272, 1369, 26, 1362, 446, 19287, 12, 4409, 3747, 1591, 1247, 14, 221, 4885, 849, 12, 29979, 47, 20867, 6127, 3663, 7057, 543, 314, 2011, 536, 14, 221, 13510, 642, 370, 298, 5066, 2, 6127, 1454, 1373, 1591, 1126, 536, 14, 221, 18491, 367, 9979, 9613, 6692, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 849, 26, 298, 889, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 1568, 63, 344, 26, 272, 1369, 26, 1362, 446, 961, 365, 314, 8889, 402, 314, 1568, 1265, 3955, 2839, 314, 5978, 2723, 2737, 543, 14, 523, 1834, 63, 344, 26, 272, 1369, 26, 1362, 446, 961, 365, 314, 8889, 402, 314, 1834, 1265, 3955, 2839, 314, 5978, 2723, 2737, 543, 14, 523, 4897, 63, 344, 26, 272, 1369, 26, 1362, 446, 961, 365, 314, 8889, 402, 314, 4897, 1265, 3955, 2839, 2195, 1654, 370, 506, 2737, 315, 14, 523, 8635, 63, 498, 63, 1580, 26, 272, 1369, 26, 1362, 446, 4879, 12, 1625, 402, 402, 12027, 790, 334, 6677, 9, 2870, 626, 1265, 3955, 2839, 370, 506, 3483, 370, 314, 1654, 14, 523, 18291, 4538, 26, 272, 1369, 26, 1362, 446, 298, 10349, 12, 7485, 641, 18291, 4538, 5253, 315, 5978, 2723, 367, 1742, 26429, 2784, 436, 4887, 473, 15, 47, 2122, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 849, 26, 298, 5066, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 5726, 63, 1200, 316, 26, 272, 1369, 26, 1362, 446, 298, 10349, 12, 1050, 376, 4722, 12, 5726, 2784, 3217, 370, 5978, 2723, 367, 1640, 13, 4824, 2723, 23506, 2122, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 849, 26, 298, 889, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 6902, 83, 63, 3827, 26, 272, 1369, 26, 1362, 446, 4879, 12, 9411, 12, 22741, 6902, 83, 367, 2195, 5978, 2723, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 849, 26, 298, 889, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 922, 63, 576, 26, 272, 1369, 26, 489, 446, 15058, 9182, 402, 666, 1314, 365, 6326, 2808, 370, 314, 5978, 2723, 272, 1015, 63, 3270, 26, 298, 17, 14, 709, 2, 272, 1415, 26, 3055, 272, 849, 26, 488, 523, 3618, 26, 272, 1369, 26, 1362, 446, 13144, 367, 314, 5978, 2723, 370, 506, 315, 1174, 283, 5720, 7, 2544, 8152, 14, 221, 982, 3618, 365, 298, 889, 2, 376, 3384, 63, 1562, 1443, 440, 506, 2138, 14, 272, 849, 26, 298, 5066, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 3618, 63, 2593, 26, 272, 1369, 26, 1362, 446, 7494, 1846, 2544, 3618, 10557, 1536, 12, 315, 4696, 14, 272, 849, 26, 9601, 523, 8635, 63, 5645, 63, 498, 26, 272, 1369, 26, 1362, 446, 710, 4575, 12027, 790, 1265, 2934, 370, 1050, 370, 2195, 2933, 14, 199, 199, 5983, 26, 523, 446, 16853, 3734, 2860, 883, 506, 1202, 12, 3506, 63, 3735, 63, 3078, 436, 3506, 63, 3735, 63, 8803, 14, 9322, 3865, 10618, 370, 314, 373, 18, 1526, 14, 523, 446, 3709, 402, 2622, 499, 14, 16, 12, 3394, 499, 402, 314, 29979, 47, 20867, 3261, 365, 1202, 14, 523, 446, 3709, 402, 2622, 499, 14, 16, 12, 314, 3432, 2633, 4898, 2896, 16474, 590, 14, 982, 1265, 787, 3879, 413, 14, 25, 14, 88, 503, 14119, 12, 8749, 675, 445, 8, 4853, 13, 1301, 20545, 63, 31737, 9, 370, 2455, 314, 3211, 2633, 367, 2195, 1015, 14, 1487, 24489, 3330, 9149, 911, 506, 2808, 315, 314, 17429, 6466, 367, 314, 17830, 5246, 14, 199, 7538, 26, 523, 446, 298 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 20545, 63, 31737, 199, 3612, 63, 1802, 26, 2790, 15, 1807, 282, 5978, 2723, 15, 13716, 63, 498, 315, 29979, 47, 20867, 199, 1802, 26, 1362, 446, 2790, 15, 1807, 282, 5978, 2723, 315, 29979, 47, 20867, 436, 14190, 3618, 367, 652, 370, 506, 283, 5720, 297, 503, 12287, 376, 12027, 790, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 2, 199, 2502, 26, 298, 54, 262, 2946, 812, 2380, 2723, 8593, 90, 4982, 2924, 199, 1419, 26, 523, 1414, 26, 272, 1369, 26, 1362, 446, 26058, 1347, 1265, 2934, 370, 19218, 641, 14, 272, 849, 26, 5978, 2723, 272, 3415, 26, 788, 4824, 2723, 297, 283, 5510, 418, 523, 1174, 26, 272, 1369, 26, 1362, 446, 1010, 10188, 6387, 1174, 402, 314, 1347, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 2682, 297, 283, 5575, 297, 283, 6062, 418, 523, 2986, 63, 1418, 26, 272, 1369, 26, 1362, 446, 29979, 47, 20867, 2986, 1526, 14, 523, 1305, 26, 272, 1369, 26, 1362, 446, 19378, 12, 314, 5978, 2723, 1305, 1265, 2934, 370, 19218, 641, 14, 523, 536, 26, 272, 1369, 26, 1362, 446, 2624, 12, 642, 365, 314, 536, 402, 314, 5978, 2723, 446, 1471, 506, 7871, 701, 6246, 4713, 12, 503, 314, 536, 402, 282, 12027, 790, 14, 523, 3747, 63, 354, 26, 272, 1369, 26, 1362, 446, 19287, 12, 4409, 3747, 1591, 1247, 14, 221, 4885, 849, 12, 29979, 47, 20867, 6127, 3663, 7057, 543, 314, 2011, 536, 14, 221, 13510, 642, 370, 298, 5066, 2, 6127, 1454, 1373, 1591, 1126, 536, 14, 221, 18491, 367, 9979, 9613, 6692, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 849, 26, 298, 889, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 1568, 63, 344, 26, 272, 1369, 26, 1362, 446, 961, 365, 314, 8889, 402, 314, 1568, 1265, 3955, 2839, 314, 5978, 2723, 2737, 543, 14, 523, 1834, 63, 344, 26, 272, 1369, 26, 1362, 446, 961, 365, 314, 8889, 402, 314, 1834, 1265, 3955, 2839, 314, 5978, 2723, 2737, 543, 14, 523, 4897, 63, 344, 26, 272, 1369, 26, 1362, 446, 961, 365, 314, 8889, 402, 314, 4897, 1265, 3955, 2839, 2195, 1654, 370, 506, 2737, 315, 14, 523, 8635, 63, 498, 63, 1580, 26, 272, 1369, 26, 1362, 446, 4879, 12, 1625, 402, 402, 12027, 790, 334, 6677, 9, 2870, 626, 1265, 3955, 2839, 370, 506, 3483, 370, 314, 1654, 14, 523, 18291, 4538, 26, 272, 1369, 26, 1362, 446, 298, 10349, 12, 7485, 641, 18291, 4538, 5253, 315, 5978, 2723, 367, 1742, 26429, 2784, 436, 4887, 473, 15, 47, 2122, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 849, 26, 298, 5066, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 5726, 63, 1200, 316, 26, 272, 1369, 26, 1362, 446, 298, 10349, 12, 1050, 376, 4722, 12, 5726, 2784, 3217, 370, 5978, 2723, 367, 1640, 13, 4824, 2723, 23506, 2122, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 849, 26, 298, 889, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 6902, 83, 63, 3827, 26, 272, 1369, 26, 1362, 446, 4879, 12, 9411, 12, 22741, 6902, 83, 367, 2195, 5978, 2723, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 849, 26, 298, 889, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 922, 63, 576, 26, 272, 1369, 26, 489, 446, 15058, 9182, 402, 666, 1314, 365, 6326, 2808, 370, 314, 5978, 2723, 272, 1015, 63, 3270, 26, 298, 17, 14, 709, 2, 272, 1415, 26, 3055, 272, 849, 26, 488, 523, 3618, 26, 272, 1369, 26, 1362, 446, 13144, 367, 314, 5978, 2723, 370, 506, 315, 1174, 283, 5720, 7, 2544, 8152, 14, 221, 982, 3618, 365, 298, 889, 2, 376, 3384, 63, 1562, 1443, 440, 506, 2138, 14, 272, 849, 26, 298, 5066, 2, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 3618, 63, 2593, 26, 272, 1369, 26, 1362, 446, 7494, 1846, 2544, 3618, 10557, 1536, 12, 315, 4696, 14, 272, 849, 26, 9601, 523, 8635, 63, 5645, 63, 498, 26, 272, 1369, 26, 1362, 446, 710, 4575, 12027, 790, 1265, 2934, 370, 1050, 370, 2195, 2933, 14, 199, 199, 5983, 26, 523, 446, 16853, 3734, 2860, 883, 506, 1202, 12, 3506, 63, 3735, 63, 3078, 436, 3506, 63, 3735, 63, 8803, 14, 9322, 3865, 10618, 370, 314, 373, 18, 1526, 14, 523, 446, 3709, 402, 2622, 499, 14, 16, 12, 3394, 499, 402, 314, 29979, 47, 20867, 3261, 365, 1202, 14, 523, 446, 3709, 402, 2622, 499, 14, 16, 12, 314, 3432, 2633, 4898, 2896, 16474, 590, 14, 982, 1265, 787, 3879, 413, 14, 25, 14, 88, 503, 14119, 12, 8749, 675, 445, 8, 4853, 13, 1301, 20545, 63, 31737, 9, 370, 2455, 314, 3211, 2633, 367, 2195, 1015, 14, 1487, 24489, 3330, 9149, 911, 506, 2808, 315, 314, 17429, 6466, 367, 314, 17830, 5246, 14, 199, 7538, 26, 523, 446, 298, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
openstack/horizon
openstack_dashboard/dashboards/admin/volumes/forms.py
1
10388
# Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, 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. from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import forms from horizon import messages from horizon.utils import validators as utils_validators from openstack_dashboard.api import cinder from openstack_dashboard.dashboards.admin.snapshots.forms \ import populate_status_choices from openstack_dashboard.dashboards.project.volumes \ import forms as project_forms from openstack_dashboard.dashboards.project.volumes.tables \ import VolumesTableBase as volumes_table # This set of states was pulled from cinder's admin_actions.py SETTABLE_STATUSES = ( 'attaching', 'available', 'creating', 'deleting', 'detaching', 'error', 'error_deleting', 'in-use', 'maintenance', 'reserved') STATUS_CHOICES = tuple( status for status in volumes_table.STATUS_DISPLAY_CHOICES if status[0] in SETTABLE_STATUSES ) class ManageVolume(forms.SelfHandlingForm): identifier = forms.CharField( max_length=255, label=_("Identifier"), help_text=_("Name or other identifier for existing volume")) id_type = forms.ThemableChoiceField( label=_("Identifier Type"), help_text=_("Type of backend device identifier provided")) host = forms.CharField( max_length=255, label=_("Host"), help_text=_("Cinder host on which the existing volume resides; " "takes the form: host@backend-name#pool")) name = forms.CharField( max_length=255, label=_("Volume Name"), required=False, help_text=_("Volume name to be assigned")) description = forms.CharField(max_length=255, widget=forms.Textarea( attrs={'rows': 4}), label=_("Description"), required=False) metadata = forms.CharField(max_length=255, widget=forms.Textarea( attrs={'rows': 2}), label=_("Metadata"), required=False, help_text=_("Comma-separated key=value pairs"), validators=[utils_validators.validate_metadata]) volume_type = forms.ThemableChoiceField( label=_("Volume Type"), required=False) availability_zone = forms.ThemableChoiceField( label=_("Availability Zone"), required=False) bootable = forms.BooleanField( label=_("Bootable"), required=False, help_text=_("Specifies that the newly created volume " "should be marked as bootable")) def __init__(self, request, *args, **kwargs): super().__init__(request, *args, **kwargs) self.fields['id_type'].choices = [("source-name", _("Name"))] + \ [("source-id", _("ID"))] volume_types = cinder.volume_type_list(request) self.fields['volume_type'].choices = [("", _("No volume type"))] + \ [(type.name, type.name) for type in volume_types] self.fields['availability_zone'].choices = \ project_forms.availability_zones(request) def handle(self, request, data): try: az = data.get('availability_zone') # assume user enters metadata with "key1=val1,key2=val2" # convert to dictionary metadataDict = {} metadata = data.get('metadata') if metadata: metadata.replace(" ", "") for item in metadata.split(','): key, value = item.split('=') metadataDict[key] = value cinder.volume_manage(request, host=data['host'], identifier=data['identifier'], id_type=data['id_type'], name=data['name'], description=data['description'], volume_type=data['volume_type'], availability_zone=az, metadata=metadataDict, bootable=data['bootable']) # for success message, use identifier if user does not # provide a volume name volume_name = data['name'] if not volume_name: volume_name = data['identifier'] messages.success( request, _('Successfully sent the request to manage volume: %s') % volume_name) return True except Exception: redirect = reverse("horizon:admin:volumes:index") exceptions.handle(request, _("Unable to manage volume."), redirect=redirect) class UnmanageVolume(forms.SelfHandlingForm): name = forms.CharField(label=_("Volume Name"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) host = forms.CharField(label=_("Host"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) volume_id = forms.CharField(label=_("ID"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) def handle(self, request, data): try: cinder.volume_unmanage(request, self.initial['volume_id']) messages.success( request, _('Successfully sent the request to unmanage volume: %s') % data['name']) return True except Exception: redirect = reverse("horizon:admin:volumes:index") exceptions.handle(request, _("Unable to unmanage volume."), redirect=redirect) class MigrateVolume(forms.SelfHandlingForm): name = forms.CharField(label=_("Volume Name"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) current_host = forms.CharField(label=_("Current Host"), required=False, widget=forms.TextInput( attrs={'readonly': 'readonly'})) host = forms.ThemableChoiceField( label=_("Destination Host"), help_text=_("Choose a Host to migrate to.")) force_host_copy = forms.BooleanField(label=_("Force Host Copy"), initial=False, required=False) def __init__(self, request, *args, **kwargs): super().__init__(request, *args, **kwargs) initial = kwargs.get('initial', {}) self.fields['host'].choices = self.populate_host_choices(request, initial) def populate_host_choices(self, request, initial): hosts = initial.get('hosts') current_host = initial.get('current_host') host_list = [(host.name, host.name) for host in hosts if host.name != current_host] if host_list: host_list.insert(0, ("", _("Select a new host"))) else: host_list.insert(0, ("", _("No other hosts available"))) return sorted(host_list) def handle(self, request, data): try: cinder.volume_migrate(request, self.initial['volume_id'], data['host'], data['force_host_copy']) messages.success( request, _('Successfully sent the request to migrate volume: %s') % data['name']) return True except Exception: redirect = reverse("horizon:admin:volumes:index") exceptions.handle(request, _("Failed to migrate volume."), redirect=redirect) class UpdateStatus(forms.SelfHandlingForm): status = forms.ThemableChoiceField(label=_("Status")) def __init__(self, request, *args, **kwargs): # Initial values have to be operated before super() otherwise the # initial values will get overwritten back to the raw value current_status = kwargs['initial']['status'] kwargs['initial'].pop('status') super().__init__(request, *args, **kwargs) self.fields['status'].choices = populate_status_choices( current_status, STATUS_CHOICES) def handle(self, request, data): # Obtain the localized status for including in the message for choice in self.fields['status'].choices: if choice[0] == data['status']: new_status = choice[1] break else: new_status = data['status'] try: cinder.volume_reset_state(request, self.initial['volume_id'], data['status']) messages.success(request, _('Successfully updated volume status to "%s".') % new_status) return True except Exception: redirect = reverse("horizon:admin:volumes:index") exceptions.handle(request, _('Unable to update volume status to "%s".') % new_status, redirect=redirect)
apache-2.0
[ 3, 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 3788, 199, 504, 21726, 14, 1208, 492, 14370, 465, 3778, 63, 11346, 199, 199, 504, 13869, 63, 9743, 14, 1246, 492, 13069, 199, 504, 13869, 63, 9743, 14, 30424, 14, 2113, 14, 15331, 14, 3351, 971, 272, 492, 13904, 63, 1205, 63, 4577, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 8838, 971, 272, 492, 4513, 465, 2199, 63, 3351, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 8838, 14, 5987, 971, 272, 492, 15018, 83, 3186, 1563, 465, 12158, 63, 1224, 421, 199, 3, 961, 663, 402, 6363, 1990, 25239, 1146, 687, 13069, 1159, 4628, 63, 3723, 14, 647, 199, 3597, 8723, 63, 6305, 654, 275, 334, 272, 283, 5040, 316, 297, 283, 4561, 297, 283, 20358, 297, 283, 7346, 1337, 297, 283, 14481, 316, 297, 283, 705, 297, 272, 283, 705, 63, 7346, 1337, 297, 283, 262, 13, 1180, 297, 283, 19725, 297, 283, 10421, 358, 199, 6305, 63, 16236, 275, 2008, 8, 272, 2004, 367, 2004, 315, 12158, 63, 1224, 14, 6305, 63, 20993, 63, 16236, 272, 340, 2004, 59, 16, 61, 315, 11543, 8723, 63, 6305, 654, 199, 9, 421, 199, 533, 14944, 6464, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 5148, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 7544, 1288, 267, 1720, 63, 505, 9384, 985, 503, 1163, 5148, 367, 3411, 3301, 2237, 272, 1305, 63, 466, 275, 4513, 14, 1918, 77, 461, 15792, 8, 267, 1768, 9384, 7544, 2434, 1288, 267, 1720, 63, 505, 9384, 804, 402, 4865, 2243, 5148, 2741, 2237, 272, 1591, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 4965, 1288, 267, 1720, 63, 505, 9384, 35, 5755, 1591, 641, 1314, 314, 3411, 3301, 295, 19564, 27, 298, 490, 298, 31613, 314, 1824, 26, 1591, 32, 4620, 13, 354, 3, 2293, 2237, 272, 536, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 6464, 2812, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6464, 536, 370, 506, 7943, 2237, 272, 1369, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 841, 8688, 267, 1768, 9384, 5831, 1288, 1415, 29, 797, 9, 272, 3341, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 499, 8688, 267, 1768, 9384, 5142, 1288, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 25732, 13, 12794, 790, 29, 585, 6342, 1288, 267, 14370, 1524, 1208, 63, 11346, 14, 3502, 63, 2343, 566, 272, 3301, 63, 466, 275, 4513, 14, 1918, 77, 461, 15792, 8, 267, 1768, 9384, 6464, 2434, 1288, 267, 1415, 29, 797, 9, 272, 14962, 63, 2619, 275, 4513, 14, 1918, 77, 461, 15792, 8, 267, 1768, 9384, 26462, 22518, 1288, 267, 1415, 29, 797, 9, 339, 8498, 461, 275, 4513, 14, 5036, 8, 267, 1768, 9384, 17989, 461, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6154, 5604, 626, 314, 13903, 2737, 3301, 298, 490, 298, 5626, 506, 11584, 465, 8498, 461, 2237, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 11027, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 291, 14, 955, 459, 344, 63, 466, 2278, 4577, 275, 10003, 1365, 13, 354, 401, 3824, 985, 2237, 61, 435, 971, 1460, 10003, 1365, 13, 344, 401, 3824, 998, 2237, 61, 267, 3301, 63, 1313, 275, 13069, 14, 2405, 63, 466, 63, 513, 8, 1069, 9, 267, 291, 14, 955, 459, 2405, 63, 466, 2278, 4577, 275, 3842, 5151, 3824, 1944, 3301, 730, 2237, 61, 435, 971, 6163, 3842, 466, 14, 354, 12, 730, 14, 354, 9, 6343, 367, 730, 315, 3301, 63, 1313, 61, 267, 291, 14, 955, 459, 11856, 63, 2619, 2278, 4577, 275, 971, 288, 2199, 63, 3351, 14, 11856, 63, 13325, 8, 1069, 9, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 862, 26, 288, 24978, 275, 666, 14, 362, 360, 11856, 63, 2619, 358, 953, 327, 5534, 922, 655, 878, 3341, 543, 298, 498, 17, 29, 637, 17, 12, 498, 18, 29, 637, 18, 2, 288, 327, 3957, 370, 2600, 288, 3341, 2141, 275, 1052, 288, 3341, 275, 666, 14, 362, 360, 2343, 358, 288, 340, 3341, 26, 355, 3341, 14, 1814, 480, 3872, 6899, 355, 367, 1242, 315, 3341, 14, 1294, 25908, 490, 790, 12, 574, 275, 1242, 14, 1294, 23917, 490, 3341, 2141, 59, 498, 61, 275, 574, 953, 13069, 14, 2405, 63, 9053, 8, 1069, 12, 639, 1591, 29, 576, 459, 1102, 995, 639, 5148, 29, 576, 459, 5364, 995, 639, 1305, 63, 466, 29, 576, 459, 344, 63, 466, 995, 639, 536 ]
[ 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 3788, 199, 504, 21726, 14, 1208, 492, 14370, 465, 3778, 63, 11346, 199, 199, 504, 13869, 63, 9743, 14, 1246, 492, 13069, 199, 504, 13869, 63, 9743, 14, 30424, 14, 2113, 14, 15331, 14, 3351, 971, 272, 492, 13904, 63, 1205, 63, 4577, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 8838, 971, 272, 492, 4513, 465, 2199, 63, 3351, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 8838, 14, 5987, 971, 272, 492, 15018, 83, 3186, 1563, 465, 12158, 63, 1224, 421, 199, 3, 961, 663, 402, 6363, 1990, 25239, 1146, 687, 13069, 1159, 4628, 63, 3723, 14, 647, 199, 3597, 8723, 63, 6305, 654, 275, 334, 272, 283, 5040, 316, 297, 283, 4561, 297, 283, 20358, 297, 283, 7346, 1337, 297, 283, 14481, 316, 297, 283, 705, 297, 272, 283, 705, 63, 7346, 1337, 297, 283, 262, 13, 1180, 297, 283, 19725, 297, 283, 10421, 358, 199, 6305, 63, 16236, 275, 2008, 8, 272, 2004, 367, 2004, 315, 12158, 63, 1224, 14, 6305, 63, 20993, 63, 16236, 272, 340, 2004, 59, 16, 61, 315, 11543, 8723, 63, 6305, 654, 199, 9, 421, 199, 533, 14944, 6464, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 5148, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 7544, 1288, 267, 1720, 63, 505, 9384, 985, 503, 1163, 5148, 367, 3411, 3301, 2237, 272, 1305, 63, 466, 275, 4513, 14, 1918, 77, 461, 15792, 8, 267, 1768, 9384, 7544, 2434, 1288, 267, 1720, 63, 505, 9384, 804, 402, 4865, 2243, 5148, 2741, 2237, 272, 1591, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 4965, 1288, 267, 1720, 63, 505, 9384, 35, 5755, 1591, 641, 1314, 314, 3411, 3301, 295, 19564, 27, 298, 490, 298, 31613, 314, 1824, 26, 1591, 32, 4620, 13, 354, 3, 2293, 2237, 272, 536, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 1768, 9384, 6464, 2812, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6464, 536, 370, 506, 7943, 2237, 272, 1369, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 841, 8688, 267, 1768, 9384, 5831, 1288, 1415, 29, 797, 9, 272, 3341, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3938, 29, 3351, 14, 1872, 6789, 8, 267, 3290, 3713, 3838, 356, 499, 8688, 267, 1768, 9384, 5142, 1288, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 25732, 13, 12794, 790, 29, 585, 6342, 1288, 267, 14370, 1524, 1208, 63, 11346, 14, 3502, 63, 2343, 566, 272, 3301, 63, 466, 275, 4513, 14, 1918, 77, 461, 15792, 8, 267, 1768, 9384, 6464, 2434, 1288, 267, 1415, 29, 797, 9, 272, 14962, 63, 2619, 275, 4513, 14, 1918, 77, 461, 15792, 8, 267, 1768, 9384, 26462, 22518, 1288, 267, 1415, 29, 797, 9, 339, 8498, 461, 275, 4513, 14, 5036, 8, 267, 1768, 9384, 17989, 461, 1288, 267, 1415, 29, 797, 12, 267, 1720, 63, 505, 9384, 6154, 5604, 626, 314, 13903, 2737, 3301, 298, 490, 298, 5626, 506, 11584, 465, 8498, 461, 2237, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 11027, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 291, 14, 955, 459, 344, 63, 466, 2278, 4577, 275, 10003, 1365, 13, 354, 401, 3824, 985, 2237, 61, 435, 971, 1460, 10003, 1365, 13, 344, 401, 3824, 998, 2237, 61, 267, 3301, 63, 1313, 275, 13069, 14, 2405, 63, 466, 63, 513, 8, 1069, 9, 267, 291, 14, 955, 459, 2405, 63, 466, 2278, 4577, 275, 3842, 5151, 3824, 1944, 3301, 730, 2237, 61, 435, 971, 6163, 3842, 466, 14, 354, 12, 730, 14, 354, 9, 6343, 367, 730, 315, 3301, 63, 1313, 61, 267, 291, 14, 955, 459, 11856, 63, 2619, 2278, 4577, 275, 971, 288, 2199, 63, 3351, 14, 11856, 63, 13325, 8, 1069, 9, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 862, 26, 288, 24978, 275, 666, 14, 362, 360, 11856, 63, 2619, 358, 953, 327, 5534, 922, 655, 878, 3341, 543, 298, 498, 17, 29, 637, 17, 12, 498, 18, 29, 637, 18, 2, 288, 327, 3957, 370, 2600, 288, 3341, 2141, 275, 1052, 288, 3341, 275, 666, 14, 362, 360, 2343, 358, 288, 340, 3341, 26, 355, 3341, 14, 1814, 480, 3872, 6899, 355, 367, 1242, 315, 3341, 14, 1294, 25908, 490, 790, 12, 574, 275, 1242, 14, 1294, 23917, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ijmarshall/robotreviewer3
robotreviewer/robots/rationale_robot.py
1
13649
""" the BiasRobot class takes the full text of a clinical trial as input as a robotreviewer.data_structures.MultiDict, and returns bias information in the same format, which can easily be converted to JSON. there are multiple ways to build a MultiDict, however the most common way used in this project is as a PDF binary. pdf_binary = ... pdfr = PDFReader() data = pdfr.convert(pdf_binary) robot = BiasRobot() annotations = robot.annotate(data) """ # Authors: Iain Marshall <mail@ijmarshall.com> # Joel Kuiper <me@joelkuiper.com> # Byron Wallace <byron@ccs.neu.edu> import uuid import operator import pickle import numpy as np from collections import OrderedDict, defaultdict import robotreviewer import logging log = logging.getLogger(__name__) import sys sys.path.append('robotreviewer/ml') # need this for loading the rationale_CNN module from celery.contrib import rdb __version__ = {"name": "Risk of bias (CNN/SVM ensemble)", "version_number": "3", "publication_url": "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5300751/", "cite_bibtex": """@inproceedings{zhang2016rationale, title={Rationale-augmented convolutional neural networks for text classification}, author={Zhang, Ye and Marshall, Iain and Wallace, Byron C}, booktitle={Proceedings of the Conference on Empirical Methods in Natural Language Processing. Conference on Empirical Methods in Natural Language Processing}, volume={2016}, pages={795}, year={2016}, organization={NIH Public Access} }""", "cite_text": "Zhang, Ye, Iain J Marshall, and Byron C. Wallace. “Rationale-Augmented Convolutional Neural Networks for Text Classification.” Proceedings of Empirical Methods in Natural Language Processing (EMNLP), 2016." } class BiasRobot: def __init__(self, top_k=3): """ `top_k` refers to 'top-k recall'. top-1 recall will return the single most relevant sentence in the document, and top-3 recall the 3 most relevant. The validation study assessed the accuracy of top-3 and top-1 and we suggest top-3 as default """ self.bias_domains = ['Random sequence generation'] self.top_k = top_k self.bias_domains = {'RSG': 'Random sequence generation', 'AC': 'Allocation concealment', 'BPP': 'Blinding of participants and personnel', 'BOA': 'Blinding of outcome assessment', 'IOD': 'Incomplete outcome data', 'SR': 'Selective reporting' } ### # Here we take a simple ensembling approach in which we combine the # predictions made by our rationaleCNN model and the JAMIA (linear) # multi task variant. ### self.all_domains = ['RSG', 'AC', 'BPP', 'BOA'] from robotreviewer.ml.classifier import MiniClassifier from robotreviewer.ml.vectorizer import ModularVectorizer from robotreviewer.ml.rationale_CNN import RationaleCNN, Document global RationaleCNN, Document, MiniClassifier, ModularVectorizer # CNN domains vectorizer_str = 'robotreviewer/data/keras/vectorizers/{}.pickle' arch_str = 'robotreviewer/data/keras/models/{}.json' weight_str = 'robotreviewer/data/keras/models/{}.hdf5' self.CNN_models = OrderedDict() for bias_domain in ['RSG', 'AC', 'BPP', 'BOA']: # Load vectorizer and keras model vectorizer_loc = vectorizer_str.format(bias_domain) arch_loc = arch_str.format(bias_domain) weight_loc = weight_str.format(bias_domain) preprocessor = pickle.load(open(vectorizer_loc, 'rb')) preprocessor.tokenizer.oov_token = None # TODO check with Byron self.CNN_models[bias_domain] = RationaleCNN(preprocessor, document_model_architecture_path=arch_loc, document_model_weights_path=weight_loc) # Linear domains (these are joint models!) self.linear_sent_clf = MiniClassifier(robotreviewer.get_data('bias/bias_sent_level.npz')) self.linear_doc_clf = MiniClassifier(robotreviewer.get_data('bias/bias_doc_level.npz')) self.linear_vec = ModularVectorizer(norm=None, non_negative=True, binary=True, ngram_range=(1, 2), n_features=2**26) def simple_borda_count(self, a, b, weights=None): ''' Basic Borda count implementation for just two lists. Assumes that a and b are lists of indices sorted in *increasing* preference (so top-ranked sentence should be the last element). ''' rank_scores_dict = defaultdict(int) if weights is None: weights = np.ones(2) # ensure list sizes are equal. note that the CNN # model will always assume/force 200 sentences, # whereas BoW model will not. so here we trim if # necessary, effectively taking the max_index # top sentences from each model and pooling these. a_n, b_n = len(a), len(b) max_index = min(a_n, b_n) a = a[-max_index:] b = b[-max_index:] for i in range(max_index): score = i+1 # 1 ... m rank_scores_dict[a[i]] += weights[0]*score rank_scores_dict[b[i]] += weights[1]*score sorted_indices = sorted(rank_scores_dict.items(), key=operator.itemgetter(1), reverse=True) return [index[0] for index in sorted_indices] def annotate(self, doc_text, top_k=None, threshold=0.5): """ Annotate full text of clinical trial report `top_k` can be overridden here, else defaults to the class default set in __init__ """ log.info('getting top k') top_k = self.top_k if not top_k else top_k doc_len = len(doc_text.text) doc_sents = [sent.text for sent in doc_text.sents] doc_sent_start_i = [sent.start_char for sent in doc_text.sents] doc_sent_end_i = [sent.end_char for sent in doc_text.sents] structured_data = [] #for domain, model in self.models.items(): log.info('starting modeling') for domain in self.all_domains: log.info('STARTING DOMAIN {}'.format(domain)) ### # linear model predictions (all domains) #if type(model) == tuple: # linear model log.info('doing linear predictions') (vec, sent_clf, doc_clf) = (self.linear_vec, self.linear_sent_clf, self.linear_doc_clf) doc_domains = [self.bias_domains[domain]] * len(doc_sents) doc_X_i = zip(doc_sents, doc_domains) vec.builder_clear() vec.builder_add_docs(doc_sents) vec.builder_add_docs(doc_X_i) doc_sents_X = vec.builder_transform() doc_sents_preds = sent_clf.decision_function(doc_sents_X) linear_high_prob_sent_indices = np.argsort(doc_sents_preds) ### # CNN predictions log.info('doing cnn predictions') bias_prob_CNN = None if domain in self.CNN_models: model = self.CNN_models[domain] log.info('model selected for {}'.format(domain)) doc = Document(doc_id=None, sentences=doc_sents) # make consumable for RA-CNN log.info('Doc done {}'.format(domain)) # this never comes back bias_prob_CNN, high_prob_sent_indices_CNN = model.predict_and_rank_sentences_for_doc(doc, num_rationales=len(doc), return_rationale_indices=True) log.info('got probs {}'.format(domain)) high_prob_sent_indices = self.simple_borda_count(high_prob_sent_indices_CNN, linear_high_prob_sent_indices)[:top_k] # and now the overall (doc-level) prediction from the CNN model. # bias_prob = 1 --> low risk # from riskofbias2: # doc_y[mapped_domain] = 1 if domain["RATING"] == "YES" else -1 # # simplifying to LOW risk of bias = 1 *v* HIGH/UNKNOWN risk = -1 #### bias_pred = int(bias_prob_CNN >= threshold) # low risk if True and high/unclear otherwise else: # no aggregation here (since no CNN model for this domain) high_prob_sent_indices = linear_high_prob_sent_indices[-top_k:] high_prob_sent_indices = linear_high_prob_sent_indices[::-1] # put highest prob sentence first #if domain == "BOA": # high_prob_sents_CNN = [doc_sents[i] for i in high_prob_sent_indices_CNN] # Find high probability sentences #from celery.contrib import rdb #rdb.set_trace() high_prob_sents = [doc_sents[i] for i in high_prob_sent_indices] high_prob_start_i = [doc_sent_start_i[i] for i in high_prob_sent_indices] high_prob_end_i = [doc_sent_end_i[i] for i in high_prob_sent_indices] high_prob_prefixes = [doc_text.text[max(0, offset-20):offset] for offset in high_prob_start_i] high_prob_suffixes = [doc_text.text[offset: min(doc_len, offset+20)] for offset in high_prob_end_i] high_prob_sents_j = " ".join(high_prob_sents) # overall pred from linear model vec.builder_clear() vec.builder_add_docs([doc_text.text]) vec.builder_add_docs([(doc_text.text, self.bias_domains[domain])]) sent_domain_interaction = "-s-" + self.bias_domains[domain] vec.builder_add_docs([(high_prob_sents_j, sent_domain_interaction)]) X = vec.builder_transform() bias_prob_linear = doc_clf.predict_proba(X)[0] # if we have a CNN pred, too, then average; otherwise # rely on linear model. bias_prob = bias_prob_linear if bias_prob_CNN is not None: bias_prob = (bias_prob_CNN + bias_prob_linear) / 2.0 bias_pred = int(bias_prob >= threshold) bias_class = ["high/unclear", "low"][bias_pred] # prediction annotation_metadata = [] for sent in zip(high_prob_sents, high_prob_start_i, high_prob_prefixes, high_prob_suffixes): sent_metadata = {"content": sent[0], "position": sent[1], "uuid": str(uuid.uuid1()), "prefix": sent[2], "suffix": sent[3]} annotation_metadata.append(sent_metadata) structured_data.append({"domain": self.bias_domains[domain], "judgement": bias_class, "annotations": annotation_metadata}) return structured_data def pdf_annotate(self, data): log.info('retrieving text') doc_text = data.get('parsed_text') if not doc_text: return data # we've got to know the text at least.. structured_data = self.annotate(doc_text) data.ml["bias"] = structured_data log.info('done predictions, ready to return answers') return data def api_annotate(self, articles): if not all(('parsed_fullText' in article for article in articles)): raise Exception('Bias model requires full text to be able to complete annotation') annotations = [] for article in articles: if article.get('skip_annotation'): annotations.append([]) else: annotations.append(self.annotate(article['parsed_fullText'])) # reformat annotations to API formatting api_domain_titles = { 'Random sequence generation': 'random_sequence_generation', 'Allocation concealment': 'allocation_concealment', 'Blinding of participants and personnel': 'blinding_participants_personnel', 'Blinding of outcome assessment': 'blinding_outcome_assessment'} out = [] for r in annotations: row = {} for b in r: row[api_domain_titles[b['domain']]] = { "judgement": b['judgement'], "annotations": [{"text": an['content'], "start_index":an['position'] } for an in b['annotations']] } out.append(row) return out @staticmethod def get_marginalia(data): """ Get marginalia formatted for Spa from structured data """ marginalia = [] for row in data['bias']: marginalia.append({ "type": "Risk of Bias", "title": row['domain'], "annotations": row['annotations'], "description": "**Overall risk of bias prediction**: {}".format(row['judgement']) }) return marginalia @staticmethod def get_domains(): return [u'Random sequence generation', u'Allocation concealment', u'Blinding of participants and personnel', u'Blinding of outcome assessment'] #u'Incomplete outcome data', #u'Selective reporting']
gpl-3.0
[ 624, 199, 1589, 699, 2241, 21823, 1021, 6181, 314, 2615, 1318, 402, 282, 286, 472, 2652, 16324, 465, 199, 1210, 465, 282, 14544, 23492, 14, 576, 63, 13547, 14, 21365, 12, 436, 2529, 199, 8160, 2556, 315, 314, 2011, 1475, 12, 1314, 883, 16174, 506, 6702, 199, 475, 4840, 14, 199, 199, 16990, 787, 3663, 15217, 370, 1900, 282, 29393, 12, 13432, 314, 4750, 2863, 199, 3316, 1202, 315, 642, 2199, 365, 465, 282, 15537, 3366, 14, 339, 11249, 63, 3008, 275, 2263, 339, 11249, 82, 275, 15537, 5929, 342, 272, 666, 275, 11249, 82, 14, 3916, 8, 5607, 63, 3008, 9, 339, 14544, 275, 699, 2241, 21823, 342, 272, 15538, 275, 14544, 14, 10898, 8, 576, 9, 199, 199, 624, 199, 199, 3, 6642, 26, 221, 473, 1581, 16794, 609, 452, 665, 1198, 32, 7879, 28128, 452, 14, 957, 30, 199, 3, 3698, 7135, 352, 1804, 1907, 529, 665, 278, 32, 743, 352, 75, 1907, 529, 14, 957, 30, 199, 3, 3698, 4885, 2641, 644, 279, 1071, 665, 991, 2641, 32, 67, 1259, 14, 685, 85, 14, 8654, 30, 4388, 199, 646, 5377, 199, 646, 4182, 199, 646, 5927, 199, 646, 2680, 465, 980, 199, 504, 5055, 492, 8773, 12, 10018, 199, 199, 646, 14544, 23492, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 360, 9751, 23492, 15, 757, 358, 327, 1929, 642, 367, 8697, 314, 660, 296, 1895, 63, 35, 7178, 859, 199, 504, 22748, 14, 2828, 492, 519, 697, 199, 199, 363, 1023, 363, 275, 2420, 354, 582, 298, 50, 28600, 402, 10671, 334, 35, 7178, 15, 29389, 19965, 4186, 2049, 298, 1023, 63, 1955, 582, 298, 19, 401, 2049, 298, 22678, 63, 633, 582, 298, 2859, 921, 1544, 14, 78, 2894, 73, 14, 7530, 77, 14, 8445, 72, 14, 16294, 15, 80, 5466, 15, 19813, 15, 48, 7608, 2481, 383, 24595, 10665, 2049, 298, 25171, 63, 8804, 3858, 582, 408, 32, 262, 496, 15648, 780, 91, 3951, 621, 9261, 1754, 1895, 12, 523, 2538, 3126, 50, 425, 1895, 13, 20669, 2509, 17461, 279, 1279, 4889, 11759, 367, 1318, 12505, 1386, 523, 4132, 3126, 12674, 621, 12, 1488, 69, 436, 16794, 609, 452, 12, 473, 1581, 436, 644, 279, 1071, 12, 4885, 2641, 445, 1386, 523, 6719, 1213, 3126, 919, 15648, 780, 402, 314, 1448, 1769, 641, 662, 22575, 17653, 315, 653, 292, 4889, 8466, 20157, 14, 1448, 1769, 641, 662, 22575, 17653, 315, 653, 292, 4889, 8466, 20157, 1386, 523, 3301, 3126, 9261, 1386, 523, 6497, 3126, 22370, 1386, 523, 5361, 3126, 9261, 1386, 523, 13237, 3126, 16730, 40, 1684, 11003, 93, 199, 93, 7208, 3698, 298, 25171, 63, 505, 582, 298, 12674, 621, 12, 1488, 69, 12, 473, 1581, 1603, 16794, 609, 452, 12, 436, 4885, 2641, 445, 14, 644, 279, 1071, 14, 27430, 251, 50, 425, 1895, 13, 21640, 2509, 19140, 3347, 279, 5612, 4889, 17138, 367, 4516, 8465, 7789, 14, 8477, 252, 2165, 15648, 780, 402, 662, 22575, 17653, 315, 653, 292, 4889, 8466, 20157, 334, 2769, 46, 9257, 395, 7800, 2122, 1598, 789, 199, 199, 533, 699, 2241, 21823, 26, 339, 347, 636, 826, 721, 277, 12, 2746, 63, 75, 29, 19, 304, 267, 408, 267, 658, 2119, 63, 75, 64, 15724, 370, 283, 2119, 13, 75, 26174, 1370, 398, 2746, 13, 17, 26174, 911, 372, 314, 2849, 4750, 12082, 14537, 267, 315, 314, 2213, 12, 436, 2746, 13, 19, 26174, 314, 650, 4750, 12082, 14, 398, 710, 6411, 25932, 465, 874, 939, 314, 12862, 402, 2746, 13, 19, 436, 2746, 13, 17, 267, 436, 781, 18453, 2746, 13, 19, 465, 849, 398, 408, 267, 291, 14, 8160, 63, 9756, 275, 788, 3883, 3414, 10152, 418, 267, 291, 14, 2119, 63, 75, 275, 2746, 63, 75, 398, 291, 14, 8160, 63, 9756, 275, 791, 50, 4254, 356, 283, 3883, 3414, 10152, 297, 2490, 283, 1348, 356, 283, 17794, 406, 301, 279, 434, 297, 2490, 283, 34, 7701, 356, 283, 34, 472, 1098, 402, 623, 20989, 436, 4954, 2715, 297, 2490, 283, 3973, 33, 356, 283, 34, 472, 1098, 402, 15955, 28273, 297, 2490, 283, 25705, 356, 283, 31962, 15955, 666, 297, 2490, 283, 5943, 356, 283, 1513, 25982, 17290, 7, 267, 789, 398, 6754, 267, 327, 11842, 781, 5452, 282, 3486, 655, 8946, 2983, 18140, 315, 1314, 781, 13323, 314, 267, 327, 7914, 6326, 701, 4154, 660, 296, 1895, 35, 7178, 1402, 436, 314, 1603, 1156, 13033, 334, 6676, 9, 267, 327, 3510, 2120, 9854, 14, 267, 6754, 398, 291, 14, 452, 63, 9756, 275, 788, 50, 4254, 297, 283, 1348, 297, 283, 34, 7701, 297, 283, 3973, 33, 418, 7318, 687, 14544, 23492, 14, 757, 14, 14720, 492, 24954, 8508, 267, 687, 14544, 23492, 14, 757, 14, 4106, 1793, 492, 22035, 2238, 26165, 267, 687, 14544, 23492, 14, 757, 14, 1754, 1895, 63, 35, 7178, 492, 820, 425, 1895, 35, 7178, 12, 7543, 267, 2288, 820, 425, 1895, 35, 7178, 12, 7543, 12, 24954, 8508, 12, 22035, 2238, 26165, 267, 327, 445, 7178, 14006, 267, 5477, 1793, 63, 495, 275, 283, 9751, 23492, 15, 576, 15, 8811, 15, 4106, 6315, 14698, 14, 8092, 7, 267, 3819, 63, 495, 275, 283, 9751, 23492, 15, 576, 15, 8811, 15, 992, 14698, 14, 1001, 7, 267, 5401, 63, 495, 275, 283, 9751, 23492, 15, 576, 15, 8811, 15, 992, 14698, 14, 19912, 21, 7, 267, 291, 14, 35, 7178, 63, 992, 275, 8773, 342, 267, 367, 10671, 63, 2261, 315, 788, 50, 4254, 297, 283, 1348, 297, 283, 34, 7701, 297, 283, 3973, 33, 2565, 288, 327, 7190, 5477, 1793, 436, 11708, 1402, 288, 5477, 1793, 63, 2102, 275, 5477, 1793, 63, 495, 14, 908, 8, 8160, 63, 2261, 9, 288, 3819, 63, 2102, 275, 3819, 63, 495, 14, 908, 8, 8160, 63, 2261, 9, 288, 5401, 63, 2102, 275, 5401, 63, 495, 14, 908, 8, 8160, 63, 2261, 9, 288, 22335, 275, 5927, 14, 912, 8, 1490, 8, 4106, 1793, 63, 2102, 12, 283, 4848, 1333, 953, 22335, 14, 13771, 14, 1534, 86, 63, 1418, 275, 488, 327, 3254, 1104, 543, 4885, 2641, 953, 291, 14, 35, 7178, 63, 992, 59 ]
[ 199, 1589, 699, 2241, 21823, 1021, 6181, 314, 2615, 1318, 402, 282, 286, 472, 2652, 16324, 465, 199, 1210, 465, 282, 14544, 23492, 14, 576, 63, 13547, 14, 21365, 12, 436, 2529, 199, 8160, 2556, 315, 314, 2011, 1475, 12, 1314, 883, 16174, 506, 6702, 199, 475, 4840, 14, 199, 199, 16990, 787, 3663, 15217, 370, 1900, 282, 29393, 12, 13432, 314, 4750, 2863, 199, 3316, 1202, 315, 642, 2199, 365, 465, 282, 15537, 3366, 14, 339, 11249, 63, 3008, 275, 2263, 339, 11249, 82, 275, 15537, 5929, 342, 272, 666, 275, 11249, 82, 14, 3916, 8, 5607, 63, 3008, 9, 339, 14544, 275, 699, 2241, 21823, 342, 272, 15538, 275, 14544, 14, 10898, 8, 576, 9, 199, 199, 624, 199, 199, 3, 6642, 26, 221, 473, 1581, 16794, 609, 452, 665, 1198, 32, 7879, 28128, 452, 14, 957, 30, 199, 3, 3698, 7135, 352, 1804, 1907, 529, 665, 278, 32, 743, 352, 75, 1907, 529, 14, 957, 30, 199, 3, 3698, 4885, 2641, 644, 279, 1071, 665, 991, 2641, 32, 67, 1259, 14, 685, 85, 14, 8654, 30, 4388, 199, 646, 5377, 199, 646, 4182, 199, 646, 5927, 199, 646, 2680, 465, 980, 199, 504, 5055, 492, 8773, 12, 10018, 199, 199, 646, 14544, 23492, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 360, 9751, 23492, 15, 757, 358, 327, 1929, 642, 367, 8697, 314, 660, 296, 1895, 63, 35, 7178, 859, 199, 504, 22748, 14, 2828, 492, 519, 697, 199, 199, 363, 1023, 363, 275, 2420, 354, 582, 298, 50, 28600, 402, 10671, 334, 35, 7178, 15, 29389, 19965, 4186, 2049, 298, 1023, 63, 1955, 582, 298, 19, 401, 2049, 298, 22678, 63, 633, 582, 298, 2859, 921, 1544, 14, 78, 2894, 73, 14, 7530, 77, 14, 8445, 72, 14, 16294, 15, 80, 5466, 15, 19813, 15, 48, 7608, 2481, 383, 24595, 10665, 2049, 298, 25171, 63, 8804, 3858, 582, 408, 32, 262, 496, 15648, 780, 91, 3951, 621, 9261, 1754, 1895, 12, 523, 2538, 3126, 50, 425, 1895, 13, 20669, 2509, 17461, 279, 1279, 4889, 11759, 367, 1318, 12505, 1386, 523, 4132, 3126, 12674, 621, 12, 1488, 69, 436, 16794, 609, 452, 12, 473, 1581, 436, 644, 279, 1071, 12, 4885, 2641, 445, 1386, 523, 6719, 1213, 3126, 919, 15648, 780, 402, 314, 1448, 1769, 641, 662, 22575, 17653, 315, 653, 292, 4889, 8466, 20157, 14, 1448, 1769, 641, 662, 22575, 17653, 315, 653, 292, 4889, 8466, 20157, 1386, 523, 3301, 3126, 9261, 1386, 523, 6497, 3126, 22370, 1386, 523, 5361, 3126, 9261, 1386, 523, 13237, 3126, 16730, 40, 1684, 11003, 93, 199, 93, 7208, 3698, 298, 25171, 63, 505, 582, 298, 12674, 621, 12, 1488, 69, 12, 473, 1581, 1603, 16794, 609, 452, 12, 436, 4885, 2641, 445, 14, 644, 279, 1071, 14, 27430, 251, 50, 425, 1895, 13, 21640, 2509, 19140, 3347, 279, 5612, 4889, 17138, 367, 4516, 8465, 7789, 14, 8477, 252, 2165, 15648, 780, 402, 662, 22575, 17653, 315, 653, 292, 4889, 8466, 20157, 334, 2769, 46, 9257, 395, 7800, 2122, 1598, 789, 199, 199, 533, 699, 2241, 21823, 26, 339, 347, 636, 826, 721, 277, 12, 2746, 63, 75, 29, 19, 304, 267, 408, 267, 658, 2119, 63, 75, 64, 15724, 370, 283, 2119, 13, 75, 26174, 1370, 398, 2746, 13, 17, 26174, 911, 372, 314, 2849, 4750, 12082, 14537, 267, 315, 314, 2213, 12, 436, 2746, 13, 19, 26174, 314, 650, 4750, 12082, 14, 398, 710, 6411, 25932, 465, 874, 939, 314, 12862, 402, 2746, 13, 19, 436, 2746, 13, 17, 267, 436, 781, 18453, 2746, 13, 19, 465, 849, 398, 408, 267, 291, 14, 8160, 63, 9756, 275, 788, 3883, 3414, 10152, 418, 267, 291, 14, 2119, 63, 75, 275, 2746, 63, 75, 398, 291, 14, 8160, 63, 9756, 275, 791, 50, 4254, 356, 283, 3883, 3414, 10152, 297, 2490, 283, 1348, 356, 283, 17794, 406, 301, 279, 434, 297, 2490, 283, 34, 7701, 356, 283, 34, 472, 1098, 402, 623, 20989, 436, 4954, 2715, 297, 2490, 283, 3973, 33, 356, 283, 34, 472, 1098, 402, 15955, 28273, 297, 2490, 283, 25705, 356, 283, 31962, 15955, 666, 297, 2490, 283, 5943, 356, 283, 1513, 25982, 17290, 7, 267, 789, 398, 6754, 267, 327, 11842, 781, 5452, 282, 3486, 655, 8946, 2983, 18140, 315, 1314, 781, 13323, 314, 267, 327, 7914, 6326, 701, 4154, 660, 296, 1895, 35, 7178, 1402, 436, 314, 1603, 1156, 13033, 334, 6676, 9, 267, 327, 3510, 2120, 9854, 14, 267, 6754, 398, 291, 14, 452, 63, 9756, 275, 788, 50, 4254, 297, 283, 1348, 297, 283, 34, 7701, 297, 283, 3973, 33, 418, 7318, 687, 14544, 23492, 14, 757, 14, 14720, 492, 24954, 8508, 267, 687, 14544, 23492, 14, 757, 14, 4106, 1793, 492, 22035, 2238, 26165, 267, 687, 14544, 23492, 14, 757, 14, 1754, 1895, 63, 35, 7178, 492, 820, 425, 1895, 35, 7178, 12, 7543, 267, 2288, 820, 425, 1895, 35, 7178, 12, 7543, 12, 24954, 8508, 12, 22035, 2238, 26165, 267, 327, 445, 7178, 14006, 267, 5477, 1793, 63, 495, 275, 283, 9751, 23492, 15, 576, 15, 8811, 15, 4106, 6315, 14698, 14, 8092, 7, 267, 3819, 63, 495, 275, 283, 9751, 23492, 15, 576, 15, 8811, 15, 992, 14698, 14, 1001, 7, 267, 5401, 63, 495, 275, 283, 9751, 23492, 15, 576, 15, 8811, 15, 992, 14698, 14, 19912, 21, 7, 267, 291, 14, 35, 7178, 63, 992, 275, 8773, 342, 267, 367, 10671, 63, 2261, 315, 788, 50, 4254, 297, 283, 1348, 297, 283, 34, 7701, 297, 283, 3973, 33, 2565, 288, 327, 7190, 5477, 1793, 436, 11708, 1402, 288, 5477, 1793, 63, 2102, 275, 5477, 1793, 63, 495, 14, 908, 8, 8160, 63, 2261, 9, 288, 3819, 63, 2102, 275, 3819, 63, 495, 14, 908, 8, 8160, 63, 2261, 9, 288, 5401, 63, 2102, 275, 5401, 63, 495, 14, 908, 8, 8160, 63, 2261, 9, 288, 22335, 275, 5927, 14, 912, 8, 1490, 8, 4106, 1793, 63, 2102, 12, 283, 4848, 1333, 953, 22335, 14, 13771, 14, 1534, 86, 63, 1418, 275, 488, 327, 3254, 1104, 543, 4885, 2641, 953, 291, 14, 35, 7178, 63, 992, 59, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kapiziak/mtasa-blue
vendor/google-breakpad/src/testing/gtest/xcode/Scripts/versiongenerate.py
3088
4536
#!/usr/bin/env python # # Copyright 2008, 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. """A script to prepare version informtion for use the gtest Info.plist file. This script extracts the version information from the configure.ac file and uses it to generate a header file containing the same information. The #defines in this header file will be included in during the generation of the Info.plist of the framework, giving the correct value to the version shown in the Finder. This script makes the following assumptions (these are faults of the script, not problems with the Autoconf): 1. The AC_INIT macro will be contained within the first 1024 characters of configure.ac 2. The version string will be 3 integers separated by periods and will be surrounded by squre brackets, "[" and "]" (e.g. [1.0.1]). The first segment represents the major version, the second represents the minor version and the third represents the fix version. 3. No ")" character exists between the opening "(" and closing ")" of AC_INIT, including in comments and character strings. """ import sys import re # Read the command line argument (the output directory for Version.h) if (len(sys.argv) < 3): print "Usage: versiongenerate.py input_dir output_dir" sys.exit(1) else: input_dir = sys.argv[1] output_dir = sys.argv[2] # Read the first 1024 characters of the configure.ac file config_file = open("%s/configure.ac" % input_dir, 'r') buffer_size = 1024 opening_string = config_file.read(buffer_size) config_file.close() # Extract the version string from the AC_INIT macro # The following init_expression means: # Extract three integers separated by periods and surrounded by squre # brackets(e.g. "[1.0.1]") between "AC_INIT(" and ")". Do not be greedy # (*? is the non-greedy flag) since that would pull in everything between # the first "(" and the last ")" in the file. version_expression = re.compile(r"AC_INIT\(.*?\[(\d+)\.(\d+)\.(\d+)\].*?\)", re.DOTALL) version_values = version_expression.search(opening_string) major_version = version_values.group(1) minor_version = version_values.group(2) fix_version = version_values.group(3) # Write the version information to a header file to be included in the # Info.plist file. file_data = """// // DO NOT MODIFY THIS FILE (but you can delete it) // // This file is autogenerated by the versiongenerate.py script. This script // is executed in a "Run Script" build phase when creating gtest.framework. This // header file is not used during compilation of C-source. Rather, it simply // defines some version strings for substitution in the Info.plist. Because of // this, we are not not restricted to C-syntax nor are we using include guards. // #define GTEST_VERSIONINFO_SHORT %s.%s #define GTEST_VERSIONINFO_LONG %s.%s.%s """ % (major_version, minor_version, major_version, minor_version, fix_version) version_file = open("%s/Version.h" % output_dir, 'w') version_file.write(file_data) version_file.close()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 33, 2884, 370, 9275, 1015, 315, 964, 296, 367, 675, 314, 9088, 10332, 14, 10265, 570, 14, 819, 961, 2884, 5536, 83, 314, 1015, 2556, 687, 314, 7908, 14, 645, 570, 436, 523, 4440, 652, 370, 3550, 282, 1406, 570, 3035, 314, 2011, 2556, 14, 710, 523, 327, 14334, 315, 642, 1406, 570, 911, 506, 5120, 315, 5309, 314, 10152, 402, 523, 314, 10332, 14, 10265, 402, 314, 10059, 12, 15131, 314, 3211, 574, 370, 314, 1015, 523, 9164, 315, 314, 481, 5755, 14, 819, 961, 2884, 7704, 314, 2569, 21546, 334, 29032, 787, 16898, 83, 402, 314, 2884, 12, 523, 440, 8826, 543, 314, 9195, 2190, 304, 272, 413, 14, 710, 6570, 63, 8727, 9559, 911, 506, 10470, 4453, 314, 1642, 6619, 4110, 2126, 402, 7908, 14, 645, 272, 499, 14, 710, 1015, 1059, 911, 506, 650, 9446, 11673, 701, 17382, 436, 911, 506, 2126, 6296, 25677, 701, 12345, 264, 21873, 12, 32607, 436, 298, 8480, 334, 69, 14, 71, 14, 359, 17, 14, 16, 14, 17, 6575, 710, 1642, 2126, 8135, 8469, 314, 12160, 1015, 12, 314, 3499, 8469, 314, 12612, 2126, 1015, 436, 314, 10919, 8469, 314, 5325, 1015, 14, 272, 650, 14, 3091, 19607, 4528, 3495, 3382, 314, 13618, 26054, 436, 11261, 19607, 402, 2126, 6570, 63, 8727, 12, 5893, 315, 6786, 436, 4528, 3326, 14, 199, 624, 199, 199, 646, 984, 199, 646, 295, 199, 199, 3, 5574, 314, 1414, 1004, 1423, 334, 1589, 1072, 2082, 367, 3394, 14, 72, 9, 199, 692, 334, 552, 8, 1274, 14, 3020, 9, 665, 650, 304, 523, 870, 298, 7692, 26, 1015, 4208, 14, 647, 1324, 63, 694, 1072, 63, 694, 2, 523, 984, 14, 2224, 8, 17, 9, 199, 2836, 26, 523, 1324, 63, 694, 275, 984, 14, 3020, 59, 17, 61, 523, 1072, 63, 694, 275, 984, 14, 3020, 59, 18, 61, 199, 199, 3, 5574, 314, 1642, 6619, 4110, 402, 314, 7908, 14, 645, 570, 199, 888, 63, 493, 275, 1551, 3647, 83, 15, 6472, 14, 645, 2, 450, 1324, 63, 694, 12, 283, 82, 358, 199, 2738, 63, 890, 275, 6619, 199, 21849, 63, 875, 275, 1101, 63, 493, 14, 739, 8, 2738, 63, 890, 9, 199, 888, 63, 493, 14, 1600, 342, 199, 199, 3, 12892, 314, 1015, 1059, 687, 314, 6570, 63, 8727, 9559, 199, 3, 257, 710, 2569, 4205, 63, 5599, 4910, 26, 199, 3, 258, 12892, 7795, 9446, 11673, 701, 17382, 436, 6296, 25677, 701, 12345, 264, 199, 3, 258, 21873, 8, 69, 14, 71, 14, 7369, 17, 14, 16, 14, 17, 12523, 3382, 298, 1348, 63, 8727, 480, 436, 6099, 1674, 4226, 440, 506, 486, 24737, 199, 3, 258, 334, 15279, 365, 314, 2222, 13, 71, 24737, 3305, 9, 3967, 626, 3955, 10299, 315, 8137, 3382, 199, 3, 258, 314, 1642, 26054, 436, 314, 2061, 19607, 315, 314, 570, 14, 199, 1023, 63, 5599, 275, 295, 14, 2014, 8, 82, 2, 1348, 63, 8727, 60, 17140, 25621, 2961, 68, 13439, 14, 2961, 68, 13439, 14, 2961, 68, 13439, 1055, 10, 8995, 4186, 1816, 295, 14, 16504, 9, 199, 1023, 63, 1459, 275, 1015, 63, 5599, 14, 1733, 8, 21849, 63, 875, 9, 199, 8452, 63, 1023, 275, 1015, 63, 1459, 14, 923, 8, 17, 9, 199, 11067, 63, 1023, 275, 1015, 63, 1459, 14, 923, 8, 18, 9, 199, 970, 63, 1023, 275, 1015, 63, 1459, 14, 923, 8, 19, 9, 199, 199, 3, 6990, 314, 1015, 2556, 370, 282, 1406, 570, 370, 506, 5120, 315, 314, 199, 3, 10332, 14, 10265, 570, 14, 199, 493, 63, 576, 275, 408, 501, 199, 501, 3506, 2845, 10362, 1914, 18114, 5749, 13024, 334, 7911, 1265, 883, 3145, 652, 9, 199, 501, 199, 501, 961, 570, 365, 18392, 701, 314, 1015, 4208, 14, 647, 2884, 14, 961, 2884, 199, 501, 365, 7934, 315, 282, 298, 2540, 14914, 2, 1900, 7669, 1380, 6425, 9088, 14, 4857, 14, 961, 199, 501, 1406, 570, 365, 440, 1202, 5309, 18653, 402, 445, 13, 1365, 14, 3898, 728, 12, 652, 9329, 199, 501, 7890, 2005, 1015, 3326, 367, 20584, 315, 314, 10332, 14, 10265, 14, 13821, 402, 199, 501, 642, 12, 781, 787, 440, 440, 15297, 370, 445 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 33, 2884, 370, 9275, 1015, 315, 964, 296, 367, 675, 314, 9088, 10332, 14, 10265, 570, 14, 819, 961, 2884, 5536, 83, 314, 1015, 2556, 687, 314, 7908, 14, 645, 570, 436, 523, 4440, 652, 370, 3550, 282, 1406, 570, 3035, 314, 2011, 2556, 14, 710, 523, 327, 14334, 315, 642, 1406, 570, 911, 506, 5120, 315, 5309, 314, 10152, 402, 523, 314, 10332, 14, 10265, 402, 314, 10059, 12, 15131, 314, 3211, 574, 370, 314, 1015, 523, 9164, 315, 314, 481, 5755, 14, 819, 961, 2884, 7704, 314, 2569, 21546, 334, 29032, 787, 16898, 83, 402, 314, 2884, 12, 523, 440, 8826, 543, 314, 9195, 2190, 304, 272, 413, 14, 710, 6570, 63, 8727, 9559, 911, 506, 10470, 4453, 314, 1642, 6619, 4110, 2126, 402, 7908, 14, 645, 272, 499, 14, 710, 1015, 1059, 911, 506, 650, 9446, 11673, 701, 17382, 436, 911, 506, 2126, 6296, 25677, 701, 12345, 264, 21873, 12, 32607, 436, 298, 8480, 334, 69, 14, 71, 14, 359, 17, 14, 16, 14, 17, 6575, 710, 1642, 2126, 8135, 8469, 314, 12160, 1015, 12, 314, 3499, 8469, 314, 12612, 2126, 1015, 436, 314, 10919, 8469, 314, 5325, 1015, 14, 272, 650, 14, 3091, 19607, 4528, 3495, 3382, 314, 13618, 26054, 436, 11261, 19607, 402, 2126, 6570, 63, 8727, 12, 5893, 315, 6786, 436, 4528, 3326, 14, 199, 624, 199, 199, 646, 984, 199, 646, 295, 199, 199, 3, 5574, 314, 1414, 1004, 1423, 334, 1589, 1072, 2082, 367, 3394, 14, 72, 9, 199, 692, 334, 552, 8, 1274, 14, 3020, 9, 665, 650, 304, 523, 870, 298, 7692, 26, 1015, 4208, 14, 647, 1324, 63, 694, 1072, 63, 694, 2, 523, 984, 14, 2224, 8, 17, 9, 199, 2836, 26, 523, 1324, 63, 694, 275, 984, 14, 3020, 59, 17, 61, 523, 1072, 63, 694, 275, 984, 14, 3020, 59, 18, 61, 199, 199, 3, 5574, 314, 1642, 6619, 4110, 402, 314, 7908, 14, 645, 570, 199, 888, 63, 493, 275, 1551, 3647, 83, 15, 6472, 14, 645, 2, 450, 1324, 63, 694, 12, 283, 82, 358, 199, 2738, 63, 890, 275, 6619, 199, 21849, 63, 875, 275, 1101, 63, 493, 14, 739, 8, 2738, 63, 890, 9, 199, 888, 63, 493, 14, 1600, 342, 199, 199, 3, 12892, 314, 1015, 1059, 687, 314, 6570, 63, 8727, 9559, 199, 3, 257, 710, 2569, 4205, 63, 5599, 4910, 26, 199, 3, 258, 12892, 7795, 9446, 11673, 701, 17382, 436, 6296, 25677, 701, 12345, 264, 199, 3, 258, 21873, 8, 69, 14, 71, 14, 7369, 17, 14, 16, 14, 17, 12523, 3382, 298, 1348, 63, 8727, 480, 436, 6099, 1674, 4226, 440, 506, 486, 24737, 199, 3, 258, 334, 15279, 365, 314, 2222, 13, 71, 24737, 3305, 9, 3967, 626, 3955, 10299, 315, 8137, 3382, 199, 3, 258, 314, 1642, 26054, 436, 314, 2061, 19607, 315, 314, 570, 14, 199, 1023, 63, 5599, 275, 295, 14, 2014, 8, 82, 2, 1348, 63, 8727, 60, 17140, 25621, 2961, 68, 13439, 14, 2961, 68, 13439, 14, 2961, 68, 13439, 1055, 10, 8995, 4186, 1816, 295, 14, 16504, 9, 199, 1023, 63, 1459, 275, 1015, 63, 5599, 14, 1733, 8, 21849, 63, 875, 9, 199, 8452, 63, 1023, 275, 1015, 63, 1459, 14, 923, 8, 17, 9, 199, 11067, 63, 1023, 275, 1015, 63, 1459, 14, 923, 8, 18, 9, 199, 970, 63, 1023, 275, 1015, 63, 1459, 14, 923, 8, 19, 9, 199, 199, 3, 6990, 314, 1015, 2556, 370, 282, 1406, 570, 370, 506, 5120, 315, 314, 199, 3, 10332, 14, 10265, 570, 14, 199, 493, 63, 576, 275, 408, 501, 199, 501, 3506, 2845, 10362, 1914, 18114, 5749, 13024, 334, 7911, 1265, 883, 3145, 652, 9, 199, 501, 199, 501, 961, 570, 365, 18392, 701, 314, 1015, 4208, 14, 647, 2884, 14, 961, 2884, 199, 501, 365, 7934, 315, 282, 298, 2540, 14914, 2, 1900, 7669, 1380, 6425, 9088, 14, 4857, 14, 961, 199, 501, 1406, 570, 365, 440, 1202, 5309, 18653, 402, 445, 13, 1365, 14, 3898, 728, 12, 652, 9329, 199, 501, 7890, 2005, 1015, 3326, 367, 20584, 315, 314, 10332, 14, 10265, 14, 13821, 402, 199, 501, 642, 12, 781, 787, 440, 440, 15297, 370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 1, 1, 1, 1 ]
AladdinSonni/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/tool/steps/ensurebugisopenandassigned.py
135
2061
# 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. from webkitpy.tool.steps.abstractstep import AbstractStep class EnsureBugIsOpenAndAssigned(AbstractStep): def run(self, state): bug = self.cached_lookup(state, "bug") if bug.is_unassigned(): self._tool.bugs.reassign_bug(bug.id()) if bug.is_closed(): # FIXME: We should probably pass this message in somehow? # Right now this step is only used before PostDiff steps, so this is OK. self._tool.bugs.reopen_bug(bug.id(), "Reopening to attach new patch.")
bsd-3-clause
[ 3, 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 18007, 14, 3557, 14, 5895, 14, 6198, 2926, 492, 11836, 7801, 421, 199, 533, 7523, 17545, 1831, 4299, 3325, 2822, 1737, 8, 8458, 7801, 304, 272, 347, 1255, 8, 277, 12, 1174, 304, 267, 6519, 275, 291, 14, 5245, 63, 3892, 8, 929, 12, 298, 1266, 531, 267, 340, 6519, 14, 374, 63, 324, 12941, 837, 288, 291, 423, 3557, 14, 13017, 14, 264, 5038, 63, 1266, 8, 1266, 14, 344, 1012, 398, 340, 6519, 14, 374, 63, 5938, 837, 288, 327, 7600, 26, 2136, 1077, 8646, 986, 642, 1245, 315, 29437, 31, 288, 327, 20854, 3063, 642, 3650, 365, 1454, 1202, 2544, 7711, 10746, 7124, 12, 880, 642, 365, 9949, 14, 288, 291, 423, 3557, 14, 13017, 14, 264, 1490, 63, 1266, 8, 1266, 14, 344, 1062, 298, 497, 21849, 370, 6554, 892, 3371, 2685, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 18007, 14, 3557, 14, 5895, 14, 6198, 2926, 492, 11836, 7801, 421, 199, 533, 7523, 17545, 1831, 4299, 3325, 2822, 1737, 8, 8458, 7801, 304, 272, 347, 1255, 8, 277, 12, 1174, 304, 267, 6519, 275, 291, 14, 5245, 63, 3892, 8, 929, 12, 298, 1266, 531, 267, 340, 6519, 14, 374, 63, 324, 12941, 837, 288, 291, 423, 3557, 14, 13017, 14, 264, 5038, 63, 1266, 8, 1266, 14, 344, 1012, 398, 340, 6519, 14, 374, 63, 5938, 837, 288, 327, 7600, 26, 2136, 1077, 8646, 986, 642, 1245, 315, 29437, 31, 288, 327, 20854, 3063, 642, 3650, 365, 1454, 1202, 2544, 7711, 10746, 7124, 12, 880, 642, 365, 9949, 14, 288, 291, 423, 3557, 14, 13017, 14, 264, 1490, 63, 1266, 8, 1266, 14, 344, 1062, 298, 497, 21849, 370, 6554, 892, 3371, 2685, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
CristinaCristescu/root
bindings/pyroot/JupyROOT/kernel/magics/jsrootmagic.py
27
1240
# -*- coding:utf-8 -*- #----------------------------------------------------------------------------- # Copyright (c) 2016, ROOT Team. # Authors: Danilo Piparo <Danilo.Piparo@cern.ch> CERN #----------------------------------------------------------------------------- from JupyROOT.utils import enableJSVis, disableJSVis, enableJSVisDebug, TBufferJSONErrorMessage, TBufferJSONAvailable from metakernel import Magic, option class JSRootMagics(Magic): def __init__(self, kernel): super(JSRootMagics, self).__init__(kernel) @option('arg', default="on", help='Enable or disable JavaScript visualisation. Possible values: on (default), off') def line_jsroot(self, args): '''Change the visualisation of plots from images to interactive JavaScript objects.''' if args == 'on' or args == '': self.printErrorIfNeeded() enableJSVis() elif args == 'off': disableJSVis() elif args == 'debug': self.printErrorIfNeeded() enableJSVisDebug() def printErrorIfNeeded(self): if not TBufferJSONAvailable(): self.kernel.Error(TBufferJSONErrorMessage) def register_magics(kernel): kernel.register_magics(JSRootMagics)
lgpl-2.1
[ 3, 1882, 2803, 26, 1624, 13, 24, 1882, 199, 18045, 199, 3, 221, 1898, 334, 67, 9, 7800, 12, 16547, 11682, 14, 199, 3, 221, 6642, 26, 24747, 11737, 19835, 462, 79, 665, 29336, 11737, 14, 10542, 462, 79, 32, 22082, 14, 335, 30, 24354, 199, 18045, 199, 199, 504, 1603, 28022, 5441, 14, 1208, 492, 4756, 42, 4985, 374, 12, 3507, 42, 4985, 374, 12, 4756, 42, 4985, 374, 7084, 12, 377, 3299, 6243, 547, 2209, 12, 377, 3299, 6243, 11464, 199, 199, 504, 3404, 4989, 492, 603, 6573, 12, 945, 199, 199, 533, 18001, 6405, 22745, 2932, 8, 45, 6573, 304, 272, 347, 636, 826, 721, 277, 12, 5114, 304, 267, 1613, 8, 11378, 6405, 22745, 2932, 12, 291, 2843, 826, 721, 4989, 9, 272, 768, 1422, 360, 1273, 297, 849, 628, 265, 401, 1720, 534, 6476, 503, 3507, 15250, 13104, 19914, 14, 18558, 1338, 26, 641, 334, 885, 395, 2331, 358, 339, 347, 1004, 63, 3596, 1231, 8, 277, 12, 1249, 304, 267, 1449, 4001, 314, 13104, 19914, 402, 19695, 687, 5935, 370, 12777, 15250, 2251, 10595, 267, 340, 1249, 508, 283, 265, 7, 503, 1249, 508, 8061, 1779, 291, 14, 1361, 547, 3917, 21549, 342, 1779, 4756, 42, 4985, 374, 342, 267, 916, 1249, 508, 283, 1997, 356, 1779, 3507, 42, 4985, 374, 342, 267, 916, 1249, 508, 283, 1757, 356, 1779, 291, 14, 1361, 547, 3917, 21549, 342, 1779, 4756, 42, 4985, 374, 7084, 342, 339, 347, 870, 547, 3917, 21549, 8, 277, 304, 267, 340, 440, 377, 3299, 6243, 11464, 837, 288, 291, 14, 4989, 14, 547, 8, 52, 3299, 6243, 547, 2209, 9, 199, 199, 318, 2274, 63, 5615, 2932, 8, 4989, 304, 272, 5114, 14, 2683, 63, 5615, 2932, 8, 11378, 6405, 22745, 2932, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 1624, 13, 24, 1882, 199, 18045, 199, 3, 221, 1898, 334, 67, 9, 7800, 12, 16547, 11682, 14, 199, 3, 221, 6642, 26, 24747, 11737, 19835, 462, 79, 665, 29336, 11737, 14, 10542, 462, 79, 32, 22082, 14, 335, 30, 24354, 199, 18045, 199, 199, 504, 1603, 28022, 5441, 14, 1208, 492, 4756, 42, 4985, 374, 12, 3507, 42, 4985, 374, 12, 4756, 42, 4985, 374, 7084, 12, 377, 3299, 6243, 547, 2209, 12, 377, 3299, 6243, 11464, 199, 199, 504, 3404, 4989, 492, 603, 6573, 12, 945, 199, 199, 533, 18001, 6405, 22745, 2932, 8, 45, 6573, 304, 272, 347, 636, 826, 721, 277, 12, 5114, 304, 267, 1613, 8, 11378, 6405, 22745, 2932, 12, 291, 2843, 826, 721, 4989, 9, 272, 768, 1422, 360, 1273, 297, 849, 628, 265, 401, 1720, 534, 6476, 503, 3507, 15250, 13104, 19914, 14, 18558, 1338, 26, 641, 334, 885, 395, 2331, 358, 339, 347, 1004, 63, 3596, 1231, 8, 277, 12, 1249, 304, 267, 1449, 4001, 314, 13104, 19914, 402, 19695, 687, 5935, 370, 12777, 15250, 2251, 10595, 267, 340, 1249, 508, 283, 265, 7, 503, 1249, 508, 8061, 1779, 291, 14, 1361, 547, 3917, 21549, 342, 1779, 4756, 42, 4985, 374, 342, 267, 916, 1249, 508, 283, 1997, 356, 1779, 3507, 42, 4985, 374, 342, 267, 916, 1249, 508, 283, 1757, 356, 1779, 291, 14, 1361, 547, 3917, 21549, 342, 1779, 4756, 42, 4985, 374, 7084, 342, 339, 347, 870, 547, 3917, 21549, 8, 277, 304, 267, 340, 440, 377, 3299, 6243, 11464, 837, 288, 291, 14, 4989, 14, 547, 8, 52, 3299, 6243, 547, 2209, 9, 199, 199, 318, 2274, 63, 5615, 2932, 8, 4989, 304, 272, 5114, 14, 2683, 63, 5615, 2932, 8, 11378, 6405, 22745, 2932, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
MihaiMoldovanu/ansible
lib/ansible/plugins/connection/zone.py
21
7937
# Based on local.py (c) 2012, Michael DeHaan <michael.dehaan@gmail.com> # and chroot.py (c) 2013, Maykel Moya <mmoya@speedyrails.com> # and jail.py (c) 2013, Michael Scherer <misc@zarb.org> # (c) 2015, Dagobert Michelsen <dam@baltic-online.de> # (c) 2015, Toshio Kuratomi <tkuratomi@ansible.com> # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type DOCUMENTATION = """ author: Ansible Core Team connection: zone short_description: Run tasks in a zone instance description: - Run commands or put/fetch files to an existing zone version_added: "2.0" options: remote_addr: description: - Zone identifire default: inventory_hostname vars: - name: ansible_host - name: ansible_zone_host """ import distutils.spawn import os import os.path import subprocess import traceback from ansible import constants as C from ansible.errors import AnsibleError from ansible.module_utils.six.moves import shlex_quote from ansible.module_utils._text import to_bytes from ansible.plugins.connection import ConnectionBase, BUFSIZE try: from __main__ import display except ImportError: from ansible.utils.display import Display display = Display() class Connection(ConnectionBase): ''' Local zone based connections ''' transport = 'zone' has_pipelining = True become_methods = frozenset(C.BECOME_METHODS).difference(('su',)) def __init__(self, play_context, new_stdin, *args, **kwargs): super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs) self.zone = self._play_context.remote_addr if os.geteuid() != 0: raise AnsibleError("zone connection requires running as root") self.zoneadm_cmd = to_bytes(self._search_executable('zoneadm')) self.zlogin_cmd = to_bytes(self._search_executable('zlogin')) if self.zone not in self.list_zones(): raise AnsibleError("incorrect zone name %s" % self.zone) @staticmethod def _search_executable(executable): cmd = distutils.spawn.find_executable(executable) if not cmd: raise AnsibleError("%s command not found in PATH" % executable) return cmd def list_zones(self): process = subprocess.Popen([self.zoneadm_cmd, 'list', '-ip'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) zones = [] for l in process.stdout.readlines(): # 1:work:running:/zones/work:3126dc59-9a07-4829-cde9-a816e4c5040e:native:shared s = l.split(':') if s[1] != 'global': zones.append(s[1]) return zones def get_zone_path(self): # solaris10vm# zoneadm -z cswbuild list -p # -:cswbuild:installed:/zones/cswbuild:479f3c4b-d0c6-e97b-cd04-fd58f2c0238e:native:shared process = subprocess.Popen([self.zoneadm_cmd, '-z', to_bytes(self.zone), 'list', '-p'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # stdout, stderr = p.communicate() path = process.stdout.readlines()[0].split(':')[3] return path + '/root' def _connect(self): ''' connect to the zone; nothing to do here ''' super(Connection, self)._connect() if not self._connected: display.vvv("THIS IS A LOCAL ZONE DIR", host=self.zone) self._connected = True def _buffered_exec_command(self, cmd, stdin=subprocess.PIPE): ''' run a command on the zone. This is only needed for implementing put_file() get_file() so that we don't have to read the whole file into memory. compared to exec_command() it looses some niceties like being able to return the process's exit code immediately. ''' # NOTE: zlogin invokes a shell (just like ssh does) so we do not pass # this through /bin/sh -c here. Instead it goes through the shell # that zlogin selects. local_cmd = [self.zlogin_cmd, self.zone, cmd] local_cmd = map(to_bytes, local_cmd) display.vvv("EXEC %s" % (local_cmd), host=self.zone) p = subprocess.Popen(local_cmd, shell=False, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return p def exec_command(self, cmd, in_data=None, sudoable=False): ''' run a command on the zone ''' super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) p = self._buffered_exec_command(cmd) stdout, stderr = p.communicate(in_data) return (p.returncode, stdout, stderr) def _prefix_login_path(self, remote_path): ''' Make sure that we put files into a standard path If a path is relative, then we need to choose where to put it. ssh chooses $HOME but we aren't guaranteed that a home dir will exist in any given chroot. So for now we're choosing "/" instead. This also happens to be the former default. Can revisit using $HOME instead if it's a problem ''' if not remote_path.startswith(os.path.sep): remote_path = os.path.join(os.path.sep, remote_path) return os.path.normpath(remote_path) def put_file(self, in_path, out_path): ''' transfer a file from local to zone ''' super(Connection, self).put_file(in_path, out_path) display.vvv("PUT %s TO %s" % (in_path, out_path), host=self.zone) out_path = shlex_quote(self._prefix_login_path(out_path)) try: with open(in_path, 'rb') as in_file: try: p = self._buffered_exec_command('dd of=%s bs=%s' % (out_path, BUFSIZE), stdin=in_file) except OSError: raise AnsibleError("jail connection requires dd command in the jail") try: stdout, stderr = p.communicate() except: traceback.print_exc() raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path)) if p.returncode != 0: raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, stdout, stderr)) except IOError: raise AnsibleError("file or module does not exist at: %s" % in_path) def fetch_file(self, in_path, out_path): ''' fetch a file from zone to local ''' super(Connection, self).fetch_file(in_path, out_path) display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self.zone) in_path = shlex_quote(self._prefix_login_path(in_path)) try: p = self._buffered_exec_command('dd if=%s bs=%s' % (in_path, BUFSIZE)) except OSError: raise AnsibleError("zone connection requires dd command in the zone") with open(out_path, 'wb+') as out_file: try: chunk = p.stdout.read(BUFSIZE) while chunk: out_file.write(chunk) chunk = p.stdout.read(BUFSIZE) except: traceback.print_exc() raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path)) stdout, stderr = p.communicate() if p.returncode != 0: raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, stdout, stderr)) def close(self): ''' terminate the connection; nothing to do here ''' super(Connection, self).close() self._connected = False
gpl-3.0
[ 3, 21311, 641, 2257, 14, 647, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 436, 32028, 14, 647, 258, 334, 67, 9, 6171, 12, 10162, 75, 352, 3930, 11552, 665, 77, 573, 11552, 32, 7625, 89, 345, 17841, 14, 957, 30, 199, 3, 436, 1335, 1054, 14, 647, 755, 334, 67, 9, 6171, 12, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 3, 334, 67, 9, 6900, 12, 577, 14315, 12504, 603, 1158, 352, 2464, 665, 68, 455, 32, 4982, 764, 13, 15178, 14, 271, 30, 199, 3, 334, 67, 9, 6900, 12, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 1898, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8948, 275, 408, 272, 4132, 26, 2622, 11672, 11682, 272, 1950, 26, 5718, 272, 3974, 63, 1802, 26, 3378, 6527, 315, 282, 5718, 1256, 272, 1369, 26, 267, 446, 3378, 3718, 503, 5324, 15, 3535, 1584, 370, 376, 3411, 5718, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1511, 26, 489, 3982, 63, 2697, 26, 267, 1369, 26, 288, 446, 22518, 16346, 264, 267, 849, 26, 8200, 63, 4269, 267, 6802, 26, 288, 446, 536, 26, 3242, 63, 1102, 288, 446, 536, 26, 3242, 63, 2619, 63, 1102, 199, 624, 199, 199, 646, 7065, 14, 10212, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 646, 5190, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 492, 16701, 63, 3513, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 199, 504, 3242, 14, 5265, 14, 2105, 492, 8113, 1563, 12, 16331, 38, 4305, 421, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 533, 8113, 8, 3225, 1563, 304, 272, 1449, 10111, 5718, 4079, 6947, 1449, 339, 7773, 275, 283, 2619, 7, 272, 965, 63, 4990, 30176, 275, 715, 272, 8649, 63, 2474, 275, 9522, 8, 35, 14, 6773, 1439, 3635, 63, 18383, 680, 9196, 4725, 9648, 16829, 339, 347, 636, 826, 721, 277, 12, 5232, 63, 1100, 12, 892, 63, 6626, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 3225, 12, 291, 2843, 826, 721, 2802, 63, 1100, 12, 892, 63, 6626, 12, 627, 589, 12, 1011, 958, 9, 398, 291, 14, 2619, 275, 291, 423, 2802, 63, 1100, 14, 3846, 63, 2697, 398, 340, 747, 14, 31508, 1535, 342, 1137, 378, 26, 288, 746, 13358, 480, 2619, 1950, 5074, 3879, 465, 1738, 531, 398, 291, 14, 2619, 14464, 63, 1760, 275, 370, 63, 2394, 8, 277, 423, 1733, 63, 5904, 360, 2619, 14464, 1333, 267, 291, 14, 90, 2886, 63, 1760, 275, 370, 63, 2394, 8, 277, 423, 1733, 63, 5904, 360, 90, 2886, 1333, 398, 340, 291, 14, 2619, 440, 315, 291, 14, 513, 63, 13325, 837, 288, 746, 13358, 480, 15448, 5718, 536, 450, 83, 2, 450, 291, 14, 2619, 9, 339, 768, 4639, 272, 347, 485, 1733, 63, 5904, 8, 5904, 304, 267, 2088, 275, 7065, 14, 10212, 14, 1623, 63, 5904, 8, 5904, 9, 267, 340, 440, 2088, 26, 288, 746, 13358, 3647, 83, 1414, 440, 1911, 315, 15097, 2, 450, 7286, 9, 267, 372, 2088, 339, 347, 769, 63, 13325, 8, 277, 304, 267, 2112, 275, 3873, 14, 7942, 779, 277, 14, 2619, 14464, 63, 1760, 12, 283, 513, 297, 2475, 711, 995, 3521, 9009, 29, 5781, 14, 6089, 12, 3521, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 398, 18666, 275, 942, 267, 367, 634, 315, 2112, 14, 2703, 14, 9684, 837, 288, 327, 413, 26, 800, 26, 5720, 11254, 13325, 15, 800, 26, 19, 7957, 3833, 1427, 13, 25, 65, 1780, 13, 2006, 1398, 13, 31414, 25, 13, 65, 31104, 69, 20, 67, 21, 11189, 69, 26, 6106, 26, 5555, 288, 308, 275, 634, 14, 1294, 11633, 288, 340, 308, 59, 17, 61, 1137, 283, 2966, 356, 355, 18666, 14, 740, 8, 83, 59, 17, 566, 398, 372, 18666, 339, 347, 664, 63, 2619, 63, 515, 8, 277, 304, 267, 327, 8597, 4663, 709, 2611, 3, 5718, 14464, 446, 90, 286, 3519, 1506, 769, 446, 80, 267, 327, 446, 26, 29735, 1506, 26, 7657, 11254, 13325, 15, 29735, 1506, 26, 14847, 70, 19, 67, 20, 66, 13, 68, 16, 67, 22, 13, 69, 2576, 66, 13, 2866, 966, 13, 2592, 2010, 70, 18, 67, 996, 1703, 69, 26, 6106, 26, 5555, 267, 2112, 275, 3873, 14, 7942, 779, 277, 14, 2619, 14464, 63, 1760, 12, 2475, 90, 297, 370, 63, 2394, 8, 277, 14, 2619, 395, 283, 513, 297, 2475, 80, 995, 3521, 9009, 29, 5781, 14, 6089, 12, 3521, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 398, 327, 3839, 12, 4635, 275, 299, 14, 10664, 342, 267, 931, 275, 2112, 14, 2703, 14, 9684, 3430, 16, 1055, 1294, 24050, 19, 61, 267, 372, 931, 435, 1994, 1231, 7, 339, 347, 485, 2242, 8, 277, 304, 267, 1449, 4907, 370, 314, 5718, 27, 6548, 370, 886, 2348, 1449, 267, 1613, 8, 3225, 12, 291, 10445, 2242, 342, 267, 340, 440, 291, 423, 7113, 26, 288, 2929, 14, 24622, 480, 24571, 2281, 437, 20639, 3107, 4817, 19253, 401, 1591, 29, 277, 14, 2619, 9, 288, 291, 423, 7113, 275, 715, 339, 347, 485, 17605, 63, 1628, 63, 1531, 8, 277, 12, 2088, 12, 9009, 29, 5781, 14, 6089, 304, 267, 1449, 1255, 282, 1414, 641, 314, 5718, 14, 221, 961, 365, 1454, 4346, 367, 18234, 267, 5324, 63, 493, 342, 664, 63, 493, 342 ]
[ 21311, 641, 2257, 14, 647, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 436, 32028, 14, 647, 258, 334, 67, 9, 6171, 12, 10162, 75, 352, 3930, 11552, 665, 77, 573, 11552, 32, 7625, 89, 345, 17841, 14, 957, 30, 199, 3, 436, 1335, 1054, 14, 647, 755, 334, 67, 9, 6171, 12, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 3, 334, 67, 9, 6900, 12, 577, 14315, 12504, 603, 1158, 352, 2464, 665, 68, 455, 32, 4982, 764, 13, 15178, 14, 271, 30, 199, 3, 334, 67, 9, 6900, 12, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 1898, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8948, 275, 408, 272, 4132, 26, 2622, 11672, 11682, 272, 1950, 26, 5718, 272, 3974, 63, 1802, 26, 3378, 6527, 315, 282, 5718, 1256, 272, 1369, 26, 267, 446, 3378, 3718, 503, 5324, 15, 3535, 1584, 370, 376, 3411, 5718, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1511, 26, 489, 3982, 63, 2697, 26, 267, 1369, 26, 288, 446, 22518, 16346, 264, 267, 849, 26, 8200, 63, 4269, 267, 6802, 26, 288, 446, 536, 26, 3242, 63, 1102, 288, 446, 536, 26, 3242, 63, 2619, 63, 1102, 199, 624, 199, 199, 646, 7065, 14, 10212, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 646, 5190, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 492, 16701, 63, 3513, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 199, 504, 3242, 14, 5265, 14, 2105, 492, 8113, 1563, 12, 16331, 38, 4305, 421, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 533, 8113, 8, 3225, 1563, 304, 272, 1449, 10111, 5718, 4079, 6947, 1449, 339, 7773, 275, 283, 2619, 7, 272, 965, 63, 4990, 30176, 275, 715, 272, 8649, 63, 2474, 275, 9522, 8, 35, 14, 6773, 1439, 3635, 63, 18383, 680, 9196, 4725, 9648, 16829, 339, 347, 636, 826, 721, 277, 12, 5232, 63, 1100, 12, 892, 63, 6626, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 3225, 12, 291, 2843, 826, 721, 2802, 63, 1100, 12, 892, 63, 6626, 12, 627, 589, 12, 1011, 958, 9, 398, 291, 14, 2619, 275, 291, 423, 2802, 63, 1100, 14, 3846, 63, 2697, 398, 340, 747, 14, 31508, 1535, 342, 1137, 378, 26, 288, 746, 13358, 480, 2619, 1950, 5074, 3879, 465, 1738, 531, 398, 291, 14, 2619, 14464, 63, 1760, 275, 370, 63, 2394, 8, 277, 423, 1733, 63, 5904, 360, 2619, 14464, 1333, 267, 291, 14, 90, 2886, 63, 1760, 275, 370, 63, 2394, 8, 277, 423, 1733, 63, 5904, 360, 90, 2886, 1333, 398, 340, 291, 14, 2619, 440, 315, 291, 14, 513, 63, 13325, 837, 288, 746, 13358, 480, 15448, 5718, 536, 450, 83, 2, 450, 291, 14, 2619, 9, 339, 768, 4639, 272, 347, 485, 1733, 63, 5904, 8, 5904, 304, 267, 2088, 275, 7065, 14, 10212, 14, 1623, 63, 5904, 8, 5904, 9, 267, 340, 440, 2088, 26, 288, 746, 13358, 3647, 83, 1414, 440, 1911, 315, 15097, 2, 450, 7286, 9, 267, 372, 2088, 339, 347, 769, 63, 13325, 8, 277, 304, 267, 2112, 275, 3873, 14, 7942, 779, 277, 14, 2619, 14464, 63, 1760, 12, 283, 513, 297, 2475, 711, 995, 3521, 9009, 29, 5781, 14, 6089, 12, 3521, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 398, 18666, 275, 942, 267, 367, 634, 315, 2112, 14, 2703, 14, 9684, 837, 288, 327, 413, 26, 800, 26, 5720, 11254, 13325, 15, 800, 26, 19, 7957, 3833, 1427, 13, 25, 65, 1780, 13, 2006, 1398, 13, 31414, 25, 13, 65, 31104, 69, 20, 67, 21, 11189, 69, 26, 6106, 26, 5555, 288, 308, 275, 634, 14, 1294, 11633, 288, 340, 308, 59, 17, 61, 1137, 283, 2966, 356, 355, 18666, 14, 740, 8, 83, 59, 17, 566, 398, 372, 18666, 339, 347, 664, 63, 2619, 63, 515, 8, 277, 304, 267, 327, 8597, 4663, 709, 2611, 3, 5718, 14464, 446, 90, 286, 3519, 1506, 769, 446, 80, 267, 327, 446, 26, 29735, 1506, 26, 7657, 11254, 13325, 15, 29735, 1506, 26, 14847, 70, 19, 67, 20, 66, 13, 68, 16, 67, 22, 13, 69, 2576, 66, 13, 2866, 966, 13, 2592, 2010, 70, 18, 67, 996, 1703, 69, 26, 6106, 26, 5555, 267, 2112, 275, 3873, 14, 7942, 779, 277, 14, 2619, 14464, 63, 1760, 12, 2475, 90, 297, 370, 63, 2394, 8, 277, 14, 2619, 395, 283, 513, 297, 2475, 80, 995, 3521, 9009, 29, 5781, 14, 6089, 12, 3521, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 398, 327, 3839, 12, 4635, 275, 299, 14, 10664, 342, 267, 931, 275, 2112, 14, 2703, 14, 9684, 3430, 16, 1055, 1294, 24050, 19, 61, 267, 372, 931, 435, 1994, 1231, 7, 339, 347, 485, 2242, 8, 277, 304, 267, 1449, 4907, 370, 314, 5718, 27, 6548, 370, 886, 2348, 1449, 267, 1613, 8, 3225, 12, 291, 10445, 2242, 342, 267, 340, 440, 291, 423, 7113, 26, 288, 2929, 14, 24622, 480, 24571, 2281, 437, 20639, 3107, 4817, 19253, 401, 1591, 29, 277, 14, 2619, 9, 288, 291, 423, 7113, 275, 715, 339, 347, 485, 17605, 63, 1628, 63, 1531, 8, 277, 12, 2088, 12, 9009, 29, 5781, 14, 6089, 304, 267, 1449, 1255, 282, 1414, 641, 314, 5718, 14, 221, 961, 365, 1454, 4346, 367, 18234, 267, 5324, 63, 493, 342, 664, 63, 493, 342, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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